54 |
54 |
55 inspect:aContext |
55 inspect:aContext |
56 "set the context to be inspected" |
56 "set the context to be inspected" |
57 |
57 |
58 |homeContext method homeNames rec sel implementorClass |
58 |homeContext method homeNames rec sel implementorClass |
59 argNames varNames tmpNames m argsOnly blockNode vars| |
59 argNames varNames tmpNames m argsOnly blockNode vars |
|
60 numVarsInSource numVarsInContext isDoIt |
|
61 numArgs numVars| |
60 |
62 |
61 (aContext == inspectedContext) ifTrue:[ |
63 (aContext == inspectedContext) ifTrue:[ |
62 listView selection notNil ifTrue:[ |
64 listView selection notNil ifTrue:[ |
63 self showSelection:(listView selection). |
65 self showSelection:(listView selection). |
64 ]. |
66 ]. |
82 homeContext isNil ifTrue:[ |
84 homeContext isNil ifTrue:[ |
83 "its a cheap blocks context" |
85 "its a cheap blocks context" |
84 rec := aContext receiver. |
86 rec := aContext receiver. |
85 sel := aContext selector. |
87 sel := aContext selector. |
86 homeNames := OrderedCollection new. |
88 homeNames := OrderedCollection new. |
|
89 isDoIt := false. |
87 ] ifFalse:[ |
90 ] ifFalse:[ |
88 rec := homeContext receiver. |
91 rec := homeContext receiver. |
89 sel := homeContext selector. |
92 sel := homeContext selector. |
90 |
93 |
91 implementorClass := homeContext methodClass. |
94 "/ #doIt needs special handling below |
92 implementorClass notNil ifTrue:[ |
95 isDoIt := (sel == #doIt) or:[sel == #doIt:]. |
93 method := implementorClass compiledMethodAt:sel. |
96 |
94 method notNil ifTrue:[ |
97 method := homeContext method. |
95 method isWrapped ifTrue:[ |
98 |
96 " |
99 "/ implementorClass := homeContext methodClass. |
97 in a wrapped context, locals are something different |
100 "/ implementorClass notNil ifTrue:[ |
98 " |
101 "/ method := implementorClass compiledMethodAt:sel. |
99 "/ argsOnly := true. |
102 "/ ] ifFalse:[ |
100 m := method originalMethod. |
103 "/ "/ mhm - an unbound method; |
101 m notNil ifTrue:[ |
104 "/ "/ see if it was invoked by a direct call |
102 method := m. |
105 "/ "/ consider this a kludge |
103 ] ifFalse:[ |
106 "/ |
|
107 "/ homeContext sender notNil ifTrue:[ |
|
108 "/ (homeContext sender selector startsWith:'valueWithReceiver:') ifTrue:[ |
|
109 "/ method := homeContext sender receiver |
|
110 "/ ] |
|
111 "/ ] |
|
112 "/ ]. |
|
113 |
|
114 (method notNil |
|
115 and:[method isWrapped]) ifTrue:[ |
|
116 " |
|
117 in a wrapped context, locals are something different |
|
118 " |
|
119 "/ argsOnly := true. |
|
120 m := method originalMethod. |
|
121 m notNil ifTrue:[ |
|
122 method := m. |
|
123 ] ifFalse:[ |
|
124 argsOnly := true. |
|
125 ]. |
|
126 ]. |
|
127 |
|
128 method notNil ifTrue:[ |
|
129 method source notNil ifTrue:[ |
|
130 argsOnly ifTrue:[ |
|
131 homeNames := method methodArgNames |
|
132 ] ifFalse:[ |
|
133 homeNames := method methodArgAndVarNames. |
|
134 |
|
135 "/ did it already allocate its locals ? |
|
136 homeNames size - method methodArgNames size == homeContext numVars |
|
137 ifFalse:[ |
|
138 homeNames := method methodArgNames. |
104 argsOnly := true. |
139 argsOnly := true. |
105 ]. |
140 ]. |
106 ]. |
141 ]. |
107 ]. |
142 |
108 method notNil ifTrue:[ |
143 "/ there is one case, where the above is by purpose: |
109 method source notNil ifTrue:[ |
144 "/ the #doIt - method, which has been given an invalid |
110 argsOnly ifTrue:[ |
145 "/ source. |
111 homeNames := method methodArgNames |
146 "/ care for this here. |
112 ] ifFalse:[ |
147 |
113 homeNames := method methodArgAndVarNames. |
148 isDoIt ifTrue:[ |
114 |
149 homeNames := #(). |
115 "/ did it already allocate its locals ? |
150 ] ifFalse:[ |
116 homeNames size - method methodArgNames size == homeContext numVars |
151 |
117 ifFalse:[ |
152 "/ check |
118 homeNames := method methodArgNames. |
153 |
119 argsOnly := true |
154 numVarsInContext := homeContext argsAndVars size. |
|
155 numVarsInSource := homeNames size. |
|
156 |
|
157 numVarsInContext ~~ numVarsInSource ifTrue:[ |
|
158 |
|
159 "/ the methods source does not correctly reflect |
|
160 "/ the number of args&vars in the context. |
|
161 "/ either outDated, or somehow strange. |
|
162 |
|
163 numVarsInSource > numVarsInContext ifTrue:[ |
|
164 homeNames := homeNames copyTo:numVarsInContext. |
|
165 ] ifFalse:[ |
|
166 homeNames := nil |
120 ] |
167 ] |
121 ] |
168 ] |
122 ] |
169 ] |
123 ]. |
170 ] |
124 ]. |
171 ]. |
125 |
172 |
126 " |
173 " |
127 create dummy names for method vars (if there is no source available) |
174 create dummy names for method vars (if there is no source available) |
128 " |
175 " |
147 " |
194 " |
148 stupid: should find the block via the contexts |
195 stupid: should find the block via the contexts |
149 method-home and put real names in here |
196 method-home and put real names in here |
150 " |
197 " |
151 aContext isBlockContext ifTrue:[ |
198 aContext isBlockContext ifTrue:[ |
152 method notNil ifTrue:[ |
199 numArgs := aContext numArgs. |
153 (aContext numArgs > 0 |
200 numVars := aContext numVars. |
154 or:[aContext numVars > 0]) ifTrue:[ |
201 |
155 blockNode := Compiler |
202 (numArgs > 0 or:[numVars > 0]) ifTrue:[ |
|
203 "/ special for #doIt |
|
204 "/ my source is found in the method. |
|
205 |
|
206 isDoIt ifTrue:[ |
|
207 blockNode := Compiler |
156 blockAtLine:(aContext lineNumber) |
208 blockAtLine:(aContext lineNumber) |
157 in:method |
209 in:nil |
158 numArgs:aContext numArgs |
210 orSource:('[' , method source , '\]') withCRs |
159 numVars:aContext numVars. |
211 numArgs:numArgs |
160 blockNode notNil ifTrue:[ |
212 numVars:numVars. |
161 aContext numArgs > 0 ifTrue:[ |
213 |
162 vars := blockNode arguments. |
214 ] ifFalse:[ |
163 vars size > 0 ifTrue:[ |
215 method notNil ifTrue:[ |
164 argNames := vars collect:[:var | var name] |
216 blockNode := Compiler |
165 ] |
217 blockAtLine:(aContext lineNumber) |
166 ]. |
218 in:method |
167 aContext numVars > 0 ifTrue:[ |
219 orSource:nil |
168 vars := blockNode variables. |
220 numArgs:numArgs |
169 vars size > 0 ifTrue:[ |
221 numVars:numVars. |
170 varNames := vars collect:[:var | var name]. |
222 ] |
171 ] |
223 ]. |
|
224 |
|
225 blockNode notNil ifTrue:[ |
|
226 numArgs > 0 ifTrue:[ |
|
227 vars := blockNode arguments. |
|
228 vars size > 0 ifTrue:[ |
|
229 argNames := vars collect:[:var | var name] |
172 ] |
230 ] |
173 ] |
231 ]. |
174 ] |
232 numVars > 0 ifTrue:[ |
|
233 vars := blockNode variables. |
|
234 vars size > 0 ifTrue:[ |
|
235 varNames := vars collect:[:var | var name]. |
|
236 ] |
|
237 ] |
|
238 ]. |
175 ]. |
239 ]. |
176 |
240 |
177 names := OrderedCollection new. |
241 names := OrderedCollection new. |
178 |
242 |
179 argNames isNil ifTrue:[ |
243 argNames isNil ifTrue:[ |
180 argNames := (1 to:(aContext numArgs)) collect:[:i | 'arg' , i printString]. |
244 argNames := (1 to:numArgs) collect:[:i | 'arg' , i printString]. |
181 ]. |
245 ]. |
182 |
246 |
183 names addAll:argNames. |
247 names addAll:argNames. |
184 varNames isNil ifTrue:[ |
248 varNames isNil ifTrue:[ |
185 varNames := (1 to:(aContext numVars)) collect:[:i | 'var' , i printString]. |
249 varNames := (1 to:numVars) collect:[:i | 'var' , i printString]. |
186 ] ifFalse:[ |
250 ] ifFalse:[ |
187 varNames size ~~ aContext numVars ifTrue:[ |
251 varNames size ~~ numVars ifTrue:[ |
188 varNames := varNames asOrderedCollection. |
252 varNames := varNames asOrderedCollection. |
189 varNames size+1 to:aContext numVars do:[:i | |
253 varNames size+1 to:aContext numVars do:[:i | |
190 varNames add:('var' , i printString) |
254 varNames add:('var' , i printString) |
191 ] |
255 ] |
192 ] |
256 ] |
198 tmpNames := (1 to:(aContext numTemps)) collect:[:i | 'tmp' , i printString]. |
262 tmpNames := (1 to:(aContext numTemps)) collect:[:i | 'tmp' , i printString]. |
199 names addAll:tmpNames. |
263 names addAll:tmpNames. |
200 ]. |
264 ]. |
201 |
265 |
202 names addAll:homeNames. |
266 names addAll:homeNames. |
|
267 |
203 ] ifFalse:[ |
268 ] ifFalse:[ |
204 names := homeNames. |
269 names := homeNames. |
205 ]. |
270 ]. |
206 |
271 |
207 listView list:names. |
272 listView list:names. |
208 |
273 |
209 workspace contents:nil. |
274 workspace contents:nil. |
210 self setDoitActionIn:workspace for:aContext. |
275 self setDoitActionIn:workspace for:aContext. |
211 |
276 |
212 "Modified: 7.11.1996 / 17:21:21 / cg" |
277 "Modified: 11.1.1997 / 23:51:59 / cg" |
213 ! |
278 ! |
214 |
279 |
215 release |
280 release |
216 "release inspected object" |
281 "release inspected object" |
217 |
282 |