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