From VisualWorks®, 7.6 of February 8, 2008 on March 3, 2008 at 9:44:03 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>StackInspector</name> <environment>CraftedSmalltalk</environment> <super>Tools.ContextInspector</super> <private>false</private> none isTopContext <imports></imports> <category>CraftedSt-Inspector</category> <attributes> <package>Debugger-StackInspector</package> </attributes> </class> <comment> CraftedSmalltalk.StackInspector
A StackInspector is used by the Debugger to display expression interim values, values that are pushed onto the stack. This allows a user to see the results of message sends before a following message is sent. Instance variables: isTopContext <Boolean> Signifies that the context being inspected is the top context. Inherited Instance variable: tempIndex <Integer> Index of selection. If value is -1, auto selection is turned off.
</comment> <name>InitialTempIndex</name> <environment>CraftedSmalltalk.StackInspector</environment> <private>false</private> <constant>false</constant> <category>defaults</category> <attributes> <package>Debugger-StackInspector</package> </attributes> <methods> CraftedSmalltalk.StackInspector <category>private</category>
acceptText: aText from: aController "Text has been changed. Store or compile the text, depending on the current mode of the receiver." | val | field == nil ifTrue: [^ false]. val := self evaluateText: aText string from: aController ifFail: [^ false]. object localAt: object stackP - (self fieldIndex - 1) put: val. self resetText; changeStackFields. ^ true
changeStackFields | list tempIndex | tempIndex := self fieldIndex. list := self getAndSetNewList. (tempIndex notNil and: [tempIndex < 0]) ifTrue: [^fieldList selectionIndexHolder value: 0]. tempIndex := list size = 0 ifTrue: [0] "no selection" ifFalse: [(list size < tempIndex or: [tempIndex = 0]) ifTrue: [1] "reset to 'top' field" ifFalse: [tempIndex]. "set to previous setting"]. properties at: #tempIndex put: tempIndex. fieldList selectionIndexHolder value: tempIndex.
help | msg | msg := Text string: (#StackInspectorHelpText << #pdp >> ' The stack inspector allows one to inspect the current statement''s object stack. The inspector''s fields are dynamically determined and appear in two forms. The first appears when the selected context is the top context and is about to send a message. The named fields identify the message arguments and the messge receiver. If you were about to send the #displayOn:at: message in the following statement; anImage displayOn: gc at: (45 @ 70). the stack inspector would show; arg2 = 45 @ 70 arg1 = aGraphicsContext rcvr = anImage If you select a context other than the top context and there are objects on the stack they will be identified as: "top", "-1", ..., "-n". "top" refers to the top of stack and the fields "-1", to "-n" refer to the top of stack -1 to -n. Additionally, if the top context is selected and it is about to store an object into a variable or return an object you will see just "top". Furthermore, if there objects that have been pushed on the stack are are intended for a subsequent message send you may see something like; arg2 arg1 rcvr -3 -4 Try stepping through the following and observe how the stack changes. self halt. (Array with: 2 with: 4) at: (1 * 2) put: 5 ') asString runs: (RunArray runs: #(410 36 34 55 523 26 74 56) values: #(nil #bold nil #bold nil #bold nil #bold)). ComposedTextView open: msg asValue label: (#StackInspectorHelp << #pdp >> 'Stack Inspector Help')
isInspectorPDPEnhanced ^Tools.Inspector includesSelector: #copyField
newObject: anObject "Replace the selected object with anObject." object localAt: object stackP - (self fieldIndex - 1) put: anObject.
resetFields | list tempIndex | tempIndex := self fieldIndex. list := self getAndSetNewList. (tempIndex notNil and: [tempIndex < 0]) ifTrue: [^fieldList selectionIndexHolder value: 0]. tempIndex := list size = 0 ifTrue: [0] "no selection" ifFalse: [1]. "reset to 'top' field, it makes no sense to set to previous setting." properties at: #tempIndex put: tempIndex. fieldList selectionIndexHolder value: tempIndex.
stackStringAt: index ^Tools.Trippy.Inspector bulletproofLabelStringOf: (self fieldValueAt: index)
</methods> <methods> CraftedSmalltalk.StackInspector <category>initialize-release</category>
initialize super initialize. isTopContext := false. properties at: #tempIndex put: InitialTempIndex.
</methods> <methods> CraftedSmalltalk.StackInspector <category>field list</category>
fieldIndex: selectionIndex "Set selection to be the currently selected variable." | tempNames tempIndex | tempNames := properties at: #tempNames. tempIndex := properties at: #tempIndex. field := selectionIndex = 0 ifTrue: [nil] ifFalse: [tempNames at: selectionIndex]. "The following code means: 1. if we have disabled auto-selection and the new index is greater than 0 then enable auto-selection and use new index. 2. if auto-selection is not disabled and the new index is 0, then disable auto-selection. Otherwise, use the new index." tempIndex < 0 ifTrue: [selectionIndex > 0 ifTrue: [tempIndex := selectionIndex]] ifFalse: [(tempIndex > 0 and: [selectionIndex = 0]) ifTrue: [tempIndex := -1] ifFalse: [tempIndex := selectionIndex]]. properties at: #tempIndex put: tempIndex. self resetText
fieldList | argumentCount size index tempNames | object == nil ifTrue: [properties at: #tempNames put: Array new. ^super fieldList]. size := object stackP - object method numLocals. size > 0 ifFalse: [^properties at: #tempNames put: Array new]. tempNames := Array new: size. index := 1. (isTopContext and: [object atEnd not and: [object pdpWillSend and: [argumentCount := object peekForSelector numArgs. object sendsAdd1 ifTrue: [argumentCount := argumentCount - 1]. argumentCount < 100]]]) ifTrue: [[argumentCount > 0] whileTrue: [tempNames at: index put: 'a', argumentCount printString, ': ', (self stackStringAt: index). argumentCount := argumentCount - 1. index := index + 1]. object hasReceiverOnStackForSend ifTrue: [tempNames at: index put: 'r: ', (self stackStringAt: index)] ifFalse: [index := index - 1]] ifFalse: [tempNames at: index put: (self stackStringAt: index)]. index := index + 1. index to: size do: [:j | tempNames at: j put: (self stackStringAt: j)]. ^properties at: #tempNames put: tempNames
fieldMenu "Answer a Menu of operations on variables that is to be displayed when the operate menu button is pressed." field == nil ifTrue: [^Menu labelList: (Array with: (Array with: (#Help << #pdp >> 'Help'))) values: #( help)]. ^self isInspectorPDPEnhanced ifTrue: [Menu labelList: (Array with: (Array with: (#Inspect << #pdp >> 'Inspect') with: (#Owners << #pdp >> 'Owners') with: (#ReferencePath << #pdp >> 'Reference Path')) with: (Array with: (#Copy << #pdp >> 'Copy') with: (#Paste << #pdp >> 'Paste') with: (#Compare << #pdp >> 'Compare')) with: (Array with: (#Help << #pdp >> 'Help'))) values: #(inspectField ownersOfField findReferencePath copyField pasteField compareField help)] ifFalse: [Menu labelList: (Array with: (Array with: (#Inspect << #pdp >> 'Inspect') with: (#Owners << #pdp >> 'Owners') with: (#ReferencePath << #pdp >> 'Reference Path')) with: (Array with: (#Help << #pdp >> 'Help'))) values: #(inspectField ownersOfField refPathToField help)]
fieldValue ^self fieldValueAt: self fieldIndex
fieldValueAt: index ^object localAt: object stackP - (index - 1).
</methods> <methods> CraftedSmalltalk.StackInspector <category>accessing</category>
context: theContext isTop: aBoolean isTopContext := aBoolean. object := theContext.
</methods> <methods> CraftedSmalltalk.StackInspector <category>updating</category>
updateAsTop: aBoolean "Reshow contents, assuming selected value may have changed." isTopContext := aBoolean. self changeStackFields.
</methods> <methods> CraftedSmalltalk.StackInspector class <category>class initialization</category>
initialAutoSelectionOff InitialTempIndex := -1
initialAutoSelectionOn InitialTempIndex := 0
initialize self initialAutoSelectionOff
</methods> <methods> Kernel.Context <category>accessing</category>
stackP ^stackp
</methods> <methods> CraftedSmalltalk.StackInspector class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: ' ' #min: #(#{Core.Point} 180 180 ) #bounds: #(#{Graphics.Rectangle} 722 445 992 625 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 0 0 0 0 -2 0.6 0 1 ) #name: #fieldList #model: #fieldListHolder #callbacksSpec: #(#{UI.UIEventCallbackSubSpec} #doubleClickSelector: #inspectField #requestValueChangeSelector: #changeRequest ) #tabable: false #menu: #fieldMenuHolder ) #(#{UI.TextEditorSpec} #layout: #(#{Graphics.LayoutFrame} 2 0.6 0 0 0 1 0 1 ) #name: #text #model: #textHolder #callbacksSpec: #(#{UI.UIEventCallbackSubSpec} #valueChangeSelector: #textAccepted: #requestValueChangeSelector: #textAcceptAllowed: ) #tabRequiresControl: true ) #(#{UI.ResizingSplitterSpec} #layout: #(#{Graphics.LayoutFrame} -2 0.6 0 0 2 0.6 0 1 ) #name: #splitter #horizontal: false #minAboveSize: 30 #minBelowSize: 0 #aboveWidgets: 'fieldList' #belowWidgets: 'text' ) ) ) )
</methods> <initialize> CraftedSmalltalk.StackInspector </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Context</name> <environment>Kernel</environment> <super>Kernel.InstructionStream</super> <private>false</private> none sender receiver stackp stack <imports> private Kernel.OpcodePool.* </imports> <category>Kernel-Methods</category> <attributes> <package>Kernel-Methods</package> </attributes> </class> <class> <name>ContextInspector</name> <environment>Tools</environment> <super>Tools.Inspector</super> <private>false</private> none <imports></imports> <category>Tools-Programming</category> <attributes> <package>Tools-Programming</package> </attributes> </class>