Behavior.st
changeset 2228 ddcc662bd9b1
parent 2226 b59ec5725a9d
child 2230 b7a86880ab9c
equal deleted inserted replaced
2227:eb1e28c62f14 2228:ddcc662bd9b1
   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
  3432 ! !
  3436 ! !
  3433 
  3437 
  3434 !Behavior class methodsFor:'documentation'!
  3438 !Behavior class methodsFor:'documentation'!
  3435 
  3439 
  3436 version
  3440 version
  3437     ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.100 1997-01-22 19:30:51 cg Exp $'
  3441     ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.101 1997-01-22 20:11:17 cg Exp $'
  3438 ! !
  3442 ! !