203 ] |
203 ] |
204 |
204 |
205 |
205 |
206 more examples, which try to trick the VM ;-): |
206 more examples, which try to trick the VM ;-): |
207 badly playing around with a classes internals ... |
207 badly playing around with a classes internals ... |
208 |
|
209 |newClass someInstance| |
|
210 |
|
211 newClass := Class new. |
|
212 newClass setSelectorArray:nil. |
|
213 someInstance := newClass new. |
|
214 someInstance inspect |
|
215 |
|
216 |
208 |
217 |newClass someInstance| |
209 |newClass someInstance| |
218 |
210 |
219 newClass := Class new. |
211 newClass := Class new. |
220 newClass setSuperclass:nil. |
212 newClass setSuperclass:nil. |
2273 "set the receivers method dictionary. |
2265 "set the receivers method dictionary. |
2274 Convert dict to a MethodDictionary if necessary. |
2266 Convert dict to a MethodDictionary if necessary. |
2275 Do not flush inline caches, therefore old cached methods may be executed |
2267 Do not flush inline caches, therefore old cached methods may be executed |
2276 after this call" |
2268 after this call" |
2277 |
2269 |
|
2270 "/ since the only thing the VM is prepared to deal with are |
|
2271 "/ proper methodDictionaries (it cannot do another message send, to |
|
2272 "/ find any methods ...), we convert it here if required. |
|
2273 "/ No other classes instances are allowed. |
|
2274 |
2278 dict class ~~ MethodDictionary ifTrue:[ |
2275 dict class ~~ MethodDictionary ifTrue:[ |
2279 methodDictionary := MethodDictionary withAll:dict. |
2276 methodDictionary := MethodDictionary withAll:dict. |
2280 methodDictionary isNil ifTrue:[ |
2277 methodDictionary isNil ifTrue:[ |
2281 self halt:'cannot set methodDictionary to nil'. |
2278 |
2282 ^ self. |
2279 "/ refuse to do this |
2283 ] |
2280 "/ (can only happen in case of memory allocation trouble, |
|
2281 "/ where the allocation failed and some exception handler returned |
|
2282 "/ nil ...) |
|
2283 |
|
2284 self halt:'cannot set methodDictionary to nil'. |
|
2285 ^ self. |
|
2286 ] |
2284 ] ifFalse:[ |
2287 ] ifFalse:[ |
2285 methodDictionary := dict. |
2288 methodDictionary := dict. |
2286 ]. |
2289 ]. |
2287 ^ self. |
2290 ^ self. |
2288 |
2291 |
2289 "Created: 5.6.1996 / 11:29:36 / stefan" |
2292 "Created: 5.6.1996 / 11:29:36 / stefan" |
2290 "Modified: 12.6.1996 / 13:58:55 / stefan" |
2293 "Modified: 12.6.1996 / 13:58:55 / stefan" |
|
2294 "Modified: 22.1.1997 / 21:10:48 / cg" |
2291 ! |
2295 ! |
2292 |
2296 |
2293 setOtherSuperclasses:anArrayOfClasses |
2297 setOtherSuperclasses:anArrayOfClasses |
2294 "EXPERIMENTAL: set the other superclasses of the receiver. |
2298 "EXPERIMENTAL: set the other superclasses of the receiver. |
2295 this method is for special uses only - there will be no recompilation |
2299 this method is for special uses only - there will be no recompilation |