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