1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
3 |
All Rights Reserved
|
1
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Object subclass:#ClassCategoryReader
|
216
|
14 |
instanceVariableNames:'myClass myCategory privacy ignore primSpec'
|
425
|
15 |
classVariableNames:'KeepSource'
|
1
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
ClassCategoryReader comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
22 |
All Rights Reserved
|
92
|
23 |
|
425
|
24 |
$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.19 1995-09-09 18:32:08 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!ClassCategoryReader class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
32 |
All Rights Reserved
|
1
|
33 |
|
88
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
425
|
45 |
$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.19 1995-09-09 18:32:08 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
a helper class for fileIn - keeps track of class and category to filein for.
|
|
52 |
Instances of this are created by the #methodsFor: methods in Class, to
|
|
53 |
read the next chunk(s) from a stream.
|
|
54 |
"
|
|
55 |
! !
|
1
|
56 |
|
425
|
57 |
!ClassCategoryReader class methodsFor:'initialization'!
|
|
58 |
|
|
59 |
initialize
|
|
60 |
KeepSource := true
|
|
61 |
! !
|
|
62 |
|
|
63 |
!ClassCategoryReader class methodsFor:'defaults'!
|
|
64 |
|
|
65 |
keepSource:aBoolean
|
|
66 |
KeepSource := aBoolean
|
|
67 |
|
|
68 |
"Created: 9.9.1995 / 15:22:26 / claus"
|
|
69 |
!
|
|
70 |
|
|
71 |
keepSource
|
|
72 |
^ KeepSource
|
|
73 |
|
|
74 |
"Created: 9.9.1995 / 15:22:27 / claus"
|
|
75 |
! !
|
|
76 |
|
1
|
77 |
!ClassCategoryReader class methodsFor:'instance creation'!
|
|
78 |
|
|
79 |
class:aClass category:aCategory
|
|
80 |
"return a new ClassCategoryReader to read methods for aClass with
|
|
81 |
methodCategory aCategory"
|
|
82 |
|
|
83 |
^ self new class:aClass category:aCategory
|
167
|
84 |
!
|
|
85 |
|
216
|
86 |
class:aClass primitiveSpec:which
|
|
87 |
"return a ClassCategoryReader to read a primitiveSpec chunk"
|
|
88 |
|
|
89 |
^ self new class:aClass primitiveSpec:which
|
|
90 |
!
|
|
91 |
|
167
|
92 |
skippingChunks
|
|
93 |
"return a class categoryReader which skips chunks up to the next empty one"
|
|
94 |
|
|
95 |
^ self new ignoreMethods
|
1
|
96 |
! !
|
|
97 |
|
|
98 |
!ClassCategoryReader methodsFor:'private'!
|
|
99 |
|
|
100 |
class:aClass category:aCategory
|
|
101 |
"set the instance variables"
|
|
102 |
|
|
103 |
myClass := aClass.
|
68
|
104 |
myCategory := aCategory.
|
216
|
105 |
ignore := false
|
|
106 |
!
|
|
107 |
|
|
108 |
class:aClass primitiveSpec:which
|
|
109 |
"set the instance variables"
|
|
110 |
|
|
111 |
myClass := aClass.
|
|
112 |
primSpec := which.
|
135
|
113 |
ignore := false
|
68
|
114 |
! !
|
|
115 |
|
|
116 |
!ClassCategoryReader methodsFor:'special'!
|
|
117 |
|
|
118 |
privateProtocol
|
167
|
119 |
privacy := #private
|
|
120 |
!
|
|
121 |
|
|
122 |
protectedProtocol
|
|
123 |
privacy := #protected
|
135
|
124 |
!
|
|
125 |
|
|
126 |
ignoreMethods
|
|
127 |
ignore := true
|
1
|
128 |
! !
|
|
129 |
|
|
130 |
!ClassCategoryReader methodsFor:'fileIn'!
|
|
131 |
|
328
|
132 |
fileInFrom:aStream notifying:requestor passChunk:passChunk
|
1
|
133 |
"read method-chunks from the input stream, aStream; compile them
|
|
134 |
and add the methods to the class defined by the class-instance var;
|
12
|
135 |
errors and notifications are passed to requestor"
|
1
|
136 |
|
425
|
137 |
|aString done method compiler makeSourceRef sourceFile pos|
|
1
|
138 |
|
328
|
139 |
Smalltalk silentLoading ifFalse:[
|
|
140 |
Transcript show:' '; show:myClass name; show:' -> '; showCr:myCategory.
|
|
141 |
].
|
|
142 |
|
425
|
143 |
makeSourceRef := false.
|
|
144 |
KeepSource == false ifTrue:[
|
|
145 |
aStream isFileStream ifTrue:[
|
|
146 |
sourceFile := aStream pathName.
|
|
147 |
sourceFile printNL.
|
|
148 |
makeSourceRef := true.
|
|
149 |
]
|
|
150 |
].
|
|
151 |
|
1
|
152 |
done := false.
|
|
153 |
[done] whileFalse:[
|
167
|
154 |
done := aStream atEnd.
|
|
155 |
done ifFalse:[
|
425
|
156 |
makeSourceRef ifTrue:[
|
|
157 |
pos := aStream position
|
|
158 |
].
|
167
|
159 |
aString := aStream nextChunk.
|
|
160 |
done := aString isNil or:[aString isEmpty].
|
|
161 |
done ifFalse:[
|
216
|
162 |
primSpec notNil ifTrue:[
|
|
163 |
myClass perform:primSpec with:aString.
|
|
164 |
"
|
|
165 |
ignore rest
|
|
166 |
"
|
|
167 |
ignore := true
|
|
168 |
].
|
167
|
169 |
ignore ifFalse:[
|
328
|
170 |
passChunk ifTrue:[
|
|
171 |
requestor source:aString
|
|
172 |
].
|
|
173 |
|
350
|
174 |
compiler := myClass compilerClass.
|
|
175 |
|
|
176 |
"/
|
370
|
177 |
"/ kludge - for now;
|
|
178 |
"/ have to make ST/X's compiler protocol be compatible to ST-80's
|
425
|
179 |
"/ for other compilers to work ... (TGEN for example)
|
350
|
180 |
"/
|
|
181 |
(compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
|
|
182 |
ifTrue:[
|
370
|
183 |
"/ ST/X's compiler
|
350
|
184 |
method :=compiler
|
|
185 |
compile:aString
|
|
186 |
forClass:myClass
|
|
187 |
inCategory:myCategory
|
|
188 |
notifying:requestor
|
|
189 |
install:true
|
|
190 |
skipIfSame:true.
|
|
191 |
|
425
|
192 |
makeSourceRef ifTrue:[
|
|
193 |
method source = aString ifTrue:[
|
|
194 |
method sourceFilename:sourceFile position:pos
|
|
195 |
]
|
|
196 |
]
|
350
|
197 |
] ifFalse:[
|
370
|
198 |
"/ some generated (TGEN) compiler
|
350
|
199 |
method := compiler new
|
|
200 |
compile:aString
|
|
201 |
in:myClass
|
|
202 |
notifying:requestor
|
|
203 |
ifFail:nil
|
|
204 |
].
|
328
|
205 |
|
167
|
206 |
privacy notNil ifTrue:[
|
|
207 |
privacy == #private ifTrue:[
|
|
208 |
method setToPrivate
|
|
209 |
] ifFalse:[
|
|
210 |
privacy == #protected ifTrue:[
|
|
211 |
method setToProtected
|
|
212 |
]
|
|
213 |
]
|
|
214 |
]
|
|
215 |
]
|
|
216 |
]
|
|
217 |
]
|
1
|
218 |
]
|
425
|
219 |
|
|
220 |
"Modified: 9.9.1995 / 15:29:08 / claus"
|
1
|
221 |
!
|
|
222 |
|
|
223 |
fileInFrom:aStream
|
|
224 |
"read method-chunks from the input stream, aStream; compile them
|
|
225 |
and add the methods to the class defined by the class-instance var"
|
|
226 |
|
328
|
227 |
self fileInFrom:aStream notifying:nil passChunk:false
|
1
|
228 |
! !
|