Class.st
changeset 7833 08f541e77f8e
parent 7755 08b4e0bca2e3
child 7866 6624a55c7dd0
equal deleted inserted replaced
7832:f8a02752ca28 7833:08f541e77f8e
  1236       is gone ...)"
  1236       is gone ...)"
  1237 
  1237 
  1238     |nm newClass|
  1238     |nm newClass|
  1239 
  1239 
  1240     self wasAutoloaded ifFalse:[
  1240     self wasAutoloaded ifFalse:[
  1241 	"
  1241         "
  1242 	 can it be done ?
  1242          can it be done ?
  1243 	 (all of my methods must have a source)
  1243          (all of my methods must have a source)
  1244 	"
  1244         "
  1245 	self instAndClassSelectorsAndMethodsDo:[:sel :aMethod |
  1245         self instAndClassSelectorsAndMethodsDo:[:sel :aMethod |
  1246 	    aMethod source isNil ifTrue:[^false].
  1246             aMethod source isNil ifTrue:[^false].
  1247 	    aMethod hasPrimitiveCode ifTrue:[^ false].
  1247             aMethod hasPrimitiveCode ifTrue:[^ false].
  1248 	].
  1248         ].
  1249     ].
  1249     ].
  1250 
  1250 
  1251     "/ cannot unload, if non-autoloaded subclasses exist ...
  1251     "/ cannot unload, if non-autoloaded subclasses exist ...
  1252     self allSubclassesDo:[:aClass |
  1252     self allSubclassesDo:[:aClass |
  1253 	aClass wasAutoloaded ifFalse:[
  1253         aClass wasAutoloaded ifFalse:[
  1254 	    aClass isPrivate ifFalse:[
  1254             aClass isPrivate ifFalse:[
  1255 		self warn:('cannot unload ' , self name , ' (' , aClass name , ' requires it').
  1255                 self warn:('cannot unload ' , self name , ' (' , aClass name , ' requires it)').
  1256 		^ self.
  1256                 ^ false.
  1257 	    ]
  1257             ]
  1258 	]
  1258         ]
  1259     ].
  1259     ].
  1260 
  1260 
  1261     self allSubclassesDo:[:aClass |
  1261     self allSubclassesDo:[:aClass |
  1262 	aClass wasAutoloaded ifTrue:[
  1262         aClass wasAutoloaded ifTrue:[
  1263 	    aClass unload
  1263             aClass unload
  1264 	] ifFalse:[
  1264         ] ifFalse:[
  1265 	    aClass removeFromSystem.
  1265             aClass removeFromSystem.
  1266 	]
  1266         ]
  1267     ].
  1267     ].
  1268     self privateClasses do:[:aClass |
  1268     self privateClasses do:[:aClass |
  1269 	aClass removeFromSystem.
  1269         aClass removeFromSystem.
  1270     ].
  1270     ].
  1271     Transcript showCR:'unloading ' , name , ' ...'.
  1271     Transcript showCR:'unloading ' , name , ' ...'.
  1272 
  1272 
  1273     "/ reinstall as autoloaded
  1273     "/ reinstall as autoloaded
  1274     Autoload removeClass:self.    
  1274     Autoload removeClass:self.    
  1276     Smalltalk at:nm put:nil.
  1276     Smalltalk at:nm put:nil.
  1277     ObjectMemory flushInlineCaches.
  1277     ObjectMemory flushInlineCaches.
  1278     ObjectMemory flushMethodCache.
  1278     ObjectMemory flushMethodCache.
  1279     newClass := Autoload addClass:nm inCategory:category.
  1279     newClass := Autoload addClass:nm inCategory:category.
  1280     newClass notNil ifTrue:[
  1280     newClass notNil ifTrue:[
  1281 	newClass package:package
  1281         newClass package:package
  1282     ].
  1282     ].
  1283     Smalltalk flushCachedClasses.
  1283     Smalltalk flushCachedClasses.
  1284     ^ true
  1284     ^ true
  1285 
  1285 
  1286     "
  1286     "
  4808 ! !
  4808 ! !
  4809 
  4809 
  4810 !Class class methodsFor:'documentation'!
  4810 !Class class methodsFor:'documentation'!
  4811 
  4811 
  4812 version
  4812 version
  4813     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.451 2003-11-18 09:07:19 cg Exp $'
  4813     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.452 2004-01-23 15:55:51 penk Exp $'
  4814 ! !
  4814 ! !