Metaclass.st
changeset 2308 db44ef9a050e
parent 2233 0dd796870a34
child 2313 f7b903af509d
--- a/Metaclass.st	Wed Jan 29 16:31:14 1997 +0100
+++ b/Metaclass.st	Wed Jan 29 18:02:07 1997 +0100
@@ -476,7 +476,8 @@
      anyChange oldInstVars newInstVars oldClassVars newClassVars superFlags newFlags
      pkg idx spec nClassInstVars superInstVars
      realNewName thisIsPrivate oldCIVNames newCIVNames msg nsName namespace
-     oldSuperClass newSuperClass globalExistedBefore oldCategory|
+     oldSuperClass newSuperClass globalExistedBefore oldCategory
+     recompileGlobalAccessTo|
 
     "NOTICE:
      this method is too complex and should be splitted into managable pieces ...
@@ -510,7 +511,7 @@
     ].
 
     "
-     Check for invalid variable names (dublicates)
+     Check for invalid variable names (duplicates)
     "
     (self 
         checkValidVarNamesFor:newName
@@ -684,46 +685,11 @@
         ]
     ].
 
-    aClass notNil ifTrue:[
-        "
-         check for instVar redef of superClass instVars
-        "
-        superInstVars := aClass allInstVarNames.
-        stringOfInstVarNames asCollectionOfWords do:[:nm |
-            (superInstVars includes:nm) ifTrue:[
-                (oldClass notNil 
-                and:[stringOfInstVarNames = oldClass instanceVariableString])
-                ifTrue:[
-                    msg := 'instVar conflict in `' , newName , ''' for `' , nm , ''' due to superclass change.\You now have two different instVar slots with the same name.\\Dont forget to fix this later.'.
-                    self warn:msg withCRs.
-                ] ifFalse:[
-                    msg := 'instVar `' , nm , ''' is already defined in a superclass.\Change the definition of `' , newName , ''' anyway ?\\Notice: you must fix the superclass later.'.
-                    (self confirm:msg withCRs) ifFalse:[
-                        ^ nil.
-                    ]
-                ].
-            ]
-        ].
-    ].
-
-    oldClass notNil ifTrue:[
-        "
-         check for instVar redefs in subclass instVars
-        "
-        oldClass allSubclassesDo:[:sub |
-            |vars|
-
-            vars := sub instVarNames.
-            stringOfInstVarNames asCollectionOfWords do:[:nm |
-                (vars includes:nm) ifTrue:[
-                    (self confirm:('subclass ' , sub name , ' already defines an instVar named `' , nm , '''.\\Change the definition of `' , newName , ''' anyway ?\Notice: you must fix the subclass later.') withCRs)
-                    ifFalse:[
-                        ^ nil.
-                    ]
-                ]
-            ]
-        ]
-    ].
+    (self
+        checkInstvarRedefsWith:stringOfInstVarNames 
+        subclassOf:aClass 
+        old:oldClass 
+        name:newName) ifFalse:[^ nil].
 
     nClassInstVars := stringOfClassInstVarNames countWords.
 
@@ -760,8 +726,15 @@
     (namespace notNil 
     and:[namespace ~~ Smalltalk]) ifTrue:[
         newClass setName:(namespace name , '::' , nameKey) asSymbol.
+        "/
+        "/ if that key exists in smalltalk,
+        "/ must recompile everything in that nameSpace,
+        "/ which referes to the global.
+        "/
+        recompileGlobalAccessTo := nameKey.
     ] ifFalse:[
         newClass setName:classSymbol.
+        recompileGlobalAccessTo := nil.
     ].
     newClass setComment:newComment category:categoryString.
 
@@ -894,12 +867,10 @@
         "/ same namespace which access the unprefixed-global
         "/ must be recompiled (so they access the new class)
 
-        (namespace notNil and:[namespace ~~ Smalltalk]) ifTrue:[
-"/            namespace allBehaviorsDo:[:aClass |
-"/                Transcript showCR:'recompiling methods in ' , aClass name , ' accessing ' , newClass nameWithoutNameSpacePrefix.
-"/                Transcript endEntry.
-"/                aClass recompileMethodsAccessingAny:(newClass nameWithoutNameSpacePrefix)
-"/            ]
+        recompileGlobalAccessTo notNil ifTrue:[
+            self recompileGlobalAccessorsTo:recompileGlobalAccessTo
+                 in:namespace
+                 except:newClass
         ].
 
         ^ newClass
@@ -1347,7 +1318,7 @@
 
     "Created: 26.5.1996 / 11:55:26 / cg"
     "Modified: 18.6.1996 / 14:19:39 / stefan"
-    "Modified: 23.1.1997 / 01:19:54 / cg"
+    "Modified: 29.1.1997 / 17:50:07 / cg"
 !
 
 name:newName inEnvironment:aSystemDictionary
@@ -1484,6 +1455,56 @@
     "Modified: 22.10.1996 / 15:25:50 / cg"
 !
 
+checkInstvarRedefsWith:stringOfInstVarNames subclassOf:aClass old:oldClass name:newName
+    |superInstVars msg|
+
+    aClass notNil ifTrue:[
+        "
+         check for instVar redef of superClass instVars
+        "
+        superInstVars := aClass allInstVarNames.
+        stringOfInstVarNames asCollectionOfWords do:[:nm |
+            (superInstVars includes:nm) ifTrue:[
+                (oldClass notNil 
+                and:[stringOfInstVarNames = oldClass instanceVariableString])
+                ifTrue:[
+                    msg := 'instVar conflict in `' , newName , ''' for `' , nm , ''' due to superclass change.\You now have two different instVar slots with the same name.\\Dont forget to fix this later.'.
+                    self warn:msg withCRs.
+                ] ifFalse:[
+                    msg := 'instVar `' , nm , ''' is already defined in a superclass.\Change the definition of `' , newName , ''' anyway ?\\Notice: you must fix the superclass later.'.
+                    ^ self confirm:msg withCRs
+                ].
+            ]
+        ].
+    ].
+
+    oldClass notNil ifTrue:[
+        "
+         check for instVar redefs in subclass instVars
+        "
+        oldClass allSubclassesDo:[:sub |
+            |vars|
+
+            vars := sub instVarNames.
+            stringOfInstVarNames asCollectionOfWords do:[:nm |
+                (vars includes:nm) ifTrue:[
+                    ^ self confirm:('subclass ' 
+                                    , sub name 
+                                    , ' already defines an instVar named `' 
+                                    , nm 
+                                    , '''.\\Change the definition of `' 
+                                    , newName 
+                                    , ''' anyway ?\Notice: you must fix the subclass later.'
+                                   ) withCRs
+                ]
+            ]
+        ]
+    ].
+    ^ true
+
+    "Created: 29.1.1997 / 17:42:11 / cg"
+!
+
 checkValidVarNamesFor:className subClassOf:aClass instVarNames:instVarNameString classVarNames:classVarNameString
     "Check for some 'considered bad-style' things, like lower case names.
      NOTICE:
@@ -1693,6 +1714,20 @@
     "
 !
 
+recompileGlobalAccessorsTo:aGlobalKey in:aNamespace except:someClass
+    aNamespace allBehaviorsDo:[:aClass |
+        aClass ~~ someClass ifTrue:[
+            Transcript showCR:'recompiling methods in ''' , aClass name , ''' accessing ''' , aGlobalKey , ''''.
+            Transcript endEntry.
+            aClass recompileMethodsAccessingGlobal:aGlobalKey.
+            aClass class recompileMethodsAccessingGlobal:aGlobalKey.
+            "/ actually - must eventually recompile USERS of this namespace too
+        ]
+    ]
+
+    "Modified: 29.1.1997 / 17:59:20 / cg"
+!
+
 setSoleInstance:aClass 
     myClass := aClass
 
@@ -1763,5 +1798,5 @@
 !Metaclass class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.102 1997-01-23 01:11:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.103 1997-01-29 17:02:07 cg Exp $'
 ! !