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