41
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCSnapshotReader subclass:#MCStReader
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Chunk Format'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCStReader class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
extension
|
|
14 |
^ 'st'
|
|
15 |
! !
|
|
16 |
|
|
17 |
!MCStReader methodsFor:'as yet unclassified'!
|
|
18 |
|
|
19 |
addDefinitionsFromDoit: aString
|
209
|
20 |
| parser |
|
|
21 |
(parser := MCDoItParser forDoit: aString) ifNotNil:
|
|
22 |
[
|
41
|
23 |
parser addDefinitionsTo: definitions]
|
|
24 |
!
|
|
25 |
|
|
26 |
categoryFromDoIt: aString
|
|
27 |
| tokens |
|
209
|
28 |
tokens := Scanner new scanTokens: aString.
|
41
|
29 |
tokens size = 3 ifFalse: [self error: 'Unrecognized category definition'].
|
|
30 |
^ tokens at: 3
|
|
31 |
!
|
|
32 |
|
|
33 |
classDefinitionFrom: aPseudoClass
|
209
|
34 |
| tokens traitCompositionString lastIndex classTraitCompositionString |
|
|
35 |
tokens := Scanner new scanTokens: aPseudoClass definition.
|
|
36 |
traitCompositionString := ((ReadStream on: aPseudoClass definition)
|
|
37 |
match: 'uses:';
|
|
38 |
upToAll: 'instanceVariableNames:') withBlanksTrimmed.
|
|
39 |
classTraitCompositionString := ((ReadStream on: aPseudoClass metaClass definition asString)
|
|
40 |
match: 'uses:';
|
|
41 |
upToAll: 'instanceVariableNames:') withBlanksTrimmed.
|
|
42 |
traitCompositionString isEmpty ifTrue: [traitCompositionString := '{}'].
|
|
43 |
classTraitCompositionString isEmpty ifTrue: [classTraitCompositionString := '{}'].
|
|
44 |
lastIndex := tokens size.
|
41
|
45 |
^ MCClassDefinition
|
|
46 |
name: (tokens at: 3)
|
|
47 |
superclassName: (tokens at: 1)
|
209
|
48 |
traitComposition: traitCompositionString
|
|
49 |
classTraitComposition: classTraitCompositionString
|
|
50 |
category: (tokens at: lastIndex)
|
|
51 |
instVarNames: ((tokens at: lastIndex - 6) findTokens: ' ')
|
|
52 |
classVarNames: ((tokens at: lastIndex - 4) findTokens: ' ')
|
|
53 |
poolDictionaryNames: ((tokens at: lastIndex - 2) findTokens: ' ')
|
41
|
54 |
classInstVarNames: (self classInstVarNamesFor: aPseudoClass)
|
|
55 |
type: (self typeOfSubclass: (tokens at: 2))
|
|
56 |
comment: (self commentFor: aPseudoClass)
|
|
57 |
commentStamp: (self commentStampFor: aPseudoClass)
|
|
58 |
!
|
|
59 |
|
|
60 |
classInstVarNamesFor: aPseudoClass
|
|
61 |
| tokens |
|
209
|
62 |
|
|
63 |
self flag: #traits.
|
41
|
64 |
aPseudoClass metaClass hasDefinition ifFalse: [^ #()].
|
209
|
65 |
tokens := Scanner new scanTokens: aPseudoClass metaClass definition.
|
|
66 |
"tokens size = 4 ifFalse: [self error: 'Unrecognized metaclass definition']."
|
41
|
67 |
^ tokens last findTokens: ' '
|
|
68 |
!
|
|
69 |
|
|
70 |
commentFor: aPseudoClass
|
|
71 |
| comment |
|
209
|
72 |
comment := aPseudoClass organization classComment.
|
41
|
73 |
^ comment asString = ''
|
|
74 |
ifTrue: [comment]
|
|
75 |
ifFalse: [comment string]
|
|
76 |
!
|
|
77 |
|
|
78 |
commentStampFor: aPseudoClass
|
|
79 |
| comment |
|
209
|
80 |
comment := aPseudoClass organization classComment.
|
41
|
81 |
^ [comment stamp] on: MessageNotUnderstood do: [nil]
|
|
82 |
!
|
|
83 |
|
|
84 |
methodDefinitionsFor: aPseudoClass
|
|
85 |
^ aPseudoClass selectors collect:
|
|
86 |
[:ea |
|
|
87 |
MCMethodDefinition
|
|
88 |
className: aPseudoClass name
|
|
89 |
classIsMeta: aPseudoClass isMeta
|
|
90 |
selector: ea
|
|
91 |
category: (aPseudoClass organization categoryOfElement: ea)
|
|
92 |
timeStamp: (aPseudoClass stampAt: ea)
|
|
93 |
source: (aPseudoClass sourceCodeAt: ea)]
|
|
94 |
!
|
|
95 |
|
|
96 |
systemOrganizationFromRecords: changeRecords
|
|
97 |
| categories |
|
209
|
98 |
categories := changeRecords
|
41
|
99 |
select: [:ea | 'SystemOrganization*' match: ea string]
|
|
100 |
thenCollect: [:ea | (self categoryFromDoIt: ea string)].
|
|
101 |
^ categories isEmpty ifFalse: [MCOrganizationDefinition categories: categories asArray]
|
|
102 |
!
|
|
103 |
|
|
104 |
typeOfSubclass: aSymbol
|
|
105 |
#(
|
|
106 |
(subclass: normal)
|
|
107 |
(variableSubclass: variable)
|
|
108 |
(variableByteSubclass: bytes)
|
|
109 |
(variableWordSubclass: words)
|
|
110 |
(weakSubclass: weak)
|
|
111 |
) do: [:ea | ea first = aSymbol ifTrue: [^ ea second]].
|
|
112 |
self error: 'Unrecognized class definition'
|
|
113 |
! !
|
|
114 |
|
|
115 |
!MCStReader methodsFor:'evaluating'!
|
|
116 |
|
|
117 |
loadDefinitions
|
|
118 |
| filePackage |
|
209
|
119 |
filePackage :=
|
41
|
120 |
FilePackage new
|
|
121 |
fullName: 'ReadStream';
|
|
122 |
fileInFrom: self readStream.
|
209
|
123 |
definitions := OrderedCollection new.
|
41
|
124 |
filePackage classes do:
|
|
125 |
[:pseudoClass |
|
|
126 |
pseudoClass hasDefinition
|
|
127 |
ifTrue: [definitions add:
|
|
128 |
(self classDefinitionFrom: pseudoClass)].
|
|
129 |
definitions addAll: (self methodDefinitionsFor: pseudoClass).
|
|
130 |
definitions addAll: (self methodDefinitionsFor: pseudoClass metaClass)].
|
|
131 |
filePackage doIts do:
|
|
132 |
[:ea |
|
|
133 |
self addDefinitionsFromDoit: ea string].
|
|
134 |
|
|
135 |
!
|
|
136 |
|
|
137 |
readStream
|
|
138 |
^ ('!!!!
|
|
139 |
|
|
140 |
', stream contents) readStream
|
|
141 |
! !
|
|
142 |
|
|
143 |
!MCStReader class methodsFor:'documentation'!
|
|
144 |
|
|
145 |
version
|
209
|
146 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStReader.st,v 1.2 2011-08-20 11:43:28 cg Exp $'
|
|
147 |
!
|
|
148 |
|
|
149 |
version_CVS
|
|
150 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStReader.st,v 1.2 2011-08-20 11:43:28 cg Exp $'
|
|
151 |
!
|
|
152 |
|
|
153 |
version_SVN
|
|
154 |
^ '§Id: MCStReader.st 17 2010-10-13 12:07:52Z vranyj1 §'
|
41
|
155 |
! !
|