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