author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 12 Aug 2013 02:50:35 +0200 | |
changeset 894 | 0c981690a584 |
parent 876 | 14ab9847bdda |
child 897 | 76481ea7aaba |
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 |
||
848
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
231 |
superclassName:something |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
232 |
superclassName := something. |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
233 |
! |
b86a6f467667
More support Squeak/Pharo interoperability - part 1:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
766
diff
changeset
|
234 |
|
214 | 235 |
traitComposition |
236 |
^traitComposition |
|
237 |
! |
|
238 |
||
239 |
traitCompositionString |
|
240 |
^self traitComposition ifNil: ['{}']. |
|
241 |
! |
|
242 |
||
48 | 243 |
type |
244 |
^ type |
|
245 |
! |
|
246 |
||
247 |
variables |
|
248 |
^ variables |
|
249 |
! ! |
|
250 |
||
251 |
!MCClassDefinition methodsFor:'annotations'! |
|
252 |
||
253 |
printAnnotations: requests on: aStream |
|
254 |
"Add a string for an annotation pane, trying to fulfill the annotation requests. |
|
255 |
These might include anything that |
|
256 |
Preferences defaultAnnotationRequests |
|
257 |
might return. Which includes anything in |
|
258 |
Preferences annotationInfo |
|
259 |
To edit these, use:" |
|
260 |
"Preferences editAnnotations" |
|
261 |
||
262 |
requests do: [ :aRequest | |
|
263 |
aRequest == #requirements ifTrue: [ |
|
264 |
self requirements do: [ :req | aStream nextPutAll: req ] separatedBy: [ aStream space ]] |
|
265 |
] separatedBy: [ aStream space ]. |
|
266 |
! ! |
|
267 |
||
268 |
!MCClassDefinition methodsFor:'comparing'! |
|
269 |
||
270 |
hash |
|
271 |
| hash | |
|
214 | 272 |
hash := String stringHash: name initialHash: 0. |
273 |
hash := String stringHash: superclassName initialHash: hash. |
|
274 |
hash := String stringHash: self traitCompositionString initialHash: hash. |
|
275 |
hash := String stringHash: self classTraitComposition asString initialHash: hash. |
|
276 |
hash := String stringHash: (category ifNil: ['']) initialHash: hash. |
|
277 |
hash := String stringHash: type initialHash: hash. |
|
48 | 278 |
variables do: [ |
279 |
:v | |
|
214 | 280 |
hash := String stringHash: v name initialHash: hash. |
48 | 281 |
]. |
282 |
^ hash |
|
283 |
! |
|
284 |
||
285 |
provisions |
|
286 |
^ Array with: name |
|
287 |
! |
|
288 |
||
289 |
requirements |
|
290 |
^ (Array with: superclassName), self poolDictionaries |
|
291 |
! ! |
|
292 |
||
214 | 293 |
!MCClassDefinition methodsFor:'converting'! |
294 |
||
295 |
asChange |
|
565 | 296 |
|instVarNamesString classVarNamesString classInstVarNamesString poolDictionariesString |
297 |
definitionSelector| |
|
214 | 298 |
|
565 | 299 |
instVarNamesString := self instVarNames asStringWith:' '. |
300 |
classVarNamesString := self classVarNames asStringWith:' '. |
|
301 |
classInstVarNamesString := self classInstVarNames asStringWith:' '. |
|
302 |
poolDictionariesString := self poolDictionaries asStringWith:' '. |
|
303 |
||
304 |
definitionSelector := #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
713 | 305 |
(type notNil and:[type ~~ #normal]) ifTrue:[ |
565 | 306 |
type == #variable ifTrue:[ |
307 |
definitionSelector := #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
308 |
] ifFalse:[ |
|
309 |
type == #bytes ifTrue:[ |
|
310 |
definitionSelector := #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
311 |
] ifFalse:[ |
|
312 |
type == #words ifTrue:[ |
|
313 |
"for Squeak compatibility: that is long-words !!!!!!!!" |
|
314 |
definitionSelector := #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
315 |
] ifFalse:[ |
|
316 |
type == #compiledMethod ifTrue:[ |
|
317 |
definitionSelector := #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'. |
|
318 |
] ifFalse:[ |
|
319 |
self halt:'unhandled class-type'. |
|
320 |
] |
|
321 |
] |
|
322 |
] |
|
323 |
] |
|
324 |
]. |
|
214 | 325 |
^ClassDefinitionChange new |
326 |
mcDefinition: self; |
|
565 | 327 |
definitionSelector: definitionSelector; |
214 | 328 |
className: name; |
329 |
superClassName: superclassName; |
|
565 | 330 |
instanceVariableNames: instVarNamesString ; |
331 |
classVariableNames: classVarNamesString ; |
|
332 |
classInstanceVariableNames: classInstVarNamesString ; |
|
333 |
poolDictionaries: poolDictionariesString ; |
|
214 | 334 |
category: category; |
335 |
yourself |
|
336 |
||
337 |
"Created: / 13-10-2010 / 17:11:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
338 |
"Modified: / 08-11-2010 / 17:56:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
565 | 339 |
"Modified: / 13-06-2012 / 12:57:38 / cg" |
214 | 340 |
! ! |
341 |
||
48 | 342 |
!MCClassDefinition methodsFor:'initializing'! |
343 |
||
344 |
addVariables: aCollection ofType: aClass |
|
345 |
variables addAll: (aCollection collect: [:var | aClass name: var asString]). |
|
346 |
! |
|
347 |
||
348 |
defaultCommentStamp |
|
349 |
^ String new |
|
350 |
||
351 |
"The version below avoids stomping on stamps already in the image |
|
352 |
||
353 |
^ (Smalltalk at: name ifPresent: [:c | c organization commentStamp]) |
|
354 |
ifNil: [''] |
|
355 |
" |
|
214 | 356 |
|
48 | 357 |
! ! |
358 |
||
359 |
!MCClassDefinition methodsFor:'installing'! |
|
360 |
||
361 |
createClass |
|
470 | 362 |
"cg: changed to honor any nameSpace query override" |
363 |
||
364 |
| env superClass class installedSuperclassName| |
|
365 |
||
366 |
env := MCStXNamespaceQuery query ? Smalltalk. |
|
367 |
superClass := env at: superclassName. |
|
368 |
(superClass isNil and:[env ~~ Smalltalk]) ifTrue:[ |
|
369 |
superClass := Smalltalk at: superclassName. |
|
370 |
]. |
|
371 |
||
214 | 372 |
"Create class if not exists" |
470 | 373 |
superClass isNil ifTrue:[ |
374 |
installedSuperclassName := (env == Smalltalk) |
|
375 |
ifTrue:[ superclassName ] |
|
376 |
ifFalse:[ env name ,'::',superclassName]. |
|
377 |
superClass := Class undeclared: installedSuperclassName |
|
378 |
]. |
|
379 |
||
380 |
"/ env := superClass environment. |
|
214 | 381 |
|
382 |
class := (ClassBuilder new) |
|
156 | 383 |
name: name |
470 | 384 |
inEnvironment: env |
156 | 385 |
subclassOf: superClass |
386 |
type: type |
|
387 |
instanceVariableNames: self instanceVariablesString |
|
388 |
classVariableNames: self classVariablesString |
|
389 |
poolDictionaries: self sharedPoolsString |
|
390 |
category: category. |
|
470 | 391 |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
392 |
self installedClassName:class name. |
470 | 393 |
|
214 | 394 |
self traitComposition ifNotNil: [ |
395 |
class setTraitComposition: (Compiler |
|
396 |
evaluate: self traitComposition) asTraitComposition ]. |
|
397 |
self classTraitComposition ifNotNil: [ |
|
398 |
class class setTraitComposition: (Compiler |
|
399 |
evaluate: self classTraitComposition) asTraitComposition ]. |
|
400 |
^class. |
|
156 | 401 |
|
214 | 402 |
"Modified: / 09-11-2010 / 08:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
470 | 403 |
"Modified (comment): / 07-09-2011 / 13:32:38 / cg" |
48 | 404 |
! |
405 |
||
406 |
load |
|
214 | 407 |
| class | |
408 |
||
470 | 409 |
(class := self createClass) notNil ifTrue:[ |
410 |
class class instanceVariableNames: self classInstanceVariablesString. |
|
411 |
self hasComment ifTrue: [class classComment: comment stamp: commentStamp] |
|
412 |
]. |
|
214 | 413 |
class package: MCStXPackageQuery query. |
414 |
||
415 |
"Modified: / 14-09-2010 / 22:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
470 | 416 |
"Modified: / 07-09-2011 / 13:01:53 / cg" |
214 | 417 |
! |
418 |
||
419 |
stringForSortedVariablesOfType: aSymbol |
|
420 |
^ String streamContents: |
|
421 |
[:stream | |
|
422 |
(self selectVariables: aSymbol) asSortedCollection |
|
423 |
do: [:ea | stream nextPutAll: ea] |
|
424 |
separatedBy: [stream space]] |
|
48 | 425 |
! |
426 |
||
427 |
stringForVariablesOfType: aSymbol |
|
428 |
^ String streamContents: |
|
429 |
[:stream | |
|
430 |
(self selectVariables: aSymbol) |
|
431 |
do: [:ea | stream nextPutAll: ea] |
|
432 |
separatedBy: [stream space]] |
|
433 |
! |
|
434 |
||
435 |
unload |
|
436 |
Smalltalk removeClassNamed: name |
|
437 |
! ! |
|
438 |
||
439 |
!MCClassDefinition methodsFor:'printing'! |
|
440 |
||
441 |
classInstanceVariablesString |
|
442 |
^ self stringForVariablesOfType: #isClassInstanceVariable |
|
443 |
! |
|
444 |
||
445 |
classVariablesString |
|
214 | 446 |
^ self stringForSortedVariablesOfType: #isClassVariable |
48 | 447 |
! |
448 |
||
449 |
definitionString |
|
450 |
^ String streamContents: [:stream | self printDefinitionOn: stream] |
|
451 |
! |
|
452 |
||
453 |
instanceVariablesString |
|
454 |
^ self stringForVariablesOfType: #isInstanceVariable |
|
455 |
! |
|
456 |
||
457 |
kindOfSubclass |
|
214 | 458 |
type = #normal ifTrue: [^ ' subclass:']. |
459 |
type = #words ifTrue: [^ ' variableWordSubclass:']. |
|
460 |
type = #variable ifTrue: [^ ' variableSubclass:']. |
|
461 |
type = #bytes ifTrue: [^ ' variableByteSubclass:']. |
|
462 |
type = #weak ifTrue: [^ ' weakSubclass:' ]. |
|
463 |
type = #compiledMethod ifTrue: [^ ' variableByteSubclass:' ]. |
|
464 |
self error: 'Unrecognized class type' |
|
465 |
||
466 |
"Modified: / 11-09-2010 / 18:13:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 | 467 |
! |
468 |
||
469 |
printDefinitionOn: stream |
|
766 | 470 |
|clsName| |
471 |
||
214 | 472 |
stream |
473 |
nextPutAll: self superclassName; |
|
766 | 474 |
nextPutAll: self kindOfSubclass. |
475 |
((clsName := self className) includes:$_) ifTrue:[ |
|
476 |
stream |
|
477 |
nextPutAll: '#''' ; |
|
214 | 478 |
nextPutAll: self className; |
766 | 479 |
nextPutAll: '''' . |
480 |
] ifFalse:[ |
|
481 |
stream |
|
482 |
nextPut: $#; |
|
483 |
nextPutAll: self className. |
|
484 |
]. |
|
485 |
stream |
|
214 | 486 |
cr; tab. |
487 |
self hasTraitComposition ifTrue: [ |
|
488 |
stream |
|
489 |
nextPutAll: 'uses: '; |
|
490 |
nextPutAll: self traitCompositionString; |
|
491 |
cr; tab ]. |
|
492 |
stream |
|
493 |
nextPutAll: 'instanceVariableNames:'; |
|
494 |
store: self instanceVariablesString; |
|
495 |
cr; tab; |
|
496 |
nextPutAll: 'classVariableNames:'; |
|
497 |
store: self classVariablesString; |
|
498 |
cr; tab; |
|
499 |
nextPutAll: 'poolDictionaries:'; |
|
500 |
store: self sharedPoolsString; |
|
501 |
cr; tab; |
|
502 |
nextPutAll: 'category:'; |
|
503 |
store: self category asString |
|
504 |
||
505 |
"Modified: / 11-09-2010 / 18:11:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 | 506 |
! |
507 |
||
508 |
sharedPoolsString |
|
214 | 509 |
^ self stringForSortedVariablesOfType: #isPoolImport |
48 | 510 |
! |
511 |
||
512 |
source |
|
513 |
^ self definitionString |
|
514 |
! |
|
515 |
||
516 |
summary |
|
517 |
^ name |
|
518 |
! ! |
|
519 |
||
520 |
!MCClassDefinition methodsFor:'serializing'! |
|
521 |
||
522 |
initializeWithName: nameString |
|
523 |
superclassName: superclassString |
|
524 |
category: categoryString |
|
525 |
instVarNames: ivarArray |
|
526 |
classVarNames: cvarArray |
|
527 |
poolDictionaryNames: poolArray |
|
528 |
classInstVarNames: civarArray |
|
529 |
type: typeSymbol |
|
530 |
comment: commentString |
|
531 |
commentStamp: stampStringOrNil |
|
214 | 532 |
name := nameString asSymbol. |
533 |
superclassName := superclassString ifNil: ['nil'] ifNotNil: [superclassString asSymbol]. |
|
534 |
category := categoryString. |
|
535 |
name = #CompiledMethod ifTrue: [type := #compiledMethod] ifFalse: [type := typeSymbol]. |
|
536 |
comment := (commentString ? '') asStringWithSqueakLineEndings. |
|
537 |
commentStamp := stampStringOrNil ifNil: [self defaultCommentStamp]. |
|
538 |
variables := OrderedCollection new. |
|
156 | 539 |
self addVariables: ivarArray ofType: MCInstanceVariableDefinition. |
540 |
self addVariables: cvarArray ofType: MCClassVariableDefinition. |
|
541 |
self addVariables: poolArray ofType: MCPoolImportDefinition. |
|
542 |
self addVariables: civarArray ofType: MCClassInstanceVariableDefinition. |
|
214 | 543 |
|
544 |
"Modified: / 12-09-2010 / 17:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
545 |
! |
|
546 |
||
547 |
storeDataOn: aDataStream |
|
548 |
| instVarSize | |
|
549 |
instVarSize := (self hasTraitComposition or: [ self hasClassTraitComposition ]) |
|
550 |
ifTrue: [ self class instSize ] |
|
551 |
ifFalse: [ self class instSize - 2 ]. |
|
552 |
aDataStream |
|
553 |
beginInstance: self class |
|
554 |
size: instVarSize. |
|
555 |
1 to: instVarSize do: [ :index | |
|
556 |
aDataStream nextPut: (self instVarAt: index) ]. |
|
48 | 557 |
! ! |
558 |
||
559 |
!MCClassDefinition methodsFor:'testing'! |
|
560 |
||
561 |
hasClassInstanceVariables |
|
562 |
^ (self selectVariables: #isClassInstanceVariable) isEmpty not |
|
563 |
! |
|
564 |
||
214 | 565 |
hasClassTraitComposition |
566 |
^self classTraitCompositionString ~= '{}' |
|
567 |
! |
|
568 |
||
48 | 569 |
hasComment |
214 | 570 |
^ comment isEmptyOrNil not |
571 |
! |
|
572 |
||
573 |
hasTraitComposition |
|
574 |
^self traitCompositionString ~= '{}' |
|
48 | 575 |
! |
576 |
||
577 |
isClassDefinition |
|
578 |
^ true |
|
579 |
! |
|
580 |
||
581 |
isCodeDefinition |
|
582 |
^ true |
|
583 |
! ! |
|
584 |
||
585 |
!MCClassDefinition methodsFor:'visiting'! |
|
586 |
||
214 | 587 |
= aDefinition |
588 |
^super = aDefinition |
|
589 |
and: [superclassName = aDefinition superclassName |
|
590 |
and: [self traitCompositionString = aDefinition traitCompositionString |
|
591 |
and: [self classTraitCompositionString = aDefinition classTraitCompositionString |
|
592 |
and: [category = aDefinition category |
|
593 |
and: [type = aDefinition type |
|
594 |
and: [variables = aDefinition variables |
|
595 |
and: [comment = aDefinition comment]]]]]]] |
|
596 |
||
597 |
"Modified: / 18-08-2009 / 10:19:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
598 |
! |
|
599 |
||
48 | 600 |
accept: aVisitor |
214 | 601 |
aVisitor visitClassDefinition: self. |
602 |
(self hasClassInstanceVariables or: [self hasClassTraitComposition]) |
|
603 |
ifTrue: [aVisitor visitMetaclassDefinition: self]. |
|
604 |
||
605 |
! |
|
606 |
||
607 |
initializeWithName: nameString |
|
608 |
superclassName: superclassString |
|
609 |
traitComposition: traitCompositionString |
|
610 |
classTraitComposition: classTraitCompositionString |
|
611 |
category: categoryString |
|
612 |
instVarNames: ivarArray |
|
613 |
classVarNames: cvarArray |
|
614 |
poolDictionaryNames: poolArray |
|
615 |
classInstVarNames: civarArray |
|
616 |
type: typeSymbol |
|
617 |
comment: commentString |
|
618 |
commentStamp: stampStringOrNil |
|
619 |
name := nameString asSymbol. |
|
620 |
superclassName := superclassString ifNil: ['nil'] ifNotNil: [superclassString asSymbol]. |
|
621 |
traitComposition := traitCompositionString. |
|
622 |
classTraitComposition := classTraitCompositionString. |
|
623 |
category := categoryString. |
|
624 |
name = #CompiledMethod ifTrue: [type := #compiledMethod] ifFalse: [type := typeSymbol]. |
|
521 | 625 |
comment := commentString isNil ifTrue:[ nil] ifFalse:[ commentString asStringWithSqueakLineEndings]. |
214 | 626 |
commentStamp := stampStringOrNil ifNil: [self defaultCommentStamp]. |
627 |
variables := OrderedCollection new. |
|
628 |
self addVariables: ivarArray ofType: MCInstanceVariableDefinition. |
|
629 |
self addVariables: cvarArray ofType: MCClassVariableDefinition. |
|
630 |
self addVariables: poolArray ofType: MCPoolImportDefinition. |
|
631 |
self addVariables: civarArray ofType: MCClassInstanceVariableDefinition. |
|
632 |
||
633 |
"Modified: / 12-09-2010 / 16:05:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
521 | 634 |
"Modified: / 25-11-2011 / 17:30:38 / cg" |
48 | 635 |
! ! |
636 |
||
637 |
!MCClassDefinition class methodsFor:'documentation'! |
|
638 |
||
639 |
version |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
640 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.14 2013-08-12 00:50:35 vrany Exp $' |
156 | 641 |
! |
642 |
||
643 |
version_CVS |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
644 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.14 2013-08-12 00:50:35 vrany Exp $' |
214 | 645 |
! |
646 |
||
647 |
version_SVN |
|
894
0c981690a584
Removed instvar installedClassName and make it an object attribute.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
876
diff
changeset
|
648 |
^ '$Id: MCClassDefinition.st,v 1.14 2013-08-12 00:50:35 vrany Exp $' |
48 | 649 |
! ! |
713 | 650 |