117 |
117 |
118 !BlockContext methodsFor:'printing & storing'! |
118 !BlockContext methodsFor:'printing & storing'! |
119 |
119 |
120 receiverPrintString |
120 receiverPrintString |
121 "return a printString describing the contexts receiver. |
121 "return a printString describing the contexts receiver. |
122 Since this is called from the debugger, be very careful to |
122 |
|
123 Since this is also used by the debugger(s), be very careful to |
123 return something useful, even in case internals of the system |
124 return something useful, even in case internals of the system |
124 got corrupted ... (i.e. avoid messageNotUnderstood here)" |
125 got corrupted ... (i.e. avoid messageNotUnderstood here)" |
125 |
126 |
126 |cls who mHome m className| |
127 |cls who mHome m className |
127 |
128 sender selSender tryVars possibleBlocks method mWho| |
128 home isNil ifTrue:[ |
129 |
|
130 (home isNil or:[home isContext not]) ifTrue:[ |
|
131 " |
|
132 mhmh - an optimized blocks context |
|
133 should get the block here, and get the method from |
|
134 that one ... |
|
135 ... but in 2.10.x, there is no easy way to get to the block |
|
136 since that one is not in the context. |
|
137 Starting with 2.11, the new block calling scheme will fix this. |
|
138 " |
|
139 |
|
140 "temporary kludge - peek into the sender context. |
|
141 If its a do-like method and there is a single block variable |
|
142 in the args or temporaries, that must be the one. |
|
143 This helps in some cases. |
|
144 " |
|
145 (sender := self sender) notNil ifTrue:[ |
|
146 tryVars := false. |
|
147 (selSender := sender selector) notNil ifTrue:[ |
|
148 (selSender endsWith:'do:') ifTrue:[ |
|
149 tryVars := true. |
|
150 ] ifFalse:[ |
|
151 (selSender endsWith:'Do:') ifTrue:[ |
|
152 tryVars := true. |
|
153 ] |
|
154 ] |
|
155 ]. |
|
156 tryVars ifTrue:[ |
|
157 possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
|
158 possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
|
159 |
|
160 possibleBlocks size == 1 ifTrue:[ |
|
161 method := possibleBlocks first method. |
|
162 " |
|
163 change the line in the upper-listview |
|
164 according the information we have now |
|
165 " |
|
166 mWho := method who. |
|
167 ^ '[] (optimized) in ' , |
|
168 (mWho at:1) name , '-' , (mWho at:2). |
|
169 ]. |
|
170 ] |
|
171 ]. |
|
172 |
129 ^ '[] optimized' |
173 ^ '[] optimized' |
130 ]. |
174 ]. |
131 home isContext ifFalse:[ |
175 |
132 "a copying block" |
|
133 |
|
134 "/ receiverClassName := home selfValue class name. |
|
135 ^ '[] optimized' |
|
136 ]. |
|
137 mHome := self methodHome. |
176 mHome := self methodHome. |
138 mHome isNil ifTrue:[ |
177 mHome isNil ifTrue:[ |
139 'BCONTEXT: no methodHome' errorPrintNL. |
178 'BCONTEXT: no methodHome' errorPrintNL. |
140 ^ '[] in ???' |
179 ^ '[] in ???' |
141 ]. |
180 ]. |