Smalltalk.st
branchjv
changeset 18247 3c81bb9bbaea
parent 18200 3ddc4e7d42c0
child 18261 22bdfc405bca
equal deleted inserted replaced
18237:8457ae63fa44 18247:3c81bb9bbaea
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1988 by Claus Gittinger
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
  1279     aClass isNil ifTrue:[^ self].
  1277     aClass isNil ifTrue:[^ self].
  1280 
  1278 
  1281     oldName := aClass name.
  1279     oldName := aClass name.
  1282     sym := oldNameSym := oldName asSymbol.
  1280     sym := oldNameSym := oldName asSymbol.
  1283     ((self at:oldNameSym) == aClass) ifFalse:[
  1281     ((self at:oldNameSym) == aClass) ifFalse:[
  1284 	"check other name ..."
  1282         "check other name ..."
  1285 	(self includes:aClass) ifFalse:[
  1283         (self includes:aClass) ifFalse:[
  1286 	    'Smalltalk [warning]: no such class: ' errorPrint. oldName errorPrintCR.
  1284             'Smalltalk [warning]: no such class: ' errorPrint. oldName errorPrintCR.
  1287 	    ^ self
  1285             ^ self
  1288 	].
  1286         ].
  1289 	"
  1287         "
  1290 	 the class has changed its name - without telling me ...
  1288          the class has changed its name - without telling me ...
  1291 	 what should be done in this case ?
  1289          what should be done in this case ?
  1292 	"
  1290         "
  1293 	'Smalltalk [warning]: class ' errorPrint. oldName errorPrint.
  1291         'Smalltalk [warning]: class ' errorPrint. oldName errorPrint.
  1294 	' has changed its name' errorPrintCR.
  1292         ' has changed its name' errorPrintCR.
  1295 
  1293 
  1296 	"/
  1294         "/
  1297 	"/ might be an alias (i.e. removing a compatibility name)
  1295         "/ might be an alias (i.e. removing a compatibility name)
  1298 	"/
  1296         "/
  1299 	actualName := self keyAtValue:aClass.
  1297         actualName := self keyAtValue:aClass.
  1300 	('Smalltalk [info]: ' , oldName , ' is actually stored as ' , actualName , '.') infoPrintCR.
  1298         ('Smalltalk [info]: ' , oldName , ' is actually stored as ' , actualName , '.') infoPrintCR.
  1301 	sym := actualName asSymbol.
  1299         sym := actualName asSymbol.
  1302 	oldName := actualName asString.
  1300         oldName := actualName asString.
  1303 	wrongName := true.
  1301         wrongName := true.
  1304     ].
  1302     ].
  1305 
  1303 
  1306     ns := aClass nameSpace.
  1304     ns := aClass nameSpace.
  1307     aClass topOwningClass notNil ifTrue:[
  1305     aClass topOwningClass notNil ifTrue:[
  1308 	ons := aClass topOwningClass nameSpace
  1306         ons := aClass topOwningClass nameSpace
       
  1307     ].
       
  1308     aClass isBuiltInClass ifTrue:[ 
       
  1309         self error: 'Cannot remove builtin class!!'.        
  1309     ].
  1310     ].
  1310 
  1311 
  1311     self at:sym put:nil.    "nil it out for compiled accesses"
  1312     self at:sym put:nil.    "nil it out for compiled accesses"
  1312 
  1313 
  1313     "/
  1314     "/
  1314     "/ see comment in removeKey: on why we dont remove it here
  1315     "/ see comment in removeKey: on why we dont remove it here
  1315     "/
  1316     "/
  1316     "/ self removeKey:sym.     "/ remove key - this actually fails, if there are
  1317     "/ self removeKey:sym.     "/ remove key - this actually fails, if there are
  1317 			       "/ still compiled code references."
  1318                                "/ still compiled code references."
  1318 
  1319 
  1319     "remove private classes"
  1320     "remove private classes"
  1320 
  1321 
  1321     aClass privateClassesSorted do:[:somePrivateClass |
  1322     aClass privateClassesSorted do:[:somePrivateClass |
  1322 	aClass privateClassesAt:(somePrivateClass nameWithoutPrefix) asSymbol put:nil.
  1323         aClass privateClassesAt:(somePrivateClass nameWithoutPrefix) asSymbol put:nil.
  1323     ].
  1324     ].
  1324 
  1325 
  1325     "remove class variables"
  1326     "remove class variables"
  1326 
  1327 
  1327     names := aClass classVariableString asCollectionOfWords.
  1328     names := aClass classVariableString asCollectionOfWords.
  1328     names do:[:name |
  1329     names do:[:name |
  1329 	cSym := aClass globalKeyForClassVar:name.
  1330         cSym := aClass globalKeyForClassVar:name.
  1330 	self at:cSym asSymbol put:nil.
  1331         self at:cSym asSymbol put:nil.
  1331 
  1332 
  1332 	"/
  1333         "/
  1333 	"/ see comment in removeKey: on why we dont remove it here
  1334         "/ see comment in removeKey: on why we dont remove it here
  1334 	"/
  1335         "/
  1335 	"/ self removeKey:cSym
  1336         "/ self removeKey:cSym
  1336     ].
  1337     ].
  1337 
  1338 
  1338 
  1339 
  1339 "/    actually could get along with less flushing
  1340 "/    actually could get along with less flushing
  1340 "/    (entries for aClass and subclasses only)
  1341 "/    (entries for aClass and subclasses only)
  1362     self flushCachedClass:aClass.
  1363     self flushCachedClass:aClass.
  1363     Class flushSubclassInfoFor:aClass superclass.
  1364     Class flushSubclassInfoFor:aClass superclass.
  1364     Class flushSubclassInfoFor:aClass.
  1365     Class flushSubclassInfoFor:aClass.
  1365 
  1366 
  1366     wrongName == true ifTrue:[
  1367     wrongName == true ifTrue:[
  1367 	"/
  1368         "/
  1368 	"/ an alias (i.e. removing a compatibility name)
  1369         "/ an alias (i.e. removing a compatibility name)
  1369 	"/
  1370         "/
  1370 	"/ check if there are more refs to it ...
  1371         "/ check if there are more refs to it ...
  1371 	[self includes:aClass] whileTrue:[
  1372         [self includes:aClass] whileTrue:[
  1372 	    actualName := self keyAtValue:aClass.
  1373             actualName := self keyAtValue:aClass.
  1373 	    ('Smalltalk [info]: ' , aClass name , ' is also registered under the name ' , actualName
  1374             ('Smalltalk [info]: ' , aClass name , ' is also registered under the name ' , actualName
  1374 			  , ' - remove that binding too.') infoPrintCR.
  1375                           , ' - remove that binding too.') infoPrintCR.
  1375 	    self at:actualName put:nil.
  1376             self at:actualName put:nil.
  1376 	].
  1377         ].
  1377     ].
  1378     ].
  1378 
  1379 
  1379     ns ~~ Smalltalk ifTrue:[
  1380     ns ~~ Smalltalk ifTrue:[
  1380 	ons notNil ifTrue:[
  1381         ons notNil ifTrue:[
  1381 	    ClassBuilder
  1382             ClassBuilder
  1382 		recompileGlobalAccessorsTo:oldNameSym
  1383                 recompileGlobalAccessorsTo:oldNameSym
  1383 		in:ons
  1384                 in:ons
  1384 		except:nil
  1385                 except:nil
  1385 	].
  1386         ].
  1386 	(ns notNil and:[ns ~~ ons]) ifTrue:[
  1387         (ns notNil and:[ns ~~ ons]) ifTrue:[
  1387 	    ClassBuilder
  1388             ClassBuilder
  1388 		recompileGlobalAccessorsTo:oldNameSym
  1389                 recompileGlobalAccessorsTo:oldNameSym
  1389 		in:ns
  1390                 in:ns
  1390 		except:nil
  1391                 except:nil
  1391 	].
  1392         ].
  1392     ].
  1393     ].
  1393 
  1394 
  1394     "Modified: / 18-11-2006 / 17:16:31 / cg"
  1395     "Modified: / 18-11-2006 / 17:16:31 / cg"
       
  1396     "Modified: / 20-04-2015 / 17:20:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1395 !
  1397 !
  1396 
  1398 
  1397 renameClass:aClass to:newName
  1399 renameClass:aClass to:newName
  1398     "rename aClass to newName. Most of the work is in
  1400     "rename aClass to newName. Most of the work is in
  1399      renaming the classVariables (create & copy over values)
  1401      renaming the classVariables (create & copy over values)
  7917 
  7919 
  7918     lang := Language.
  7920     lang := Language.
  7919     (lang == #de) ifTrue:[
  7921     (lang == #de) ifTrue:[
  7920 	proto := 'Willkommen bei %1 (Version %2 von %3)'
  7922 	proto := 'Willkommen bei %1 (Version %2 von %3)'
  7921     ] ifFalse:[ (lang == #fr) ifTrue:[
  7923     ] ifFalse:[ (lang == #fr) ifTrue:[
  7922 	proto := 'Salut, Bienvenue à %1 (version %2 de %3)'
  7924 	proto := 'Salut, Bienvenue à %1 (version %2 de %3)'
  7923     ] ifFalse:[ (lang == #it) ifTrue:[
  7925     ] ifFalse:[ (lang == #it) ifTrue:[
  7924 	proto := 'Ciao, benvenuto al %1 (versione %2 di %3)'
  7926 	proto := 'Ciao, benvenuto al %1 (versione %2 di %3)'
  7925     ] ifFalse:[ (lang == #es) ifTrue:[
  7927     ] ifFalse:[ (lang == #es) ifTrue:[
  7926 "/        proto := 'Hola, bienvenida a %1 (versión %2 de %3)'
  7928 "/        proto := 'Hola, bienvenida a %1 (versión %2 de %3)'
  7927     ] ifFalse:[ (lang == #es) ifTrue:[
  7929     ] ifFalse:[ (lang == #es) ifTrue:[
  7928 "/        proto := 'Oi, benvindo a %1 (versão %2 de %3)'
  7930 "/        proto := 'Oi, benvindo a %1 (versão %2 de %3)'
  7929     ] ifFalse:[ (lang == #no) ifTrue:[
  7931     ] ifFalse:[ (lang == #no) ifTrue:[
  7930 	proto := 'Hei, verdenmottakelse til %1 (versjon %2 av %3)'
  7932 	proto := 'Hei, verdenmottakelse til %1 (versjon %2 av %3)'
  7931     ]]]]]].
  7933     ]]]]]].
  7932 
  7934 
  7933     "/ ... more needed here ...
  7935     "/ ... more needed here ...
  8211 
  8213 
  8212 version_CVS
  8214 version_CVS
  8213     ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1119 2015-04-09 12:03:15 cg Exp $'
  8215     ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1119 2015-04-09 12:03:15 cg Exp $'
  8214 !
  8216 !
  8215 
  8217 
       
  8218 version_HG
       
  8219 
       
  8220     ^ '$Changeset: <not expanded> $'
       
  8221 !
       
  8222 
  8216 version_SVN
  8223 version_SVN
  8217     ^ '$ Id: Smalltalk.st 10648 2011-06-23 15:55:10Z vranyj1  $'
  8224     ^ '$ Id: Smalltalk.st 10648 2011-06-23 15:55:10Z vranyj1  $'
  8218 ! !
  8225 ! !
  8219 
  8226