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