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