34
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
45
|
3 |
All Rights Reserved
|
34
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
73
|
13 |
'From Smalltalk/X, Version:2.10.4 on 28-feb-1995 at 2:11:55 am'!
|
|
14 |
|
34
|
15 |
InspectorView subclass:#ContextInspectorView
|
73
|
16 |
instanceVariableNames:'inspectedContext values names showingTemporaries'
|
45
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-Inspector'
|
34
|
20 |
!
|
|
21 |
|
|
22 |
ContextInspectorView comment:'
|
|
23 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
45
|
24 |
All Rights Reserved
|
34
|
25 |
|
124
|
26 |
$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.14 1995-08-28 16:12:56 claus Exp $
|
34
|
27 |
'!
|
|
28 |
|
|
29 |
!ContextInspectorView class methodsFor:'documentation'!
|
|
30 |
|
|
31 |
copyright
|
|
32 |
"
|
|
33 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
45
|
34 |
All Rights Reserved
|
34
|
35 |
|
|
36 |
This software is furnished under a license and may be used
|
|
37 |
only in accordance with the terms of that license and with the
|
|
38 |
inclusion of the above copyright notice. This software may not
|
|
39 |
be provided or otherwise made available to, or used by, any
|
|
40 |
other person. No title to or ownership of the software is
|
|
41 |
hereby transferred.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
version
|
|
46 |
"
|
124
|
47 |
$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.14 1995-08-28 16:12:56 claus Exp $
|
34
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
documentation
|
|
52 |
"
|
|
53 |
a modified Inspector for Contexts (used in Debugger)
|
|
54 |
"
|
|
55 |
! !
|
|
56 |
|
73
|
57 |
!ContextInspectorView methodsFor:'private'!
|
51
|
58 |
|
73
|
59 |
setDoitActionIn:aWorkspace for:aContext
|
|
60 |
aWorkspace doItAction:[:theCode |
|
|
61 |
Compiler evaluate:theCode
|
|
62 |
in:aContext
|
|
63 |
receiver:nil
|
|
64 |
notifying:aWorkspace
|
|
65 |
logged:true
|
|
66 |
ifFail:nil
|
|
67 |
]
|
51
|
68 |
!
|
|
69 |
|
73
|
70 |
valueAtLine:lineNr
|
|
71 |
"helper - return the value of the selected entry"
|
|
72 |
|
|
73 |
^ values at:lineNr.
|
|
74 |
|
|
75 |
|
|
76 |
!
|
|
77 |
|
|
78 |
fieldList
|
|
79 |
^ names
|
51
|
80 |
! !
|
|
81 |
|
34
|
82 |
!ContextInspectorView methodsFor:'accessing'!
|
|
83 |
|
|
84 |
inspect:con
|
|
85 |
"set the context to be inspected"
|
|
86 |
|
107
|
87 |
|homeContext method homeNames rec sel implementorClass
|
98
|
88 |
argNames varNames tmpNames m argsOnly|
|
34
|
89 |
|
73
|
90 |
hasMore := false.
|
34
|
91 |
inspectedObject := nil.
|
|
92 |
inspectedContext := con.
|
98
|
93 |
argsOnly := false.
|
49
|
94 |
|
34
|
95 |
con isNil ifTrue:[
|
73
|
96 |
names := nil.
|
|
97 |
values := nil.
|
|
98 |
listView list:nil.
|
45
|
99 |
^ self
|
34
|
100 |
].
|
|
101 |
|
56
|
102 |
"/ realized ifFalse:[^ self].
|
|
103 |
|
34
|
104 |
homeContext := con methodHome.
|
51
|
105 |
|
|
106 |
homeContext isNil ifTrue:[
|
|
107 |
"its a cheap blocks context"
|
|
108 |
rec := con receiver.
|
|
109 |
sel := con selector.
|
73
|
110 |
homeNames := OrderedCollection new.
|
51
|
111 |
] ifFalse:[
|
|
112 |
rec := homeContext receiver.
|
|
113 |
sel := homeContext selector.
|
34
|
114 |
|
55
|
115 |
implementorClass := homeContext methodClass.
|
51
|
116 |
implementorClass notNil ifTrue:[
|
|
117 |
method := implementorClass compiledMethodAt:sel.
|
57
|
118 |
method notNil ifTrue:[
|
|
119 |
method isWrapped ifTrue:[
|
98
|
120 |
"
|
|
121 |
in a wrapped context, locals are something different
|
|
122 |
"
|
124
|
123 |
"/ argsOnly := true.
|
57
|
124 |
m := method originalMethod.
|
|
125 |
m notNil ifTrue:[
|
|
126 |
method := m.
|
124
|
127 |
] ifFalse:[
|
|
128 |
argsOnly := true.
|
|
129 |
].
|
57
|
130 |
].
|
51
|
131 |
].
|
57
|
132 |
method notNil ifTrue:[
|
|
133 |
method source notNil ifTrue:[
|
98
|
134 |
argsOnly ifTrue:[
|
|
135 |
homeNames := method methodArgNames
|
|
136 |
] ifFalse:[
|
|
137 |
homeNames := method methodArgAndVarNames.
|
|
138 |
]
|
73
|
139 |
]
|
124
|
140 |
].
|
73
|
141 |
].
|
|
142 |
|
|
143 |
"
|
|
144 |
create dummy names for method vars (if there is no source available)
|
|
145 |
"
|
|
146 |
homeNames isNil ifTrue:[
|
|
147 |
homeNames := OrderedCollection new.
|
|
148 |
1 to:homeContext numArgs do:[:index |
|
|
149 |
homeNames add:('mArg' , index printString)
|
|
150 |
].
|
98
|
151 |
argsOnly ifFalse:[
|
|
152 |
1 to:homeContext nvars do:[:index |
|
|
153 |
homeNames add:('mVar' , index printString)
|
|
154 |
].
|
|
155 |
showingTemporaries ifTrue:[
|
|
156 |
1 to:homeContext ntemp do:[:index |
|
|
157 |
homeNames add:('mTmp' , index printString)
|
|
158 |
]
|
51
|
159 |
]
|
|
160 |
]
|
|
161 |
].
|
34
|
162 |
].
|
51
|
163 |
|
34
|
164 |
"
|
|
165 |
stupid: should find the block via the contexts
|
|
166 |
method-home and put real names in here
|
|
167 |
"
|
|
168 |
con isBlockContext ifTrue:[
|
73
|
169 |
names := OrderedCollection new.
|
|
170 |
|
45
|
171 |
argNames := (1 to:(con numArgs)) collect:[:i | 'arg' , i printString].
|
73
|
172 |
names addAll:argNames.
|
45
|
173 |
varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
|
73
|
174 |
names addAll:varNames.
|
51
|
175 |
|
|
176 |
showingTemporaries ifTrue:[
|
|
177 |
tmpNames := (1 to:(con ntemp)) collect:[:i | 'tmp' , i printString].
|
73
|
178 |
names addAll:tmpNames.
|
51
|
179 |
].
|
|
180 |
|
73
|
181 |
names addAll:homeNames.
|
51
|
182 |
|
73
|
183 |
values := Array withAll:(con argsAndVars).
|
51
|
184 |
(showingTemporaries and:[con ntemp ~~ 0]) ifTrue:[
|
73
|
185 |
values := values , con temporaries
|
51
|
186 |
].
|
|
187 |
homeContext notNil ifTrue:[
|
98
|
188 |
values := values , homeContext args.
|
|
189 |
argsOnly ifFalse:[
|
|
190 |
values := values , homeContext vars.
|
|
191 |
(showingTemporaries and:[homeContext ntemp ~~ 0])ifTrue:[
|
|
192 |
values := values , homeContext temporaries
|
|
193 |
]
|
51
|
194 |
].
|
|
195 |
].
|
|
196 |
|
34
|
197 |
] ifFalse:[
|
73
|
198 |
names := homeNames.
|
98
|
199 |
argsOnly ifTrue:[
|
|
200 |
values := homeContext args
|
|
201 |
] ifFalse:[
|
|
202 |
values := homeContext argsAndVars
|
|
203 |
]
|
34
|
204 |
].
|
73
|
205 |
|
|
206 |
listView list:names.
|
34
|
207 |
|
|
208 |
workspace contents:nil.
|
|
209 |
self setDoitActionIn:workspace for:con.
|
|
210 |
!
|
|
211 |
|
|
212 |
release
|
|
213 |
"release inspected object"
|
|
214 |
|
|
215 |
inspectedContext := nil.
|
73
|
216 |
names := values := nil.
|
34
|
217 |
super release
|
|
218 |
! !
|
|
219 |
|
73
|
220 |
!ContextInspectorView methodsFor:'user actions'!
|
|
221 |
|
|
222 |
showSelection:lineNr
|
|
223 |
"user clicked on an entry - show value in workspace"
|
|
224 |
|
|
225 |
workspace replace:(values at:lineNr) displayString.
|
|
226 |
selectedLine := lineNr
|
34
|
227 |
|
73
|
228 |
|
|
229 |
!
|
34
|
230 |
|
73
|
231 |
showTemporaries
|
|
232 |
showingTemporaries := true.
|
|
233 |
self inspect:inspectedContext
|
|
234 |
!
|
34
|
235 |
|
|
236 |
doAccept:theText
|
|
237 |
|value|
|
|
238 |
|
|
239 |
selectedLine notNil ifTrue:[
|
45
|
240 |
value := Compiler evaluate:theText
|
|
241 |
receiver:inspectedObject
|
|
242 |
notifying:workspace.
|
34
|
243 |
|
45
|
244 |
"yes, you can do that with a context"
|
|
245 |
inspectedContext at:selectedLine put:value.
|
34
|
246 |
].
|
51
|
247 |
!
|
|
248 |
|
|
249 |
hideTemporaries
|
|
250 |
showingTemporaries := false.
|
|
251 |
self inspect:inspectedContext
|
34
|
252 |
! !
|
51
|
253 |
|
73
|
254 |
!ContextInspectorView methodsFor:'initialization'!
|
51
|
255 |
|
73
|
256 |
initialize
|
|
257 |
super initialize.
|
|
258 |
showingTemporaries := false.
|
|
259 |
|
|
260 |
!
|
|
261 |
|
|
262 |
fieldMenu
|
|
263 |
|labels selectors|
|
|
264 |
|
|
265 |
showingTemporaries ifFalse:[
|
|
266 |
labels := #(
|
|
267 |
'inspect'
|
|
268 |
'basicInspect'
|
|
269 |
'-'
|
|
270 |
'show temporaries'
|
|
271 |
).
|
|
272 |
selectors := #(
|
|
273 |
doInspect
|
|
274 |
doBasicInspect
|
|
275 |
nil
|
|
276 |
showTemporaries
|
|
277 |
)
|
|
278 |
] ifTrue:[
|
|
279 |
labels := #(
|
|
280 |
'inspect'
|
|
281 |
'basicInspect'
|
|
282 |
'-'
|
|
283 |
'hide temporaries'
|
|
284 |
).
|
|
285 |
selectors := #(
|
|
286 |
doInspect
|
|
287 |
doBasicInspect
|
|
288 |
nil
|
|
289 |
hideTemporaries
|
|
290 |
)
|
|
291 |
].
|
|
292 |
|
|
293 |
^ PopUpMenu
|
|
294 |
labels:(resources array:labels)
|
|
295 |
selectors:selectors
|
|
296 |
! !
|