On Fri, Feb 3, 2017 at 11:33 AM, Ben Coman <[hidden email]> wrote:
> > On Fri, Feb 3, 2017 at 10:21 AM, Ben Coman <[hidden email]> wrote: >> >> Or maybe it [Stack] would be better as a tab of thisContext's next pane. >> > > Actually you can try this now... > > Context>>stackValueMap > | stackValues stackDepth| > stackValues := OrderedCollection new. > stackDepth := self basicSize min: 21. > (stackDepth to: 1 by: -1) do: [ :index | > |key| > key := (index = stackDepth) ifTrue: ['Top'] ifFalse: [(stackDepth - index + > 1) asString]. > stackValues add: (key -> (self basicAt: index)) > ]. > ^stackValues > > Context>>gtInspectorStackValuesIn: composite > <gtInspectorPresentationOrder: 40> > | stackValues | > stackValues := self stackValues. > ^ (composite table) > title: 'Stack'; > display: [ self stackValueMap ]; > column: 'Depth' evaluated: [ :assoc | assoc key ] width: 50; > column: 'Item' evaluated: [ :assoc | GTObjectPrinter new > asTruncatedTextFrom: assoc value ] > > > I'm not sure whether the #stackValueMap is an appropriate name. Perhaps it > should be #methodStackValueMap or something else? Similar for the tab name. A couple of times already I've missed not having this in fresh Images. Since its simple and low impact I hoping to add it for Pharo 6, but I'd like to check the semantics are right As a comparison, what I understand of C lang is it has only one stack (per thread) for: * execution flow return to caller's next statement * function parameters * function local variables So C kind of combines call stack and variable stack.. In Pharo, the top pane of the debugger shows a stack of Contexts as returned by "thisContext stack" which is effectively is for * execution flow return to caller's next statement And from what I learnt writing #stackValueMap above it seems , that each Context has its own stack for: * function parameters * function local variables * calculations / parameter marshalling for message sends So how should the second stack be referred to? Any of the following? * methodStackValues? * contextStackValues? * valueStack? * stackValues? and btw I wonder if Context>>stack would be better named Context>>callStack Here is my current refinement of the methods... Context>>stackValues | stackValues stackDepth| stackValues := OrderedCollection new. stackDepth := self basicSize min: 21. (stackDepth to: 1 by: -1) do: [ :index | stackValues add: (self basicAt: index) ]. ^stackValues Context>>composite <gtInspectorPresentationOrder: 30> |stackValues| stackValues := self stackValues. ^ composite table title: 'Value Stack'; display: [ :aCollection | [(1 to: stackValues size) collect: [ :index | index -> (stackValues at: index) ]] on:Error do:[#()]]; beMultiple; column: 'Index' evaluated: [ :assoc | (assoc key = 1 ifTrue: ['Top'] ifFalse: [ assoc key asString ])] width: 50; column: 'Item' evaluated: [ :assoc | GTObjectPrinter new asTruncatedTextFrom: assoc value ]; send: [ :result | result isNil ifTrue: [ nil ] ifFalse: [ result value size = 1 ifTrue: [result anyOne value] ifFalse: [self species withAll: (result collect: [:each | each value])]]]; showOnly: 50 cheers -ben |
Free forum by Nabble | Edit this page |