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