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