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