author | Claus Gittinger <cg@exept.de> |
Sat, 07 Feb 2015 12:09:03 +0100 | |
changeset 966 | 1819c104488d |
parent 934 | 6a56a913c6b0 |
child 968 | 70b2a6241dd2 |
permissions | -rw-r--r-- |
48 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
MCDefinition subclass:#MCClassDefinition |
|
214 | 4 |
instanceVariableNames:'name superclassName variables category type comment commentStamp |
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
5 |
traitComposition classTraitComposition' |
48 | 6 |
classVariableNames:'' |
7 |
poolDictionaries:'' |
|
610 | 8 |
category:'SCM-Monticello-Modeling' |
48 | 9 |
! |
10 |
||
11 |
||
12 |
!MCClassDefinition class methodsFor:'instance creation'! |
|
13 |
||
14 |
name: nameString |
|
15 |
superclassName: superclassString |
|
16 |
category: categoryString |
|
17 |
instVarNames: ivarArray |
|
18 |
classVarNames: cvarArray |
|
19 |
poolDictionaryNames: poolArray |
|
20 |
classInstVarNames: civarArray |
|
21 |
type: typeSymbol |
|
22 |
comment: commentString |
|
23 |
commentStamp: stampString |
|
24 |
^ self instanceLike: |
|
25 |
(self new initializeWithName: nameString |
|
26 |
superclassName: superclassString |
|
214 | 27 |
traitComposition: '{}' |
28 |
classTraitComposition: '{}' |
|
29 |
category: categoryString |
|
30 |
instVarNames: ivarArray |
|
31 |
classVarNames: cvarArray |
|
32 |
poolDictionaryNames: poolArray |
|
33 |
classInstVarNames: civarArray |
|
34 |
type: typeSymbol |
|
35 |
comment: commentString |
|
36 |
commentStamp: stampString) |
|
37 |
! |
|
38 |
||
39 |
name: nameString |
|
40 |
superclassName: superclassString |
|
41 |
traitComposition: traitCompositionString |
|
42 |
classTraitComposition: classTraitCompositionString |
|
43 |
category: categoryString |
|
44 |
instVarNames: ivarArray |
|
45 |
classVarNames: cvarArray |
|
46 |
poolDictionaryNames: poolArray |
|
47 |
classInstVarNames: civarArray |
|
48 |
type: typeSymbol |
|
49 |
comment: commentString |
|
50 |
commentStamp: stampString |
|
51 |
||
52 |
^ self instanceLike: |
|
53 |
(self new initializeWithName: nameString |
|
54 |
superclassName: superclassString |
|
55 |
traitComposition: traitCompositionString |
|
56 |
classTraitComposition: classTraitCompositionString |
|
48 | 57 |
category: categoryString |
58 |
instVarNames: ivarArray |
|
59 |
classVarNames: cvarArray |
|
60 |
poolDictionaryNames: poolArray |
|
61 |
classInstVarNames: civarArray |
|
62 |
type: typeSymbol |
|
63 |
comment: commentString |
|
64 |
commentStamp: stampString) |
|
65 |
! ! |
|
66 |
||
67 |
!MCClassDefinition class methodsFor:'obsolete'! |
|
68 |
||
69 |
name: nameString |
|
70 |
superclassName: superclassString |
|
71 |
category: categoryString |
|
72 |
instVarNames: ivarArray |
|
73 |
classVarNames: cvarArray |
|
74 |
poolDictionaryNames: poolArray |
|
75 |
classInstVarNames: civarArray |
|
76 |
comment: commentString |
|
77 |
^ self name: nameString |
|
78 |
superclassName: superclassString |
|
79 |
category: categoryString |
|
80 |
instVarNames: ivarArray |
|
81 |
classVarNames: cvarArray |
|
82 |
poolDictionaryNames: poolArray |
|
83 |
classInstVarNames: civarArray |
|
84 |
type: #normal |
|
85 |
comment: commentString |
|
214 | 86 |
|
48 | 87 |
! |
88 |
||
89 |
name: nameString |
|
90 |
superclassName: superclassString |
|
91 |
category: categoryString |
|
92 |
instVarNames: ivarArray |
|
93 |
classVarNames: cvarArray |
|
94 |
poolDictionaryNames: poolArray |
|
95 |
classInstVarNames: civarArray |
|
96 |
type: typeSymbol |
|
97 |
comment: commentString |
|
98 |
^ self |
|
99 |
name: nameString |
|
100 |
superclassName: superclassString |
|
101 |
category: categoryString |
|
102 |
instVarNames: ivarArray |
|
103 |
classVarNames: cvarArray |
|
104 |
poolDictionaryNames: poolArray |
|
105 |
classInstVarNames: civarArray |
|
106 |
type: typeSymbol |
|
107 |
comment: commentString |
|
108 |
commentStamp: nil |
|
109 |
! |
|
110 |
||
111 |
name: nameString |
|
112 |
superclassName: superclassString |
|
113 |
category: categoryString |
|
114 |
instVarNames: ivarArray |
|
115 |
comment: commentString |
|
116 |
^ self name: nameString |
|
117 |
superclassName: superclassString |
|
118 |
category: categoryString |
|
119 |
instVarNames: ivarArray |
|
120 |
classVarNames: #() |
|
121 |
poolDictionaryNames: #() |
|
122 |
classInstVarNames: #() |
|
123 |
comment: commentString |
|
214 | 124 |
|
48 | 125 |
! ! |
126 |
||
127 |
!MCClassDefinition methodsFor:'accessing'! |
|
128 |
||
129 |
actualClass |
|
130 |
^Smalltalk classNamed: self className |
|
131 |
! |
|
132 |
||
133 |
category |
|
134 |
^ category |
|
135 |
! |
|
136 |
||
848
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
137 |
category:something |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
138 |
category := something. |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
139 |
! |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
140 |
|
48 | 141 |
classInstVarNames |
142 |
^ self selectVariables: #isClassInstanceVariable |
|
143 |
! |
|
144 |
||
521 | 145 |
classInstVarNames:civarArray |
146 |
self addVariables: civarArray ofType: MCClassInstanceVariableDefinition. |
|
147 |
||
148 |
"Created: / 25-11-2011 / 17:42:34 / cg" |
|
149 |
! |
|
150 |
||
48 | 151 |
className |
152 |
^ name |
|
153 |
! |
|
154 |
||
876 | 155 |
className: aString |
156 |
name := aString |
|
157 |
||
158 |
"Created: / 31-05-2013 / 10:33:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
159 |
! |
|
160 |
||
214 | 161 |
classTraitComposition |
162 |
^classTraitComposition |
|
163 |
! |
|
164 |
||
165 |
classTraitCompositionString |
|
166 |
^self classTraitComposition ifNil: ['{}']. |
|
167 |
! |
|
168 |
||
48 | 169 |
classVarNames |
170 |
^ self selectVariables: #isClassVariable |
|
171 |
! |
|
172 |
||
173 |
comment |
|
214 | 174 |
^ comment ? '' |
175 |
||
176 |
"Modified: / 12-09-2010 / 17:07:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 | 177 |
! |
178 |
||
179 |
commentStamp |
|
180 |
^ commentStamp |
|
181 |
! |
|
182 |
||
183 |
description |
|
184 |
^ Array with: name |
|
214 | 185 |
|
48 | 186 |
! |
187 |
||
188 |
instVarNames |
|
189 |
^ self selectVariables: #isInstanceVariable |
|
190 |
! |
|
191 |
||
470 | 192 |
installedClass |
193 |
^Smalltalk classNamed: self installedClassName |
|
194 |
||
195 |
"Created: / 07-09-2011 / 13:33:10 / cg" |
|
196 |
! |
|
197 |
||
198 |
installedClassName |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
199 |
| installedClassName | |
470 | 200 |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
201 |
installedClassName := self objectAttributeAt: #installedClassName. |
470 | 202 |
^ installedClassName ? name |
203 |
||
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
204 |
"Created: / 07-09-2011 / 13:36:37 / cg" |
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
205 |
"Modified: / 12-08-2013 / 01:49:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
206 |
! |
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
207 |
|
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
208 |
installedClassName:aString |
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
209 |
self objectAttributeAt: #installedClassName put: aString. |
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
210 |
|
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
211 |
"Modified: / 12-08-2013 / 01:37:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
470 | 212 |
! |
213 |
||
48 | 214 |
poolDictionaries |
215 |
^ self selectVariables: #isPoolImport |
|
216 |
! |
|
217 |
||
218 |
selectVariables: aSelector |
|
713 | 219 |
variables isNil ifTrue:[^#()]. |
220 |
^ variables select: [:v | v perform: aSelector] thenCollect: [:v | v name] |
|
48 | 221 |
! |
222 |
||
223 |
sortKey |
|
224 |
^ self className |
|
225 |
! |
|
226 |
||
227 |
superclassName |
|
228 |
^ superclassName |
|
229 |
! |
|
230 |
||
897
76481ea7aaba
Bugfix: MCClassDefinition.superclassName must be a symbol.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
894
diff
changeset
|
231 |
superclassName:aStringOrSymbol |
76481ea7aaba
Bugfix: MCClassDefinition.superclassName must be a symbol.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
894
diff
changeset
|
232 |
superclassName := aStringOrSymbol asSymbol. |
76481ea7aaba
Bugfix: MCClassDefinition.superclassName must be a symbol.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
894
diff
changeset
|
233 |
|
76481ea7aaba
Bugfix: MCClassDefinition.superclassName must be a symbol.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
894
diff
changeset
|
234 |
"Modified: / 20-09-2013 / 00:13:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
848
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
235 |
! |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
236 |
|
214 | 237 |
traitComposition |
238 |
^traitComposition |
|
239 |
! |
|
240 |
||
241 |
traitCompositionString |
|
242 |
^self traitComposition ifNil: ['{}']. |
|
243 |
! |
|
244 |
||
48 | 245 |
type |
246 |
^ type |
|
247 |
! |
|
248 |
||
249 |
variables |
|
250 |
^ variables |
|
251 |
! ! |
|
252 |
||
253 |
!MCClassDefinition methodsFor:'annotations'! |
|
254 |
||
255 |
printAnnotations: requests on: aStream |
|
256 |
"Add a string for an annotation pane, trying to fulfill the annotation requests. |
|
257 |
These might include anything that |
|
258 |
Preferences defaultAnnotationRequests |
|
259 |
might return. Which includes anything in |
|
260 |
Preferences annotationInfo |
|
261 |
To edit these, use:" |
|
262 |
"Preferences editAnnotations" |
|
263 |
||
264 |
requests do: [ :aRequest | |
|
265 |
aRequest == #requirements ifTrue: [ |
|
266 |
self requirements do: [ :req | aStream nextPutAll: req ] separatedBy: [ aStream space ]] |
|
267 |
] separatedBy: [ aStream space ]. |
|
268 |
! ! |
|
269 |
||
270 |
!MCClassDefinition methodsFor:'comparing'! |
|
271 |
||
272 |
hash |
|
273 |
| hash | |
|
214 | 274 |
hash := String stringHash: name initialHash: 0. |
275 |
hash := String stringHash: superclassName initialHash: hash. |
|
276 |
hash := String stringHash: self traitCompositionString initialHash: hash. |
|
277 |
hash := String stringHash: self classTraitComposition asString initialHash: hash. |
|
278 |
hash := String stringHash: (category ifNil: ['']) initialHash: hash. |
|
279 |
hash := String stringHash: type initialHash: hash. |
|
48 | 280 |
variables do: [ |
281 |
:v | |
|
214 | 282 |
hash := String stringHash: v name initialHash: hash. |
48 | 283 |
]. |
284 |
^ hash |
|
285 |
! |
|
286 |
||
287 |
provisions |
|
288 |
^ Array with: name |
|
289 |
! |
|
290 |
||
291 |
requirements |
|
292 |
^ (Array with: superclassName), self poolDictionaries |
|
293 |
! ! |
|
294 |
||
214 | 295 |
!MCClassDefinition methodsFor:'converting'! |
296 |
||
297 |
asChange |
|
565 | 298 |
|instVarNamesString classVarNamesString classInstVarNamesString poolDictionariesString |
299 |
definitionSelector| |
|
214 | 300 |
|
565 | 301 |
instVarNamesString := self instVarNames asStringWith:' '. |
302 |
classVarNamesString := self classVarNames asStringWith:' '. |
|
303 |
classInstVarNamesString := self classInstVarNames asStringWith:' '. |
|
304 |
poolDictionariesString := self poolDictionaries asStringWith:' '. |
|
305 |
||
306 |
definitionSelector := #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
713 | 307 |
(type notNil and:[type ~~ #normal]) ifTrue:[ |
565 | 308 |
type == #variable ifTrue:[ |
309 |
definitionSelector := #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
310 |
] ifFalse:[ |
|
311 |
type == #bytes ifTrue:[ |
|
312 |
definitionSelector := #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
313 |
] ifFalse:[ |
|
314 |
type == #words ifTrue:[ |
|
315 |
"for Squeak compatibility: that is long-words !!!!!!!!" |
|
316 |
definitionSelector := #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
317 |
] ifFalse:[ |
|
318 |
type == #compiledMethod ifTrue:[ |
|
319 |
definitionSelector := #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
320 |
] ifFalse:[ |
|
321 |
self halt:'unhandled class-type'. |
|
322 |
] |
|
323 |
] |
|
324 |
] |
|
325 |
] |
|
326 |
]. |
|
214 | 327 |
^ClassDefinitionChange new |
328 |
mcDefinition: self; |
|
565 | 329 |
definitionSelector: definitionSelector; |
214 | 330 |
className: name; |
331 |
superClassName: superclassName; |
|
565 | 332 |
instanceVariableNames: instVarNamesString ; |
333 |
classVariableNames: classVarNamesString ; |
|
334 |
classInstanceVariableNames: classInstVarNamesString ; |
|
335 |
poolDictionaries: poolDictionariesString ; |
|
214 | 336 |
category: category; |
337 |
yourself |
|
338 |
||
339 |
"Created: / 13-10-2010 / 17:11:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
340 |
"Modified: / 08-11-2010 / 17:56:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
565 | 341 |
"Modified: / 13-06-2012 / 12:57:38 / cg" |
214 | 342 |
! ! |
343 |
||
48 | 344 |
!MCClassDefinition methodsFor:'initializing'! |
345 |
||
346 |
addVariables: aCollection ofType: aClass |
|
347 |
variables addAll: (aCollection collect: [:var | aClass name: var asString]). |
|
348 |
! |
|
349 |
||
350 |
defaultCommentStamp |
|
351 |
^ String new |
|
352 |
||
353 |
"The version below avoids stomping on stamps already in the image |
|
354 |
||
355 |
^ (Smalltalk at: name ifPresent: [:c | c organization commentStamp]) |
|
356 |
ifNil: [''] |
|
357 |
" |
|
214 | 358 |
|
48 | 359 |
! ! |
360 |
||
361 |
!MCClassDefinition methodsFor:'installing'! |
|
362 |
||
363 |
createClass |
|
470 | 364 |
"cg: changed to honor any nameSpace query override" |
365 |
||
366 |
| env superClass class installedSuperclassName| |
|
367 |
||
368 |
env := MCStXNamespaceQuery query ? Smalltalk. |
|
369 |
superClass := env at: superclassName. |
|
370 |
(superClass isNil and:[env ~~ Smalltalk]) ifTrue:[ |
|
371 |
superClass := Smalltalk at: superclassName. |
|
372 |
]. |
|
373 |
||
214 | 374 |
"Create class if not exists" |
470 | 375 |
superClass isNil ifTrue:[ |
376 |
installedSuperclassName := (env == Smalltalk) |
|
377 |
ifTrue:[ superclassName ] |
|
378 |
ifFalse:[ env name ,'::',superclassName]. |
|
379 |
superClass := Class undeclared: installedSuperclassName |
|
380 |
]. |
|
934
6a56a913c6b0
Fixed MCClassDefinition>>#createClass: load superclass before creating class.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
897
diff
changeset
|
381 |
superClass isLoaded ifFalse:[ superClass autoload ]. |
470 | 382 |
|
383 |
"/ env := superClass environment. |
|
214 | 384 |
|
385 |
class := (ClassBuilder new) |
|
156 | 386 |
name: name |
470 | 387 |
inEnvironment: env |
156 | 388 |
subclassOf: superClass |
389 |
type: type |
|
390 |
instanceVariableNames: self instanceVariablesString |
|
391 |
classVariableNames: self classVariablesString |
|
392 |
poolDictionaries: self sharedPoolsString |
|
393 |
category: category. |
|
470 | 394 |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
395 |
self installedClassName:class name. |
470 | 396 |
|
214 | 397 |
self traitComposition ifNotNil: [ |
398 |
class setTraitComposition: (Compiler |
|
399 |
evaluate: self traitComposition) asTraitComposition ]. |
|
400 |
self classTraitComposition ifNotNil: [ |
|
401 |
class class setTraitComposition: (Compiler |
|
402 |
evaluate: self classTraitComposition) asTraitComposition ]. |
|
403 |
^class. |
|
156 | 404 |
|
470 | 405 |
"Modified (comment): / 07-09-2011 / 13:32:38 / cg" |
934
6a56a913c6b0
Fixed MCClassDefinition>>#createClass: load superclass before creating class.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
897
diff
changeset
|
406 |
"Modified: / 07-10-2014 / 00:20:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
48 | 407 |
! |
408 |
||
409 |
load |
|
214 | 410 |
| class | |
411 |
||
470 | 412 |
(class := self createClass) notNil ifTrue:[ |
413 |
class class instanceVariableNames: self classInstanceVariablesString. |
|
414 |
self hasComment ifTrue: [class classComment: comment stamp: commentStamp] |
|
415 |
]. |
|
214 | 416 |
class package: MCStXPackageQuery query. |
417 |
||
418 |
"Modified: / 14-09-2010 / 22:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
470 | 419 |
"Modified: / 07-09-2011 / 13:01:53 / cg" |
214 | 420 |
! |
421 |
||
422 |
stringForSortedVariablesOfType: aSymbol |
|
423 |
^ String streamContents: |
|
424 |
[:stream | |
|
425 |
(self selectVariables: aSymbol) asSortedCollection |
|
426 |
do: [:ea | stream nextPutAll: ea] |
|
427 |
separatedBy: [stream space]] |
|
48 | 428 |
! |
429 |
||
430 |
stringForVariablesOfType: aSymbol |
|
431 |
^ String streamContents: |
|
432 |
[:stream | |
|
433 |
(self selectVariables: aSymbol) |
|
434 |
do: [:ea | stream nextPutAll: ea] |
|
435 |
separatedBy: [stream space]] |
|
436 |
! |
|
437 |
||
438 |
unload |
|
439 |
Smalltalk removeClassNamed: name |
|
440 |
! ! |
|
441 |
||
442 |
!MCClassDefinition methodsFor:'printing'! |
|
443 |
||
444 |
classInstanceVariablesString |
|
445 |
^ self stringForVariablesOfType: #isClassInstanceVariable |
|
446 |
! |
|
447 |
||
448 |
classVariablesString |
|
214 | 449 |
^ self stringForSortedVariablesOfType: #isClassVariable |
48 | 450 |
! |
451 |
||
452 |
definitionString |
|
453 |
^ String streamContents: [:stream | self printDefinitionOn: stream] |
|
454 |
! |
|
455 |
||
456 |
instanceVariablesString |
|
457 |
^ self stringForVariablesOfType: #isInstanceVariable |
|
458 |
! |
|
459 |
||
460 |
kindOfSubclass |
|
214 | 461 |
type = #normal ifTrue: [^ ' subclass:']. |
462 |
type = #words ifTrue: [^ ' variableWordSubclass:']. |
|
463 |
type = #variable ifTrue: [^ ' variableSubclass:']. |
|
464 |
type = #bytes ifTrue: [^ ' variableByteSubclass:']. |
|
465 |
type = #weak ifTrue: [^ ' weakSubclass:' ]. |
|
466 |
type = #compiledMethod ifTrue: [^ ' variableByteSubclass:' ]. |
|
467 |
self error: 'Unrecognized class type' |
|
468 |
||
469 |
"Modified: / 11-09-2010 / 18:13:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 | 470 |
! |
471 |
||
472 |
printDefinitionOn: stream |
|
766 | 473 |
|clsName| |
474 |
||
214 | 475 |
stream |
476 |
nextPutAll: self superclassName; |
|
766 | 477 |
nextPutAll: self kindOfSubclass. |
478 |
((clsName := self className) includes:$_) ifTrue:[ |
|
479 |
stream |
|
480 |
nextPutAll: '#''' ; |
|
214 | 481 |
nextPutAll: self className; |
766 | 482 |
nextPutAll: '''' . |
483 |
] ifFalse:[ |
|
484 |
stream |
|
485 |
nextPut: $#; |
|
486 |
nextPutAll: self className. |
|
487 |
]. |
|
488 |
stream |
|
214 | 489 |
cr; tab. |
490 |
self hasTraitComposition ifTrue: [ |
|
491 |
stream |
|
492 |
nextPutAll: 'uses: '; |
|
493 |
nextPutAll: self traitCompositionString; |
|
494 |
cr; tab ]. |
|
495 |
stream |
|
496 |
nextPutAll: 'instanceVariableNames:'; |
|
497 |
store: self instanceVariablesString; |
|
498 |
cr; tab; |
|
499 |
nextPutAll: 'classVariableNames:'; |
|
500 |
store: self classVariablesString; |
|
501 |
cr; tab; |
|
502 |
nextPutAll: 'poolDictionaries:'; |
|
503 |
store: self sharedPoolsString; |
|
504 |
cr; tab; |
|
505 |
nextPutAll: 'category:'; |
|
506 |
store: self category asString |
|
507 |
||
508 |
"Modified: / 11-09-2010 / 18:11:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 | 509 |
! |
510 |
||
511 |
sharedPoolsString |
|
214 | 512 |
^ self stringForSortedVariablesOfType: #isPoolImport |
48 | 513 |
! |
514 |
||
515 |
source |
|
516 |
^ self definitionString |
|
517 |
! |
|
518 |
||
519 |
summary |
|
520 |
^ name |
|
521 |
! ! |
|
522 |
||
523 |
!MCClassDefinition methodsFor:'serializing'! |
|
524 |
||
525 |
initializeWithName: nameString |
|
526 |
superclassName: superclassString |
|
527 |
category: categoryString |
|
528 |
instVarNames: ivarArray |
|
529 |
classVarNames: cvarArray |
|
530 |
poolDictionaryNames: poolArray |
|
531 |
classInstVarNames: civarArray |
|
532 |
type: typeSymbol |
|
533 |
comment: commentString |
|
534 |
commentStamp: stampStringOrNil |
|
214 | 535 |
name := nameString asSymbol. |
536 |
superclassName := superclassString ifNil: ['nil'] ifNotNil: [superclassString asSymbol]. |
|
537 |
category := categoryString. |
|
538 |
name = #CompiledMethod ifTrue: [type := #compiledMethod] ifFalse: [type := typeSymbol]. |
|
539 |
comment := (commentString ? '') asStringWithSqueakLineEndings. |
|
540 |
commentStamp := stampStringOrNil ifNil: [self defaultCommentStamp]. |
|
541 |
variables := OrderedCollection new. |
|
156 | 542 |
self addVariables: ivarArray ofType: MCInstanceVariableDefinition. |
543 |
self addVariables: cvarArray ofType: MCClassVariableDefinition. |
|
544 |
self addVariables: poolArray ofType: MCPoolImportDefinition. |
|
545 |
self addVariables: civarArray ofType: MCClassInstanceVariableDefinition. |
|
214 | 546 |
|
547 |
"Modified: / 12-09-2010 / 17:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
548 |
! |
|
549 |
||
550 |
storeDataOn: aDataStream |
|
551 |
| instVarSize | |
|
552 |
instVarSize := (self hasTraitComposition or: [ self hasClassTraitComposition ]) |
|
553 |
ifTrue: [ self class instSize ] |
|
554 |
ifFalse: [ self class instSize - 2 ]. |
|
555 |
aDataStream |
|
556 |
beginInstance: self class |
|
557 |
size: instVarSize. |
|
558 |
1 to: instVarSize do: [ :index | |
|
559 |
aDataStream nextPut: (self instVarAt: index) ]. |
|
48 | 560 |
! ! |
561 |
||
562 |
!MCClassDefinition methodsFor:'testing'! |
|
563 |
||
564 |
hasClassInstanceVariables |
|
565 |
^ (self selectVariables: #isClassInstanceVariable) isEmpty not |
|
566 |
! |
|
567 |
||
214 | 568 |
hasClassTraitComposition |
569 |
^self classTraitCompositionString ~= '{}' |
|
570 |
! |
|
571 |
||
48 | 572 |
hasComment |
214 | 573 |
^ comment isEmptyOrNil not |
574 |
! |
|
575 |
||
576 |
hasTraitComposition |
|
577 |
^self traitCompositionString ~= '{}' |
|
48 | 578 |
! |
579 |
||
580 |
isClassDefinition |
|
581 |
^ true |
|
582 |
! |
|
583 |
||
584 |
isCodeDefinition |
|
585 |
^ true |
|
586 |
! ! |
|
587 |
||
588 |
!MCClassDefinition methodsFor:'visiting'! |
|
589 |
||
214 | 590 |
= aDefinition |
591 |
^super = aDefinition |
|
592 |
and: [superclassName = aDefinition superclassName |
|
593 |
and: [self traitCompositionString = aDefinition traitCompositionString |
|
594 |
and: [self classTraitCompositionString = aDefinition classTraitCompositionString |
|
595 |
and: [category = aDefinition category |
|
596 |
and: [type = aDefinition type |
|
597 |
and: [variables = aDefinition variables |
|
598 |
and: [comment = aDefinition comment]]]]]]] |
|
599 |
||
600 |
"Modified: / 18-08-2009 / 10:19:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
601 |
! |
|
602 |
||
48 | 603 |
accept: aVisitor |
214 | 604 |
aVisitor visitClassDefinition: self. |
605 |
(self hasClassInstanceVariables or: [self hasClassTraitComposition]) |
|
606 |
ifTrue: [aVisitor visitMetaclassDefinition: self]. |
|
607 |
||
608 |
! |
|
609 |
||
610 |
initializeWithName: nameString |
|
611 |
superclassName: superclassString |
|
612 |
traitComposition: traitCompositionString |
|
613 |
classTraitComposition: classTraitCompositionString |
|
614 |
category: categoryString |
|
615 |
instVarNames: ivarArray |
|
616 |
classVarNames: cvarArray |
|
617 |
poolDictionaryNames: poolArray |
|
618 |
classInstVarNames: civarArray |
|
619 |
type: typeSymbol |
|
620 |
comment: commentString |
|
621 |
commentStamp: stampStringOrNil |
|
622 |
name := nameString asSymbol. |
|
623 |
superclassName := superclassString ifNil: ['nil'] ifNotNil: [superclassString asSymbol]. |
|
624 |
traitComposition := traitCompositionString. |
|
625 |
classTraitComposition := classTraitCompositionString. |
|
626 |
category := categoryString. |
|
627 |
name = #CompiledMethod ifTrue: [type := #compiledMethod] ifFalse: [type := typeSymbol]. |
|
521 | 628 |
comment := commentString isNil ifTrue:[ nil] ifFalse:[ commentString asStringWithSqueakLineEndings]. |
214 | 629 |
commentStamp := stampStringOrNil ifNil: [self defaultCommentStamp]. |
630 |
variables := OrderedCollection new. |
|
631 |
self addVariables: ivarArray ofType: MCInstanceVariableDefinition. |
|
632 |
self addVariables: cvarArray ofType: MCClassVariableDefinition. |
|
633 |
self addVariables: poolArray ofType: MCPoolImportDefinition. |
|
634 |
self addVariables: civarArray ofType: MCClassInstanceVariableDefinition. |
|
635 |
||
636 |
"Modified: / 12-09-2010 / 16:05:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
521 | 637 |
"Modified: / 25-11-2011 / 17:30:38 / cg" |
48 | 638 |
! ! |
639 |
||
640 |
!MCClassDefinition class methodsFor:'documentation'! |
|
641 |
||
642 |
version |
|
934
6a56a913c6b0
Fixed MCClassDefinition>>#createClass: load superclass before creating class.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
897
diff
changeset
|
643 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.16 2014-10-06 23:21:51 vrany Exp $' |
156 | 644 |
! |
645 |
||
646 |
version_CVS |
|
934
6a56a913c6b0
Fixed MCClassDefinition>>#createClass: load superclass before creating class.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
897
diff
changeset
|
647 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.16 2014-10-06 23:21:51 vrany Exp $' |
214 | 648 |
! |
649 |
||
650 |
version_SVN |
|
934
6a56a913c6b0
Fixed MCClassDefinition>>#createClass: load superclass before creating class.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
897
diff
changeset
|
651 |
^ '$Id: MCClassDefinition.st,v 1.16 2014-10-06 23:21:51 vrany Exp $' |
48 | 652 |
! ! |
713 | 653 |