author | Claus Gittinger <cg@exept.de> |
Thu, 07 Dec 1995 22:32:39 +0100 | |
changeset 699 | 12f456343eea |
parent 528 | a083413dfbe8 |
child 784 | 0811a8196743 |
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 |
|
699 | 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:[ |
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
102 |
Smalltalk silentLoading ifFalse:[ |
451 | 103 |
myClass isNil ifTrue:[ |
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
104 |
nm := '** UndefinedClass **' |
451 | 105 |
] ifFalse:[ |
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
106 |
nm := myClass name |
451 | 107 |
]. |
108 |
Transcript show:' '; show:nm; show:' -> '; showCr:myCategory. |
|
450 | 109 |
]. |
328 | 110 |
|
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
111 |
makeSourceRef := false. |
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
112 |
KeepSource == false ifTrue:[ |
451 | 113 |
aStream isFileStream ifTrue:[ |
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
114 |
sourceFile := aStream pathName. |
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
115 |
sourceFile printNL. |
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
116 |
makeSourceRef := true. |
451 | 117 |
] |
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
118 |
]. |
425 | 119 |
]. |
120 |
||
1 | 121 |
done := false. |
122 |
[done] whileFalse:[ |
|
167 | 123 |
done := aStream atEnd. |
124 |
done ifFalse:[ |
|
425 | 125 |
makeSourceRef ifTrue:[ |
126 |
pos := aStream position |
|
127 |
]. |
|
167 | 128 |
aString := aStream nextChunk. |
129 |
done := aString isNil or:[aString isEmpty]. |
|
130 |
done ifFalse:[ |
|
216 | 131 |
primSpec notNil ifTrue:[ |
132 |
myClass perform:primSpec with:aString. |
|
133 |
" |
|
134 |
ignore rest |
|
135 |
" |
|
136 |
ignore := true |
|
137 |
]. |
|
167 | 138 |
ignore ifFalse:[ |
328 | 139 |
passChunk ifTrue:[ |
140 |
requestor source:aString |
|
141 |
]. |
|
142 |
||
350 | 143 |
compiler := myClass compilerClass. |
144 |
||
145 |
"/ |
|
370 | 146 |
"/ kludge - for now; |
147 |
"/ have to make ST/X's compiler protocol be compatible to ST-80's |
|
425 | 148 |
"/ for other compilers to work ... (TGEN for example) |
350 | 149 |
"/ |
150 |
(compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:) |
|
151 |
ifTrue:[ |
|
370 | 152 |
"/ ST/X's compiler |
350 | 153 |
method :=compiler |
154 |
compile:aString |
|
155 |
forClass:myClass |
|
156 |
inCategory:myCategory |
|
157 |
notifying:requestor |
|
158 |
install:true |
|
159 |
skipIfSame:true. |
|
160 |
||
425 | 161 |
makeSourceRef ifTrue:[ |
162 |
method source = aString ifTrue:[ |
|
163 |
method sourceFilename:sourceFile position:pos |
|
164 |
] |
|
165 |
] |
|
350 | 166 |
] ifFalse:[ |
370 | 167 |
"/ some generated (TGEN) compiler |
350 | 168 |
method := compiler new |
169 |
compile:aString |
|
170 |
in:myClass |
|
171 |
notifying:requestor |
|
172 |
ifFail:nil |
|
173 |
]. |
|
328 | 174 |
|
167 | 175 |
privacy notNil ifTrue:[ |
176 |
privacy == #private ifTrue:[ |
|
177 |
method setToPrivate |
|
178 |
] ifFalse:[ |
|
179 |
privacy == #protected ifTrue:[ |
|
180 |
method setToProtected |
|
181 |
] |
|
182 |
] |
|
183 |
] |
|
184 |
] |
|
185 |
] |
|
186 |
] |
|
1 | 187 |
] |
425 | 188 |
|
189 |
"Modified: 9.9.1995 / 15:29:08 / claus" |
|
699 | 190 |
! ! |
191 |
||
192 |
!ClassCategoryReader methodsFor:'private'! |
|
193 |
||
194 |
class:aClass category:aCategory |
|
195 |
"set the instance variables" |
|
196 |
||
197 |
myClass := aClass. |
|
198 |
myCategory := aCategory. |
|
199 |
ignore := false |
|
1 | 200 |
! |
201 |
||
699 | 202 |
class:aClass primitiveSpec:which |
203 |
"set the instance variables" |
|
204 |
||
205 |
myClass := aClass. |
|
206 |
primSpec := which. |
|
207 |
ignore := false |
|
208 |
! ! |
|
209 |
||
210 |
!ClassCategoryReader methodsFor:'special'! |
|
211 |
||
212 |
ignoreMethods |
|
213 |
ignore := true |
|
214 |
! |
|
1 | 215 |
|
699 | 216 |
privateProtocol |
217 |
privacy := #private |
|
218 |
! |
|
219 |
||
220 |
protectedProtocol |
|
221 |
privacy := #protected |
|
1 | 222 |
! ! |
699 | 223 |
|
224 |
!ClassCategoryReader class methodsFor:'documentation'! |
|
225 |
||
226 |
version |
|
227 |
^ '$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.23 1995-12-07 21:31:11 cg Exp $' |
|
228 |
! ! |
|
229 |
ClassCategoryReader initialize! |