--- a/Metaclass.st Thu Dec 19 17:26:17 1996 +0100
+++ b/Metaclass.st Thu Dec 19 23:09:28 1996 +0100
@@ -872,12 +872,15 @@
oldClassVars := oldClass classVariableString asCollectionOfWords.
newClassVars := newClass classVariableString asCollectionOfWords.
+ superClassChange := oldClass superclass ~~ newClass superclass.
+
"
we are on the bright side of life, if the instance layout and
inheritance do not change.
In this case, we can go ahead and patch the class object.
"
- (oldClass superclass == newClass superclass) ifTrue:[
+
+ superClassChange ifFalse:[
(oldClass instSize == newClass instSize) ifTrue:[
(oldClass flags == newClass flags) ifTrue:[
(oldClass name = newClass name) ifTrue:[
@@ -999,8 +1002,6 @@
newClass comment:newComment
].
- superClassChange := oldClass superclass ~~ newClass superclass.
-
"
dont allow built-in classes to be modified this way
"
@@ -1032,31 +1033,45 @@
classVarChange := false.
superClassChange ifTrue:[
- "
- superclass changed:
- must recompile all class methods accessing ANY classvar
- (
- actually, we could be less strict and handle the case where
- both the old and the new superclass have a common ancestor,
- and both have no new classvariables in between.
- This would speedup the case when a class is inserted into
- the inheritance chain.
- )
- "
+ (oldClass superclass allClassVarNames = newClass superclass allClassVarNames
+ and:[oldClass superclass name = newClass superclass name
+ and:[oldClassVars = newClassVars]])
+ ifTrue:[
+" "
+ Transcript showCR:'keep class methods (same classvars)'.
+ Transcript endEntry.
+" "
+ "
+ class methods still work
+ "
+ self copyMethodsFrom:(oldClass class) for:newMetaclass
+ ] ifFalse:[
+ "
+ superclass changed:
+ must recompile all class methods accessing ANY classvar
+ (
+ actually, we could be less strict and handle the case where
+ both the old and the new superclass have a common ancestor,
+ and both have no new classvariables in between.
+ This would speedup the case when a class is inserted into
+ the inheritance chain.
+ )
+ "
- oldClass allClassVarNames do:[:nm | changeSet1 add:nm].
- newClass allClassVarNames do:[:nm | changeSet1 add:nm].
+ oldClass allClassVarNames do:[:nm | changeSet1 add:nm].
+ newClass allClassVarNames do:[:nm | changeSet1 add:nm].
" "
- Transcript showCR:'recompiling class methods accessing any classvar'.
- Transcript endEntry.
+ Transcript showCR:'recompiling class methods accessing any classvar'.
+ Transcript endEntry.
" "
- self copyInvalidatedMethodsFrom:(oldClass class)
- for:newMetaclass
- accessingAny:changeSet1
- orSuper:true.
- newMetaclass recompileInvalidatedMethods.
- ] ifFalse:[
+ self copyInvalidatedMethodsFrom:(oldClass class)
+ for:newMetaclass
+ accessingAny:changeSet1
+ orSuper:true.
+ newMetaclass recompileInvalidatedMethods.
+ ]
+ ]ifFalse:[
"
same superclass, find out which classvars have changed
"
@@ -1072,9 +1087,6 @@
changeSet1 add:nm
]
].
- ].
-
- classVarChange ifTrue:[
"
must recompile some class-methods
"
@@ -1116,7 +1128,7 @@
changeSet1 do:[:nm | changeSet2 add:nm].
" "
- Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'.
+ Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' [superclass change]...'.
Transcript endEntry.
" "
self copyInvalidatedMethodsFrom:oldClass
@@ -1138,7 +1150,7 @@
"recompile all inst methods accessing changed classvars"
" "
- Transcript showCR:'recompiling instance methods accessing ' , changeSet1 printString , ' ...'.
+ Transcript showCR:'recompiling instance methods accessing classvars ' , changeSet1 printString , ' ...'.
Transcript endEntry.
" "
self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet1.
@@ -1273,7 +1285,7 @@
"Created: 26.5.1996 / 11:55:26 / cg"
"Modified: 18.6.1996 / 14:19:39 / stefan"
- "Modified: 7.11.1996 / 17:35:53 / cg"
+ "Modified: 19.12.1996 / 23:08:30 / cg"
!
name:newName inEnvironment:aSystemDictionary
@@ -1647,5 +1659,5 @@
!Metaclass class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.92 1996-11-08 15:16:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.93 1996-12-19 22:09:28 cg Exp $'
! !