109 |
109 |
110 "/ #doIt needs special handling below |
110 "/ #doIt needs special handling below |
111 isDoIt := (sel == #doIt) or:[sel == #doIt:]. |
111 isDoIt := (sel == #doIt) or:[sel == #doIt:]. |
112 method := methodHomeContext method. |
112 method := methodHomeContext method. |
113 |
113 |
114 "/ implementorClass := methodHomeContext methodClass. |
|
115 "/ implementorClass notNil ifTrue:[ |
|
116 "/ method := implementorClass compiledMethodAt:sel. |
|
117 "/ ] ifFalse:[ |
|
118 "/ "/ mhm - an unbound method; |
|
119 "/ "/ see if it was invoked by a direct call |
|
120 "/ "/ consider this a kludge |
|
121 "/ |
|
122 "/ methodHomeContext sender notNil ifTrue:[ |
|
123 "/ (methodHomeContext sender selector startsWith:'valueWithReceiver:') ifTrue:[ |
|
124 "/ method := methodHomeContext sender receiver |
|
125 "/ ] |
|
126 "/ ] |
|
127 "/ ]. |
|
128 |
|
129 (method notNil and:[method isWrapped]) ifTrue:[ |
114 (method notNil and:[method isWrapped]) ifTrue:[ |
130 " |
115 "/ in a wrapped context, locals are something different |
131 in a wrapped context, locals are something different |
116 argsOnly := true. |
132 " |
|
133 "/ argsOnly := true. |
|
134 |
117 |
135 m := method originalMethod. |
118 m := method originalMethod. |
136 m notNil ifTrue:[ |
119 m notNil ifTrue:[ |
137 method := m. |
120 method := m. |
138 ] ifFalse:[ |
121 ] ifFalse:[ |
139 argsOnly := true. |
122 argsOnly := true. |
140 ]. |
123 ]. |
141 ]. |
124 ]. |
142 |
125 |
143 method notNil ifTrue:[ |
126 method notNil ifTrue:[ |
144 "/ method source notNil ifTrue:[ |
127 argsOnly ifFalse:[ |
145 |
128 homeNames := method methodArgAndVarNames. |
146 argsOnly ifTrue:[ |
129 |
147 homeNames := method methodArgNames |
130 "/ did it already allocate its locals ? |
148 ] ifFalse:[ |
131 (homeNames size > (methodHomeContext numArgs + methodHomeContext numVars)) ifTrue:[ |
149 homeNames := method methodArgAndVarNames. |
132 argsOnly := true. |
150 |
|
151 "/ did it already allocate its locals ? |
|
152 homeNames size > (methodHomeContext numArgs + methodHomeContext numVars) |
|
153 ifTrue:[ |
|
154 homeNames := method methodArgNames. |
|
155 argsOnly := true. |
|
156 ]. |
|
157 ]. |
133 ]. |
158 |
134 ]. |
159 "/ there is one case, where the above is by purpose: |
135 argsOnly ifTrue:[ |
160 "/ the #doIt - method, which has been given an invalid |
136 homeNames := method methodArgNames |
161 "/ source. |
137 ]. |
162 "/ care for this here. |
138 |
163 |
139 "/ there is one case, where the above is by purpose: |
164 isDoIt ifTrue:[ |
140 "/ the #doIt - method, which has been given an invalid |
165 homeNames := #(). |
141 "/ source. |
166 ] ifFalse:[ |
142 "/ care for this here. |
167 |
143 |
168 "/ check |
144 isDoIt ifTrue:[ |
169 |
145 homeNames := #(). |
170 numVarsInContext := methodHomeContext argsAndVars size. |
146 ] ifFalse:[ |
171 numVarsInSource := homeNames size. |
147 "/ check |
172 |
148 numVarsInContext := methodHomeContext argsAndVars size. |
173 numVarsInSource > 0 ifTrue:[ |
149 numVarsInSource := homeNames size. |
174 numVarsInContext < numVarsInSource ifTrue:[ |
150 |
175 |
151 numVarsInSource > 0 ifTrue:[ |
176 "/ the methods source does not correctly reflect |
152 numVarsInContext < numVarsInSource ifTrue:[ |
177 "/ the number of args&vars in the context. |
153 "/ the methods source does not correctly reflect |
178 "/ either outDated, or somehow strange. |
154 "/ the number of args&vars in the context. |
179 "/ (happens with wrapped methods, which are not |
155 "/ either outDated, or somehow strange. |
180 "/ what they look) |
156 "/ (happens with wrapped methods, which are not |
181 |
157 "/ what they look) |
182 numVarsInSource > numVarsInContext ifTrue:[ |
158 |
183 homeNames := homeNames copyTo:numVarsInContext. |
159 numVarsInSource > numVarsInContext ifTrue:[ |
|
160 homeNames := homeNames copyTo:numVarsInContext. |
|
161 ] ifFalse:[ |
|
162 numVarsInContext >= methodHomeContext numArgs ifTrue:[ |
|
163 homeNames := homeNames copyTo:methodHomeContext numArgs |
184 ] ifFalse:[ |
164 ] ifFalse:[ |
185 numVarsInContext >= methodHomeContext numArgs ifTrue:[ |
165 homeNames := nil |
186 homeNames := homeNames copyTo:methodHomeContext numArgs |
166 ] |
187 ] ifFalse:[ |
|
188 homeNames := nil |
|
189 ] |
|
190 ] |
|
191 ] |
167 ] |
192 ] |
168 ] |
193 ] |
169 ] |
194 "/ ] |
170 ] |
195 ]. |
171 ]. |
196 |
172 |
197 " |
173 " |
198 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) |
199 " |
175 " |
219 homeNames add:('mTmp' , index printString) |
195 homeNames add:('mTmp' , index printString) |
220 ] |
196 ] |
221 ]. |
197 ]. |
222 |
198 |
223 n := homeNames size. |
199 n := homeNames size. |
224 n < (methodHomeContext numVars + methodHomeContext numArgs) ifTrue:[ |
200 n < ((argsOnly ifTrue:[0] ifFalse:[ methodHomeContext numVars]) + methodHomeContext numArgs) ifTrue:[ |
225 "/ its a context which includes locals from |
201 "/ its a context which includes locals from |
226 "/ inlined sub-blocks. |
202 "/ inlined sub-blocks. |
227 "/ First, generate synthetic varNames ... |
203 "/ First, generate synthetic varNames ... |
228 |
204 |
229 homeNames := homeNames asOrderedCollection. |
205 homeNames := homeNames asOrderedCollection. |