author | Claus Gittinger <cg@exept.de> |
Fri, 17 Aug 2001 14:37:43 +0200 | |
changeset 5911 | b9b601514f13 |
parent 5747 | 95f11bec8998 |
child 6222 | 339364ec5573 |
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 |
||
5747 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
Object subclass:#ClassCategoryReader |
784 | 16 |
instanceVariableNames:'myClass myCategory privacy ignore primSpec' |
2404
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
17 |
classVariableNames:'KeepSource SourceMode SkipUnchangedMethods' |
784 | 18 |
poolDictionaries:'' |
19 |
category:'Kernel-Support' |
|
1 | 20 |
! |
21 |
||
2065 | 22 |
!ClassCategoryReader class methodsFor:'documentation'! |
88 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
167 | 27 |
All Rights Reserved |
1 | 28 |
|
88 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
a helper class for fileIn - keeps track of class and category to filein for. |
|
41 |
Instances of this are created by the #methodsFor: methods in Class, to |
|
42 |
read the next chunk(s) from a stream. |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
43 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
44 |
ClassCategoryReaders allow different ways of keeping the sourceCode of its |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
45 |
loaded code. This is controlled by the SourceMode class variable which may be: |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
46 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
47 |
#discard - forget the source code; no browsing/recompilation is possible |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
48 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
49 |
#keep - keep the source code as a string. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
50 |
any saved image will later be fully independent of any |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
51 |
source files. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
52 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
53 |
#reference - keep a reference to the loaded files basename |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
54 |
In order to be browsable, the original sourcefile should be |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
55 |
found along the sourcePath |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
56 |
(i.e. typically a link in the source directory should be present) |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
57 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
58 |
#absReference - keep a reference to the loaded files absolute pathname |
3860
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
59 |
but only if the file ends with .st. |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
60 |
(this is ok in multiUser configurations, where all sourcefiles are mounted |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
61 |
on a common path; typically automounted systems) |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
62 |
|
3860
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
63 |
#forceAbsReference |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
64 |
- like above, but also do it for files not ending with .st. |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
65 |
Must be used with care - NEVER ever reference sources from the changes |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
66 |
file, because the changesBrowser does not adjust methods sources |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
67 |
when it compresses or removes changes. |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
68 |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
69 |
#sourceReference - append source to the `st.src' file, |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
70 |
and keep a reference to that file. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
71 |
if the image is later moved to another location, |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
72 |
this file should be moved along with it. |
1295 | 73 |
|
74 |
[author:] |
|
75 |
Claus Gittinger |
|
76 |
||
77 |
[see also:] |
|
78 |
Class PositionableStream |
|
88 | 79 |
" |
80 |
! ! |
|
1 | 81 |
|
2065 | 82 |
!ClassCategoryReader class methodsFor:'initialization'! |
425 | 83 |
|
84 |
initialize |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
85 |
KeepSource := true. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
86 |
SourceMode := #keep. |
2404
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
87 |
SkipUnchangedMethods := true. |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
88 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
89 |
" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
90 |
ClassCategoryReader initialize |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
91 |
" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
92 |
|
2404
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
93 |
"Modified: 14.2.1997 / 18:26:52 / cg" |
425 | 94 |
! ! |
95 |
||
2065 | 96 |
!ClassCategoryReader class methodsFor:'instance creation'! |
1 | 97 |
|
98 |
class:aClass category:aCategory |
|
99 |
"return a new ClassCategoryReader to read methods for aClass with |
|
100 |
methodCategory aCategory" |
|
101 |
||
102 |
^ self new class:aClass category:aCategory |
|
167 | 103 |
! |
104 |
||
216 | 105 |
class:aClass primitiveSpec:which |
106 |
"return a ClassCategoryReader to read a primitiveSpec chunk" |
|
107 |
||
108 |
^ self new class:aClass primitiveSpec:which |
|
1 | 109 |
! ! |
110 |
||
2065 | 111 |
!ClassCategoryReader class methodsFor:'defaults'! |
1 | 112 |
|
699 | 113 |
keepSource |
114 |
^ KeepSource |
|
1 | 115 |
|
699 | 116 |
"Created: 9.9.1995 / 15:22:27 / claus" |
216 | 117 |
! |
118 |
||
699 | 119 |
keepSource:aBoolean |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
120 |
KeepSource := aBoolean. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
121 |
SourceMode := (aBoolean ifTrue:[#keep] ifFalse:[#reference]) |
68 | 122 |
|
699 | 123 |
"Created: 9.9.1995 / 15:22:26 / claus" |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
124 |
"Modified: 9.2.1996 / 17:23:04 / cg" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
125 |
! |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
126 |
|
2404
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
127 |
skipUnchangedMethods |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
128 |
"return true, if the default for unchanged methods is to skip them. |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
129 |
The default is true." |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
130 |
|
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
131 |
^ SkipUnchangedMethods |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
132 |
|
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
133 |
"Created: 14.2.1997 / 18:27:49 / cg" |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
134 |
"Modified: 14.2.1997 / 18:28:13 / cg" |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
135 |
! |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
136 |
|
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
137 |
skipUnchangedMethods:aBoolean |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
138 |
"return true, if the default for unchanged methods is to skip them. |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
139 |
The default is true. Can be temporarily changed to false, if |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
140 |
a forced fileIn is required." |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
141 |
|
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
142 |
SkipUnchangedMethods := aBoolean |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
143 |
|
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
144 |
"Created: 14.2.1997 / 18:27:43 / cg" |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
145 |
"Modified: 14.2.1997 / 18:28:42 / cg" |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
146 |
! |
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
147 |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
148 |
sourceMode |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
149 |
"return the sourceMode, which controls how sources are to be handled. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
150 |
Read #documentation for more info" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
151 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
152 |
^ SourceMode |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
153 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
154 |
"Created: 9.2.1996 / 17:22:58 / cg" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
155 |
! |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
156 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
157 |
sourceMode:aSymbol |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
158 |
"set the sourceMode, which controls how sources are to be handled. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
159 |
Read #documentation for more info" |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
160 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
161 |
SourceMode := aSymbol |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
162 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
163 |
"Created: 9.2.1996 / 17:23:00 / cg" |
1 | 164 |
! ! |
165 |
||
166 |
!ClassCategoryReader methodsFor:'fileIn'! |
|
167 |
||
699 | 168 |
fileInFrom:aStream |
169 |
"read method-chunks from the input stream, aStream; compile them |
|
170 |
and add the methods to the class defined by the class-instance var" |
|
171 |
||
3453 | 172 |
^ self |
173 |
fileInFrom:aStream |
|
174 |
notifying:nil |
|
175 |
passChunk:false |
|
176 |
single:false |
|
177 |
silent:nil |
|
178 |
||
179 |
"Modified: / 17.5.1998 / 19:58:33 / cg" |
|
699 | 180 |
! |
181 |
||
328 | 182 |
fileInFrom:aStream notifying:requestor passChunk:passChunk |
1 | 183 |
"read method-chunks from the input stream, aStream; compile them |
184 |
and add the methods to the class defined by the class-instance var; |
|
2065 | 185 |
errors and notifications are passed to requestor. |
186 |
If passChunk is true, chunks are given to the requestor, |
|
187 |
via a #source: message, allowing it to open a view showing any |
|
188 |
arronous source code." |
|
1 | 189 |
|
1644 | 190 |
^ self |
191 |
fileInFrom:aStream |
|
192 |
notifying:requestor |
|
193 |
passChunk:passChunk |
|
194 |
single:false |
|
3453 | 195 |
silent:nil |
1644 | 196 |
|
3453 | 197 |
"Modified: / 17.5.1998 / 19:58:15 / cg" |
1644 | 198 |
! |
199 |
||
200 |
fileInFrom:aStream notifying:requestor passChunk:passChunk single:oneChunkOnly |
|
201 |
"read method-chunks from the input stream, aStream; compile them |
|
202 |
and add the methods to the class defined by the class-instance var; |
|
2065 | 203 |
errors and notifications are passed to requestor. |
204 |
If passChunk is true, chunks are given to the requestor, |
|
205 |
via a #source: message, allowing it to open a view showing any |
|
3028 | 206 |
erronous source code. |
2065 | 207 |
If oneChunkOnly is true, the fileIn is finished after the first chunk." |
1644 | 208 |
|
3453 | 209 |
^ self |
210 |
fileInFrom:aStream |
|
211 |
notifying:requestor |
|
212 |
passChunk:passChunk |
|
213 |
single:oneChunkOnly |
|
214 |
silent:nil |
|
215 |
||
216 |
"Modified: / 17.5.1998 / 19:58:05 / cg" |
|
217 |
! |
|
1 | 218 |
|
3453 | 219 |
fileInFrom:aStream notifying:requestor passChunk:passChunk single:oneChunkOnly silent:beSilent |
220 |
"read method-chunks from the input stream, aStream; compile them |
|
221 |
and add the methods to the class defined by the class-instance var; |
|
222 |
errors and notifications are passed to requestor. |
|
223 |
If passChunk is true, chunks are given to the requestor, |
|
224 |
via a #source: message, allowing it to open a view showing any |
|
225 |
erronous source code. |
|
226 |
If oneChunkOnly is true, the fileIn is finished after the first chunk. |
|
227 |
The beSilent argument controls output to the transcript, if its true or |
|
228 |
false. If its nil, output is controlled by the Smalltalk>>silenLoading setting." |
|
229 |
||
230 |
|aString done method compiler canMakeSourceRef sourceFile pos nm src s silent| |
|
231 |
||
5911 | 232 |
|
233 |
(silent := beSilent isNil) ifTrue:[silent := Smalltalk silentLoading]. |
|
3453 | 234 |
silent == true ifFalse:[ |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
235 |
myClass isNil ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
236 |
nm := '** UndefinedClass **' |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
237 |
] ifFalse:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
238 |
nm := myClass name |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
239 |
]. |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
240 |
Transcript show:' '; show:nm; show:' -> '; show:myCategory. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
241 |
ignore ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
242 |
Transcript show:' (** ignored **)'. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
243 |
] ifFalse:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
244 |
privacy notNil ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
245 |
Transcript show:' (** '; show:privacy; show:' **)' |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
246 |
] |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
247 |
]. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
248 |
Transcript cr. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
249 |
]. |
868
fc7ab02e0537
only keep sourceRef in methods if the sourceFIle is a '.st' file
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
250 |
|
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
251 |
canMakeSourceRef := false. |
328 | 252 |
|
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
253 |
"/ |
3519
6f4ccc0c6eff
handle squeaks commentStamp: special
Claus Gittinger <cg@exept.de>
parents:
3454
diff
changeset
|
254 |
"/ SourceMode controls if |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
255 |
"/ the sourceString should be kept or |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
256 |
"/ a reference to the fileStream should be placed into the |
3519
6f4ccc0c6eff
handle squeaks commentStamp: special
Claus Gittinger <cg@exept.de>
parents:
3454
diff
changeset
|
257 |
"/ method instead. |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
258 |
"/ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
259 |
((SourceMode ~~ #keep) |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
260 |
and:[SourceMode ~~ #discard]) ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
261 |
aStream isFileStream ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
262 |
sourceFile := aStream pathName. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
263 |
"/ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
264 |
"/ only do it, if the sourceFiles name |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
265 |
"/ ends with '.st' |
3028 | 266 |
"/ this prevents methods from referencing the changes file. |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
267 |
"/ |
3860
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
268 |
((SourceMode == #forceAbsReference) |
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
269 |
or:[sourceFile asFilename hasSuffix:'st']) ifTrue:[ |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
270 |
canMakeSourceRef := true. |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
271 |
|
3860
6ec12b7b2073
added #forceAbsReference sourceMode.
Claus Gittinger <cg@exept.de>
parents:
3519
diff
changeset
|
272 |
(SourceMode ~~ #absReference |
3904 | 273 |
and:[SourceMode ~~ #forceAbsReference]) ifTrue:[ |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
274 |
SourceMode == #sourceReference ifTrue:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
275 |
sourceFile := 'st.src'. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
276 |
] ifFalse:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
277 |
sourceFile := aStream pathName asFilename baseName |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
278 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
279 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
280 |
] |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
281 |
] |
425 | 282 |
]. |
283 |
||
1 | 284 |
done := false. |
285 |
[done] whileFalse:[ |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
286 |
done := aStream atEnd. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
287 |
done ifFalse:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
288 |
canMakeSourceRef ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
289 |
pos := aStream position |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
290 |
]. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
291 |
aString := aStream nextChunk. |
3028 | 292 |
done := aString size == 0. |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
293 |
done ifFalse:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
294 |
primSpec notNil ifTrue:[ |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
295 |
ignore ifFalse:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
296 |
myClass perform:primSpec with:aString. |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
297 |
" |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
298 |
ignore rest |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
299 |
" |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
300 |
ignore := true |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
301 |
] |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
302 |
] ifFalse:[ |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
303 |
passChunk ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
304 |
requestor source:aString |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
305 |
]. |
328 | 306 |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
307 |
compiler := myClass compilerClass. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
308 |
|
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
309 |
"/ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
310 |
"/ kludge - for now; |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
311 |
"/ have to make ST/X's compiler protocol be compatible to ST-80's |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
312 |
"/ for other compilers to work ... (TGEN for example) |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
313 |
"/ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
314 |
(compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:) |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
315 |
ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
316 |
"/ ST/X's compiler |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
317 |
method :=compiler |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
318 |
compile:aString |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
319 |
forClass:myClass |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
320 |
inCategory:myCategory |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
321 |
notifying:requestor |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
322 |
install:true |
2404
77c6111ce6ba
added access to skipIfSame default.
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
323 |
skipIfSame:SkipUnchangedMethods. |
350 | 324 |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
325 |
(method notNil and:[method ~~ #Error]) ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
326 |
canMakeSourceRef ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
327 |
(src := method getSource) = aString ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
328 |
"/ it was not corrected ... |
350 | 329 |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
330 |
SourceMode == #sourceReference ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
331 |
s := sourceFile asFilename appendingWriteStream. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
332 |
s setToEnd. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
333 |
pos := s position. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
334 |
s nextChunkPut:src. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
335 |
s close. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
336 |
]. |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
337 |
method sourceFilename:sourceFile position:pos |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
338 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
339 |
] ifFalse:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
340 |
SourceMode == #discard ifTrue:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
341 |
method sourceFilename:nil position:nil |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
342 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
343 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
344 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
345 |
] ifFalse:[ |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
346 |
"/ some generated (TGEN) compiler |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
347 |
method := compiler new |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
348 |
compile:aString |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
349 |
in:myClass |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
350 |
notifying:requestor |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
351 |
ifFail:nil |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
352 |
]. |
328 | 353 |
|
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
354 |
ignore ifTrue:[ |
3217
568eaf667294
Use #setPrivacy: instead of #setPrivate #setProtected and #setIgnored
Stefan Vogel <sv@exept.de>
parents:
3089
diff
changeset
|
355 |
method setPrivacy:#ignore |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
356 |
] ifFalse:[ |
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
357 |
privacy notNil ifTrue:[ |
3217
568eaf667294
Use #setPrivacy: instead of #setPrivate #setProtected and #setIgnored
Stefan Vogel <sv@exept.de>
parents:
3089
diff
changeset
|
358 |
method setPrivacy:privacy |
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
359 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
360 |
] |
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
361 |
] |
1644 | 362 |
]. |
363 |
oneChunkOnly ifTrue:[done := true]. |
|
955
6b5487deebfa
more & better sourceHandling options
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
364 |
] |
1 | 365 |
] |
425 | 366 |
|
3217
568eaf667294
Use #setPrivacy: instead of #setPrivate #setProtected and #setIgnored
Stefan Vogel <sv@exept.de>
parents:
3089
diff
changeset
|
367 |
"Modified: / 9.9.1995 / 15:29:08 / claus" |
568eaf667294
Use #setPrivacy: instead of #setPrivate #setProtected and #setIgnored
Stefan Vogel <sv@exept.de>
parents:
3089
diff
changeset
|
368 |
"Modified: / 23.1.1998 / 15:25:01 / stefan" |
3453 | 369 |
"Created: / 17.5.1998 / 19:56:32 / cg" |
3904 | 370 |
"Modified: / 29.10.1998 / 21:34:59 / cg" |
3453 | 371 |
! |
372 |
||
373 |
fileInFrom:aStream silent:beSilent |
|
374 |
"read method-chunks from the input stream, aStream; compile them |
|
375 |
and add the methods to the class defined by the class-instance var. |
|
376 |
The beSilent argument controls if a message is to be sent to the Transcript." |
|
377 |
||
378 |
^ self |
|
379 |
fileInFrom:aStream |
|
380 |
notifying:nil |
|
381 |
passChunk:false |
|
382 |
single:false |
|
3454 | 383 |
silent:beSilent |
3453 | 384 |
|
385 |
"Created: / 17.5.1998 / 19:59:08 / cg" |
|
3454 | 386 |
"Modified: / 17.5.1998 / 19:59:57 / cg" |
699 | 387 |
! ! |
388 |
||
389 |
!ClassCategoryReader methodsFor:'private'! |
|
390 |
||
391 |
class:aClass category:aCategory |
|
392 |
"set the instance variables" |
|
393 |
||
394 |
myClass := aClass. |
|
5170 | 395 |
"/ ensure that the class is loaded. |
396 |
myClass autoload. |
|
699 | 397 |
myCategory := aCategory. |
398 |
ignore := false |
|
1 | 399 |
! |
400 |
||
699 | 401 |
class:aClass primitiveSpec:which |
402 |
"set the instance variables" |
|
403 |
||
404 |
myClass := aClass. |
|
5170 | 405 |
"/ ensure that the class is loaded. |
406 |
myClass autoload. |
|
699 | 407 |
primSpec := which. |
408 |
ignore := false |
|
409 |
! ! |
|
410 |
||
411 |
!ClassCategoryReader methodsFor:'special'! |
|
412 |
||
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
413 |
ignoredProtocol |
699 | 414 |
ignore := true |
959
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
415 |
|
dbf9d63b4a6c
correctly handling ignoredMethods
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
416 |
"Created: 10.2.1996 / 12:54:15 / cg" |
699 | 417 |
! |
1 | 418 |
|
699 | 419 |
privateProtocol |
420 |
privacy := #private |
|
421 |
! |
|
422 |
||
423 |
protectedProtocol |
|
424 |
privacy := #protected |
|
1 | 425 |
! ! |
699 | 426 |
|
2065 | 427 |
!ClassCategoryReader class methodsFor:'documentation'! |
699 | 428 |
|
429 |
version |
|
5911 | 430 |
^ '$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.46 2001-08-17 12:37:00 cg Exp $' |
699 | 431 |
! ! |
432 |
ClassCategoryReader initialize! |