author | Claus Gittinger <cg@exept.de> |
Fri, 20 Dec 1996 00:22:30 +0100 | |
changeset 452 | 466112d0d3fd |
parent 430 | fbf6a7c19b86 |
child 464 | f409008c2106 |
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 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
141 | 46 |
" |
73 | 47 |
! ! |
48 |
||
49 |
!SourceFileLoader class methodsFor:'instance creation'! |
|
50 |
||
51 |
on:aStream |
|
84 | 52 |
^ self new reader:aStream wantChangeLog:false |
73 | 53 |
! ! |
54 |
||
141 | 55 |
!SourceFileLoader methodsFor:'accessing'! |
56 |
||
57 |
source:aString |
|
58 |
currentSource := aString |
|
59 |
! ! |
|
60 |
||
61 |
!SourceFileLoader methodsFor:'compiler queries'! |
|
62 |
||
416 | 63 |
currentNameSpace |
64 |
"sent by the compiler to ask for the current nameSpace. |
|
65 |
This is still to be finished ..." |
|
66 |
||
419 | 67 |
currentNameSpace isNil ifTrue:[ |
452 | 68 |
currentNameSpace := Smalltalk defaultNameSpace |
419 | 69 |
]. |
416 | 70 |
^ currentNameSpace |
71 |
||
72 |
"Created: 5.11.1996 / 22:05:19 / cg" |
|
452 | 73 |
"Modified: 20.12.1996 / 00:01:32 / cg" |
416 | 74 |
! |
75 |
||
414 | 76 |
packageToInstall |
77 |
"sent by the compiler to ask in which package new methods/classes |
|
78 |
are to be installed. |
|
79 |
This is still to be finished ..." |
|
80 |
||
419 | 81 |
package isNil ifTrue:[ |
452 | 82 |
package := Project currentPackageName |
419 | 83 |
]. |
414 | 84 |
^ package |
85 |
||
86 |
"Created: 5.11.1996 / 19:56:03 / cg" |
|
452 | 87 |
"Modified: 20.12.1996 / 00:01:41 / cg" |
414 | 88 |
! |
89 |
||
416 | 90 |
usedNameSpaces |
91 |
"sent by the compiler to ask for a list of used nameSpaces. |
|
92 |
This is still to be finished ..." |
|
93 |
||
94 |
^ usedNameSpaces |
|
95 |
||
96 |
"Created: 5.11.1996 / 22:05:37 / cg" |
|
97 |
! |
|
98 |
||
141 | 99 |
wantChangeLog |
100 |
"sent by the compiler to ask if a changeLog entry should |
|
101 |
be written. Return false here, since SourceFileLaoders are |
|
102 |
used to read existing source files" |
|
103 |
||
104 |
^ wantChangeLog |
|
105 |
! ! |
|
106 |
||
107 |
!SourceFileLoader methodsFor:'directve processing'! |
|
108 |
||
452 | 109 |
addUsedSpace:aNameSpace |
110 |
usedNameSpaces isNil ifTrue:[ |
|
111 |
usedNameSpaces := OrderedCollection new. |
|
112 |
]. |
|
113 |
usedNameSpaces add:aNameSpace |
|
114 |
||
115 |
"Modified: 5.11.1996 / 22:03:53 / cg" |
|
116 |
"Created: 19.12.1996 / 22:26:12 / cg" |
|
117 |
! |
|
118 |
||
119 |
addUsedSpaces:aNameSpaceList |
|
120 |
usedNameSpaces isNil ifTrue:[ |
|
121 |
usedNameSpaces := OrderedCollection new. |
|
122 |
]. |
|
123 |
aNameSpaceList do:[:aNameSpace | |
|
124 |
usedNameSpaces add:aNameSpace |
|
125 |
]. |
|
126 |
||
127 |
"Modified: 5.11.1996 / 22:03:53 / cg" |
|
128 |
"Created: 19.12.1996 / 22:26:23 / cg" |
|
129 |
! |
|
130 |
||
141 | 131 |
requirePackage:packageName |
132 |
'require package: ' print. |
|
279 | 133 |
packageName printCR |
134 |
||
135 |
"Modified: 20.5.1996 / 10:29:05 / cg" |
|
141 | 136 |
! |
137 |
||
428
1d24f4dfed64
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
138 |
setNameSpace:aNameSpaceName |
1d24f4dfed64
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
139 |
"set the namespace for further variable resolving" |
416 | 140 |
|
428
1d24f4dfed64
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
141 |
currentNameSpace := Namespace fullName:aNameSpaceName |
416 | 142 |
|
428
1d24f4dfed64
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
143 |
"Modified: 8.11.1996 / 13:42:54 / cg" |
416 | 144 |
! |
145 |
||
141 | 146 |
setPackage:packageName |
414 | 147 |
package := packageName asSymbol |
279 | 148 |
|
414 | 149 |
"Modified: 5.11.1996 / 20:24:33 / cg" |
141 | 150 |
! ! |
151 |
||
73 | 152 |
!SourceFileLoader methodsFor:'error handling'! |
153 |
||
83 | 154 |
correctableError:aMessage position:position to:endPos from:aCompiler |
73 | 155 |
"error notification during fileIn. |
156 |
This is sent by the compiler/evaluator if it detects errors." |
|
157 |
||
275 | 158 |
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
|
159 |
self showWherePosition:position to:endPos from:aCompiler. |
97 | 160 |
^ false |
275 | 161 |
|
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
162 |
"Modified: 8.11.1996 / 18:53:17 / cg" |
73 | 163 |
! |
164 |
||
83 | 165 |
error:aMessage position:position to:endPos from:aCompiler |
73 | 166 |
"error notification during fileIn. |
167 |
This is sent by the compiler/evaluator if it detects errors." |
|
168 |
||
169 |
" |
|
170 |
will eventually open a TextBox here, showing the error .... |
|
171 |
" |
|
275 | 172 |
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
|
173 |
self showWherePosition:position to:endPos from:aCompiler. |
73 | 174 |
^ false |
275 | 175 |
|
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
176 |
"Modified: 8.11.1996 / 18:49:41 / cg" |
73 | 177 |
! |
178 |
||
98 | 179 |
insertAndSelect:aString at:aCharacterPosition |
180 |
"ST-80 compatible error notification during fileIn." |
|
181 |
||
182 |
" |
|
183 |
will eventually open a TextBox here, showing the error .... |
|
184 |
" |
|
275 | 185 |
Transcript show:'===> '; showCR:aString. |
98 | 186 |
^ false |
275 | 187 |
|
188 |
"Modified: 18.5.1996 / 15:44:54 / cg" |
|
141 | 189 |
! |
190 |
||
430
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
191 |
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
|
192 |
"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
|
193 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
194 |
|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
|
195 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
196 |
" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
197 |
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
|
198 |
" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
199 |
(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
|
200 |
(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
|
201 |
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
|
202 |
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
|
203 |
] ifFalse:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
204 |
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
|
205 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
206 |
Transcript cr. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
207 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
208 |
myStream isFileStream ifTrue:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
209 |
Transcript show:' while reading '; show:myStream pathName. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
210 |
Transcript cr. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
211 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
212 |
(where := aCompiler lastTokenLineNumber) notNil ifTrue:[ |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
213 |
Transcript show:' at or near line '; show:where. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
214 |
Transcript cr. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
215 |
]. |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
216 |
|
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
217 |
"Created: 8.11.1996 / 18:49:08 / cg" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
218 |
"Modified: 8.11.1996 / 18:51:11 / cg" |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
219 |
! |
fbf6a7c19b86
show more info in case of errors while reading from a file
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
220 |
|
141 | 221 |
warning:aMessage position:position to:endPos from:aCompiler |
222 |
"warning notification during fileIn - ignore it. |
|
223 |
This is sent by the compiler/evaluator if it detects errors." |
|
224 |
||
225 |
^ self |
|
73 | 226 |
! ! |
227 |
||
228 |
!SourceFileLoader methodsFor:'private access'! |
|
229 |
||
84 | 230 |
reader:aStream wantChangeLog:aBoolean |
231 |
myStream := aStream. |
|
232 |
wantChangeLog := aBoolean |
|
233 |
! ! |
|
234 |
||
148 | 235 |
!SourceFileLoader class methodsFor:'documentation'! |
236 |
||
237 |
version |
|
452 | 238 |
^ '$Header: /cvs/stx/stx/libcomp/Attic/SrcFLoader.st,v 1.20 1996-12-19 23:22:30 cg Exp $' |
148 | 239 |
! ! |