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