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
|
|
20 |
(MCDoItParser forDoit: aString) ifNotNilDo:
|
|
21 |
[:parser |
|
|
22 |
parser addDefinitionsTo: definitions]
|
|
23 |
!
|
|
24 |
|
|
25 |
categoryFromDoIt: aString
|
|
26 |
| tokens |
|
|
27 |
tokens _ Scanner new scanTokens: aString.
|
|
28 |
tokens size = 3 ifFalse: [self error: 'Unrecognized category definition'].
|
|
29 |
^ tokens at: 3
|
|
30 |
!
|
|
31 |
|
|
32 |
classDefinitionFrom: aPseudoClass
|
|
33 |
| tokens |
|
|
34 |
tokens _ Scanner new scanTokens: aPseudoClass definition.
|
|
35 |
tokens size = 11 ifFalse: [self error: 'Unrecognized class definition'].
|
|
36 |
^ MCClassDefinition
|
|
37 |
name: (tokens at: 3)
|
|
38 |
superclassName: (tokens at: 1)
|
|
39 |
category: (tokens at: 11)
|
|
40 |
instVarNames: ((tokens at: 5) findTokens: ' ')
|
|
41 |
classVarNames: ((tokens at: 7) findTokens: ' ')
|
|
42 |
poolDictionaryNames: ((tokens at: 9) findTokens: ' ')
|
|
43 |
classInstVarNames: (self classInstVarNamesFor: aPseudoClass)
|
|
44 |
type: (self typeOfSubclass: (tokens at: 2))
|
|
45 |
comment: (self commentFor: aPseudoClass)
|
|
46 |
commentStamp: (self commentStampFor: aPseudoClass)
|
|
47 |
!
|
|
48 |
|
|
49 |
classInstVarNamesFor: aPseudoClass
|
|
50 |
| tokens |
|
|
51 |
aPseudoClass metaClass hasDefinition ifFalse: [^ #()].
|
|
52 |
|
|
53 |
tokens _ Scanner new scanTokens: aPseudoClass metaClass definition.
|
|
54 |
tokens size = 4 ifFalse: [self error: 'Unrecognized metaclass definition'].
|
|
55 |
^ tokens last findTokens: ' '
|
|
56 |
!
|
|
57 |
|
|
58 |
commentFor: aPseudoClass
|
|
59 |
| comment |
|
|
60 |
comment _ aPseudoClass organization classComment.
|
|
61 |
^ comment asString = ''
|
|
62 |
ifTrue: [comment]
|
|
63 |
ifFalse: [comment string]
|
|
64 |
!
|
|
65 |
|
|
66 |
commentStampFor: aPseudoClass
|
|
67 |
| comment |
|
|
68 |
comment _ aPseudoClass organization classComment.
|
|
69 |
^ [comment stamp] on: MessageNotUnderstood do: [nil]
|
|
70 |
!
|
|
71 |
|
|
72 |
methodDefinitionsFor: aPseudoClass
|
|
73 |
^ aPseudoClass selectors collect:
|
|
74 |
[:ea |
|
|
75 |
MCMethodDefinition
|
|
76 |
className: aPseudoClass name
|
|
77 |
classIsMeta: aPseudoClass isMeta
|
|
78 |
selector: ea
|
|
79 |
category: (aPseudoClass organization categoryOfElement: ea)
|
|
80 |
timeStamp: (aPseudoClass stampAt: ea)
|
|
81 |
source: (aPseudoClass sourceCodeAt: ea)]
|
|
82 |
!
|
|
83 |
|
|
84 |
systemOrganizationFromRecords: changeRecords
|
|
85 |
| categories |
|
|
86 |
categories _ changeRecords
|
|
87 |
select: [:ea | 'SystemOrganization*' match: ea string]
|
|
88 |
thenCollect: [:ea | (self categoryFromDoIt: ea string)].
|
|
89 |
^ categories isEmpty ifFalse: [MCOrganizationDefinition categories: categories asArray]
|
|
90 |
!
|
|
91 |
|
|
92 |
typeOfSubclass: aSymbol
|
|
93 |
#(
|
|
94 |
(subclass: normal)
|
|
95 |
(variableSubclass: variable)
|
|
96 |
(variableByteSubclass: bytes)
|
|
97 |
(variableWordSubclass: words)
|
|
98 |
(weakSubclass: weak)
|
|
99 |
) do: [:ea | ea first = aSymbol ifTrue: [^ ea second]].
|
|
100 |
self error: 'Unrecognized class definition'
|
|
101 |
! !
|
|
102 |
|
|
103 |
!MCStReader methodsFor:'evaluating'!
|
|
104 |
|
|
105 |
loadDefinitions
|
|
106 |
| filePackage |
|
|
107 |
filePackage _
|
|
108 |
FilePackage new
|
|
109 |
fullName: 'ReadStream';
|
|
110 |
fileInFrom: self readStream.
|
|
111 |
definitions _ OrderedCollection new.
|
|
112 |
filePackage classes do:
|
|
113 |
[:pseudoClass |
|
|
114 |
pseudoClass hasDefinition
|
|
115 |
ifTrue: [definitions add:
|
|
116 |
(self classDefinitionFrom: pseudoClass)].
|
|
117 |
definitions addAll: (self methodDefinitionsFor: pseudoClass).
|
|
118 |
definitions addAll: (self methodDefinitionsFor: pseudoClass metaClass)].
|
|
119 |
filePackage doIts do:
|
|
120 |
[:ea |
|
|
121 |
self addDefinitionsFromDoit: ea string].
|
|
122 |
|
|
123 |
!
|
|
124 |
|
|
125 |
readStream
|
|
126 |
^ ('!!!!
|
|
127 |
|
|
128 |
', stream contents) readStream
|
|
129 |
! !
|
|
130 |
|
|
131 |
!MCStReader class methodsFor:'documentation'!
|
|
132 |
|
|
133 |
version
|
|
134 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStReader.st,v 1.1 2006-11-22 13:06:33 cg Exp $'
|
|
135 |
! !
|