158 ^ nil |
158 ^ nil |
159 ! ! |
159 ! ! |
160 |
160 |
161 !BlockContext methodsFor:'printing & storing'! |
161 !BlockContext methodsFor:'printing & storing'! |
162 |
162 |
163 receiverPrintString |
163 printReceiverOn:aStream |
164 "return a printString describing the contexts receiver. |
164 "print a string describing the receiver of the context on aStream |
165 |
165 |
166 Since this is also used by the debugger(s), be very careful to |
166 Since this is also used by the debugger(s), be very careful to |
167 return something useful, even in case internals of the system |
167 return something useful, even in case internals of the system |
168 got corrupted ... (i.e. avoid messageNotUnderstood here)" |
168 got corrupted ... (i.e. avoid messageNotUnderstood here)" |
169 |
169 |
170 |cls who mHome m className sel homeSel| |
170 |cls who mHome m className homeSel| |
171 |
171 |
172 (home isNil or:[home isContext not]) ifTrue:[ |
172 home isContext ifFalse:[ |
173 " |
173 " |
174 mhmh - an optimized blocks context |
174 mhmh - an optimized blocks context |
175 should get the block here, and get the method from |
175 should get the block here, and get the method from |
176 that one ... |
176 that one ... |
177 ... but in 2.x, there is no easy way to get to the block |
177 ... but in 2.x, there is no easy way to get to the block |
184 in the args or temporaries, that must be the one. |
184 in the args or temporaries, that must be the one. |
185 This helps in some cases. |
185 This helps in some cases. |
186 " |
186 " |
187 m := self method. |
187 m := self method. |
188 m isNil ifTrue:[ |
188 m isNil ifTrue:[ |
189 ^ '[] (optimized) in ???'. |
189 aStream nextPutAll:'[] (optimized) in ???'. |
|
190 ] ifFalse:[ |
|
191 aStream nextPutAll:'[] in '. |
|
192 m mclass name printOn:aStream. |
|
193 aStream nextPutAll:'>>'. |
|
194 m selector printOn:aStream. |
190 ]. |
195 ]. |
191 ^ '[] in ' , m mclass name , ' >> ' , m selector. |
196 ^ self. |
192 ]. |
197 ]. |
193 |
198 |
194 mHome := self methodHome. |
199 mHome := self methodHome. |
195 mHome isNil ifTrue:[ |
200 mHome isNil ifTrue:[ |
196 'BlockContext [warning]: no methodHome' errorPrintCR. |
201 aStream nextPutAll:'[] (no methodHome!!) in ???'. |
197 ^ '[] in ???' |
202 ^ self. |
198 ]. |
203 ]. |
199 |
204 |
200 " |
205 " |
201 kludge to avoid slow search for containing class |
206 kludge to avoid slow search for containing class |
202 " |
207 " |
203 ((homeSel := mHome selector) == #doIt |
208 homeSel := mHome selector. |
204 or:[homeSel == #doIt:]) ifTrue:[ |
209 (homeSel == #doIt or:[homeSel == #doIt:]) ifTrue:[ |
205 sel := #doIt. |
|
206 cls := mHome receiver class. |
210 cls := mHome receiver class. |
|
211 homeSel := #doIt. |
207 ] ifFalse:[ |
212 ] ifFalse:[ |
208 m := mHome method. |
213 m := mHome method. |
209 m isNil ifTrue:[ |
214 m isNil ifTrue:[ |
210 'BlockContext [warning]: no method' errorPrintCR. |
215 aStream nextPutAll:'[] (no method!!) in ???'. |
211 ^ '[] in ???' |
216 ^ self. |
212 ]. |
217 ]. |
213 who := m who. |
218 who := m who. |
214 who notNil ifTrue:[ |
219 who notNil ifTrue:[ |
215 cls := who methodClass |
220 cls := who methodClass |
216 ] ifFalse:[ |
221 ] ifFalse:[ |
217 cls := receiver class. |
222 cls := receiver class. |
218 ]. |
223 ]. |
219 sel := homeSel printString. |
|
220 ]. |
224 ]. |
221 |
225 |
222 cls isNil ifTrue:[ |
226 cls isNil ifTrue:[ |
223 'BlockContext [warning]: no home class' errorPrintCR. |
227 className := '???(no home class!!)' |
224 className := '???' |
|
225 ] ifFalse:[ |
228 ] ifFalse:[ |
226 className := cls name. |
229 className := cls name. |
227 className isNil ifTrue:[ |
230 className isEmptyOrNil ifTrue:[ |
228 'BlockContext [warning]: nameless class' errorPrintCR. |
231 className := '???(nameless class!!)' |
229 className := '???' |
|
230 ] |
232 ] |
231 ]. |
233 ]. |
232 ^ '[] in ' , className , ' >> ' , sel |
234 aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:'>>'. |
|
235 homeSel printOn:aStream. |
233 |
236 |
234 "Modified: / 19-07-2012 / 11:02:41 / cg" |
237 "Modified: / 19-07-2012 / 11:02:41 / cg" |
235 ! ! |
238 ! ! |
236 |
239 |
237 !BlockContext methodsFor:'testing'! |
240 !BlockContext methodsFor:'testing'! |