Eliot Miranda uploaded a new version of VMMakerUI to project VM Maker: http://source.squeak.org/VMMaker/VMMakerUI-eem.2.mcz ==================== Summary ==================== Name: VMMakerUI-eem.2 Author: eem Time: 22 December 2019, 7:14:20.960407 pm UUID: d412eec8-114e-4a7a-ad8e-3ac33b0e36b3 Ancestors: VMMakerUI-eem.1 Add abstract register names on the left of the register state (i.e. include the register map) if there's a cogit. Nuke unused accessors (I like my state encapsulated). No need for an unaccessible pc field. (buit still have to test using the CogProcessorAlien without a cogit etc). =============== Diff against VMMakerUI-eem.1 =============== Item was changed: Model subclass: #CogProcessorAlienInspector + instanceVariableNames: 'cogit coInterpreter objectMemory processor registerSelectors windowTitle registerCache registerMap' - instanceVariableNames: 'cogit coInterpreter objectMemory processor registerSelectors windowTitle registerCache' classVariableNames: '' poolDictionaries: '' category: 'VMMakerUI-SqueakInspectors'! !CogProcessorAlienInspector commentStamp: 'eem 12/22/2019 08:27' prior: 0! A CogProcessorAlienInspector is an inspector for a CogProcessorAlien processor simulator that displays the processor simulator's register state. Instance Variables processor: <CogProcessorAlien> registerCache: <Array of Integer> registerSelectors: <Array of Symbol> windowTitle: <String>! Item was changed: ----- Method: CogProcessorAlienInspector>>cogit: (in category 'initialization') ----- cogit: aCogit cogit := aCogit. coInterpreter := cogit coInterpreter. objectMemory := coInterpreter objectMemory. processor := cogit processor. + registerSelectors := processor registerStateGetters. + self computeRegisterMap. + windowTitle := nil. + self changed: #text; changed: #window! - registerSelectors := OrderedCollection withAll: processor registerStateGetters! Item was added: + ----- Method: CogProcessorAlienInspector>>computeRegisterMap (in category 'initialization') ----- + computeRegisterMap + | map | + registerMap := Dictionary new. + map := cogit backEnd generalPurposeRegisterMap. + (map keys asSortedCollection: [:a :b| (map at: a) < (map at: b)]) do: + [:regName| | abstractName | + abstractName := cogit backEnd nameForRegister: (map at: regName). + abstractName last ~~ $? ifTrue: + [registerMap at: regName put: abstractName]]! Item was changed: ----- Method: CogProcessorAlienInspector>>evaluateExpression: (in category 'evaluation') ----- evaluateExpression: exp "Callback from text widget after do-it, print-it, inspect-it, etc... The return value will be fed back." | register value | register := (exp asString findTokens: '=') first withBlanksTrimmed asLowercase asSymbol. + value := registerCache at: register. - value := self registerCache at: register. self interpret: register. + + ^value! - - ^ value! Item was changed: ----- Method: CogProcessorAlienInspector>>initialize (in category 'initialization') ----- initialize super initialize. + registerSelectors := OrderedCollection new. + registerMap := Dictionary new. + registerCache := IdentityDictionary new.! - - self registerSelectors: OrderedCollection new. - - self registerCache: IdentityDictionary new.! Item was removed: - ----- Method: CogProcessorAlienInspector>>inspect: (in category 'initialization') ----- - inspect: aRegisterSelector - - self registerSelectors add: aRegisterSelector. - self changed: #text.! Item was removed: - ----- Method: CogProcessorAlienInspector>>inspectAll: (in category 'initialization') ----- - inspectAll: someRegisterSelectors - - self registerSelectors addAll: someRegisterSelectors. - self changed: #text.! Item was removed: - ----- Method: CogProcessorAlienInspector>>inspectNone (in category 'initialization') ----- - inspectNone - - self registerSelectors removeAll. - self changed: #text.! Item was changed: ----- Method: CogProcessorAlienInspector>>interpret: (in category 'evaluation') ----- interpret: registerSelector "Offer some ways of interpretation." + | value options where choice | - | value options choice | self flag: #updates. "mt: The cache value corresponds maybe to the value at interaction time. In case the register changes quickly and it takes the user some time to make a choice?" + value := registerCache at: registerSelector. + - value := self registerCache at: registerSelector. - options := OrderedDictionary newFrom: { 'Object' -> #interpret:asObject:. 'Stack frame' -> #interpret:asStackFrame:. 'Code address' -> #interpret:asCodeAddress:. 'Integer' -> #interpret:asInteger:. 'Character' -> #interpret:asCharacter:. }. + where := coInterpreter whereIs: value. - choice := Project uiManager chooseFrom: options keys values: options values + title: ('{1} {2}' format: {registerSelector asUppercase. (where beginsWith: ' ') ifTrue: [where allButFirst] ifFalse: [' = ', where]}). - title: ('{1} {2}' format: {registerSelector asUppercase. coInterpreter whereIs: value}). choice ifNotNil: [:selector | self perform: selector with: registerSelector with: value]! Item was removed: - ----- Method: CogProcessorAlienInspector>>pcText (in category 'accessing - ui') ----- - pcText - - ^processor pc hex allButFirst: 3! Item was changed: ----- Method: CogProcessorAlienInspector>>processor: (in category 'accessing') ----- processor: aCogProcessorAlien processor := aCogProcessorAlien. registerSelectors := processor registerStateGetters. + registerMap := Dictionary new. windowTitle := nil. + self changed: #text; changed: #windowTitle.! - self changed: #windowTitle.! Item was removed: - ----- Method: CogProcessorAlienInspector>>registerAt: (in category 'accessing - ui') ----- - registerAt: aRegisterSelector - - ^ self alien perform: aRegisterSelector! Item was removed: - ----- Method: CogProcessorAlienInspector>>registerCache (in category 'accessing') ----- - registerCache - - ^ registerCache! Item was removed: - ----- Method: CogProcessorAlienInspector>>registerCache: (in category 'accessing') ----- - registerCache: anObject - - registerCache := anObject.! Item was removed: - ----- Method: CogProcessorAlienInspector>>registerSelectors (in category 'accessing') ----- - registerSelectors - - ^ registerSelectors! Item was removed: - ----- Method: CogProcessorAlienInspector>>registerSelectors: (in category 'accessing') ----- - registerSelectors: anObject - - registerSelectors := anObject. - self changed: #text.! Item was changed: ----- Method: CogProcessorAlienInspector>>registerTextAt: (in category 'accessing - ui') ----- registerTextAt: aRegisterSelector | raw current last text | current := processor perform: aRegisterSelector. + last := registerCache at: aRegisterSelector ifAbsent: []. + registerCache at: aRegisterSelector put: current. - last := self registerCache at: aRegisterSelector ifAbsent: []. - self registerCache at: aRegisterSelector put: current. raw := String streamContents: [:s | current printOn: s base: (2 raisedTo: self bitsPerDigit) length: processor class wordSize * 8 / self bitsPerDigit padded: true]. text := (String streamContents: [:s | raw groupsOf: self digitsPerGroup atATimeCollect: [:group | s nextPutAll: group; space]]) asText. last ~= current ifTrue: [text addAllAttributes: {TextEmphasis bold. TextColor color: Color salmon}]. ^text! Item was changed: ----- Method: CogProcessorAlienInspector>>text (in category 'accessing - ui') ----- text ^Text streamContents: [:s | | max exclude fpstate | + max := (registerSelectors ifEmpty: [1] ifNotEmpty: [:selector | (selector collect: #size) max]). - max := (self registerSelectors ifEmpty: [1] ifNotEmpty: [:selector | (selector collect: #size) max]). - s - nextPutAll: ('PC' padded: #right to: max with: Character space); - nextPutAll: ' = '; - nextPutAll: self pcText; - cr. exclude := Set new. 1 to: (fpstate := processor floatingPointRegisterStateGetters) size by: 4 do: [:index| ((index to: index + 3) allSatisfy: [:fpri| (processor perform: (fpstate at: fpri)) isZero]) ifTrue: [exclude addAll: (fpstate copyFrom: index to: index + 3)]]. + registerSelectors do: + [:selector | | attribute | - self registerSelectors do: [:selector | (exclude includes: selector) ifFalse: [s nextPutAll: ((selector asUppercase padded: #right to: max with: Character space) + asText addAttribute: (attribute := PluggableTextAttribute evalBlock: [self interpret: selector])); + space; + nextPutAll: (self registerTextAt: selector). + (registerMap at: selector ifAbsent: []) ifNotNil: + [:abstractReg| + s space; nextPutAll: (abstractReg asText addAttribute: attribute)]. + s cr]]]! - asText addAttribute: (PluggableTextAttribute evalBlock: [self interpret: selector])); - nextPutAll: ' = '; - nextPutAll: (self registerTextAt: selector); - cr]]]! |
Free forum by Nabble | Edit this page |