128 |
128 |
129 |cls who mHome m className |
129 |cls who mHome m className |
130 sender selSender tryVars possibleBlocks method mWho| |
130 sender selSender tryVars possibleBlocks method mWho| |
131 |
131 |
132 (home isNil or:[home isContext not]) ifTrue:[ |
132 (home isNil or:[home isContext not]) ifTrue:[ |
133 " |
133 " |
134 mhmh - an optimized blocks context |
134 mhmh - an optimized blocks context |
135 should get the block here, and get the method from |
135 should get the block here, and get the method from |
136 that one ... |
136 that one ... |
137 ... but in 2.10.x, there is no easy way to get to the block |
137 ... but in 2.10.x, there is no easy way to get to the block |
138 since that one is not in the context. |
138 since that one is not in the context. |
139 Starting with 2.11, the new block calling scheme will fix this. |
139 Starting with 2.11, the new block calling scheme will fix this. |
140 " |
140 " |
141 |
141 |
142 "temporary kludge - peek into the sender context. |
142 "temporary kludge - peek into the sender context. |
143 If its a do-like method and there is a single block variable |
143 If its a do-like method and there is a single block variable |
144 in the args or temporaries, that must be the one. |
144 in the args or temporaries, that must be the one. |
145 This helps in some cases. |
145 This helps in some cases. |
146 " |
146 " |
147 (sender := self sender) notNil ifTrue:[ |
147 (sender := self sender) notNil ifTrue:[ |
148 tryVars := false. |
148 tryVars := false. |
149 (selSender := sender selector) notNil ifTrue:[ |
149 (selSender := sender selector) notNil ifTrue:[ |
150 (selSender endsWith:'do:') ifTrue:[ |
150 (selSender endsWith:'do:') ifTrue:[ |
151 tryVars := true. |
151 tryVars := true. |
152 ] ifFalse:[ |
152 ] ifFalse:[ |
153 (selSender endsWith:'Do:') ifTrue:[ |
153 (selSender endsWith:'Do:') ifTrue:[ |
154 tryVars := true. |
154 tryVars := true. |
155 ] |
155 ] |
156 ] |
156 ] |
157 ]. |
157 ]. |
158 tryVars ifTrue:[ |
158 tryVars ifTrue:[ |
159 possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
159 possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
160 possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
160 possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
161 |
161 |
162 possibleBlocks size == 1 ifTrue:[ |
162 possibleBlocks size == 1 ifTrue:[ |
163 method := possibleBlocks first method. |
163 method := possibleBlocks first method. |
164 " |
164 " |
165 change the line in the upper-listview |
165 change the line in the upper-listview |
166 according the information we have now |
166 according the information we have now |
167 " |
167 " |
168 mWho := method who. |
168 mWho := method who. |
169 ^ '[] (optimized) in ' , |
169 mWho isNil ifTrue:[ |
170 (mWho at:1) name , '-' , (mWho at:2). |
170 ^ '[] (optimized) in ???'. |
171 ]. |
171 ]. |
172 ] |
172 ^ '[] (optimized) in ' , |
173 ]. |
173 (mWho at:1) name , '-' , (mWho at:2). |
174 |
174 ]. |
175 ^ '[] optimized' |
175 ] |
|
176 ]. |
|
177 |
|
178 ^ '[] (optimized)' |
176 ]. |
179 ]. |
177 |
180 |
178 mHome := self methodHome. |
181 mHome := self methodHome. |
179 mHome isNil ifTrue:[ |
182 mHome isNil ifTrue:[ |
180 'BCONTEXT: no methodHome' errorPrintNL. |
183 'BCONTEXT: no methodHome' errorPrintNL. |
181 ^ '[] in ???' |
184 ^ '[] in ???' |
182 ]. |
185 ]. |
183 |
186 |
184 " |
187 " |
185 kludge to avoid slow search for containing class |
188 kludge to avoid slow search for containing class |
186 " |
189 " |
187 mHome selector == #doIt ifTrue:[ |
190 mHome selector == #doIt ifTrue:[ |
188 who := Array with:mHome receiver class |
191 who := Array with:mHome receiver class |
189 with:#doIt |
192 with:#doIt |
190 ] ifFalse:[ |
193 ] ifFalse:[ |
191 m := mHome method. |
194 m := mHome method. |
192 m isNil ifTrue:[ |
195 m isNil ifTrue:[ |
193 'BCONTEXT: no method' errorPrintNL. |
196 'BCONTEXT: no method' errorPrintNL. |
194 ^ '[] in ???' |
197 ^ '[] in ???' |
195 ]. |
198 ]. |
196 who := m who. |
199 who := m who. |
197 ]. |
200 ]. |
198 who notNil ifTrue:[ |
201 who notNil ifTrue:[ |
199 cls := who at:1 |
202 cls := who at:1 |
200 ] ifFalse:[ |
203 ] ifFalse:[ |
201 cls := receiver class. |
204 cls := receiver class. |
202 ]. |
205 ]. |
203 className := cls name. |
206 className := cls name. |
204 className isNil ifTrue:[ |
207 className isNil ifTrue:[ |
205 'BCONTEXT: nameless class' errorPrintNL. |
208 'BCONTEXT: nameless class' errorPrintNL. |
206 className := '???' |
209 className := '???' |
207 ]. |
210 ]. |
208 ^ '[] in ' , className , '-' , mHome selector printString |
211 ^ '[] in ' , className , '-' , mHome selector printString |
|
212 |
|
213 "Modified: 29.5.1996 / 13:56:47 / cg" |
209 ! ! |
214 ! ! |
210 |
215 |
211 !BlockContext class methodsFor:'documentation'! |
216 !BlockContext class methodsFor:'documentation'! |
212 |
217 |
213 version |
218 version |
214 ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.21 1996-04-25 16:49:34 cg Exp $' |
219 ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.22 1996-05-29 13:19:03 cg Exp $' |
215 ! ! |
220 ! ! |