[Vm-dev] VM Maker: VMMaker.oscog-tty.616.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 15 21:10:19 UTC 2014


Timothy M uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-tty.616.mcz

==================== Summary ====================

Name: VMMaker.oscog-tty.616
Author: tty
Time: 15 February 2014, 4:06:33.43 pm
UUID: 6cf1ed46-20ba-4278-b333-414f6b4ae39a
Ancestors: VMMaker.oscog-dtl.615, VMMaker.oscog-tty.614

Started with a clean Squeak4.5-13675 RC4 image. 
Loaded VMMaker.oscog-dtl.615 etc.

Filein VMMaker-InterpreterSimulation-Morphic category and classes.

Merged in StackInterpreterSimulator changes required for event forwarding from VMMaker.oscog-tty.614

Saved this to local repository.

Copy this to live repository.

=============== Diff against VMMaker.oscog-dtl.615 ===============

Item was changed:
  SystemOrganization addCategory: #'VMMaker-Building'!
- SystemOrganization addCategory: #'VMMaker-JIT'!
  SystemOrganization addCategory: #'VMMaker-Interpreter'!
  SystemOrganization addCategory: #'VMMaker-InterpreterSimulation'!
+ SystemOrganization addCategory: #'VMMaker-InterpreterSimulation-Morphic'!
+ SystemOrganization addCategory: #'VMMaker-JIT'!
  SystemOrganization addCategory: #'VMMaker-JITSimulation'!
+ SystemOrganization addCategory: #'VMMaker-Multithreading'!
+ SystemOrganization addCategory: #'VMMaker-Plugins'!
+ SystemOrganization addCategory: #'VMMaker-Plugins-Alien'!
- SystemOrganization addCategory: #'VMMaker-Translation to C'!
- SystemOrganization addCategory: #'VMMaker-Support'!
  SystemOrganization addCategory: #'VMMaker-PostProcessing'!
+ SystemOrganization addCategory: #'VMMaker-SmartSyntaxPlugins'!
  SystemOrganization addCategory: #'VMMaker-SpurMemoryManager'!
  SystemOrganization addCategory: #'VMMaker-SpurMemoryManagerSimulation'!
+ SystemOrganization addCategory: #'VMMaker-Support'!
- SystemOrganization addCategory: #'VMMaker-Multithreading'!
  SystemOrganization addCategory: #'VMMaker-Tests'!
+ SystemOrganization addCategory: #'VMMaker-Translation to C'!
- SystemOrganization addCategory: #'VMMaker-Plugins'!
- SystemOrganization addCategory: #'VMMaker-SmartSyntaxPlugins'!
- SystemOrganization addCategory: #'VMMaker-Plugins-Alien'!

Item was changed:
  SharedPool subclass: #CogRTLOpcodes
  	instanceVariableNames: ''
+ 	classVariableNames: 'AddCqR AddCwR AddRR AddRdRd AlignmentNops AndCqR AndCwR AndRR Arg0Reg Arg1Reg ArithmeticShiftRightCqR ArithmeticShiftRightRR Call ClassReg CmpCqR CmpCwR CmpRR CmpRdRd ConvertRRd DPFPReg0 DPFPReg1 DPFPReg2 DPFPReg3 DPFPReg4 DPFPReg5 DPFPReg6 DPFPReg7 DivRdRd FPReg Fill16 Fill32 Fill8 FillBytesFrom FillFromWord FirstJump FirstShortJump GPRegMax GPRegMin Jump JumpAbove JumpAboveOrEqual JumpBelow JumpBelowOrEqual JumpCarry JumpFPEqual JumpFPGreater JumpFPGreaterOrEqual JumpFPLess JumpFPLessOrEqual JumpFPNotEqual JumpFPOrdered JumpFPUnordered JumpGreater JumpGreaterOrEqual JumpLess JumpLessOrEqual JumpLong JumpLongNonZero JumpLongZero JumpNegative JumpNoCarry JumpNoOverflow JumpNonNegative JumpNonZero JumpOverflow JumpR JumpZero Label LastJump LastRTLCode LinkReg LoadEffectiveAddressMwrR LoadEffectiveAddressXowrR LogicalShiftLeftCqR LogicalShiftLeftRR LogicalShiftRightCqR LogicalShiftRightRR MoveAbR MoveAwR MoveC32R MoveC64R MoveCqR MoveCwR MoveM16rR MoveM32rR MoveM64rRd MoveMbrR MoveMwrR MoveRAw MoveRM16r MoveRM32r MoveRMbr MoveRMwr MoveRR MoveRX16rR MoveRX32rR MoveRXbrR MoveRXowr MoveRXwrR MoveRdM64r MoveRdRd MoveX16rRR MoveX32rRR MoveXbrRR MoveXowrR MoveXwrRR MulCqR MulCwR MulRR MulRdRd NegateR Nop OrCqR OrCwR OrRR PopR PrefetchAw PushCw PushR ReceiverResultReg RetN SPReg SendNumArgsReg SqrtRd SubCqR SubCwR SubRR SubRdRd TempReg XorCqR XorCwR XorRR'
- 	classVariableNames: 'AddCqR AddCwR AddRR AddRdRd AlignmentNops AndCqR AndCwR AndRR Arg0Reg Arg1Reg ArithmeticShiftRightCqR ArithmeticShiftRightRR Call ClassReg CmpCqR CmpCwR CmpRR CmpRdRd ConvertRRd DPFPReg0 DPFPReg1 DPFPReg2 DPFPReg3 DPFPReg4 DPFPReg5 DPFPReg6 DPFPReg7 DivRdRd FPReg Fill16 Fill32 Fill8 FillBytesFrom FillFromWord FirstJump FirstShortJump GPRegMax GPRegMin Jump JumpAbove JumpAboveOrEqual JumpBelow JumpBelowOrEqual JumpCarry JumpFPEqual JumpFPGreater JumpFPGreaterOrEqual JumpFPLess JumpFPLessOrEqual JumpFPNotEqual JumpFPOrdered JumpFPUnordered JumpGreater JumpGreaterOrEqual JumpLess JumpLessOrEqual JumpLong JumpLongNonZero JumpLongZero JumpNegative JumpNoCarry JumpNoOverflow JumpNonNegative JumpNonZero JumpOverflow JumpR JumpZero Label LastJump LastRTLCode LinkReg LoadEffectiveAddressMwrR LogicalShiftLeftCqR LogicalShiftLeftRR LogicalShiftRightCqR LogicalShiftRightRR MoveAbR MoveAwR MoveC32R MoveC64R MoveCqR MoveCwR MoveM16rR MoveM64rRd MoveMbrR MoveMwrR MoveRAw MoveRM16r MoveRMbr MoveRMwr MoveRR MoveRX16rR MoveRXbrR MoveRXowr MoveRXwrR MoveRdM64r MoveRdRd MoveX16rRR MoveXbrRR MoveXowrR MoveXwrRR MulCqR MulCwR MulRR MulRdRd NegateR Nop OrCqR OrCwR OrRR PopR PrefetchAw PushCw PushR ReceiverResultReg RetN SPReg SendNumArgsReg SqrtRd SubCqR SubCwR SubRR SubRdRd TempReg XorCqR XorCwR XorRR'
  	poolDictionaries: ''
  	category: 'VMMaker-JIT'!
  
  !CogRTLOpcodes commentStamp: '<historical>' prior: 0!
  I am a pool for the Register-Transfer-Language to which Cog compiles.  I define unique integer values for all RTL opcodes and abstract registers.  See CogAbstractInstruction for instances of instructions with the opcodes that I define.!

Item was changed:
  StackInterpreterPrimitives subclass: #StackInterpreterSimulator
+ 	instanceVariableNames: 'bootstrapping byteCount breakCount sendCount printSends printReturns traceOn myBitBlt displayForm filesOpen imageName pluginList mappedPluginEntries quitBlock transcript displayView printFrameAtEachStep printBytecodeAtEachStep systemAttributes startMicroseconds externalSemaphoreSignalRequests externalSemaphoreSignalResponses extSemTabSize atEachStepBlock disableBooleanCheat performFilters eventQueue'
- 	instanceVariableNames: 'bootstrapping byteCount breakCount sendCount printSends printReturns traceOn myBitBlt displayForm filesOpen imageName pluginList mappedPluginEntries quitBlock transcript displayView printFrameAtEachStep printBytecodeAtEachStep systemAttributes startMicroseconds externalSemaphoreSignalRequests externalSemaphoreSignalResponses extSemTabSize atEachStepBlock disableBooleanCheat performFilters'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'VMMaker-InterpreterSimulation'!
  
  !StackInterpreterSimulator commentStamp: 'eem 9/3/2013 11:05' prior: 0!
  This class defines basic memory access and primitive simulation so that the StackInterpreter can run simulated in the Squeak environment.  It also defines a number of handy object viewing methods to facilitate pawing around in the object memory.
  
  To see the thing actually run, you could (after backing up this image and changes), execute
  
  	(StackInterpreterSimulator new openOn: Smalltalk imageName) test
  
  	((StackInterpreterSimulator newWithOptions: #(NewspeakVM true MULTIPLEBYTECODESETS true))
  		openOn: 'ns101.image') test
  
  and be patient both to wait for things to happen, and to accept various things that may go wrong depending on how large or unusual your image may be.  We usually do this with a small and simple benchmark image.
  
  Here's an example of what Eliot uses to launch the simulator in a window.  The bottom-right window has a menu packed with useful stuff:
  
  | vm |
  vm := StackInterpreterSimulator newWithOptions: #().
  vm openOn: '/Users/eliot/Squeak/Squeak4.4/trunk44.image'.
  vm setBreakSelector: #&.
  vm openAsMorph; run!

Item was added:
+ ----- Method: StackInterpreterSimulator>>displayForm (in category 'accessing') -----
+ displayForm
+ 	"The VM SImulator draws directly on an imageMorph named displayView
+ 	  displayView is housed on a Form named displayForm
+ 	  displayForm is initialized in my initialize method. 
+ 	  it 'needs' to be initialized there to support Eliot's legacy openAsMorph functionality
+ 	"
+ 	^displayForm!

Item was added:
+ ----- Method: StackInterpreterSimulator>>displayView (in category 'accessing') -----
+ displayView
+ 	"The VM SImulator draws directly on an imageMorph named displayView
+ 	  displayView is housed on a Form named displayForm
+ 	  Since this is housed directly on the Morph, I have this tight compling from here->model->morph. 
+ 	"
+ 	self flag: 'tty'.	
+ 	^displayView!

Item was added:
+ ----- Method: StackInterpreterSimulator>>displayView: (in category 'accessing') -----
+ displayView: anImageMorph
+ 	"The VM SImulator draws directly on an imageMorph named displayView
+ 	  displayView is housed on a Form named displayForm
+ 	  Since this is housed directly on the Morph, I have this tight compling from here->model->morph. 
+ 	"
+ 	self flag: 'tty'.
+ 	displayView := anImageMorph!

Item was changed:
  ----- Method: StackInterpreterSimulator>>incrementByteCount (in category 'interpreter shell') -----
  incrementByteCount
  	(byteCount := byteCount + 1) = breakCount ifTrue:
  		[self doOrDefer: [self changed: #byteCountText].
  		 self halt].
  	byteCount \\ 1000 = 0 ifTrue:
  		[self doOrDefer: [self changed: #byteCountText].
  		 self forceInterruptCheck.
+ 		 byteCount \\ 1000 = 0 ifTrue: [self fullDisplayUpdate]] "tty. denominator was 10000 before event forwarding. Refactor me."!
- 		 byteCount \\ 10000 = 0 ifTrue: [self fullDisplayUpdate]]!

Item was changed:
  ----- Method: StackInterpreterSimulator>>initialize (in category 'initialization') -----
  initialize
  	"Initialize the StackInterpreterSimulator when running the interpreter
  	 inside Smalltalk. The primary responsibility of this method is to allocate
  	 Smalltalk Arrays for variables that will be declared as statically-allocated
  	 global arrays in the translated code."
  
  	bootstrapping := false.
  
  	objectMemory ifNil:
  		[objectMemory := self class objectMemoryClass simulatorClass new].
  	objectMemory coInterpreter: self.
  
  	"Note: we must initialize ConstMinusOne differently for simulation,
  		due to the fact that the simulator works only with +ve 32-bit values"
  	ConstMinusOne := objectMemory integerObjectOf: -1.
  
  	methodCache := Array new: MethodCacheSize.
  	atCache := Array new: AtCacheTotalSize.
  	self flushMethodCache.
  	gcSemaphoreIndex := 0.
  	externalSemaphoreSignalRequests := externalSemaphoreSignalResponses := #().
  	externalPrimitiveTable := CArrayAccessor on: (Array new: MaxExternalPrimitiveTableSize).
  	externalPrimitiveTableFirstFreeIndex := 0.
  	primitiveTable := self class primitiveTable copy.
  	objectMemory hasSpurMemoryManagerAPI
  		ifTrue:
  			[primitiveAccessorDepthTable := self class primitiveAccessorDepthTable.
  			 pluginList := {}]
  		ifFalse:
  			[pluginList := {'' -> self }].
  	mappedPluginEntries := OrderedCollection new.
  	desiredNumStackPages := desiredEdenBytes := 0.
  	"This is initialized on loading the image, but convenient for testing stack page values..."
  	numStackPages := self defaultNumStackPages. 
  	startMicroseconds := Time totalSeconds * 1000000.
  
  	"initialize InterpreterSimulator variables used for debugging"
  	byteCount := 0.
  	sendCount := 0.
  	quitBlock := [^ self].
  	traceOn := true.
  	printSends := printReturns := printFrameAtEachStep := printBytecodeAtEachStep := false.
  	myBitBlt := BitBltSimulator new setInterpreter: self.
  	transcript := Transcript.
  	displayForm := 'Display has not yet been installed' asDisplayText form.
  	suppressHeartbeatFlag := false.
  	systemAttributes := Dictionary new.
  	extSemTabSize := 256.
+ 	disableBooleanCheat := false.
+ 
+ 	"Forward events from the host to the Simulator tty"
+ 	eventQueue := SharedQueue new.!
- 	disableBooleanCheat := false!

Item was changed:
  ----- Method: StackInterpreterSimulator>>ioGetNextEvent: (in category 'I/O primitives') -----
  ioGetNextEvent: evtBuf
+ 	| evt  |
+ 	"StackInterpreterSimulatorMorphicModel browse"
+ 	eventQueue isNil ifTrue: 
+ 		[^self primitiveFail].
+ 	eventQueue isEmpty
+ 		ifFalse:
+ 			[	evt :=  eventQueue next.
+ 			      1 to: (evt size) do: [:i | ((evt at: i) isNil) ifFalse: [evtBuf at: (i - 1) put: (evt at: i)]]].
+ 	 self success: true.
- 
- 	self primitiveFail.
  !

Item was added:
+ ----- Method: StackInterpreterSimulator>>openAsStackInterpreterSimulatorMorph (in category 'UI') -----
+ openAsStackInterpreterSimulatorMorph
+ 	"Open a morphic view on this simulation. ala Bert Freudenberg's
+ 	SqueakJS http://lively-web.org/users/bert/squeak.html	"
+ 	| localImageName borderWidth window |
+ 	localImageName := imageName
+ 				ifNil: [' synthetic image']
+ 				ifNotNil: [FileDirectory default localNameFor: imageName].
+ 
+ 	transcript := TranscriptStream
+ 				on: (String new: 10000).
+ 
+ 	window := StackInterpreterSimulatorMorph	
+ 					withVMSimulator: self 
+ 					title: 'Simulation of ' , localImageName, ' (beta)'
+ 					transcript: transcript.				
+ 
+ 	borderWidth := [StackInterpreterSimulatorMorph borderWidth
+ 			"Squeak 4.1"]
+ 				on: MessageNotUnderstood
+ 				do: [:ex | 0].
+ 	"3.8"
+ 	borderWidth := borderWidth + window borderWidth.
+ 	window openInWorldExtent: (self desiredDisplayExtent + (2 * borderWidth) + (0 @ window labelHeight) * (1 @ (1 / 0.8))) rounded.
+ 	^ window!

Item was added:
+ ----- Method: StackInterpreterSimulator>>queueForwardedEvent: (in category 'event forwarding') -----
+ queueForwardedEvent:evt
+ 	eventQueue isNil
+ 		ifTrue:[eventQueue := SharedQueue new].
+ 	eventQueue nextPut: evt.!

Item was added:
+ ----- Method: StackInterpreterSimulator>>toggleTranscriptForSimulatorMorph: (in category 'UI') -----
+ toggleTranscriptForSimulatorMorph: aTranscriptStreamOrTranscript
+ 	"tty think this through when not so tired"
+ 	self flag: 'tty'.
+ 	transcript ifNil: [transcript := Transcript. ^self].
+ 	displayView ifNil: [^self changed: #flash].
+ 	transcript := transcript = Transcript
+ 					ifTrue: [aTranscriptStreamOrTranscript]
+ 					ifFalse: [Transcript]!

Item was changed:
+ ----- Method: StackInterpreterSimulator>>transcript (in category 'accessing') -----
- ----- Method: StackInterpreterSimulator>>transcript (in category 'simulation only') -----
  transcript
+ 	"tty accessor needed by StackInstperpeterSimulatorMorphicModel"
+ 		^transcript!
- 	^transcript!

Item was changed:
+ ----- Method: StackInterpreterSimulator>>transcript: (in category 'accessing') -----
- ----- Method: StackInterpreterSimulator>>transcript: (in category 'simulation only') -----
  transcript: aTranscript
+ 	"tty accessor needed by StackInstperpeterSimulatorMorphicModel"
+ 		transcript := aTranscript!
- 	transcript := aTranscript!

Item was added:
+ Object subclass: #StackInterpreterSimulatorEventTransformer
+ 	instanceVariableNames: ''
+ 	classVariableNames: 'Default'
+ 	poolDictionaries: 'EventSensorConstants'
+ 	category: 'VMMaker-InterpreterSimulation-Morphic'!
+ 
+ !StackInterpreterSimulatorEventTransformer commentStamp: 'tty 2/8/2014 12:54' prior: 0!
+ A StackInterpreterSimulatorEventUnwrapper takes events as wrapped by HandMorph and converts them to a form a StackInterpreterSimulator can deal with.
+ 
+ See HandMorph >> handleEvent to see what the wrapping entails.
+ See HandMorph >> ProcessEvents  or EventSensor >> fetchMoreEvents for examples of what an unwrapped event looks like when given to the system
+ 
+ 
+ for pre-wrapping
+ 
+ Instance Variables
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer class>>default (in category 'initialize-release') -----
+ default
+ 	^Default ifNil:[Default := self new]!

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer>>degenerateEvent: (in category 'event transformation') -----
+ degenerateEvent: aMorphicEvent
+ 	"tty. Bert had mentioned a distinction between events and polling events and that Morphic could handle both.
+ 	I don't know what he is talking about."	
+ 	| evt type |
+ 	self flag:'tty'.
+ 
+ 	evt := nil.	
+ 	type := aMorphicEvent type.
+ "	Transcript show:type;cr."
+ 	(('mouse' charactersExactlyMatching: type asString) > 4)  "mous"
+ 		ifTrue: [^self degenerateMouseEvent: aMorphicEvent].
+ 	(('key' charactersExactlyMatching: type asString) > 2)  "key"
+ 		ifTrue: [^self degenerateKeyboardEvent: aMorphicEvent].
+ "	type = EventTypeDragDropFiles ifTrue: [evt := self generateDropFilesEvent: evtBuf].
+ 	type = EventTypeWindow	ifTrue:[evt := self generateWindowEvent: evtBuf]."
+ 
+ 	^ #(0 0 0 0 0 0 0 0).!

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer>>degenerateKeyboardEvent: (in category 'event transformation') -----
+ degenerateKeyboardEvent: aMorphicEvent
+ 	| evt |
+ 	"see HandMorph>>generateKeyboardEvent and EventSensor class comment"
+ 	evt := {2 . 0 . 0 . 0 . 0. 0 . 0 . 0}.
+ 	
+ 	evt at:2 put: aMorphicEvent timeStamp.
+ 	evt at:3 put: aMorphicEvent keyValue.    "<--this is wrong. See Sensor FirstEvt: for what needs to happen. hooo boy"
+ 	evt at:4 put: aMorphicEvent position y.
+ 	evt at:5 put: (aMorphicEvent buttons bitAnd: 7).  "thanks Ron T."
+ 	evt at:6 put: (aMorphicEvent buttons >> 3).     "Thanks dtl"
+ 	^evt
+ 
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer>>degenerateMouseButtonEvent: (in category 'event transformation') -----
+ degenerateMouseButtonEvent: aMorphicEvent
+ 	| evt |
+ 	"see HandMorph>>generateMouseEvent"
+ 	evt := {1 . 0 . 0 . 0 . 0. 0 . 0 . 0}.
+ 	
+ 	evt at:2 put: aMorphicEvent timeStamp.
+ 	evt at:3 put: aMorphicEvent position x.
+ 	evt at:4 put: aMorphicEvent position y.
+ 	evt at:5 put: (aMorphicEvent buttons bitAnd: 7).  "thanks Ron T."
+ 	evt at:6 put: (aMorphicEvent buttons >> 3).     "Thanks dtl"
+ 	^evt
+ 
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer>>degenerateMouseEvent: (in category 'event transformation') -----
+ degenerateMouseEvent: aMorphicEvent
+ 	"see HandMorph>>generateMouseEvent"
+ 
+ 	(aMorphicEvent type) = #mouseMove
+ 		ifTrue:[^self degenerateMouseMoveEvent: aMorphicEvent].	
+ 
+ 	((aMorphicEvent type) = #mouseUp) |  ((aMorphicEvent type) = #mouseDown)
+ 		ifTrue:[^self degenerateMouseButtonEvent: aMorphicEvent].	
+ "	(aMorphicEvent type) = #mouseDrag
+ 		ifTrue:[evt := self degenerateMouseDragEvent: aMorphicEvent].	
+ "
+ 	^{0 . 0. 0. 0. 0. 0. 0. 0}.!

Item was added:
+ ----- Method: StackInterpreterSimulatorEventTransformer>>degenerateMouseMoveEvent: (in category 'event transformation') -----
+ degenerateMouseMoveEvent: aMorphicEvent
+ 	| evt |
+ 	"see HandMorph>>generateMouseEvent"
+ 	evt := {1 . 0 . 0 . 0 . 0. 0 . 0 . 0}.
+ 	
+ 	evt at:2 put: aMorphicEvent timeStamp.
+ 	evt at:3 put: aMorphicEvent position x.
+ 	evt at:4 put: aMorphicEvent position y.
+ 	evt at:5 put: (aMorphicEvent buttons bitAnd: 7).  "thanks Ron T."
+ 	evt at:6 put: (aMorphicEvent buttons >> 3).     "Thanks dtl"
+ 	^evt
+ 
+ 
+ !

Item was added:
+ ImageMorph subclass: #StackInterpreterSimulatorImageMorph
+ 	instanceVariableNames: 'eventForwarder'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'VMMaker-InterpreterSimulation-Morphic'!
+ 
+ !StackInterpreterSimulatorImageMorph commentStamp: 'tty 2/5/2014 12:28' prior: 0!
+ A StackInterpreterSimulatorImageMorph is an ImageMorph The StackInterpreterSimulator paints its world on me.
+ 
+ If tty can get event forwarding working along the HandMorph->StackInterpreterSimulatorMorphicModel->StackInterpreterSimulator path, then then I don't need to exist.
+ 
+ If event forwarding attempt above fails, then I may need to handle it.
+ 
+ 
+ Instance Variables
+ 
+ !

Item was added:
+ SystemWindow subclass: #StackInterpreterSimulatorMorph
+ 	instanceVariableNames: 'loadButton helpButton resetButton stepButton overButton sendButton returnButton runButton toggleTranscriptButton optionsButton transcriptPanel commandPanel contextPanel stackPanel callStackPanel displayForm displayView eventEncoder ioExitButton fullDisplayUpdateButton forceInterruptCheckButton hackButton'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'VMMaker-InterpreterSimulation-Morphic'!
+ 
+ !StackInterpreterSimulatorMorph commentStamp: 'tty 2/5/2014 12:11' prior: 0!
+ A StackInterpreterSimulatorMorph is a copy of PreferenceBrowserMorph that has been mangled into something that will support the StackInterpreterSimulator.
+ 
+ I provide some UI features inspired by  Bert Freudenberg's Lively Squeak VM at http://lively-web.org/users/bert/squeak.html
+ 
+ See class protocol 'documentation' for examples of invoking me.
+ 
+ My model is StackInterpreterSimulatorMorphicModel. 
+ My model has a reference to the StackInterpreterSimulator and itermediates all (?) interaction with it.
+ 
+ The StackInterpreterSimulator renders the simulated World on a StackInterpreterSimulatorImageMorph that I contain. 
+ 
+ There is some cruft (tight coupling via direct references along all three layers UI-Model-VM )in me that exists to support Eliot's original StackInterpreterSimulator>>openAsMorph functionality and use-case.
+ Rumors that said cruft is an artifact of tty's rudimentary Morphic skills are entirely credible.
+ 
+ I hold out the barest glimmer of hope that Bert Freudenberg's SqueakJS functionality can be integrated into my functionality as well. 
+ see http://lively-web.org/users/bert/squeak.html for the inspiration.
+ 
+ I am not amenable to Flaps or the WorldMenu as there is a lot of pre-run configuration that is done to the Simulator prior to its being run.
+ Managing that ability with a GUI is counter-productive. If said functionality is desired in the future, then inspiration can be gleaned by cut-n-paste from PreferenceBrowser and PreferenceBrowserModel.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph class>>ttyOne (in category 'documentation') -----
+ ttyOne
+ "Script tty uses to run the stackIntepreter using this class"
+ | vm |
+ Transcript clear.
+ vm := StackInterpreterSimulator newWithOptions: #(#STACKVM).
+ vm openOn: '/home/tty/usr/src/smalltalk/buildCogDevelopmentImageCog.app/Contents/Resources/targets/Squeak4.5.image'.
+ "vm setBreakSelector: #&."
+ vm 
+ 	openAsStackInterpreterSimulatorMorph "; 
+ 	toggleTranscript;
+ 	halt;
+ 	run"
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph class>>withVMSimulator:title:transcript: (in category 'instance creation') -----
+ withVMSimulator: aStackInterpreterSimulatorMorphicModel title: aString transcript: aTranscript
+ 	^self new initializeWithVMSimulator: aStackInterpreterSimulatorMorphicModel title: aString aTranscript: aTranscript;
+ 		yourself.
+ 		
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>basicButton (in category 'submorphs - buttons') -----
+ basicButton
+ 	| button |
+ 	button := SimpleButtonMorph new.
+ 	button
+ 		borderWidth: 2;
+ 		borderColor: #raised;
+ 		on: #mouseEnter send: #value to: [button borderColor: self paneColor];
+ 		on: #mouseLeave send: #value to: [button borderColor: #raised];
+ 		vResizing: #spaceFill;
+ 		useRoundedCorners;
+ 		clipSubmorphs: true;
+ 		color: self paneColor muchLighter;
+ 		target: self model.
+ 	^button!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>buttonRowLayoutFrame (in category 'submorphs - buttons') -----
+ buttonRowLayoutFrame 
+ 	^LayoutFrame fractions: (0 at 0 corner: 1 at 0) offsets: (0 at 0 corner: 0@ (TextStyle defaultFont height * 2.5))
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>callStackPanel (in category 'submorphs - squeakJS') -----
+ callStackPanel
+ 	"If any Morphic gurus exist, please have at it."
+ 	^callStackPanel ifNil: 
+ 		[callStackPanel :=  (PluggableTextMorph
+ 				on: self model
+ 				text: #processesAndContextStack
+ 				accept: nil
+ 				readSelection: nil
+ 				menu: nil) hideScrollBarsIndefinitely.
+ 		callStackPanel		
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself].
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>commandPanel (in category 'submorphs - simulator panel') -----
+ commandPanel
+ 	self flag: 'tty'. "does this hybrid of PreferenceBrowser layout and Simulato openAsMorph stuff make sense?"
+ 	^commandPanel ifNil: 
+ 		[commandPanel :=  (PluggableTextMorph
+ 				on: self model vm
+ 				text: #byteCountText
+ 				accept: nil
+ 				readSelection: nil
+ 				menu: #utilitiesMenu:) hideScrollBarsIndefinitely.
+ 		commandPanel		
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself].
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>contextPanel (in category 'submorphs - squeakJS') -----
+ contextPanel
+ 	"This should show the currentContext and Special Objects array. as seen at SqueakJS
+ 	  Doing that requires real talent. talent tty is lacking at the moment
+ 							on: [ Array with:  (MorphWithSubmorphsWrapper with: self)  ]	
+ 	Array with: (ObjectExplorerWrapper with: rootObject name: 'root' model: self parent: nil)
+ 	"
+ 	^contextPanel ifNil: 
+ 		[contextPanel := (SimpleHierarchicalListMorph
+ 							on: [ Array with: (ObjectExplorerWrapper with: (self model vm) name: 'root' model: (self model vm) parent: nil) ]
+ 							list: #value
+ 							selected: nil
+ 							changeSelected: nil
+ 							menu: nil
+ 							keystroke: nil) showScrollBarsOnlyWhenNeeded: true.
+ 		contextPanel		
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself]
+ 
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>displayView (in category 'submorphs - simulator display view') -----
+ displayView
+ 	"The VM SImulator draws directly on an imageMorph named displayView
+ 	  displayView is housed on a Form named displayForm
+ 	   displayForm is initialized in StackInterpreterSimulator >> initialize.
+ 	  see StackInterpreterSimulator >>openAsMorph for original constructs.
+ 	"
+ 	^displayView ifNil: 
+ 		[displayView :=  (StackInterpreterSimulatorImageMorph new image: (model vm displayForm)). 
+ 		(self model) displayView: displayView.					
+ 		(self model) morph: displayView. "<-- N.B.. morph bounds are used to filter events in the model. tty"
+ 	      displayView activeHand addEventListener: self model.		
+ 					
+  		displayView		
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself
+ 			].
+ 
+ 
+ 	
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>displayViewLayoutFrame (in category 'submorphs - simulator display view') -----
+ displayViewLayoutFrame 
+ 	| squeakJSFrame buttonFrame simulatorFrame|
+ 	"if any Morphic guru's understand layouts and offsets, please fix this. tty"
+ 	buttonFrame := self buttonRowLayoutFrame.
+ 	squeakJSFrame := self squeakJSRowLayoutFrame.
+ 	simulatorFrame := self simulatorLayoutFrame..
+ 	^LayoutFrame fractions: (0 at 0 corner: 1 at 1) 
+ 				    offsets: (0@(buttonFrame bottomOffset) corner: simulatorFrame leftOffset at squeakJSFrame topOffset)!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>extent: (in category 'geometry') -----
+ extent: aPoint
+ 	super extent: aPoint.
+ 	self fullBounds.
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>forceInterruptCheckButton (in category 'submorphs - buttons') -----
+ forceInterruptCheckButton
+ 	self flag: 'tty'.
+ 	^forceInterruptCheckButton ifNil: 
+ 		[forceInterruptCheckButton := self basicButton 
+ 						label: 'vm forceInterruptCheck' translated; 
+ 						actionSelector: #forceInterruptCheck;						
+ 						setBalloonText: 
+ 							'Invoke forceInterruptCheck on Simulator.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>fullDisplayUpdateButton (in category 'submorphs - buttons') -----
+ fullDisplayUpdateButton
+ 	self flag: 'tty'.
+ 	^fullDisplayUpdateButton ifNil: 
+ 		[fullDisplayUpdateButton := self basicButton 
+ 						label: 'vm fullDisplayUpdate' translated; 
+ 						actionSelector: #fullDisplayUpdate;						
+ 						setBalloonText: 
+ 							'Invoke fullDisplayUpdate on Simulator.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>hackButton (in category 'submorphs - buttons') -----
+ hackButton
+ 	self flag: 'tty'.
+ 	^hackButton ifNil: 
+ 		[hackButton := self basicButton 
+ 						label: 'Display ImageMorph Bounds' translated; 
+ 						actionSelector: #hack;						
+ 						setBalloonText: 
+ 							'tty needs a hack button.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>helpButton (in category 'submorphs - buttons') -----
+ helpButton
+ 	^helpButton ifNil: 
+ 		[helpButton := self basicButton 
+ 						label: 'help' translated; 
+ 						setBalloonText: 
+ 							'Click here to get some hints on use of me ',
+ 							'Panel' translated;
+ 						actionSelector: #help]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>initializeWithVMSimulator:title:aTranscript: (in category 'initialization') -----
+ initializeWithVMSimulator: aStackInterpreterSimulator title: aString aTranscript: aTranscript
+ 	|model|
+ 	self flag: 'tty'. "need to get the layout right at this point. resizers and scroll bars would be nice. Layout offsets need a gimlet eye as well"
+ 	model := StackInterpreterSimulatorMorphicModel on: aStackInterpreterSimulator title: aString transcript: aTranscript. 
+ 	self 
+ 		model: model;
+ 		clipSubmorphs: true;
+ 		setLabel: self model windowTitle;
+ 		name: aString;
+ 		addMorph: self newButtonRow fullFrame: self buttonRowLayoutFrame;
+ 		addMorph: self squeakJSRow fullFrame: self squeakJSRowLayoutFrame;
+ 		addMorph: self simulatorPanel fullFrame: self simulatorLayoutFrame;
+ 		addMorph: self displayView fullFrame: self displayViewLayoutFrame.	
+ 	^self		!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>ioExitButton (in category 'submorphs - buttons') -----
+ ioExitButton
+ 	self flag: 'tty'.
+ 	^ioExitButton ifNil: 
+ 		[ioExitButton := self basicButton 
+ 						label: 'vm ioExit' translated; 
+ 						actionSelector: #ioExit;						
+ 						setBalloonText: 
+ 							'Invoke ioExit on Simulator.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>loadButton (in category 'submorphs - buttons') -----
+ loadButton
+ 	^loadButton ifNil: 
+ 		[loadButton := self basicButton 
+ 						label: 'Load Image' translated; 
+ 						actionSelector: #loadImage;						
+ 						setBalloonText: 
+ 							'Select an image to load.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>newButtonRow (in category 'submorphs - buttons') -----
+ newButtonRow
+ 	^BorderedMorph new
+ 		color: Color transparent;
+ 		cellInset: 2;
+ 		layoutInset: 2;
+ 		layoutPolicy: TableLayout new;
+ 		listDirection: #leftToRight;
+ 		listCentering: #topLeft;
+ 		cellPositioning: #topLeft;
+ 		on: #mouseEnter send: #paneTransition: to: self;
+ 		on: #mouseLeave send: #paneTransition: to: self;
+ 		addMorphBack: self hackButton;
+ 		addMorphBack: self newSeparator;
+ 
+ "		addMorphBack: self resetButton;
+ 		addMorphBack: self newSeparator;
+ 		addMorphBack: self forceInterruptCheckButton;
+ 		addMorphBack: self newSeparator;
+ 		addMorphBack: self fullDisplayUpdateButton;
+ 		addMorphBack: self newSeparator;
+ 		addMorphBack: self toggleTranscriptButton;"  
+ 		addMorphBack: self runButton;				
+ 		addMorphBack: self newSeparator; 
+ 		addMorphBack: self ioExitButton;
+ 		addMorphBack: self newTransparentFiller;		
+ 		addMorphBack: self stepButton;
+ 		addMorphBack: self newSeparator;		
+ 		addMorphBack: self overButton;
+ 		addMorphBack: self newSeparator;
+ 		addMorphBack: self newSeparator;		
+ 		addMorphBack: self sendButton;
+ 		addMorphBack: self newSeparator;		
+ 		addMorphBack: self returnButton;		
+ 		addMorphBack: self newTransparentFiller;
+ "		addMorphBack: self loadButton;
+ 		addMorphBack: self newSeparator;				
+ 		addMorphBack: self optionsButton;     too complex to implement now. See StackInterpreterSimulator class comment for examples"										
+ 		addMorphBack: self newTransparentFiller;
+ 		addMorphBack: self helpButton;
+ 		yourself.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>newSeparator (in category 'submorphs - buttons') -----
+ newSeparator
+ 	^BorderedMorph new
+ 		borderWidth: 2;
+ 		borderColor: Color transparent;
+ 		color: self paneColor;
+ 		hResizing: #rigid;
+ 		width: 5;
+ 		vResizing: #spaceFill;
+ 		yourself!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>newTransparentFiller (in category 'submorphs - buttons') -----
+ newTransparentFiller
+ 	^Morph new
+ 		color: Color transparent;
+ 		vResizing: #spaceFill;
+ 		hResizing: #spaceFill;
+ 		yourself.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>optionsButton (in category 'submorphs - buttons') -----
+ optionsButton
+ 	^optionsButton ifNil: 
+ 		[optionsButton := self basicButton 
+ 						label: 'VM Options' translated; 
+ 						actionSelector: #options;						
+ 						setBalloonText: 
+ 							'VM Options.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>overButton (in category 'submorphs - buttons') -----
+ overButton
+ 	^overButton ifNil: 
+ 		[overButton := self basicButton 
+ 						label: 'Over' translated; 
+ 						actionSelector: #over;						
+ 						setBalloonText: 
+ 							'Step Over.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>resetButton (in category 'submorphs - buttons') -----
+ resetButton
+ 	^resetButton ifNil: 
+ 		[resetButton := self basicButton 
+ 						label: 'Reset' translated; 
+ 						actionSelector: #reset;						
+ 						setBalloonText: 
+ 							'Reset running simulation.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>returnButton (in category 'submorphs - buttons') -----
+ returnButton
+ 	self flag: 'tty'.
+ 	^returnButton ifNil: 
+ 		[returnButton := self basicButton 
+ 						label: 'Return' translated; 
+ 						actionSelector: #return;						
+ 						setBalloonText: 
+ 							'Return from what?.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>runButton (in category 'submorphs - buttons') -----
+ runButton
+ 	self flag: 'tty'.
+ 	^runButton ifNil: 
+ 		[runButton := self basicButton 
+ 						label: 'vm run' translated; 
+ 						actionSelector: #run;						
+ 						setBalloonText: 
+ 							'Run Simulation.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>sendButton (in category 'submorphs - buttons') -----
+ sendButton
+ 	self flag: 'tty'.
+ 	^sendButton ifNil: 
+ 		[sendButton := self basicButton 
+ 						label: 'Send' translated; 
+ 						actionSelector: #send;						
+ 						setBalloonText: 
+ 							'Send what exactly?.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>simulatorLayoutFrame (in category 'submorphs - simulator panel') -----
+ simulatorLayoutFrame 
+ 	| squeakJSFrame buttonFrame |
+ 	"I don't understand offsets in the LayoutFrame. I just fiddled until it looked ok. If anybody knows what they are doing, please refactor."
+ 	self flag: 'tty'.
+ 	buttonFrame := self buttonRowLayoutFrame.
+ 	squeakJSFrame := self squeakJSRowLayoutFrame.
+ 	^LayoutFrame fractions: (0.7 at 0 corner: 1 at squeakJSFrame topOffset) 
+ 				    offsets: (0@(buttonFrame bottomOffset) corner: 0.70 at squeakJSFrame topOffset)
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>simulatorPanel (in category 'submorphs - simulator panel') -----
+ simulatorPanel
+ 	"standard controls from StackInterpreterSimulator >> openAsMorph"
+ 	^BorderedMorph new
+ 		color: Color transparent;
+ 		layoutInset: 10;
+ 		cellInset: 10;
+ 		layoutPolicy: TableLayout new;
+ 		listDirection: #topToBottom;
+ 		listCentering: #topLeft;
+ 		cellPositioning: #topLeft;
+ 		on: #mouseEnter send: #paneTransition: to: self;
+ 		on: #mouseLeave send: #paneTransition: to: self;		
+ 		addMorphBack: self transcriptPanel;
+ 		addMorphBack: self commandPanel;
+ 		yourself.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>squeakJSRow (in category 'submorphs - squeakJS') -----
+ squeakJSRow
+ 	"row fo SqueakJS context, stack and call-stack panels"
+ 	^BorderedMorph new
+ 		color: Color blue;
+ 		cellInset: 2;
+ 		layoutInset: 2;
+ 		layoutPolicy: TableLayout new;
+ 		listDirection: #leftToRight;
+ 		listCentering: #topLeft;
+ 		cellPositioning: #topLeft;
+ 		on: #mouseEnter send: #paneTransition: to: self;
+ 		on: #mouseLeave send: #paneTransition: to: self;
+ 		addMorphBack: self callStackPanel;
+ 		addMorphBack: self contextPanel;
+ 		addMorphBack: self stackPanel;		
+ 		yourself.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>squeakJSRowLayoutFrame (in category 'submorphs - squeakJS') -----
+ squeakJSRowLayoutFrame 
+ 	^LayoutFrame fractions: (0 at 0.8 corner: 1 at 1) offsets: (0 at 0.8 corner: 1@ (TextStyle defaultFont height * 2.5))
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>stackPanel (in category 'submorphs - squeakJS') -----
+ stackPanel
+ 	"If any Morphic gurus exist, please have at it."
+ 	^stackPanel ifNil: 
+ 		[stackPanel :=  (PluggableTextMorph
+ 				on: self model
+ 				text: #currentContextStack
+ 				accept: nil
+ 				readSelection: nil
+ 				menu: nil) hideScrollBarsIndefinitely.
+ 		stackPanel		
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself].
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>stepButton (in category 'submorphs - buttons') -----
+ stepButton
+ 	self flag: 'tty'.
+ 	^stepButton ifNil: 
+ 		[stepButton := self basicButton 
+ 						label: 'Step' translated; 
+ 						actionSelector: #step;						
+ 						setBalloonText: 
+ 							'Step Into.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>toggleTranscriptButton (in category 'submorphs - buttons') -----
+ toggleTranscriptButton
+ 	"tty I dont like this. I have diabled the button"
+ 	self flag: 'tty'.
+ 	^toggleTranscriptButton ifNil: 
+ 		[toggleTranscriptButton := self basicButton 
+ 						label: 'Toggle Transcript' translated; 
+ 						actionSelector: #toggleTranscript;						
+ 						setBalloonText: 
+ 							'Use External Transcript Instead of Internal.' translated]!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorph>>transcriptPanel (in category 'submorphs - simulator panel') -----
+ transcriptPanel
+ 	self flag: 'tty'. "does this hybrid of PreferenceBrowser layout and Simulato openAsMorph stuff make sense?"
+ 	^transcriptPanel ifNil: 
+ 		[transcriptPanel := (PluggableTextMorph
+ 				on:  self model vm transcript
+ 				text: nil
+ 				accept: nil
+ 				readSelection: nil
+ 				menu: #codePaneMenu:shifted:).
+ 		transcriptPanel	
+ 			name: 'transcriptPanel';	
+ 			color: Color transparent;
+ 			hResizing: #spaceFill;
+ 			vResizing: #spaceFill;
+ 			cellInset: 5;
+ 			yourself].
+ !

Item was added:
+ TestCase subclass: #StackInterpreterSimulatorMorphicEventTests
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: 'EventSensorConstants'
+ 	category: 'VMMaker-InterpreterSimulation-Morphic'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicEventTests>>testKeyEventDegeneration (in category 'test event') -----
+ testKeyEventDegeneration
+ 	|aMorphicEvent evtBuf type|
+ 	aMorphicEvent := HandMorph new generateKeyboardEvent: {2 . 0. 0. 0. 0. 0. 0. 0}.
+ 	evtBuf := (StackInterpreterSimulatorEventTransformer default) degenerateEvent: aMorphicEvent. 
+ 	type := evtBuf at:1.
+ 	self assert:(type = EventTypeKeyboard).
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicEventTests>>testMouseEventDegeneration (in category 'test event') -----
+ testMouseEventDegeneration
+ 	|aMorphicEvent evtBuf type|
+ 	"see class comment in EventSensor browse"
+ 	aMorphicEvent := HandMorph new generateMouseEvent: {1 . 0. 0. 0. 0. 0. 0. 0}.
+ 	evtBuf := (StackInterpreterSimulatorEventTransformer default) degenerateEvent: aMorphicEvent. 
+ 	type := evtBuf at:1.
+ 	self assert:(type = EventTypeMouse).
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicEventTests>>testNullEventDegeneration (in category 'test event') -----
+ testNullEventDegeneration
+ 	|aMorphicEvent evtBuf type|
+ 	"Test a bad morphic event returns a null event"	"see class comment in EventSensor browse"
+ 	aMorphicEvent := UserInputEvent new.
+ 	evtBuf := (StackInterpreterSimulatorEventTransformer default) degenerateEvent: aMorphicEvent. 
+ 	type := evtBuf at:1.
+ 	self assert:(type = EventTypeNone).
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicEventTests>>testStackInterpreterSimulatorDisplayViewAccess (in category 'test tight coupling') -----
+ testStackInterpreterSimulatorDisplayViewAccess
+ 	"There is tight coupling between the morph,model and vm simulator on the simulators displayView variable
+ 	 this test makes sure it is accesible and is an ImageMorph."
+ 	
+ self assert: ((SystemNavigation allImplementorsOf: #displayView localTo: StackInterpreterSimulator) size = 1).
+ self assert: ((SystemNavigation allImplementorsOf: #displayView: localTo: StackInterpreterSimulator)size = 1).
+ 
+ !

Item was added:
+ Model subclass: #StackInterpreterSimulatorMorphicModel
+ 	instanceVariableNames: 'vm title stepping morph'
+ 	classVariableNames: ''
+ 	poolDictionaries: 'EventSensorConstants'
+ 	category: 'VMMaker-InterpreterSimulation-Morphic'!
+ 
+ !StackInterpreterSimulatorMorphicModel commentStamp: 'tty 2/6/2014 09:43' prior: 0!
+ A StackInterpreterSimulatorMorphicModel handles Morphic callbacks and UI  for (some parts of ) the StackInterpreterSimulator.
+ 
+ I   handle event forwarding management..
+ 
+ Currently, I am a listener to HandMorphs>>addPrimitiveEventListener. 
+ I am added as a listener by StackInterpreterSimulatorMorph>>displayView (which probably  needs to change. tty)
+ 
+ 
+ instance vars:
+ 
+ stepping   when true the vm is running, but the user is stepping throught the stack--like a debugger. (not implemented: tty)
+ 
+ 
+ sharedPools: EventSensorConstants!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>initialize (in category 'class initialization') -----
+ initialize
+ 	"I want to keep it launchable by script only for now.
+ 	Eliot has a bunch of options that aren't really feasible for a Morphic first approach.
+ 	"
+ 	"self
+ 		registerWindowColor;
+ 		registerInOpenMenu;
+ 		registerInFlaps"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>on:title:transcript: (in category 'instance creation') -----
+ on: aStackInterpreterSimulator title: aString transcript: aTranscriptStream
+ 	| simmodel |
+ 	simmodel := self new.
+ 	simmodel 
+ 		vm: aStackInterpreterSimulator;
+ 		title: aString;
+ 		transcript: aTranscriptStream.
+ 	^simmodel.	!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>registerInFlaps (in category 'class initialization') -----
+ registerInFlaps
+ "	Flaps 
+ 		registerQuad: 
+ 			{ #StackInterpreterSimulator. 
+ 			#prototypicalToolWindow.
+ 			'StackInterpreter Simulator' translated.
+ 			'A Morphic Wrapper for VM Simulations' translated }
+ 	 	forFlapNamed: 'Tools' translated.
+ 	Flaps replaceToolsFlap"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>registerInOpenMenu (in category 'class initialization') -----
+ registerInOpenMenu
+ 	(TheWorldMenu respondsTo: #registerOpenCommand:) ifTrue: [
+ 		TheWorldMenu unregisterOpenCommand: 'StackInterpreter Simulator'.
+ 		TheWorldMenu registerOpenCommand: {'StackInterpreter Simulator'. {self. #open}}].
+ 		!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>registerWindowColor (in category 'class initialization') -----
+ registerWindowColor
+ 	(Preferences windowColorFor: self name) = Color white
+ 		ifTrue: [ Preferences setWindowColorFor: self name to: (Color colorFrom: self windowColorSpecification brightColor) ].!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>unload (in category 'class initialization') -----
+ unload
+ 	self 
+ 		unregisterFromOpenMenu;
+ 		unregisterFromFlaps.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>unregisterFromFlaps (in category 'class initialization') -----
+ unregisterFromFlaps
+ 	"Flaps 
+ 		unregisterQuadsWithReceiver: self;
+ 		replaceToolsFlap"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>unregisterFromOpenMenu (in category 'class initialization') -----
+ unregisterFromOpenMenu
+ 	 (TheWorldMenu respondsTo: #registerOpenCommand:)
+ 		ifTrue: [TheWorldMenu unregisterOpenCommand: 'StackInterpreter Simulator'].
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel class>>windowColorSpecification (in category 'window color') -----
+ windowColorSpecification
+ 	"Answer a WindowColorSpec object that declares my preference"
+ 
+ 	^ WindowColorSpec classSymbol: self name wording: 'StackInterpreter Simulator' brightColor: #(0.645 1.0 1.0)	pastelColor: #(0.886 1.0 1.0) helpMessage: 'A tool for simulating a Stack Interpreter Virtual Machine.'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>bounds (in category 'accessing') -----
+ bounds
+ 	^morph bounds.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>byteCountText (in category 'user interface') -----
+ byteCountText
+ 	^vm byteCountText!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>currentContextStack (in category 'user interface - squeakJS') -----
+ currentContextStack
+ 	self flag: 'tty'.
+ 	^ 'Current Context Stack' printString asText!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>displayForm (in category 'accessing') -----
+ displayForm
+ 	^ vm displayForm!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>displayView (in category 'accessing') -----
+ displayView
+ 	^ vm displayView!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>displayView: (in category 'accessing') -----
+ displayView: anImageMorph
+ 	vm displayView: anImageMorph!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>forceInterruptCheck (in category 'buttons callbacks') -----
+ forceInterruptCheck
+ 	vm forceInterruptCheck
+ "^UserDialogBoxMorph inform: 'Toggle Transcript' title: 'TODO:'"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>fullDisplayUpdate (in category 'buttons callbacks') -----
+ fullDisplayUpdate
+ 	vm fullDisplayUpdate
+ "^UserDialogBoxMorph inform: 'Toggle Transcript' title: 'TODO:'"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>hack (in category 'buttons callbacks') -----
+ hack
+ 	UserDialogBoxMorph inform: (morph bounds printString) title: 'Hack:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>handleListenEvent: (in category 'event-forwarding') -----
+ handleListenEvent: aMorphicEvent
+ "The StackInterpreterSimulatorImageMorph  regsitered me (a StackInterpreterSimulatorMorphicModel ) with HandMorph>>addEventListener
+ HandMorph then broadcasts events to all registered listeners at this method. See HandMorph>>sendListenPrimitiveEvent
+ "
+ 	|evtBuf xtranslated ytranslated|
+ 	morph
+ 		ifNotNil:[
+ 			evtBuf := (StackInterpreterSimulatorEventTransformer default) degenerateEvent: aMorphicEvent. 
+ 			((evtBuf at: 1) = EventTypeMouse) & (morph bounds containsPoint: aMorphicEvent position)
+ 				ifTrue:[
+ 						xtranslated :=  (evtBuf at:3) - (morph bounds left) - 2 .  "<--heh"  
+ 						ytranslated :=  (evtBuf at:4) - (morph bounds top). 
+ 						evtBuf at: 3 put: xtranslated.
+ 						evtBuf at: 4 put: ytranslated.
+ 						vm queueForwardedEvent: evtBuf]]
+ 
+ 
+ 
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>help (in category 'buttons callbacks') -----
+ help
+ 	"Open up a workspace with explanatory info in it about the StackInterpreterSimulator"
+ 	Workspace new
+ 		contents: self helpText;
+ 		openLabel: self windowTitle, ' Help'.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>helpText (in category 'buttons callbacks') -----
+ helpText
+ 	^(String streamContents: [:str |
+ 		str nextPutAll:
+ 'Stack Intepreter Simulator Help Contents Go Here.']) translated!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>initialExtent (in category 'user interface') -----
+ initialExtent
+ 	^ 1286 at 938!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>initialize (in category 'initialize-release') -----
+ initialize
+ 	
+ 	title := 'StackInterpreter Simulator (Beta))'.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>ioExit (in category 'buttons callbacks') -----
+ ioExit
+ 	vm ioExit
+ 	displayView activeHand removeEventListener: self model.	"This is a bug as the user in vm ioExit may have cancelled the confirm t.m."
+ "^UserDialogBoxMorph inform: 'Toggle Transcript' title: 'TODO:'"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>loadImage (in category 'buttons callbacks') -----
+ loadImage
+ 	^UserDialogBoxMorph inform: 'load image' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>morph (in category 'accessing') -----
+ morph
+ 	"I need the bounds of my morph for filtering mouse events.
+        If there is a canned way of doing this besides this tight binding to my StackInterpreterSimulatorMorph,
+ 	then please refactor me.
+ 
+       see my protocol event-forwarding for the gory details"
+ 	self flag:'tty'.
+ 	^morph.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>morph: (in category 'accessing') -----
+ morph: aMorph
+ 	"I need the bounds of my morph for filtering mouse events.
+        If there is a canned way of doing this besides this tight binding to my StackInterpreterSimulatorMorph,
+ 	then please refactor me.
+ 
+       see my protocol event-forwarding for the gory details"
+ 	self flag:'tty'.
+ 	morph := aMorph.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>onItemClicked: (in category 'user interface - squeakJS') -----
+ onItemClicked: anItem
+ 	"I am an item in the current context display on the SqueakJS tree view".!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>options (in category 'buttons callbacks') -----
+ options
+ ^UserDialogBoxMorph inform: 'Options Popup--need checkboxes?' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>over (in category 'buttons callbacks') -----
+ over
+ 	stepping:=true.
+ ^UserDialogBoxMorph inform: 'Step Over' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>processesAndContextStack (in category 'user interface - squeakJS') -----
+ processesAndContextStack
+ 	"just a stub. see top right panel at http://lively-web.org/users/bert/squeak.html  for what I intend to present"
+ 	self flag: 'tty'.
+ 	^ 'Processes and ContextStack' printString asText
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>reset (in category 'buttons callbacks') -----
+ reset
+ 	^UserDialogBoxMorph inform: 'Reset' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>return (in category 'buttons callbacks') -----
+ return
+ ^UserDialogBoxMorph inform: 'Return' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>run (in category 'buttons callbacks') -----
+ run
+ 	stepping:=false.
+ 	vm run
+ "^UserDialogBoxMorph inform: 'Run' title: 'TODO:'"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>send (in category 'buttons callbacks') -----
+ send
+ ^UserDialogBoxMorph inform: 'Send' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>specialObjectsAndActiveContext (in category 'user interface - squeakJS') -----
+ specialObjectsAndActiveContext
+ 	"just a stub. see top left panel at http://lively-web.org/users/bert/squeak.html  for what I intend to present"
+ 	self flag: 'tty'.
+ 	^ 'Special Objects and Active Context' printString asText
+ !

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>step (in category 'buttons callbacks') -----
+ step
+ 	stepping:=true.
+ ^UserDialogBoxMorph inform: 'Step' title: 'TODO:'!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>stepping (in category 'accessing') -----
+ stepping
+ 	^stepping!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>stepping: (in category 'accessing') -----
+ stepping: aBoolean
+ 	stepping := aBoolean!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>title: (in category 'accessing') -----
+ title: aString
+ 	title := aString!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>toggleTranscript (in category 'buttons callbacks') -----
+ toggleTranscript
+ 	vm toggleTranscriptForSimulatorMorph: self transcript.
+ "^UserDialogBoxMorph inform: 'Toggle Transcript' title: 'TODO:'"!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>transcript (in category 'accessing') -----
+ transcript
+ 	^vm transcript!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>transcript: (in category 'accessing') -----
+ transcript: aTranscriptStream
+ 	vm transcript: aTranscriptStream.!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>utilitiesMenu: (in category 'user interface') -----
+ utilitiesMenu: aMenuMorph 
+ 	^vm utilitiesMenu: aMenuMorph!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>vm (in category 'accessing') -----
+ vm
+ 	^vm!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>vm: (in category 'accessing') -----
+ vm: aVMSimulator
+ 	vm := aVMSimulator!

Item was added:
+ ----- Method: StackInterpreterSimulatorMorphicModel>>windowTitle (in category 'user interface') -----
+ windowTitle
+ 	^ title translated!



More information about the Vm-dev mailing list