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