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