2186 Q: should we add a backref from the method to the class |
2186 Q: should we add a backref from the method to the class |
2187 and/or add a subclass of Method for unbound ones ? |
2187 and/or add a subclass of Method for unbound ones ? |
2188 Q2: if so, what about the bad guy then, who copies methods around to |
2188 Q2: if so, what about the bad guy then, who copies methods around to |
2189 other classes ?" |
2189 other classes ?" |
2190 |
2190 |
2191 |classes cls sel| |
2191 |classes cls sel fn clsName| |
2192 |
2192 |
2193 " |
2193 " |
2194 very first, look in the class we found something the last time |
2194 speedup kludge: if my sourceFileName is valid, |
|
2195 extract the className from it and try that class first. |
|
2196 " |
|
2197 (fn := self sourceFilename) notNil ifTrue:[ |
|
2198 clsName := fn asFilename withoutSuffix name. |
|
2199 clsName := clsName asSymbolIfInterned. |
|
2200 clsName notNil ifTrue:[ |
|
2201 cls := Smalltalk at:clsName ifAbsent:nil. |
|
2202 cls notNil ifTrue:[ |
|
2203 sel := cls selectorAtMethod:self. |
|
2204 sel notNil ifTrue:[ |
|
2205 ^ MethodWhoInfo class:cls selector:sel |
|
2206 ]. |
|
2207 |
|
2208 cls := cls class. |
|
2209 sel := cls selectorAtMethod:self. |
|
2210 sel notNil ifTrue:[ |
|
2211 ^ MethodWhoInfo class:cls selector:sel |
|
2212 ]. |
|
2213 ] |
|
2214 ]. |
|
2215 ]. |
|
2216 |
|
2217 " |
|
2218 then, look in the class we found something the last time |
2195 this may often give a hit, when asking who repeatingly for |
2219 this may often give a hit, when asking who repeatingly for |
2196 a context chain. (keep last by its name, to not keep classes from |
2220 a context chain. (keep last by its name, to not keep classes from |
2197 being garbage collected) |
2221 being garbage collected) |
2198 " |
2222 " |
2199 LastWhoClass notNil ifTrue:[ |
2223 LastWhoClass notNil ifTrue:[ |