ClassBuilder.st
author Stefan Vogel <sv@exept.de>
Wed, 26 Jan 2005 15:41:06 +0100
changeset 8709 25088287bbd0
parent 8639 b4a2caa29d19
child 8724 dceaa47d4217
permissions -rw-r--r--
Catch #fromString: (for autoloaded classes from Dolphin)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7592
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     1
"
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     2
 COPYRIGHT (c) 2001 by eXept Software AG
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     3
              All Rights Reserved
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     4
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     5
 This software is furnished under a license and may be used
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     6
 only in accordance with the terms of that license and with the
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     8
 be provided or otherwise made available to, or used by, any
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
     9
 other person.  No title to or ownership of the software is
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    10
 hereby transferred.
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    11
"
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    12
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Object subclass:#ClassBuilder
7617
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
    16
	instanceVariableNames:'metaclass className environment superClass instanceVariableNames
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
    17
		variable words pointers classVariableNames poolDictionaries
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
    18
		category comment changed classInstanceVariableNames oldMetaClass
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
    19
		oldClass realNewName buildPrivateClass buildingPrivateClass
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
    20
		nameKey oldSuperClass newSuperClass superClassChange oldClassVars
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
    21
		newClassVars oldInstVars newInstVars classVarChange instVarChange
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
    22
		recompileGlobalAccessTo oldClassToBecomeNew'
6057
12aeb2b3fac8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6037
diff changeset
    23
	classVariableNames:''
12aeb2b3fac8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6037
diff changeset
    24
	poolDictionaries:''
12aeb2b3fac8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6037
diff changeset
    25
	category:'Kernel-Support'
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
7592
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    28
!ClassBuilder class methodsFor:'documentation'!
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    29
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    30
copyright
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    31
"
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    32
 COPYRIGHT (c) 2001 by eXept Software AG
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    33
              All Rights Reserved
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    34
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    35
 This software is furnished under a license and may be used
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    36
 only in accordance with the terms of that license and with the
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    38
 be provided or otherwise made available to, or used by, any
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    39
 other person.  No title to or ownership of the software is
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    40
 hereby transferred.
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    41
"
aaa6a17f80a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7580
diff changeset
    42
! !
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!ClassBuilder class methodsFor:'checks'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    46
checkForAliasesOf:oldClass with:newClass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    47
    "oldClass changed its identity (now use newClass).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    48
     check if there are any global aliases, which should also be changed"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    49
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    50
    Smalltalk keysAndValuesDo:[:nm :o |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    51
        o == oldClass ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    52
            nm ~~ oldClass name ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    53
                (self confirm:('The global/classVar `' , nm , ''' is an alias for ' , oldClass name , '.\\Change it to the new class ?') withCRs)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    54
                ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    55
                    Smalltalk at:nm put:newClass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    56
                ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    57
            ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    58
        ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    59
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    60
!
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
    61
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
differentInstanceVariableOffsetsIn:class1 and:class2
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "return a set of instance variable names which have different
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     positions in class1 and class2.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
     Also, variables which are only present in one class are returned.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
     This is used to find methods which need recompilation after a
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     change in the instance variable layout."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    |offsets1 offsets2 changeSet|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    changeSet := Set new.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
     collect the instvar-indices in the old and new class
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    offsets1 := class1 instanceVariableOffsets.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    offsets2 := class2 instanceVariableOffsets.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
     compute the changeset as a set of instance variables, 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
     which have a different position
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    offsets1 keysAndValuesDo:[:varName :varIndex |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        (offsets2 includesKey:varName) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
            changeSet add:varName 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        ] ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
            (varIndex ~~ (offsets2 at:varName)) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
                changeSet add:varName 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    offsets2 keysAndValuesDo:[:varName :varIndex |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        (offsets1 includesKey:varName) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
            changeSet add:varName
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        ] ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
            (varIndex ~~ (offsets1 at:varName)) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
                changeSet add:varName
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ changeSet
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     View class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        differentInstanceVariableOffsetsIn:View
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
                                       and:StandardSystemView
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
     View class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
        differentInstanceVariableOffsetsIn:Object 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
                                       and:Point 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!ClassBuilder class methodsFor:'recompiling'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
6024
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   115
copyInvalidatedMethodsFrom:oldClass for:newClass
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   116
    "copy all methods from oldClass to newClass and change their code
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   117
     to a trap method reporting an error.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   118
     This is done when a class has changed its layout or inheritance,
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   119
     before recompilation is attempted.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   120
     This allows us to keep the source while trapping uncompilable (due to
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   121
     now undefined instvars) methods. Later compilation of these methods will show
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   122
     an error on the transcript and lead to the debugger once called."
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   123
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   124
    |trap trapCode trapByteCode oldMethod newMethod
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   125
     oldDict newDict|
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   126
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   127
    oldDict := oldClass methodDictionary.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   128
    newDict := MethodDictionary new:oldDict size.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   129
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   130
    oldDict keysAndValuesDo:[ :sel :mthd |
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   131
        trap := mthd trapMethodForNumArgs:(mthd numArgs).
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   132
        trapCode := trap code.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   133
        trapByteCode := trap byteCode.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   134
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   135
        mthd isWrapped ifTrue:[
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   136
            oldMethod := mthd originalMethod
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   137
        ] ifFalse:[
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   138
            oldMethod := mthd.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   139
        ].
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   140
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   141
        newMethod := oldMethod copy.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   142
        newMethod makeInvalid.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   143
        newDict at:sel put:newMethod
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   144
    ].
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   145
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   146
    newClass methodDictionary:newDict.
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   147
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   148
    "Modified: 12.6.1996 / 10:44:27 / stefan"
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   149
    "Modified: 4.11.1996 / 22:55:57 / cg"
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   150
!
51f6277a5ab9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5907
diff changeset
   151
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "copy all methods from oldClass to newClass. Those methods accessing
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
     a variable in setOfNames will be copied as invalid method, leading to
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
     a trap when its executed. This is used when a class has changed its
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
     layout for all methods which are affected by the change."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    self copyInvalidatedMethodsFrom:oldClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                                for:newClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                       accessingAny:setOfNames 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                            orSuper:false 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames orSuper:superBoolean
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "copy all methods from oldClass to newClass. 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
     Those methods accessing a variable in setOfNames will be copied as invalid method, 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
     leading to a trap when its executed. If superBoolean is true, this is also done
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
     for methods accessing super.  This is used when a class has changed its
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
     layout for all methods which are affected by the change."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    |p source mustInvalidate
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
     oldMethod newMethod methodDict newMethodDict nNames|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    methodDict := oldClass methodDictionary.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    newMethodDict := methodDict copy.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    nNames := setOfNames size.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    methodDict keysAndValuesDo:[:selector :method |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        method isWrapped ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
            oldMethod := method originalMethod
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
            oldMethod := method
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        "before parsing (which may take some time),
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
         do a string search if its only one variable,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
         we are looking for.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
         Could look for more than one variable by string compare, but then
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
         parsing it right away may be faster ..."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        source := oldMethod source.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        ((nNames == 1) and:[superBoolean not]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
            mustInvalidate := (source findString:(setOfNames first)) ~~ 0.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            ((nNames == 0) and:[superBoolean]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
                mustInvalidate := (source findString:'super') ~~ 0.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
            ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
                mustInvalidate := true
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
        mustInvalidate ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
            "we have to parse it ..."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
            p := Parser parseMethod:source in:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
            (p isNil 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
             or:[(p usedVars includesAny:setOfNames)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
             or:[superBoolean and:[p usesSuper]]]) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
                mustInvalidate := false
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        mustInvalidate ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
            newMethod := oldMethod copy.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
"/            Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
"/                Transcript showCR:'invalidating ' , selector , '...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
"/            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
            newMethod makeInvalid.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
            newMethod := oldMethod.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
            newMethod mclass:nil.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
        newMethodDict at:selector put:newMethod
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    newClass methodDictionary:newMethodDict.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    "Modified: 7.6.1996 / 08:33:52 / stefan"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "Modified: 19.6.1997 / 18:27:09 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
copyMethodsFrom:oldClass for:newClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    "copy all methods from oldClass to newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
     This is used for class-methods when a class has changed, but its metaclass is 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
     unaffected (i.e. classVars/inheritance have not changed) so there is no need
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
     to recompile the class methods."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    newClass methodDictionary:(oldClass methodDictionary copy).
8467
f25892c63a56 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8421
diff changeset
   237
    newClass methodDictionary do:[:mthd | mthd mclass:nil.].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
8467
f25892c63a56 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 8421
diff changeset
   239
    "Modified: / 05-08-2004 / 19:52:28 / stefan"
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
recompileGlobalAccessorsTo:aGlobalKey in:aNamespace except:someClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    "when a new class enters a namespace, all accessors to the same-named
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
     class in that namespace must be recompiled"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    aNamespace allPrivateClassesDo:[:aClass |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
        aClass ~~ someClass ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
            aClass isLoaded ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
"/                Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
"/                    Transcript showCR:'recompiling methods in ''' , aClass name , ''' accessing ''' , aGlobalKey , ''''.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
"/                    Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
"/                ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
                aClass recompileMethodsAccessingGlobal:aGlobalKey.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
                aClass class recompileMethodsAccessingGlobal:aGlobalKey.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
                "/ actually - must eventually recompile USERS of this namespace too
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
        ]
6408
32ed2e990c09 fixed recompilation of accessors when a private class shadows a global
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
   260
    ].
6414
a09d80f31c79 isNamespace --> isNameSpace
Stefan Vogel <sv@exept.de>
parents: 6408
diff changeset
   261
    aNamespace isNameSpace ifFalse:[
6408
32ed2e990c09 fixed recompilation of accessors when a private class shadows a global
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
   262
        aNamespace recompileMethodsAccessingGlobal:aGlobalKey.
32ed2e990c09 fixed recompilation of accessors when a private class shadows a global
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
   263
        aNamespace class recompileMethodsAccessingGlobal:aGlobalKey.
32ed2e990c09 fixed recompilation of accessors when a private class shadows a global
Claus Gittinger <cg@exept.de>
parents: 6385
diff changeset
   264
    ].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    "Modified: 31.1.1997 / 11:22:57 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
recompileMachineCodeMethodsIn:aClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    "recompile all machine-code methods in aClass."
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    aClass recompileMethodsWithMachineCode.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    aClass class recompileMethodsWithMachineCode.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
! !
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!ClassBuilder methodsFor:'accessing'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
7617
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
   278
metaclass:metaclassOrASubclassOfIt
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
   279
    metaclass := metaclassOrASubclassOfIt.
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
   280
!
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
   281
6825
517d941b94f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6713
diff changeset
   282
name:newName inEnvironment:aSystemDictionaryOrClass subclassOf:aClass instanceVariableNames:stringOfInstVarNames variable:variableBoolean words:wordsBoolean pointers:pointersBoolean classVariableNames:stringOfClassVarNames poolDictionaries:stringOfPoolNames category:categoryString comment:commentString changed:changedBoolean classInstanceVariableNames:stringOfClassInstVarNamesOrNil 
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   283
    className := newName asSymbol.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    environment := aSystemDictionaryOrClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    superClass := aClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    instanceVariableNames := stringOfInstVarNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    variable := variableBoolean.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    words := wordsBoolean.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    pointers := pointersBoolean.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    classVariableNames := stringOfClassVarNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    poolDictionaries := stringOfPoolNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    category := categoryString.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    comment := commentString.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    changed := changedBoolean.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    classInstanceVariableNames := stringOfClassInstVarNamesOrNil
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
   296
!
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
   297
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
   298
oldMetaclass:aMetaclass instanceVariableNames:stringOfInstVarNames
7516
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   299
    |instrVarNames|
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   300
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
   301
    oldMetaClass := aMetaclass.
7516
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   302
    instrVarNames := oldMetaClass superclass allInstanceVariableNames asBag.
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   303
    instrVarNames addAll:(stringOfInstVarNames asStringCollection).
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   304
    (instrVarNames contents includesValue:2) ifTrue:[
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   305
        self error:'duplicate variable name'.
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   306
    ].
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
   307
    
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
   308
    instanceVariableNames := stringOfInstVarNames.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
! !
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
!ClassBuilder methodsFor:'building'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
buildClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "this is the main workhorse for installing new classes - special care
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
     has to be taken, when changing an existing classes definition. In this
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
     case, some or all of the methods and subclasses methods have to be
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
     recompiled.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
     Also, the old class(es) are still kept (but not accessable as a global),
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
     to allow existing instances some life. 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
     This might change in the future.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
8234
4e89a2755041 oops - did not care for changed instVars
Claus Gittinger <cg@exept.de>
parents: 8073
diff changeset
   324
    |newClass newMetaclass nameString newComment|
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "NOTICE:
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
     this method is too complex and should be splitted into managable pieces ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
     I dont like it anymore :-) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
     (well, at least, its a good test for the compilers ability 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
      to handle big, complex methods ;-)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
     take it as an example of bad coding style ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
     ST-80 uses a ClassBuilder object to collect the work and perform all updates;
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
     this method may be changed to do something similar in the future ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
    self checkClassName.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    self checkValidSubclassing.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
7230
82934cb163d4 autoload is understood by all classes (dummy if already loaded)
Claus Gittinger <cg@exept.de>
parents: 7201
diff changeset
   340
    environment notNil ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   341
        environment autoload   "/ owner must be loaded
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    (instanceVariableNames size > 0
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    or:[classVariableNames size > 0]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
        (self 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
            checkValidVarNamesFor:className
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
            subClassOf:superClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
            instVarNames:instanceVariableNames 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
            classVarNames:classVariableNames) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
        ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
            ^ nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    nameString := className asString.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   358
    (self determineNewName) ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   359
        ^ nil.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    (superClass notNil and:[realNewName = superClass name]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
        self error:'trying to create circular class definition'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
        ^ nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
    "look, if it already exists as a class"
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   368
    environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   369
        buildingPrivateClass ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   370
            oldClass := environment at:className ifAbsent:[nil].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
        ] ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   372
            oldClass := environment privateClassesAt:className.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
7528
4c8d5b4f1221 oops - rebuild of Smalltalk
penk
parents: 7516
diff changeset
   376
    (oldClass notNil and:[oldClass isNameSpace and:[oldClass ~~ Smalltalk]]) ifTrue:[
6713
6f197bcc0958 catch class exists as nameSpace
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
   377
        self error:'class exists as namespace'.
6f197bcc0958 catch class exists as nameSpace
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
   378
        ^ nil
6f197bcc0958 catch class exists as nameSpace
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
   379
    ].
6f197bcc0958 catch class exists as nameSpace
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
   380
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    (oldClass isBehavior and:[oldClass isLoaded not]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
        oldClassToBecomeNew := oldClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    (oldClass isBehavior and:[oldClass isLoaded]) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
        oldClass := nil.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   388
        (buildingPrivateClass and:[Compiler warnSTXSpecials]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   389
            (self confirm:('support for private classes is an ST/X extension.\\continue ?') withCRs)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   390
            ifFalse:[^ nil].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    ] ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
        oldClass name ~= realNewName ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   394
            (self confirm:(className , ' is an alias for ' , oldClass name , '\\continue ?') withCRs)
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
            ifFalse:[^ nil].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
            oldClass := nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
        ] ifFalse:[
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
   398
            (self checkForCircularDefinitionFrom:oldClass) ifTrue:[
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
   399
                self error:'trying to create circular class definition'.
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
   400
                ^ nil
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
            "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
             warn, if it exists with different category and different instvars,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
             and the existing is not an autoload class.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
             Usually, this indicates that someone wants to create a new class with
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
             a name, which already exists (it happened a few times to myself, while 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
             I wanted to create a new class called ReturnNode ...).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
             This will be much less of a problem, once multiple name spaces are
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
             implemented and classes can be put into separate packages.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
            "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
            oldClass isLoaded ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
                oldClass category ~= category ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   414
                    oldClass instanceVariableString asCollectionOfWords ~= instanceVariableNames asCollectionOfWords ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   415
                        (self confirm:'a class named ' , oldClass name , ' already exists -\\create (i.e. change) anyway ?' withCRs)
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
                        ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
                            ^ nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
                        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
                    ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
            "/
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
            "/ hints - warn, if creating a variableSubclass of a Set
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
            "/ (common error - containers in ST/X do not use variable-slots)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
            "/
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
            ((variable == true) and:[pointers]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
                (oldClass isKindOf:Set class) ifTrue:[
6057
12aeb2b3fac8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6037
diff changeset
   429
                    (self confirm:('ST/X Set & Dictionary are not variable-classes.\Create %1 anyway ?' bindWith:nameString) withCRs)
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
                    ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
                        ^ nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
                    ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
    "/ Check for some 'considered bad-style' things, like lower case names.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "/ But only do these checks for new classes - 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
    "/ - thus, once confirmed, the warnings will not come again and again.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    "/ NOTICE:
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    "/ I dont like the confirmers there - we need a notifying: argument, to give
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
    "/ the outer codeview a chance to highlight the error.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    "/ (but thats how its defined in the book - maybe I will change anyway).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
    "/ - or use upQueries in future versions.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
    oldClass isNil ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   449
        (instanceVariableNames size > 0 or:[classVariableNames size > 0]) ifTrue:[
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
            (self 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
                checkConventionsFor:className
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
                subClassOf:superClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
                instVarNames:instanceVariableNames 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
                classVarNames:classVariableNames) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
            ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
                ^ nil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
        ].
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   459
    ].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   461
    (self
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   462
        checkInstvarRedefsWith:instanceVariableNames 
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   463
        subclassOf:superClass 
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   464
        old:oldClass 
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
   465
        name:className) ifFalse:[^ nil].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   467
    self checkValidPools.
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   468
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
   469
    newMetaclass := self instantiateMetaclass.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   470
    newClass := self instantiateNewClassFrom:newMetaclass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   472
    (environment notNil and:[environment ~~ Smalltalk]) ifTrue:[
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
        newClass setName:realNewName.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
        "/
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
        "/ if that key exists in smalltalk,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
        "/ must recompile everything in that nameSpace,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
        "/ which refers to the unprefixed global.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
        "/
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   479
        recompileGlobalAccessTo := className.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    ] ifFalse:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   481
        newClass setName:className.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
        recompileGlobalAccessTo := nil.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   485
    newComment := comment.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   486
    newComment isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   487
        oldClass notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   488
            newComment := oldClass comment
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   489
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   490
    ].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
    newClass setComment:newComment category:category.
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   492
    poolDictionaries notEmptyOrNil ifTrue:[
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   493
        newClass sharedPools:poolDictionaries
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   494
    ].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   496
    "/ for new classes, we are almost done here
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   497
    "/ (also for autoloaded classes)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   498
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   499
    (oldClass isNil or:[oldClass isLoaded not]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   500
        self handleNewlyCreatedClass:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   501
        ^ newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   502
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   503
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   504
    "/ here comes the hard part - we are actually changing the
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   505
    "/ definition of an existing class ....
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   506
    "/ Try hard to get away WITHOUT recompiling, since it is both slow
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   507
    "/ and it makes all compiled code into interpreted (which is reJITed then)...
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   508
    oldInstVars := oldClass instanceVariableString asCollectionOfWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   509
    newInstVars := newClass instanceVariableString asCollectionOfWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   510
    oldClassVars := oldClass classVariableString asCollectionOfWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   511
    newClassVars := newClass classVariableString asCollectionOfWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   512
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   513
    "/ We are on the bright side of life, if the instance layout and inheritance do not change.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   514
    "/ In this case, we can go ahead and patch the class object.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   515
    "/ (only comment and/or classVars have changed)
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   516
    oldSuperClass := oldClass superclass.
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   517
    newSuperClass := newClass superclass.
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   518
    superClassChange := (oldSuperClass ~~ newSuperClass).
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   519
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   520
    superClassChange ifFalse:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   521
        (oldClass instSize == newClass instSize) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   522
            (oldClass flags == newClass flags) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   523
                (oldClass name = newClass name) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   524
                    (oldInstVars = newInstVars) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   525
                        self handleEasyNewClass:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   526
                        ^ oldClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   527
                    ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   528
                ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   529
            ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   530
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   531
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   532
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   533
    self handleHardNewClass:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   534
    ^ newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   535
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   536
    "Created: / 26.5.1996 / 11:55:26 / cg"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   537
    "Modified: / 18.3.1999 / 18:23:31 / stefan"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   538
    "Modified: / 13.2.2000 / 22:59:57 / cg"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   539
! !
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   540
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   541
!ClassBuilder methodsFor:'building-helpers'!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   542
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   543
changeReferencesFrom:oldClass to:newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   544
    | refs|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   545
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   546
    refs := OrderedCollection new.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   547
    ObjectMemory allObjectsDo:[:obj |
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   548
        (obj referencesObject:oldClass) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   549
            obj isContext ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   550
                refs add:obj
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   551
            ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   552
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   553
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   554
    refs isEmpty ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   555
        ^ self
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   556
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   557
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   558
"/    answer := OptionBox 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   559
"/                  request:('Update References (from old class to new class) ?') withCRs
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   560
"/                  label:'Confirm'
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   561
"/                  buttonLabels:#('no' 'browse references' 'update')
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   562
"/                  values:#(false #browse true)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   563
"/                  default:#true
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   564
"/                  onCancel:false.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   565
"/
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   566
"/    answer == #browse ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   567
"/        refs inspect.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   568
"/        answer := self confirm:('Update References (from old class to new class) ?') withCRs.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   569
"/    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   570
"/    answer == false ifTrue:[^ self].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   571
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   572
    refs do:[:obj |
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   573
        |skip|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   574
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   575
        skip := false.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   576
        obj isBehavior ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   577
            skip := true.    
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   578
            obj isObsolete ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   579
                obj isMeta ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   580
                    "/ the owner-slot ?
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   581
                    obj owningClass == oldClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   582
"/                        self halt.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   583
                    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   584
                    obj theNonMetaclass == oldClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   585
"/                        self halt.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   586
                    ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   587
                ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   588
            ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   589
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   590
        skip ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   591
            obj replaceReferencesTo:oldClass with:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   592
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   593
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   594
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   595
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   596
copyClassInstanceVariablesFrom:oldClass to:newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   597
    |oldCIVNames newCIVNames|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   598
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   599
    "/ copy over classInstanceVariables
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   600
    "/ but not those inherited from class
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   601
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    oldClass notNil ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
        oldCIVNames := oldClass class allInstVarNames asSet.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
        newCIVNames := newClass class allInstVarNames asSet.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
        Class class allInstVarNames do:[:n |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
             oldCIVNames remove:n ifAbsent:nil.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
             newCIVNames remove:n ifAbsent:nil.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
        newCIVNames size > 0 ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
            newCIVNames do:[:n |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
                (oldCIVNames includes:n) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
                    newClass instVarNamed:n put:(oldClass instVarNamed:n)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   618
!
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   620
determineNewName
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   621
    |doCreate namespace classSymbol idx nsName|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   622
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   623
    classSymbol := className asSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   624
    namespace := environment.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   626
    (namespace notNil
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   627
    and:[namespace isNameSpace not]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   628
        buildingPrivateClass := true.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   629
        realNewName := (namespace name , '::' , classSymbol) asSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   630
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   631
        buildingPrivateClass := false.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   632
        realNewName := classSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   633
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   634
        "/ does the name imply a nameSpace ?
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   635
        ((idx := realNewName indexOf:$:)) ~~ 0 ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   636
            "/ check for this namespace to exist
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   637
            nsName := realNewName copyTo:(idx - 1).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   638
            nsName := nsName asSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   639
            (realNewName indexOf:$: startingAt:(idx+2)) ~~ 0 ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   640
                (Smalltalk at:nsName) isNameSpace ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   641
                    self warn:('Nested namespaces are not (yet) implemented.') withCRs.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   642
                ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   643
                    self warn:('Trying to define a private class with a non-private definition selector.') withCRs.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
                ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   645
                ^ false
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   648
            namespace := Smalltalk at:nsName ifAbsent:nil.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   649
            namespace isNameSpace ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   650
                namespace isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   651
                    doCreate := Class createNameSpaceQuerySignal query.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   652
                    doCreate ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   653
                        doCreate := Dialog
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   654
                            confirmWithCancel:('Nonexistent Namespace: `' , nsName , '''.\\Create ?') withCRs.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   655
                        doCreate isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   656
                            "/ cancelled
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   657
                            AbortSignal raise.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   658
                            ^ false.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   659
                        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   660
                    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   661
                    doCreate ifFalse:[^ false].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   662
                    namespace := NameSpace name:nsName.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   663
                ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   664
                    (namespace isBehavior
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   665
                    and:[namespace isMeta not])
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   666
                    ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   667
                        buildingPrivateClass := true.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   668
                        realNewName := classSymbol asSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   669
                    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   670
                        self warn:('A global named ' , nsName , ' exists, but is no namespace.') withCRs.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   671
                        ^ false
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   672
                    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   673
                ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   674
            ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   675
            namespace isNameSpace ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   676
                nameKey := (classSymbol copyFrom:(nsName size + 3)) asSymbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   677
            ]
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
        ] ifFalse:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   679
            (namespace notNil and:[namespace ~~ Smalltalk]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   680
                realNewName := (namespace name , '::' , classSymbol) asSymbol.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
    ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   684
    ^ true
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   685
!
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   687
environmentChanged:how with:argument
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   688
      environment changed:how with:argument.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   689
      environment ~~ Smalltalk ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   690
          Smalltalk changed:how with:argument.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   691
      ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   692
!
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   694
environmentChangedOrganization
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   695
      environment changed:#organization.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   696
      environment ~~ Smalltalk ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   697
          Smalltalk changed:#organization.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   698
      ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   699
!
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   701
fixMethodsIn:newClass
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
   702
    |changeSet1 changeSet2 newMetaclass addedNames|
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   704
    newMetaclass := newClass class.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    "/ care for class methods ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
    changeSet1 := Set new.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
    classVarChange := false.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    superClassChange ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
        (oldSuperClass notNil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
        and:[newSuperClass notNil
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
        and:[oldSuperClass allClassVarNames = newSuperClass allClassVarNames
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
        and:[oldSuperClass name = newSuperClass name
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
        and:[oldClassVars = newClassVars]]]])
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
        ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
"/            Transcript showCR:'keep class methods (same classvars)'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
"/            Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
            "/ class methods still work
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
            self class copyMethodsFrom:(oldClass class) for:newMetaclass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
"/            Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
"/                Transcript showCR:'recompiling class methods accessing super ...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
"/                Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
"/            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
            "/ however, those accessing super must be recompiled
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
            self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
                copyInvalidatedMethodsFrom:(oldClass class) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
                for:newMetaclass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
                accessingAny:#()
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
                orSuper:true.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
            "/ superclass changed:
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
            "/  must recompile all class methods accessing ANY classvar
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
            "/  (actually, we could be less strict and handle the case where
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
            "/   both the old and the new superclass have a common ancestor,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
            "/   and both have no new classvariables in between.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
            "/   This would speedup the case when a class is inserted into
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
            "/   the inheritance chain.)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
            oldClass allClassVarNames do:[:nm | changeSet1 add:nm].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
            newClass allClassVarNames do:[:nm | changeSet1 add:nm].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
"/            Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
"/                Transcript showCR:'recompiling class methods accessing any classvar or super ...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
"/                Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
"/            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
            self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
                copyInvalidatedMethodsFrom:(oldClass class) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
                for:newMetaclass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
                accessingAny:changeSet1
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
                orSuper:true.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
        newMetaclass recompileInvalidatedMethods.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
    ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
        "/ same superclass, find out which classvars have changed
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
        classVarChange := oldClassVars ~= newClassVars.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
        classVarChange ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
            oldClassVars do:[:nm |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
                (newClassVars includes:nm) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
                    changeSet1 add:nm
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
            newClassVars do:[:nm |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
                (oldClassVars includes:nm) ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
                    changeSet1 add:nm
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
            "/ must recompile some class-methods
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
"/            Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
"/                Transcript showCR:'recompiling class methods accessing ' , changeSet1 printString.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
"/                Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
"/            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
            self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
                copyInvalidatedMethodsFrom:(oldClass class) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
                for:newMetaclass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
                accessingAny:changeSet1.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
            newMetaclass recompileInvalidatedMethods.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
            "/ class methods still work
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
            self class copyMethodsFrom:(oldClass class) for:newMetaclass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   799
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
    "/ care for instance methods ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    superClassChange ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
        "/ superclass changed,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
        "/  must recompile all methods accessing any class or instvar.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
        "/  If number of instvars (i.e. the instances instSize) is the same,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
        "/  we can limit the set of recompiled instance methods to those methods,
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
        "/  which refer to an instvar with a different inst-index
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
        "/ the changeset consists of instance variables, 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
        "/ with a different position
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
        changeSet2 := self class differentInstanceVariableOffsetsIn:oldClass and:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
        "/ merge in the changed class variables
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
        changeSet1 do:[:nm | changeSet2 add:nm].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
"/        Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
"/             Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' [superclass change]...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
"/             Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
"/        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
        self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
                copyInvalidatedMethodsFrom:oldClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
                for:newClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
                accessingAny:changeSet2
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
                orSuper:true.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
        newClass recompileInvalidatedMethods.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
        "/ same inheritance ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
        instVarChange := oldInstVars ~= newInstVars.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
        instVarChange ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
            "/ same instance variables ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
            classVarChange ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
                "recompile all inst methods accessing changed classvars"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
"/                Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
"/                    Transcript showCR:'recompiling instance methods accessing classvars ' , changeSet1 printString , ' ...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
"/                    Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
"/                ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
                self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
                    copyInvalidatedMethodsFrom:oldClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
                    for:newClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
                    accessingAny:changeSet1.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
                newClass recompileInvalidatedMethods.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
            ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
                "/ instance methods still work
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
                self class copyMethodsFrom:oldClass for:newClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
        ] ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
            "/ dont allow built-in classes to be modified
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
            (oldClass notNil and:[oldClass isBuiltInClass and:[instVarChange]]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
                self error:'the layout of this class is fixed - you cannot change it'.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   862
                AbortSignal raise
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
            ((oldInstVars size == 0) 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
            or:[newInstVars startsWith:oldInstVars]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
                "/ only new inst variable(s) has/have been added - 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
                "/ old methods still work (the existing inst-indices are still valid)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
"/                Transcript showCR:'copying methods ...'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
"/                Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
                self class copyMethodsFrom:oldClass for:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
                "/ but: we have to recompile all methods accessing new instars
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
                "/ (it might have been a classVar/global before ...)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
                addedNames := newInstVars select:[:nm | (oldInstVars includes:nm) not].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
                "merge in class variables"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
                changeSet1 do:[:nm | addedNames add:nm].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
"/                Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
"/                    Transcript showCR:'recompiling instance methods accessing ' , addedNames printString ,  '... [added instvars]'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
"/                    Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
"/                ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
                newClass recompileMethodsAccessingAny:addedNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
            ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
                "/ the changeset consists of instance variables, 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
                "/ with a different position
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
                changeSet2 := self class differentInstanceVariableOffsetsIn:oldClass and:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
                "merge in the class variables"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
                changeSet1 do:[:nm | changeSet2 add:nm].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
"/                Smalltalk silentLoading ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
"/                    Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ... [changed instvars]'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
"/                    Transcript endEntry.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
"/                ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
                self class 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
                    copyInvalidatedMethodsFrom:oldClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
                    for:newClass 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
                    accessingAny:changeSet2.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
                newClass recompileInvalidatedMethods.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
            ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
    ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   912
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   913
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   914
handleEasyNewClass:newClass
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   915
    "instance layout remains the same.
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   916
     We only have to recompile methods which access changed class variables
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   917
     and changed pool variables."
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   918
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   919
    |newComment anyChange setOfChangedVariables oldPoolVars newPoolVars|
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   920
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   921
    oldPoolVars := oldClass sharedPools collectAll:[:pool | pool keys].
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   922
    newPoolVars := newClass sharedPools collectAll:[:pool | pool keys].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   923
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   924
    newComment := newClass comment.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   925
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   926
    (newComment ~= oldClass comment) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   927
        oldClass setComment:newComment.        "writes a change-chunk"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   928
        oldClass changed:#comment with:oldClass comment.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   929
        changed ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   930
            oldClass addChangeRecordForClassComment:oldClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   931
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   932
    ]. 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   933
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   934
    ((oldClassVars = newClassVars)
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   935
    and:[oldPoolVars = newPoolVars]) ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   936
        "/ really no change (just comment and/or category)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   937
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   938
        anyChange := false.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   939
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   940
        oldClass setInstanceVariableString:(newClass instanceVariableString).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   941
        oldClass setClassVariableString:(newClass classVariableString).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   942
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   943
        oldClass category ~= category ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   944
            oldClass setCategory:category. 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   945
            changed ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   946
                newClass addChangeRecordForClass:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   947
            ].    
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   948
            environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   949
                buildingPrivateClass ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   950
                    self environmentChangedOrganization.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   951
                ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   952
            ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   953
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   954
        "notify change of class"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   955
"/                oldClass changed.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   956
        ^ oldClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   957
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   958
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   959
    "/ when we arrive here, class variables have changed
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   960
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   961
    oldClass category ~= category ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   962
        "notify change of organization"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   963
        oldClass setCategory:category. 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   964
        environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   965
            buildingPrivateClass ifFalse:[ 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   966
                self environmentChangedOrganization.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   967
            ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   968
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   969
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   970
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   971
    "/ set class variable string; 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   972
    "/ this also updates the set of class variables
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   973
    "/ by creating new / deleting obsolete ones.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   974
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   975
    oldClass classVariableString:classVariableNames.
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   976
    oldClass sharedPools:newClass sharedPools.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   977
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   978
    "
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   979
     get the set of changed class variables
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   980
    "
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   981
    setOfChangedVariables := Set new.
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   982
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   983
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   984
     add the set of changed class variables (those which are not in both)
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   985
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   986
    setOfChangedVariables addAll:(oldClassVars xor:newClassVars).
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
   987
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   988
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   989
     add the set of changed pool variables (those which are not in both)
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   990
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   991
    setOfChangedVariables addAll:(oldPoolVars xor:newPoolVars).
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   992
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   993
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   994
     add the set of pool vars which are now classVars and vice versa
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   995
    "
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   996
    setOfChangedVariables addAll:(oldPoolVars intersect:newClassVars).
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   997
    setOfChangedVariables addAll:(oldClassVars intersect:newPoolVars).
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   998
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
   999
    setOfChangedVariables notEmpty ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1000
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1001
        "/ recompile all methods accessing set of changed classvars
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1002
        "/ here and also in all subclasses ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1003
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1004
        "/ dont update change file for the recompilation
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1005
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1006
        Class withoutUpdatingChangesDo:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1007
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1008
"/                      Smalltalk silentLoading ifFalse:[
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
  1009
"/                          Transcript showCR:'recompiling class & inst methods accessing ' , setOfChangedVariables printString.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1010
"/                          Transcript endEntry.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1011
"/                      ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1012
            oldClass withAllSubclasses do:[:aClass |
8610
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
  1013
                aClass class recompileMethodsAccessingAnyClassvarOrGlobal:setOfChangedVariables.
071f830dae18 poolVar handling
Claus Gittinger <cg@exept.de>
parents: 8539
diff changeset
  1014
                aClass recompileMethodsAccessingAnyClassvarOrGlobal:setOfChangedVariables.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1015
            ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1016
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1017
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1018
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1019
    Class flushSubclassInfo.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1020
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1021
    "notify change of class"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1022
    changed ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1023
        oldClass addChangeRecordForClass:oldClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1024
    ].  
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1025
    oldClass changed:#definition.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1026
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1027
    self environmentChanged:#classDefinition with:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1028
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1029
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1030
handleHardNewClass:newClass
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
  1031
    |oldCategory|
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1032
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1033
    "/ dont allow built-in classes to be modified this way
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1034
    (oldClass notNil and:[oldClass isBuiltInClass and:[superClassChange]]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1035
        self error:'the inheritance of this class is fixed - you cannot change it'.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1036
        ^ oldClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1037
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1038
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1039
    "/ since we will change the inheritance of some class(es)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1040
    Class flushSubclassInfo.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1041
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1042
    "/ catch special case, where superclass changed its layout and thus
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1043
    "/ forced redefinition of this class; 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1044
    "/ only log if this is not the case.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1045
    changed ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1046
        (superClassChange 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1047
         and:[(oldSuperClass isNil or:[newSuperClass notNil and:[oldSuperClass name = newSuperClass name]])
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1048
         and:[(oldClassVars = newClassVars) 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1049
         and:[(oldInstVars = newInstVars)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1050
         and:[oldClass comment = newClass comment]]]]) ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1051
            newClass addChangeRecordForClass:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1052
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1053
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1054
    self fixMethodsIn:newClass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    "/ finally, if the oldClass came from a dynamically loaded
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
    "/ classLibrary, we must recompile the methods in the newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    "/ otherwise, the methods code will vanish when the old (obsolete)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
    "/ class eventually vanishes ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    self class recompileMachineCodeMethodsIn:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1062
"/    (oldPkg notNil and:[oldPkg ~= pkg]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1063
"/        "/ we have to change all methods package info
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1064
"/        "/ to belong to the old package.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1065
"/        newClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1066
"/            mthd setPackage:oldPkg
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1067
"/        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1068
"/    ].
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
    "/ WOW, everything done for this class
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
    "/ what about subclasses ?
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
    "/ update superclass of immediate subclasses - 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
    "/ this forces recompilation (recursively) if needed
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
    "/ (dont update change file for the subclass changes)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
    Class classRedefinitionSignal answer:#keep do:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
        Class withoutUpdatingChangesDo:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
            oldClass subclasses copy do:[:aClass |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
                aClass superclass:newClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
    "/ change any private subclasses' owners
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
    oldClass privateClassesDo:[:aClass |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
        aClass isLoaded ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
            aClass class setOwningClass:newClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    "/ change category in oldClass - so we see immediately what it is ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    oldCategory := oldClass category.
7580
0a49277831d9 class category: sends a change notification;
Claus Gittinger <cg@exept.de>
parents: 7528
diff changeset
  1096
    oldClass setCategory:#'* obsolete *'.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
    oldClass wasAutoloaded ifTrue:[ Autoload removeClass:oldClass ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    Smalltalk flushCachedClass:oldClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
    "/ and make the new class globally known
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1102
    environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1103
        buildingPrivateClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1104
            environment privateClassesAt:className put:newClass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
        ] ifFalse:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1106
            environment at:className put:newClass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
            oldCategory ~= category ifTrue:[
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1109
                self environmentChangedOrganization.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
    "/ Not becoming the old class creates some update problems;
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
    "/ the browsers must check carefully - a simple identity compare is
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    "/ not enough ...
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    "/ QUESTION: is this a good idea ?
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
    newClass dependents:(oldClass dependents).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
    newClass changed:#definition.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
    "just to make certain ... - tell dependents of oldClass, that something changed
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
     (systemBrowsers will react on this, and update their views)"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
    oldClass changed:#definition with:newClass.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1125
    self environmentChanged:#classDefinition with:newClass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    ObjectMemory flushCaches.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1129
    buildingPrivateClass ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1130
        oldClass ~~ newClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1131
            environment == Smalltalk ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1132
                ClassBuilder checkForAliasesOf:oldClass with:newClass.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    ].
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1136
    (instVarChange or:[classVarChange]) ifTrue:[
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1137
        self changeReferencesFrom:oldClass to:newClass.
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1138
    ].
7434
aa0faab58aaf SubclassInfo moved from Behavior to Class
Stefan Vogel <sv@exept.de>
parents: 7370
diff changeset
  1139
    Class flushSubclassInfo.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    ^ newClass
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
    "Created: / 26.5.1996 / 11:55:26 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
    "Modified: / 18.3.1999 / 18:23:31 / stefan"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
    "Modified: / 13.2.2000 / 22:59:57 / cg"
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1145
!
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1146
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1147
handleNewlyCreatedClass:newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1148
"/    comment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1149
"/        newClass comment:comment
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1150
"/    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1151
    environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1152
        buildingPrivateClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1153
            environment privateClassesAt:className put:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1154
        ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1155
            environment at:className put:newClass.
8351
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1156
        ].
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1157
        (oldClass isNil and:[changed and:[superClass ~~ Autoload]]) ifTrue:[
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1158
            newClass addChangeRecordForClass:newClass.
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1159
        ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1160
    ].
6035
cbb2f3894582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6034
diff changeset
  1161
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1162
    oldClass notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1163
        "/ since we changed the classes inheritance (from Autoloaded)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1164
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1165
        "/ actually, could optimize to:
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1166
        "/  Class updateSuperclassInfoFor:oldClass superclass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1167
        "/  Class updateSuperclassInfoFor:newClass superclass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1168
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1169
        Class flushSubclassInfo.
6037
0b6a188b413f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6035
diff changeset
  1170
    ].
0b6a188b413f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6035
diff changeset
  1171
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1172
    oldClassToBecomeNew notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1173
        "/ old was an autoloaded class - make it the new one
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1174
        "/ and flush ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1175
        oldClassToBecomeNew class becomeSameAs:newClass class.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1176
        oldClassToBecomeNew becomeSameAs:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1177
        ObjectMemory flushCaches.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1178
    ].
6035
cbb2f3894582 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6034
diff changeset
  1179
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1180
    environment notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1181
        buildingPrivateClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1182
            environment changed.
8351
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1183
        ].
a2c6f07fc4e3 no change notifications
penk
parents: 8235
diff changeset
  1184
        self environmentChanged:#newClass with:newClass.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1185
    ].
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1186
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1187
    "/ be very careful, when adding classes
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1188
    "/ to a namespace or adding a privateClass. 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1189
    "/ When adding, all methods within that namespace/owning class
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1190
    "/ which access the unprefixed-global,
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1191
    "/ must be recompiled (so they access the new class)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1192
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1193
    recompileGlobalAccessTo notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1194
        self class 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1195
            recompileGlobalAccessorsTo:recompileGlobalAccessTo
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1196
            in:environment except:newClass.
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1197
    ].
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1198
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1199
    (buildingPrivateClass 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1200
    and:[newClass owningClass nameSpace notNil]) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1201
        "/ namespace is a class; 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1202
        "/ if this owner is itself in a namespace,
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1203
        "/ must recompile all from owners namespace
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1204
        "/ accessing the new class (without namespace prefix)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1205
        self class 
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1206
            recompileGlobalAccessorsTo:(newClass nameWithoutNameSpacePrefix asSymbol)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1207
            in:(newClass owningClass nameSpace) except:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1208
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1209
    ^ newClass
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1210
!
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1211
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1212
instantiateMetaclass
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1213
    "create the metaclass proper"
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1214
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1215
    |newMetaclass classesSuperclass|
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1216
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1217
    classInstanceVariableNames isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1218
        oldClass isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1219
            classInstanceVariableNames := ''
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1220
        ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1221
            classInstanceVariableNames := oldClass class instanceVariableString
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1222
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1223
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1224
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1225
    buildingPrivateClass ifTrue:[
7617
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
  1226
        newMetaclass := metaclass asPrivate new
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1227
    ] ifFalse:[
7617
a557bbe96ef1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7592
diff changeset
  1228
        newMetaclass := metaclass new.
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1229
    ].
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1230
    superClass isNil ifTrue:[
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1231
        classesSuperclass := Class.
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1232
    ] ifFalse:[
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1233
        classesSuperclass := superClass class.
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1234
    ].
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1235
    newMetaclass setSuperclass:classesSuperclass instSize:(classesSuperclass instSize + classInstanceVariableNames countWords).
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1236
    newMetaclass setInstanceVariableString:classInstanceVariableNames.
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1237
    buildingPrivateClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1238
        newMetaclass setOwningClass:environment.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1239
    ].
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1240
    ^ newMetaclass
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1241
!
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1242
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1243
instantiateNewClassFrom:newMetaclass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1244
    "create the class proper"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1245
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1246
    |newClass nInstVars newInstSize|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1247
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1248
    "let the new meta create the class"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1249
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1250
    instanceVariableNames size > 0 ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1251
        nInstVars := instanceVariableNames countWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1252
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1253
        nInstVars := 0.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1254
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1255
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1256
    newClass := newMetaclass new.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1257
    superClass isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1258
        newInstSize := nInstVars.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1259
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1260
        newInstSize := superClass instSize + nInstVars.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1261
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1262
    newClass setSuperclass:superClass instSize:newInstSize.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1263
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1264
    self copyClassInstanceVariablesFrom:oldClass to:newClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1265
    self setPackageInNewClass:newClass fromOld:oldClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1266
    self setupNewClass:newClass fromOld:oldClass.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1267
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1268
    ^ newClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1269
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1270
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1271
rebuildForChangedInstanceVariables
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1272
    "changing / adding class-inst vars -
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1273
     this actually creates a new metaclass and class, leaving the original
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1274
     classes around as obsolete classes. This may also be true for all subclasses,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1275
     if class instance variables are added/removed.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1276
     Existing instances continue to be defined by their original classes.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1277
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1278
     Time will show, if this is an acceptable behavior or if we should migrate
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1279
     instances to become insts. of the new classes."
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1280
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1281
    |newClass newMetaclass nClassInstVars oldClass 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1282
     allSubclasses oldVars
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1283
     oldNames newNames addedNames
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1284
     oldOffsets newOffsets offset changeSet delta
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
  1285
     oldToNew newSubMeta newSub oldSubMeta 
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1286
     commonClassInstVars t superclass|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1287
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1288
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1289
     cleanup needed here: extract common things with name:inEnvironment:...
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1290
     and restructure things ... currently way too complex.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1291
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1292
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1293
    oldVars := oldMetaClass instanceVariableString.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1294
    instanceVariableNames = oldVars ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1295
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1296
        Transcript showCR:'no change (', oldVars , ') -> (', instanceVariableNames , ')'.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1297
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1298
        ^ self
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1299
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1300
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1301
    oldNames := oldVars asCollectionOfWords.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1302
    newNames := instanceVariableNames asCollectionOfWords.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1303
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1304
    oldNames = newNames ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1305
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1306
        Transcript showCR:'no real change'.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1307
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1308
        "no real change (just formatting)"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1309
        oldMetaClass setInstanceVariableString:instanceVariableNames.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1310
        ^ self
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1311
    ]. 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1312
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1313
"/    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1314
"/     let user confirm, if any name is no good (and was good before)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1315
"/    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1316
"/    (oldNames inject:true
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1317
"/                into:[:okSoFar :word |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1318
"/                         okSoFar and:[word first isUppercase]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1319
"/                     ])
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1320
"/    ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1321
"/        "was ok before"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1322
"/        (newNames inject:true
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1323
"/                    into:[:okSoFar :word |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1324
"/                             okSoFar and:[word first isUppercase]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1325
"/                         ])
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1326
"/        ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1327
"/            (self confirm:'class instance variable names should start with an uppercase letter
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1328
"/(by convention only)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1329
"/
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1330
"/install anyway ?' withCRs)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1331
"/            ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1332
"/                ^ nil
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1333
"/            ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1334
"/        ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1335
"/    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1336
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1337
    nClassInstVars := newNames size.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1338
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1339
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1340
    Transcript showCR:'create new class/metaclass'.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1341
"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1342
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1343
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1344
     create the new metaclass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1345
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1346
    oldMetaClass isPrivate ifTrue:[
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1347
        newMetaclass := oldMetaClass class "PrivateMetaclass" new.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1348
        newMetaclass setOwningClass:(oldMetaClass owningClass).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1349
    ] ifFalse:[
6514
8cac16d95cb3 care for private metaclass
Claus Gittinger <cg@exept.de>
parents: 6414
diff changeset
  1350
        newMetaclass := oldMetaClass class "Metaclass" new.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1351
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1352
    superclass := oldMetaClass superclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1353
    newMetaclass setSuperclass:superclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1354
    newMetaclass instSize:(superclass instSize + nClassInstVars).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1355
    (nClassInstVars ~~ 0) ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1356
        newMetaclass setInstanceVariableString:instanceVariableNames
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1357
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1358
"/    newMetaclass flags:(Behavior flagBehavior "flagNotIndexed").
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1359
"/    newMetaclass setName:name.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1360
"/    newMetaclass classVariableString:classvars.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1361
"/    newMetaclass setComment:(self comment).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1362
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1363
    "find the class which is my sole instance"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1364
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1365
    oldClass := oldMetaClass theNonMetaclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1366
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1367
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1368
     create the new class
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1369
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1370
    newClass := newMetaclass new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1371
    newClass setSuperclass:(oldClass superclass) instSize:(oldClass instSize).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1372
    newClass flags:(oldClass flags).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1373
    newClass setName:(oldClass name).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1374
    newClass setInstanceVariableString:(oldClass instanceVariableString).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1375
    newClass classVariableString:(oldClass classVariableString).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1376
    newClass setComment:(oldClass comment).
7580
0a49277831d9 class category: sends a change notification;
Claus Gittinger <cg@exept.de>
parents: 7528
diff changeset
  1377
    newClass setCategory:(oldClass category).
7487
c1bb5613ae04 renamed class-attributes
tm
parents: 7434
diff changeset
  1378
    (t := oldClass classAttributes) notNil ifTrue:[
c1bb5613ae04 renamed class-attributes
tm
parents: 7434
diff changeset
  1379
        newClass classAttributes:t.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1380
    ].        
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1381
    newClass setClassFilename:(oldClass classFilename).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1382
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1383
    "/ set the new classes package
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1384
    "/ from the old package
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1385
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1386
    newClass package:(oldClass package).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1387
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1388
    "/ and keep the binary revision
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1389
    newClass setBinaryRevision:(oldClass binaryRevision).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1390
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1391
    changeSet := Set new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1392
    ((oldNames size == 0) 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1393
    or:[newNames startsWith:oldNames]) ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1394
        "new variable(s) has/have been added - old methods still work"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1395
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1396
"/        Transcript showCR:'copying methods ...'.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1397
"/        Transcript endEntry.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1398
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1399
        ClassBuilder copyMethodsFrom:oldMetaClass for:newMetaclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1400
        ClassBuilder copyMethodsFrom:oldClass for:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1401
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1402
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1403
         but have to recompile methods accessing stuff now defined
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1404
         (it might have been a global/undeclared before ...)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1405
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1406
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1407
        addedNames := newNames select:[:nm | (oldNames includes:nm) not].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1408
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1409
"/        Smalltalk silentLoading ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1410
"/            Transcript showCR:'recompiling class methods of ' , newMetaclass name ,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1411
"/                              ' accessing any of ' , addedNames printString.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1412
"/        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1413
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1414
        "recompile class-methods"    
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1415
        newMetaclass recompileMethodsAccessingAny:addedNames.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1416
    ] ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1417
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1418
         create the changeSet; thats the set of class instvar names
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1419
         which have changed their position or are new
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1420
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1421
        offset := 0. oldOffsets := Dictionary new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1422
        oldNames do:[:nm | offset := offset + 1. oldOffsets at:nm put:offset].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1423
        offset := 0. newOffsets := Dictionary new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1424
        newNames do:[:nm | offset := offset + 1. newOffsets at:nm put:offset].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1425
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1426
        oldOffsets associationsDo:[:a |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1427
            |k|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1428
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1429
            k := a key.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1430
            (newOffsets includesKey:k) ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1431
                changeSet add:k
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1432
            ] ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1433
                (a value ~~ (newOffsets at:k)) ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1434
                    changeSet add:k
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1435
                ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1436
            ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1437
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1438
        newOffsets associationsDo:[:a |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1439
            |k|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1440
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1441
            k := a key.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1442
            (oldOffsets includesKey:k) ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1443
                changeSet add:k
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1444
            ] ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1445
                (a value ~~ (oldOffsets at:k)) ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1446
                    changeSet add:k
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1447
                ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1448
            ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1449
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1450
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1451
"/        Smalltalk silentLoading ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1452
"/            Transcript showCR:'recompiling class methods of ' , newMetaclass name ,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1453
"/                              ' accessing any of ' , changeSet printString.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1454
"/        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1455
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1456
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1457
         recompile class-methods accessing any c-instvar with a changed position
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1458
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1459
        ClassBuilder copyInvalidatedMethodsFrom:oldMetaClass for:newMetaclass accessingAny:changeSet.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1460
        newMetaclass recompileInvalidatedMethods.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1461
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1462
        ClassBuilder copyMethodsFrom:oldClass for:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1463
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1464
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1465
    delta := newNames size - oldNames size.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1466
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1467
    "/ preserve existing classInstVar values (but not those from Class)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1468
    newMetaclass allInstVarNames do:[:nm |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1469
        |v|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1470
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1471
        (Class class allInstVarNames includes:nm) ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1472
            v := oldClass instVarNamed:nm ifAbsent:nil.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1473
            v notNil ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1474
                newClass instVarNamed:nm put:v.    
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1475
            ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1476
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1477
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1478
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1479
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1480
     get list of all subclasses - do before superclass is changed
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1481
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1482
    allSubclasses := oldClass allSubclasses asOrderedCollection.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1483
    "/ cg: wrong: allSubclasses := allSubclasses asSortedCollection:[:a :b | b isSubclassOf:a].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1484
    allSubclasses := allSubclasses topologicalSort:[:a :b | b isSubclassOf:a]. 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1485
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1486
    oldToNew := IdentityDictionary new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1487
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1488
    "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1489
     create a new class tree, based on the new version
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1490
    "
6957
562b88083688 more cache flushing when instvars change
Claus Gittinger <cg@exept.de>
parents: 6825
diff changeset
  1491
    Smalltalk flushCachedClasses.
562b88083688 more cache flushing when instvars change
Claus Gittinger <cg@exept.de>
parents: 6825
diff changeset
  1492
    Class flushSubclassInfo.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1493
    allSubclasses do:[:aSubclass |
8235
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
  1494
        |oldSuper|
4cb26959673c oops - did not care for changed superclass
Claus Gittinger <cg@exept.de>
parents: 8234
diff changeset
  1495
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1496
        oldSuper := aSubclass superclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1497
        oldSubMeta := aSubclass class.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1498
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1499
        newSubMeta := Metaclass new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1500
        oldSuper == oldClass ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1501
            newSubMeta setSuperclass:newMetaclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1502
        ] ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1503
            newSubMeta setSuperclass:(oldToNew at:oldSuper) class.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1504
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1505
        newSubMeta instSize:(oldSubMeta instSize + delta).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1506
        newSubMeta flags:(oldSubMeta flags).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1507
"/        newSubMeta setName:(oldSubMeta name).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1508
        newSubMeta setInstanceVariableString:(oldSubMeta instanceVariableString).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1509
"/        newSubMeta setComment:(oldSubMeta comment).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1510
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1511
        newSub := newSubMeta new.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1512
        oldSuper == oldClass ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1513
            newSub setSuperclass:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1514
        ] ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1515
            newSub setSuperclass:(oldToNew at:oldSuper).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1516
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1517
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1518
"/        newSub setMethodDictionary:(aSubclass methodDictionary copy).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1519
"/        newSub class setMethodDictionary:(aSubclass class methodDictionary copy).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1520
        newSub setName:(aSubclass name).
7516
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1521
        newSub setClassVariableString:(aSubclass classVariableString).
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1522
        newSub setInstanceVariableString:(aSubclass instanceVariableString).
7487
c1bb5613ae04 renamed class-attributes
tm
parents: 7434
diff changeset
  1523
        (t := aSubclass classAttributes) notNil ifTrue:[
c1bb5613ae04 renamed class-attributes
tm
parents: 7434
diff changeset
  1524
            newSub classAttributes:t.
7370
1ed996a6e7bf primitiveSpec changed to attributes.
Claus Gittinger <cg@exept.de>
parents: 7230
diff changeset
  1525
        ].        
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1526
        newSub package:(aSubclass package).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1527
        newSub setClassFilename:(oldClass classFilename).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1528
        newSub setComment:(aSubclass comment).
7580
0a49277831d9 class category: sends a change notification;
Claus Gittinger <cg@exept.de>
parents: 7528
diff changeset
  1529
        newSub setCategory:(aSubclass category).
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1530
        newSub instSize:(aSubclass instSize).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1531
        newSub setBinaryRevision:(aSubclass binaryRevision).
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1532
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1533
        oldToNew at:aSubclass put:newSub.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1534
7580
0a49277831d9 class category: sends a change notification;
Claus Gittinger <cg@exept.de>
parents: 7528
diff changeset
  1535
        aSubclass setCategory:#'* obsolete *'.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1536
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1537
        "/ preserve existing classInstVar values (but not those from Class)
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1538
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1539
        newSubMeta allInstVarNames do:[:nm |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1540
            |v|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1541
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1542
            (Class class allInstVarNames includes:nm) ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1543
                v := aSubclass instVarNamed:nm ifAbsent:nil.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1544
                v notNil ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1545
                    newSub instVarNamed:nm put:v.    
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1546
                ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1547
            ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1548
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1549
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1550
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1551
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1552
    "recompile what needs to be"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1553
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1554
    delta == 0 ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1555
        "only have to recompile class methods accessing 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1556
         class instvars from changeset
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1557
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1558
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1559
        allSubclasses do:[:oldSubclass |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1560
            |newSubclass|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1561
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1562
            newSubclass := oldToNew at:oldSubclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1563
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1564
"/            Smalltalk silentLoading ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1565
"/                Transcript showCR:'recompiling class methods of ' , newSubclass class name ,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1566
"/                                  ' accessing any of ' , changeSet printString.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1567
"/            ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1568
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1569
            ClassBuilder
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1570
                copyInvalidatedMethodsFrom:oldSubclass class for:newSubclass class 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1571
                accessingAny:changeSet orSuper:true.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1572
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1573
            ClassBuilder
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1574
                copyInvalidatedMethodsFrom:oldSubclass for:newSubclass 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1575
                accessingAny:#() orSuper:true.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1576
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1577
            newSubclass class recompileInvalidatedMethods.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1578
            newSubclass recompileInvalidatedMethods.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1579
        ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1580
    ] ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1581
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1582
         have to recompile all class methods accessing class instvars
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1583
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1584
        commonClassInstVars := oldClass class allInstVarNames.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1585
        changeSet do:[:v |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1586
            commonClassInstVars remove:v ifAbsent:[]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1587
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1588
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1589
        allSubclasses do:[:oldSubclass |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1590
            |newSubclass classInstVars|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1591
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1592
            newSubclass := oldToNew at:oldSubclass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1593
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1594
            classInstVars := newSubclass class allInstVarNames asSet.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1595
            classInstVars removeAll:commonClassInstVars.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1596
            classInstVars addAll:changeSet.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1597
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1598
"/            Smalltalk silentLoading ifFalse:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1599
"/                Transcript showCR:'recompiling class methods of ' , newSubclass class name ,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1600
"/                                  ' accessing any of ' , classInstVars printString.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1601
"/            ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1602
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1603
            ClassBuilder
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1604
                copyInvalidatedMethodsFrom:oldSubclass class for:newSubclass class 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1605
                accessingAny:classInstVars orSuper:true.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1606
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1607
            ClassBuilder
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1608
                copyInvalidatedMethodsFrom:oldSubclass for:newSubclass 
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1609
                accessingAny:#() orSuper:true.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1610
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1611
            newSubclass class recompileInvalidatedMethods.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1612
            newSubclass recompileInvalidatedMethods.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1613
        ]
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1614
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1615
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1616
    newClass addChangeRecordForClassInstvars:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1617
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1618
    "install all new classes"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1619
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1620
    (Smalltalk at:(oldClass name asSymbol) ifAbsent:nil) == oldClass ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1621
        Smalltalk at:(oldClass name asSymbol) put:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1622
        ClassBuilder checkForAliasesOf:oldClass with:newClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1623
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1624
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1625
         change any private subclasses' owners
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1626
        "
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1627
        oldClass privateClassesDo:[:aClass |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1628
            aClass class setOwningClass:newClass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1629
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1630
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1631
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1632
    ObjectMemory flushCachesFor:oldClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1633
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1634
    allSubclasses do:[:oldSubClass |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1635
        |newSubClass|
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1636
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1637
        newSubClass := oldToNew at:oldSubClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1638
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1639
"/        Transcript showCR:'install ' , newSubClass name , '(' , newSubClass category , ')' ,
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1640
"/                          ' as ' , newSubClass name.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1641
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1642
        (Smalltalk at:(oldSubClass name asSymbol) ifAbsent:nil) == oldSubClass ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1643
            Smalltalk at:oldSubClass name asSymbol put:newSubClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1644
            ClassBuilder checkForAliasesOf:oldSubClass with:newSubClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1645
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1646
        ObjectMemory flushCachesFor:oldSubClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1647
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1648
        oldSubClass privateClassesDo:[:aClass |
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1649
            aClass class setOwningClass:newSubClass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1650
        ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1651
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1652
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1653
    "tell dependents ..."
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1654
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1655
    oldClass changed:#definition.
7516
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1656
"/    oldClass nameSpace changed:#classDefinition with:oldClass.
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1657
"/    oldClass nameSpace ~~ Smalltalk ifTrue:[
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1658
"/        Smalltalk changed:#classDefinition with:oldClass.
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1659
"/    ].
42c5b199db20 change notifications for classInstVar change
Claus Gittinger <cg@exept.de>
parents: 7487
diff changeset
  1660
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1661
    oldMetaClass changed:#definition.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1662
    oldMetaClass nameSpace changed:#classDefinition with:oldMetaClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1663
    oldMetaClass nameSpace ~~ Smalltalk ifTrue:[
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1664
        Smalltalk changed:#classDefinition with:oldMetaClass.
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1665
    ].
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1666
7580
0a49277831d9 class category: sends a change notification;
Claus Gittinger <cg@exept.de>
parents: 7528
diff changeset
  1667
    oldClass setCategory:#'* obsolete *'.
5907
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1668
    ^ newMetaclass
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1669
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1670
    "Created: / 29.10.1995 / 19:57:08 / cg"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1671
    "Modified: / 1.4.1997 / 15:44:09 / stefan"
4abc5fb54fc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5905
diff changeset
  1672
    "Modified: / 31.7.1998 / 18:02:00 / cg"
8073
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1673
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1674
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1675
setPackageInNewClass:newClass fromOld:oldClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1676
    |pkg oldPkg answer|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1677
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1678
    "/ set the new classes package
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1679
    "/ but be careful here ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1680
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1681
    oldClass isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1682
        "/ new classes get the current package ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1683
        pkg := Class packageQuerySignal query.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1684
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1685
        newClass setClassFilename:(oldClass classFilename).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1686
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1687
        oldPkg := oldClass package.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1688
        oldClass isLoaded ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1689
            "/ autoloaded classes get the package of the autoload stub ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1690
            pkg := oldPkg
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1691
        ] ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1692
            "/ not autoloading, check for packageRedef ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1693
            buildingPrivateClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1694
                pkg := environment package.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1695
            ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1696
                pkg := Class packageQuerySignal query.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1697
                oldPkg ~= pkg ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1698
                    newClass package:pkg.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1699
                    answer := Class classRedefinitionSignal
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1700
                                  raiseRequestWith:(oldClass -> newClass)
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1701
                                  errorString:('redefinition of class: ' , oldClass name).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1702
                    answer == #keep ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1703
                        pkg := oldPkg. "/ keep old package
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1704
                    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1705
                        answer ~~ #continue ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1706
                            ^ nil "/ cancel
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1707
                        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1708
                        "/ take new package
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1709
                    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1710
                ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1711
                newClass setBinaryRevision:(oldClass binaryRevision).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1712
            ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1713
        ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1714
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1715
    pkg notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1716
"/ Transcript showCR:('set package of class: ' , newClass name , ' to ' , pkg printString).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1717
        newClass package:pkg.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1718
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1719
!
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1720
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1721
setupNewClass:newClass fromOld:oldClass
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1722
    |newFlags superFlags nInstVars spec|
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1723
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1724
    (instanceVariableNames size > 0) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1725
        nInstVars := instanceVariableNames countWords.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1726
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1727
        nInstVars := 0.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1728
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1729
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1730
    "/ Allowing non-booleans as variableBoolean
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1731
    "/ is a hack for backward (ST-80) compatibility:
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1732
    "/ ST-80 code will pass true or false as variableBoolean,
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1733
    "/ while ST/X also calls it with symbols such as #float, #double etc.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1734
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1735
    (variable == true) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1736
        pointers ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1737
            newFlags := Behavior flagPointers
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1738
        ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1739
            words ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1740
                newFlags := Behavior flagWords
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1741
            ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1742
                newFlags := Behavior flagBytes
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1743
            ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1744
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1745
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1746
        "/ false or symbol.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1747
        newFlags := Behavior flagForSymbolic:variable.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1748
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1749
    superClass isNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1750
        superFlags := 0
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1751
    ] ifFalse:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1752
        superFlags := superClass flags bitAnd:(Behavior maskIndexType bitInvert). "preserve other bits"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1753
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1754
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1755
    oldClass notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1756
        oldClass isBuiltInClass ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1757
            "
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1758
             special care when redefining Method, Block and other built-in classes,
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1759
             which might have other flag bits ...
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1760
            "
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1761
            newFlags := newFlags bitOr:(oldClass flags bitAnd:(Behavior maskIndexType bitInvert))
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1762
        ]
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1763
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1764
    newClass flags:(newFlags bitOr:superFlags). "preserve  inherited special bits"
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1765
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1766
    (nInstVars ~~ 0) ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1767
        newClass setInstanceVariableString:instanceVariableNames
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1768
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1769
    oldClass notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1770
        "/ setting first will make new class clear obsolete classvars
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1771
        newClass setClassVariableString:(oldClass classVariableString).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1772
        newClass setClassFilename:(oldClass classFilename).
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1773
        (spec := oldClass classAttributes) notNil ifTrue:[
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1774
            newClass classAttributes:spec.
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1775
        ].        
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1776
    ].
42c37438e0dc refactored for shorter methods
Claus Gittinger <cg@exept.de>
parents: 7617
diff changeset
  1777
    newClass setClassVariableString:classVariableNames.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
! !
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
!ClassBuilder methodsFor:'checks'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
checkClassName
8421
93d8a1a98244 *** empty log message ***
ca
parents: 8351
diff changeset
  1783
    environment isNil ifTrue:[
93d8a1a98244 *** empty log message ***
ca
parents: 8351
diff changeset
  1784
        "/ no constraints
93d8a1a98244 *** empty log message ***
ca
parents: 8351
diff changeset
  1785
        ^ self
93d8a1a98244 *** empty log message ***
ca
parents: 8351
diff changeset
  1786
    ].
93d8a1a98244 *** empty log message ***
ca
parents: 8351
diff changeset
  1787
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
    (className isSymbol not
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1789
    or:[className size == 0]) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
        self error:'invalid class name (must be a nonEmpty symbol)'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
    className first isLetter ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
        self error:'invalid class name (must start with a letter)'.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
checkConventionsFor:className subClassOf:aClass instVarNames:instVarNameString classVarNames:classVarNameString
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
    "Check for some 'considered bad-style' things, like lower case names.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
     NOTICE:
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
     I dont like the confirmers below - we need a notifying: argument, to give
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
     the outer codeview a chance to highlight the error.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
     (but thats how its defined in the book - maybe I will change it anyway).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
    |names idx what doChecks answ|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1807
    doChecks := Metaclass confirmationQuerySignal query.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
    doChecks == false ifTrue:[^ true].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
    "let user confirm, if the classname is no good"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
    className first isUppercase ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
        aClass == NameSpace ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
            what := 'namespace'
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1814
        ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
            what := 'class'
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
        answ := Class classConventionViolationConfirmationQuerySignal query.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1819
        answ notNil ifTrue:[^ answ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
        (self confirm:(what , ' name ''' , className , 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
                             ''' should start with an uppercase letter
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
(by convention only)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
install anyway ?') withCRs)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1826
        ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1827
            ^ false
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1831
    names := instVarNameString asCollectionOfWords.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1832
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
    "let user confirm, if any instvarname is no good"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
    (idx := names findFirst:[:word | word first isUppercase]) ~~ 0 ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
        answ := Class classConventionViolationConfirmationQuerySignal query.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
        answ notNil ifTrue:[^ answ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1837
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
        (self confirm:className , ': instance variable named ''' , (names at:idx) allBold , ''' 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1839
should start with a lowercase letter (by convention only).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1840
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
Install anyway ?' withCRs)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
        ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
            ^ false
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1844
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1847
    names := classVarNameString asCollectionOfWords. 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1848
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
    "let user confirm, if any classvarname is no good"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
    (idx := names findFirst:[:word | word first isLowercase]) ~~ 0 ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1851
        answ := Class classConventionViolationConfirmationQuerySignal query.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
        answ notNil ifTrue:[^ answ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1854
        (self confirm:className , ': class variable named ''' , (names at:idx) allBold  , ''' 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
should start with an uppercase letter (by convention only).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1856
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
Install anyway ?' withCRs)
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
        ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
            ^ false
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1861
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1863
    ^ true
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
    "Created: / 15.10.1996 / 11:56:38 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
    "Modified: / 3.2.1999 / 11:24:52 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
    "Modified: / 18.3.1999 / 18:22:47 / stefan"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
6034
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1870
checkForCircularDefinitionFrom:oldClass
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1871
    oldClass allSuperclasses do:[:cls |
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1872
        cls name = realNewName ifTrue:[
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1873
            ^ true
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1874
        ]
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1875
    ].
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1876
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1877
    superClass notNil ifTrue:[
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1878
        superClass allSuperclasses do:[:cls |
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1879
            cls name = realNewName ifTrue:[
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1880
                ^ true
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1881
            ]
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1882
        ].
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1883
    ].
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1884
    ^ false
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1885
!
837b3fd25342 optionally replaceReferencesTo oldClass with references to newClass
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  1886
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1887
checkInstvarRedefsWith:stringOfInstVarNames subclassOf:aClass old:oldClass name:newName
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
    |superInstVars msg|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
    aClass notNil ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
        "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1892
         check for instVar redef of superClass instVars
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1893
        "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1894
        superInstVars := aClass allInstVarNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1895
        stringOfInstVarNames asCollectionOfWords do:[:nm |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1896
            (superInstVars includes:nm) ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1897
                (oldClass notNil 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1898
                and:[stringOfInstVarNames = oldClass instanceVariableString])
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
                ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
                    Transcript showCR:('instVar conflict in `' , newName , ''' for `' , nm , ''' due to superclass change.').
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1901
                    msg := 'InstVar conflict in `' , newName allBold , ''' for `' , nm allBold, ''' due to superclass change.\You now have two different instVar slots with the same name.\\Don''t forget to fix this later.'.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
                    self warn:msg withCRs.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
                ] ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1904
                    Transcript showCR:('instVar `' , nm , ''' is already defined in a superclass of `' , newName , '''.').
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1905
                    msg := 'instVar `' , nm allBold, ''' is already defined in a superclass.\Change the definition of `' , newName allBold, ''' anyway ?\\Don''t forget to fix this later.'.
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1906
                    ^ self confirm:msg withCRs
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1907
                ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
        ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
    oldClass notNil ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1913
        "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1914
         check for instVar redefs in subclass instVars
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1915
        "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1916
        oldClass allSubclassesDo:[:sub |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1917
            |vars|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1918
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1919
            vars := sub instVarNames.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1920
            stringOfInstVarNames asCollectionOfWords do:[:nm |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1921
                (vars includes:nm) ifTrue:[
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1922
                    ^ self confirm:('subclass `' 
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1923
                                    , sub name allBold
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1924
                                    , ''' already defines an instVar named `' 
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1925
                                    , nm allBold
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1926
                                    , '''.\\Change the definition of `' 
7132
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1927
                                    , newName allBold
7b9ddc1700c5 instvar redef warnings;
Claus Gittinger <cg@exept.de>
parents: 7131
diff changeset
  1928
                                    , ''' anyway ?\Notice: you must fix this later.'
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1929
                                   ) withCRs
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1930
                ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1931
            ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1932
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1934
    ^ true
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1935
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
    "Created: 29.1.1997 / 17:42:11 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1937
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1938
8539
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1939
checkValidPools
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1940
    "check for invalid subclassing of UndefinedObject and SmallInteger"
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1941
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1942
    poolDictionaries notNil ifTrue:[
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1943
        poolDictionaries asCollectionOfWords do:[:eachPoolName |
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1944
            |pool|
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1945
8636
c7b8998a99dd read pool from environment
penk
parents: 8610
diff changeset
  1946
            pool := environment classNamed:eachPoolName.
c7b8998a99dd read pool from environment
penk
parents: 8610
diff changeset
  1947
            pool isNil ifTrue:[
c7b8998a99dd read pool from environment
penk
parents: 8610
diff changeset
  1948
                pool := Smalltalk classNamed:eachPoolName.
c7b8998a99dd read pool from environment
penk
parents: 8610
diff changeset
  1949
            ].
8639
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  1950
            (pool notNil and:[pool isBehavior]) ifTrue:[
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  1951
                pool autoload.
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  1952
                pool isSharedPool ifFalse:[
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  1953
                    self error:('Not a valid pool: ' , eachPoolName) mayProceed:true.
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  1954
                ]
8539
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1955
            ]
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1956
        ]
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1957
    ].
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1958
!
e2fd35af7360 *** empty log message ***
ca
parents: 8467
diff changeset
  1959
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1960
checkValidSubclassing
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1961
    "check for invalid subclassing of UndefinedObject and SmallInteger"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1962
    superClass notNil ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1963
        superClass canBeSubclassed ifFalse:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1964
            self error:('it is not possible to subclass ' , superClass name).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1967
!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1968
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1969
checkValidVarNamesFor:className subClassOf:aClass instVarNames:instVarNameString classVarNames:classVarNameString
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1970
    "Check for some 'considered bad-style' things, like lower case names.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1971
     NOTICE:
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1972
     I dont like the confirmers below - we need a notifying: argument, to give
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1973
     the outer codeview a chance to highlight the error.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1974
     (but thats how its defined in the book - maybe I will change it anyway).
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1975
    "
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1976
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1977
    |names|
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1978
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1979
    names := instVarNameString asCollectionOfWords.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1980
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1981
    "check for instvar redefs within local instvars"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1982
    names keysAndValuesDo:[:index :aName |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1983
        (names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1984
            self warn:'instance variable ''' , aName , '''\occurs multiple times in instVarString.\\Class not installed.' withCRs.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1985
            ^ false.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1986
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
    names := classVarNameString asCollectionOfWords. 
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
    "check for classvar redefs within local instvars"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1992
    names keysAndValuesDo:[:index :aName |
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1993
        (names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1994
            self warn:'class variable ''' , aName , '''\occurs multiple times in classVarString.\\Class not installed.' withCRs.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1995
            ^ false.
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1996
        ]
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1997
    ].
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1998
    ^ true
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
    "Created: 8.1.1997 / 21:09:14 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
    "Modified: 9.1.1997 / 02:10:02 / cg"
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2002
! !
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2003
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2004
!ClassBuilder class methodsFor:'documentation'!
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2005
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2006
version
8639
b4a2caa29d19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8636
diff changeset
  2007
    ^ '$Header: /cvs/stx/stx/libbasic/ClassBuilder.st,v 1.41 2004-11-16 21:20:29 cg Exp $'
5905
06cf209d6acc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2008
! !