author | Claus Gittinger <cg@exept.de> |
Sun, 04 Jul 1999 19:48:24 +0200 | |
changeset 887 | e42ea977b85d |
parent 883 | e595802b4853 |
child 894 | 943b6d0d26b3 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
44 | 3 |
All Rights Reserved |
0 | 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 |
Scanner subclass:#Parser |
|
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
14 |
instanceVariableNames:'classToCompileFor selfValue contextToEvaluateIn selector |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
15 |
methodArgs methodArgNames methodVars methodVarNames tree |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
currentBlock parseForCode usedInstVars usedClassVars usedVars |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
17 |
modifiedInstVars modifiedClassVars modifiedGlobals usesSuper |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
18 |
usedGlobals usedSymbols usedMessages localVarDefPosition |
664 | 19 |
evalExitBlock selfNode superNode nilNode hasPrimitiveCode |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
20 |
hasNonOptionalPrimitiveCode primitiveNr primitiveResource logged |
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
21 |
warnedUndefVars warnSTXHereExtensionUsed correctedSource |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
22 |
foldConstants lineNumberInfo currentNamespace |
825 | 23 |
currentUsedNamespaces warnUndeclared methodNode |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
24 |
alreadyWarnedClassInstVarRefs localBlockVarDefPosition |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
25 |
endOfSelectorPosition startOfBlockPosition' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
26 |
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
27 |
PrevClassInstVarNames LazyCompilation ArraysAreImmutable |
601 | 28 |
ImplicitSelfSends WarnST80Directives FoldConstants LineNumberInfo |
752 | 29 |
SuppressDoItCompilation StringsAreImmutable' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
30 |
poolDictionaries:'' |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
31 |
category:'System-Compiler' |
0 | 32 |
! |
33 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
34 |
!Parser class methodsFor:'documentation'! |
19 | 35 |
|
20 | 36 |
copyright |
37 |
" |
|
38 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
44 | 39 |
All Rights Reserved |
20 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
! |
|
49 |
||
19 | 50 |
documentation |
51 |
" |
|
52 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
53 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
54 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
55 |
the (planned) MachineCodeCompiler. |
|
56 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
57 |
methods of main interest are: |
755 | 58 |
Parser evaluateExpression:... |
19 | 59 |
|
60 |
and: |
|
755 | 61 |
Parser parseExpression:... |
62 |
Parser parseMethod:... |
|
19 | 63 |
|
64 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
65 |
||
66 |
Parser is also used to find the referenced/modified inst/classvars of |
|
67 |
a method - this is done by sending parseXXX message to a parser and asking |
|
68 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
69 |
||
70 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
71 |
example analyzes the expressions in the changelist ...) by looking at the |
|
72 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 73 |
compilers internals ... better style is to add specialized query methods here) |
19 | 74 |
|
75 |
One instance of Parser is created to parse one method or expression - i.e. |
|
76 |
its not suggested to reuse parsers. |
|
77 |
||
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
78 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
79 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
80 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
81 |
The parser has various modes for constant folding; by default, only numeric |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
82 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
83 |
(i.e. something like 'Float pi sin' or '1.5 + 0.3' will be reduced to a constant). |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
84 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
85 |
Constant folding can be turned off completely (setting FoldConstants to nil) |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
86 |
to ``secure folding'', which only folds constant numbers (#level1) or to #full. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
87 |
In full mode, more constant expressions are folded (for example: '1.0 @ 1.0' is |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
88 |
reduced to a constant point), but the resulting code may not be compatible with other |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
89 |
smalltalk systems (consider the case, where the point is modified using #x: or #y: messages). |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
90 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 91 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
92 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
93 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
94 |
if its known that the used constant objects are subject of modifications as described above. |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
95 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
96 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
97 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
98 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
99 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
100 |
Consider the case of a method returning '#(1 2 3 4)', and that array being modified |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
101 |
by some other method (using #at:put:). Since the array-return is actually a return of |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
102 |
a reference to the compiler created array, the next invokation of the method will |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
103 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
104 |
By an option, the compiler can generate immutable arrays, which dont allow modification |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
105 |
of its elements. For clean code, you should enable this option during development. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
106 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
107 |
As mentioned above, this is experimental. If it is reported to be a useful feature, |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
108 |
the immutable feature will be extended to strings, point-literals etc. in a future version |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
109 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
110 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
111 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
112 |
|
260 | 113 |
[Instance variables:] |
114 |
||
755 | 115 |
classToCompileFor <Class> the class (or nil) we are compiling for |
116 |
||
117 |
selfValue <any> value to use as self when interpreting |
|
118 |
||
119 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
120 |
||
121 |
selector <Symbol> the selector of the parsed method |
|
122 |
(valid after parseMethodSpecification) |
|
123 |
methodArgs internal |
|
124 |
||
125 |
methodArgNames <Collection> the names of the arguments |
|
126 |
(valid after parseMethodSpecification) |
|
127 |
||
128 |
methodVars internal |
|
129 |
||
130 |
methodVarNames <Collection> the names of the method locals |
|
131 |
(valid after parseMethodBodyVarSpec) |
|
132 |
||
133 |
tree <ParseTree> the parse tree - valid after parsing |
|
134 |
||
135 |
currentBlock if currently parsing for a block |
|
136 |
||
137 |
usedInstVars set of all accessed instances variables |
|
138 |
(valid after parsing) |
|
139 |
||
140 |
usedClassVars same for classVars |
|
141 |
||
142 |
usedVars all used variables (inst, class & globals) |
|
143 |
||
144 |
modifiedInstVars set of all modified instance variables |
|
145 |
||
146 |
modifiedClassVars same for clasVars |
|
147 |
||
148 |
localVarDefPosition <Integer> the character offset of the local variable |
|
149 |
def. (i.e. the first '|' if any) |
|
150 |
Not yet used - prepared for automatic add of |
|
151 |
undefined variables |
|
152 |
||
153 |
evalExitBlock internal for interpretation |
|
154 |
||
155 |
selfNode <Node> cached one-and-only 'self' node |
|
156 |
superNode <Node> cached one-and-only 'super' node |
|
157 |
||
158 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
159 |
hasNonOptionalPrimitiveCode |
|
160 |
<Boolean> true, if it contains ST/X style primitive code |
|
161 |
which is NOT flagged by the OPTIONAL directive. |
|
162 |
||
163 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
164 |
||
165 |
logged |
|
166 |
||
167 |
warnedUndefVars <Set> set of all variables which the parser has |
|
168 |
already output a warning (to avoid multiple |
|
169 |
warnings about the same variable) |
|
260 | 170 |
|
171 |
[Class variables:] |
|
172 |
||
755 | 173 |
PrevClass <Class> class, of which properties are |
174 |
cached in: |
|
175 |
||
176 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
177 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
178 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
179 |
||
180 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
181 |
||
182 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
183 |
as instances of ImmutableArray, |
|
184 |
which cannot be stored into. |
|
185 |
Default is false, for compatibility. |
|
186 |
Can be turned on while developping |
|
187 |
new code to make certain that side |
|
188 |
effects are avoided. |
|
189 |
||
190 |
WarnST80Directives <Boolean> if true, give warnings about |
|
191 |
ST-80 directives (resource defs) |
|
192 |
which are ignored in st/x. |
|
193 |
defaults to false. |
|
194 |
||
195 |
FoldConstants <Symbol> controls how constant folding should be |
|
196 |
done. |
|
197 |
Can be one of: |
|
198 |
nil - no constant folding |
|
199 |
#level1 - numeric optimizations only |
|
200 |
#level2 - secure optimizations only |
|
201 |
#full - full folding |
|
202 |
||
203 |
level1: arithmetic on constant numbers |
|
204 |
||
205 |
level2: above PLUS array conversions with #asFloatArray, |
|
206 |
#asDoubleArray, string concatenation |
|
207 |
||
208 |
full: constant points. |
|
260 | 209 |
|
210 |
[see also:] |
|
755 | 211 |
ByteCodeCompiler Scanner ObjectFileLoader |
212 |
Workspace |
|
213 |
SystemBrowser |
|
263 | 214 |
|
215 |
[author:] |
|
755 | 216 |
Claus Gittinger |
19 | 217 |
" |
141 | 218 |
! ! |
219 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
220 |
!Parser class methodsFor:'instance creation'! |
141 | 221 |
|
222 |
for:aStringOrStream in:aClass |
|
223 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
224 |
||
225 |
|parser| |
|
226 |
||
227 |
parser := self for:aStringOrStream. |
|
228 |
parser setClassToCompileFor:aClass. |
|
229 |
^ parser |
|
230 |
! ! |
|
231 |
||
540 | 232 |
!Parser class methodsFor:'ST-80 compatibility'! |
233 |
||
234 |
parse:aString class:aClass |
|
235 |
"same as #parseMethod:in: for ST80 compatibility." |
|
236 |
||
237 |
|parser| |
|
238 |
||
239 |
parser := self parseMethod:aString in:aClass. |
|
240 |
parser notNil ifTrue:[^ parser tree]. |
|
241 |
^ nil |
|
242 |
||
243 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
244 |
! ! |
|
245 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
246 |
!Parser class methodsFor:'changes'! |
141 | 247 |
|
248 |
flushNameCache |
|
249 |
"unconditional flush name caches" |
|
250 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
251 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
252 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
253 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
254 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
255 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
256 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
257 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
258 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
259 |
] valueUninterruptably |
141 | 260 |
|
261 |
"Parser flushNameCache" |
|
262 |
! |
|
263 |
||
264 |
update:something with:someArgument from:changedObject |
|
265 |
"aClass has changed its definition - flush name caches if we have to" |
|
266 |
||
267 |
(changedObject == PrevClass) ifTrue:[ |
|
268 |
something == #definition ifTrue:[ |
|
269 |
self flushNameCache |
|
270 |
] |
|
271 |
] |
|
272 |
! ! |
|
273 |
||
717 | 274 |
!Parser class methodsFor:'class initialization'! |
275 |
||
276 |
initialize |
|
277 |
LazyCompilation := false. "/ usually set to true in your .rc file |
|
752 | 278 |
ArraysAreImmutable := false. "/ usually left false for ST-80 compatibility |
279 |
StringsAreImmutable := false. "/ usually left false for ST-80 compatibility |
|
280 |
||
717 | 281 |
ImplicitSelfSends := false. |
282 |
WarnST80Directives := false. |
|
283 |
FoldConstants := #level1. |
|
284 |
LineNumberInfo := false. |
|
285 |
||
286 |
" |
|
287 |
self initialize |
|
288 |
" |
|
289 |
||
752 | 290 |
"Modified: / 3.8.1998 / 14:53:47 / cg" |
717 | 291 |
! ! |
292 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
293 |
!Parser class methodsFor:'controlling compilation'! |
141 | 294 |
|
295 |
arraysAreImmutable |
|
296 |
"return true if arrays are immutable literals" |
|
297 |
||
298 |
^ ArraysAreImmutable |
|
299 |
! |
|
300 |
||
301 |
arraysAreImmutable:aBoolean |
|
302 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
303 |
||
304 |
ArraysAreImmutable := aBoolean. |
|
305 |
||
306 |
" |
|
307 |
can be added to your private.rc file: |
|
308 |
||
309 |
Compiler arraysAreImmutable:true |
|
310 |
Compiler arraysAreImmutable:false |
|
311 |
" |
|
312 |
! |
|
313 |
||
314 |
compileLazy |
|
315 |
"return true if compiling lazy" |
|
316 |
||
317 |
^ LazyCompilation. |
|
318 |
! |
|
319 |
||
320 |
compileLazy:aBoolean |
|
321 |
"turn on/off lazy compilation - return previous setting. |
|
322 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
323 |
but it also controls the reporting of some errors here; therefore |
|
324 |
its located here" |
|
325 |
||
326 |
|oldLazy| |
|
327 |
||
328 |
oldLazy := LazyCompilation. |
|
329 |
LazyCompilation := aBoolean. |
|
330 |
^ oldLazy |
|
331 |
||
332 |
" |
|
333 |
usually set in your .rc file |
|
334 |
||
335 |
Compiler compileLazy:false |
|
336 |
Compiler compileLazy:true |
|
337 |
" |
|
338 |
! |
|
339 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
340 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
341 |
"return a symbol describing how constants are to be folded" |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
342 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
343 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
344 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
345 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
346 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
347 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
348 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
349 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
350 |
It can be: |
619 | 351 |
nil - no constant folding |
352 |
#level1 - numeric constants only |
|
353 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
354 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
355 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
356 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
357 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
358 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
359 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
360 |
|
141 | 361 |
implicitSelfSends |
362 |
"return true if undefined variables with |
|
363 |
lowercase first character are to be turned |
|
364 |
into implicit self sends" |
|
365 |
||
366 |
^ ImplicitSelfSends |
|
367 |
! |
|
368 |
||
369 |
implicitSelfSends:aBoolean |
|
370 |
"turn on/off implicit self sends" |
|
371 |
||
372 |
ImplicitSelfSends := aBoolean |
|
373 |
||
374 |
" |
|
375 |
Compiler implicitSelfSends:true |
|
376 |
Compiler implicitSelfSends:false |
|
377 |
" |
|
377 | 378 |
! |
379 |
||
380 |
lineNumberInfo |
|
381 |
^ LineNumberInfo |
|
382 |
! |
|
383 |
||
384 |
lineNumberInfo:aBoolean |
|
385 |
LineNumberInfo := aBoolean |
|
752 | 386 |
! |
387 |
||
388 |
stringsAreImmutable |
|
389 |
"return true if strings are immutable literals" |
|
390 |
||
391 |
^ StringsAreImmutable |
|
392 |
||
393 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
394 |
! |
|
395 |
||
396 |
stringsAreImmutable:aBoolean |
|
397 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
398 |
||
399 |
StringsAreImmutable := aBoolean. |
|
400 |
||
401 |
" |
|
402 |
can be added to your private.rc file: |
|
403 |
||
404 |
Compiler stringsAreImmutable:true |
|
405 |
Compiler stringsAreImmutable:false |
|
406 |
" |
|
407 |
||
408 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
19 | 409 |
! ! |
0 | 410 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
411 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
412 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
413 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
414 |
"return the maximum lineNumber that is possibly |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
415 |
encoded in a methods byteCode debugging information. |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
416 |
Since lineNumber entries only have 1 byte available, |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
417 |
this is 255 for byteCode methods." |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
418 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
419 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
420 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
421 |
"Created: 14.2.1997 / 16:52:54 / cg" |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
422 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
423 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
424 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 425 |
|
19 | 426 |
evaluate:aStringOrStream |
71 | 427 |
"return the result of evaluating an expression in aStringOrStream. |
428 |
No doit-entry is added to the changeLog." |
|
0 | 429 |
|
19 | 430 |
^ self |
44 | 431 |
evaluate:aStringOrStream |
432 |
in:nil |
|
433 |
receiver:nil |
|
434 |
notifying:nil |
|
435 |
logged:false |
|
436 |
ifFail:nil |
|
71 | 437 |
compile:true |
19 | 438 |
|
439 |
" |
|
440 |
Compiler evaluate:'1 + 2' |
|
441 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
442 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
443 |
" |
|
0 | 444 |
! |
445 |
||
71 | 446 |
evaluate:aStringOrStream compile:compile |
447 |
"return the result of evaluating aString, |
|
448 |
The compile argument specifies if the string should be compiled down to |
|
449 |
bytecode or instead be interpreted from the parseTree. |
|
450 |
The first should be done for doIts etc, where a readable walkback is |
|
451 |
required. |
|
452 |
The latter is better done for constants, styleSheet and resource |
|
453 |
reading and simple sends, where the overhead of compilation is bigger |
|
454 |
than the interpretation overhead." |
|
455 |
||
456 |
^ self |
|
457 |
evaluate:aStringOrStream |
|
458 |
in:nil |
|
459 |
receiver:nil |
|
460 |
notifying:nil |
|
461 |
logged:false |
|
462 |
ifFail:nil |
|
463 |
compile:compile |
|
464 |
! |
|
465 |
||
20 | 466 |
evaluate:aStringOrStream ifFail:failBlock |
467 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 468 |
In case of any syntax errors, return the value of failBlock. |
469 |
No doit-entry is added to the changeLog." |
|
20 | 470 |
|
471 |
^ self |
|
44 | 472 |
evaluate:aStringOrStream |
473 |
in:nil |
|
474 |
receiver:nil |
|
475 |
notifying:nil |
|
476 |
logged:false |
|
477 |
ifFail:failBlock |
|
71 | 478 |
compile:true |
20 | 479 |
" |
480 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
481 |
" |
|
482 |
! |
|
483 |
||
71 | 484 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
485 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
486 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
487 |
No doIt entry is added to the change-file. |
|
488 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
489 |
||
490 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
491 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
492 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
493 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
494 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
495 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
496 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
497 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
498 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
499 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 500 |
! |
501 |
||
502 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
503 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
504 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
505 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
506 |
is non-nil, it is evaluated if an error occurs." |
|
507 |
||
71 | 508 |
^ self |
509 |
evaluate:aStringOrStream |
|
510 |
in:aContext |
|
511 |
receiver:anObject |
|
512 |
notifying:requestor |
|
513 |
logged:logged |
|
514 |
ifFail:failBlock |
|
515 |
compile:true |
|
516 |
! |
|
517 |
||
518 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
519 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
520 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
521 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
522 |
is non-nil, it is evaluated if an error occurs. |
|
523 |
Finally, compile specifies if the string should be compiled down to |
|
524 |
bytecode or instead be interpreted from the parseTree. |
|
525 |
The first should be done for doIts etc, where a readable walkback is |
|
526 |
required. |
|
527 |
The latter is better done for constants, styleSheet and resource |
|
528 |
reading and simple sends, where the overhead of compilation is bigger |
|
529 |
than the interpretation overhead." |
|
530 |
||
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
531 |
|parser tree mustBackup loggedString chgStream value s sReal spc| |
0 | 532 |
|
619 | 533 |
aStringOrStream isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
534 |
EmptySourceNotificationSignal raiseRequest. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
535 |
^ nil |
619 | 536 |
]. |
493
77e0d6979865
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
492
diff
changeset
|
537 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
538 |
s := aStringOrStream. |
0 | 539 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
540 |
loggedString := aStringOrStream. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
541 |
s := ReadStream on:aStringOrStream. |
0 | 542 |
]. |
260 | 543 |
parser := self for:s. |
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
544 |
parser parseForCode. |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
545 |
parser foldConstants:nil. |
0 | 546 |
parser setSelf:anObject. |
547 |
parser setContext:aContext. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
548 |
aContext notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
549 |
parser setSelf:(aContext receiver) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
550 |
]. |
0 | 551 |
parser notifying:requestor. |
552 |
parser nextToken. |
|
79 | 553 |
tree := parser parseMethodBodyOrEmpty. |
0 | 554 |
|
555 |
"if reading from a stream, backup for next expression" |
|
556 |
mustBackup ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
557 |
parser backupPosition |
0 | 558 |
]. |
559 |
||
560 |
(parser errorFlag or:[tree == #Error]) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
561 |
failBlock notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
562 |
^ failBlock value |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
563 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
564 |
^ #Error |
619 | 565 |
]. |
566 |
||
567 |
tree isNil ifTrue:[ |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
568 |
EmptySourceNotificationSignal raiseRequest. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
569 |
^ nil |
619 | 570 |
]. |
571 |
||
572 |
(logged |
|
573 |
and:[loggedString notNil |
|
574 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
575 |
Class updateChangeFileQuerySignal query ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
576 |
chgStream := Class changesStream. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
577 |
chgStream notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
578 |
chgStream nextChunkPut:loggedString. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
579 |
chgStream cr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
580 |
chgStream close |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
581 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
582 |
]. |
619 | 583 |
]. |
584 |
||
585 |
" |
|
586 |
during the evaluation, handle nameSpace queries |
|
587 |
from the value as defined by any namespace directive. |
|
588 |
This, if its a class definition expression, the class will |
|
589 |
be installed there. |
|
590 |
" |
|
591 |
spc := parser getNameSpace. |
|
592 |
spc isNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
593 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
594 |
spc := requestor currentNameSpace |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
595 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
596 |
spc := Class nameSpaceQuerySignal query. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
597 |
] |
0 | 598 |
]. |
260 | 599 |
|
619 | 600 |
Class nameSpaceQuerySignal answer:spc |
601 |
do:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
602 |
|method| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
603 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
604 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
605 |
if compile is false, or the parse tree is that of a constant, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
606 |
or a variable, quickly return its value. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
607 |
This is used for example, when reading simple objects |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
608 |
via #readFrom:. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
609 |
The overhead of compiling a method is avoided in this case. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
610 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
611 |
((SuppressDoItCompilation == true) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
612 |
or:[compile not |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
613 |
or:[tree isConstant |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
614 |
or:[tree isVariable |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
615 |
or:[aStringOrStream isStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
616 |
or:[aContext notNil]]]]]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
617 |
^ tree evaluate |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
618 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
619 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
620 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
621 |
if I am the ByteCodeCompiler, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
622 |
generate a dummy method, execute it and return the value. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
623 |
otherwise, just evaluate the tree; slower, but not too bad ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
624 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
625 |
This allows systems to be delivered without the ByteCodeCompiler, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
626 |
and still evaluate expressions |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
627 |
(needed to read resource files or to process .rc files). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
628 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
629 |
self == Parser ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
630 |
parser evalExitBlock:[:value | parser release. ^ value]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
631 |
value := tree evaluate. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
632 |
parser evalExitBlock:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
633 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
634 |
aStringOrStream isStream ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
635 |
s := parser collectedSource. "/ does not work yet ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
636 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
637 |
s := aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
638 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
639 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
640 |
"/ actually, its a block, to allow |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
641 |
"/ easy return ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
642 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
643 |
sReal := 'doIt ^[\' withCRs , s , '\] value' withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
644 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
645 |
method := self |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
646 |
compile:sReal |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
647 |
forClass:anObject class |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
648 |
inCategory:'_temporary_' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
649 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
650 |
install:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
651 |
skipIfSame:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
652 |
silent:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
653 |
foldConstants:false. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
654 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
655 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
656 |
method ~~ #Error ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
657 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
658 |
fake: patch the source string, to what the user expects |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
659 |
in the browser |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
660 |
" |
688
4079c5dd2dca
doIt method should have no emphasis
Claus Gittinger <cg@exept.de>
parents:
687
diff
changeset
|
661 |
method source:' \' withCRs , s string. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
662 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
663 |
dont do any just-in-time compilation on it. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
664 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
665 |
method checked:true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
666 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
667 |
value := method |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
668 |
valueWithReceiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
669 |
arguments:nil "/ (Array with:m) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
670 |
selector:#doIt "/ #doIt: |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
671 |
search:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
672 |
sender:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
673 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
674 |
parser evalExitBlock:[:value | parser release. ^ value]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
675 |
value := tree evaluate. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
676 |
parser evalExitBlock:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
677 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
678 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
679 |
] |
0 | 680 |
]. |
35 | 681 |
parser release. |
682 |
^ value |
|
260 | 683 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
684 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
688
4079c5dd2dca
doIt method should have no emphasis
Claus Gittinger <cg@exept.de>
parents:
687
diff
changeset
|
685 |
"Modified: / 16.4.1998 / 23:30:33 / cg" |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
686 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
141 | 687 |
! |
688 |
||
689 |
evaluate:aStringOrStream logged:logged |
|
690 |
"return the result of evaluating an expression in aStringOrStream. |
|
691 |
The argument log controls if an entry is added to the changeLog." |
|
692 |
||
693 |
^ self |
|
694 |
evaluate:aStringOrStream |
|
695 |
in:nil |
|
696 |
receiver:nil |
|
697 |
notifying:nil |
|
698 |
logged:logged |
|
699 |
ifFail:nil |
|
700 |
compile:true |
|
701 |
" |
|
702 |
Compiler evaluate:'''some string''' logged:false |
|
703 |
Compiler evaluate:'''some string''' logged:true |
|
704 |
" |
|
705 |
! |
|
706 |
||
707 |
evaluate:aStringOrStream notifying:requestor |
|
708 |
"return the result of evaluating aString, |
|
709 |
errors are reported to requestor" |
|
710 |
||
711 |
^ self |
|
712 |
evaluate:aStringOrStream |
|
713 |
in:nil |
|
714 |
receiver:nil |
|
715 |
notifying:requestor |
|
716 |
logged:false |
|
717 |
ifFail:nil |
|
718 |
compile:true |
|
719 |
! |
|
720 |
||
721 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
722 |
"return the result of evaluating aString, |
|
723 |
errors are reported to requestor. |
|
724 |
The compile argument specifies if the string should be compiled down to |
|
725 |
bytecode or instead be interpreted from the parseTree. |
|
726 |
The first should be done for doIts etc, where a readable walkback is |
|
727 |
required. |
|
728 |
The latter is better done for constants, styleSheet and resource |
|
729 |
reading and simple sends, where the overhead of compilation is bigger |
|
730 |
than the interpretation overhead." |
|
731 |
||
732 |
^ self |
|
733 |
evaluate:aStringOrStream |
|
734 |
in:nil |
|
735 |
receiver:nil |
|
736 |
notifying:requestor |
|
737 |
logged:false |
|
738 |
ifFail:nil |
|
739 |
compile:compile |
|
740 |
! |
|
741 |
||
572 | 742 |
evaluate:aStringOrStream receiver:anObject |
743 |
"return the result of evaluating aString, |
|
744 |
errors are reported to requestor. Allow access to |
|
745 |
anObject as self and to its instVars " |
|
746 |
||
747 |
^ self |
|
619 | 748 |
evaluate:aStringOrStream |
749 |
in:nil |
|
750 |
receiver:anObject |
|
751 |
notifying:nil |
|
752 |
logged:false |
|
753 |
ifFail:nil |
|
754 |
compile:true |
|
572 | 755 |
|
756 |
" |
|
757 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
758 |
" |
|
759 |
||
760 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
761 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
762 |
! |
|
763 |
||
141 | 764 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
765 |
"return the result of evaluating aString, |
|
766 |
errors are reported to requestor. Allow access to |
|
767 |
anObject as self and to its instVars (used in the inspector)" |
|
768 |
||
769 |
^ self |
|
770 |
evaluate:aStringOrStream |
|
771 |
in:nil |
|
772 |
receiver:anObject |
|
773 |
notifying:requestor |
|
774 |
logged:false |
|
775 |
ifFail:nil |
|
776 |
compile:true |
|
777 |
||
778 |
" |
|
779 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
780 |
" |
|
781 |
! |
|
782 |
||
783 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
784 |
"return the result of evaluating aString, |
|
785 |
errors are reported to requestor. Allow access to |
|
786 |
anObject as self and to its instVars (used in the inspector). |
|
787 |
The compile argument specifies if the string should be compiled down to |
|
788 |
bytecode or instead be interpreted from the parseTree. |
|
789 |
The first should be done for doIts etc, where a readable walkback is |
|
790 |
required. |
|
791 |
The latter is better done for constants, styleSheet and resource |
|
792 |
reading and simple sends, where the overhead of compilation is bigger |
|
793 |
than the interpretation overhead." |
|
794 |
||
795 |
^ self |
|
796 |
evaluate:aStringOrStream |
|
797 |
in:nil |
|
798 |
receiver:anObject |
|
799 |
notifying:requestor |
|
800 |
logged:false |
|
801 |
ifFail:nil |
|
802 |
compile:compile |
|
0 | 803 |
! ! |
804 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
805 |
!Parser class methodsFor:'general helpers'! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
806 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
807 |
argAndVarNamesForContext:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
808 |
"helper: given a context, return a collection of arg&var names" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
809 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
810 |
|homeContext method numArgs numVars m src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
811 |
blockNode argNames varNames vars sel isDoIt| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
812 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
813 |
numArgs := aContext numArgs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
814 |
numVars := aContext numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
815 |
(numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
816 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
817 |
homeContext := aContext methodHome. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
818 |
sel := homeContext selector. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
819 |
method := homeContext method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
820 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
821 |
"/ #doIt needs special handling below |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
822 |
isDoIt := (sel == #doIt) or:[sel == #doIt:]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
823 |
aContext isBlockContext ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
824 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
825 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
826 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
827 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
828 |
src := ('[' , method source , '\]') withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
829 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
830 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
831 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
832 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
833 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
834 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
835 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
836 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
837 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
838 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
839 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
840 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
841 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
842 |
argNames := vars collect:[:var | var name] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
843 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
844 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
845 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
846 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
847 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
848 |
varNames := vars collect:[:var | var name]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
849 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
850 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
851 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
852 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
853 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
854 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
855 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
856 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
857 |
^ method methodArgAndVarNames. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
858 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
859 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
860 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
861 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
862 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
863 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
864 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
865 |
"/ my source is found in the method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
866 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
867 |
src := ('[' , method source , '\]') withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
868 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
869 |
m := method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
870 |
src := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
871 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
872 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
873 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
874 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
875 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
876 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
877 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
878 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
879 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
880 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
881 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
882 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
883 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
884 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
885 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
886 |
argNames := vars collect:[:var | var name] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
887 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
888 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
889 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
890 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
891 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
892 |
varNames := vars collect:[:var | var name]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
893 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
894 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
895 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
896 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
897 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
898 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
899 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
900 |
"Created: / 17.1.1998 / 03:18:05 / cg" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
901 |
"Modified: / 17.1.1998 / 03:55:44 / cg" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
902 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
903 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
904 |
!Parser class methodsFor:'parsing'! |
141 | 905 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
906 |
blockAtLine:line in:aMethod orSource:aString numArgs:nA numVars:nV |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
907 |
"given a lineNr in some method, |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
908 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
909 |
The given lineNr must be within a block for this to work. |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
910 |
This is used by the debugger, to guess reverse from a lineNumber, |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
911 |
to the corresponding block, in order to find out the blocks |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
912 |
variable names (mhmh - all of this wasnt't needed, if blocks stored |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
913 |
their characterPosition internally)." |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
914 |
|
429 | 915 |
|compiler tree mSource who mClass blocks |
397 | 916 |
maxSoFar innerBlock m| |
917 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
918 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 919 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
920 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
921 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
922 |
aMethod notNil ifTrue:[ |
815 | 923 |
m := aMethod. |
924 |
who := m who. |
|
925 |
who isNil ifTrue:[ |
|
926 |
m isWrapped ifTrue:[ |
|
927 |
m := m wrapper. |
|
928 |
m notNil ifTrue:[ |
|
929 |
who := m who. |
|
930 |
] |
|
931 |
] |
|
932 |
]. |
|
933 |
who notNil ifTrue:[ |
|
934 |
mClass := who methodClass. |
|
935 |
mClass isNil ifTrue:[ ^ nil]. |
|
936 |
]. |
|
937 |
||
938 |
mSource := m source. |
|
939 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
940 |
] ifFalse:[ |
815 | 941 |
aString notNil ifTrue:[ |
942 |
mSource := aString. |
|
943 |
mClass := UndefinedObject |
|
944 |
] ifFalse:[ |
|
945 |
^ nil |
|
946 |
] |
|
397 | 947 |
]. |
948 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
949 |
"create a compiler, let it parse and create the parsetree" |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
950 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
951 |
compiler := self for:(ReadStream on:mSource) in:mClass. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
952 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
953 |
compiler notifying:nil. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
954 |
compiler ignoreWarnings. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
955 |
compiler ignoreErrors. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
956 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
957 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
958 |
aMethod notNil ifTrue:[ |
815 | 959 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
960 |
^ nil. |
|
961 |
]. |
|
962 |
||
963 |
who notNil ifTrue:[ |
|
964 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
965 |
^ nil |
|
966 |
] |
|
967 |
]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
968 |
] ifFalse:[ |
815 | 969 |
compiler nextToken. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
970 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
971 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
972 |
tree := compiler parseMethodBody. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
973 |
|
815 | 974 |
(compiler errorFlag |
975 |
or:[tree == #Error |
|
976 |
or:[tree isNil]]) ifTrue:[ |
|
977 |
^ nil |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
978 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
979 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
980 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
981 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
982 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
983 |
blocks := blocks select:[:aBlock | |
815 | 984 |
line between: aBlock lineNumber and:aBlock endLineNumber |
985 |
||
986 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
987 |
blocks size == 1 ifTrue:[ |
815 | 988 |
^ blocks at:1 |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
989 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
990 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
991 |
nA notNil ifTrue:[ |
815 | 992 |
blocks := blocks select:[:aBlock | |
993 |
aBlock numArgs == nA |
|
994 |
]. |
|
995 |
blocks size == 1 ifTrue:[ |
|
996 |
^ blocks at:1 |
|
997 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
998 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
999 |
nV notNil ifTrue:[ |
815 | 1000 |
blocks := blocks select:[:aBlock | |
1001 |
aBlock numVars == nV |
|
1002 |
]. |
|
1003 |
blocks size == 1 ifTrue:[ |
|
1004 |
^ blocks at:1 |
|
1005 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1006 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1007 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1008 |
"/ look for the inner one |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1009 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1010 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1011 |
blocks do:[:aBlock | |
815 | 1012 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1013 |
innerBlock := aBlock. |
|
1014 |
maxSoFar := aBlock lineNumber |
|
1015 |
] |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1016 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1017 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1018 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1019 |
"Created: 11.1.1997 / 23:29:13 / cg" |
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1020 |
"Modified: 14.2.1997 / 16:51:25 / cg" |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1021 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1022 |
|
629 | 1023 |
checkMethod:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
1024 |
"parse a method in a given class. |
|
1025 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1026 |
The parser can be queried for selector, receiver, args, locals, |
|
1027 |
used selectors, modified instvars, referenced classvars etc. |
|
1028 |
The noErrors and noWarnings arguments specify if error and warning |
|
1029 |
messages should be sent to the Transcript or suppressed." |
|
1030 |
||
1031 |
|parser tree| |
|
1032 |
||
1033 |
aString isNil ifTrue:[^ nil]. |
|
1034 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1035 |
noErrors ifTrue:[ |
|
1036 |
parser ignoreErrors |
|
1037 |
]. |
|
1038 |
noWarnings ifTrue:[ |
|
1039 |
parser ignoreWarnings |
|
1040 |
]. |
|
1041 |
tree := parser parseMethod. |
|
1042 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1043 |
||
1044 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1045 |
||
1046 |
" |
|
1047 |
self |
|
1048 |
checkMethod:'foo |
|
1049 |
|local1 local2 local3| |
|
1050 |
||
1051 |
local1 := local2. |
|
1052 |
^ local3 |
|
1053 |
' |
|
1054 |
in:UndefinedObject |
|
1055 |
ignoreErrors:true |
|
1056 |
ignoreWarnings:true |
|
1057 |
" |
|
1058 |
||
1059 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1060 |
! |
|
1061 |
||
141 | 1062 |
parseExpression:aString |
1063 |
"parse aString as an expression; |
|
1064 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1065 |
or comment only) or #Error (syntactic error). |
1066 |
Error and warning messages are suppressed." |
|
141 | 1067 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1068 |
^ self |
619 | 1069 |
withSelf:nil |
1070 |
parseExpression:aString |
|
1071 |
notifying:nil |
|
1072 |
ignoreErrors:true "silence on Transcript" |
|
1073 |
ignoreWarnings:true |
|
1074 |
inNameSpace:nil |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1075 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1076 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1077 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1078 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1079 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1080 |
"parse aString as an expression; |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1081 |
Return the parseTree (if ok), nil (for an empty string |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1082 |
or comment only) or #Error (syntactic error). |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1083 |
Error and warning messages are suppressed." |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1084 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1085 |
^ self |
619 | 1086 |
withSelf:nil |
1087 |
parseExpression:aString |
|
1088 |
notifying:nil |
|
1089 |
ignoreErrors:true "silence on Transcript" |
|
1090 |
ignoreWarnings:true |
|
1091 |
inNameSpace:aNameSpaceOrNil |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1092 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1093 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1094 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1095 |
! |
1096 |
||
1097 |
parseMethod:aString |
|
1098 |
"parse a method. |
|
1099 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1100 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1101 |
used selectors etc. |
1102 |
Error and warning messages are sent to the Transcript." |
|
141 | 1103 |
|
1104 |
^ self parseMethod:aString in:nil |
|
1105 |
||
1106 |
" |
|
1107 |
|p| |
|
1108 |
||
1109 |
p := Parser |
|
619 | 1110 |
parseMethod:' |
1111 |
foo:arg1 bar:arg2 baz:arg3 |
|
1112 |
|l1 l2| |
|
1113 |
l1 := 0. |
|
1114 |
l2 := arg1. |
|
1115 |
^ self'. |
|
141 | 1116 |
|
1117 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1118 |
'args: ' print. p methodArgs printNL. |
|
1119 |
'sel: ' print. p selector printNL. |
|
1120 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1121 |
'locals: ' print. p methodVars printNL. |
|
1122 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1123 |
" |
|
258 | 1124 |
|
1125 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1126 |
! |
1127 |
||
1128 |
parseMethod:aString in:aClass |
|
1129 |
"parse a method in a given class. |
|
1130 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1131 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1132 |
used selectors, modified instvars, referenced classvars etc. |
1133 |
Error and warning messages are sent to the Transcript." |
|
141 | 1134 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1135 |
^ self |
619 | 1136 |
parseMethod:aString |
1137 |
in:aClass |
|
1138 |
ignoreErrors:false |
|
1139 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1140 |
|
258 | 1141 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1142 |
! |
1143 |
||
1144 |
parseMethod:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
|
1145 |
"parse a method in a given class. |
|
1146 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1147 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1148 |
used selectors, modified instvars, referenced classvars etc. |
1149 |
The noErrors and noWarnings arguments specify if error and warning |
|
1150 |
messages should be sent to the Transcript or suppressed." |
|
141 | 1151 |
|
1152 |
|parser tree| |
|
1153 |
||
1154 |
aString isNil ifTrue:[^ nil]. |
|
1155 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1156 |
noErrors ifTrue:[ |
|
619 | 1157 |
parser ignoreErrors |
141 | 1158 |
]. |
1159 |
noWarnings ifTrue:[ |
|
619 | 1160 |
parser ignoreWarnings |
141 | 1161 |
]. |
1162 |
tree := parser parseMethod. |
|
1163 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1164 |
^ parser |
|
258 | 1165 |
|
1166 |
"Modified: 24.4.1996 / 13:19:23 / cg" |
|
141 | 1167 |
! |
1168 |
||
1169 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1170 |
"parse a method in a given class. |
|
1171 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1172 |
The parser can be queried for selector, receiver, args, locals, |
|
1173 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1174 |
The warnBoolean arguments specifies if warning |
1175 |
messages should be sent to the Transcript or suppressed. |
|
1176 |
||
1177 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1178 |
||
1179 |
self obsoleteMethodWarning. |
|
141 | 1180 |
^ self |
619 | 1181 |
parseMethod:aString |
1182 |
in:aClass |
|
1183 |
ignoreErrors:false |
|
1184 |
ignoreWarnings:warnBoolean not |
|
258 | 1185 |
|
1186 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1187 |
! |
1188 |
||
1189 |
parseMethodArgAndVarSpecification:aString |
|
1190 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1191 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1192 |
The parser can be queried for selector, receiver etc. |
1193 |
Error and warning messages are sent to the Transcript. |
|
1194 |
This method is OBSOLETE." |
|
1195 |
||
1196 |
self obsoleteMethodWarning. |
|
141 | 1197 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1198 |
||
1199 |
" |
|
1200 |
|p| |
|
1201 |
||
1202 |
p := Parser |
|
619 | 1203 |
parseMethodArgAndVarSpecification:' |
1204 |
foo:arg1 bar:arg2 baz:arg3 |
|
1205 |
|l1 l2|'. |
|
141 | 1206 |
|
1207 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1208 |
'args: ' print. p methodArgs printNL. |
|
1209 |
'sel: ' print. p selector printNL. |
|
1210 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1211 |
'locals: ' print. p methodVars printNL. |
|
1212 |
" |
|
258 | 1213 |
|
1214 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1215 |
! |
1216 |
||
1217 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1218 |
"parse a methods selector, arg and var spec in a given class; |
|
1219 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1220 |
The parser can be queried for selector, receiver, args and locals. |
1221 |
Error and warning messages are sent to the Transcript. |
|
1222 |
This method is OBSOLETE." |
|
1223 |
||
1224 |
self obsoleteMethodWarning. |
|
141 | 1225 |
^ self parseMethodArgAndVarSpecification:aString |
619 | 1226 |
in:aClass |
1227 |
ignoreErrors:false |
|
1228 |
ignoreWarnings:false |
|
1229 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1230 |
|
258 | 1231 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1232 |
! |
1233 |
||
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1234 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings parseBody:body |
141 | 1235 |
"parse a methods selector, arg and var spec in a given class; |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1236 |
If parseBody is true, also parse the statements |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1237 |
(for primitives & resourceSpecs). |
258 | 1238 |
The noErrors and noWarnings arguments specify if error and warning |
1239 |
messages should be sent to the Transcript or suppressed. |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1240 |
|
141 | 1241 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1242 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1243 |
|
0 | 1244 |
|parser| |
1245 |
||
141 | 1246 |
aString isNil ifTrue:[^ nil]. |
1247 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1248 |
noErrors ifTrue:[ |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1249 |
parser ignoreErrors |
141 | 1250 |
]. |
1251 |
noWarnings ifTrue:[ |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1252 |
parser ignoreWarnings |
141 | 1253 |
]. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1254 |
"/ parser nextToken. |
141 | 1255 |
(parser parseMethodSpec == #Error) ifTrue:[^ nil]. |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1256 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1257 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1258 |
"/ - now, alternatively parse body for resource & primitive specs .. |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1259 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1260 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1261 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1262 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1263 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1264 |
]. |
141 | 1265 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1266 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1267 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1268 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1269 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1270 |
! |
1271 |
||
1272 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1273 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1274 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1275 |
The parser can be queried for selector, receiver etc. |
|
258 | 1276 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1277 |
display error/warning messages on the transcript." |
1278 |
||
1279 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1280 |
|
1281 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1282 |
! |
1283 |
||
1284 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1285 |
"parse a methods selector, arg and var spec in a given class; |
|
1286 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1287 |
The parser can be queried for selector, receiver, args and locals. |
|
1288 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1289 |
display error/warning messages on the transcript." |
|
1290 |
||
1291 |
^ self parseMethodArgAndVarSpecification:aString |
|
619 | 1292 |
in:aClass |
1293 |
ignoreErrors:true |
|
1294 |
ignoreWarnings:true |
|
1295 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1296 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1297 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1298 |
! |
1299 |
||
1300 |
parseMethodSilent:aString |
|
1301 |
"parse a method. |
|
1302 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1303 |
The parser can be queried for selector, receiver, args, locals, |
|
1304 |
used selectors etc. |
|
258 | 1305 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1306 |
|
1307 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1308 |
|
1309 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1310 |
! |
1311 |
||
1312 |
parseMethodSilent:aString in:aClass |
|
1313 |
"parse a method in a given class. |
|
1314 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1315 |
The parser can be queried for selector, receiver, args, locals, |
|
1316 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1317 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1318 |
||
1319 |
^ self |
|
619 | 1320 |
parseMethod:aString |
1321 |
in:aClass |
|
1322 |
ignoreErrors:true |
|
1323 |
ignoreWarnings:true |
|
258 | 1324 |
|
1325 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1326 |
! |
1327 |
||
1328 |
parseMethodSpecification:aString |
|
1329 |
"parse a methods selector & arg specification; |
|
1330 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1331 |
The parser can be queried for selector, receiver etc." |
|
1332 |
||
1333 |
^ self parseMethodSpecification:aString in:nil |
|
1334 |
||
1335 |
" |
|
1336 |
|p| |
|
1337 |
||
1338 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1339 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1340 |
'args: ' print. p methodArgs printNL. |
|
1341 |
'sel: ' print. p selector printNL |
|
1342 |
" |
|
1343 |
! |
|
1344 |
||
1345 |
parseMethodSpecification:aString in:aClass |
|
1346 |
"parse a methods selector & arg spec for a given class; |
|
1347 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1348 |
The parser can be queried for selector, receiver etc." |
|
1349 |
||
1350 |
^ self parseMethodSpecification:aString |
|
1351 |
in:aClass |
|
1352 |
ignoreErrors:false |
|
1353 |
ignoreWarnings:false |
|
1354 |
! |
|
1355 |
||
1356 |
parseMethodSpecification:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
|
1357 |
"parse a methods selector & arg spec for a given class; |
|
1358 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1359 |
The parser can be queried for selector, receiver etc. |
|
1360 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1361 |
to be output onto the Transcript." |
|
1362 |
||
1363 |
|parser tree| |
|
1364 |
||
1365 |
aString isNil ifTrue:[^ nil]. |
|
1366 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1367 |
noErrors ifTrue:[ |
|
619 | 1368 |
parser ignoreErrors |
141 | 1369 |
]. |
1370 |
noWarnings ifTrue:[ |
|
619 | 1371 |
parser ignoreWarnings |
141 | 1372 |
]. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1373 |
"/ parser nextToken. |
141 | 1374 |
tree := parser parseMethodSpec. |
1375 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1376 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1377 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1378 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1379 |
! |
1380 |
||
1381 |
parseMethodSpecificationSilent:aString |
|
1382 |
"parse a methods selector & arg specification; |
|
1383 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1384 |
The parser can be queried for selector, receiver etc. |
|
1385 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1386 |
||
1387 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1388 |
! |
|
1389 |
||
1390 |
parseMethodSpecificationSilent:aString in:aClass |
|
1391 |
"parse a methods selector & arg spec for a given class; |
|
1392 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1393 |
The parser can be queried for selector, receiver etc. |
|
1394 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1395 |
||
1396 |
^ self parseMethodSpecification:aString |
|
1397 |
in:aClass |
|
1398 |
ignoreErrors:true |
|
1399 |
ignoreWarnings:true |
|
1400 |
||
1401 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1402 |
! |
|
0 | 1403 |
|
7 | 1404 |
selectorInExpression:aString |
47 | 1405 |
"parse an expression - return the selector. Even malformed expressions |
1406 |
(such as missing receiver or missing arg are parsed. |
|
1407 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1408 |
Returns nil if unparsable." |
7 | 1409 |
|
1410 |
|tree parser| |
|
1411 |
||
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1412 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1413 |
|
21 | 1414 |
tree := self withSelf:nil |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1415 |
parseExpression:aString |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1416 |
notifying:nil |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1417 |
ignoreErrors:true |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1418 |
ignoreWarnings:true. |
21 | 1419 |
|
1420 |
" |
|
1421 |
special: take the expression of the right side, if its an |
|
1422 |
assignment or return |
|
1423 |
" |
|
7 | 1424 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1425 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1426 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1427 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1428 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1429 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1430 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1431 |
|
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1432 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1433 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1434 |
]. |
7 | 1435 |
]. |
1436 |
||
21 | 1437 |
" |
1438 |
mhmh, try expression without receiver |
|
1439 |
" |
|
7 | 1440 |
parser := self for:(ReadStream on:aString). |
1441 |
parser ignoreErrors. |
|
1442 |
parser nextToken. |
|
1443 |
^ parser degeneratedKeywordExpressionForSelector |
|
1444 |
||
1445 |
" |
|
20 | 1446 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1447 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1448 |
Parser selectorInExpression:'a + 4' |
1449 |
Parser selectorInExpression:'a negated' |
|
20 | 1450 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1451 |
Parser selectorInExpression:'at:1 put:' |
1452 |
Parser selectorInExpression:'a at:1 put:5' |
|
1453 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1454 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1455 |
" |
451 | 1456 |
|
1457 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1458 |
! |
1459 |
||
1460 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1461 |
"parse aString as an expression with self set to anObject; |
|
21 | 1462 |
Return the parseTree (if ok), nil (for an empty string |
1463 |
or comment only ) or #Error (syntactic error). |
|
1464 |
||
1465 |
Errors and warnings are forwarded to someOne (usually some |
|
1466 |
codeView) which can highlight it and show a popup box." |
|
7 | 1467 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1468 |
^ self |
619 | 1469 |
withSelf:anObject |
1470 |
parseExpression:aString |
|
1471 |
notifying:someOne |
|
1472 |
ignoreErrors:false |
|
1473 |
ignoreWarnings:false |
|
1474 |
inNameSpace:nil |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1475 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1476 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1477 |
! |
1478 |
||
1479 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1480 |
"parse aString as an expression with self set to anObject; |
21 | 1481 |
Return the parseTree (if ok), nil (for an empty string |
1482 |
or comment only ) or #Error (syntactic error). |
|
1483 |
||
1484 |
Errors and warnings are forwarded to someOne (usually some |
|
1485 |
codeView) which can highlight it and show a popup box." |
|
1486 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1487 |
^ self |
619 | 1488 |
withSelf:anObject |
1489 |
parseExpression:aString |
|
1490 |
notifying:someOne |
|
1491 |
ignoreErrors:ignore |
|
1492 |
ignoreWarnings:ignore |
|
1493 |
inNameSpace:nil |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1494 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1495 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1496 |
! |
1497 |
||
1498 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1499 |
"parse aString as an expression with self set to anObject; |
|
1500 |
Return the parseTree (if ok), nil (for an empty string |
|
1501 |
or comment only ) or #Error (syntactic error). |
|
1502 |
||
1503 |
Errors and warnings are forwarded to someOne (usually some |
|
1504 |
codeView) which can highlight it and show a popup box, |
|
1505 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1506 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1507 |
^ self |
619 | 1508 |
withSelf:anObject |
1509 |
parseExpression:aString |
|
1510 |
notifying:someOne |
|
1511 |
ignoreErrors:ignoreErrors |
|
1512 |
ignoreWarnings:ignoreWarnings |
|
1513 |
inNameSpace:nil |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1514 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1515 |
"Modified: 24.6.1997 / 16:43:12 / cg" |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1516 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1517 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1518 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1519 |
"parse aString as an expression with self set to anObject; |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1520 |
Return the parseTree (if ok), nil (for an empty string |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1521 |
or comment only ) or #Error (syntactic error). |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1522 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1523 |
Errors and warnings are forwarded to someOne (usually some |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1524 |
codeView) which can highlight it and show a popup box, |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1525 |
iff ignoreErrors/ignoreWarnings is true respectively." |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1526 |
|
35 | 1527 |
|parser tree token| |
0 | 1528 |
|
1529 |
aString isNil ifTrue:[^ nil]. |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1530 |
|
0 | 1531 |
parser := self for:(ReadStream on:aString). |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1532 |
aNameSpaceOrNil notNil ifTrue:[ |
619 | 1533 |
parser currentNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1534 |
]. |
0 | 1535 |
parser setSelf:anObject. |
1536 |
parser notifying:someOne. |
|
21 | 1537 |
ignoreErrors ifTrue:[parser ignoreErrors]. |
1538 |
ignoreWarnings ifTrue:[parser ignoreWarnings]. |
|
35 | 1539 |
token := parser nextToken. |
1540 |
(token == $^) ifTrue:[ |
|
619 | 1541 |
parser nextToken. |
35 | 1542 |
]. |
0 | 1543 |
tree := parser expression. |
1544 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1545 |
^ tree |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1546 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1547 |
"Created: 24.6.1997 / 16:42:14 / cg" |
0 | 1548 |
! ! |
1549 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1550 |
!Parser class methodsFor:'unparsing'! |
20 | 1551 |
|
1552 |
methodSpecificationForSelector:aSelector |
|
1553 |
"given a selector such as #foo:bar:, return a string that could |
|
1554 |
serve as a methods specification source code. |
|
1555 |
To be used for code generators" |
|
1556 |
||
807 | 1557 |
|argNames n| |
1558 |
||
1559 |
n := aSelector numArgs. |
|
1560 |
n == 1 ifTrue:[ |
|
1561 |
argNames := #('arg') |
|
1562 |
] ifFalse:[ |
|
1563 |
n <= 15 ifTrue:[ |
|
1564 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1565 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1566 |
'arg13' 'arg14' 'arg15') |
|
1567 |
] ifFalse:[ |
|
1568 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1569 |
]. |
|
1570 |
]. |
|
1571 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1572 |
||
20 | 1573 |
" |
807 | 1574 |
Parser methodSpecificationForSelector:#foo: |
20 | 1575 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1576 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1577 |
Parser methodSpecificationForSelector:#+ |
20 | 1578 |
Parser methodSpecificationForSelector:#negated |
1579 |
" |
|
807 | 1580 |
|
1581 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1582 |
! |
1583 |
||
1584 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1585 |
"given a selector such as #foo:bar:, return a string that could |
|
1586 |
serve as a methods specification source code. |
|
1587 |
To be used for code generators" |
|
1588 |
||
806 | 1589 |
|s nargs parts part| |
20 | 1590 |
|
1591 |
s := WriteStream on:String new. |
|
44 | 1592 |
nargs := aSelector numArgs. |
20 | 1593 |
nargs == 0 ifTrue:[ |
806 | 1594 |
s nextPutAll:aSelector |
20 | 1595 |
] ifFalse:[ |
806 | 1596 |
parts := aSelector partsIfSelector. |
1597 |
1 to:nargs do:[:i | |
|
1598 |
part := parts at:i. |
|
1599 |
s nextPutAll:part. |
|
1600 |
(part endsWith:$:) ifFalse:[ |
|
1601 |
s space. |
|
1602 |
]. |
|
1603 |
s nextPutAll:(argNames at:i). |
|
1604 |
i ~~ nargs ifTrue:[s space]. |
|
1605 |
] |
|
20 | 1606 |
]. |
1607 |
^ s contents |
|
1608 |
||
1609 |
" |
|
1610 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1611 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1612 |
Parser methodSpecificationForSelector:#negated |
|
1613 |
" |
|
806 | 1614 |
|
1615 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1616 |
! ! |
1617 |
||
0 | 1618 |
!Parser methodsFor:'ST-80 compatibility'! |
1619 |
||
1620 |
evaluate:aString in:aClass to:to notifying:aRequestor ifFail:failBlock |
|
35 | 1621 |
|parseTree value| |
0 | 1622 |
|
1623 |
aString isNil ifTrue:[^ nil]. |
|
1624 |
self initializeFor:(ReadStream on:aString). |
|
1625 |
self setClassToCompileFor:aClass. |
|
1626 |
selfValue := nil. |
|
1627 |
requestor := aRequestor. |
|
1628 |
||
1629 |
self nextToken. |
|
1630 |
parseTree := self parseMethodBody. |
|
1631 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1632 |
parseTree notNil ifTrue:[ |
|
44 | 1633 |
self evalExitBlock:[:value | ^ failBlock value]. |
1634 |
value := parseTree evaluate |
|
0 | 1635 |
]. |
35 | 1636 |
self release. |
1637 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1638 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1639 |
|
624 | 1640 |
parse:methodSource in:aClass notifying:aRequestor |
1641 |
"parse a methods source. |
|
1642 |
Return the methods parseTree" |
|
1643 |
||
1644 |
self initializeFor:methodSource. |
|
1645 |
classToCompileFor := aClass. |
|
1646 |
requestor := aRequestor. |
|
1647 |
self parseMethod. |
|
1648 |
^ MethodNode new |
|
1649 |
selector:selector |
|
1650 |
arguments:methodArgs |
|
1651 |
locals:methodVars |
|
1652 |
statements:tree |
|
1653 |
||
1654 |
"Created: 17.10.1997 / 12:35:01 / cg" |
|
1655 |
"Modified: 17.10.1997 / 12:40:34 / cg" |
|
1656 |
! |
|
1657 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1658 |
parseSelector:aStringOrStream |
624 | 1659 |
"parse a methods source for the methods selector. |
1660 |
Return the selector" |
|
1661 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1662 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1663 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1664 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1665 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1666 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1667 |
Parser new |
624 | 1668 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1669 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1670 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1671 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1672 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1673 |
' |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1674 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1675 |
|
624 | 1676 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1677 |
! ! |
1678 |
||
44 | 1679 |
!Parser methodsFor:'accessing'! |
1680 |
||
1681 |
correctedSource |
|
1682 |
^ correctedSource |
|
1683 |
! |
|
1684 |
||
141 | 1685 |
errorFlag |
1686 |
"return true if there where any errors (valid after parsing)" |
|
1687 |
||
1688 |
^ errorFlag |
|
1689 |
! |
|
1690 |
||
1691 |
evalExitBlock:aBlock |
|
1692 |
"when evaluating a return expression, this block is evaluated" |
|
1693 |
||
1694 |
evalExitBlock := aBlock |
|
1695 |
! |
|
1696 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1697 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1698 |
"retrieve the nameSpace, as found in a Namespace directive" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1699 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1700 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1701 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1702 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1703 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1704 |
|
19 | 1705 |
primitiveNumber |
1706 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1707 |
||
1708 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1709 |
! |
97 | 1710 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1711 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1712 |
"return the ST-80 style resource info or nil (valid after parsing)." |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1713 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1714 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1715 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1716 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1717 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1718 |
|
35 | 1719 |
release |
664 | 1720 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1721 |
super release. |
664 | 1722 |
|
1723 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 1724 |
! |
1725 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1726 |
setNameSpace:aNameSpaceName |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1727 |
currentNamespace := Namespace fullName:aNameSpaceName |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1728 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1729 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1730 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1731 |
|
141 | 1732 |
targetClass |
1733 |
^ classToCompileFor |
|
1734 |
! |
|
1735 |
||
90 | 1736 |
targetClass:aClass |
117 | 1737 |
classToCompileFor := aClass |
1738 |
! |
|
1739 |
||
141 | 1740 |
tree |
1741 |
"return the parsetree" |
|
1742 |
||
1743 |
^tree |
|
1744 |
! |
|
1745 |
||
1746 |
tree:aTree |
|
1747 |
"private: set the tree - for internal use only" |
|
1748 |
||
1749 |
tree := aTree |
|
1750 |
! ! |
|
1751 |
||
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1752 |
!Parser methodsFor:'dummy - syntax detection'! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1753 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1754 |
markArgumentIdentifierFrom:pos1 to:pos2 |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1755 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1756 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1757 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1758 |
|
883 | 1759 |
markBadIdentifierFrom:pos1 to:pos2 |
1760 |
||
1761 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
1762 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
1763 |
! |
|
1764 |
||
663 | 1765 |
markBooleanConstantFrom:pos1 to:pos2 |
1766 |
||
1767 |
"Created: / 31.3.1998 / 18:06:22 / cg" |
|
1768 |
! |
|
1769 |
||
673 | 1770 |
markBracketAt:pos |
1771 |
! |
|
1772 |
||
663 | 1773 |
markConstantFrom:pos1 to:pos2 |
1774 |
||
1775 |
"Created: / 31.3.1998 / 18:06:24 / cg" |
|
1776 |
! |
|
1777 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1778 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1779 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1780 |
"Created: / 4.3.1999 / 12:52:45 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1781 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1782 |
|
663 | 1783 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1784 |
||
1785 |
"Created: / 31.3.1998 / 15:29:39 / cg" |
|
1786 |
! |
|
1787 |
||
1788 |
markHereFrom:pos1 to:pos2 |
|
1789 |
||
1790 |
"Created: / 31.3.1998 / 17:39:01 / cg" |
|
1791 |
! |
|
1792 |
||
1793 |
markIdentifierFrom:pos1 to:pos2 |
|
1794 |
||
1795 |
"Created: / 31.3.1998 / 18:06:17 / cg" |
|
1796 |
! |
|
1797 |
||
687 | 1798 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1799 |
||
1800 |
"Created: / 16.4.1998 / 18:34:10 / cg" |
|
1801 |
! |
|
1802 |
||
663 | 1803 |
markLocalIdentifierFrom:pos1 to:pos2 |
1804 |
||
1805 |
"Created: / 31.3.1998 / 15:29:35 / cg" |
|
1806 |
! |
|
1807 |
||
1808 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1809 |
||
1810 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
1811 |
"Created: / 31.3.1998 / 16:39:44 / cg" |
|
1812 |
! |
|
1813 |
||
837 | 1814 |
markReturnAt:pos |
1815 |
||
1816 |
"Created: / 5.1.1980 / 00:48:24 / cg" |
|
1817 |
! |
|
1818 |
||
864 | 1819 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
1820 |
||
1821 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
|
1822 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
1823 |
! |
|
1824 |
||
663 | 1825 |
markSelfFrom:pos1 to:pos2 |
1826 |
||
1827 |
"Created: / 31.3.1998 / 17:49:38 / cg" |
|
1828 |
! |
|
1829 |
||
1830 |
markSuperFrom:pos1 to:pos2 |
|
1831 |
||
1832 |
"Created: / 31.3.1998 / 17:40:20 / cg" |
|
664 | 1833 |
! |
1834 |
||
1835 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
1836 |
||
1837 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
1838 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
687 | 1839 |
! |
1840 |
||
1841 |
markVariable:v |
|
1842 |
"support for syntaxColoring" |
|
1843 |
||
1844 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
1845 |
! |
|
1846 |
||
1847 |
markVariable:v from:pos1 to:pos2 |
|
1848 |
"support for syntaxColoring" |
|
1849 |
||
1850 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
1851 |
"Created: / 16.4.1998 / 18:50:03 / cg" |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1852 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1853 |
|
141 | 1854 |
!Parser methodsFor:'error correction'! |
1855 |
||
1856 |
askForCorrection:aString fromList:aList |
|
1857 |
"launch a selection box, which allows user to enter correction. |
|
1858 |
return newString or nil (for abort)" |
|
1859 |
||
1860 |
|box| |
|
1861 |
||
1862 |
"in systems without widgets ..." |
|
1863 |
ListSelectionBox isNil ifTrue:[ |
|
1864 |
^ self confirm:aString |
|
1865 |
]. |
|
1866 |
box := ListSelectionBox title:aString. |
|
1867 |
box initialText:(aList at:1). |
|
1868 |
box list:aList. |
|
1869 |
box okText:'correct'. |
|
1870 |
box action:[:aString | ^ aString]. |
|
1871 |
box showAtPointer. |
|
1872 |
^ nil |
|
1873 |
! |
|
1874 |
||
1875 |
correctByDeleting |
|
1876 |
"correct (by deleting token) if user wants to; |
|
1877 |
return #Error if there was no correction; |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1878 |
nil if there was one." |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1879 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1880 |
|selectionSize| |
141 | 1881 |
|
1882 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
1883 |
||
1884 |
" |
|
1885 |
tell requestor (i.e. CodeView) about the change |
|
1886 |
this will update what the requestor shows. |
|
1887 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1888 |
selectionSize := requestor selection size. |
141 | 1889 |
requestor deleteSelection. |
1890 |
||
1891 |
" |
|
1892 |
get the updated source-string |
|
1893 |
which is needed, when we eventually install the new method |
|
1894 |
" |
|
1895 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1896 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1897 |
position:(source position - selectionSize). |
141 | 1898 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1899 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1900 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 1901 |
! |
1902 |
||
1903 |
correctSelector:aSelectorString message:msg position:pos1 to:pos2 |
|
1904 |
"notify error and correct if user wants to; |
|
1905 |
return #Error if there was no correction |
|
1906 |
or a ParseNode as returned by variable" |
|
1907 |
||
1908 |
|correctIt suggestedNames newSelector| |
|
1909 |
||
1910 |
" |
|
1911 |
sorry, but I cannot handle keywords with more than one-part |
|
1912 |
currently (too much work - maybe Ill do it later when everything else works :-) |
|
1913 |
" |
|
1914 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1915 |
self warning:msg position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1916 |
^ aSelectorString |
141 | 1917 |
]. |
1918 |
||
1919 |
correctIt := self correctableError:msg position:pos1 to:pos2. |
|
1920 |
correctIt ifFalse:[^ aSelectorString]. |
|
1921 |
||
1922 |
suggestedNames := self findBestSelectorsFor:aSelectorString. |
|
1923 |
suggestedNames notNil ifTrue:[ |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1924 |
newSelector := self askForCorrection:'correct selector to: ' fromList:suggestedNames. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1925 |
newSelector isNil ifTrue:[^ aSelectorString]. |
141 | 1926 |
] ifFalse:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1927 |
self information:'no good correction found'. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1928 |
^ aSelectorString |
141 | 1929 |
]. |
1930 |
||
1931 |
" |
|
1932 |
tell requestor (i.e. CodeView) about the change |
|
1933 |
this will update what the requestor shows. |
|
1934 |
" |
|
1935 |
||
1936 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
|
1937 |
" |
|
1938 |
get the updated source-string |
|
1939 |
which is needed, when we eventually install the new method |
|
1940 |
" |
|
1941 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1942 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1943 |
position:(source position + newSelector size - aSelectorString size). |
141 | 1944 |
|
1945 |
^ newSelector |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1946 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1947 |
"Modified: / 22.1.1998 / 16:36:04 / stefan" |
141 | 1948 |
! |
1949 |
||
1950 |
correctVariable |
|
1951 |
"notify error and correct if user wants to; |
|
1952 |
return #Error if there was no correction |
|
1953 |
or a ParseNode as returned by variable" |
|
1954 |
||
877 | 1955 |
|correctIt varName suggestedNames newName pos1 pos2 rslt |
1956 |
varNameIsLowercase l how choice holder| |
|
141 | 1957 |
|
1958 |
pos1 := tokenPosition. |
|
1959 |
varName := tokenName. |
|
1960 |
pos2 := pos1 + varName size - 1. |
|
1961 |
||
877 | 1962 |
varNameIsLowercase := (varName at:1) isLowercase. |
1963 |
||
141 | 1964 |
"OLD: |
877 | 1965 |
varNameIsLowercase ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1966 |
correctIt := self undefError:varName position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1967 |
correctIt ifFalse:[^ #Error] |
141 | 1968 |
] ifFalse:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1969 |
correctIt := self warning:('''' , varName , ''' is undefined') position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1970 |
correctIt ifFalse:[ |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1971 |
^ VariableNode type:#GlobalVariable name:(varName asSymbol) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1972 |
] |
141 | 1973 |
]. |
1974 |
" |
|
1975 |
||
1976 |
correctIt := self undefError:varName position:pos1 to:pos2. |
|
887 | 1977 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 1978 |
"/ no correction wanted. |
1979 |
||
1980 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
1981 |
"/ allowing easy search for bad-spots later. |
|
1982 |
||
1983 |
varNameIsLowercase ifTrue:[ |
|
725
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
1984 |
((Smalltalk includesKey:#Undeclared) |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
1985 |
and:[((Smalltalk at:#Undeclared) includes:varName asSymbol)]) ifFalse:[ |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
1986 |
self warning:('adding ''' , varName , ''' as Undeclared.\\Remember to fix that later.') withCRs position:pos1 to:pos2. |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
1987 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
1988 |
^ self defineAsUndeclaredVariable:varName |
877 | 1989 |
]. |
1990 |
||
1991 |
"/ upperCase vars are declared as global |
|
1992 |
self warning:('adding ''' , varName , ''' as Global.') withCRs position:pos1 to:pos2. |
|
1993 |
^ VariableNode type:#GlobalVariable name:(varName asSymbol) |
|
1994 |
]. |
|
1995 |
||
1996 |
correctIt == #declare ifTrue:[ |
|
1997 |
"/ declare it |
|
1998 |
l := #(). |
|
1999 |
how := #(). |
|
2000 |
||
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2001 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
877 | 2002 |
varNameIsLowercase ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2003 |
"/ currentBlock notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2004 |
"/ l := l , #( 'Block local' ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2005 |
"/ how := how , #( BlockVariable ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2006 |
"/ ]. |
877 | 2007 |
selector notNil ifTrue:[ |
2008 |
l := l , #( 'Method local' ). |
|
2009 |
how := how , #( MethodVariable ). |
|
2010 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2011 |
"/ (classToCompileFor notNil |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2012 |
"/ and:[classToCompileFor isMeta not |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2013 |
"/ and:[classToCompileFor isBuiltInClass not]]) ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2014 |
"/ l := l , (Array with:( 'Instance variable of ' , classToCompileFor name )). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2015 |
"/ how := how , #( InstanceVariable ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2016 |
"/ ]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2017 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2018 |
l := l , #( 'Global' ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2019 |
how := how , #( GlobalVariable ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2020 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2021 |
(classToCompileFor notNil |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2022 |
and:[classToCompileFor isBuiltInClass not |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2023 |
and:[selector notNil and:[selector ~~ #doIt]]]) ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2024 |
l := l , (Array |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2025 |
with:'Class Variable in ' , classToCompileFor name |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2026 |
"/ with:'Class Instance Variable in ' , classToCompileFor name |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2027 |
). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2028 |
how := how , #( ClassVariable ClassInstVariable). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2029 |
] |
877 | 2030 |
]. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2031 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
877 | 2032 |
l size > 0 ifTrue:[ |
2033 |
l := l , #( '-' ). |
|
2034 |
how := how , #( nil ). |
|
2035 |
]. |
|
2036 |
l := l , #( 'Workspace variable' ). |
|
2037 |
how := how , #( WorkspaceVariable ). |
|
2038 |
]. |
|
2039 |
l size > 0 ifTrue:[ |
|
2040 |
l := (Array with:('Declare ' , varName asText allBold , ' as:') with:'=') , l. |
|
2041 |
how := #(nil nil) , how. |
|
2042 |
choice := (PopUpMenu labels:l) startUp. |
|
2043 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2044 |
choice := how at:choice. |
|
2045 |
||
2046 |
choice == #WorkspaceVariable ifTrue:[ |
|
2047 |
holder := Workspace addWorkspaceVariable:varName. |
|
2048 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2049 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2050 |
choice == #GlobalVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2051 |
Smalltalk at:varName asSymbol put:nil. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2052 |
^ VariableNode type:#GlobalVariable name:varName asSymbol |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2053 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2054 |
choice == #ClassVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2055 |
classToCompileFor addClassVarName:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2056 |
^ VariableNode type:#ClassVariable class:classToCompileFor name:varName |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2057 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2058 |
choice == #MethodVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2059 |
|varIndex var endLocalsPos posToInsert ins| |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2060 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2061 |
localVarDefPosition size == 2 ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2062 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2063 |
ins := ' ' , varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2064 |
] ifFalse:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2065 |
endOfSelectorPosition notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2066 |
posToInsert := endOfSelectorPosition. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2067 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2068 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2069 |
] |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2070 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2071 |
posToInsert notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2072 |
requestor |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2073 |
insertString:ins |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2074 |
atCharacterPosition:posToInsert. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2075 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2076 |
endLocalsPos notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2077 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2078 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2079 |
methodVarNames := methodVarNames copyWith:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2080 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2081 |
] ifFalse:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2082 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2083 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2084 |
methodVarNames := Array with:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2085 |
methodVars := Array with:(var := Variable new name:varName). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2086 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2087 |
correctedSource := requestor currentSourceCode. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2088 |
source := (ReadStream on:correctedSource) |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2089 |
position:(source position + ins size). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2090 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2091 |
varIndex := methodVarNames size. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2092 |
var used:true. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2093 |
^ VariableNode type:#MethodVariable |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2094 |
name:varName |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2095 |
token:var |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2096 |
index:varIndex |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2097 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2098 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2099 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
877 | 2100 |
]. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2101 |
^ #Error |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2102 |
] |
141 | 2103 |
]. |
2104 |
||
2105 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2106 |
suggestedNames isNil ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2107 |
self information:'no good correction found'. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2108 |
^ #Error |
141 | 2109 |
]. |
2110 |
||
877 | 2111 |
newName := self askForCorrection:'correct variable to: ' fromList:suggestedNames. |
2112 |
newName isNil ifTrue:[^ #Error]. |
|
2113 |
" |
|
2114 |
newName := suggestedNames at:1. |
|
2115 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2116 |
" |
|
2117 |
||
141 | 2118 |
" |
2119 |
tell requestor (i.e. CodeView) about the change |
|
2120 |
this will update what the requestor shows. |
|
2121 |
" |
|
2122 |
requestor replaceSelectionBy:newName. |
|
2123 |
" |
|
2124 |
get the updated source-string |
|
2125 |
which is needed, when we eventually install the new method |
|
2126 |
" |
|
2127 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2128 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2129 |
position:(source position + newName size - tokenName size). |
141 | 2130 |
|
2131 |
"redo parse with new value" |
|
2132 |
tokenName := newName. |
|
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2133 |
rslt := self variableOrError:tokenName. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2134 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2135 |
"/ failed again ? |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2136 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2137 |
"/ install as Undeclared:<name>, remember in #undeclared |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2138 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2139 |
rslt := self defineAsUndeclaredVariable:varName |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2140 |
]. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2141 |
^ rslt |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2142 |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2143 |
"Modified: / 22.1.1998 / 16:34:01 / stefan" |
887 | 2144 |
"Modified: / 4.7.1999 / 19:24:10 / cg" |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2145 |
! |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2146 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2147 |
defineAsUndeclaredVariable:aName |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2148 |
"define varName as undeclared variable |
629 | 2149 |
(actually, it will be installed as a funny global named 'Undeclared:::<name>'). |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2150 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2151 |
to 'Undeclared:::*' (or use the search-undeclared item in the launchers menu)." |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2152 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2153 |
|varName| |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2154 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2155 |
varName := aName. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2156 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2157 |
"/ install as Undeclared:<name>, remember in Undeclared |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2158 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2159 |
(Smalltalk includesKey:#Undeclared) ifFalse:[ |
629 | 2160 |
Smalltalk at:#Undeclared put:(IdentitySet new). |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2161 |
]. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2162 |
(Smalltalk at:#Undeclared) add:tokenName asSymbol. |
629 | 2163 |
varName := (Smalltalk underclaredPrefix) , tokenName. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2164 |
varName := varName asSymbol. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2165 |
Smalltalk at:varName put:nil. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2166 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2167 |
parseForCode ifFalse:[self rememberGlobalUsed:aName]. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2168 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2169 |
^ VariableNode type:#GlobalVariable name:varName |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2170 |
|
629 | 2171 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 2172 |
! |
2173 |
||
2174 |
findBestSelectorsFor:aString |
|
2175 |
"collect known selectors with their spelling distances to aString; |
|
2176 |
return the 10 best suggestions" |
|
2177 |
||
2178 |
|info n| |
|
2179 |
||
2180 |
info := SortedCollection new. |
|
2181 |
info sortBlock:[:a :b | a value > b value]. |
|
2182 |
||
2183 |
n := 0. |
|
2184 |
||
2185 |
Symbol allInstancesDo:[:sym | |
|
2186 |
|dist| |
|
2187 |
||
2188 |
dist := aString spellAgainst:sym. |
|
2189 |
dist > 20 ifTrue:[ |
|
2190 |
info add:(sym -> dist). |
|
2191 |
n := n + 1. |
|
2192 |
n > 10 ifTrue:[ |
|
2193 |
info removeLast. |
|
2194 |
] |
|
2195 |
] |
|
2196 |
]. |
|
2197 |
||
2198 |
^ info asOrderedCollection collect:[:a | a key] |
|
2199 |
||
2200 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
2201 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
2202 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
2203 |
! |
|
2204 |
||
2205 |
findBestVariablesFor:aString |
|
2206 |
"collect known variables with their spelling distances to aString; |
|
2207 |
return the 10 best suggestions" |
|
2208 |
||
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2209 |
|names dists searchBlock args vars globalVarName "aClass className baseClass" |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2210 |
n instVarNames| |
141 | 2211 |
|
2212 |
names := OrderedCollection new. |
|
2213 |
dists := OrderedCollection new. |
|
2214 |
||
2215 |
"block arguments" |
|
2216 |
searchBlock := currentBlock. |
|
2217 |
[searchBlock notNil] whileTrue:[ |
|
619 | 2218 |
args := searchBlock arguments. |
2219 |
args notNil ifTrue:[ |
|
2220 |
args do:[:aBlockArg | |
|
2221 |
names add:(aBlockArg name). |
|
2222 |
dists add:(aString spellAgainst: "levenshteinTo:"(aBlockArg name)) |
|
2223 |
] |
|
2224 |
]. |
|
2225 |
||
2226 |
vars := searchBlock variables. |
|
2227 |
vars notNil ifTrue:[ |
|
2228 |
vars do:[:aBlockVar | |
|
2229 |
names add:(aBlockVar name). |
|
2230 |
dists add:(aString spellAgainst: "levenshteinTo:"(aBlockVar name)) |
|
2231 |
] |
|
2232 |
]. |
|
2233 |
searchBlock := searchBlock home |
|
141 | 2234 |
]. |
2235 |
||
2236 |
"method-variables" |
|
2237 |
methodVars notNil ifTrue:[ |
|
619 | 2238 |
methodVarNames do:[:methodVarName | |
2239 |
names add:methodVarName. |
|
2240 |
dists add:(aString spellAgainst: "levenshteinTo:"methodVarName) |
|
2241 |
] |
|
141 | 2242 |
]. |
2243 |
||
2244 |
"method-arguments" |
|
2245 |
methodArgs notNil ifTrue:[ |
|
619 | 2246 |
methodArgNames do:[:methodArgName | |
2247 |
names add:methodArgName. |
|
2248 |
dists add:(aString spellAgainst: "levenshteinTo:"methodArgName) |
|
2249 |
] |
|
141 | 2250 |
]. |
2251 |
||
2252 |
"instance-variables" |
|
2253 |
classToCompileFor notNil ifTrue:[ |
|
619 | 2254 |
self classesInstVarNames do:[:instVarName | |
2255 |
names add:instVarName. |
|
2256 |
dists add:(aString spellAgainst: "levenshteinTo:"instVarName) |
|
2257 |
] |
|
141 | 2258 |
]. |
2259 |
||
2260 |
"class-variables" |
|
2261 |
classToCompileFor notNil ifTrue:[ |
|
619 | 2262 |
self classesClassVarNames do:[:classVarName | |
2263 |
names add:classVarName. |
|
2264 |
dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
2265 |
]. |
|
141 | 2266 |
|
2267 |
"/ aClass := classToCompileFor. |
|
2268 |
"/ aClass isMeta ifTrue:[ |
|
2269 |
"/ className := aClass name. |
|
2270 |
"/ className := className copyWithoutLast:5. |
|
2271 |
"/ baseClass := Smalltalk at:(className asSymbol). |
|
2272 |
"/ baseClass notNil ifTrue:[ |
|
2273 |
"/ aClass := baseClass |
|
2274 |
"/ ] |
|
2275 |
"/ ]. |
|
2276 |
"/ [aClass notNil] whileTrue:[ |
|
2277 |
"/ (aClass classVarNames) do:[:classVarName | |
|
2278 |
"/ names add:classVarName. |
|
2279 |
"/ dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
2280 |
"/ ]. |
|
2281 |
"/ aClass := aClass superclass |
|
2282 |
"/ ] |
|
2283 |
||
2284 |
]. |
|
2285 |
||
2286 |
"globals" |
|
2287 |
Smalltalk keysDo:[:aKey | |
|
619 | 2288 |
globalVarName := aKey asString. |
2289 |
"only compare strings where length is about right" |
|
2290 |
((globalVarName size - aString size) abs < 3) ifTrue:[ |
|
2291 |
names add:globalVarName. |
|
2292 |
dists add:(aString spellAgainst: "levenshteinTo:"globalVarName) |
|
2293 |
] |
|
141 | 2294 |
]. |
2295 |
||
2296 |
"misc" |
|
2297 |
#('self' 'super' 'nil' 'thisContext') do:[:name | |
|
619 | 2298 |
names add:name. |
2299 |
dists add:(aString spellAgainst: "levenshteinTo:"name) |
|
141 | 2300 |
]. |
2301 |
||
2302 |
(dists size ~~ 0) ifTrue:[ |
|
619 | 2303 |
dists sortWith:names. |
2304 |
dists := dists reverse. |
|
2305 |
names := names reverse. |
|
2306 |
n := names size min:10. |
|
2307 |
names := names copyTo:n. |
|
2308 |
||
2309 |
"if it starts with a lower case character, add all local & instvar names" |
|
2310 |
(aString at:1) isLowercase ifTrue:[ |
|
2311 |
methodVarNames size > 0 ifTrue:[ |
|
2312 |
names add:'---- method locals ----'. |
|
2313 |
methodVarNames asSortedCollection do:[:methodVarName | |
|
2314 |
names add:methodVarName. |
|
2315 |
]. |
|
2316 |
]. |
|
2317 |
||
2318 |
||
2319 |
methodArgs size > 0 ifTrue:[ |
|
2320 |
names add:'---- method arguments ----'. |
|
2321 |
methodArgNames asSortedCollection do:[:methodArgName | |
|
2322 |
names add:methodArgName. |
|
2323 |
] |
|
2324 |
]. |
|
2325 |
||
2326 |
instVarNames := OrderedCollection new. |
|
2327 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
2328 |
(instVarNames includes:instVarName) ifFalse:[ |
|
2329 |
instVarNames add:instVarName. |
|
2330 |
] |
|
2331 |
]. |
|
2332 |
||
2333 |
instVarNames size > 0 ifTrue:[ |
|
2334 |
names add:'---- instance variables ----'. |
|
2335 |
instVarNames do:[:instVarName | |
|
2336 |
(names includes:instVarName) ifFalse:[ |
|
2337 |
names add:instVarName. |
|
2338 |
] |
|
2339 |
] |
|
2340 |
] |
|
2341 |
]. |
|
2342 |
||
2343 |
^ names |
|
141 | 2344 |
]. |
2345 |
^ nil |
|
450 | 2346 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2347 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 2348 |
! |
2349 |
||
2350 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
2351 |
"just a quick check: if a selector is totally unknown as a symbol, |
|
2352 |
or has the same name as a variable or cannot be understood. |
|
2353 |
Simple, but catches many typos" |
|
2354 |
||
798
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2355 |
|ok err sym rec superCls names recType sCls| |
141 | 2356 |
|
2357 |
" |
|
2358 |
if compiling lazy, or errors are to be ignored, or there |
|
2359 |
is no requestor, do not check |
|
2360 |
" |
|
2361 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
|
2362 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
|
2363 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
2364 |
||
2365 |
err := ' is currently nowhere implemented'. |
|
2366 |
" |
|
2367 |
if the selector has the name of a variable, use another message |
|
2368 |
" |
|
2369 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
|
2370 |
or:[(methodArgNames notNil and:[methodArgNames includes:aSelectorString]) |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
2371 |
or:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString]) |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
2372 |
or:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString]) |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
2373 |
or:[((names := self classesClassVarNames) notNil and:[names includes:aSelectorString])]]]]) ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2374 |
err := ' is currently nowhere implemented .. |
141 | 2375 |
.. but a variable with that name is defined. |
2376 |
||
143 | 2377 |
Missing ''.'' after the previous expression |
2378 |
or missing keyword/receiver before that word ?'. |
|
141 | 2379 |
]. |
2380 |
||
2381 |
" |
|
2382 |
check if the selector is known at all |
|
2383 |
- if not, it cannot be understood |
|
2384 |
" |
|
2385 |
ok := false. |
|
2386 |
sym := aSelectorString asSymbolIfInterned. |
|
2387 |
sym notNil ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2388 |
ok := true. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2389 |
receiver notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2390 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2391 |
if the receiver is a constant, we can check if it responds |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2392 |
to this selector |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2393 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2394 |
receiver isConstant ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2395 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2396 |
ok := rec respondsTo:sym. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2397 |
err := ' will not be understood here (message to ' , rec classNameWithArticle , ')'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2398 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2399 |
receiver isBlock ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2400 |
"/ this should help with typos, sending #ifTrue to blocks ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2401 |
ok := [] respondsTo:sym. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2402 |
err := ' will not be understood here (message to a Block)'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2403 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2404 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2405 |
if the receiver is a global, we check it too ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2406 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2407 |
(((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2408 |
or:[recType == #PrivateClass]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2409 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2410 |
"/ - it may work after loading" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2411 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2412 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2413 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2414 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2415 |
and:[rec isLoaded not]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2416 |
^ aSelectorString |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2417 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2418 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2419 |
ok := rec respondsTo:sym. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2420 |
ok ifFalse:[ |
798
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2421 |
sCls := rec class. |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2422 |
[sCls notNil and:[sCls ~~ Object]] whileTrue:[ |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2423 |
"if it implements #doesNotUnderstand somewhere, assume its ok" |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2424 |
(sCls implements:#doesNotUnderstand:) ifTrue:[ |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2425 |
^ aSelectorString |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2426 |
]. |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2427 |
sCls := sCls superclass |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2428 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2429 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2430 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2431 |
err := ' may not be understood here (is currently ' , rec classNameWithArticle , ')'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2432 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2433 |
"if its a super send, we can do more checking" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2434 |
receiver isSuper ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2435 |
receiver isHere ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2436 |
((superCls := classToCompileFor superclass) notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2437 |
and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2438 |
err := ' is currently not implemented in any superclass'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2439 |
ok := false |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2440 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2441 |
] ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2442 |
(classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2443 |
err := ' is currently not implemented in this class'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2444 |
ok := false |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2445 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2446 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2447 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2448 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2449 |
(receiver isUnaryMessage |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2450 |
and:[receiver selector == #class |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2451 |
and:[receiver receiver type == #Self]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2452 |
"its a message to self class - can check this too ..." |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2453 |
(classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2454 |
ok := false. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2455 |
classToCompileFor allSubclasses do:[:subclass | |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2456 |
(subclass class implements:sym) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2457 |
ok := true |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2458 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2459 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2460 |
err := ' is currently not implemented in the class'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2461 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2462 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2463 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2464 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2465 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2466 |
] |
141 | 2467 |
]. |
2468 |
||
2469 |
ok ifFalse:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2470 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2471 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2472 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2473 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2474 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2475 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2476 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2477 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2478 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2479 |
and:[rec isLoaded not]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2480 |
^ aSelectorString |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2481 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2482 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2483 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2484 |
"/ it may work after loading/defining |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2485 |
^ aSelectorString |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2486 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2487 |
]. |
141 | 2488 |
|
2489 |
"OLD: " |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2490 |
self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2 |
141 | 2491 |
" " |
2492 |
||
2493 |
"NEW: - not finished - need more interfaces |
|
2494 |
(currently produces warning output on Transcript while filing in |
|
2495 |
||
2496 |
||
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2497 |
^ self correctSelector:aSelectorString message:('#' , aSelectorString , err) position:pos1 to:pos2 |
141 | 2498 |
" |
2499 |
]. |
|
2500 |
^ aSelectorString |
|
2501 |
||
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2502 |
"Modified: / 5.9.1995 / 17:02:11 / claus" |
798
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2503 |
"Modified: / 4.11.1998 / 21:52:50 / cg" |
0 | 2504 |
! ! |
2505 |
||
2506 |
!Parser methodsFor:'error handling'! |
|
2507 |
||
141 | 2508 |
exitWith:something |
2509 |
"this is the longjump out of evaluation via a return expression" |
|
2510 |
||
2511 |
evalExitBlock value:something |
|
2512 |
! |
|
2513 |
||
2514 |
identifierExpectedIn:what |
|
2515 |
|msg| |
|
2516 |
||
2517 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
2518 |
msg := 'Reserved keyword in ' |
|
2519 |
] ifFalse:[ |
|
2520 |
msg := 'Identifier expected in ' |
|
2521 |
]. |
|
2522 |
self syntaxError:msg , what position:tokenPosition to:source position - 1. |
|
2523 |
^ #Error |
|
2524 |
! |
|
2525 |
||
0 | 2526 |
showErrorMessage:aMessage position:pos |
19 | 2527 |
"redefined since parser can give more detailed info about |
2528 |
the class & selector where the error occured." |
|
2529 |
||
71 | 2530 |
|text| |
2531 |
||
19 | 2532 |
ignoreErrors ifFalse:[ |
619 | 2533 |
Smalltalk silentLoading == true ifFalse:[ |
2534 |
Transcript show:(pos printString). |
|
2535 |
Transcript show:' '. |
|
2536 |
selector notNil ifTrue:[ |
|
2537 |
Transcript show:aMessage. |
|
2538 |
classToCompileFor notNil ifTrue:[ |
|
2539 |
text := ' in ' , classToCompileFor name , '>>' , selector |
|
2540 |
] ifFalse:[ |
|
2541 |
text := ' in ' , selector |
|
2542 |
] |
|
2543 |
] ifFalse:[ |
|
2544 |
classToCompileFor notNil ifTrue:[ |
|
2545 |
text := aMessage , ' (' , classToCompileFor name , ')' |
|
2546 |
] ifFalse:[ |
|
2547 |
text := aMessage |
|
2548 |
] |
|
2549 |
]. |
|
2550 |
Transcript showCR:text. |
|
2551 |
] |
|
0 | 2552 |
] |
273 | 2553 |
|
2554 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 2555 |
! |
2556 |
||
171 | 2557 |
showErrorMessageForClass:aClass |
2558 |
"/ compiler parseError:'syntax error'. |
|
2559 |
Transcript show:' '. |
|
2560 |
aClass notNil ifTrue:[ |
|
619 | 2561 |
Transcript show:aClass name , '>>' |
171 | 2562 |
]. |
2563 |
selector notNil ifTrue:[ |
|
619 | 2564 |
Transcript show:(selector) |
171 | 2565 |
]. |
273 | 2566 |
Transcript showCR:' -> Error'. |
171 | 2567 |
|
2568 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 2569 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 2570 |
! |
2571 |
||
0 | 2572 |
undefError:aName position:pos1 to:pos2 |
3 | 2573 |
"report an undefined variable error - return true, if it should be |
86 | 2574 |
corrected. If not corrected, only one warning is made per undefined |
2575 |
variable." |
|
2576 |
||
429 | 2577 |
|doCorrect msg idx| |
86 | 2578 |
|
607 | 2579 |
warnUndeclared ifFalse:[^ false]. |
2580 |
||
86 | 2581 |
" |
2582 |
alredy warned about this one ? |
|
2583 |
" |
|
2584 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 2585 |
(warnedUndefVars includes:aName) ifTrue:[ |
2586 |
"already warned about this one" |
|
2587 |
^ false |
|
2588 |
]. |
|
86 | 2589 |
]. |
2590 |
||
131 | 2591 |
"/ (classToCompileFor notNil |
2592 |
"/ and:[classToCompileFor superclass notNil |
|
2593 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
2594 |
"/ self showErrorMessage:'Error: no source information (instvar names)' position:pos1. |
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
2595 |
"/ ^ false |
131 | 2596 |
"/ ]. |
2597 |
||
2598 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
|
877 | 2599 |
aName first isUppercase ifFalse:[ |
2600 |
self showErrorMessage:('Error: ''' , aName , ''' is undefined') position:pos1. |
|
2601 |
]. |
|
2602 |
doCorrect := false. |
|
86 | 2603 |
] ifFalse:[ |
877 | 2604 |
" |
2605 |
ask requestor for correct/continue/abort ... |
|
2606 |
it is supposed to raise abort or return true/false. |
|
2607 |
True return means that correction is wanted. |
|
2608 |
" |
|
2609 |
msg := 'Warning: ''' , aName , ''' is undefined'. |
|
2610 |
classToCompileFor notNil ifTrue:[ |
|
2611 |
"is it an instance-variable marked inaccessable ?" |
|
2612 |
||
2613 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
2614 |
idx ~~ 0 ifTrue:[ |
|
2615 |
msg := 'Warning: ' , aName , ' is a hidden instvar (not accessable from ST-code)'. |
|
2616 |
] |
|
2617 |
]. |
|
2618 |
||
2619 |
doCorrect := self correctableError:msg position:pos1 to:pos2 |
|
86 | 2620 |
]. |
2621 |
||
877 | 2622 |
doCorrect == false ifTrue:[ |
2623 |
warnedUndefVars isNil ifTrue:[ |
|
2624 |
warnedUndefVars := Set new. |
|
2625 |
]. |
|
2626 |
warnedUndefVars add:aName. |
|
3 | 2627 |
]. |
0 | 2628 |
|
86 | 2629 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
2630 |
|
607 | 2631 |
"Modified: 7.9.1997 / 02:14:36 / cg" |
0 | 2632 |
! ! |
2633 |
||
2634 |
!Parser methodsFor:'parsing'! |
|
2635 |
||
141 | 2636 |
block |
2637 |
"parse a block; return a node-tree, nil or #Error" |
|
2638 |
||
883 | 2639 |
|node args argNames arg pos pos2 lno| |
141 | 2640 |
|
2641 |
lno := tokenLineNr. |
|
2642 |
self nextToken. |
|
2643 |
(tokenType == $: ) ifTrue:[ |
|
663 | 2644 |
[tokenType == $:] whileTrue:[ |
2645 |
pos := tokenPosition. |
|
2646 |
self nextToken. |
|
883 | 2647 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 2648 |
^ self identifierExpectedIn:'block-arg declaration' |
2649 |
]. |
|
883 | 2650 |
|
2651 |
pos2 := tokenPosition + tokenName size - 1. |
|
2652 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
663 | 2653 |
arg := Variable name:tokenName. |
2654 |
args isNil ifTrue:[ |
|
2655 |
args := Array with:arg. |
|
2656 |
argNames := Array with:tokenName. |
|
2657 |
] ifFalse:[ |
|
2658 |
(argNames includes:tokenName) ifTrue:[ |
|
883 | 2659 |
"/ argname reuse |
2660 |
self isSyntaxHighlighter ifTrue:[ |
|
2661 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
2662 |
] ifFalse:[ |
|
2663 |
self |
|
2664 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
2665 |
position:tokenPosition to:pos2 |
|
2666 |
] |
|
663 | 2667 |
]. |
2668 |
args := args copyWith:arg. |
|
2669 |
argNames := argNames copyWith:tokenName. |
|
2670 |
]. |
|
2671 |
self nextToken |
|
2672 |
]. |
|
2673 |
(tokenType ~~ $| ) ifTrue:[ |
|
2674 |
"ST-80 allows [:arg ]" |
|
2675 |
(tokenType == $] ) ifTrue:[ |
|
2676 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
2677 |
node lineNumber:lno. |
|
2678 |
^ node |
|
2679 |
]. |
|
2680 |
self syntaxError:'| expected after block-arg declaration'. |
|
2681 |
^ #Error |
|
2682 |
]. |
|
2683 |
self nextToken |
|
141 | 2684 |
]. |
2685 |
node := self blockBody:args. |
|
2686 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 2687 |
node lineNumber:lno. |
141 | 2688 |
]. |
2689 |
^ node |
|
663 | 2690 |
|
2691 |
"Modified: / 31.3.1998 / 17:31:34 / cg" |
|
141 | 2692 |
! |
2693 |
||
2694 |
blockBody:args |
|
2695 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
2696 |
||
883 | 2697 |
|stats node var vars lno names pos2| |
141 | 2698 |
|
2699 |
lno := tokenLineNr. |
|
2700 |
(tokenType == $| ) ifTrue:[ |
|
668 | 2701 |
self nextToken. |
2702 |
[tokenType == $|] whileFalse:[ |
|
2703 |
(tokenType == #Identifier) ifFalse:[ |
|
2704 |
^ self identifierExpectedIn:'block-var declaration' |
|
2705 |
]. |
|
883 | 2706 |
pos2 := tokenPosition + tokenName size - 1. |
2707 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
668 | 2708 |
var := Variable name:tokenName. |
2709 |
vars isNil ifTrue:[ |
|
2710 |
vars := Array with:var. |
|
2711 |
names := Array with:tokenName |
|
2712 |
] ifFalse:[ |
|
2713 |
(names includes:tokenName) ifTrue:[ |
|
883 | 2714 |
"/ varname reuse |
2715 |
self isSyntaxHighlighter ifTrue:[ |
|
2716 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
2717 |
] ifFalse:[ |
|
2718 |
self |
|
2719 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
2720 |
position:tokenPosition to:pos2. |
|
2721 |
] |
|
668 | 2722 |
] ifFalse:[ |
2723 |
vars := vars copyWith:var. |
|
2724 |
names := names copyWith:tokenName |
|
2725 |
] |
|
2726 |
]. |
|
2727 |
self nextToken. |
|
2728 |
]. |
|
2729 |
self nextToken |
|
141 | 2730 |
]. |
382 | 2731 |
|
141 | 2732 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
2733 |
node lineNumber:lno. |
|
2734 |
currentBlock := node. |
|
2735 |
stats := self blockStatementList. |
|
382 | 2736 |
lineNumberInfo == #full ifTrue:[ |
668 | 2737 |
node endLineNumber:tokenLineNr |
382 | 2738 |
]. |
141 | 2739 |
node statements:stats. |
2740 |
currentBlock := node home. |
|
2741 |
(stats == #Error) ifTrue:[^ #Error]. |
|
2742 |
^ node |
|
382 | 2743 |
|
668 | 2744 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 2745 |
! |
2746 |
||
2747 |
blockExpression |
|
2748 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
2749 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
2750 |
||
2751 |
tokenType ~~ $[ ifTrue:[ |
|
2752 |
self syntaxError:'[ expected'. |
|
2753 |
^ #Error. |
|
2754 |
]. |
|
2755 |
^ self block |
|
2756 |
! |
|
2757 |
||
2758 |
blockStatementList |
|
2759 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
2760 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2761 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 2762 |
|
2763 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
2764 |
thisStatement := self statement. |
|
2765 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
2766 |
firstStatement := thisStatement. |
|
2767 |
[tokenType == $] ] whileFalse:[ |
|
673 | 2768 |
(tokenType == $.) ifFalse:[ |
2769 |
((tokenType == #EOF) or:[tokenType == $)]) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2770 |
eMsg := 'missing '']'' in block' |
673 | 2771 |
] ifFalse:[ |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2772 |
eMsg := 'missing ''.'' between statements (i.e. ' , tokenType printString , ' token unexpected)' |
673 | 2773 |
]. |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2774 |
self syntaxError:eMsg "position:tokenPosition". |
673 | 2775 |
^ #Error |
2776 |
] ifTrue:[ |
|
2777 |
prevStatement := thisStatement. |
|
2778 |
self nextToken. |
|
2779 |
tokenType == $] ifTrue:[ |
|
141 | 2780 |
" |
673 | 2781 |
*** I had a warning here (since it was not defined |
2782 |
*** in the blue-book; but PD-code contains a lot of |
|
2783 |
*** code with periods at the end so that the warnings |
|
2784 |
*** became annoying |
|
2785 |
||
2786 |
self warning:'period after last statement in block'. |
|
141 | 2787 |
" |
673 | 2788 |
self markBracketAt:tokenPosition. |
2789 |
^ firstStatement |
|
2790 |
]. |
|
2791 |
thisStatement := self statement. |
|
2792 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
2793 |
prevStatement nextStatement:thisStatement |
|
2794 |
] |
|
141 | 2795 |
]. |
673 | 2796 |
self markBracketAt:tokenPosition. |
141 | 2797 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2798 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
2799 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 2800 |
! |
2801 |
||
0 | 2802 |
parseMethod |
19 | 2803 |
"parse a method. |
2804 |
Return the parseTree or #Error. |
|
2805 |
||
2806 |
method ::= methodSpec methodBody |
|
2807 |
" |
|
0 | 2808 |
|
2809 |
|parseTree| |
|
2810 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2811 |
"/ self nextToken. |
0 | 2812 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
2813 |
parseTree := self parseMethodBody. |
|
2814 |
(parseTree == #Error) ifFalse:[ |
|
619 | 2815 |
self tree:parseTree |
0 | 2816 |
]. |
2817 |
^ parseTree |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2818 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2819 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 2820 |
! |
2821 |
||
19 | 2822 |
parseMethodBody |
2823 |
"parse a methods body (locals & statements). |
|
2824 |
No more tokens may follow. |
|
2825 |
Return a node-tree, or #Error |
|
2826 |
||
2827 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 2828 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 2829 |
|
2830 |
" |
|
429 | 2831 |
|stats| |
19 | 2832 |
|
883 | 2833 |
"/ classToCompileFor notNil ifTrue:[ |
2834 |
"/ stats := self parseMethodBodyOrEmpty. |
|
2835 |
"/ ] ifFalse:[ |
|
2836 |
stats := self parseMethodBodyOrEmpty. |
|
2837 |
"/ ]. |
|
19 | 2838 |
(stats == #Error) ifFalse:[ |
883 | 2839 |
(tokenType ~~ #EOF) ifTrue:[ |
2840 |
"/ just for the nicer error message |
|
2841 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
|
2842 |
self parseError:tokenName , ' unexpected (missing ''.'' before ' , tokenName , ' ?)' |
|
2843 |
position:tokenPosition to:(tokenPosition + tokenName size - 1) |
|
2844 |
] ifFalse:[ |
|
2845 |
self parseError:(tokenType printString , ' unexpected (missing ''.'' or selector before it ?)') |
|
2846 |
position:tokenPosition to:source position-1. |
|
2847 |
]. |
|
2848 |
^#Error |
|
2849 |
] |
|
19 | 2850 |
]. |
2851 |
^ stats |
|
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
2852 |
|
619 | 2853 |
"Modified: 14.10.1997 / 20:53:17 / cg" |
19 | 2854 |
! |
2855 |
||
79 | 2856 |
parseMethodBodyOrEmpty |
0 | 2857 |
"parse a methods body (locals & statements); |
19 | 2858 |
return a node-tree, nil or #Error. |
2859 |
empty (or comment only) input is accepted and returns nil. |
|
2860 |
||
2861 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
619 | 2862 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
2863 |
| <empty> |
|
19 | 2864 |
" |
0 | 2865 |
|
265 | 2866 |
|stats| |
0 | 2867 |
|
2868 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
2869 |
||
2870 |
(tokenType ~~ #EOF) ifTrue:[ |
|
619 | 2871 |
stats := self statementList |
0 | 2872 |
]. |
2873 |
^ stats |
|
265 | 2874 |
|
2875 |
"Modified: 27.4.1996 / 16:57:56 / cg" |
|
0 | 2876 |
! |
2877 |
||
19 | 2878 |
parseMethodBodyVarSpec |
265 | 2879 |
"parse a methods local variable specification, handling |
2880 |
possible primitive or resourceSpecs. |
|
2881 |
. |
|
19 | 2882 |
Leave spec of locals in methodLocals as a side effect. |
2883 |
Return #Error or nil. |
|
0 | 2884 |
|
19 | 2885 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 2886 |
| <empty> |
19 | 2887 |
" |
0 | 2888 |
|
883 | 2889 |
|var pos pos2 msg| |
0 | 2890 |
|
265 | 2891 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 2892 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 2893 |
]. |
2894 |
||
0 | 2895 |
(tokenType == $|) ifTrue:[ |
663 | 2896 |
"memorize position for declaration in correction" |
883 | 2897 |
|
663 | 2898 |
localVarDefPosition := tokenPosition. |
2899 |
self nextToken. |
|
2900 |
pos := tokenPosition. |
|
2901 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 2902 |
pos2 := tokenPosition + tokenName size - 1. |
2903 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
663 | 2904 |
var := Variable name:tokenName. |
883 | 2905 |
|
663 | 2906 |
methodVars isNil ifTrue:[ |
2907 |
methodVars := OrderedCollection with:var. |
|
2908 |
methodVarNames := OrderedCollection with:tokenName |
|
2909 |
] ifFalse:[ |
|
2910 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 2911 |
"/ redefinition |
2912 |
self isSyntaxHighlighter ifTrue:[ |
|
2913 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
2914 |
] ifFalse:[ |
|
2915 |
self |
|
2916 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
2917 |
position:tokenPosition to:pos2. |
|
2918 |
] |
|
663 | 2919 |
] ifFalse:[ |
2920 |
methodVars add:var. |
|
2921 |
methodVarNames add:tokenName |
|
2922 |
] |
|
2923 |
]. |
|
883 | 2924 |
|
663 | 2925 |
methodArgNames notNil ifTrue:[ |
2926 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
883 | 2927 |
self |
2928 |
warning:'local variable ''' , tokenName , ''' hides argument.' |
|
2929 |
position:tokenPosition to:pos2 |
|
663 | 2930 |
] |
2931 |
]. |
|
2932 |
self nextToken. |
|
2933 |
pos := tokenPosition |
|
2934 |
]. |
|
883 | 2935 |
|
663 | 2936 |
(tokenType ~~ $|) ifTrue:[ |
2937 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
883 | 2938 |
msg := 'Reserved keyword in local var declaration'. |
2939 |
pos2 := tokenPosition + tokenName size - 1. |
|
2940 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 2941 |
] ifFalse:[ |
883 | 2942 |
pos2 := source position-1. |
663 | 2943 |
msg := 'Identifier or | expected in local var declaration' |
2944 |
]. |
|
883 | 2945 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 2946 |
^ #Error |
2947 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2948 |
localVarDefPosition := Array with:localVarDefPosition with:tokenPosition. |
663 | 2949 |
self nextToken |
0 | 2950 |
]. |
2951 |
^ nil |
|
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
2952 |
|
663 | 2953 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 2954 |
! |
2955 |
||
141 | 2956 |
parseMethodSpec |
2957 |
"parse a methods selector & arg specification; |
|
2958 |
Set selector and methodArgs in the receiver as a side effect. |
|
2959 |
Return the receiver or #Error. |
|
2960 |
||
2961 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2962 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2963 |
| IDENTIFIER |
141 | 2964 |
" |
2965 |
||
883 | 2966 |
|var pos2| |
141 | 2967 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2968 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2969 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2970 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
2971 |
|
141 | 2972 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2973 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2974 |
[tokenType == #Keyword] whileTrue:[ |
663 | 2975 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2976 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2977 |
self nextToken. |
883 | 2978 |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2979 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
883 | 2980 |
pos2 := tokenPosition+tokenName size-1. |
2981 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2982 |
var := Variable name:tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2983 |
methodArgs isNil ifTrue:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2984 |
methodArgs := Array with:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2985 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2986 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2987 |
(methodArgNames includes:tokenName) ifTrue:[ |
883 | 2988 |
"/ argname reuse |
2989 |
self isSyntaxHighlighter ifTrue:[ |
|
2990 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
2991 |
] ifFalse:[ |
|
2992 |
self |
|
2993 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
2994 |
position:tokenPosition to:pos2 |
|
2995 |
] |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2996 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2997 |
methodArgs := methodArgs copyWith:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2998 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2999 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3000 |
self nextToken |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3001 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3002 |
selector := selector asSymbol. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3003 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3004 |
^ self |
141 | 3005 |
]. |
3006 |
(tokenType == #Identifier) ifTrue:[ |
|
663 | 3007 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3008 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3009 |
self nextToken. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3010 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3011 |
^ self |
141 | 3012 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3013 |
|
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3014 |
"/ special handling for |, which is also a lexical token |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3015 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3016 |
tokenType := #BinaryOperator. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3017 |
tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3018 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3019 |
|
141 | 3020 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 3021 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3022 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3023 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3024 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
663 | 3025 |
self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3026 |
var := Variable name:tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3027 |
|
141 | 3028 |
"/ methodArgs isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3029 |
methodArgs := Array with:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3030 |
methodArgNames := Array with:tokenName. |
141 | 3031 |
"/ ] ifFalse:[ |
3032 |
"/ methodArgs := methodArgs copyWith:var. |
|
3033 |
"/ methodArgNames := methodArgNames copyWith:tokenName |
|
3034 |
"/ ]. |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3035 |
self nextToken. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3036 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3037 |
^ self |
141 | 3038 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3039 |
|
141 | 3040 |
^ #Error |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3041 |
|
663 | 3042 |
"Modified: / 31.3.1998 / 17:31:59 / cg" |
141 | 3043 |
! |
3044 |
||
265 | 3045 |
parsePrimitiveOrResourceSpecOrEmpty |
3046 |
"parse a methods primitive or resource spec" |
|
3047 |
||
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3048 |
|pos wmsg primNr| |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3049 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3050 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
619 | 3051 |
"/ an ST-80 primitive or resourceSpec - parsed but ignored |
3052 |
||
3053 |
pos := tokenPosition. |
|
3054 |
self nextToken. |
|
3055 |
primNr := self parseST80Primitive. |
|
3056 |
||
3057 |
(primNr == #Error) ifTrue:[^ #Error]. |
|
3058 |
wmsg := nil. |
|
3059 |
||
3060 |
primNr < 0 ifTrue:[ |
|
3061 |
WarnST80Directives == true ifTrue:[ |
|
3062 |
wmsg := 'ST-80 directive ignored'. |
|
3063 |
]. |
|
3064 |
] ifFalse:[ |
|
3065 |
primitiveNr := primNr. |
|
3066 |
wmsg := 'ST-80 primitive may not work' |
|
3067 |
]. |
|
3068 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
|
265 | 3069 |
]. |
3070 |
||
3071 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3072 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
265 | 3073 |
! |
3074 |
||
7 | 3075 |
parseST80Primitive |
3076 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
|
19 | 3077 |
return primitive number or #Error. |
97 | 3078 |
Also, ST-80 style resource specs are parsed; the result is |
3079 |
left (as side effect) in primitiveResource. |
|
3080 |
(maybe someone else knows what to do with it ...) |
|
3081 |
||
3082 |
Well, as we now have this mechanism, I'll use it to mark methods which |
|
3083 |
do keyboard processing ... <resource: keyboard ( keys )> |
|
3084 |
For faster finding of used keyboard accelerators. |
|
19 | 3085 |
|
3086 |
st80Primitive ::= 'primitive:' INTEGER |
|
97 | 3087 |
st80Primitive ::= 'resource:' SYMBOL - ignored; leave SYMBOL in primitiveResource |
3088 |
st80Primitive ::= 'resource:' SYMBOL (...) - ignored; leave (SYMBOL (...)) in primitiveResource |
|
19 | 3089 |
" |
0 | 3090 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3091 |
|primNumber keys resource resourceValue| |
0 | 3092 |
|
60 | 3093 |
(tokenType ~~ #Keyword) ifTrue:[ |
619 | 3094 |
self parseError:'bad primitive definition (keyword expected)'. |
3095 |
^ #Error |
|
0 | 3096 |
]. |
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3097 |
|
60 | 3098 |
(tokenName = 'primitive:') ifTrue:[ |
619 | 3099 |
self nextToken. |
3100 |
(tokenType == #Integer) ifFalse:[ |
|
3101 |
self parseError:'primitive number expected'. |
|
3102 |
^ #Error |
|
3103 |
]. |
|
3104 |
primitiveNr notNil ifTrue:[ |
|
3105 |
self parseError:'only one primitive spec allowed'. |
|
3106 |
primNumber := -1. |
|
3107 |
] ifFalse:[ |
|
3108 |
primNumber := tokenValue. |
|
3109 |
]. |
|
3110 |
self nextToken. |
|
60 | 3111 |
] ifFalse:[ |
619 | 3112 |
(tokenName = 'resource:') ifTrue:[ |
3113 |
self nextToken. |
|
3114 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
3115 |
self parseError:'symbol expected'. |
|
3116 |
^ #Error |
|
3117 |
]. |
|
3118 |
primNumber := -1. |
|
3119 |
resource := tokenValue. |
|
3120 |
resourceValue := true. |
|
3121 |
||
3122 |
self nextToken. |
|
3123 |
||
3124 |
tokenType == $( ifTrue:[ |
|
3125 |
self nextToken. |
|
3126 |
keys := OrderedCollection new. |
|
3127 |
[tokenType == $) ] whileFalse:[ |
|
3128 |
keys add:tokenValue. |
|
3129 |
self nextToken. |
|
3130 |
]. |
|
3131 |
resourceValue := keys. |
|
3132 |
self nextToken. |
|
3133 |
]. |
|
3134 |
||
3135 |
primitiveResource isNil ifTrue:[ |
|
3136 |
primitiveResource := IdentityDictionary new. |
|
3137 |
]. |
|
3138 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
3139 |
] ifFalse:[ |
|
3140 |
self parseError:'unrecognized primitive'. |
|
3141 |
^ #Error |
|
3142 |
]. |
|
0 | 3143 |
]. |
97 | 3144 |
|
0 | 3145 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifFalse:[ |
619 | 3146 |
self parseError:'bad primitive definition (> expected)'. |
3147 |
^ #Error |
|
0 | 3148 |
]. |
3149 |
self nextToken. |
|
3150 |
^ primNumber |
|
221
35b92bf6d9ef
parse style-resource directive
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
3151 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3152 |
"Modified: 29.5.1996 / 17:24:09 / cg" |
0 | 3153 |
! |
3154 |
||
713 | 3155 |
statement |
3156 |
"parse a statement; return a node-tree or #Error. |
|
3157 |
||
3158 |
statement ::= '^' expression |
|
3159 |
| PRIMITIVECODE |
|
3160 |
| expression |
|
3161 |
" |
|
3162 |
||
3163 |
|expr node lnr| |
|
3164 |
||
3165 |
(tokenType == $^) ifTrue:[ |
|
837 | 3166 |
self markReturnAt:tokenPosition. |
713 | 3167 |
lnr := tokenLineNr. |
3168 |
self nextToken. |
|
3169 |
expr := self expression. |
|
3170 |
(expr == #Error) ifTrue:[^ #Error]. |
|
3171 |
node := ReturnNode expression:expr. |
|
3172 |
node home:self blockHome:currentBlock. |
|
3173 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
3174 |
^ node |
|
3175 |
]. |
|
3176 |
||
3177 |
(tokenType == #Primitive) ifTrue:[ |
|
3178 |
self nextToken. |
|
3179 |
node := PrimitiveNode code:tokenValue. |
|
3180 |
node isOptional ifFalse:[ |
|
3181 |
hasNonOptionalPrimitiveCode := true |
|
3182 |
]. |
|
3183 |
hasPrimitiveCode := true. |
|
3184 |
^ node |
|
3185 |
]. |
|
3186 |
||
3187 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3188 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3189 |
self syntaxError:'missing '']'' at end of block'. |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3190 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3191 |
self syntaxError:'period after last statement'. |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3192 |
]. |
713 | 3193 |
^ #Error |
3194 |
]. |
|
3195 |
||
3196 |
expr := self expression. |
|
3197 |
(expr == #Error) ifTrue:[^ #Error]. |
|
3198 |
||
3199 |
"/ classToCompileFor notNil ifTrue:[ |
|
3200 |
"/ currentBlock isNil ifTrue:[ |
|
3201 |
"/ expr isPrimary ifTrue:[ |
|
3202 |
"/ self warning:'useless computation - missing ^ ?' |
|
3203 |
"/ ] |
|
3204 |
"/ ] |
|
3205 |
"/ ]. |
|
3206 |
||
3207 |
node := StatementNode expression:expr. |
|
3208 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
3209 |
^ node |
|
3210 |
||
837 | 3211 |
"Modified: / 5.1.1980 / 00:45:20 / cg" |
713 | 3212 |
! |
3213 |
||
3214 |
statementList |
|
3215 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
3216 |
Statements must be separated by periods. |
|
3217 |
||
3218 |
statementList ::= <statement> |
|
3219 |
| <statementList> . <statement> |
|
3220 |
" |
|
3221 |
||
3222 |
|thisStatement prevStatement firstStatement correctIt periodPos |
|
3223 |
prevExpr| |
|
3224 |
||
3225 |
thisStatement := self statement. |
|
3226 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3227 |
firstStatement := thisStatement. |
|
3228 |
[tokenType == $.] whileTrue:[ |
|
3229 |
prevExpr := thisStatement expression. |
|
3230 |
(prevExpr notNil and:[prevExpr isMessage]) ifTrue:[ |
|
3231 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
3232 |
self warning:'useless computation - mistyped assignment ?' |
|
3233 |
]. |
|
3234 |
]. |
|
3235 |
||
3236 |
periodPos := tokenPosition. |
|
3237 |
self nextToken. |
|
3238 |
(tokenType == $]) ifTrue:[ |
|
3239 |
currentBlock isNil ifTrue:[ |
|
3240 |
self parseError:'block nesting error'. |
|
3241 |
errorFlag := true |
|
3242 |
" |
|
3243 |
*** I had a warning here (since it was not defined |
|
3244 |
*** in the blue-book; but PD-code contains a lot of |
|
3245 |
*** code with periods at the end so that the warnings |
|
3246 |
*** became annoying |
|
3247 |
||
3248 |
] ifFalse:[ |
|
3249 |
self warning:'period after last statement' position:periodPos |
|
3250 |
" |
|
3251 |
]. |
|
3252 |
^ firstStatement |
|
3253 |
]. |
|
3254 |
(tokenType == #EOF) ifTrue:[ |
|
3255 |
currentBlock notNil ifTrue:[ |
|
3256 |
self parseError:'block nesting error (expected '']'')'. |
|
3257 |
errorFlag := true |
|
3258 |
" |
|
3259 |
*** I had a warning here (since it was not defined |
|
3260 |
*** in the blue-book; but PD-code contains a lot of |
|
3261 |
*** code with periods at the end so that the warnings |
|
3262 |
*** became annoying |
|
3263 |
||
3264 |
] ifFalse:[ |
|
3265 |
self warning:'period after last statement' position:periodPos |
|
3266 |
" |
|
3267 |
]. |
|
3268 |
^ firstStatement |
|
3269 |
]. |
|
3270 |
||
3271 |
prevStatement := thisStatement. |
|
3272 |
prevStatement isReturnNode ifTrue:[ |
|
3273 |
self warning:'statements after return' position:tokenPosition |
|
3274 |
]. |
|
3275 |
" |
|
3276 |
periodPos := tokenPosition. |
|
3277 |
self nextToken. |
|
3278 |
" |
|
3279 |
||
3280 |
((tokenType == $]) or:[tokenType == #EOF]) ifTrue:[ |
|
3281 |
(currentBlock isNil and:[tokenType == $]]) ifTrue:[ |
|
3282 |
self parseError:'block nesting error'. |
|
3283 |
errorFlag := true |
|
3284 |
] ifFalse:[ |
|
3285 |
correctIt := self correctableError:'period after last statement in block' |
|
3286 |
position:periodPos to:(periodPos + 1). |
|
3287 |
correctIt ifTrue:[ |
|
3288 |
(self correctByDeleting == #Error) ifTrue:[ |
|
3289 |
errorFlag := true |
|
3290 |
] |
|
3291 |
] |
|
3292 |
]. |
|
3293 |
^ firstStatement |
|
3294 |
]. |
|
3295 |
thisStatement := self statement. |
|
3296 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3297 |
prevStatement nextStatement:thisStatement |
|
3298 |
]. |
|
3299 |
^ firstStatement |
|
3300 |
||
3301 |
"Modified: 14.4.1997 / 20:46:46 / cg" |
|
3302 |
! ! |
|
3303 |
||
3304 |
!Parser methodsFor:'parsing-expressions'! |
|
3305 |
||
3306 |
array |
|
3307 |
|arr elements elem pos1| |
|
3308 |
||
3309 |
pos1 := tokenPosition. |
|
3310 |
elements := OrderedCollection new:20. |
|
3311 |
[tokenType ~~ $) ] whileTrue:[ |
|
3312 |
elem := self arrayConstant. |
|
3313 |
(elem == #Error) ifTrue:[ |
|
3314 |
(tokenType == #EOF) ifTrue:[ |
|
3315 |
self syntaxError:'unterminated array-constant; '')'' expected' |
|
3316 |
position:pos1 to:tokenPosition |
|
3317 |
]. |
|
3318 |
^ #Error |
|
3319 |
]. |
|
3320 |
elem isSymbol ifTrue:[ |
|
3321 |
self markSymbolFrom:tokenPosition to:(source position-1). |
|
3322 |
]. |
|
3323 |
elements add:elem. |
|
3324 |
self nextToken |
|
3325 |
]. |
|
3326 |
arr := Array withAll:elements. |
|
3327 |
||
3328 |
(ArraysAreImmutable and:[ImmutableArray notNil]) ifTrue:[ |
|
3329 |
arr changeClassTo:ImmutableArray. |
|
3330 |
]. |
|
3331 |
^ arr |
|
3332 |
||
3333 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
3334 |
! |
|
3335 |
||
3336 |
arrayConstant |
|
3337 |
(tokenType == #Nil) ifTrue:[ |
|
3338 |
^ nil |
|
3339 |
]. |
|
3340 |
((tokenType == #Integer) |
|
3341 |
or:[tokenType == #Float]) ifTrue:[ |
|
3342 |
^ tokenValue |
|
3343 |
]. |
|
3344 |
((tokenType == #String) |
|
3345 |
or:[tokenType == #Character]) ifTrue:[ |
|
3346 |
^ tokenValue |
|
3347 |
]. |
|
3348 |
(tokenType == #True) ifTrue:[ |
|
3349 |
^ true |
|
3350 |
]. |
|
3351 |
(tokenType == #False) ifTrue:[ |
|
3352 |
^ false |
|
3353 |
]. |
|
3354 |
(tokenType == #Error) ifTrue:[ |
|
3355 |
^ #Error |
|
3356 |
]. |
|
3357 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
3358 |
^ tokenName asSymbol |
|
3359 |
]. |
|
3360 |
||
3361 |
"/ some more special symbol consts ... |
|
3362 |
(tokenType == $| ) ifTrue:[ |
|
3363 |
^ #| |
|
3364 |
]. |
|
3365 |
(tokenType == #Self ) ifTrue:[ |
|
3366 |
^ #'self' |
|
3367 |
]. |
|
3368 |
(tokenType == #Super ) ifTrue:[ |
|
3369 |
^ #'super' |
|
3370 |
]. |
|
3371 |
(tokenType == #Here ) ifTrue:[ |
|
3372 |
^ #'here' |
|
3373 |
]. |
|
3374 |
(tokenType == #ThisContext ) ifTrue:[ |
|
3375 |
^ #'thisContext' |
|
3376 |
]. |
|
3377 |
||
3378 |
((tokenType == #Keyword) |
|
3379 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
3380 |
^ tokenName asSymbol |
|
3381 |
]. |
|
3382 |
((tokenType == $() |
|
3383 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
3384 |
self nextToken. |
|
3385 |
^ self array |
|
3386 |
]. |
|
3387 |
((tokenType == $[) |
|
3388 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
3389 |
self nextToken. |
|
3390 |
^ self byteArray |
|
3391 |
]. |
|
3392 |
(tokenType == #Symbol) ifTrue:[ |
|
3393 |
^ tokenValue |
|
3394 |
]. |
|
3395 |
(tokenType == #EOF) ifTrue:[ |
|
3396 |
"just for the better error-hilight; let caller handle error" |
|
3397 |
^ #Error |
|
3398 |
]. |
|
3399 |
self syntaxError:('error in array-constant; ' |
|
3400 |
, tokenType printString |
|
3401 |
, ' unexpected'). |
|
3402 |
^ #Error |
|
3403 |
||
3404 |
"Modified: / 14.4.1998 / 18:22:54 / cg" |
|
3405 |
! |
|
3406 |
||
3407 |
binaryExpression |
|
3408 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
3409 |
||
3410 |
|receiver arg sel pos try lno note| |
|
3411 |
||
3412 |
receiver := self unaryExpression. |
|
3413 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
3414 |
||
3415 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
3416 |
expression or a negative constant, handle cases here" |
|
3417 |
||
3418 |
[(tokenType == #BinaryOperator) |
|
3419 |
or:[(tokenType == $|) |
|
3420 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
3421 |
and:[tokenValue < 0]]] |
|
3422 |
] whileTrue:[ |
|
3423 |
pos := tokenPosition. |
|
3424 |
||
3425 |
lno := tokenLineNr. |
|
3426 |
||
3427 |
"kludge here: bar and minus are not scanned as binop " |
|
3428 |
(tokenType == $|) ifTrue:[ |
|
3429 |
sel := '|'. |
|
3430 |
self nextToken |
|
3431 |
] ifFalse:[ |
|
3432 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
3433 |
sel := self selectorCheck:tokenName for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
|
3434 |
self nextToken |
|
3435 |
] ifFalse:[ |
|
3436 |
sel := '-'. |
|
3437 |
tokenValue := tokenValue negated |
|
3438 |
] |
|
3439 |
]. |
|
864 | 3440 |
self markSelector:sel from:pos to:(pos + sel size - 1) receiverNode:receiver. |
713 | 3441 |
|
3442 |
arg := self unaryExpression. |
|
3443 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3444 |
try := BinaryNode receiver:receiver selector:sel arg:arg fold:foldConstants. |
|
3445 |
(try isMemberOf:String) ifTrue:[ |
|
3446 |
self parseError:try position:pos to:tokenPosition. |
|
3447 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
3448 |
receiver := BinaryNode receiver:receiver selector:sel arg:arg fold:nil. |
|
787 | 3449 |
note := self plausibilityCheck:receiver. |
713 | 3450 |
note notNil ifTrue:[ |
3451 |
self warning:note position:pos to:tokenPosition |
|
3452 |
]. |
|
3453 |
] ifFalse:[ |
|
3454 |
receiver := try |
|
3455 |
]. |
|
3456 |
receiver lineNumber:lno. |
|
3457 |
receiver selectorPosition:pos. |
|
3458 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
3459 |
]. |
|
3460 |
^ receiver |
|
3461 |
||
3462 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
787 | 3463 |
"Modified: / 19.10.1998 / 19:56:40 / cg" |
713 | 3464 |
! |
3465 |
||
3466 |
byteArray |
|
3467 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
3468 |
||
3469 |
|bytes index limit newArray elem pos1 pos2| |
|
3470 |
||
3471 |
pos1 := tokenPosition. |
|
3472 |
bytes := ByteArray uninitializedNew:5000. |
|
3473 |
index := 0. limit := 5000. |
|
3474 |
[tokenType ~~ $] ] whileTrue:[ |
|
3475 |
pos2 := tokenPosition. |
|
3476 |
" |
|
3477 |
this is not good programming style, but speeds up |
|
3478 |
reading of huge byte arrays (i.e. stored Images ...) |
|
3479 |
" |
|
3480 |
(tokenType == #Integer) ifTrue:[ |
|
3481 |
elem := tokenValue |
|
3482 |
] ifFalse:[ |
|
3483 |
elem := self arrayConstant. |
|
3484 |
(elem == #Error) ifTrue:[ |
|
3485 |
(tokenType == #EOF) ifTrue:[ |
|
3486 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
3487 |
position:pos1 to:tokenPosition |
|
3488 |
]. |
|
3489 |
^ #Error |
|
3490 |
]. |
|
3491 |
]. |
|
3492 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
3493 |
index := index + 1. |
|
3494 |
bytes at:index put:elem. |
|
3495 |
index == limit ifTrue:[ |
|
3496 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
3497 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
3498 |
limit := limit * 2. |
|
3499 |
bytes := newArray |
|
3500 |
]. |
|
3501 |
] ifFalse:[ |
|
3502 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
3503 |
]. |
|
3504 |
self nextToken. |
|
3505 |
]. |
|
3506 |
newArray := ByteArray uninitializedNew:index. |
|
3507 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
3508 |
^ newArray |
|
3509 |
! |
|
3510 |
||
3511 |
degeneratedKeywordExpressionForSelector |
|
3512 |
"parse a keyword-expression without receiver - for the selector |
|
3513 |
only. return the selector or nil. This is not used in normal parsing, |
|
3514 |
but instead to extract the selector from a code fragment. |
|
3515 |
(for example, the system browsers implementors-function uses this)" |
|
3516 |
||
3517 |
|sel arg rec| |
|
3518 |
||
3519 |
(tokenType == #Keyword) ifTrue:[ |
|
3520 |
sel := tokenName. |
|
3521 |
self nextToken. |
|
3522 |
arg := self binaryExpression. |
|
3523 |
(arg == #Error) ifTrue:[^ sel]. |
|
3524 |
[tokenType == #Keyword] whileTrue:[ |
|
3525 |
sel := sel , tokenName. |
|
3526 |
self nextToken. |
|
3527 |
arg := self binaryExpression. |
|
3528 |
(arg == #Error) ifTrue:[^ sel]. |
|
3529 |
]. |
|
3530 |
^ sel |
|
3531 |
]. |
|
3532 |
||
3533 |
(rec := self primary) ~~ #Error ifTrue:[ |
|
3534 |
sel := self degeneratedKeywordExpressionForSelector. |
|
3535 |
sel isNil ifTrue:[ |
|
3536 |
rec isMessage ifTrue:[ |
|
3537 |
sel := rec selector |
|
3538 |
] ifFalse:[ |
|
3539 |
rec isAssignment ifTrue:[ |
|
3540 |
rec expression isMessage ifTrue:[ |
|
3541 |
sel := rec expression selector |
|
3542 |
] |
|
3543 |
] |
|
3544 |
] |
|
3545 |
] |
|
3546 |
]. |
|
3547 |
^ sel |
|
3548 |
! |
|
3549 |
||
3550 |
expression |
|
3551 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
3552 |
||
3553 |
expression ::= keywordExpression |
|
3554 |
| keywordExpression cascade |
|
3555 |
||
3556 |
cascade ::= ';' expressionSendPart |
|
3557 |
| cascade ';' expressionSendPart |
|
3558 |
||
3559 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
3560 |
| BINARYOPERATOR unaryExpression |
|
3561 |
| IDENTIFIER |
|
3562 |
" |
|
3563 |
||
864 | 3564 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 3565 |
|
3566 |
pos := tokenPosition. |
|
3567 |
receiver := self keywordExpression. |
|
3568 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
3569 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3570 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3571 |
self syntaxError:'left side of cascade must be a message expression' |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3572 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3573 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3574 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3575 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3576 |
]. |
713 | 3577 |
[tokenType == $;] whileTrue:[ |
3578 |
self nextToken. |
|
3579 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3580 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 3581 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3582 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 3583 |
receiver := CascadeNode receiver:receiver selector:sel. |
3584 |
receiver lineNumber:tokenLineNr. |
|
3585 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
3586 |
self nextToken. |
|
3587 |
] ifFalse:[ |
|
3588 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3589 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 3590 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3591 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 3592 |
lno := tokenLineNr. |
3593 |
self nextToken. |
|
3594 |
arg := self unaryExpression. |
|
3595 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3596 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
3597 |
receiver lineNumber:lno. |
|
3598 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
3599 |
] ifFalse:[ |
|
3600 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3601 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 3602 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3603 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3604 |
pos2 := tokenEnd. |
713 | 3605 |
lno := tokenLineNr. |
3606 |
sel := tokenName. |
|
3607 |
self nextToken. |
|
3608 |
arg := self binaryExpression. |
|
3609 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3610 |
args := Array with:arg. |
|
3611 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3612 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 3613 |
positions add:(tokenPosition to:tokenEnd). |
713 | 3614 |
sel := sel , tokenName. |
3615 |
self nextToken. |
|
3616 |
arg := self binaryExpression. |
|
3617 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3618 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
3619 |
pos2 := tokenEnd |
713 | 3620 |
]. |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3621 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
864 | 3622 |
|
3623 |
positions do:[:p | |
|
3624 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
3625 |
]. |
|
713 | 3626 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
3627 |
receiver lineNumber:lno. |
|
3628 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
3629 |
] ifFalse:[ |
|
3630 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
3631 |
self syntaxError:('invalid cascade; ' , tokenType printString , ' unexpected') |
|
3632 |
position:tokenPosition to:source position - 1. |
|
3633 |
^ #Error |
|
3634 |
] |
|
3635 |
] |
|
3636 |
] |
|
3637 |
]. |
|
3638 |
||
3639 |
"obscure (unspecified ?) if selector follows; Question: |
|
3640 |
||
3641 |
is |
|
3642 |
'expr sel1; sel2 sel3' |
|
3643 |
||
3644 |
to be parsed as: |
|
3645 |
(t := expr. |
|
3646 |
t sel1. |
|
3647 |
t sel2) sel3 |
|
3648 |
||
3649 |
or: |
|
3650 |
(t := expr. |
|
3651 |
t sel1. |
|
3652 |
t sel2 sel3) |
|
3653 |
" |
|
3654 |
((tokenType == #Identifier) |
|
3655 |
or:[(tokenType == #BinaryOperator) |
|
3656 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
3657 |
self syntaxError:'ambigous cascade - please group using ( ...)' |
|
3658 |
position:tokenPosition to:source position - 1. |
|
3659 |
^ #Error |
|
3660 |
] |
|
3661 |
]. |
|
3662 |
^ receiver |
|
3663 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3664 |
"Modified: / 16.7.1998 / 20:46:59 / cg" |
713 | 3665 |
! |
3666 |
||
3667 |
keywordExpression |
|
3668 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
3669 |
||
3670 |
keywordExpression ::= binaryexpression |
|
3671 |
| { KEYWORD-PART binaryExpression } |
|
3672 |
" |
|
3673 |
||
864 | 3674 |
|receiver sel arg args posR1 posR2 pos1 pos2 try lno note positions| |
713 | 3675 |
|
3676 |
posR1 := tokenPosition. |
|
3677 |
receiver := self binaryExpression. |
|
3678 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
3679 |
(tokenType == #Keyword) ifTrue:[ |
|
3680 |
pos1 := posR2 := tokenPosition. |
|
3681 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 3682 |
positions := OrderedCollection with:(pos1 to:pos2). |
713 | 3683 |
sel := tokenName. |
3684 |
lno := tokenLineNr. |
|
3685 |
self nextToken. |
|
3686 |
arg := self binaryExpression. |
|
3687 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3688 |
args := Array with:arg. |
|
3689 |
[tokenType == #Keyword] whileTrue:[ |
|
3690 |
sel := sel , tokenName. |
|
3691 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 3692 |
positions add:(tokenPosition to:pos2). |
713 | 3693 |
self nextToken. |
3694 |
arg := self binaryExpression. |
|
3695 |
(arg == #Error) ifTrue:[^ #Error]. |
|
3696 |
args := args copyWith:arg. |
|
3697 |
]. |
|
864 | 3698 |
|
3699 |
positions do:[:p | |
|
3700 |
self markSelector:sel from:p start to:p stop receiverNode:receiver. |
|
3701 |
]. |
|
713 | 3702 |
sel := self selectorCheck:sel for:receiver position:pos1 to:pos2. |
864 | 3703 |
|
713 | 3704 |
try := MessageNode receiver:receiver selector:sel args:args fold:foldConstants. |
3705 |
(try isMemberOf:String) ifTrue:[ |
|
3706 |
self parseError:try position:pos1 to:pos2. |
|
3707 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
3708 |
receiver := MessageNode receiver:receiver selector:sel args:args fold:nil. |
|
787 | 3709 |
note := self plausibilityCheck:receiver. |
713 | 3710 |
note notNil ifTrue:[ |
3711 |
self warning:note position:pos1 to:pos2 |
|
3712 |
]. |
|
3713 |
] ifFalse:[ |
|
3714 |
receiver := try |
|
3715 |
]. |
|
3716 |
receiver lineNumber:lno. |
|
3717 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
3718 |
||
3719 |
(sel = #and: |
|
3720 |
or:[sel = #or:]) ifTrue:[ |
|
3721 |
receiver arg1 isBlock ifFalse:[ |
|
3722 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
3723 |
position:pos2+1 to:tokenPosition-1 |
|
3724 |
] |
|
3725 |
]. |
|
3726 |
(sel = #whileTrue: |
|
3727 |
or:[sel = #whileFalse:]) ifTrue:[ |
|
3728 |
receiver receiver isBlock ifFalse:[ |
|
3729 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
3730 |
position:posR1 to:posR2-1 |
|
3731 |
] |
|
3732 |
]. |
|
3733 |
]. |
|
3734 |
^ receiver |
|
3735 |
||
787 | 3736 |
"Modified: / 19.10.1998 / 19:56:55 / cg" |
713 | 3737 |
! |
3738 |
||
0 | 3739 |
primary |
3740 |
"parse a primary-expression; return a node-tree, nil or #Error" |
|
3741 |
||
390
5ba190b979d4
warn about another beginners error
Claus Gittinger <cg@exept.de>
parents:
387
diff
changeset
|
3742 |
|val var expr pos name t cls nameSpace nameSpaceGlobal globlName lnr node |
432 | 3743 |
pos2 eMsg| |
0 | 3744 |
|
3745 |
pos := tokenPosition. |
|
44 | 3746 |
(tokenType == #Self) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3747 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3748 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3749 |
self parseError:'assignment to self' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3750 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3751 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3752 |
selfNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3753 |
selfNode := SelfNode value:selfValue |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3754 |
]. |
663 | 3755 |
self markSelfFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3756 |
^ selfNode |
44 | 3757 |
]. |
869 | 3758 |
|
0 | 3759 |
(tokenType == #Identifier) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3760 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3761 |
must check for variable first, to be backward compatible |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3762 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3763 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3764 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3765 |
(self variableOrError:tokenName) == #Error ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3766 |
tokenType := #Here. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3767 |
warnSTXHereExtensionUsed ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3768 |
self warning:'here-sends are a nonstandard feature of ST/X' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3769 |
position:pos to:pos+3. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3770 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3771 |
only warn once |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3772 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3773 |
warnSTXHereExtensionUsed := false |
663 | 3774 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3775 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3776 |
] |
49 | 3777 |
]. |
3778 |
||
3779 |
(tokenType == #Identifier) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3780 |
name := tokenName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3781 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3782 |
var := self variable. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3783 |
(var == #Error) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3784 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3785 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3786 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3787 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3788 |
(tokenType == #'::') ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3789 |
globlName := name. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3790 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3791 |
"is it in a namespace ?" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3792 |
nameSpace := self findNameSpaceWith:globlName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3793 |
nameSpace notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3794 |
globlName := nameSpace name , '::' , globlName |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3795 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3796 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3797 |
[tokenType == #'::'] whileTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3798 |
nameSpace := globlName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3799 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3800 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3801 |
(tokenType == #Identifier) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3802 |
ignoreWarnings ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3803 |
warnSTXNameSpaceUse ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3804 |
self warning:'nameSpaces are a nonstandard feature of ST/X' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3805 |
position:pos to:(source position). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3806 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3807 |
only warn once |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3808 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3809 |
warnSTXNameSpaceUse := false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3810 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3811 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3812 |
name := tokenName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3813 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3814 |
globlName := (nameSpace , '::' , name). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3815 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3816 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3817 |
nameSpaceGlobal isNil ifTrue:[ |
647
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3818 |
self warning:('unknown nameSpace: ', nameSpace) |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3819 |
position:pos to:tokenPosition-1. |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3820 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3821 |
"/ errorFlag := true |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3822 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3823 |
nameSpaceGlobal isNamespace ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3824 |
"/ for now: only Smalltalk is allowed |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3825 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
424 | 3826 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
3827 |
"/ errorFlag := true |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3828 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3829 |
globlName := name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3830 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3831 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3832 |
nameSpaceGlobal isBehavior ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3833 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos to:tokenPosition-1. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3834 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3835 |
] ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3836 |
(nameSpaceGlobal privateClassesAt:name asSymbol) isNil ifTrue:[ |
647
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3837 |
self warning:('no private class: ' , name , ' in class: ' , nameSpace) |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3838 |
position:pos to:tokenPosition-1. |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3839 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
3840 |
"/ errorFlag := true |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3841 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3842 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3843 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3844 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3845 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3846 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3847 |
var := VariableNode |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3848 |
type:#GlobalVariable |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3849 |
name:globlName asSymbol. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3850 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
869 | 3851 |
]. |
3852 |
self markVariable:var from:pos to:pos+var name size - 1. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3853 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3854 |
|
869 | 3855 |
var == #Error ifTrue:[ |
3856 |
^ #Error |
|
3857 |
]. |
|
687 | 3858 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3859 |
((tokenType == $_) or:[tokenType == #':=']) ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3860 |
^ var |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3861 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3862 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3863 |
"/ careful: it could already be an implicit self send |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3864 |
ImplicitSelfSends ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3865 |
var isMessage ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3866 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3867 |
expr := self expression. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3868 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3869 |
selfNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3870 |
selfNode := SelfNode value:selfValue |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3871 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3872 |
^ MessageNode receiver:selfNode selector:('implicit_' , name , ':') asSymbol arg:expr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3873 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3874 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3875 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3876 |
(var ~~ #Error) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3877 |
t := var type. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3878 |
(t ~~ #MethodVar) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3879 |
(t == #PrivateClass) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3880 |
self parseError:'assignment to private class' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3881 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3882 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3883 |
(t == #MethodArg) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3884 |
self parseError:'assignment to method argument' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3885 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3886 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3887 |
(t == #BlockArg) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3888 |
self parseError:'assignment to block argument' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3889 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3890 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3891 |
(t == #InstanceVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3892 |
name := self classesInstVarNames at:(var index). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3893 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3894 |
"/ ca once did this to `name' and wondered what happened to his class ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3895 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3896 |
"/ and is hard to track down later) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3897 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3898 |
warnCommonMistakes ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3899 |
classToCompileFor isMeta ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3900 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3901 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3902 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of `Class'')' withCRs position:pos to:tokenPosition+1. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3903 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3904 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3905 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3906 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3907 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3908 |
modifiedInstVars isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3909 |
modifiedInstVars := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3910 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3911 |
modifiedInstVars add:name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3912 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3913 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3914 |
(t == #ClassVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3915 |
name := var name. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3916 |
name := name copyFrom:((name indexOf:$:) + 1). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3917 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3918 |
modifiedClassVars isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3919 |
modifiedClassVars := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3920 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3921 |
modifiedClassVars add:name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3922 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3923 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3924 |
(t == #GlobalVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3925 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3926 |
cls name = var name ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3927 |
self warning:'assignment to global which refers to a class' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3928 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3929 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3930 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3931 |
modifiedGlobals isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3932 |
modifiedGlobals := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3933 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3934 |
modifiedGlobals add:var name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3935 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3936 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3937 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3938 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3939 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3940 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3941 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3942 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3943 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3944 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3945 |
lnr := tokenLineNr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3946 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3947 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3948 |
pos2 := tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3949 |
expr := self expression. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3950 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3951 |
"/ a typical beginner error: |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3952 |
"/ expr ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3953 |
"/ var := super |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3954 |
"/ ] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3955 |
"/ var := something-else |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3956 |
"/ ]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3957 |
"/ var messageSend |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3958 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3959 |
"/ does not what a beginner might think. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3960 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3961 |
warnCommonMistakes ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3962 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3963 |
self warning:'followup messageSends to `' , var name , ''' will have normal send semantics\(i.e. NO super- or here-sends). Use self to avoid confusion.' withCRs position:pos to:pos2. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3964 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3965 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3966 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3967 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3968 |
node := AssignmentNode variable:var expression:expr. |
712 | 3969 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3970 |
^ node |
0 | 3971 |
]. |
49 | 3972 |
|
44 | 3973 |
((tokenType == #Integer) |
120 | 3974 |
or:[(tokenType == #String) |
44 | 3975 |
or:[(tokenType == #Character) |
3976 |
or:[(tokenType == #Float) |
|
3977 |
or:[(tokenType == #Symbol)]]]]) ifTrue:[ |
|
752 | 3978 |
((tokenType == #String) |
3979 |
and:[(StringsAreImmutable == true) |
|
3980 |
and:[ImmutableString notNil]]) ifTrue:[ |
|
3981 |
tokenValue := tokenValue copy. |
|
3982 |
tokenValue changeClassTo:ImmutableString. |
|
3983 |
]. |
|
3984 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3985 |
val := ConstantNode type:tokenType value:tokenValue. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3986 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3987 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3988 |
self parseError:'assignment to a constant' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3989 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3990 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3991 |
^ val |
0 | 3992 |
]. |
3993 |
(tokenType == #Nil) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3994 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3995 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3996 |
self parseError:'assignment to nil' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3997 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
3998 |
]. |
670 | 3999 |
"/ self markConstantFrom:pos to:pos+2. |
664 | 4000 |
nilNode isNil ifTrue:[ |
4001 |
nilNode := ConstantNode type:#Nil value:nil |
|
4002 |
]. |
|
4003 |
^ nilNode |
|
0 | 4004 |
]. |
4005 |
(tokenType == #True) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4006 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4007 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4008 |
self parseError:'assignment to true' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4009 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4010 |
]. |
670 | 4011 |
"/ self markBooleanConstantFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4012 |
^ ConstantNode type:#True value:true |
0 | 4013 |
]. |
4014 |
(tokenType == #False) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4015 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4016 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4017 |
self parseError:'assignment to false' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4018 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4019 |
]. |
670 | 4020 |
"/ self markBooleanConstantFrom:pos to:pos+4. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4021 |
^ ConstantNode type:#False value:false |
0 | 4022 |
]. |
4023 |
(tokenType == #Super) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4024 |
usesSuper := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4025 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4026 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4027 |
self parseError:'assignment to super' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4028 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4029 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4030 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4031 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4032 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4033 |
superNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4034 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4035 |
]. |
869 | 4036 |
self markSelfFrom:pos to:pos+5. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4037 |
^ superNode |
0 | 4038 |
]. |
49 | 4039 |
(tokenType == #Here) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4040 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4041 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4042 |
self parseError:'assignment to here' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4043 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4044 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4045 |
classToCompileFor isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4046 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4047 |
]. |
869 | 4048 |
self markSelfFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4049 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
49 | 4050 |
]. |
0 | 4051 |
(tokenType == #ThisContext) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4052 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4053 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4054 |
self parseError:'assignment to thisContext' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4055 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4056 |
]. |
663 | 4057 |
self markIdentifierFrom:pos to:pos+10. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4058 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4059 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4060 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4061 |
^ VariableNode type:#ThisContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4062 |
] |
0 | 4063 |
]. |
4064 |
(tokenType == #HashLeftParen) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4065 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4066 |
val := self array. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4067 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4068 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4069 |
self parseError:'assignment to a constant' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4070 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4071 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4072 |
^ ConstantNode type:#Array value:val |
0 | 4073 |
]. |
4074 |
(tokenType == #HashLeftBrack) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4075 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4076 |
val := self byteArray. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4077 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4078 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4079 |
self parseError:'assignment to a constant' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4080 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4081 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4082 |
^ ConstantNode type:#Array value:val |
0 | 4083 |
]. |
432 | 4084 |
|
0 | 4085 |
(tokenType == $() ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4086 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4087 |
val := self expression. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4088 |
(val == #Error) ifTrue:[^ #Error]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4089 |
(tokenType ~~ $) ) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4090 |
tokenType isCharacter ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4091 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4092 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4093 |
eMsg := 'missing '')'''. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4094 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4095 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4096 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4097 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4098 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4099 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4100 |
self parseError:'invalid assignment' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4101 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4102 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4103 |
val parenthized:true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4104 |
^ val |
0 | 4105 |
]. |
4106 |
(tokenType == $[ ) ifTrue:[ |
|
673 | 4107 |
self markBracketAt:tokenPosition. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4108 |
val := self block. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4109 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4110 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4111 |
self parseError:'invalid assignment' position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4112 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4113 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4114 |
^ val |
0 | 4115 |
]. |
19 | 4116 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4117 |
(tokenType == #Primitive) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4118 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4119 |
node := PrimitiveNode code:tokenValue. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4120 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4121 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4122 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4123 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4124 |
|
0 | 4125 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 4126 |
tokenType isCharacter ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4127 |
self syntaxError:('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4128 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4129 |
' unexpected') position:tokenPosition to:tokenPosition |
0 | 4130 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4131 |
(#(BinaryOperator Keyword) includes:tokenType) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4132 |
eMsg := ('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4133 |
, tokenType printString , '(' , tokenName , ') ' , |
805 | 4134 |
' unexpected (missing receiver ?)') |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4135 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4136 |
eMsg := ('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4137 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4138 |
' unexpected') |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4139 |
]. |
805 | 4140 |
self syntaxError:eMsg position:tokenPosition to:source position |
0 | 4141 |
]. |
4142 |
^ #Error |
|
120 | 4143 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4144 |
"Created: / 13.9.1995 / 12:50:50 / claus" |
752 | 4145 |
"Modified: / 3.8.1998 / 15:31:52 / cg" |
0 | 4146 |
! |
4147 |
||
141 | 4148 |
unaryExpression |
4149 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
4150 |
||
4151 |
|receiver sel pos pos2 try| |
|
4152 |
||
4153 |
receiver := self primary. |
|
4154 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
4155 |
[tokenType == #Identifier] whileTrue:[ |
|
663 | 4156 |
pos := tokenPosition. |
4157 |
pos2 := pos + tokenName size - 1. |
|
864 | 4158 |
self markSelector:tokenName from:pos to:pos2 receiverNode:receiver. |
663 | 4159 |
sel := self selectorCheck:tokenName for:receiver position:pos to:pos2. |
4160 |
try := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
|
4161 |
(try isMemberOf:String) ifTrue:[ |
|
4162 |
self parseError:try position:pos to:pos2. |
|
4163 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
4164 |
receiver := UnaryNode receiver:receiver selector:sel fold:nil. |
|
4165 |
] ifFalse:[ |
|
4166 |
receiver := try |
|
4167 |
]. |
|
4168 |
receiver lineNumber:tokenLineNr. |
|
4169 |
parseForCode ifFalse:[self rememberSelectorUsed:sel]. |
|
4170 |
self nextToken. |
|
141 | 4171 |
]. |
4172 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
4173 |
|
663 | 4174 |
"Modified: / 31.3.1998 / 17:53:36 / cg" |
141 | 4175 |
! |
4176 |
||
4177 |
variable |
|
4178 |
"parse a variable; if undefined, notify error and correct if user wants to" |
|
4179 |
||
864 | 4180 |
|v pos1 pos2| |
687 | 4181 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4182 |
v := self variableOrError:tokenName. |
664 | 4183 |
(v ~~ #Error) ifTrue:[ |
663 | 4184 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 4185 |
self markVariable:v. |
663 | 4186 |
]. |
4187 |
^ v |
|
4188 |
]. |
|
865 | 4189 |
|
687 | 4190 |
pos1 := tokenPosition. |
864 | 4191 |
pos2 := pos1+tokenName size-1. |
4192 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 4193 |
|
141 | 4194 |
v := self correctVariable. |
664 | 4195 |
(v ~~ #Error) ifTrue:[^ v]. |
4196 |
||
141 | 4197 |
parseForCode ifFalse:[ |
663 | 4198 |
self rememberGlobalUsed:tokenName |
141 | 4199 |
] ifTrue:[ |
663 | 4200 |
tokenName first isLowercase ifTrue:[ |
4201 |
ImplicitSelfSends ifTrue:[ |
|
4202 |
selfNode isNil ifTrue:[ |
|
4203 |
selfNode := SelfNode value:selfValue |
|
4204 |
]. |
|
4205 |
^ UnaryNode receiver:selfNode selector:('implicit_' , tokenName) asSymbol. |
|
4206 |
]. |
|
4207 |
^ #Error |
|
4208 |
] |
|
141 | 4209 |
]. |
865 | 4210 |
|
869 | 4211 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
141 | 4212 |
^ VariableNode type:#GlobalVariable name:tokenName asSymbol |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4213 |
|
687 | 4214 |
"Modified: / 16.4.1998 / 18:46:45 / cg" |
141 | 4215 |
! |
4216 |
||
0 | 4217 |
variableOrError |
4218 |
"parse a variable; return a node-tree, nil or #Error" |
|
4219 |
||
21 | 4220 |
^ self variableOrError:tokenName |
4221 |
! |
|
4222 |
||
4223 |
variableOrError:varName |
|
4224 |
"parse a variable; return a node-tree, nil or #Error" |
|
4225 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4226 |
|var varIndex aClass searchBlock args vars |
877 | 4227 |
tokenSymbol space classVarIndex holder| |
0 | 4228 |
|
4229 |
"is it a block-arg or block-var ?" |
|
4230 |
searchBlock := currentBlock. |
|
4231 |
[searchBlock notNil] whileTrue:[ |
|
628 | 4232 |
vars := searchBlock variables. |
4233 |
vars notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4234 |
varIndex := vars findFirst:[:aBlockVar | aBlockVar name = varName]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4235 |
varIndex ~~ 0 ifTrue:[ |
628 | 4236 |
^ VariableNode type:#BlockVariable |
4237 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4238 |
token:(vars at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4239 |
index:varIndex |
628 | 4240 |
block:searchBlock |
4241 |
from:currentBlock |
|
4242 |
]. |
|
4243 |
]. |
|
4244 |
||
4245 |
args := searchBlock arguments. |
|
4246 |
args notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4247 |
varIndex := args findFirst:[:aBlockArg | aBlockArg name = varName]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4248 |
varIndex ~~ 0 ifTrue:[ |
628 | 4249 |
^ VariableNode type:#BlockArg |
4250 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4251 |
token:(args at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4252 |
index:varIndex |
628 | 4253 |
block:searchBlock |
4254 |
from:currentBlock |
|
4255 |
]. |
|
4256 |
||
4257 |
]. |
|
4258 |
||
4259 |
searchBlock := searchBlock home |
|
0 | 4260 |
]. |
4261 |
||
4262 |
"is it a method-variable ?" |
|
4263 |
methodVars notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4264 |
varIndex := methodVarNames indexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4265 |
varIndex ~~ 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4266 |
var := methodVars at:varIndex. |
628 | 4267 |
var used:true. |
4268 |
^ VariableNode type:#MethodVariable |
|
4269 |
name:varName |
|
4270 |
token:var |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4271 |
index:varIndex |
628 | 4272 |
] |
0 | 4273 |
]. |
4274 |
||
4275 |
"is it a method-argument ?" |
|
4276 |
methodArgs notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4277 |
varIndex := methodArgNames indexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4278 |
varIndex ~~ 0 ifTrue:[ |
628 | 4279 |
^ VariableNode type:#MethodArg |
4280 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4281 |
token:(methodArgs at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4282 |
index:varIndex |
628 | 4283 |
] |
0 | 4284 |
]. |
4285 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4286 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4287 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4288 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4289 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4290 |
"/ search names of the context. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4291 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4292 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4293 |
[con notNil] whileTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4294 |
varNames := self class argAndVarNamesForContext:con. |
690 | 4295 |
varNames size > 0 ifTrue:[ |
4296 |
varIndex := varNames lastIndexOf:varName. |
|
4297 |
varIndex ~~ 0 ifTrue:[ |
|
4298 |
^ VariableNode type:#ContextVariable |
|
4299 |
name:varName |
|
4300 |
context:con |
|
4301 |
index:varIndex |
|
4302 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4303 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4304 |
con := con home. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4305 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4306 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4307 |
|
0 | 4308 |
classToCompileFor notNil ifTrue:[ |
628 | 4309 |
"is it an instance-variable ?" |
4310 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4311 |
varIndex := (self classesInstVarNames) lastIndexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4312 |
varIndex ~~ 0 ifTrue:[ |
628 | 4313 |
classToCompileFor isMeta ifTrue:[ |
4314 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
4315 |
classVarIndex ~~ 0 ifTrue:[ |
|
4316 |
"/ give a warning - that maybe a common error |
|
825 | 4317 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
4318 |
alreadyWarnedClassInstVarRefs := Set new |
|
4319 |
]. |
|
4320 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
4321 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
4322 |
alreadyWarnedClassInstVarRefs add:varName. |
|
4323 |
]. |
|
628 | 4324 |
]. |
4325 |
]. |
|
4326 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
4327 |
^ VariableNode type:#InstanceVariable |
|
4328 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4329 |
index:varIndex |
628 | 4330 |
selfValue:selfValue |
4331 |
]. |
|
4332 |
||
4333 |
"/ see if there is a corresponding classVar (for the warning) |
|
4334 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
4335 |
||
4336 |
"/ "is it a class-instance-variable ?" |
|
4337 |
"/ |
|
4338 |
"/ Notice: |
|
4339 |
"/ it is no longer allowed to fetch class-instance variables |
|
4340 |
"/ from instance methods ... |
|
4341 |
"/ (used to be in previous ST/X versions) |
|
4342 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4343 |
varIndex := (self classesClassInstVarNames) lastIndexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4344 |
varIndex ~~ 0 ifTrue:[ |
628 | 4345 |
aClass := self inWhichClassIsClassInstVar:varName. |
4346 |
aClass notNil ifTrue:[ |
|
4347 |
classToCompileFor isMeta ifFalse:[ |
|
4348 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4349 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4350 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4351 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4352 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4353 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4354 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4355 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4356 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4357 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4358 |
]. |
628 | 4359 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
4360 |
^ #Error. |
|
4361 |
] ifFalse:[ |
|
4362 |
"/ give a warning - that maybe a common error |
|
738 | 4363 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class variable here (instMethods dont see classInstVars).') withCRs. |
628 | 4364 |
] |
4365 |
]. |
|
4366 |
||
4367 |
"/ OLD CODE: |
|
4368 |
"/ self warning:'access to class-inst-var from inst method will soon be no longer supported'. |
|
443
e7d0bad68d60
oops - previous versions allowed access to class-instance variables
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
4369 |
"/ |
628 | 4370 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
4371 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
4372 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4373 |
"/ index:varIndex |
628 | 4374 |
"/ selfClass:aClass |
4375 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4376 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4377 |
"/ self halt:'oops - should not happen'. |
628 | 4378 |
] |
4379 |
]. |
|
4380 |
||
4381 |
"is it a class-variable ?" |
|
4382 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4383 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4384 |
varIndex ~~ 0 ifTrue:[ |
628 | 4385 |
aClass := self inWhichClassIsClassVar:varName. |
4386 |
aClass notNil ifTrue:[ |
|
4387 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
4388 |
^ VariableNode type:#ClassVariable class:aClass name:varName |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4389 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4390 |
"/ self halt:'oops - should not happen'. |
628 | 4391 |
]. |
4392 |
||
4393 |
"is it a private-class ?" |
|
4394 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4395 |
aClass := self classToLookForClassVars. |
628 | 4396 |
aClass isMeta ifTrue:[ |
4397 |
aClass := aClass soleInstance. |
|
4398 |
]. |
|
4399 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
|
4400 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
4401 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
4402 |
]. |
|
418 | 4403 |
]. |
4404 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4405 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4406 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4407 |
space notNil ifTrue:[ |
628 | 4408 |
space ~~ Smalltalk ifTrue:[ |
4409 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
4410 |
^ VariableNode type:#PrivateClass class:space name:varName |
|
4411 |
] ifFalse:[ |
|
4412 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
4413 |
^ VariableNode type:#GlobalVariable name:varName asSymbol |
|
4414 |
] |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4415 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4416 |
|
0 | 4417 |
"is it a global-variable ?" |
63 | 4418 |
tokenSymbol := varName asSymbolIfInterned. |
4419 |
tokenSymbol notNil ifTrue:[ |
|
628 | 4420 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
4421 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
4422 |
^ VariableNode type:#GlobalVariable name:tokenSymbol |
|
4423 |
] |
|
0 | 4424 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4425 |
|
877 | 4426 |
"is it a workspace variable ?" |
4427 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
4428 |
"/ when parsing doits, this is done twice; |
|
4429 |
"/ first, for the parse, then as a block-code |
|
4430 |
"/ for the code. |
|
4431 |
"/ We only care for WorkspaceVars in doIts |
|
4432 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
|
4433 |
(holder := Workspace workspaceVariableAt:varName) notNil ifTrue:[ |
|
4434 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
4435 |
] |
|
4436 |
] |
|
4437 |
]. |
|
4438 |
||
0 | 4439 |
^ #Error |
353 | 4440 |
|
825 | 4441 |
"Modified: / 8.3.1999 / 01:35:56 / cg" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4442 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4443 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4444 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4445 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4446 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4447 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4448 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4449 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4450 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4451 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4452 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4453 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4454 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4455 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4456 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4457 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4458 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4459 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4460 |
"Created: / 19.12.1996 / 23:47:58 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4461 |
"Modified: / 14.10.1997 / 20:56:06 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4462 |
"Modified: / 18.3.1999 / 18:25:50 / stefan" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4463 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4464 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4465 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4466 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4467 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4468 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4469 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
4470 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4471 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4472 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4473 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4474 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4475 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4476 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4477 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4478 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4479 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4480 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4481 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4482 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4483 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4484 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4485 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4486 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4487 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4488 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
4489 |
"Modified: / 7.4.1998 / 08:59:28 / cg" |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
4490 |
"Modified: / 18.3.1999 / 18:25:57 / stefan" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4491 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4492 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4493 |
findNameSpaceWith:aVariableName |
692 | 4494 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4495 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4496 |
"/ private names have already been searched for. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4497 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4498 |
classToCompileFor notNil ifTrue:[ |
619 | 4499 |
"/ Q: |
4500 |
"/ consider private classes of superclasses. |
|
4501 |
"/ or search in the top owing classes namespace only ? |
|
4502 |
||
4503 |
"/ for now, ignore other private classes - they are only |
|
4504 |
"/ known to the corresponding ownerClass. |
|
4505 |
||
4506 |
"is it in the classes namespace ?" |
|
4507 |
||
4508 |
classToCompileFor isPrivate ifTrue:[ |
|
4509 |
ns := classToCompileFor topOwningClass nameSpace |
|
4510 |
] ifFalse:[ |
|
4511 |
ns := classToCompileFor nameSpace. |
|
4512 |
]. |
|
4513 |
||
4514 |
(ns notNil |
|
4515 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
|
4516 |
(ns privateClassesAt:aVariableName) notNil ifTrue:[ |
|
4517 |
^ ns |
|
4518 |
] |
|
4519 |
]. |
|
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
4520 |
|
495 | 4521 |
"/ ns := classToCompileFor nameSpace. |
4522 |
"/ ns notNil ifTrue:[ |
|
4523 |
"/ "is it in the current classes namespace ?" |
|
4524 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
4525 |
"/ ^ ns |
|
4526 |
"/ ] |
|
4527 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4528 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4529 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4530 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4531 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4532 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4533 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
619 | 4534 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
4535 |
^ currentSpace |
|
4536 |
] |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4537 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4538 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4539 |
"is it in one of the used namespaces ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4540 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4541 |
usedSpaces notNil ifTrue:[ |
619 | 4542 |
usedSpaces do:[:aNameSpace | |
4543 |
(aNameSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
4544 |
^ aNameSpace |
|
4545 |
] |
|
4546 |
] |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4547 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4548 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4549 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
4550 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 4551 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 4552 |
! |
4553 |
||
4554 |
inWhichClassIsClassInstVar:aString |
|
4555 |
"search class-chain for the class-instance variable named aString |
|
4556 |
- return the class or nil if not found" |
|
4557 |
||
4558 |
|aClass| |
|
4559 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4560 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4561 |
|
713 | 4562 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4563 |
(aClass class instVarNames includes:aString) ifTrue:[ ^ aClass]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4564 |
aClass := aClass superclass |
713 | 4565 |
]. |
4566 |
^ nil |
|
4567 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4568 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 4569 |
! |
4570 |
||
4571 |
inWhichClassIsClassVar:aString |
|
4572 |
"search class-chain for the classvariable named aString |
|
4573 |
- return the class or nil if not found" |
|
4574 |
||
4575 |
|aClass className baseClass| |
|
4576 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4577 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4578 |
|
713 | 4579 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4580 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4581 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4582 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4583 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4584 |
] |
713 | 4585 |
]. |
4586 |
^ aClass whichClassDefinesClassVar:aString |
|
4587 |
||
4588 |
"/ [aClass notNil] whileTrue:[ |
|
4589 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
4590 |
"/ aClass := aClass superclass |
|
4591 |
"/ ]. |
|
4592 |
"/ ^ nil |
|
4593 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4594 |
"Modified: / 17.6.1996 / 17:18:41 / stefan" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4595 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 4596 |
! |
4597 |
||
4598 |
plausibilityCheck:aNode |
|
4599 |
^ aNode plausibilityCheck |
|
4600 |
||
4601 |
"Created: / 19.10.1998 / 19:56:09 / cg" |
|
4602 |
"Modified: / 19.10.1998 / 19:56:29 / cg" |
|
141 | 4603 |
! ! |
4604 |
||
4605 |
!Parser methodsFor:'queries'! |
|
4606 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4607 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4608 |
"helper - return the class to look for classVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4609 |
If there is a context in which we evaluate, the |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4610 |
methods implementing class is used instead of the |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4611 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4612 |
|
748 | 4613 |
|names m who cls| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4614 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4615 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 4616 |
m := contextToEvaluateIn method. |
4617 |
m notNil ifTrue:[ |
|
4618 |
who := contextToEvaluateIn method who. |
|
4619 |
who notNil ifTrue:[ |
|
4620 |
^ who methodClass. |
|
4621 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4622 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4623 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4624 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4625 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4626 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4627 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 4628 |
"Modified: / 21.7.1998 / 18:19:52 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4629 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4630 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4631 |
classesClassInstVarNames |
141 | 4632 |
"caching allInstVarNames for next compilation saves time ..." |
4633 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4634 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4635 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4636 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4637 |
|cls| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4638 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4639 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4640 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4641 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4642 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4643 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4644 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4645 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4646 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4647 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4648 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4649 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4650 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4651 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4652 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4653 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4654 |
"Created: / 14.10.1996 / 18:03:35 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4655 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 4656 |
! |
4657 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4658 |
classesClassVarNames |
141 | 4659 |
"caching allClassVarNames for next compilation saves time ..." |
4660 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4661 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4662 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4663 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4664 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4665 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4666 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4667 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4668 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4669 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4670 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4671 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4672 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4673 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4674 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4675 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4676 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4677 |
] |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4678 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4679 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4680 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4681 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4682 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4683 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4684 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
4685 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4686 |
"Modified: / 17.6.1996 / 17:15:53 / stefan" |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
4687 |
"Created: / 14.10.1996 / 18:02:41 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
4688 |
"Modified: / 18.6.1998 / 15:44:30 / cg" |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4689 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4690 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4691 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4692 |
"caching allInstVarNames for next compilation saves time ..." |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4693 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4694 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4695 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4696 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4697 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4698 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4699 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4700 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4701 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4702 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4703 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4704 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4705 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4706 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4707 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4708 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4709 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
4710 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4711 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4712 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 4713 |
! |
4714 |
||
141 | 4715 |
hasNonOptionalPrimitiveCode |
4716 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
4717 |
||
4718 |
^ hasNonOptionalPrimitiveCode |
|
0 | 4719 |
! |
4720 |
||
141 | 4721 |
hasPrimitiveCode |
4722 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
4723 |
||
4724 |
^ hasPrimitiveCode |
|
98 | 4725 |
! |
4726 |
||
883 | 4727 |
isSyntaxHighlighter |
4728 |
^ false |
|
4729 |
! |
|
4730 |
||
385 | 4731 |
lineNumberInfo |
4732 |
^ lineNumberInfo |
|
4733 |
||
4734 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
4735 |
! |
|
4736 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4737 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4738 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4739 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4740 |
"Created: 23.10.1996 / 15:39:43 / cg" |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4741 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
4742 |
|
141 | 4743 |
methodArgs |
4744 |
"return an array with methodarg names (valid after parsing spec)" |
|
4745 |
||
4746 |
^ methodArgNames |
|
4747 |
! |
|
4748 |
||
4749 |
methodVars |
|
4750 |
"return a collection with method variablenames (valid after parsing)" |
|
4751 |
||
4752 |
^ methodVarNames |
|
23 | 4753 |
! |
4754 |
||
141 | 4755 |
modifiedClassVars |
4756 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
4757 |
||
541 | 4758 |
^ modifiedClassVars ? #() |
4759 |
||
4760 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 4761 |
! |
4762 |
||
4763 |
modifiedGlobals |
|
4764 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
4765 |
||
541 | 4766 |
^ modifiedGlobals ? #() |
4767 |
||
4768 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 4769 |
! |
4770 |
||
4771 |
modifiedInstVars |
|
4772 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
4773 |
||
541 | 4774 |
^ modifiedInstVars ? #() |
4775 |
||
4776 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 4777 |
! |
4778 |
||
141 | 4779 |
numberOfMethodArgs |
4780 |
"return the number of methodargs (valid after parsing spec)" |
|
4781 |
||
4782 |
^ methodArgs size |
|
4783 |
! |
|
4784 |
||
4785 |
numberOfMethodVars |
|
4786 |
"return the number of method variables (valid after parsing)" |
|
4787 |
||
4788 |
^ methodVars size |
|
4789 |
! |
|
4790 |
||
4791 |
selector |
|
4792 |
"return the selector (valid after parsing spec)" |
|
4793 |
||
4794 |
^ selector |
|
0 | 4795 |
! |
4796 |
||
141 | 4797 |
usedClassVars |
4798 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
4799 |
||
541 | 4800 |
^ usedClassVars ? #() |
4801 |
||
4802 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 4803 |
! |
4804 |
||
4805 |
usedGlobals |
|
4806 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
4807 |
||
541 | 4808 |
^ usedGlobals ? #() |
4809 |
||
4810 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 4811 |
! |
4812 |
||
4813 |
usedInstVars |
|
4814 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
4815 |
||
541 | 4816 |
^ usedInstVars ? #() |
4817 |
||
4818 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 4819 |
! |
4820 |
||
4821 |
usedVars |
|
4822 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
4823 |
||
541 | 4824 |
^ usedVars ? #() |
4825 |
||
4826 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 4827 |
! |
4828 |
||
141 | 4829 |
usesSuper |
4830 |
"return true if the parsed method uses super (valid after parsing)" |
|
4831 |
||
4832 |
^ usesSuper |
|
4833 |
! ! |
|
4834 |
||
4835 |
!Parser methodsFor:'setup'! |
|
4836 |
||
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4837 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4838 |
"change the constant folding level. See the classMethod for a description." |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4839 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4840 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4841 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4842 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4843 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4844 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
4845 |
|
141 | 4846 |
initialize |
4847 |
super initialize. |
|
4848 |
||
4849 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
4850 |
warnSTXHereExtensionUsed := WarnSTXSpecials. |
|
4851 |
usesSuper := false. |
|
4852 |
parseForCode := false. |
|
377 | 4853 |
foldConstants := FoldConstants. |
4854 |
lineNumberInfo := LineNumberInfo. |
|
607 | 4855 |
warnUndeclared := true. |
4856 |
||
4857 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 4858 |
! |
4859 |
||
4860 |
parseForCode |
|
4861 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
4862 |
Use this when parsing for compilation or evaluation" |
|
4863 |
||
4864 |
parseForCode := true |
|
0 | 4865 |
! |
4866 |
||
141 | 4867 |
setClassToCompileFor:aClass |
4868 |
"set the class to be used for parsing/evaluating" |
|
4869 |
||
4870 |
classToCompileFor := aClass. |
|
4871 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
4872 |
PrevClass notNil ifTrue:[ |
|
4873 |
Parser update:PrevClass |
|
4874 |
] |
|
4875 |
] |
|
4876 |
! |
|
4877 |
||
4878 |
setContext:aContext |
|
4879 |
"set the context used while evaluating" |
|
4880 |
||
4881 |
contextToEvaluateIn := aContext |
|
4882 |
! |
|
4883 |
||
4884 |
setSelf:anObject |
|
4885 |
"set the value to be used for self while evaluating" |
|
4886 |
||
4887 |
selfValue := anObject. |
|
4888 |
classToCompileFor := anObject class. |
|
4889 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
4890 |
PrevClass notNil ifTrue:[ |
|
4891 |
Parser update:PrevClass |
|
4892 |
] |
|
4893 |
] |
|
607 | 4894 |
! |
4895 |
||
4896 |
warnUndeclared:aBoolean |
|
4897 |
warnUndeclared := aBoolean. |
|
4898 |
||
4899 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
0 | 4900 |
! ! |
4901 |
||
84 | 4902 |
!Parser methodsFor:'statistic'! |
4903 |
||
141 | 4904 |
rememberClassVarUsed:name |
4905 |
usedClassVars isNil ifTrue:[ |
|
4906 |
usedClassVars := Set new |
|
4907 |
]. |
|
4908 |
usedClassVars add:name. |
|
4909 |
self rememberVariableUsed:name |
|
4910 |
! |
|
4911 |
||
4912 |
rememberGlobalUsed:name |
|
4913 |
usedGlobals isNil ifTrue:[ |
|
4914 |
usedGlobals := Set new |
|
4915 |
]. |
|
4916 |
usedGlobals add:name. |
|
4917 |
self rememberVariableUsed:name |
|
4918 |
! |
|
4919 |
||
4920 |
rememberInstVarUsed:name |
|
4921 |
usedInstVars isNil ifTrue:[ |
|
4922 |
usedInstVars := Set new |
|
4923 |
]. |
|
4924 |
usedInstVars add:name. |
|
4925 |
self rememberVariableUsed:name |
|
4926 |
! |
|
4927 |
||
84 | 4928 |
rememberSelectorUsed:sel |
4929 |
usedMessages isNil ifTrue:[ |
|
4930 |
usedMessages := IdentitySet new. |
|
4931 |
]. |
|
4932 |
usedMessages add:sel |
|
4933 |
! |
|
4934 |
||
4935 |
rememberVariableUsed:name |
|
4936 |
usedVars isNil ifTrue:[ |
|
4937 |
usedVars := Set new |
|
4938 |
]. |
|
4939 |
usedVars add:name |
|
4940 |
! ! |
|
4941 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
4942 |
!Parser class methodsFor:'documentation'! |
148 | 4943 |
|
4944 |
version |
|
887 | 4945 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.207 1999-07-04 17:48:24 cg Exp $' |
148 | 4946 |
! ! |
141 | 4947 |
Parser initialize! |