author | Claus Gittinger <cg@exept.de> |
Tue, 06 May 2003 19:45:51 +0200 | |
changeset 1410 | e93635fe8c40 |
parent 1166 | 3b4083f0b1b4 |
child 1416 | 3da6a2670bd8 |
permissions | -rw-r--r-- |
73 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
1147 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
73 | 15 |
Object subclass:#SourceFileLoader |
416 | 16 |
instanceVariableNames:'myStream currentSource package wantChangeLog currentNameSpace |
17 |
usedNameSpaces' |
|
263 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler' |
|
73 | 21 |
! |
22 |
||
23 |
!SourceFileLoader class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
141 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
Instances of this class are created temporary during fileIn. |
|
42 |
They get notified about any errors. Currently, all we |
|
43 |
do here is to output the error on the Transcript; |
|
44 |
eventually, we will open a box showing the position of the error. |
|
263 | 45 |
|
464 | 46 |
Also, information found in scanned compiler directives is remembered |
47 |
here, for later queries (this is required, since the fileIn mechanism |
|
48 |
creates new parsers for every chunk - someone has to remember this |
|
49 |
information across chunks ...). |
|
50 |
||
263 | 51 |
[author:] |
52 |
Claus Gittinger |
|
141 | 53 |
" |
73 | 54 |
! ! |
55 |
||
56 |
!SourceFileLoader class methodsFor:'instance creation'! |
|
57 |
||
58 |
on:aStream |
|
84 | 59 |
^ self new reader:aStream wantChangeLog:false |
73 | 60 |
! ! |
61 |
||
141 | 62 |
!SourceFileLoader methodsFor:'accessing'! |
63 |
||
64 |
source:aString |
|
464 | 65 |
"this is optionally sent by the chunk reader, |
66 |
to pass a single chunks source before its evaluated. |
|
67 |
This allows me to show the erronous code in a TextView |
|
68 |
(but this is not yet implemented)" |
|
69 |
||
141 | 70 |
currentSource := aString |
464 | 71 |
|
72 |
"Modified: 5.1.1997 / 03:06:32 / cg" |
|
141 | 73 |
! ! |
74 |
||
75 |
!SourceFileLoader methodsFor:'compiler queries'! |
|
76 |
||
416 | 77 |
currentNameSpace |
78 |
"sent by the compiler to ask for the current nameSpace. |
|
79 |
This is still to be finished ..." |
|
80 |
||
419 | 81 |
currentNameSpace isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
82 |
currentNameSpace := Class nameSpaceQuerySignal query. |
491
b05dc84e74c0
oops - did not always return the namespace correctly
Claus Gittinger <cg@exept.de>
parents:
464
diff
changeset
|
83 |
"/ currentNameSpace := Smalltalk defaultNameSpace |
419 | 84 |
]. |
416 | 85 |
^ currentNameSpace |
86 |
||
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
87 |
"Created: / 5.11.1996 / 22:05:19 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
88 |
"Modified: / 20.12.1996 / 00:01:32 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
89 |
"Modified: / 18.3.1999 / 18:28:24 / stefan" |
416 | 90 |
! |
91 |
||
414 | 92 |
packageToInstall |
93 |
"sent by the compiler to ask in which package new methods/classes |
|
94 |
are to be installed. |
|
95 |
This is still to be finished ..." |
|
96 |
||
419 | 97 |
package isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
98 |
package := Class packageQuerySignal query. |
491
b05dc84e74c0
oops - did not always return the namespace correctly
Claus Gittinger <cg@exept.de>
parents:
464
diff
changeset
|
99 |
"/ package := Project currentPackageName |
419 | 100 |
]. |
414 | 101 |
^ package |
102 |
||
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
103 |
"Created: / 5.11.1996 / 19:56:03 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
104 |
"Modified: / 20.12.1996 / 00:01:41 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
827
diff
changeset
|
105 |
"Modified: / 18.3.1999 / 18:28:30 / stefan" |
414 | 106 |
! |
107 |
||
416 | 108 |
usedNameSpaces |
109 |
"sent by the compiler to ask for a list of used nameSpaces. |
|
110 |
This is still to be finished ..." |
|
111 |
||
112 |
^ usedNameSpaces |
|
113 |
||
114 |
"Created: 5.11.1996 / 22:05:37 / cg" |
|
115 |
! |
|
116 |
||
141 | 117 |
wantChangeLog |
118 |
"sent by the compiler to ask if a changeLog entry should |
|
119 |
be written. Return false here, since SourceFileLaoders are |
|
120 |
used to read existing source files" |
|
121 |
||
122 |
^ wantChangeLog |
|
123 |
! ! |
|
124 |
||
1153 | 125 |
!SourceFileLoader methodsFor:'directive processing'! |
141 | 126 |
|
452 | 127 |
addUsedSpace:aNameSpace |
464 | 128 |
"sent by the compiler, whenever it encounters a 'Uses:' |
129 |
directive; collect used namespaces here, for later namespace |
|
130 |
queries" |
|
131 |
||
452 | 132 |
usedNameSpaces isNil ifTrue:[ |
133 |
usedNameSpaces := OrderedCollection new. |
|
134 |
]. |
|
135 |
usedNameSpaces add:aNameSpace |
|
136 |
||
137 |
"Created: 19.12.1996 / 22:26:12 / cg" |
|
464 | 138 |
"Modified: 5.1.1997 / 03:07:17 / cg" |
452 | 139 |
! |
140 |
||
141 |
addUsedSpaces:aNameSpaceList |
|
464 | 142 |
"sent by the compiler, whenever it encounters a 'Uses:' |
143 |
directive; collect used namespaces here, for later namespace |
|
144 |
queries" |
|
145 |
||
452 | 146 |
usedNameSpaces isNil ifTrue:[ |
147 |
usedNameSpaces := OrderedCollection new. |
|
148 |
]. |
|
149 |
aNameSpaceList do:[:aNameSpace | |
|
150 |
usedNameSpaces add:aNameSpace |
|
151 |
]. |
|
152 |
||
153 |
"Created: 19.12.1996 / 22:26:23 / cg" |
|
464 | 154 |
"Modified: 5.1.1997 / 03:07:24 / cg" |
452 | 155 |
! |
156 |
||
141 | 157 |
requirePackage:packageName |
464 | 158 |
"sent by the compiler, whenever it encounters a 'Prerequisites:' |
159 |
directive. For now, this is ignored." |
|
160 |
||
141 | 161 |
'require package: ' print. |
279 | 162 |
packageName printCR |
163 |
||
464 | 164 |
"Modified: 5.1.1997 / 03:08:06 / cg" |
141 | 165 |
! |
166 |
||
428
1d24f4dfed64
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
167 |
setNameSpace:aNameSpaceName |
464 | 168 |
"sent by the compiler, whenever it encounters a 'NameSpace:' |
169 |
directive. Remember the namespace for further variable resolving |
|
170 |
and nameSpace queries." |
|
416 | 171 |
|
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
172 |
currentNameSpace := NameSpace fullName:aNameSpaceName |
416 | 173 |
|
464 | 174 |
"Modified: 5.1.1997 / 03:08:43 / cg" |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
175 |
|
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
176 |
|
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
177 |
|
416 | 178 |
! |
179 |
||
141 | 180 |
setPackage:packageName |
464 | 181 |
"sent by the compiler, whenever it encounters a 'Package:' |
182 |
directive. Remember the package for further queries." |
|
183 |
||
414 | 184 |
package := packageName asSymbol |
279 | 185 |
|
464 | 186 |
"Modified: 5.1.1997 / 03:09:00 / cg" |
141 | 187 |
! ! |
188 |
||
73 | 189 |
!SourceFileLoader methodsFor:'error handling'! |
190 |
||
83 | 191 |
correctableError:aMessage position:position to:endPos from:aCompiler |
827
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
192 |
"correctable error notification during fileIn. |
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
193 |
This is sent by the compiler/evaluator if it detects undefined variables-errors." |
73 | 194 |
|
827
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
195 |
"/ Transcript show:'** '; showCR:aMessage. |
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
196 |
"/ self showWherePosition:position to:endPos from:aCompiler. |
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
197 |
|
97 | 198 |
^ false |
275 | 199 |
|
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
200 |
"Modified: 8.11.1996 / 18:53:17 / cg" |
73 | 201 |
! |
202 |
||
1023 | 203 |
correctableSelectorWarning:aMessage position:position to:endPos from:aCompiler |
204 |
"correctable error notification during fileIn." |
|
205 |
||
206 |
^ false |
|
207 |
||
208 |
"Modified: / 19.1.2000 / 16:25:58 / cg" |
|
209 |
"Created: / 19.1.2000 / 16:27:25 / cg" |
|
210 |
! |
|
211 |
||
83 | 212 |
error:aMessage position:position to:endPos from:aCompiler |
73 | 213 |
"error notification during fileIn. |
214 |
This is sent by the compiler/evaluator if it detects errors." |
|
215 |
||
216 |
" |
|
217 |
will eventually open a TextBox here, showing the error .... |
|
218 |
" |
|
275 | 219 |
Transcript show:'===> '; showCR:aMessage. |
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
220 |
self showWherePosition:position to:endPos from:aCompiler. |
73 | 221 |
^ false |
275 | 222 |
|
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
223 |
"Modified: 8.11.1996 / 18:49:41 / cg" |
73 | 224 |
! |
225 |
||
98 | 226 |
insertAndSelect:aString at:aCharacterPosition |
227 |
"ST-80 compatible error notification during fileIn." |
|
228 |
||
229 |
" |
|
230 |
will eventually open a TextBox here, showing the error .... |
|
231 |
" |
|
275 | 232 |
Transcript show:'===> '; showCR:aString. |
98 | 233 |
^ false |
275 | 234 |
|
235 |
"Modified: 18.5.1996 / 15:44:54 / cg" |
|
141 | 236 |
! |
237 |
||
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
238 |
showWherePosition:position to:endPos from:aCompiler |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
239 |
"show more details about the errors/warnings position." |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
240 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
241 |
|cls sel where| |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
242 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
243 |
" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
244 |
will eventually open a TextBox here, showing the error .... |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
245 |
" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
246 |
(cls := aCompiler targetClass) notNil ifTrue:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
247 |
(sel := aCompiler selector) notNil ifTrue:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
248 |
Transcript show:' when compiling '; show:cls name. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
249 |
Transcript show:'>>'; show:sel. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
250 |
] ifFalse:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
251 |
Transcript show:' when compiling/evaluating for '; show:cls name. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
252 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
253 |
Transcript cr. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
254 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
255 |
myStream isFileStream ifTrue:[ |
464 | 256 |
Transcript show:' while reading '; showCR:myStream pathName. |
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
257 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
258 |
(where := aCompiler lastTokenLineNumber) notNil ifTrue:[ |
827
ed73e2d19dae
suppress correctable-warnings.
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
259 |
Transcript show:' at or near line '; show:where; showCR:' [relative to chunk start]'. |
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
260 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
261 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
262 |
"Created: 8.11.1996 / 18:49:08 / cg" |
464 | 263 |
"Modified: 5.1.1997 / 03:04:05 / cg" |
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
264 |
! |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
265 |
|
1166 | 266 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
267 |
"compiler notifies us of a (or some) unused variables; |
|
268 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
269 |
this method should return true to the compiler if user wants the error |
|
270 |
to be corrected; false otherwise" |
|
271 |
||
272 |
^ false |
|
273 |
! |
|
274 |
||
141 | 275 |
warning:aMessage position:position to:endPos from:aCompiler |
276 |
"warning notification during fileIn - ignore it. |
|
277 |
This is sent by the compiler/evaluator if it detects errors." |
|
278 |
||
279 |
^ self |
|
73 | 280 |
! ! |
281 |
||
282 |
!SourceFileLoader methodsFor:'private access'! |
|
283 |
||
84 | 284 |
reader:aStream wantChangeLog:aBoolean |
285 |
myStream := aStream. |
|
286 |
wantChangeLog := aBoolean |
|
287 |
! ! |
|
288 |
||
148 | 289 |
!SourceFileLoader class methodsFor:'documentation'! |
290 |
||
291 |
version |
|
1166 | 292 |
^ '$Header: /cvs/stx/stx/libcomp/SourceFileLoader.st,v 1.29 2001-08-01 13:12:25 cg Exp $' |
148 | 293 |
! ! |