author | Claus Gittinger <cg@exept.de> |
Wed, 07 May 2003 12:31:09 +0200 | |
changeset 1412 | af3ec9f24a38 |
parent 1411 | c71cf8b2be10 |
child 1413 | 75e5b1b10079 |
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 |
||
1043 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
0 | 15 |
Scanner subclass:#Parser |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
instanceVariableNames:'classToCompileFor selfValue contextToEvaluateIn selector |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
17 |
methodArgs methodArgNames methodVars methodVarNames tree |
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
18 |
currentBlock parseForCode readInstVars readClassVars readGlobals |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
19 |
usedInstVars usedClassVars usedVars modifiedInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
20 |
modifiedClassVars modifiedGlobals usesSuper usedGlobals |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
21 |
usedSymbols messagesSent messagesSentToSelf messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
22 |
localVarDefPosition evalExitBlock selfNode superNode nilNode |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
23 |
hasPrimitiveCode hasNonOptionalPrimitiveCode primitiveNr |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
24 |
primitiveResource logged warnedUndefVars warnedUnknownNamespaces |
1160 | 25 |
warnSTXHereExtensionUsed warnUnusedVars correctedSource |
26 |
foldConstants lineNumberInfo currentNamespace |
|
27 |
currentUsedNamespaces warnUndeclared methodNode |
|
28 |
alreadyWarnedClassInstVarRefs localBlockVarDefPosition |
|
29 |
endOfSelectorPosition startOfBlockPosition primitiveContextInfo |
|
30 |
usedLocalVars modifiedLocalVars alreadyWarnedUninitializedVars |
|
1295 | 31 |
alreadyWarnedUnimplementedSelectors returnedValues currentPackage |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
32 |
doItTemporaries inFunctionCallArgument' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
33 |
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
34 |
PrevClassInstVarNames LazyCompilation ArraysAreImmutable |
1160 | 35 |
ImplicitSelfSends WarnST80Directives WarnUnusedVars FoldConstants |
36 |
LineNumberInfo SuppressDoItCompilation StringsAreImmutable |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
37 |
ParseErrorSignal RestartCompilationSignal |
1295 | 38 |
AllowFunctionCallSyntaxForBlockEvaluation AllowLazyValueExtension |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
39 |
AllowVariableReferences AllowReservedWordsAsSelectors |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
40 |
AllowLocalVariableDeclarationWithInitializerExpression |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
41 |
AllowArrayIndexSyntaxExtension' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
42 |
poolDictionaries:'' |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
43 |
category:'System-Compiler' |
0 | 44 |
! |
45 |
||
1282
14b97cbd6eec
ParseError is an error, not an exception.
Stefan Vogel <sv@exept.de>
parents:
1277
diff
changeset
|
46 |
Error subclass:#ParseError |
1340 | 47 |
instanceVariableNames:'errorMessage startPosition endPosition' |
971 | 48 |
classVariableNames:'' |
49 |
poolDictionaries:'' |
|
50 |
privateIn:Parser |
|
51 |
! |
|
52 |
||
53 |
Parser::ParseError subclass:#UndefinedSuperclassError |
|
54 |
instanceVariableNames:'' |
|
55 |
classVariableNames:'' |
|
56 |
poolDictionaries:'' |
|
57 |
privateIn:Parser |
|
58 |
! |
|
59 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
60 |
Notification subclass:#UndefinedVariableNotification |
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
61 |
instanceVariableNames:'parser' |
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
62 |
classVariableNames:'' |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
63 |
poolDictionaries:'' |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
64 |
privateIn:Parser |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
65 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
66 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
67 |
!Parser class methodsFor:'documentation'! |
19 | 68 |
|
20 | 69 |
copyright |
70 |
" |
|
71 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
44 | 72 |
All Rights Reserved |
20 | 73 |
|
74 |
This software is furnished under a license and may be used |
|
75 |
only in accordance with the terms of that license and with the |
|
76 |
inclusion of the above copyright notice. This software may not |
|
77 |
be provided or otherwise made available to, or used by, any |
|
78 |
other person. No title to or ownership of the software is |
|
79 |
hereby transferred. |
|
80 |
" |
|
81 |
! |
|
82 |
||
19 | 83 |
documentation |
84 |
" |
|
85 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
86 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
87 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
88 |
the (planned) MachineCodeCompiler. |
|
89 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
90 |
methods of main interest are: |
755 | 91 |
Parser evaluateExpression:... |
19 | 92 |
|
93 |
and: |
|
755 | 94 |
Parser parseExpression:... |
95 |
Parser parseMethod:... |
|
19 | 96 |
|
97 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
98 |
||
99 |
Parser is also used to find the referenced/modified inst/classvars of |
|
100 |
a method - this is done by sending parseXXX message to a parser and asking |
|
101 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
102 |
||
103 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
104 |
example analyzes the expressions in the changelist ...) by looking at the |
|
105 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 106 |
compilers internals ... better style is to add specialized query methods here) |
19 | 107 |
|
108 |
One instance of Parser is created to parse one method or expression - i.e. |
|
109 |
its not suggested to reuse parsers. |
|
110 |
||
212
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 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
113 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
114 |
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
|
115 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
116 |
(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
|
117 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 124 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
125 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
126 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
127 |
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
|
128 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
129 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
130 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
131 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
132 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
133 |
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
|
134 |
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
|
135 |
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
|
136 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
143 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
144 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
145 |
|
260 | 146 |
[Instance variables:] |
147 |
||
755 | 148 |
classToCompileFor <Class> the class (or nil) we are compiling for |
149 |
||
150 |
selfValue <any> value to use as self when interpreting |
|
151 |
||
152 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
153 |
||
154 |
selector <Symbol> the selector of the parsed method |
|
155 |
(valid after parseMethodSpecification) |
|
156 |
methodArgs internal |
|
157 |
||
158 |
methodArgNames <Collection> the names of the arguments |
|
159 |
(valid after parseMethodSpecification) |
|
160 |
||
161 |
methodVars internal |
|
162 |
||
163 |
methodVarNames <Collection> the names of the method locals |
|
164 |
(valid after parseMethodBodyVarSpec) |
|
165 |
||
166 |
tree <ParseTree> the parse tree - valid after parsing |
|
167 |
||
168 |
currentBlock if currently parsing for a block |
|
169 |
||
170 |
usedInstVars set of all accessed instances variables |
|
171 |
(valid after parsing) |
|
172 |
||
173 |
usedClassVars same for classVars |
|
174 |
||
175 |
usedVars all used variables (inst, class & globals) |
|
176 |
||
177 |
modifiedInstVars set of all modified instance variables |
|
178 |
||
179 |
modifiedClassVars same for clasVars |
|
180 |
||
181 |
localVarDefPosition <Integer> the character offset of the local variable |
|
182 |
def. (i.e. the first '|' if any) |
|
183 |
Not yet used - prepared for automatic add of |
|
184 |
undefined variables |
|
185 |
||
186 |
evalExitBlock internal for interpretation |
|
187 |
||
188 |
selfNode <Node> cached one-and-only 'self' node |
|
189 |
superNode <Node> cached one-and-only 'super' node |
|
190 |
||
191 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
192 |
hasNonOptionalPrimitiveCode |
|
193 |
<Boolean> true, if it contains ST/X style primitive code |
|
194 |
which is NOT flagged by the OPTIONAL directive. |
|
195 |
||
196 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
197 |
||
198 |
logged |
|
199 |
||
200 |
warnedUndefVars <Set> set of all variables which the parser has |
|
201 |
already output a warning (to avoid multiple |
|
202 |
warnings about the same variable) |
|
260 | 203 |
|
204 |
[Class variables:] |
|
205 |
||
755 | 206 |
PrevClass <Class> class, of which properties are |
207 |
cached in: |
|
208 |
||
209 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
210 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
211 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
212 |
||
213 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
214 |
||
215 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
216 |
as instances of ImmutableArray, |
|
217 |
which cannot be stored into. |
|
218 |
Default is false, for compatibility. |
|
219 |
Can be turned on while developping |
|
220 |
new code to make certain that side |
|
221 |
effects are avoided. |
|
222 |
||
223 |
WarnST80Directives <Boolean> if true, give warnings about |
|
224 |
ST-80 directives (resource defs) |
|
225 |
which are ignored in st/x. |
|
226 |
defaults to false. |
|
227 |
||
228 |
FoldConstants <Symbol> controls how constant folding should be |
|
229 |
done. |
|
230 |
Can be one of: |
|
231 |
nil - no constant folding |
|
232 |
#level1 - numeric optimizations only |
|
233 |
#level2 - secure optimizations only |
|
234 |
#full - full folding |
|
235 |
||
236 |
level1: arithmetic on constant numbers |
|
237 |
||
238 |
level2: above PLUS array conversions with #asFloatArray, |
|
239 |
#asDoubleArray, string concatenation |
|
240 |
||
241 |
full: constant points. |
|
260 | 242 |
|
243 |
[see also:] |
|
755 | 244 |
ByteCodeCompiler Scanner ObjectFileLoader |
245 |
Workspace |
|
246 |
SystemBrowser |
|
263 | 247 |
|
248 |
[author:] |
|
755 | 249 |
Claus Gittinger |
19 | 250 |
" |
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
251 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
252 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
253 |
examples |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
254 |
" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
255 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
256 |
Parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
257 |
evaluate:'1+2*3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
258 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
259 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
260 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
261 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
262 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
263 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
264 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
265 |
Parser undefinedVariableNotification handle:[:ex | |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
266 |
|badName| |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
267 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
268 |
badName := ex variableName. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
269 |
ex proceedWith:(ConstantNode value:5). |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
270 |
] do:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
271 |
^ self compilerClass |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
272 |
evaluate:'foo * 3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
273 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
274 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
275 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
276 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
277 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
278 |
] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
279 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
280 |
" |
141 | 281 |
! ! |
282 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
283 |
!Parser class methodsFor:'instance creation'! |
141 | 284 |
|
285 |
for:aStringOrStream in:aClass |
|
286 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
287 |
||
288 |
|parser| |
|
289 |
||
290 |
parser := self for:aStringOrStream. |
|
291 |
parser setClassToCompileFor:aClass. |
|
292 |
^ parser |
|
293 |
! ! |
|
294 |
||
1020 | 295 |
!Parser class methodsFor:'Compatibility - ST80'! |
540 | 296 |
|
297 |
parse:aString class:aClass |
|
298 |
"same as #parseMethod:in: for ST80 compatibility." |
|
299 |
||
300 |
|parser| |
|
301 |
||
302 |
parser := self parseMethod:aString in:aClass. |
|
303 |
parser notNil ifTrue:[^ parser tree]. |
|
304 |
^ nil |
|
305 |
||
306 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
307 |
! ! |
|
308 |
||
920 | 309 |
!Parser class methodsFor:'Compatibility - Squeak'! |
310 |
||
311 |
evaluate:someString for:aReceiver logged:logged |
|
312 |
^ self evaluate:someString receiver:aReceiver logged:logged |
|
313 |
||
314 |
||
315 |
||
316 |
! ! |
|
317 |
||
1062 | 318 |
!Parser class methodsFor:'Signal constants'! |
319 |
||
320 |
parseErrorSignal |
|
321 |
^ ParseErrorSignal |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
322 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
323 |
|
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
324 |
undefinedVariableNotification |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
325 |
^ UndefinedVariableNotification |
1062 | 326 |
! ! |
327 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
328 |
!Parser class methodsFor:'changes'! |
141 | 329 |
|
330 |
flushNameCache |
|
331 |
"unconditional flush name caches" |
|
332 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
333 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
334 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
335 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
336 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
337 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
338 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
339 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
340 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
341 |
] valueUninterruptably |
141 | 342 |
|
343 |
"Parser flushNameCache" |
|
344 |
! |
|
345 |
||
346 |
update:something with:someArgument from:changedObject |
|
347 |
"aClass has changed its definition - flush name caches if we have to" |
|
348 |
||
349 |
(changedObject == PrevClass) ifTrue:[ |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
350 |
something == #definition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
351 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
352 |
] |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
353 |
]. |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
354 |
(changedObject == Smalltalk) ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
355 |
something == #classDefinition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
356 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
357 |
] |
141 | 358 |
] |
359 |
! ! |
|
360 |
||
717 | 361 |
!Parser class methodsFor:'class initialization'! |
362 |
||
363 |
initialize |
|
364 |
LazyCompilation := false. "/ usually set to true in your .rc file |
|
752 | 365 |
ArraysAreImmutable := false. "/ usually left false for ST-80 compatibility |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
366 |
StringsAreImmutable := false. "/ usually left false for ST-80 compatibility |
752 | 367 |
|
717 | 368 |
ImplicitSelfSends := false. |
369 |
WarnST80Directives := false. |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
370 |
WarnUnusedVars := true. |
717 | 371 |
FoldConstants := #level1. |
372 |
LineNumberInfo := false. |
|
373 |
||
1062 | 374 |
ParseErrorSignal isNil ifTrue:[ |
1380 | 375 |
ParseErrorSignal := ParseError. |
1062 | 376 |
ParseErrorSignal notifierString:'parse error'. |
1380 | 377 |
|
378 |
"/ ParseErrorSignal := Error newSignalMayProceed:true. |
|
379 |
"/ ParseErrorSignal notifierString:'parse error'. |
|
380 |
"/ ParseErrorSignal nameClass:self message:#parseErrorSignal. |
|
1062 | 381 |
]. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
382 |
RestartCompilationSignal := Signal new. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
383 |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
384 |
Smalltalk addDependent:self. |
1062 | 385 |
|
717 | 386 |
" |
387 |
self initialize |
|
388 |
" |
|
389 |
||
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
390 |
"Modified: / 15.11.2001 / 22:54:09 / cg" |
717 | 391 |
! ! |
392 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
393 |
!Parser class methodsFor:'controlling compilation'! |
141 | 394 |
|
395 |
arraysAreImmutable |
|
396 |
"return true if arrays are immutable literals" |
|
397 |
||
398 |
^ ArraysAreImmutable |
|
399 |
! |
|
400 |
||
401 |
arraysAreImmutable:aBoolean |
|
402 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
403 |
||
404 |
ArraysAreImmutable := aBoolean. |
|
405 |
||
406 |
" |
|
407 |
can be added to your private.rc file: |
|
408 |
||
409 |
Compiler arraysAreImmutable:true |
|
410 |
Compiler arraysAreImmutable:false |
|
411 |
" |
|
412 |
! |
|
413 |
||
414 |
compileLazy |
|
415 |
"return true if compiling lazy" |
|
416 |
||
417 |
^ LazyCompilation. |
|
418 |
! |
|
419 |
||
420 |
compileLazy:aBoolean |
|
421 |
"turn on/off lazy compilation - return previous setting. |
|
422 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
423 |
but it also controls the reporting of some errors here; therefore |
|
424 |
its located here" |
|
425 |
||
426 |
|oldLazy| |
|
427 |
||
428 |
oldLazy := LazyCompilation. |
|
429 |
LazyCompilation := aBoolean. |
|
430 |
^ oldLazy |
|
431 |
||
432 |
" |
|
433 |
usually set in your .rc file |
|
434 |
||
435 |
Compiler compileLazy:false |
|
436 |
Compiler compileLazy:true |
|
437 |
" |
|
438 |
! |
|
439 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
440 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
441 |
"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
|
442 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
443 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
444 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
445 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
446 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
447 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
448 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
449 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
450 |
It can be: |
619 | 451 |
nil - no constant folding |
452 |
#level1 - numeric constants only |
|
453 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
454 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
455 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
456 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
457 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
458 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
459 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
460 |
|
141 | 461 |
implicitSelfSends |
462 |
"return true if undefined variables with |
|
463 |
lowercase first character are to be turned |
|
464 |
into implicit self sends" |
|
465 |
||
466 |
^ ImplicitSelfSends |
|
467 |
! |
|
468 |
||
469 |
implicitSelfSends:aBoolean |
|
470 |
"turn on/off implicit self sends" |
|
471 |
||
472 |
ImplicitSelfSends := aBoolean |
|
473 |
||
474 |
" |
|
475 |
Compiler implicitSelfSends:true |
|
476 |
Compiler implicitSelfSends:false |
|
477 |
" |
|
377 | 478 |
! |
479 |
||
480 |
lineNumberInfo |
|
481 |
^ LineNumberInfo |
|
482 |
! |
|
483 |
||
484 |
lineNumberInfo:aBoolean |
|
485 |
LineNumberInfo := aBoolean |
|
752 | 486 |
! |
487 |
||
488 |
stringsAreImmutable |
|
489 |
"return true if strings are immutable literals" |
|
490 |
||
491 |
^ StringsAreImmutable |
|
492 |
||
493 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
494 |
! |
|
495 |
||
496 |
stringsAreImmutable:aBoolean |
|
497 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
498 |
||
499 |
StringsAreImmutable := aBoolean. |
|
500 |
||
501 |
" |
|
502 |
can be added to your private.rc file: |
|
503 |
||
504 |
Compiler stringsAreImmutable:true |
|
505 |
Compiler stringsAreImmutable:false |
|
506 |
" |
|
507 |
||
508 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
1160 | 509 |
! |
510 |
||
511 |
warnUnusedVars |
|
512 |
"controls generation of warning messages about unued method variables" |
|
513 |
||
514 |
^ WarnUnusedVars |
|
515 |
! |
|
516 |
||
517 |
warnUnusedVars:aBoolean |
|
518 |
"controls generation of warning messages about unued method variables" |
|
519 |
||
520 |
WarnUnusedVars := aBoolean |
|
19 | 521 |
! ! |
0 | 522 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
523 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
524 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
525 |
allowReservedWordsAsSelectors |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
526 |
"return true, if self, super, thisContext, nil, true and false are to be allowed |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
527 |
as unary message selectors." |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
528 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
529 |
^ AllowReservedWordsAsSelectors ? false |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
530 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
531 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
532 |
allowReservedWordsAsSelectors:aBoolean |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
533 |
"enable/disable, if self, super, thisContext, nil, true and false are to be allowed |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
534 |
as unary message selectors." |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
535 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
536 |
AllowReservedWordsAsSelectors := aBoolean. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
537 |
self setupActions |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
538 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
539 |
" |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
540 |
self allowReservedWordsAsSelectors:true |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
541 |
self allowReservedWordsAsSelectors:false |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
542 |
" |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
543 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
544 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
545 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
546 |
"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
|
547 |
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
|
548 |
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
|
549 |
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
|
550 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
551 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
552 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
553 |
"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
|
554 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
555 |
|
1187 | 556 |
!Parser class methodsFor:'error correction'! |
557 |
||
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
558 |
findBest:nMax selectorsFor:aString in:aClassOrNil |
1187 | 559 |
"collect known selectors with their spelling distances to aString; |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
560 |
return the nMax best suggestions. If the argument, aClassOrNil is not nil, |
1187 | 561 |
the message is assumed to be sent to instances of that class (i.e. offer |
562 |
corrections from that hierarchy only)" |
|
563 |
||
1286 | 564 |
|info block lcSelector| |
1187 | 565 |
|
566 |
info := SortedCollection new. |
|
567 |
info sortBlock:[:a :b | a value > b value]. |
|
568 |
||
569 |
lcSelector := aString asLowercase. |
|
570 |
||
571 |
block := [:sym :mthd| |
|
1215 | 572 |
|dist lcSym keepThis| |
1187 | 573 |
|
574 |
lcSym := sym asLowercase. |
|
575 |
(info contains:[:i | i key == sym]) ifFalse:[ |
|
576 |
dist := lcSelector spellAgainst:lcSym. |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
577 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
578 |
(lcSym startsWith:lcSelector) ifTrue:[ |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
579 |
dist := dist + (aString size * 10). |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
580 |
]. |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
581 |
|
1215 | 582 |
(dist > 20) ifTrue:[ |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
583 |
(info contains:[:entry | entry key = sym]) ifFalse:[ |
1215 | 584 |
keepThis := true. |
585 |
info size >= nMax ifTrue:[ |
|
586 |
"will remove last entry anyway - so check if this one will remain ..." |
|
587 |
dist < info last value ifTrue:[ |
|
588 |
keepThis := false. |
|
589 |
] |
|
590 |
]. |
|
591 |
keepThis ifTrue:[ |
|
592 |
"expensive - therefore do this check at last" |
|
593 |
mthd isObsolete ifFalse:[ |
|
594 |
info add:(sym -> dist). |
|
595 |
info size > nMax ifTrue:[ |
|
596 |
info removeLast. |
|
597 |
] |
|
598 |
] |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
599 |
] |
1187 | 600 |
] |
601 |
] |
|
602 |
] |
|
603 |
]. |
|
604 |
||
605 |
aClassOrNil isNil ifTrue:[ |
|
606 |
Smalltalk allClassesDo:[:cls | |
|
607 |
cls methodDictionary keysAndValuesDo:block. |
|
608 |
cls class methodDictionary keysAndValuesDo:block. |
|
609 |
] |
|
610 |
] ifFalse:[ |
|
611 |
aClassOrNil withAllSuperclassesDo:[:cls | |
|
612 |
cls methodDictionary keysAndValuesDo:block. |
|
1323 | 613 |
"/ cls class methodDictionary keysAndValuesDo:block. |
1187 | 614 |
] |
615 |
]. |
|
616 |
||
617 |
^ info asOrderedCollection collect:[:a | a key] |
|
618 |
||
619 |
"Modified: / 19.1.2000 / 16:43:37 / cg" |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
620 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
621 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
622 |
findBestSelectorsFor:aString |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
623 |
"collect known selectors with their spelling distances to aString; |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
624 |
return the 10 best suggestions" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
625 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
626 |
^ self findBestSelectorsFor:aString in:nil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
627 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
628 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
629 |
Parser findBestSelectorsFor:'at' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
630 |
Parser findBestSelectorsFor:'at:pu' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
631 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
632 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
633 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
634 |
findBestSelectorsFor:aString in:aClassOrNil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
635 |
"collect known selectors with their spelling distances to aString; |
1323 | 636 |
return the 15 best suggestions. If the argument, aClassOrNil is not nil, |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
637 |
the message is assumed to be sent to instances of that class (i.e. offer |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
638 |
corrections from that hierarchy only)" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
639 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
640 |
^ self |
1323 | 641 |
findBest:15 selectorsFor:aString in:aClassOrNil |
1187 | 642 |
! ! |
643 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
644 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 645 |
|
19 | 646 |
evaluate:aStringOrStream |
71 | 647 |
"return the result of evaluating an expression in aStringOrStream. |
648 |
No doit-entry is added to the changeLog." |
|
0 | 649 |
|
19 | 650 |
^ self |
44 | 651 |
evaluate:aStringOrStream |
652 |
in:nil |
|
653 |
receiver:nil |
|
654 |
notifying:nil |
|
655 |
logged:false |
|
656 |
ifFail:nil |
|
71 | 657 |
compile:true |
19 | 658 |
|
659 |
" |
|
660 |
Compiler evaluate:'1 + 2' |
|
661 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
662 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
663 |
" |
|
0 | 664 |
! |
665 |
||
71 | 666 |
evaluate:aStringOrStream compile:compile |
667 |
"return the result of evaluating aString, |
|
668 |
The compile argument specifies if the string should be compiled down to |
|
669 |
bytecode or instead be interpreted from the parseTree. |
|
670 |
The first should be done for doIts etc, where a readable walkback is |
|
671 |
required. |
|
672 |
The latter is better done for constants, styleSheet and resource |
|
673 |
reading and simple sends, where the overhead of compilation is bigger |
|
674 |
than the interpretation overhead." |
|
675 |
||
676 |
^ self |
|
677 |
evaluate:aStringOrStream |
|
678 |
in:nil |
|
679 |
receiver:nil |
|
680 |
notifying:nil |
|
681 |
logged:false |
|
682 |
ifFail:nil |
|
683 |
compile:compile |
|
684 |
! |
|
685 |
||
20 | 686 |
evaluate:aStringOrStream ifFail:failBlock |
687 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 688 |
In case of any syntax errors, return the value of failBlock. |
689 |
No doit-entry is added to the changeLog." |
|
20 | 690 |
|
691 |
^ self |
|
44 | 692 |
evaluate:aStringOrStream |
693 |
in:nil |
|
694 |
receiver:nil |
|
695 |
notifying:nil |
|
696 |
logged:false |
|
697 |
ifFail:failBlock |
|
71 | 698 |
compile:true |
20 | 699 |
" |
700 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
701 |
" |
|
702 |
! |
|
703 |
||
71 | 704 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
705 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
706 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
707 |
No doIt entry is added to the change-file. |
|
708 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
709 |
||
710 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
711 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
712 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
713 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
714 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
715 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
716 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
717 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
718 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
719 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 720 |
! |
721 |
||
722 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
723 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
724 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
725 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
726 |
is non-nil, it is evaluated if an error occurs." |
|
727 |
||
71 | 728 |
^ self |
729 |
evaluate:aStringOrStream |
|
730 |
in:aContext |
|
731 |
receiver:anObject |
|
732 |
notifying:requestor |
|
733 |
logged:logged |
|
734 |
ifFail:failBlock |
|
735 |
compile:true |
|
736 |
! |
|
737 |
||
738 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
739 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
740 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
741 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
742 |
is non-nil, it is evaluated if an error occurs. |
|
743 |
Finally, compile specifies if the string should be compiled down to |
|
744 |
bytecode or instead be interpreted from the parseTree. |
|
745 |
The first should be done for doIts etc, where a readable walkback is |
|
746 |
required. |
|
747 |
The latter is better done for constants, styleSheet and resource |
|
748 |
reading and simple sends, where the overhead of compilation is bigger |
|
749 |
than the interpretation overhead." |
|
750 |
||
1363 | 751 |
^ self new |
752 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
141 | 753 |
! |
754 |
||
755 |
evaluate:aStringOrStream logged:logged |
|
756 |
"return the result of evaluating an expression in aStringOrStream. |
|
757 |
The argument log controls if an entry is added to the changeLog." |
|
758 |
||
759 |
^ self |
|
760 |
evaluate:aStringOrStream |
|
761 |
in:nil |
|
762 |
receiver:nil |
|
763 |
notifying:nil |
|
764 |
logged:logged |
|
765 |
ifFail:nil |
|
766 |
compile:true |
|
767 |
" |
|
768 |
Compiler evaluate:'''some string''' logged:false |
|
769 |
Compiler evaluate:'''some string''' logged:true |
|
770 |
" |
|
771 |
! |
|
772 |
||
773 |
evaluate:aStringOrStream notifying:requestor |
|
774 |
"return the result of evaluating aString, |
|
775 |
errors are reported to requestor" |
|
776 |
||
777 |
^ self |
|
778 |
evaluate:aStringOrStream |
|
779 |
in:nil |
|
780 |
receiver:nil |
|
781 |
notifying:requestor |
|
782 |
logged:false |
|
783 |
ifFail:nil |
|
784 |
compile:true |
|
785 |
! |
|
786 |
||
787 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
788 |
"return the result of evaluating aString, |
|
789 |
errors are reported to requestor. |
|
790 |
The compile argument specifies if the string should be compiled down to |
|
791 |
bytecode or instead be interpreted from the parseTree. |
|
792 |
The first should be done for doIts etc, where a readable walkback is |
|
793 |
required. |
|
794 |
The latter is better done for constants, styleSheet and resource |
|
795 |
reading and simple sends, where the overhead of compilation is bigger |
|
796 |
than the interpretation overhead." |
|
797 |
||
798 |
^ self |
|
799 |
evaluate:aStringOrStream |
|
800 |
in:nil |
|
801 |
receiver:nil |
|
802 |
notifying:requestor |
|
803 |
logged:false |
|
804 |
ifFail:nil |
|
805 |
compile:compile |
|
806 |
! |
|
807 |
||
1025
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
808 |
evaluate:aStringOrStream notifying:requestor logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
809 |
"return the result of evaluating aString, |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
810 |
errors are reported to requestor" |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
811 |
|
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
812 |
^ self |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
813 |
evaluate:aStringOrStream |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
814 |
in:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
815 |
receiver:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
816 |
notifying:requestor |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
817 |
logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
818 |
ifFail:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
819 |
compile:true |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
820 |
! |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
821 |
|
572 | 822 |
evaluate:aStringOrStream receiver:anObject |
823 |
"return the result of evaluating aString, |
|
824 |
errors are reported to requestor. Allow access to |
|
825 |
anObject as self and to its instVars " |
|
826 |
||
827 |
^ self |
|
619 | 828 |
evaluate:aStringOrStream |
829 |
in:nil |
|
830 |
receiver:anObject |
|
831 |
notifying:nil |
|
832 |
logged:false |
|
833 |
ifFail:nil |
|
834 |
compile:true |
|
572 | 835 |
|
836 |
" |
|
837 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
838 |
" |
|
839 |
||
840 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
841 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
842 |
! |
|
843 |
||
919 | 844 |
evaluate:aStringOrStream receiver:someOne logged:logged |
845 |
"return the result of evaluating an expression in aStringOrStream. |
|
846 |
The argument log controls if an entry is added to the changeLog." |
|
847 |
||
848 |
^ self |
|
849 |
evaluate:aStringOrStream |
|
850 |
in:nil |
|
851 |
receiver:someOne |
|
852 |
notifying:nil |
|
853 |
logged:logged |
|
854 |
ifFail:nil |
|
855 |
compile:true |
|
856 |
" |
|
857 |
Compiler evaluate:'''some string''' logged:false |
|
858 |
Compiler evaluate:'''some string''' logged:true |
|
859 |
Compiler evaluate:'self class' receiver:nil logged:false |
|
860 |
Compiler evaluate:'self class' receiver:1 logged:false |
|
861 |
" |
|
862 |
! |
|
863 |
||
141 | 864 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
865 |
"return the result of evaluating aString, |
|
866 |
errors are reported to requestor. Allow access to |
|
867 |
anObject as self and to its instVars (used in the inspector)" |
|
868 |
||
869 |
^ self |
|
870 |
evaluate:aStringOrStream |
|
871 |
in:nil |
|
872 |
receiver:anObject |
|
873 |
notifying:requestor |
|
874 |
logged:false |
|
875 |
ifFail:nil |
|
876 |
compile:true |
|
877 |
||
878 |
" |
|
879 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
880 |
" |
|
881 |
! |
|
882 |
||
883 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
884 |
"return the result of evaluating aString, |
|
885 |
errors are reported to requestor. Allow access to |
|
886 |
anObject as self and to its instVars (used in the inspector). |
|
887 |
The compile argument specifies if the string should be compiled down to |
|
888 |
bytecode or instead be interpreted from the parseTree. |
|
889 |
The first should be done for doIts etc, where a readable walkback is |
|
890 |
required. |
|
891 |
The latter is better done for constants, styleSheet and resource |
|
892 |
reading and simple sends, where the overhead of compilation is bigger |
|
893 |
than the interpretation overhead." |
|
894 |
||
895 |
^ self |
|
896 |
evaluate:aStringOrStream |
|
897 |
in:nil |
|
898 |
receiver:anObject |
|
899 |
notifying:requestor |
|
900 |
logged:false |
|
901 |
ifFail:nil |
|
902 |
compile:compile |
|
0 | 903 |
! ! |
904 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
905 |
!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
|
906 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
907 |
argAndVarNamesForContext:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
908 |
"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
|
909 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
910 |
|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
|
911 |
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
|
912 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
913 |
numArgs := aContext numArgs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
914 |
numVars := aContext numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
915 |
(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
|
916 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
917 |
homeContext := aContext methodHome. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
918 |
sel := homeContext selector. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
919 |
method := homeContext method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
920 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
921 |
"/ #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
|
922 |
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
|
923 |
aContext isBlockContext ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
924 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
925 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
926 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
927 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
928 |
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
|
929 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
930 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
931 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
932 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
933 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
934 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
935 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
936 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
937 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
938 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
939 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
940 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
941 |
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
|
942 |
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
|
943 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
944 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
945 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
946 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
947 |
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
|
948 |
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
|
949 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
950 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
951 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
952 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
953 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
954 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
955 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
956 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
957 |
^ method methodArgAndVarNames. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
958 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
959 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
960 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
961 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
962 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
963 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
964 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
965 |
"/ 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
|
966 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
967 |
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
|
968 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
969 |
m := method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
970 |
src := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
971 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
972 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
973 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
974 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
975 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
976 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
977 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
978 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
979 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
980 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
981 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
982 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
983 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
984 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
988 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
989 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
990 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
991 |
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
|
992 |
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
|
993 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
994 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
995 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
996 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
997 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
998 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
999 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1000 |
"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
|
1001 |
"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
|
1002 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1003 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1004 |
!Parser class methodsFor:'parsing'! |
141 | 1005 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1006 |
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
|
1007 |
"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
|
1008 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1009 |
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
|
1010 |
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
|
1011 |
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
|
1012 |
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
|
1013 |
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
|
1014 |
|
429 | 1015 |
|compiler tree mSource who mClass blocks |
397 | 1016 |
maxSoFar innerBlock m| |
1017 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1018 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 1019 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1020 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1021 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1022 |
aMethod notNil ifTrue:[ |
815 | 1023 |
m := aMethod. |
1024 |
who := m who. |
|
1025 |
who isNil ifTrue:[ |
|
1026 |
m isWrapped ifTrue:[ |
|
1027 |
m := m wrapper. |
|
1028 |
m notNil ifTrue:[ |
|
1029 |
who := m who. |
|
1030 |
] |
|
1031 |
] |
|
1032 |
]. |
|
1033 |
who notNil ifTrue:[ |
|
1034 |
mClass := who methodClass. |
|
1035 |
mClass isNil ifTrue:[ ^ nil]. |
|
1036 |
]. |
|
1037 |
||
1038 |
mSource := m source. |
|
1039 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1040 |
] ifFalse:[ |
815 | 1041 |
aString notNil ifTrue:[ |
1042 |
mSource := aString. |
|
1043 |
mClass := UndefinedObject |
|
1044 |
] ifFalse:[ |
|
1045 |
^ nil |
|
1046 |
] |
|
397 | 1047 |
]. |
1048 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1049 |
"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
|
1050 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1051 |
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
|
1052 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1053 |
compiler notifying:nil. |
1365 | 1054 |
compiler ignoreWarnings:true. |
1055 |
compiler ignoreErrors:true. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1056 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1057 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1058 |
aMethod notNil ifTrue:[ |
815 | 1059 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
1060 |
^ nil. |
|
1061 |
]. |
|
1062 |
||
1063 |
who notNil ifTrue:[ |
|
1064 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
1065 |
^ nil |
|
1066 |
] |
|
1067 |
]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1068 |
] ifFalse:[ |
815 | 1069 |
compiler nextToken. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1070 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1071 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1072 |
tree := compiler parseMethodBody. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1073 |
|
815 | 1074 |
(compiler errorFlag |
1075 |
or:[tree == #Error |
|
1076 |
or:[tree isNil]]) ifTrue:[ |
|
1077 |
^ nil |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1078 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1079 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1080 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1081 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1082 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1083 |
blocks := blocks select:[:aBlock | |
815 | 1084 |
line between: aBlock lineNumber and:aBlock endLineNumber |
1085 |
||
1086 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1087 |
blocks size == 1 ifTrue:[ |
815 | 1088 |
^ 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
|
1089 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1090 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1091 |
nA notNil ifTrue:[ |
815 | 1092 |
blocks := blocks select:[:aBlock | |
1093 |
aBlock numArgs == nA |
|
1094 |
]. |
|
1095 |
blocks size == 1 ifTrue:[ |
|
1096 |
^ blocks at:1 |
|
1097 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1098 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1099 |
nV notNil ifTrue:[ |
815 | 1100 |
blocks := blocks select:[:aBlock | |
1101 |
aBlock numVars == nV |
|
1102 |
]. |
|
1103 |
blocks size == 1 ifTrue:[ |
|
1104 |
^ blocks at:1 |
|
1105 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1106 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1107 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1108 |
"/ 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
|
1109 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1110 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1111 |
blocks do:[:aBlock | |
815 | 1112 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1113 |
innerBlock := aBlock. |
|
1114 |
maxSoFar := aBlock lineNumber |
|
1115 |
] |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1116 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1117 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1118 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1119 |
"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
|
1120 |
"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
|
1121 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1122 |
|
1365 | 1123 |
checkMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
629 | 1124 |
"parse a method in a given class. |
1125 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1126 |
The parser can be queried for selector, receiver, args, locals, |
|
1127 |
used selectors, modified instvars, referenced classvars etc. |
|
1128 |
The noErrors and noWarnings arguments specify if error and warning |
|
1129 |
messages should be sent to the Transcript or suppressed." |
|
1130 |
||
1131 |
|parser tree| |
|
1132 |
||
1133 |
aString isNil ifTrue:[^ nil]. |
|
1134 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1135 |
parser ignoreErrors:ignoreErrors. |
1136 |
parser ignoreWarnings:ignoreWarnings. |
|
629 | 1137 |
tree := parser parseMethod. |
1138 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1139 |
||
1140 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1141 |
||
1142 |
" |
|
1143 |
self |
|
1144 |
checkMethod:'foo |
|
1145 |
|local1 local2 local3| |
|
1146 |
||
1147 |
local1 := local2. |
|
1148 |
^ local3 |
|
1149 |
' |
|
1150 |
in:UndefinedObject |
|
1151 |
ignoreErrors:true |
|
1152 |
ignoreWarnings:true |
|
1153 |
" |
|
1154 |
||
1155 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1156 |
! |
|
1157 |
||
141 | 1158 |
parseExpression:aString |
1159 |
"parse aString as an expression; |
|
1160 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1161 |
or comment only) or #Error (syntactic error). |
1162 |
Error and warning messages are suppressed." |
|
141 | 1163 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1164 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1165 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1166 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1167 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1168 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1169 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1170 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1171 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1172 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1173 |
" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1174 |
Parser parseExpression:'self foo' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1175 |
Parser parseExpression:'self:123' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1176 |
Parser parseExpression:'self:123' onError:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1177 |
" |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1178 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1179 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1180 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1181 |
"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
|
1182 |
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
|
1183 |
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
|
1184 |
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
|
1185 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1186 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1187 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1188 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1189 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1190 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1191 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1192 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1193 |
inNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1194 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1195 |
"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
|
1196 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1197 |
! |
1198 |
||
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1199 |
parseExpression:aString inNameSpace:aNameSpaceOrNil onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1200 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1201 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1202 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1203 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1204 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1205 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1206 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1207 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1208 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1209 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1210 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1211 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1212 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1213 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1214 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1215 |
"Created: 24.6.1997 / 16:44:26 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1216 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1217 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1218 |
parseExpression:aString onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1219 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1220 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1221 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1222 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1223 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1224 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1225 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1226 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1227 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1228 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1229 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1230 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1231 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1232 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1233 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1234 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1235 |
|
141 | 1236 |
parseMethod:aString |
1237 |
"parse a method. |
|
1238 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1239 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1240 |
used selectors etc. |
1241 |
Error and warning messages are sent to the Transcript." |
|
141 | 1242 |
|
1243 |
^ self parseMethod:aString in:nil |
|
1244 |
||
1245 |
" |
|
1246 |
|p| |
|
1247 |
||
1248 |
p := Parser |
|
619 | 1249 |
parseMethod:' |
1250 |
foo:arg1 bar:arg2 baz:arg3 |
|
1251 |
|l1 l2| |
|
1252 |
l1 := 0. |
|
1253 |
l2 := arg1. |
|
1254 |
^ self'. |
|
141 | 1255 |
|
1256 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1257 |
'args: ' print. p methodArgs printNL. |
|
1258 |
'sel: ' print. p selector printNL. |
|
1259 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1260 |
'locals: ' print. p methodVars printNL. |
|
1261 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1262 |
" |
|
258 | 1263 |
|
1264 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1265 |
! |
1266 |
||
1267 |
parseMethod:aString in:aClass |
|
1268 |
"parse a method in a given class. |
|
1269 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1270 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1271 |
used selectors, modified instvars, referenced classvars etc. |
1272 |
Error and warning messages are sent to the Transcript." |
|
141 | 1273 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1274 |
^ self |
619 | 1275 |
parseMethod:aString |
1276 |
in:aClass |
|
1277 |
ignoreErrors:false |
|
1278 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1279 |
|
258 | 1280 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1281 |
! |
1282 |
||
1365 | 1283 |
parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1284 |
"parse a method in a given class. |
1285 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1286 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1287 |
used selectors, modified instvars, referenced classvars etc. |
1288 |
The noErrors and noWarnings arguments specify if error and warning |
|
1289 |
messages should be sent to the Transcript or suppressed." |
|
141 | 1290 |
|
1291 |
|parser tree| |
|
1292 |
||
1293 |
aString isNil ifTrue:[^ nil]. |
|
1294 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1295 |
parser ignoreErrors:ignoreErrors. |
1296 |
parser ignoreWarnings:ignoreWarnings. |
|
141 | 1297 |
tree := parser parseMethod. |
1298 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1299 |
^ parser |
|
258 | 1300 |
|
1301 |
"Modified: 24.4.1996 / 13:19:23 / cg" |
|
141 | 1302 |
! |
1303 |
||
1304 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1305 |
"parse a method in a given class. |
|
1306 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1307 |
The parser can be queried for selector, receiver, args, locals, |
|
1308 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1309 |
The warnBoolean arguments specifies if warning |
1310 |
messages should be sent to the Transcript or suppressed. |
|
1311 |
||
1312 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1313 |
||
1314 |
self obsoleteMethodWarning. |
|
141 | 1315 |
^ self |
619 | 1316 |
parseMethod:aString |
1317 |
in:aClass |
|
1318 |
ignoreErrors:false |
|
1319 |
ignoreWarnings:warnBoolean not |
|
258 | 1320 |
|
1321 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1322 |
! |
1323 |
||
1324 |
parseMethodArgAndVarSpecification:aString |
|
1325 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1326 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1327 |
The parser can be queried for selector, receiver etc. |
1328 |
Error and warning messages are sent to the Transcript. |
|
1329 |
This method is OBSOLETE." |
|
1330 |
||
1331 |
self obsoleteMethodWarning. |
|
141 | 1332 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1333 |
||
1334 |
" |
|
1335 |
|p| |
|
1336 |
||
1337 |
p := Parser |
|
619 | 1338 |
parseMethodArgAndVarSpecification:' |
1339 |
foo:arg1 bar:arg2 baz:arg3 |
|
1340 |
|l1 l2|'. |
|
141 | 1341 |
|
1342 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1343 |
'args: ' print. p methodArgs printNL. |
|
1344 |
'sel: ' print. p selector printNL. |
|
1345 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1346 |
'locals: ' print. p methodVars printNL. |
|
1347 |
" |
|
258 | 1348 |
|
1349 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1350 |
! |
1351 |
||
1352 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1353 |
"parse a methods selector, arg and var spec in a given class; |
|
1354 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1355 |
The parser can be queried for selector, receiver, args and locals. |
1356 |
Error and warning messages are sent to the Transcript. |
|
1357 |
This method is OBSOLETE." |
|
1358 |
||
1359 |
self obsoleteMethodWarning. |
|
141 | 1360 |
^ self parseMethodArgAndVarSpecification:aString |
619 | 1361 |
in:aClass |
1362 |
ignoreErrors:false |
|
1363 |
ignoreWarnings:false |
|
1364 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1365 |
|
258 | 1366 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1367 |
! |
1368 |
||
1365 | 1369 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings parseBody:body |
141 | 1370 |
"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
|
1371 |
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
|
1372 |
(for primitives & resourceSpecs). |
258 | 1373 |
The noErrors and noWarnings arguments specify if error and warning |
1374 |
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
|
1375 |
|
141 | 1376 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1377 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1378 |
|
0 | 1379 |
|parser| |
1380 |
||
141 | 1381 |
aString isNil ifTrue:[^ nil]. |
1382 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1383 |
parser ignoreErrors:ignoreErrors. |
1384 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1385 |
"/ parser nextToken. |
141 | 1386 |
(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
|
1387 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1388 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1389 |
"/ - 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
|
1390 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1391 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1392 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1393 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1394 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1395 |
]. |
141 | 1396 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1397 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1398 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1399 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1400 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1401 |
! |
1402 |
||
1403 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1404 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1405 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1406 |
The parser can be queried for selector, receiver etc. |
|
258 | 1407 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1408 |
display error/warning messages on the transcript." |
1409 |
||
1410 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1411 |
|
1412 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1413 |
! |
1414 |
||
1415 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1416 |
"parse a methods selector, arg and var spec in a given class; |
|
1417 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1418 |
The parser can be queried for selector, receiver, args and locals. |
|
1419 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1420 |
display error/warning messages on the transcript." |
|
1421 |
||
1422 |
^ self parseMethodArgAndVarSpecification:aString |
|
619 | 1423 |
in:aClass |
1424 |
ignoreErrors:true |
|
1425 |
ignoreWarnings:true |
|
1426 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1427 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1428 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1429 |
! |
1430 |
||
1431 |
parseMethodSilent:aString |
|
1432 |
"parse a method. |
|
1433 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1434 |
The parser can be queried for selector, receiver, args, locals, |
|
1435 |
used selectors etc. |
|
258 | 1436 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1437 |
|
1438 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1439 |
|
1440 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1441 |
! |
1442 |
||
1443 |
parseMethodSilent:aString in:aClass |
|
1444 |
"parse a method in a given class. |
|
1445 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1446 |
The parser can be queried for selector, receiver, args, locals, |
|
1447 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1448 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1449 |
||
1450 |
^ self |
|
619 | 1451 |
parseMethod:aString |
1452 |
in:aClass |
|
1453 |
ignoreErrors:true |
|
1454 |
ignoreWarnings:true |
|
258 | 1455 |
|
1456 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1457 |
! |
1458 |
||
1459 |
parseMethodSpecification:aString |
|
1460 |
"parse a methods selector & arg specification; |
|
1461 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1462 |
The parser can be queried for selector, receiver etc." |
|
1463 |
||
1464 |
^ self parseMethodSpecification:aString in:nil |
|
1465 |
||
1466 |
" |
|
1467 |
|p| |
|
1468 |
||
1469 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1470 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1471 |
'args: ' print. p methodArgs printNL. |
|
1472 |
'sel: ' print. p selector printNL |
|
1473 |
" |
|
1474 |
! |
|
1475 |
||
1476 |
parseMethodSpecification:aString in:aClass |
|
1477 |
"parse a methods selector & arg spec for a given class; |
|
1478 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1479 |
The parser can be queried for selector, receiver etc." |
|
1480 |
||
1481 |
^ self parseMethodSpecification:aString |
|
1482 |
in:aClass |
|
1483 |
ignoreErrors:false |
|
1484 |
ignoreWarnings:false |
|
1485 |
! |
|
1486 |
||
1365 | 1487 |
parseMethodSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1488 |
"parse a methods selector & arg spec for a given class; |
1489 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1490 |
The parser can be queried for selector, receiver etc. |
|
1491 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1492 |
to be output onto the Transcript." |
|
1493 |
||
1494 |
|parser tree| |
|
1495 |
||
1496 |
aString isNil ifTrue:[^ nil]. |
|
1497 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1498 |
parser ignoreErrors:ignoreErrors. |
1499 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1500 |
"/ parser nextToken. |
141 | 1501 |
tree := parser parseMethodSpec. |
1502 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1503 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1504 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1505 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1506 |
! |
1507 |
||
1508 |
parseMethodSpecificationSilent:aString |
|
1509 |
"parse a methods selector & arg specification; |
|
1510 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1511 |
The parser can be queried for selector, receiver etc. |
|
1512 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1513 |
||
1514 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1515 |
! |
|
1516 |
||
1517 |
parseMethodSpecificationSilent:aString in:aClass |
|
1518 |
"parse a methods selector & arg spec for a given class; |
|
1519 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1520 |
The parser can be queried for selector, receiver etc. |
|
1521 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1522 |
||
1523 |
^ self parseMethodSpecification:aString |
|
1524 |
in:aClass |
|
1525 |
ignoreErrors:true |
|
1526 |
ignoreWarnings:true |
|
1527 |
||
1528 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1529 |
! |
|
0 | 1530 |
|
7 | 1531 |
selectorInExpression:aString |
47 | 1532 |
"parse an expression - return the selector. Even malformed expressions |
1533 |
(such as missing receiver or missing arg are parsed. |
|
1534 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1535 |
Returns nil if unparsable." |
7 | 1536 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1537 |
|tree parser sel| |
7 | 1538 |
|
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1539 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1540 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1541 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1542 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1543 |
do:[ |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1544 |
tree := self withSelf:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1545 |
parseExpression:aString |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1546 |
notifying:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1547 |
ignoreErrors:true |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1548 |
ignoreWarnings:true. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1549 |
]. |
21 | 1550 |
|
1551 |
" |
|
1552 |
special: take the expression of the right side, if its an |
|
1553 |
assignment or return |
|
1554 |
" |
|
7 | 1555 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1556 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1557 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1558 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1559 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1560 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1561 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1562 |
|
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1563 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1564 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1565 |
]. |
7 | 1566 |
]. |
1567 |
||
21 | 1568 |
" |
1569 |
mhmh, try expression without receiver |
|
1570 |
" |
|
7 | 1571 |
parser := self for:(ReadStream on:aString). |
1365 | 1572 |
parser ignoreErrors:true. |
7 | 1573 |
parser nextToken. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1574 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1575 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1576 |
do:[ |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1577 |
sel := parser degeneratedKeywordExpressionForSelector |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1578 |
]. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1579 |
^ sel |
7 | 1580 |
|
1581 |
" |
|
20 | 1582 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1583 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1584 |
Parser selectorInExpression:'a + 4' |
1585 |
Parser selectorInExpression:'a negated' |
|
20 | 1586 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1587 |
Parser selectorInExpression:'at:1 put:' |
1588 |
Parser selectorInExpression:'a at:1 put:5' |
|
1589 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1590 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1591 |
" |
451 | 1592 |
|
1593 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1594 |
! |
1595 |
||
1596 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1597 |
"parse aString as an expression with self set to anObject; |
|
21 | 1598 |
Return the parseTree (if ok), nil (for an empty string |
1599 |
or comment only ) or #Error (syntactic error). |
|
1600 |
||
1601 |
Errors and warnings are forwarded to someOne (usually some |
|
1602 |
codeView) which can highlight it and show a popup box." |
|
7 | 1603 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1604 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1605 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1606 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1607 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1608 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1609 |
ignoreErrors:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1610 |
ignoreWarnings:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1611 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1612 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1613 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1614 |
! |
1615 |
||
1616 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1617 |
"parse aString as an expression with self set to anObject; |
21 | 1618 |
Return the parseTree (if ok), nil (for an empty string |
1619 |
or comment only ) or #Error (syntactic error). |
|
1620 |
||
1621 |
Errors and warnings are forwarded to someOne (usually some |
|
1622 |
codeView) which can highlight it and show a popup box." |
|
1623 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1624 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1625 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1626 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1627 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1628 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1629 |
ignoreErrors:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1630 |
ignoreWarnings:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1631 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1632 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1633 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1634 |
! |
1635 |
||
1636 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1637 |
"parse aString as an expression with self set to anObject; |
|
1638 |
Return the parseTree (if ok), nil (for an empty string |
|
1639 |
or comment only ) or #Error (syntactic error). |
|
1640 |
||
1641 |
Errors and warnings are forwarded to someOne (usually some |
|
1642 |
codeView) which can highlight it and show a popup box, |
|
1643 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1644 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1645 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1646 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1647 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1648 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1649 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1650 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1651 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1652 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1653 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1654 |
"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
|
1655 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1656 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1657 |
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
|
1658 |
"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
|
1659 |
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
|
1660 |
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
|
1661 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1662 |
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
|
1663 |
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
|
1664 |
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
|
1665 |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1666 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1667 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1668 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1669 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1670 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1671 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1672 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1673 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1674 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1675 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1676 |
withSelf:anObject parseExpression:aString onError:errorValue notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1677 |
"parse aString as an expression with self set to anObject; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1678 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1679 |
or comment only ) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1680 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1681 |
Errors and warnings are forwarded to someOne (usually some |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1682 |
codeView) which can highlight it and show a popup box, |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1683 |
iff ignoreErrors/ignoreWarnings is true respectively." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1684 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1685 |
|parser tree| |
0 | 1686 |
|
1687 |
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
|
1688 |
|
0 | 1689 |
parser := self for:(ReadStream on:aString). |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1690 |
tree := parser |
1006 | 1691 |
parseExpressionWithSelf:anObject |
1692 |
notifying:someOne |
|
1693 |
ignoreErrors:ignoreErrors |
|
1694 |
ignoreWarnings:ignoreWarnings |
|
1695 |
inNameSpace:aNameSpaceOrNil. |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1696 |
tree == #Error ifTrue:[ |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1697 |
^ errorValue value |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1698 |
]. |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1699 |
^ tree |
1006 | 1700 |
|
1701 |
"Modified: / 14.12.1999 / 15:12:16 / cg" |
|
0 | 1702 |
! ! |
1703 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1704 |
!Parser class methodsFor:'unparsing'! |
20 | 1705 |
|
1706 |
methodSpecificationForSelector:aSelector |
|
1707 |
"given a selector such as #foo:bar:, return a string that could |
|
1708 |
serve as a methods specification source code. |
|
1709 |
To be used for code generators" |
|
1710 |
||
807 | 1711 |
|argNames n| |
1712 |
||
1713 |
n := aSelector numArgs. |
|
1714 |
n == 1 ifTrue:[ |
|
1715 |
argNames := #('arg') |
|
1716 |
] ifFalse:[ |
|
1717 |
n <= 15 ifTrue:[ |
|
1718 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1719 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1720 |
'arg13' 'arg14' 'arg15') |
|
1721 |
] ifFalse:[ |
|
1722 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1723 |
]. |
|
1724 |
]. |
|
1725 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1726 |
||
20 | 1727 |
" |
807 | 1728 |
Parser methodSpecificationForSelector:#foo: |
20 | 1729 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1730 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1731 |
Parser methodSpecificationForSelector:#+ |
20 | 1732 |
Parser methodSpecificationForSelector:#negated |
1733 |
" |
|
807 | 1734 |
|
1735 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1736 |
! |
1737 |
||
1738 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1739 |
"given a selector such as #foo:bar:, return a string that could |
|
1740 |
serve as a methods specification source code. |
|
1741 |
To be used for code generators" |
|
1742 |
||
806 | 1743 |
|s nargs parts part| |
20 | 1744 |
|
1745 |
s := WriteStream on:String new. |
|
44 | 1746 |
nargs := aSelector numArgs. |
20 | 1747 |
nargs == 0 ifTrue:[ |
806 | 1748 |
s nextPutAll:aSelector |
20 | 1749 |
] ifFalse:[ |
806 | 1750 |
parts := aSelector partsIfSelector. |
1751 |
1 to:nargs do:[:i | |
|
1752 |
part := parts at:i. |
|
1753 |
s nextPutAll:part. |
|
1754 |
(part endsWith:$:) ifFalse:[ |
|
1755 |
s space. |
|
1756 |
]. |
|
1757 |
s nextPutAll:(argNames at:i). |
|
1758 |
i ~~ nargs ifTrue:[s space]. |
|
1759 |
] |
|
20 | 1760 |
]. |
1761 |
^ s contents |
|
1762 |
||
1763 |
" |
|
1764 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1765 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1766 |
Parser methodSpecificationForSelector:#negated |
|
1767 |
" |
|
806 | 1768 |
|
1769 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1770 |
! ! |
1771 |
||
1020 | 1772 |
!Parser methodsFor:'Compatibility - ST80'! |
0 | 1773 |
|
918 | 1774 |
evaluate:aString in:aClassOrContext to:to notifying:aRequestor ifFail:failBlock |
35 | 1775 |
|parseTree value| |
0 | 1776 |
|
1777 |
aString isNil ifTrue:[^ nil]. |
|
1778 |
self initializeFor:(ReadStream on:aString). |
|
918 | 1779 |
|
1780 |
"/ stupid - there seem to be differences among the various |
|
1781 |
"/ ST dialects ... |
|
1782 |
aClassOrContext isBehavior ifTrue:[ |
|
1783 |
self setClassToCompileFor:aClassOrContext. |
|
1784 |
selfValue := nil. |
|
1785 |
] ifFalse:[ |
|
1786 |
self setContext:aClassOrContext. |
|
1787 |
aClassOrContext notNil ifTrue:[ |
|
1788 |
self setSelf:(aClassOrContext receiver) |
|
1789 |
]. |
|
1790 |
]. |
|
0 | 1791 |
requestor := aRequestor. |
1792 |
||
1793 |
self nextToken. |
|
1794 |
parseTree := self parseMethodBody. |
|
1795 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1796 |
parseTree notNil ifTrue:[ |
|
918 | 1797 |
self evalExitBlock:[:value | ^ failBlock value]. |
1798 |
value := parseTree evaluate |
|
0 | 1799 |
]. |
35 | 1800 |
self release. |
1801 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1802 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1803 |
|
624 | 1804 |
parse:methodSource in:aClass notifying:aRequestor |
1805 |
"parse a methods source. |
|
1806 |
Return the methods parseTree" |
|
1807 |
||
1808 |
self initializeFor:methodSource. |
|
1809 |
classToCompileFor := aClass. |
|
1810 |
requestor := aRequestor. |
|
1811 |
self parseMethod. |
|
918 | 1812 |
|
624 | 1813 |
^ MethodNode new |
1814 |
selector:selector |
|
1815 |
arguments:methodArgs |
|
1816 |
locals:methodVars |
|
1207 | 1817 |
statements:tree asCollectionOfStatements |
624 | 1818 |
|
1214 | 1819 |
"Created: / 17.10.1997 / 12:35:01 / cg" |
1820 |
"Modified: / 5.11.2001 / 16:56:43 / cg" |
|
624 | 1821 |
! |
1822 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1823 |
parseSelector:aStringOrStream |
624 | 1824 |
"parse a methods source for the methods selector. |
1825 |
Return the selector" |
|
1826 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1827 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1828 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1829 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1830 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1831 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1832 |
Parser new |
624 | 1833 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1834 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1835 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1836 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1837 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1838 |
' |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1839 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1840 |
|
624 | 1841 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1842 |
! ! |
1843 |
||
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1844 |
!Parser methodsFor:'Signal constants'! |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1845 |
|
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1846 |
restartCompilationSignal |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1847 |
^ RestartCompilationSignal |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1848 |
|
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1849 |
"Created: / 15.11.2001 / 22:57:05 / cg" |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1850 |
! ! |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
1851 |
|
44 | 1852 |
!Parser methodsFor:'accessing'! |
1853 |
||
1854 |
correctedSource |
|
1855 |
^ correctedSource |
|
1856 |
! |
|
1857 |
||
141 | 1858 |
errorFlag |
1859 |
"return true if there where any errors (valid after parsing)" |
|
1860 |
||
1861 |
^ errorFlag |
|
1862 |
! |
|
1863 |
||
1864 |
evalExitBlock:aBlock |
|
1865 |
"when evaluating a return expression, this block is evaluated" |
|
1866 |
||
1867 |
evalExitBlock := aBlock |
|
1868 |
! |
|
1869 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1870 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1871 |
"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
|
1872 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1873 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1874 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1875 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1876 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1877 |
|
19 | 1878 |
primitiveNumber |
1879 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1880 |
||
1881 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1882 |
! |
97 | 1883 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1884 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1885 |
"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
|
1886 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1887 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1888 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1889 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1890 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1891 |
|
35 | 1892 |
release |
664 | 1893 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1894 |
super release. |
664 | 1895 |
|
1896 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 1897 |
! |
1898 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1899 |
setNameSpace:aNameSpaceName |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
1900 |
currentNamespace := NameSpace fullName:aNameSpaceName |
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1901 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1902 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1903 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1904 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1905 |
setPackage:aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1906 |
currentPackage := aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1907 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1908 |
|
141 | 1909 |
targetClass |
1910 |
^ classToCompileFor |
|
1911 |
! |
|
1912 |
||
90 | 1913 |
targetClass:aClass |
117 | 1914 |
classToCompileFor := aClass |
1915 |
! |
|
1916 |
||
141 | 1917 |
tree |
1918 |
"return the parsetree" |
|
1919 |
||
1920 |
^tree |
|
1921 |
! |
|
1922 |
||
1923 |
tree:aTree |
|
1924 |
"private: set the tree - for internal use only" |
|
1925 |
||
1926 |
tree := aTree |
|
1363 | 1927 |
! |
1928 |
||
1929 |
warnSTXHereExtensionUsed |
|
1930 |
"return the value of the instance variable 'warnSTXHereExtensionUsed' (automatically generated)" |
|
1931 |
||
1932 |
^ warnSTXHereExtensionUsed |
|
141 | 1933 |
! ! |
1934 |
||
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1935 |
!Parser methodsFor:'dummy - syntax detection'! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1936 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1937 |
markArgumentIdentifierFrom:pos1 to:pos2 |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1938 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1939 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1940 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1941 |
|
883 | 1942 |
markBadIdentifierFrom:pos1 to:pos2 |
1943 |
||
1944 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
1945 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
1946 |
! |
|
1947 |
||
663 | 1948 |
markBooleanConstantFrom:pos1 to:pos2 |
1949 |
||
1950 |
"Created: / 31.3.1998 / 18:06:22 / cg" |
|
1951 |
! |
|
1952 |
||
673 | 1953 |
markBracketAt:pos |
1954 |
! |
|
1955 |
||
663 | 1956 |
markConstantFrom:pos1 to:pos2 |
1957 |
||
1958 |
"Created: / 31.3.1998 / 18:06:24 / cg" |
|
1959 |
! |
|
1960 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1961 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1962 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1963 |
"Created: / 4.3.1999 / 12:52:45 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1964 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1965 |
|
663 | 1966 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1967 |
||
1968 |
"Created: / 31.3.1998 / 15:29:39 / cg" |
|
1969 |
! |
|
1970 |
||
1971 |
markHereFrom:pos1 to:pos2 |
|
1972 |
||
1973 |
"Created: / 31.3.1998 / 17:39:01 / cg" |
|
1974 |
! |
|
1975 |
||
1976 |
markIdentifierFrom:pos1 to:pos2 |
|
1977 |
||
1978 |
"Created: / 31.3.1998 / 18:06:17 / cg" |
|
1979 |
! |
|
1980 |
||
687 | 1981 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1982 |
||
1983 |
"Created: / 16.4.1998 / 18:34:10 / cg" |
|
1984 |
! |
|
1985 |
||
663 | 1986 |
markLocalIdentifierFrom:pos1 to:pos2 |
1987 |
||
1988 |
"Created: / 31.3.1998 / 15:29:35 / cg" |
|
1989 |
! |
|
1990 |
||
1991 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1992 |
||
1993 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
1994 |
"Created: / 31.3.1998 / 16:39:44 / cg" |
|
1995 |
! |
|
1996 |
||
837 | 1997 |
markReturnAt:pos |
1998 |
||
1999 |
"Created: / 5.1.1980 / 00:48:24 / cg" |
|
2000 |
! |
|
2001 |
||
864 | 2002 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
2003 |
||
2004 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
|
2005 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
2006 |
! |
|
2007 |
||
663 | 2008 |
markSelfFrom:pos1 to:pos2 |
2009 |
||
2010 |
"Created: / 31.3.1998 / 17:49:38 / cg" |
|
2011 |
! |
|
2012 |
||
2013 |
markSuperFrom:pos1 to:pos2 |
|
2014 |
||
2015 |
"Created: / 31.3.1998 / 17:40:20 / cg" |
|
664 | 2016 |
! |
2017 |
||
2018 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
2019 |
||
2020 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
2021 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
687 | 2022 |
! |
2023 |
||
2024 |
markVariable:v |
|
2025 |
"support for syntaxColoring" |
|
2026 |
||
2027 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
2028 |
! |
|
2029 |
||
2030 |
markVariable:v from:pos1 to:pos2 |
|
2031 |
"support for syntaxColoring" |
|
2032 |
||
2033 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
2034 |
"Created: / 16.4.1998 / 18:50:03 / cg" |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2035 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2036 |
|
141 | 2037 |
!Parser methodsFor:'error correction'! |
2038 |
||
1295 | 2039 |
addDoItTemporary:varName |
2040 |
|holder| |
|
2041 |
||
2042 |
doItTemporaries isNil ifTrue:[ |
|
2043 |
doItTemporaries := IdentityDictionary new. |
|
2044 |
]. |
|
2045 |
doItTemporaries at:varName asSymbol put:(holder := ValueHolder new). |
|
2046 |
^ holder |
|
2047 |
! |
|
2048 |
||
141 | 2049 |
askForCorrection:aString fromList:aList |
2050 |
"launch a selection box, which allows user to enter correction. |
|
2051 |
return newString or nil (for abort)" |
|
2052 |
||
1323 | 2053 |
|box rslt| |
141 | 2054 |
|
2055 |
"in systems without widgets ..." |
|
2056 |
ListSelectionBox isNil ifTrue:[ |
|
1285 | 2057 |
^ self confirm:aString |
141 | 2058 |
]. |
2059 |
box := ListSelectionBox title:aString. |
|
2060 |
box initialText:(aList at:1). |
|
2061 |
box list:aList. |
|
1285 | 2062 |
box okText:'Correct'. |
1323 | 2063 |
box action:[:aString | rslt := aString]. |
141 | 2064 |
box showAtPointer. |
1323 | 2065 |
box destroy. |
2066 |
^ rslt |
|
2067 |
! |
|
2068 |
||
2069 |
askForCorrection:aString fromList:aList for:originalSelector |
|
2070 |
"launch a selection box, which allows user to enter correction. |
|
2071 |
return newString or nil (for abort)" |
|
2072 |
||
2073 |
|box rslt| |
|
2074 |
||
2075 |
"in systems without widgets ..." |
|
2076 |
ListSelectionBox isNil ifTrue:[ |
|
2077 |
^ self confirm:aString |
|
2078 |
]. |
|
2079 |
box := ListSelectionBox title:aString. |
|
2080 |
box initialText:(aList at:1). |
|
2081 |
box list:aList. |
|
2082 |
box okText:'Correct'. |
|
2083 |
box action:[:aString | rslt := aString]. |
|
2084 |
box addButton:(Button label:'Keep Selector' action:[rslt := originalSelector. box hide]) after:(box okButton). |
|
2085 |
box showAtPointer. |
|
2086 |
box destroy. |
|
2087 |
^ rslt |
|
141 | 2088 |
! |
2089 |
||
1295 | 2090 |
askForVariableTypeWhenDeclaringUndefined:varName |
2091 |
|l how varNameIsLowercase choice holder newClass| |
|
2092 |
||
2093 |
l := #(). |
|
2094 |
how := #(). |
|
2095 |
||
2096 |
varNameIsLowercase := (varName at:1) isLowercase. |
|
2097 |
||
2098 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
|
2099 |
varNameIsLowercase ifTrue:[ |
|
2100 |
"/ currentBlock notNil ifTrue:[ |
|
2101 |
"/ l := l , #( 'Block local' ). |
|
2102 |
"/ how := how , #( BlockVariable ). |
|
2103 |
"/ ]. |
|
2104 |
selector notNil ifTrue:[ |
|
2105 |
l := l , #( 'Method Local Variable' ). |
|
2106 |
how := how , #( MethodVariable ). |
|
2107 |
]. |
|
2108 |
(classToCompileFor notNil |
|
2109 |
and:[classToCompileFor isMeta not |
|
2110 |
and:[classToCompileFor isBuiltInClass not |
|
2111 |
and:[selector notNil and:[selector ~~ #doIt]]]]) ifTrue:[ |
|
2112 |
l := l copyWith:'Instance Variable'. |
|
2113 |
how := how copyWith: #InstanceVariable. |
|
2114 |
]. |
|
2115 |
] ifFalse:[ |
|
2116 |
l := l , #( 'New Class' 'Global' 'NameSpace' ). |
|
2117 |
how := how , #( NewClass GlobalVariable NameSpace ). |
|
2118 |
||
2119 |
(classToCompileFor notNil |
|
2120 |
and:[classToCompileFor isBuiltInClass not |
|
2121 |
and:[selector notNil and:[selector ~~ #doIt]]]) ifTrue:[ |
|
2122 |
classToCompileFor isMeta ifTrue:[ |
|
2123 |
l := l , #('Class Instance Variable'). |
|
2124 |
how := how , #( ClassInstanceVariable). |
|
2125 |
]. |
|
2126 |
l := l , #('Class Variable' ). |
|
2127 |
how := how , #( ClassVariable). |
|
2128 |
] |
|
2129 |
]. |
|
2130 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
|
2131 |
l size > 0 ifTrue:[ |
|
2132 |
l := l , #( '-' ). |
|
2133 |
how := how , #( nil ). |
|
2134 |
]. |
|
2135 |
l := l , #( 'Workspace Variable' 'DoIt Temporary'). |
|
2136 |
how := how , #( WorkspaceVariable DoItTemporary ). |
|
2137 |
]. |
|
2138 |
||
2139 |
l size > 0 ifTrue:[ |
|
2140 |
l := (Array with:('Declare ' , varName allBold , ' as:') |
|
2141 |
with:'-' |
|
2142 |
) , l. |
|
2143 |
how := #(nil nil) , how. |
|
2144 |
choice := (PopUpMenu labels:l) startUp. |
|
2145 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2146 |
choice := how at:choice. |
|
2147 |
||
2148 |
choice == #WorkspaceVariable ifTrue:[ |
|
2149 |
holder := Workspace addWorkspaceVariable:varName. |
|
2150 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2151 |
]. |
|
2152 |
choice == #DoItTemporary ifTrue:[ |
|
2153 |
holder := self addDoItTemporary:varName. |
|
2154 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
2155 |
]. |
|
2156 |
||
2157 |
choice == #GlobalVariable ifTrue:[ |
|
2158 |
Smalltalk at:varName asSymbol put:nil. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2159 |
^ VariableNode globalNamed:varName |
1295 | 2160 |
]. |
2161 |
||
2162 |
choice == #NewClass ifTrue:[ |
|
2163 |
newClass := Object subclass:varName asSymbol |
|
2164 |
instanceVariableNames:'' |
|
2165 |
classVariableNames:'' |
|
2166 |
poolDictionaries:'' |
|
2167 |
category:'* As yet uncategorized *'. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2168 |
^ VariableNode globalNamed:newClass name |
1295 | 2169 |
]. |
2170 |
||
2171 |
choice == #NameSpace ifTrue:[ |
|
2172 |
NameSpace name:varName. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2173 |
^ VariableNode globalNamed:varName |
1295 | 2174 |
]. |
2175 |
||
2176 |
choice == #ClassVariable ifTrue:[ |
|
2177 |
classToCompileFor theNonMetaclass addClassVarName:varName. |
|
2178 |
^ VariableNode type:#ClassVariable class:classToCompileFor theNonMetaclass name:varName |
|
2179 |
]. |
|
2180 |
||
2181 |
choice == #InstanceVariable ifTrue:[ |
|
2182 |
classToCompileFor theNonMetaclass addInstVarName:varName. |
|
2183 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2184 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2185 |
RestartCompilationSignal raise. |
|
2186 |
"/ not reached - restarted compile will not arrive here again |
|
2187 |
self error:'restart compile failed'. |
|
2188 |
]. |
|
2189 |
||
2190 |
choice == #ClassInstanceVariable ifTrue:[ |
|
2191 |
classToCompileFor theMetaclass addInstVarName:varName. |
|
2192 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2193 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2194 |
RestartCompilationSignal raise. |
|
2195 |
"/ not reached - restarted compile will not arrive here again |
|
2196 |
self error:'restart compile failed'. |
|
2197 |
]. |
|
2198 |
||
2199 |
choice == #MethodVariable ifTrue:[ |
|
2200 |
|varIndex var endLocalsPos posToInsert ins| |
|
2201 |
||
2202 |
localVarDefPosition size == 2 ifTrue:[ |
|
2203 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
|
2204 |
ins := ' ' , varName. |
|
2205 |
] ifFalse:[ |
|
2206 |
endOfSelectorPosition notNil ifTrue:[ |
|
2207 |
posToInsert := endOfSelectorPosition. |
|
2208 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
|
2209 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
|
2210 |
] |
|
2211 |
]. |
|
2212 |
posToInsert notNil ifTrue:[ |
|
2213 |
requestor |
|
2214 |
insertString:ins |
|
2215 |
atCharacterPosition:posToInsert. |
|
2216 |
||
2217 |
endLocalsPos notNil ifTrue:[ |
|
2218 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
|
2219 |
||
2220 |
methodVarNames := methodVarNames copyWith:varName. |
|
2221 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
|
2222 |
] ifFalse:[ |
|
2223 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
|
2224 |
||
2225 |
methodVarNames := Array with:varName. |
|
2226 |
methodVars := Array with:(var := Variable new name:varName). |
|
2227 |
]. |
|
2228 |
correctedSource := requestor currentSourceCode. |
|
2229 |
source := (ReadStream on:correctedSource) |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2230 |
position:(source position1Based + ins size). |
1295 | 2231 |
|
2232 |
varIndex := methodVarNames size. |
|
2233 |
var used:true. |
|
2234 |
^ VariableNode type:#MethodVariable |
|
2235 |
name:varName |
|
2236 |
token:var |
|
2237 |
index:varIndex |
|
2238 |
]. |
|
2239 |
]. |
|
2240 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
|
2241 |
]. |
|
2242 |
^ #Error |
|
2243 |
]. |
|
2244 |
^ nil. |
|
2245 |
! |
|
2246 |
||
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2247 |
checkSelector:selector inClass:cls |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2248 |
"check wether a method with selector exists in class cls an |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2249 |
that the methos is not obsolete. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2250 |
Return an error string on error or nil on success" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2251 |
|
1190
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2252 |
|err mthd implementor implementors| |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2253 |
|
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2254 |
cls isNil ifTrue:[ |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2255 |
implementors := SystemBrowser |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2256 |
findImplementorsOf:selector |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2257 |
in:(Smalltalk allClasses) |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2258 |
ignoreCase:false. |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2259 |
implementors size == 0 ifTrue:[ |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2260 |
^ 'is nowhere implemented' |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2261 |
]. |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2262 |
^ nil |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2263 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2264 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2265 |
mthd := cls lookupMethodFor:selector. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2266 |
mthd isNil ifTrue:[ |
1327 | 2267 |
cls == Boolean ifTrue:[ |
2268 |
mthd := True lookupMethodFor:selector. |
|
2269 |
mthd isNil ifTrue:[ |
|
2270 |
mthd := False lookupMethodFor:selector. |
|
2271 |
]. |
|
2272 |
] |
|
2273 |
]. |
|
2274 |
mthd isNil ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2275 |
"if it implements #doesNotUnderstand somewhere, assume it is ok" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2276 |
implementor := cls whichClassIncludesSelector:#doesNotUnderstand:. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2277 |
(implementor isNil or:[implementor == Object]) ifTrue:[ |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2278 |
err := 'is not implemented' |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2279 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2280 |
] ifFalse:[ |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2281 |
mthd isObsolete ifTrue:[ |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2282 |
err := 'is deprecated'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2283 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2284 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2285 |
^ err. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2286 |
! |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2287 |
|
141 | 2288 |
correctByDeleting |
2289 |
"correct (by deleting token) if user wants to; |
|
2290 |
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
|
2291 |
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
|
2292 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2293 |
|selectionSize| |
141 | 2294 |
|
2295 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
2296 |
||
2297 |
" |
|
2298 |
tell requestor (i.e. CodeView) about the change |
|
2299 |
this will update what the requestor shows. |
|
2300 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2301 |
selectionSize := requestor selection size. |
141 | 2302 |
requestor deleteSelection. |
2303 |
||
2304 |
" |
|
2305 |
get the updated source-string |
|
2306 |
which is needed, when we eventually install the new method |
|
2307 |
" |
|
2308 |
correctedSource := requestor currentSourceCode. |
|
1167 | 2309 |
"/ update the current source position |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2310 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2311 |
position:(source position1Based - selectionSize). |
1369
2304dd8c3173
recompilation after correct-by-deleting unused local
Claus Gittinger <cg@exept.de>
parents:
1368
diff
changeset
|
2312 |
|
141 | 2313 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2314 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2315 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 2316 |
! |
2317 |
||
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2318 |
correctSelector:aSelectorString message:msg position:pos1 to:pos2 in:aClassOrNil for:receiverNode |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2319 |
"notify error and correct if user wants to; |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2320 |
return #Error if there was no correction |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2321 |
or a ParseNode as returned by variable" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2322 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2323 |
|correctIt suggestedNames newSelector className classToGenerateCode| |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2324 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2325 |
alreadyWarnedUnimplementedSelectors isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2326 |
alreadyWarnedUnimplementedSelectors := Set new |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2327 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2328 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2329 |
(alreadyWarnedUnimplementedSelectors includes:aSelectorString) ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2330 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2331 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2332 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2333 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2334 |
sorry, but I cannot handle keywords with more than one-part |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2335 |
currently (too much work - maybe Ill do it later when everything else works :-) |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2336 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2337 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2338 |
self warning:msg position:pos1 to:pos2. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2339 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2340 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2341 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2342 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2343 |
correctIt := self correctableSelectorWarning:msg position:pos1 to:pos2. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2344 |
correctIt == #generate ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2345 |
receiverNode isSelf ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2346 |
classToGenerateCode := classToCompileFor |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2347 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2348 |
receiverNode isVariable ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2349 |
receiverNode isGlobal ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2350 |
classToGenerateCode := receiverNode evaluate. |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2351 |
classToGenerateCode isBehavior ifTrue:[ |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2352 |
classToGenerateCode := classToGenerateCode theMetaclass. |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2353 |
] ifFalse:[ |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2354 |
classToGenerateCode := nil |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2355 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2356 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2357 |
] |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2358 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2359 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2360 |
className := Dialog request:'Generate code in class:' initialAnswer:classToCompileFor name. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2361 |
className size == 0 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2362 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2363 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2364 |
classToGenerateCode := Smalltalk at:className asSymbol. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2365 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2366 |
self warn:'No such class.'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2367 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2368 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2369 |
]. |
1252
666db3206028
#implements: -> #includesSelector:
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2370 |
(classToGenerateCode includesSelector:aSelectorString asSymbol) ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2371 |
"do not overwrite an already existant (deprecated) method" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2372 |
classToGenerateCode |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2373 |
compile:((self class methodSpecificationForSelector:aSelectorString) , '\ self shouldImplement' withCRs) |
1323 | 2374 |
classified:(Compiler defaultMethodCategory). |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2375 |
]. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2376 |
correctIt := false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2377 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2378 |
correctIt ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2379 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2380 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2381 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2382 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2383 |
suggestedNames := self findBestSelectorsFor:aSelectorString in:aClassOrNil. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2384 |
suggestedNames notNil ifTrue:[ |
1323 | 2385 |
newSelector := self askForCorrection:'Correct Selector to: ' fromList:suggestedNames for:aSelectorString. |
2386 |
newSelector isNil ifTrue:[AbortSignal raise "^ aSelectorString"]. |
|
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2387 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2388 |
self information:'no good correction found'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2389 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2390 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2391 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2392 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2393 |
tell requestor (i.e. CodeView) about the change |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2394 |
this will update what the requestor shows. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2395 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2396 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2397 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2398 |
get the updated source-string |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2399 |
which is needed, when we eventually install the new method |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2400 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2401 |
correctedSource := requestor currentSourceCode. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2402 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2403 |
position:(source position1Based + 1 + (newSelector size - aSelectorString size)). |
1361 | 2404 |
"/ Parser murks. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2405 |
^ newSelector |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2406 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2407 |
"Modified: / 22.1.1998 / 16:36:04 / stefan" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2408 |
"Created: / 19.1.2000 / 16:34:01 / cg" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2409 |
"Modified: / 19.1.2000 / 16:34:55 / cg" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2410 |
! |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2411 |
|
1167 | 2412 |
correctSourceByDeletingFrom:start to:stop |
2413 |
"correct (by deleting token) if user wants to; |
|
2414 |
return #Error if there was no correction; |
|
2415 |
nil if there was one." |
|
2416 |
||
2417 |
|deleteSize| |
|
2418 |
||
2419 |
" |
|
2420 |
tell requestor (i.e. CodeView) about the change |
|
2421 |
this will update what the requestor shows. |
|
2422 |
" |
|
2423 |
deleteSize := stop - start + 1. |
|
2424 |
requestor deleteFromCharacterPosition:start to:stop. |
|
2425 |
||
2426 |
" |
|
2427 |
get the updated source-string |
|
2428 |
which is needed, when we eventually install the new method |
|
2429 |
" |
|
2430 |
correctedSource := requestor currentSourceCode. |
|
2431 |
"/ update the current source position |
|
2432 |
source := (ReadStream on:correctedSource) |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2433 |
position:(source position1Based - deleteSize). |
1167 | 2434 |
^ nil |
2435 |
! |
|
2436 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2437 |
correctVariable:varName atPosition:pos1 to:pos2 |
141 | 2438 |
"notify error and correct if user wants to; |
2439 |
return #Error if there was no correction |
|
2440 |
or a ParseNode as returned by variable" |
|
2441 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2442 |
|correctIt suggestedNames newName rslt |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2443 |
varNameIsLowercase undeclared boldName| |
141 | 2444 |
|
877 | 2445 |
varNameIsLowercase := (varName at:1) isLowercase. |
2446 |
||
141 | 2447 |
correctIt := self undefError:varName position:pos1 to:pos2. |
887 | 2448 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 2449 |
"/ no correction wanted. |
2450 |
||
2451 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
2452 |
"/ allowing easy search for bad-spots later. |
|
1285 | 2453 |
boldName := varName allBold. |
877 | 2454 |
|
2455 |
varNameIsLowercase ifTrue:[ |
|
1205 | 2456 |
undeclared := Smalltalk at:#Undeclared. |
2457 |
((undeclared notNil) |
|
2458 |
and:[(undeclared includes:varName asSymbol)]) ifFalse:[ |
|
1285 | 2459 |
self warning:('Adding ''' , boldName , ''' as Undeclared.\\Remember to fix that later.') withCRs position:pos1 to:pos2. |
725
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2460 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2461 |
^ self defineAsUndeclaredVariable:varName |
877 | 2462 |
]. |
2463 |
||
2464 |
"/ upperCase vars are declared as global |
|
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2465 |
(warnedUndefVars isNil or:[(warnedUndefVars includes:varName) not]) ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2466 |
(warnedUnknownNamespaces isNil or:[(warnedUnknownNamespaces includes:varName) not]) ifTrue:[ |
1285 | 2467 |
self warning:('adding ''' , boldName , ''' as Global.') withCRs position:pos1 to:pos2. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2468 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2469 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2470 |
^ VariableNode globalNamed:varName |
877 | 2471 |
]. |
2472 |
||
2473 |
correctIt == #declare ifTrue:[ |
|
2474 |
"/ declare it |
|
1295 | 2475 |
rslt := self askForVariableTypeWhenDeclaringUndefined:varName. |
2476 |
rslt notNil ifTrue:[ |
|
2477 |
^ rslt |
|
2478 |
]. |
|
141 | 2479 |
]. |
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2480 |
(correctIt isKindOf:ParseNode) ifTrue:[ |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2481 |
^ correctIt |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2482 |
]. |
141 | 2483 |
|
2484 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2485 |
suggestedNames isNil ifTrue:[ |
1285 | 2486 |
self information:'No good correction found'. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2487 |
^ #Error |
141 | 2488 |
]. |
2489 |
||
1285 | 2490 |
newName := self askForCorrection:'Correct Variable to: ' fromList:suggestedNames. |
877 | 2491 |
newName isNil ifTrue:[^ #Error]. |
2492 |
" |
|
2493 |
newName := suggestedNames at:1. |
|
2494 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2495 |
" |
|
2496 |
||
141 | 2497 |
" |
2498 |
tell requestor (i.e. CodeView) about the change |
|
2499 |
this will update what the requestor shows. |
|
2500 |
" |
|
2501 |
requestor replaceSelectionBy:newName. |
|
2502 |
" |
|
2503 |
get the updated source-string |
|
2504 |
which is needed, when we eventually install the new method |
|
2505 |
" |
|
2506 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2507 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2508 |
position:(source position1Based + newName size - tokenName size). |
141 | 2509 |
|
2510 |
"redo parse with new value" |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
2511 |
token := 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
|
2512 |
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
|
2513 |
|
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
|
2514 |
"/ 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
|
2515 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2516 |
"/ 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
|
2517 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2518 |
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
|
2519 |
]. |
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
|
2520 |
^ 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
|
2521 |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2522 |
"Modified: / 22.1.1998 / 16:34:01 / stefan" |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
2523 |
"Modified: / 15.11.2001 / 22:56:38 / 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
|
2524 |
! |
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
|
2525 |
|
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
|
2526 |
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
|
2527 |
"define varName as undeclared variable |
629 | 2528 |
(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
|
2529 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2530 |
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
|
2531 |
|
1206 | 2532 |
|varName undeclared| |
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
|
2533 |
|
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
|
2534 |
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
|
2535 |
|
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
|
2536 |
"/ 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
|
2537 |
|
1206 | 2538 |
undeclared := Smalltalk at:#Undeclared. |
2539 |
undeclared isNil ifTrue:[ |
|
2540 |
Smalltalk at:#Undeclared put:(undeclared := IdentitySet new). |
|
2541 |
]. |
|
2542 |
undeclared add:tokenName asSymbol. |
|
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
2543 |
varName := (Smalltalk undeclaredPrefix) , 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
|
2544 |
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
|
2545 |
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
|
2546 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2547 |
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
|
2548 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2549 |
^ VariableNode globalNamed: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
|
2550 |
|
629 | 2551 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 2552 |
! |
2553 |
||
1167 | 2554 |
deleteDefinitionOf:varName in:defStartPos to:defEndPos |
1393 | 2555 |
"this removes the definition of varName from the declaration part i.e. |
2556 |
if the source was '... | foo bar baz |...' |
|
2557 |
deleting the var 'bar' changes the source to '... | foo baz |...'. |
|
2558 |
The code below tries to be somewhat smart w.r.t. spaces by |
|
2559 |
trying to remove the whiteSpace around the removed variable also. |
|
2560 |
However, this seems to not always work correctly" |
|
2561 |
||
1172 | 2562 |
|source startSearch pos pos2 nextChar varSlot| |
2563 |
||
2564 |
varSlot := methodVars detect:[:var | var name = varName]. |
|
2565 |
methodVars removeIdentical:varSlot. |
|
1167 | 2566 |
|
2567 |
source := requestor currentSourceCode. |
|
2568 |
startSearch := defStartPos+1. |
|
2569 |
||
2570 |
[ |
|
1393 | 2571 |
|prevChar isFirstVar didPassEndOfLine| |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2572 |
|
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2573 |
"/ search this name's position in the declaration part ... |
1167 | 2574 |
pos := source indexOfSubCollection:varName startingAt:startSearch ifAbsent:0. |
1326 | 2575 |
(pos == 0 or:[pos >= defEndPos]) ifTrue:[ |
2576 |
self error:'should not happen' mayProceed:true. |
|
1167 | 2577 |
^ self. |
2578 |
]. |
|
2579 |
||
2580 |
pos2 := pos + varName size - 1. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2581 |
pos > 1 ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2582 |
prevChar := source at:pos-1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2583 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2584 |
(prevChar isNil or:[prevChar isLetterOrDigit not]) ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2585 |
nextChar := source at:pos2+1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2586 |
nextChar isLetterOrDigit ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2587 |
"/ halfway intuitive space-removal behavior; |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2588 |
"/ if there was a space after/before the |-char, |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2589 |
"/ leave it; otherwise remove it. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2590 |
isFirstVar := pos == (defStartPos+1). |
1393 | 2591 |
(source at:pos-1) isSeparator ifTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2592 |
pos := pos - 1. |
1393 | 2593 |
[ (source at:pos-1) isSeparator] whileTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2594 |
pos := pos - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2595 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2596 |
(source at:pos-1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2597 |
"/ there was a space before - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2598 |
pos := pos + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2599 |
isFirstVar := true. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2600 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2601 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2602 |
|
1393 | 2603 |
(source at:pos2+1) isSeparator ifTrue:[ |
2604 |
didPassEndOfLine := (source at:pos2+1) == Character cr. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2605 |
pos2 := pos2 + 1. |
1393 | 2606 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
2607 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2608 |
pos2 := pos2 + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2609 |
]. |
1393 | 2610 |
|
2611 |
didPassEndOfLine ifFalse:[ |
|
2612 |
(source at:pos2+1) == $" ifTrue:[ |
|
2613 |
"/ comment follows - assume it belongs to the removed variable |
|
2614 |
pos2 := pos2 + 1. |
|
2615 |
(source at:pos2+1) == $/ ifTrue:[ |
|
2616 |
"/ EOL comment |
|
2617 |
[ (source at:pos2+1) == Character cr ] whileFalse:[ |
|
2618 |
pos2 := pos2 + 1. |
|
2619 |
]. |
|
2620 |
pos2 := pos2 + 1. |
|
2621 |
] ifFalse:[ |
|
2622 |
"/ regular comment |
|
2623 |
[ (source at:pos2+1) == $" ] whileFalse:[ |
|
2624 |
pos2 := pos2 + 1. |
|
2625 |
]. |
|
2626 |
pos2 := pos2 + 1. |
|
2627 |
]. |
|
2628 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
|
2629 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
2630 |
pos2 := pos2 + 1. |
|
2631 |
]. |
|
2632 |
] |
|
2633 |
]. |
|
2634 |
||
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2635 |
(source at:pos2+1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2636 |
"/ there was a space after - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2637 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2638 |
] ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2639 |
isFirstVar ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2640 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2641 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2642 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2643 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2644 |
|
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2645 |
self correctSourceByDeletingFrom:pos to:pos2. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2646 |
^ self. |
1167 | 2647 |
]. |
2648 |
]. |
|
2649 |
startSearch := pos2 + 1. |
|
2650 |
] loop |
|
2651 |
! |
|
2652 |
||
141 | 2653 |
findBestSelectorsFor:aString |
2654 |
"collect known selectors with their spelling distances to aString; |
|
2655 |
return the 10 best suggestions" |
|
2656 |
||
1187 | 2657 |
^ self class findBestSelectorsFor:aString |
141 | 2658 |
|
2659 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
2660 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
2661 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
2662 |
! |
|
2663 |
||
1022 | 2664 |
findBestSelectorsFor:aString in:aClassOrNil |
2665 |
"collect known selectors with their spelling distances to aString; |
|
2666 |
return the 10 best suggestions. If the argument, aClassOrNil is not nil, |
|
2667 |
the message is assumed to be sent to instances of that class (i.e. offer |
|
2668 |
corrections from that hierarchy only)" |
|
2669 |
||
1187 | 2670 |
^ self class findBestSelectorsFor:aString in:aClassOrNil |
1022 | 2671 |
! |
2672 |
||
141 | 2673 |
findBestVariablesFor:aString |
2674 |
"collect known variables with their spelling distances to aString; |
|
2675 |
return the 10 best suggestions" |
|
2676 |
||
1200 | 2677 |
|names dists searchBlock args vars "aClass className baseClass" |
2678 |
n instVarNames classVarNames spellAgainstAction| |
|
141 | 2679 |
|
2680 |
names := OrderedCollection new. |
|
2681 |
dists := OrderedCollection new. |
|
2682 |
||
1200 | 2683 |
spellAgainstAction := |
2684 |
[:aVarNode | |
|
2685 |
|varName dist| |
|
2686 |
||
2687 |
varName := aVarNode name. |
|
2688 |
names add:varName. |
|
2689 |
||
2690 |
dist := aString spellAgainst:varName. |
|
2691 |
(aString startsWith:varName) ifTrue:[ |
|
2692 |
dist := dist + (aString size * 10). |
|
2693 |
]. |
|
2694 |
dists add:dist |
|
2695 |
]. |
|
2696 |
||
141 | 2697 |
"block arguments" |
2698 |
searchBlock := currentBlock. |
|
2699 |
[searchBlock notNil] whileTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2700 |
args := searchBlock arguments. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2701 |
args notNil ifTrue:[ |
1200 | 2702 |
args do:spellAgainstAction |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2703 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2704 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2705 |
vars := searchBlock variables. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2706 |
vars notNil ifTrue:[ |
1200 | 2707 |
vars do:spellAgainstAction |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2708 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2709 |
searchBlock := searchBlock home |
141 | 2710 |
]. |
2711 |
||
1200 | 2712 |
spellAgainstAction := |
2713 |
[:givenName | |
|
2714 |
|dist| |
|
2715 |
||
2716 |
names add:givenName. |
|
2717 |
dist := aString spellAgainst:givenName. |
|
2718 |
(aString startsWith:givenName) ifTrue:[ |
|
2719 |
dist := dist + (aString size * 10). |
|
2720 |
]. |
|
2721 |
dists add:dist |
|
2722 |
]. |
|
2723 |
||
141 | 2724 |
"method-variables" |
2725 |
methodVars notNil ifTrue:[ |
|
1200 | 2726 |
methodVarNames do:spellAgainstAction |
141 | 2727 |
]. |
2728 |
||
2729 |
"method-arguments" |
|
2730 |
methodArgs notNil ifTrue:[ |
|
1200 | 2731 |
methodArgNames do:spellAgainstAction |
141 | 2732 |
]. |
2733 |
||
2734 |
"instance-variables" |
|
2735 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 2736 |
self classesInstVarNames do:spellAgainstAction |
141 | 2737 |
]. |
2738 |
||
2739 |
"class-variables" |
|
2740 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 2741 |
self classesClassVarNames do:spellAgainstAction. |
141 | 2742 |
|
2743 |
"/ aClass := classToCompileFor. |
|
2744 |
"/ aClass isMeta ifTrue:[ |
|
2745 |
"/ className := aClass name. |
|
2746 |
"/ className := className copyWithoutLast:5. |
|
2747 |
"/ baseClass := Smalltalk at:(className asSymbol). |
|
2748 |
"/ baseClass notNil ifTrue:[ |
|
2749 |
"/ aClass := baseClass |
|
2750 |
"/ ] |
|
2751 |
"/ ]. |
|
2752 |
"/ [aClass notNil] whileTrue:[ |
|
2753 |
"/ (aClass classVarNames) do:[:classVarName | |
|
2754 |
"/ names add:classVarName. |
|
2755 |
"/ dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
2756 |
"/ ]. |
|
2757 |
"/ aClass := aClass superclass |
|
2758 |
"/ ] |
|
2759 |
||
2760 |
]. |
|
2761 |
||
2762 |
"globals" |
|
2763 |
Smalltalk keysDo:[:aKey | |
|
1200 | 2764 |
|globalVarName| |
2765 |
||
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2766 |
globalVarName := aKey asString. |
1200 | 2767 |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2768 |
"only compare strings where length is about right" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2769 |
((globalVarName size - aString size) abs < 3) ifTrue:[ |
1200 | 2770 |
spellAgainstAction value:globalVarName. |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2771 |
] |
141 | 2772 |
]. |
2773 |
||
2774 |
"misc" |
|
1200 | 2775 |
#('self' 'super' 'nil' 'thisContext') do:spellAgainstAction. |
141 | 2776 |
|
2777 |
(dists size ~~ 0) ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2778 |
dists sortWith:names. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2779 |
dists := dists reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2780 |
names := names reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2781 |
n := names size min:10. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2782 |
names := names copyTo:n. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2783 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2784 |
"if it starts with a lower case character, add all local & instvar names" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2785 |
(aString at:1) isLowercase ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2786 |
methodVarNames size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2787 |
names add:'---- method locals ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2788 |
methodVarNames asSortedCollection do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2789 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2790 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2791 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2792 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2793 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2794 |
methodArgs size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2795 |
names add:'---- method arguments ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2796 |
methodArgNames asSortedCollection do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2797 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2798 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2799 |
]. |
1078 | 2800 |
classToCompileFor notNil ifTrue:[ |
2801 |
instVarNames := OrderedCollection new. |
|
2802 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
2803 |
(instVarNames includes:instVarName) ifFalse:[ |
|
2804 |
instVarNames add:instVarName. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2805 |
] |
1078 | 2806 |
]. |
2807 |
||
2808 |
instVarNames size > 0 ifTrue:[ |
|
2809 |
(classToCompileFor notNil and:[classToCompileFor isMeta]) ifTrue:[ |
|
2810 |
names add:'---- class instance variables ----'. |
|
2811 |
] ifFalse:[ |
|
2812 |
names add:'---- instance variables ----'. |
|
2813 |
]. |
|
2814 |
instVarNames do:[:instVarName | |
|
2815 |
(names includes:instVarName) ifFalse:[ |
|
2816 |
names add:instVarName. |
|
2817 |
] |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2818 |
] |
1078 | 2819 |
]. |
2820 |
||
2821 |
classVarNames := OrderedCollection new. |
|
2822 |
self classesClassVarNames asSortedCollection do:[:classVarName | |
|
2823 |
(classVarNames includes:classVarName) ifFalse:[ |
|
2824 |
classVarNames add:classVarName. |
|
2825 |
] |
|
2826 |
]. |
|
2827 |
||
2828 |
classVarNames size > 0 ifTrue:[ |
|
2829 |
names add:'---- class variables ----'. |
|
2830 |
classVarNames do:[:classVarName | |
|
2831 |
(names includes:classVarName) ifFalse:[ |
|
2832 |
names add:classVarName. |
|
2833 |
] |
|
2834 |
] |
|
2835 |
]. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2836 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2837 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2838 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2839 |
^ names |
141 | 2840 |
]. |
2841 |
^ nil |
|
450 | 2842 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2843 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 2844 |
! |
2845 |
||
2846 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
2847 |
"just a quick check: if a selector is totally unknown as a symbol, |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2848 |
has the same name as a variable, cannot be understood or is obsolete. |
141 | 2849 |
Simple, but catches many typos" |
2850 |
||
1327 | 2851 |
|err sym rec names recType selClass newSelector nm nowhereImplemented| |
141 | 2852 |
|
2853 |
" |
|
2854 |
if compiling lazy, or errors are to be ignored, or there |
|
2855 |
is no requestor, do not check |
|
2856 |
" |
|
1022 | 2857 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2858 |
self isSyntaxHighlighter ifFalse:[ |
1022 | 2859 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
2860 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2861 |
]. |
141 | 2862 |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
2863 |
aSelectorString = '#' ifTrue:[ |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
2864 |
self warnPossibleIncompatibility:'''#'' might not be a valid selector in other smalltalk systems' position:pos1 to:pos2. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
2865 |
]. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
2866 |
|
141 | 2867 |
" |
2868 |
check if the selector is known at all |
|
2869 |
- if not, it cannot be understood |
|
2870 |
" |
|
1327 | 2871 |
nowhereImplemented := false. |
2872 |
||
141 | 2873 |
sym := aSelectorString asSymbolIfInterned. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2874 |
sym isNil ifTrue:[ |
1327 | 2875 |
nowhereImplemented := true. |
2876 |
"/ ] ifFalse:[ |
|
2877 |
"/ nowhereImplemented := (self implementedInAnyClass:sym) not. |
|
2878 |
]. |
|
2879 |
||
2880 |
nowhereImplemented ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2881 |
err := ' is currently nowhere implemented'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2882 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2883 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2884 |
if the selector has the name of a variable, use another message |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2885 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2886 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2887 |
or:[(methodArgNames notNil and:[methodArgNames includes:aSelectorString]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2888 |
or:[(classToCompileFor notNil |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2889 |
and:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString])]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2890 |
or:[(classToCompileFor notNil |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2891 |
and:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString])]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2892 |
or:[classToCompileFor notNil |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2893 |
and:[((names := self classesClassVarNames) notNil and:[names includes:aSelectorString])]]]]]) ifTrue:[ |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2894 |
err := ' is currently nowhere implemented .. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2895 |
.. but a variable with that name is defined. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2896 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2897 |
Missing ''.'' after the previous expression |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2898 |
or missing keyword/receiver before that word ?'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2899 |
]. |
1327 | 2900 |
] ifFalse:[ |
2901 |
receiver notNil ifTrue:[ |
|
2902 |
selClass := self typeOfNode:receiver. |
|
2903 |
selClass notNil ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2904 |
err := self checkSelector:sym inClass:selClass. |
1327 | 2905 |
]. |
2906 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2907 |
(receiver isConstant or:[receiver isBlock]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2908 |
err notNil ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2909 |
err := err, ' in ' , selClass name , ' or any of its superclasses'. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2910 |
]. |
1327 | 2911 |
] ifFalse:[(((recType := receiver type) == #GlobalVariable) |
2912 |
or:[recType == #PrivateClass]) ifTrue:[ |
|
2913 |
rec := receiver evaluate. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2914 |
"/ dont check autoloaded classes - it may work after loading |
1327 | 2915 |
(rec isNil |
2916 |
or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[ |
|
2917 |
^ aSelectorString |
|
2918 |
]. |
|
2919 |
||
2920 |
err notNil ifTrue:[ |
|
2921 |
(rec isBehavior |
|
2922 |
and:[rec theNonMetaclass name = receiver name]) ifTrue:[ |
|
2923 |
err := err, ' in ' , rec theNonMetaclass name. |
|
2924 |
] ifFalse:[ |
|
2925 |
err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'. |
|
2926 |
] |
|
2927 |
]. |
|
2928 |
] ifFalse:[receiver isSuper ifTrue:[ |
|
2929 |
receiver isHere ifFalse:[ |
|
2930 |
err notNil ifTrue:[ |
|
2931 |
err := err, ' in superclass chain'. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2932 |
]. |
1327 | 2933 |
] ifTrue:[ |
2934 |
err notNil ifTrue:[ |
|
2935 |
err := err, ' in this class or superclass chain'. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
2936 |
]. |
1327 | 2937 |
] |
2938 |
] ifFalse:[receiver isSelf ifTrue:[ |
|
2939 |
err notNil ifTrue:[ |
|
2940 |
|subErr| |
|
2941 |
||
2942 |
"/ understood by all subclasses ? |
|
2943 |
classToCompileFor allSubclassesDo:[:eachSubclass | |
|
2944 |
subErr isNil ifTrue:[ |
|
2945 |
selClass := eachSubclass. |
|
2946 |
subErr := self checkSelector:sym inClass:selClass. |
|
2947 |
]. |
|
2948 |
]. |
|
2949 |
subErr notNil ifTrue:[ |
|
2950 |
err := subErr, ' in this class, superclass chain or all subclasses' |
|
2951 |
] ifFalse:[ |
|
2952 |
err := err, ' in this class or superclass chain'. |
|
2953 |
]. |
|
2954 |
]. |
|
2955 |
] ifFalse:[(receiver isUnaryMessage |
|
2956 |
and:[receiver selector == #class |
|
2957 |
and:[receiver receiver isSelf]]) ifTrue:[ |
|
2958 |
"its a message to self class - can check this too ..." |
|
2959 |
err notNil ifTrue:[ |
|
2960 |
classToCompileFor isMeta ifTrue:[ |
|
2961 |
err := err, ' for the classes class'. |
|
2962 |
(self checkSelector:sym inClass:classToCompileFor) isNil ifTrue:[ |
|
2963 |
err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'. |
|
2964 |
err := err withCRs. |
|
2965 |
]. |
|
2966 |
] ifFalse:[ |
|
2967 |
err := err, ' for my class'. |
|
2968 |
(self checkSelector:sym inClass:classToCompileFor) isNil ifTrue:[ |
|
2969 |
err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'. |
|
2970 |
err := err withCRs. |
|
2971 |
]. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
2972 |
]. |
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
2973 |
]. |
1327 | 2974 |
] ifFalse:[(receiver isMethodVariable and:[receiver token type isNil]) ifTrue:[ |
2975 |
"if it is an uninitialized variable ..." |
|
2976 |
((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not]) |
|
2977 |
and:[alreadyWarnedUninitializedVars isNil |
|
2978 |
or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]) |
|
2979 |
ifTrue:[ |
|
2980 |
((#(at: at:put: basicAt: basicAt:put:) includes:sym) |
|
2981 |
or:[(nil respondsTo:sym) not])ifTrue:[ |
|
2982 |
"/ avoid trouble in miniTalk |
|
2983 |
"/ during bootstrap |
|
2984 |
nm := receiver name. |
|
2985 |
Text notNil ifTrue:[ |
|
2986 |
nm := nm allItalic |
|
2987 |
]. |
|
2988 |
err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'. |
|
2989 |
alreadyWarnedUninitializedVars isNil ifTrue:[ |
|
2990 |
alreadyWarnedUninitializedVars := Set new |
|
2991 |
]. |
|
2992 |
alreadyWarnedUninitializedVars add:receiver name |
|
2993 |
] |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2994 |
] |
1327 | 2995 |
] ifFalse:[ |
2996 |
err notNil ifTrue:[ |
|
2997 |
err := err, ' (message to ' , selClass nameWithArticle , ')'. |
|
2998 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2999 |
]]]]]]. |
1327 | 3000 |
] |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3001 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3002 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3003 |
err notNil ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3004 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3005 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3006 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3007 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3008 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3009 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3010 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3011 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3012 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3013 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 3014 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3015 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3016 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3017 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3018 |
"/ it may work after loading/defining |
1022 | 3019 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3020 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3021 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3022 |
Text notNil ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3023 |
err := '"' , aSelectorString allBold "allItalic" , '" ', err |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
3024 |
] ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3025 |
err := aSelectorString , ' ', err |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
3026 |
]. |
1157
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3027 |
"/ if its a recursive invocation of just that selector, do not complain |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3028 |
(selector = aSelectorString and:[ receiver isSelf]) ifTrue:[ |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3029 |
^ aSelectorString |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3030 |
]. |
1368 | 3031 |
err := err , '\\This is a warning from the compiler - the code has not yet been executed/compiled'. |
1022 | 3032 |
newSelector := self correctSelector:aSelectorString |
1368 | 3033 |
message:err withCRs position:pos1 to:pos2 in:selClass for:receiver. |
1022 | 3034 |
"/ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2. |
3035 |
^ newSelector. |
|
141 | 3036 |
]. |
1022 | 3037 |
^ aSelectorString |
141 | 3038 |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3039 |
"Modified: / 5.9.1995 / 17:02:11 / claus" |
1022 | 3040 |
"Modified: / 19.1.2000 / 16:34:03 / cg" |
1327 | 3041 |
! |
3042 |
||
3043 |
typeOfNode:aNode |
|
3044 |
|nodeVal nodeType| |
|
3045 |
||
3046 |
aNode isConstant ifTrue:[ |
|
3047 |
" |
|
3048 |
if the receiver is a constant, we can check if it responds |
|
3049 |
to this selector |
|
3050 |
" |
|
3051 |
nodeVal := aNode evaluate. |
|
3052 |
^ nodeVal class. |
|
3053 |
]. |
|
3054 |
||
3055 |
"/ this should help with typos, sending #ifTrue to blocks ... |
|
3056 |
aNode isBlock ifTrue:[ |
|
3057 |
^ Block |
|
3058 |
]. |
|
3059 |
||
3060 |
(((nodeType := aNode type) == #GlobalVariable) |
|
3061 |
or:[nodeType == #PrivateClass]) ifTrue:[ |
|
3062 |
"if the receiver is a global, we check it too ..." |
|
3063 |
||
3064 |
nodeVal := aNode evaluate. |
|
3065 |
"/ dont check autoloaded classes |
|
3066 |
"/ - it may work after loading |
|
3067 |
(nodeVal isNil |
|
3068 |
or:[nodeVal isBehavior and:[nodeVal isLoaded not]]) ifTrue:[ |
|
3069 |
^ nil |
|
3070 |
]. |
|
3071 |
||
3072 |
^ nodeVal class. |
|
3073 |
]. |
|
3074 |
||
3075 |
aNode isSuper ifTrue:[ |
|
3076 |
"if its a super- or here-send, we can do more checking" |
|
3077 |
aNode isHere ifFalse:[ |
|
3078 |
^ classToCompileFor superclass ? UndefinedObject. |
|
3079 |
]. |
|
3080 |
^ classToCompileFor. |
|
3081 |
]. |
|
3082 |
aNode isSelf ifTrue:[ |
|
3083 |
^ classToCompileFor. |
|
3084 |
]. |
|
3085 |
||
3086 |
(aNode isUnaryMessage) ifTrue:[ |
|
3087 |
(aNode selector == #class) ifTrue:[ |
|
3088 |
aNode receiver isSelf ifTrue:[ |
|
3089 |
"its a message to self class - can check this too ..." |
|
3090 |
^ classToCompileFor class. |
|
3091 |
]. |
|
3092 |
]. |
|
3093 |
( #(#'isNil' #'notNil') includes:aNode selector) ifTrue:[ |
|
3094 |
^ Boolean. |
|
3095 |
] |
|
3096 |
]. |
|
3097 |
aNode isBinaryMessage ifTrue:[ |
|
3098 |
( #(#'<' #'>' #'>=' #'<=' #'=' #'==' #'~=' #'~~') includes:aNode selector) ifTrue:[ |
|
3099 |
^ Boolean. |
|
3100 |
] |
|
3101 |
]. |
|
3102 |
||
3103 |
^ nil |
|
0 | 3104 |
! ! |
3105 |
||
3106 |
!Parser methodsFor:'error handling'! |
|
3107 |
||
1259 | 3108 |
blockArgRedefined:tokenName from:pos1 to:pos2 |
3109 |
"argname reuse" |
|
3110 |
||
3111 |
self isSyntaxHighlighter ifTrue:[ |
|
3112 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3113 |
] ifFalse:[ |
|
3114 |
self |
|
3115 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3116 |
position:pos1 to:pos2 |
|
3117 |
]. |
|
3118 |
! |
|
3119 |
||
141 | 3120 |
exitWith:something |
3121 |
"this is the longjump out of evaluation via a return expression" |
|
3122 |
||
3123 |
evalExitBlock value:something |
|
3124 |
! |
|
3125 |
||
3126 |
identifierExpectedIn:what |
|
3127 |
|msg| |
|
3128 |
||
3129 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3130 |
msg := 'Reserved keyword in ' |
141 | 3131 |
] ifFalse:[ |
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3132 |
msg := 'Identifier expected in ' |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3133 |
]. |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3134 |
self syntaxError:(msg , what , ' (got ''' , tokenType printString, ''')') |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3135 |
position:tokenPosition to:source position1Based - 1. |
141 | 3136 |
^ #Error |
3137 |
! |
|
3138 |
||
1259 | 3139 |
methodArgRedefined:tokenName from:pos1 to:pos2 |
3140 |
"argname reuse" |
|
3141 |
||
3142 |
self isSyntaxHighlighter ifTrue:[ |
|
3143 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3144 |
] ifFalse:[ |
|
3145 |
self |
|
3146 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3147 |
position:pos1 to:pos2 |
|
3148 |
]. |
|
3149 |
! |
|
3150 |
||
0 | 3151 |
showErrorMessage:aMessage position:pos |
19 | 3152 |
"redefined since parser can give more detailed info about |
3153 |
the class & selector where the error occured." |
|
3154 |
||
71 | 3155 |
|text| |
3156 |
||
19 | 3157 |
ignoreErrors ifFalse:[ |
1160 | 3158 |
Smalltalk silentLoading == true ifFalse:[ |
3159 |
pos notNil ifTrue:[ |
|
3160 |
Transcript show:(pos printString). |
|
3161 |
Transcript show:' '. |
|
3162 |
]. |
|
3163 |
selector notNil ifTrue:[ |
|
3164 |
Transcript show:aMessage. |
|
3165 |
classToCompileFor notNil ifTrue:[ |
|
3166 |
text := ' in ' , classToCompileFor name , '>>' , selector |
|
3167 |
] ifFalse:[ |
|
3168 |
text := ' in ' , selector |
|
3169 |
] |
|
3170 |
] ifFalse:[ |
|
3171 |
classToCompileFor notNil ifTrue:[ |
|
3172 |
text := aMessage , ' (' , classToCompileFor name , ')' |
|
3173 |
] ifFalse:[ |
|
3174 |
text := aMessage |
|
3175 |
] |
|
3176 |
]. |
|
3177 |
Transcript showCR:text. |
|
3178 |
] |
|
0 | 3179 |
] |
273 | 3180 |
|
3181 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 3182 |
! |
3183 |
||
171 | 3184 |
showErrorMessageForClass:aClass |
3185 |
"/ compiler parseError:'syntax error'. |
|
3186 |
Transcript show:' '. |
|
3187 |
aClass notNil ifTrue:[ |
|
619 | 3188 |
Transcript show:aClass name , '>>' |
171 | 3189 |
]. |
3190 |
selector notNil ifTrue:[ |
|
619 | 3191 |
Transcript show:(selector) |
171 | 3192 |
]. |
273 | 3193 |
Transcript showCR:' -> Error'. |
171 | 3194 |
|
3195 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 3196 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 3197 |
! |
3198 |
||
0 | 3199 |
undefError:aName position:pos1 to:pos2 |
3 | 3200 |
"report an undefined variable error - return true, if it should be |
86 | 3201 |
corrected. If not corrected, only one warning is made per undefined |
3202 |
variable." |
|
3203 |
||
1400 | 3204 |
|ex doCorrect msg idx boldName| |
3205 |
||
3206 |
ex := UndefinedVariableNotification newException. |
|
3207 |
ex parser:self. |
|
3208 |
ex parameter:aName. |
|
3209 |
ex suspendedContext:thisContext. |
|
3210 |
doCorrect := ex raiseRequest. |
|
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3211 |
doCorrect notNil ifTrue:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3212 |
^ doCorrect |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3213 |
]. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3214 |
|
607 | 3215 |
warnUndeclared ifFalse:[^ false]. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
3216 |
ignoreWarnings ifTrue:[^ false]. |
607 | 3217 |
|
86 | 3218 |
" |
3219 |
alredy warned about this one ? |
|
3220 |
" |
|
3221 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 3222 |
(warnedUndefVars includes:aName) ifTrue:[ |
3223 |
"already warned about this one" |
|
3224 |
^ false |
|
3225 |
]. |
|
86 | 3226 |
]. |
3227 |
||
131 | 3228 |
"/ (classToCompileFor notNil |
3229 |
"/ and:[classToCompileFor superclass notNil |
|
3230 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
3231 |
"/ 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
|
3232 |
"/ ^ false |
131 | 3233 |
"/ ]. |
3234 |
||
1285 | 3235 |
boldName := aName allBold. |
3236 |
||
131 | 3237 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
877 | 3238 |
aName first isUppercase ifFalse:[ |
1285 | 3239 |
self showErrorMessage:('Error: ''' , boldName , ''' is undefined') position:pos1. |
877 | 3240 |
]. |
3241 |
doCorrect := false. |
|
86 | 3242 |
] ifFalse:[ |
877 | 3243 |
" |
3244 |
ask requestor for correct/continue/abort ... |
|
3245 |
it is supposed to raise abort or return true/false. |
|
3246 |
True return means that correction is wanted. |
|
3247 |
" |
|
1285 | 3248 |
msg := 'Warning: ''' , boldName , ''' is undefined'. |
877 | 3249 |
classToCompileFor notNil ifTrue:[ |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3250 |
"/ is it an instance-variable marked inaccessable ? |
877 | 3251 |
|
3252 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
3253 |
idx ~~ 0 ifTrue:[ |
|
1285 | 3254 |
msg := 'Warning: ''' , boldName , ''' is a hidden instvar (not accessable from ST-code)'. |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3255 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3256 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3257 |
"/ is it an instance variable, while evaluateing for the class ? |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3258 |
classToCompileFor isMeta ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3259 |
(classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[ |
1285 | 3260 |
msg := 'Warning: ''' , boldName , ''' is an instvar\(hint: you are evaluating/compiling in the classes context)' withCRs. |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3261 |
] |
877 | 3262 |
] |
3263 |
]. |
|
3264 |
||
3265 |
doCorrect := self correctableError:msg position:pos1 to:pos2 |
|
86 | 3266 |
]. |
3267 |
||
877 | 3268 |
doCorrect == false ifTrue:[ |
3269 |
warnedUndefVars isNil ifTrue:[ |
|
3270 |
warnedUndefVars := Set new. |
|
3271 |
]. |
|
3272 |
warnedUndefVars add:aName. |
|
3 | 3273 |
]. |
0 | 3274 |
|
86 | 3275 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
3276 |
|
607 | 3277 |
"Modified: 7.9.1997 / 02:14:36 / cg" |
1160 | 3278 |
! |
3279 |
||
3280 |
warnUnused:aNameCollection |
|
3281 |
"report an unused method variable" |
|
3282 |
||
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3283 |
|s msg answer localsPos1 localsPos2| |
1160 | 3284 |
|
3285 |
(ignoreErrors not and:[ignoreWarnings not and:[warnUnusedVars]]) ifTrue:[ |
|
3286 |
s := '' writeStream. |
|
1167 | 3287 |
s nextPutAll:'Unused method variable(s): '. |
1160 | 3288 |
aNameCollection asSortedCollection do:[:name| |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3289 |
s nextPutAll:' '; nextPutAll:name asText allBold. |
1160 | 3290 |
]. |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3291 |
msg := s contents. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3292 |
|
1160 | 3293 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3294 |
self showErrorMessage:('Warning: ', msg) position:nil. |
1160 | 3295 |
] ifFalse:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3296 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3297 |
localsPos1 := localVarDefPosition first. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3298 |
localsPos2 := localVarDefPosition last. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3299 |
|
1167 | 3300 |
answer := requestor |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3301 |
unusedVariableWarning:msg |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3302 |
position:localsPos1 to:localsPos2 from:self. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3303 |
|
1167 | 3304 |
answer == true ifTrue:[ |
3305 |
"/ delete the definitions ... |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3306 |
aNameCollection do:[:eachName | |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3307 |
self deleteDefinitionOf:eachName in:localsPos1 to:localsPos2. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3308 |
]. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3309 |
RestartCompilationSignal raise |
1167 | 3310 |
]. |
1160 | 3311 |
]. |
3312 |
]. |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3313 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3314 |
"Modified: / 17.11.2001 / 10:30:47 / cg" |
0 | 3315 |
! ! |
3316 |
||
1363 | 3317 |
!Parser methodsFor:'evaluating expressions'! |
3318 |
||
3319 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
3320 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3321 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3322 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3323 |
is non-nil, it is evaluated if an error occurs. |
|
3324 |
Finally, compile specifies if the string should be compiled down to |
|
3325 |
bytecode or instead be interpreted from the parseTree. |
|
3326 |
The first should be done for doIts etc, where a readable walkback is |
|
3327 |
required. |
|
3328 |
The latter is better done for constants, styleSheet and resource |
|
3329 |
reading and simple sends, where the overhead of compilation is bigger |
|
3330 |
than the interpretation overhead." |
|
3331 |
||
3332 |
|tree mustBackup loggedString chgStream value s sReal spc |
|
3333 |
nameSpaceQuerySignal compiler| |
|
3334 |
||
3335 |
aStringOrStream isNil ifTrue:[ |
|
3336 |
EmptySourceNotificationSignal raiseRequest. |
|
3337 |
^ nil |
|
3338 |
]. |
|
3339 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
|
3340 |
s := aStringOrStream. |
|
3341 |
] ifFalse:[ |
|
3342 |
loggedString := aStringOrStream. |
|
3343 |
s := ReadStream on:aStringOrStream. |
|
3344 |
]. |
|
3345 |
||
3346 |
self source:s. |
|
3347 |
||
3348 |
self parseForCode. |
|
3349 |
self foldConstants:nil. |
|
3350 |
self setSelf:anObject. |
|
3351 |
self setContext:aContext. |
|
3352 |
aContext notNil ifTrue:[ |
|
3353 |
self setSelf:(aContext receiver). |
|
3354 |
"/ aContext method notNil ifTrue:[ |
|
3355 |
"/ cls := aContext method mclass |
|
3356 |
"/ ]. |
|
3357 |
"/ self setClassToCompileFor:(cls ? aContext receiver class). |
|
3358 |
self setClassToCompileFor:(aContext receiver class). |
|
3359 |
]. |
|
3360 |
self notifying:requestor. |
|
3361 |
self nextToken. |
|
3362 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3363 |
tree := self parseMethodBodyOrEmpty. |
|
3364 |
||
3365 |
self checkForEndOfInput. |
|
3366 |
||
3367 |
"if reading from a stream, backup for next expression" |
|
3368 |
mustBackup ifTrue:[ |
|
3369 |
self backupPosition |
|
3370 |
]. |
|
3371 |
||
3372 |
(self errorFlag or:[tree == #Error]) ifTrue:[ |
|
3373 |
failBlock notNil ifTrue:[ |
|
3374 |
^ failBlock value |
|
3375 |
]. |
|
3376 |
^ #Error |
|
3377 |
]. |
|
3378 |
||
3379 |
tree isNil ifTrue:[ |
|
3380 |
EmptySourceNotificationSignal raiseRequest. |
|
3381 |
^ nil |
|
3382 |
]. |
|
3383 |
||
3384 |
(logged |
|
3385 |
and:[loggedString notNil |
|
3386 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
3387 |
Class updateChangeFileQuerySignal query ifTrue:[ |
|
3388 |
chgStream := Class changesStream. |
|
3389 |
chgStream notNil ifTrue:[ |
|
3390 |
chgStream nextChunkPut:loggedString. |
|
3391 |
chgStream cr. |
|
3392 |
chgStream close |
|
3393 |
] |
|
3394 |
]. |
|
3395 |
Project notNil ifTrue:[ |
|
3396 |
Class updateChangeListQuerySignal query ifTrue:[ |
|
3397 |
Project addDoIt:loggedString |
|
3398 |
] |
|
3399 |
] |
|
3400 |
]. |
|
3401 |
||
3402 |
" |
|
3403 |
during the evaluation, handle nameSpace queries |
|
3404 |
from the value as defined by any namespace directive. |
|
3405 |
This, if its a class definition expression, the class will |
|
3406 |
be installed there. |
|
3407 |
" |
|
3408 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
3409 |
||
3410 |
spc := self getNameSpace. |
|
3411 |
spc isNil ifTrue:[ |
|
3412 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
|
3413 |
spc := requestor currentNameSpace |
|
3414 |
] ifFalse:[ |
|
3415 |
spc := nameSpaceQuerySignal query. |
|
3416 |
] |
|
3417 |
]. |
|
3418 |
||
3419 |
nameSpaceQuerySignal answer:spc |
|
3420 |
do:[ |
|
3421 |
|method| |
|
3422 |
||
3423 |
" |
|
3424 |
if compile is false, or the parse tree is that of a constant, |
|
3425 |
or a variable, quickly return its value. |
|
3426 |
This is used for example, when reading simple objects |
|
3427 |
via #readFrom:. |
|
3428 |
The overhead of compiling a method is avoided in this case. |
|
3429 |
" |
|
3430 |
((SuppressDoItCompilation == true) |
|
3431 |
or:[compile not |
|
3432 |
or:[tree isConstant |
|
3433 |
or:[tree isVariable |
|
3434 |
or:[aStringOrStream isStream |
|
3435 |
or:[aContext notNil]]]]]) ifTrue:[ |
|
3436 |
^ tree evaluate |
|
3437 |
]. |
|
3438 |
||
3439 |
" |
|
3440 |
if I am the ByteCodeCompiler, |
|
3441 |
generate a dummy method, execute it and return the value. |
|
3442 |
otherwise, just evaluate the tree; slower, but not too bad ... |
|
3443 |
||
3444 |
This allows systems to be delivered without the ByteCodeCompiler, |
|
3445 |
and still evaluate expressions |
|
3446 |
(needed to read resource files or to process .rc files). |
|
3447 |
" |
|
3448 |
self == Parser ifTrue:[ |
|
3449 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3450 |
value := tree evaluate. |
|
3451 |
self evalExitBlock:nil. |
|
3452 |
] ifFalse:[ |
|
3453 |
s := self correctedSource. |
|
3454 |
s isNil ifTrue:[ |
|
3455 |
aStringOrStream isStream ifTrue:[ |
|
3456 |
s := self collectedSource. "/ does not work yet ... |
|
3457 |
] ifFalse:[ |
|
3458 |
s := aStringOrStream |
|
3459 |
]. |
|
3460 |
]. |
|
3461 |
||
3462 |
"/ actually, its a block, to allow |
|
3463 |
"/ easy return ... |
|
3464 |
||
3465 |
sReal := 'doIt ^[\' withCRs , s , '\] value' withCRs. |
|
3466 |
||
1366
f91f6a0a56d5
when required to compile, use Compiler instead of self class.
Claus Gittinger <cg@exept.de>
parents:
1365
diff
changeset
|
3467 |
compiler := ByteCodeCompiler new. |
1363 | 3468 |
compiler initializeFlagsFrom:self. |
3469 |
method := compiler |
|
3470 |
compile:sReal |
|
3471 |
forClass:anObject class |
|
3472 |
inCategory:'_temporary_' |
|
3473 |
notifying:requestor |
|
3474 |
install:false |
|
3475 |
skipIfSame:false |
|
3476 |
silent:true |
|
3477 |
foldConstants:false. |
|
3478 |
||
3479 |
method notNil ifTrue:[ |
|
3480 |
method ~~ #Error ifTrue:[ |
|
3481 |
" |
|
3482 |
fake: patch the source string, to what the user expects |
|
3483 |
in the browser |
|
3484 |
" |
|
3485 |
method source:' \' withCRs , s string. |
|
3486 |
" |
|
3487 |
dont do any just-in-time compilation on it. |
|
3488 |
" |
|
3489 |
method checked:true. |
|
3490 |
||
3491 |
value := method |
|
3492 |
valueWithReceiver:anObject |
|
3493 |
arguments:nil "/ (Array with:m) |
|
3494 |
selector:#doIt "/ #doIt: |
|
3495 |
search:nil |
|
3496 |
sender:nil. |
|
3497 |
] ifFalse:[ |
|
3498 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3499 |
value := tree evaluate. |
|
3500 |
self evalExitBlock:nil. |
|
3501 |
] |
|
3502 |
]. |
|
3503 |
] |
|
3504 |
]. |
|
3505 |
self release. |
|
3506 |
^ value |
|
3507 |
||
3508 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
|
3509 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
|
3510 |
"Modified: / 6.2.2000 / 15:01:57 / cg" |
|
3511 |
! ! |
|
3512 |
||
0 | 3513 |
!Parser methodsFor:'parsing'! |
3514 |
||
141 | 3515 |
block |
3516 |
"parse a block; return a node-tree, nil or #Error" |
|
3517 |
||
883 | 3518 |
|node args argNames arg pos pos2 lno| |
141 | 3519 |
|
3520 |
lno := tokenLineNr. |
|
3521 |
self nextToken. |
|
3522 |
(tokenType == $: ) ifTrue:[ |
|
663 | 3523 |
[tokenType == $:] whileTrue:[ |
3524 |
pos := tokenPosition. |
|
3525 |
self nextToken. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3526 |
|
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3527 |
(pos == (tokenPosition - 1)) ifFalse:[ |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3528 |
self warnPossibleIncompatibility:'space(s) between colon and identifier may be non-portable' position:pos to:tokenPosition. |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3529 |
]. |
883 | 3530 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 3531 |
^ self identifierExpectedIn:'block-arg declaration' |
3532 |
]. |
|
883 | 3533 |
|
3534 |
pos2 := tokenPosition + tokenName size - 1. |
|
3535 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
663 | 3536 |
arg := Variable name:tokenName. |
3537 |
args isNil ifTrue:[ |
|
3538 |
args := Array with:arg. |
|
3539 |
argNames := Array with:tokenName. |
|
3540 |
] ifFalse:[ |
|
3541 |
(argNames includes:tokenName) ifTrue:[ |
|
1259 | 3542 |
self blockArgRedefined:tokenName from:tokenPosition to:pos2 |
663 | 3543 |
]. |
3544 |
args := args copyWith:arg. |
|
3545 |
argNames := argNames copyWith:tokenName. |
|
3546 |
]. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3547 |
self nextToken. |
663 | 3548 |
]. |
3549 |
(tokenType ~~ $| ) ifTrue:[ |
|
3550 |
"ST-80 allows [:arg ]" |
|
3551 |
(tokenType == $] ) ifTrue:[ |
|
3552 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
3553 |
node lineNumber:lno. |
|
3554 |
^ node |
|
3555 |
]. |
|
3556 |
self syntaxError:'| expected after block-arg declaration'. |
|
3557 |
^ #Error |
|
3558 |
]. |
|
3559 |
self nextToken |
|
141 | 3560 |
]. |
3561 |
node := self blockBody:args. |
|
3562 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 3563 |
node lineNumber:lno. |
141 | 3564 |
]. |
3565 |
^ node |
|
663 | 3566 |
|
3567 |
"Modified: / 31.3.1998 / 17:31:34 / cg" |
|
141 | 3568 |
! |
3569 |
||
3570 |
blockBody:args |
|
3571 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
3572 |
||
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3573 |
|stats node var vars lno pos2| |
141 | 3574 |
|
3575 |
lno := tokenLineNr. |
|
3576 |
(tokenType == $| ) ifTrue:[ |
|
668 | 3577 |
self nextToken. |
3578 |
[tokenType == $|] whileFalse:[ |
|
3579 |
(tokenType == #Identifier) ifFalse:[ |
|
3580 |
^ self identifierExpectedIn:'block-var declaration' |
|
3581 |
]. |
|
883 | 3582 |
pos2 := tokenPosition + tokenName size - 1. |
3583 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
668 | 3584 |
var := Variable name:tokenName. |
3585 |
vars isNil ifTrue:[ |
|
3586 |
vars := Array with:var. |
|
3587 |
] ifFalse:[ |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3588 |
(vars contains:[:var | var name = tokenName]) ifTrue:[ |
883 | 3589 |
"/ varname reuse |
3590 |
self isSyntaxHighlighter ifTrue:[ |
|
3591 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3592 |
] ifFalse:[ |
|
3593 |
self |
|
3594 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3595 |
position:tokenPosition to:pos2. |
|
3596 |
] |
|
668 | 3597 |
] ifFalse:[ |
3598 |
vars := vars copyWith:var. |
|
3599 |
] |
|
3600 |
]. |
|
3601 |
self nextToken. |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3602 |
"/ ((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3603 |
"/ AllowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3604 |
"/ "/ self halt. |
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3605 |
"/ "/ Q: should we allow literals only, or arbitrary expression. |
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3606 |
"/ ] |
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3607 |
"/ ]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3608 |
(tokenType == $() ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3609 |
self variableTypeDeclarationFor:var. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3610 |
]. |
668 | 3611 |
]. |
3612 |
self nextToken |
|
141 | 3613 |
]. |
382 | 3614 |
|
141 | 3615 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
3616 |
node lineNumber:lno. |
|
3617 |
currentBlock := node. |
|
3618 |
stats := self blockStatementList. |
|
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3619 |
(stats == #Error) ifTrue:[^ #Error]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3620 |
|
382 | 3621 |
lineNumberInfo == #full ifTrue:[ |
668 | 3622 |
node endLineNumber:tokenLineNr |
382 | 3623 |
]. |
141 | 3624 |
node statements:stats. |
3625 |
currentBlock := node home. |
|
3626 |
^ node |
|
382 | 3627 |
|
668 | 3628 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 3629 |
! |
3630 |
||
3631 |
blockExpression |
|
3632 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
3633 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
3634 |
||
3635 |
tokenType ~~ $[ ifTrue:[ |
|
3636 |
self syntaxError:'[ expected'. |
|
3637 |
^ #Error. |
|
3638 |
]. |
|
3639 |
^ self block |
|
3640 |
! |
|
3641 |
||
3642 |
blockStatementList |
|
3643 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
3644 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3645 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 3646 |
|
3647 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
3648 |
thisStatement := self statement. |
|
3649 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3650 |
firstStatement := thisStatement. |
|
3651 |
[tokenType == $] ] whileFalse:[ |
|
673 | 3652 |
(tokenType == $.) ifFalse:[ |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3653 |
(tokenType == #EOF) ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3654 |
self syntaxError:'missing '']'' in block' position:(source position1Based) to:(source position1Based). |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3655 |
^ #Error. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3656 |
]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3657 |
|
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3658 |
(tokenType == $) ) ifTrue:[ |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3659 |
eMsg := 'missing '']'' or bad '')'' in block' |
673 | 3660 |
] ifFalse:[ |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3661 |
eMsg := 'missing ''.'' between statements (i.e. ''' , tokenType printString , '''-token unexpected)' |
673 | 3662 |
]. |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3663 |
self syntaxError:eMsg position:tokenPosition to:tokenPosition. |
673 | 3664 |
^ #Error |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3665 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3666 |
prevStatement := thisStatement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3667 |
self nextToken. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3668 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3669 |
tokenType == $] ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3670 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3671 |
*** I had a warning here (since it was not defined |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3672 |
*** in the blue-book; but PD-code contains a lot of |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3673 |
*** code with periods at the end so that the warnings |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3674 |
*** became annoying |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3675 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3676 |
self warning:'period after last statement in block'. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3677 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3678 |
self markBracketAt:tokenPosition. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3679 |
^ firstStatement |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3680 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3681 |
thisStatement := self statement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3682 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3683 |
prevStatement nextStatement:thisStatement |
141 | 3684 |
]. |
673 | 3685 |
self markBracketAt:tokenPosition. |
141 | 3686 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3687 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3688 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 3689 |
! |
3690 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3691 |
checkForEndOfInput |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3692 |
|what| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3693 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3694 |
(tokenType ~~ #EOF) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3695 |
"/ just for the nicer error message |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3696 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3697 |
self parseError:tokenName , ' unexpected (missing ''.'' or '':'' before ' , tokenName , ' ?)' |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3698 |
position:tokenPosition to:(tokenPosition + tokenName size - 1) |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3699 |
] ifFalse:[ |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3700 |
tokenType isCharacter ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3701 |
what := '''' , tokenType , ''''. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3702 |
] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3703 |
what := tokenType printString. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3704 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
3705 |
self parseError:(what , ' unexpected (missing ''.'', '':'' or selector before it ?)') |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3706 |
position:tokenPosition to:source position1Based-1. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3707 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3708 |
^#Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3709 |
] |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3710 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3711 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3712 |
checkReturnedValues |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3713 |
| returnsSelf returnsBoolean returnsNonBooleanLiteral| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3714 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3715 |
ignoreWarnings ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3716 |
returnedValues isNil ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3717 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3718 |
returnsBoolean := returnedValues contains:[:node | node isConstant and:[node value isBoolean]]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3719 |
returnsNonBooleanLiteral := returnedValues contains:[:node | node isConstant and:[node value isBoolean not]]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3720 |
returnsSelf := returnedValues contains:[:node | node isSelf]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3721 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3722 |
returnsBoolean ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3723 |
(returnsNonBooleanLiteral or:[returnsSelf]) ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3724 |
self notifyWarning:'Possible Error Warning:\\Method returns both boolean and non-boolean values.' withCRs |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3725 |
position:1 to:tokenPosition |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3726 |
] |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3727 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3728 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3729 |
"Created: / 17.11.2001 / 10:31:03 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3730 |
"Modified: / 17.11.2001 / 10:34:16 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3731 |
! |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3732 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3733 |
checkUnusedMethodVars |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3734 |
| unused| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3735 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3736 |
ignoreWarnings ifFalse:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3737 |
methodVars notNil ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3738 |
unused := methodVars select:[:var| var used ~~ true] thenCollect:[:var| var name]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3739 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3740 |
unused size > 0 ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3741 |
self warnUnused:unused. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3742 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3743 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3744 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3745 |
"Created: / 17.11.2001 / 10:23:47 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3746 |
! |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3747 |
|
1224
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3748 |
parseExceptionOrContextPragma |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3749 |
|pragmaType| |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3750 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3751 |
"/ < resource: has already been parsed. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3752 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3753 |
pragmaType := tokenName. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3754 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3755 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3756 |
(tokenType ~~ #Symbol) ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3757 |
self parseError:'symbol expected'. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3758 |
^ #Error |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3759 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3760 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3761 |
((pragmaType = 'exception:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3762 |
and:[tokenValue == #'handle' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3763 |
or:[tokenValue == #'raise' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3764 |
or:[tokenValue == #'unwind']]]) |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3765 |
or:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3766 |
pragmaType = 'context:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3767 |
and:[(tokenValue == #'return')]]) |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3768 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3769 |
ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3770 |
primitiveContextInfo isNil ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3771 |
primitiveContextInfo := Set new. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3772 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3773 |
primitiveContextInfo add:(pragmaType->tokenValue). |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3774 |
] ifFalse:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3775 |
self parseError:'unrecognized exception pragma: ' , tokenValue. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3776 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3777 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3778 |
! |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
3779 |
|
1006 | 3780 |
parseExpressionWithSelf:anObject notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
3781 |
"parse aString as an expression with self set to anObject; |
|
3782 |
Return the parseTree (if ok), nil (for an empty string |
|
3783 |
or comment only ) or #Error (syntactic error). |
|
3784 |
||
3785 |
Errors and warnings are forwarded to someOne (usually some |
|
3786 |
codeView) which can highlight it and show a popup box, |
|
3787 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
3788 |
||
3789 |
|tree token| |
|
3790 |
||
3791 |
aNameSpaceOrNil notNil ifTrue:[ |
|
3792 |
self currentNameSpace:aNameSpaceOrNil |
|
3793 |
]. |
|
3794 |
self setSelf:anObject. |
|
3795 |
self notifying:someOne. |
|
1365 | 3796 |
self ignoreErrors:ignoreErrors. |
3797 |
self ignoreWarnings:ignoreWarnings. |
|
1006 | 3798 |
token := self nextToken. |
3799 |
(token == $^) ifTrue:[ |
|
3800 |
self nextToken. |
|
3801 |
]. |
|
3802 |
tree := self expression. |
|
3803 |
(self errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3804 |
"/ tokenType ~~ #EOF ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3805 |
"/ self parseError:'nothing more expected' position:tokenPosition |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3806 |
"/ ]. |
1006 | 3807 |
^ tree |
3808 |
||
3809 |
"Created: / 14.12.1999 / 15:11:37 / cg" |
|
3810 |
! |
|
3811 |
||
1259 | 3812 |
parseExtendedMethodSpec |
3813 |
|pos1 pos2 var| |
|
3814 |
||
3815 |
"/ EXPERIMENTAL |
|
3816 |
false ifTrue:[ |
|
3817 |
(tokenType == #Symbol) ifTrue:[ |
|
3818 |
pos1 := tokenPosition. |
|
3819 |
selector := token asSymbol. |
|
3820 |
self nextToken. |
|
3821 |
self markMethodSelectorFrom:pos1 to:(tokenPosition-1). |
|
3822 |
endOfSelectorPosition := tokenPosition. |
|
3823 |
||
3824 |
tokenType == $( ifTrue:[ |
|
3825 |
self nextToken. |
|
3826 |
[ tokenType ~~ $) ] whileTrue:[ |
|
3827 |
||
3828 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
|
3829 |
pos2 := tokenPosition+tokenName size-1. |
|
3830 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
3831 |
var := Variable name:tokenName. |
|
3832 |
methodArgs isNil ifTrue:[ |
|
3833 |
methodArgs := Array with:var. |
|
3834 |
methodArgNames := Array with:tokenName |
|
3835 |
] ifFalse:[ |
|
3836 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
3837 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
|
3838 |
]. |
|
3839 |
methodArgs := methodArgs copyWith:var. |
|
3840 |
methodArgNames := methodArgNames copyWith:tokenName |
|
3841 |
]. |
|
3842 |
self nextToken. |
|
3843 |
]. |
|
3844 |
self nextToken. |
|
3845 |
]. |
|
3846 |
||
3847 |
^ self |
|
3848 |
]. |
|
3849 |
]. |
|
3850 |
^ #Error |
|
3851 |
! |
|
3852 |
||
0 | 3853 |
parseMethod |
19 | 3854 |
"parse a method. |
3855 |
Return the parseTree or #Error. |
|
3856 |
||
3857 |
method ::= methodSpec methodBody |
|
3858 |
" |
|
0 | 3859 |
|
3860 |
|parseTree| |
|
3861 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3862 |
"/ self nextToken. |
0 | 3863 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
3864 |
parseTree := self parseMethodBody. |
|
3865 |
(parseTree == #Error) ifFalse:[ |
|
1171
0c43ce981f1b
oops - remove unused vars does not work (yet)
Claus Gittinger <cg@exept.de>
parents:
1169
diff
changeset
|
3866 |
self tree:parseTree |
0 | 3867 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
3868 |
self checkForEndOfInput. |
0 | 3869 |
^ parseTree |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3870 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3871 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 3872 |
! |
3873 |
||
19 | 3874 |
parseMethodBody |
3875 |
"parse a methods body (locals & statements). |
|
3876 |
No more tokens may follow. |
|
3877 |
Return a node-tree, or #Error |
|
3878 |
||
3879 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 3880 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 3881 |
|
3882 |
" |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3883 |
|stats| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3884 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3885 |
stats := self parseMethodBodyOrEmpty. |
19 | 3886 |
(stats == #Error) ifFalse:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3887 |
self checkForEndOfInput. |
19 | 3888 |
]. |
1160 | 3889 |
ignoreWarnings ifFalse:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3890 |
self checkUnusedMethodVars. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3891 |
self checkReturnedValues. |
1160 | 3892 |
]. |
19 | 3893 |
^ stats |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3894 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3895 |
"Modified: / 17.11.2001 / 10:31:12 / cg" |
19 | 3896 |
! |
3897 |
||
79 | 3898 |
parseMethodBodyOrEmpty |
0 | 3899 |
"parse a methods body (locals & statements); |
19 | 3900 |
return a node-tree, nil or #Error. |
3901 |
empty (or comment only) input is accepted and returns nil. |
|
3902 |
||
3903 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3904 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3905 |
| <empty> |
19 | 3906 |
" |
0 | 3907 |
|
265 | 3908 |
|stats| |
0 | 3909 |
|
3910 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
3911 |
||
3912 |
(tokenType ~~ #EOF) ifTrue:[ |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3913 |
stats := self statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3914 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
3915 |
"/ (tokenType ~~ #EOF) ifTrue:[ |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
3916 |
"/ self parseError:'nothing more expected here' position:tokenPosition to:tokenPosition. |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
3917 |
"/ ^ #Error |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
3918 |
"/ ]. |
1231 | 3919 |
(stats notNil |
3920 |
and:[stats ~~ #Error]) ifTrue:[ |
|
3921 |
stats last isReturnNode ifFalse:[ |
|
3922 |
"/ remember a returned self here. |
|
1262 | 3923 |
self rememberReturnedValue:(self selfNode) |
1231 | 3924 |
]. |
3925 |
]. |
|
0 | 3926 |
^ stats |
265 | 3927 |
|
3928 |
"Modified: 27.4.1996 / 16:57:56 / cg" |
|
0 | 3929 |
! |
3930 |
||
19 | 3931 |
parseMethodBodyVarSpec |
265 | 3932 |
"parse a methods local variable specification, handling |
3933 |
possible primitive or resourceSpecs. |
|
3934 |
. |
|
19 | 3935 |
Leave spec of locals in methodLocals as a side effect. |
3936 |
Return #Error or nil. |
|
0 | 3937 |
|
19 | 3938 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 3939 |
| <empty> |
19 | 3940 |
" |
0 | 3941 |
|
883 | 3942 |
|var pos pos2 msg| |
0 | 3943 |
|
265 | 3944 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 3945 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 3946 |
]. |
3947 |
||
0 | 3948 |
(tokenType == $|) ifTrue:[ |
663 | 3949 |
"memorize position for declaration in correction" |
883 | 3950 |
|
663 | 3951 |
localVarDefPosition := tokenPosition. |
3952 |
self nextToken. |
|
3953 |
pos := tokenPosition. |
|
3954 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 3955 |
pos2 := tokenPosition + tokenName size - 1. |
3956 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
663 | 3957 |
var := Variable name:tokenName. |
883 | 3958 |
|
663 | 3959 |
methodVars isNil ifTrue:[ |
3960 |
methodVars := OrderedCollection with:var. |
|
3961 |
methodVarNames := OrderedCollection with:tokenName |
|
3962 |
] ifFalse:[ |
|
3963 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 3964 |
"/ redefinition |
3965 |
self isSyntaxHighlighter ifTrue:[ |
|
3966 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3967 |
] ifFalse:[ |
|
3968 |
self |
|
3969 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3970 |
position:tokenPosition to:pos2. |
|
3971 |
] |
|
663 | 3972 |
] ifFalse:[ |
3973 |
methodVars add:var. |
|
3974 |
methodVarNames add:tokenName |
|
3975 |
] |
|
3976 |
]. |
|
883 | 3977 |
|
663 | 3978 |
methodArgNames notNil ifTrue:[ |
3979 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
883 | 3980 |
self |
3981 |
warning:'local variable ''' , tokenName , ''' hides argument.' |
|
3982 |
position:tokenPosition to:pos2 |
|
663 | 3983 |
] |
3984 |
]. |
|
3985 |
self nextToken. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3986 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3987 |
(tokenType == $() ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3988 |
self variableTypeDeclarationFor:var. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3989 |
]. |
663 | 3990 |
pos := tokenPosition |
3991 |
]. |
|
883 | 3992 |
|
663 | 3993 |
(tokenType ~~ $|) ifTrue:[ |
3994 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
883 | 3995 |
msg := 'Reserved keyword in local var declaration'. |
3996 |
pos2 := tokenPosition + tokenName size - 1. |
|
3997 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 3998 |
] ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3999 |
pos2 := source position1Based-1. |
663 | 4000 |
msg := 'Identifier or | expected in local var declaration' |
4001 |
]. |
|
883 | 4002 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 4003 |
^ #Error |
4004 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
4005 |
localVarDefPosition := Array with:localVarDefPosition with:tokenPosition. |
663 | 4006 |
self nextToken |
0 | 4007 |
]. |
984 | 4008 |
|
1363 | 4009 |
allowSqueakExtensions ifTrue:[ |
984 | 4010 |
"/ allow for primitiveSpec after local-var decl. |
4011 |
||
4012 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
|
4013 |
self parsePrimitiveOrResourceSpecOrEmpty. |
|
4014 |
] |
|
4015 |
]. |
|
4016 |
||
0 | 4017 |
^ nil |
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
4018 |
|
663 | 4019 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 4020 |
! |
4021 |
||
141 | 4022 |
parseMethodSpec |
4023 |
"parse a methods selector & arg specification; |
|
4024 |
Set selector and methodArgs in the receiver as a side effect. |
|
4025 |
Return the receiver or #Error. |
|
4026 |
||
4027 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4028 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4029 |
| IDENTIFIER |
141 | 4030 |
" |
4031 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4032 |
|arg pos2| |
141 | 4033 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4034 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4035 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4036 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4037 |
|
141 | 4038 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4039 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4040 |
[tokenType == #Keyword] whileTrue:[ |
663 | 4041 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4042 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4043 |
self nextToken. |
883 | 4044 |
|
1259 | 4045 |
(tokenType ~~ #Identifier) ifTrue:[ |
4046 |
"/ ^ #Error]. |
|
4047 |
^ self identifierExpectedIn:'method-arg declaration' |
|
4048 |
]. |
|
4049 |
||
883 | 4050 |
pos2 := tokenPosition+tokenName size-1. |
4051 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4052 |
arg := Variable name:tokenName. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4053 |
methodArgs isNil ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4054 |
methodArgs := Array with:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4055 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4056 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4057 |
(methodArgNames includes:tokenName) ifTrue:[ |
1259 | 4058 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4059 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4060 |
methodArgs := methodArgs copyWith:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4061 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4062 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4063 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4064 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4065 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4066 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4067 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4068 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4069 |
selector := selector asSymbol. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
4070 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4071 |
^ self |
141 | 4072 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4073 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4074 |
(self isValidUnarySelector:tokenType) ifTrue:[ |
663 | 4075 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4076 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4077 |
self nextToken. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
4078 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4079 |
^ self |
141 | 4080 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4081 |
|
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4082 |
"/ 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
|
4083 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4084 |
tokenType := #BinaryOperator. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4085 |
token := tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4086 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4087 |
|
141 | 4088 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 4089 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4090 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4091 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4092 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
663 | 4093 |
self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4094 |
arg := Variable name:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4095 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4096 |
methodArgs := Array with:arg. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4097 |
methodArgNames := Array with:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4098 |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4099 |
self nextToken. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4100 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4101 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4102 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4103 |
"/ ]. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
4104 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4105 |
^ self |
141 | 4106 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4107 |
|
1259 | 4108 |
^ self parseExtendedMethodSpec |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4109 |
|
663 | 4110 |
"Modified: / 31.3.1998 / 17:31:59 / cg" |
141 | 4111 |
! |
4112 |
||
713 | 4113 |
statement |
4114 |
"parse a statement; return a node-tree or #Error. |
|
4115 |
||
4116 |
statement ::= '^' expression |
|
4117 |
| PRIMITIVECODE |
|
4118 |
| expression |
|
4119 |
" |
|
4120 |
||
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4121 |
|expr node lnr code| |
713 | 4122 |
|
4123 |
(tokenType == $^) ifTrue:[ |
|
837 | 4124 |
self markReturnAt:tokenPosition. |
713 | 4125 |
lnr := tokenLineNr. |
4126 |
self nextToken. |
|
4127 |
expr := self expression. |
|
4128 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4129 |
node := ReturnNode expression:expr. |
|
4130 |
node home:self blockHome:currentBlock. |
|
4131 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4132 |
|
1231 | 4133 |
self rememberReturnedValue:expr. |
713 | 4134 |
^ node |
4135 |
]. |
|
4136 |
||
4137 |
(tokenType == #Primitive) ifTrue:[ |
|
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4138 |
code := tokenValue. |
713 | 4139 |
self nextToken. |
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4140 |
node := PrimitiveNode code:code. |
713 | 4141 |
node isOptional ifFalse:[ |
4142 |
hasNonOptionalPrimitiveCode := true |
|
4143 |
]. |
|
4144 |
hasPrimitiveCode := true. |
|
4145 |
^ node |
|
4146 |
]. |
|
4147 |
||
4148 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4149 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4150 |
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
|
4151 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4152 |
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
|
4153 |
]. |
713 | 4154 |
^ #Error |
4155 |
]. |
|
4156 |
||
984 | 4157 |
(tokenType == $.) ifTrue:[ |
1363 | 4158 |
allowSqueakExtensions == true ifTrue:[ |
984 | 4159 |
"/ allow empty statement |
4160 |
^ StatementNode expression:nil. |
|
4161 |
]. |
|
4162 |
]. |
|
4163 |
||
713 | 4164 |
expr := self expression. |
4165 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4166 |
||
4167 |
"/ classToCompileFor notNil ifTrue:[ |
|
4168 |
"/ currentBlock isNil ifTrue:[ |
|
4169 |
"/ expr isPrimary ifTrue:[ |
|
4170 |
"/ self warning:'useless computation - missing ^ ?' |
|
4171 |
"/ ] |
|
4172 |
"/ ] |
|
4173 |
"/ ]. |
|
4174 |
||
4175 |
node := StatementNode expression:expr. |
|
4176 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
4177 |
^ node |
|
4178 |
||
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4179 |
"Modified: / 17.11.2001 / 10:22:33 / cg" |
713 | 4180 |
! |
4181 |
||
4182 |
statementList |
|
4183 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
4184 |
Statements must be separated by periods. |
|
4185 |
||
4186 |
statementList ::= <statement> |
|
988 | 4187 |
| <statementList> . <statement> |
713 | 4188 |
" |
4189 |
||
4190 |
|thisStatement prevStatement firstStatement correctIt periodPos |
|
4191 |
prevExpr| |
|
4192 |
||
4193 |
thisStatement := self statement. |
|
4194 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4195 |
firstStatement := thisStatement. |
|
4196 |
[tokenType == $.] whileTrue:[ |
|
988 | 4197 |
prevExpr := thisStatement expression. |
4198 |
(prevExpr notNil |
|
4199 |
and:[prevExpr isMessage |
|
4200 |
and:[thisStatement isReturnNode not]]) ifTrue:[ |
|
4201 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
4202 |
self warning:'useless computation - mistyped assignment ?' |
|
4203 |
]. |
|
4204 |
]. |
|
4205 |
||
4206 |
periodPos := tokenPosition. |
|
4207 |
self nextToken. |
|
4208 |
(tokenType == $]) ifTrue:[ |
|
4209 |
currentBlock isNil ifTrue:[ |
|
4210 |
self parseError:'block nesting error'. |
|
4211 |
errorFlag := true |
|
713 | 4212 |
" |
988 | 4213 |
*** I had a warning here (since it was not defined |
4214 |
*** in the blue-book; but PD-code contains a lot of |
|
4215 |
*** code with periods at the end so that the warnings |
|
4216 |
*** became annoying |
|
4217 |
||
4218 |
] ifFalse:[ |
|
4219 |
self warning:'period after last statement' position:periodPos |
|
713 | 4220 |
" |
988 | 4221 |
]. |
4222 |
^ firstStatement |
|
4223 |
]. |
|
4224 |
(tokenType == #EOF) ifTrue:[ |
|
4225 |
currentBlock notNil ifTrue:[ |
|
4226 |
self parseError:'block nesting error (expected '']'')'. |
|
4227 |
errorFlag := true |
|
713 | 4228 |
" |
988 | 4229 |
*** I had a warning here (since it was not defined |
4230 |
*** in the blue-book; but PD-code contains a lot of |
|
4231 |
*** code with periods at the end so that the warnings |
|
4232 |
*** became annoying |
|
4233 |
||
4234 |
] ifFalse:[ |
|
4235 |
self warning:'period after last statement' position:periodPos |
|
713 | 4236 |
" |
988 | 4237 |
]. |
4238 |
^ firstStatement |
|
4239 |
]. |
|
4240 |
||
4241 |
prevStatement := thisStatement. |
|
4242 |
prevStatement isReturnNode ifTrue:[ |
|
4243 |
self warning:'statements after return' position:tokenPosition |
|
4244 |
]. |
|
713 | 4245 |
" |
988 | 4246 |
periodPos := tokenPosition. |
4247 |
self nextToken. |
|
713 | 4248 |
" |
4249 |
||
988 | 4250 |
((tokenType == $]) or:[tokenType == #EOF]) ifTrue:[ |
4251 |
(currentBlock isNil and:[tokenType == $]]) ifTrue:[ |
|
4252 |
self parseError:'block nesting error'. |
|
4253 |
errorFlag := true |
|
4254 |
] ifFalse:[ |
|
4255 |
correctIt := self correctableError:'period after last statement in block' |
|
4256 |
position:periodPos to:(periodPos + 1). |
|
4257 |
correctIt ifTrue:[ |
|
4258 |
(self correctByDeleting == #Error) ifTrue:[ |
|
4259 |
errorFlag := true |
|
4260 |
] |
|
4261 |
] |
|
4262 |
]. |
|
4263 |
^ firstStatement |
|
4264 |
]. |
|
4265 |
thisStatement := self statement. |
|
4266 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4267 |
prevStatement nextStatement:thisStatement |
|
713 | 4268 |
]. |
4269 |
^ firstStatement |
|
4270 |
||
4271 |
"Modified: 14.4.1997 / 20:46:46 / cg" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4272 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4273 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4274 |
variableTypeDeclarationFor:aVariable |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4275 |
|min max domain enumValues| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4276 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4277 |
(tokenType == $() ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4278 |
self syntaxError:'''('' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4279 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4280 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4281 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4282 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4283 |
(tokenType == #Integer) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4284 |
min := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4285 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4286 |
((tokenType == #BinaryOperator) and:[token = '%%']) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4287 |
self syntaxError:'''%%'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4288 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4289 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4290 |
(tokenType == #Integer) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4291 |
self syntaxError:'Integer (upper bound) expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4292 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4293 |
max := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4294 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4295 |
domain := IntegerDomain min:min max:max. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4296 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4297 |
((tokenType == #Identifier) and:[token first isUppercase]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4298 |
token = 'Bool' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4299 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4300 |
domain := BooleanDomain new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4301 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4302 |
token = 'Nat' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4303 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4304 |
domain := IntegerDomain min:0 max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4305 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4306 |
token = 'Int' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4307 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4308 |
domain := IntegerDomain min:(SmallInteger minVal) max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4309 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4310 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4311 |
((tokenType == #Symbol) or:[(tokenType == #Identifier)]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4312 |
enumValues := OrderedCollection new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4313 |
[((tokenType == #Symbol) or:[(tokenType == #Identifier)])] whileTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4314 |
enumValues add:token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4315 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4316 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4317 |
domain := EnumeratedDomain new values:enumValues. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4318 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4319 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4320 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4321 |
domain isNil ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4322 |
self syntaxError:'invalid domain' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4323 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4324 |
aVariable domain:domain. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4325 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4326 |
(tokenType == $)) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4327 |
self syntaxError:''')'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4328 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4329 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4330 |
self nextToken. |
713 | 4331 |
! ! |
4332 |
||
4333 |
!Parser methodsFor:'parsing-expressions'! |
|
4334 |
||
4335 |
array |
|
4336 |
|arr elements elem pos1| |
|
4337 |
||
4338 |
pos1 := tokenPosition. |
|
4339 |
elements := OrderedCollection new:20. |
|
4340 |
[tokenType ~~ $) ] whileTrue:[ |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4341 |
elem := self arrayConstant. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4342 |
|
1062 | 4343 |
"/ (elem == #Error) ifTrue:[ |
4344 |
"/ (tokenType == #EOF) ifTrue:[ |
|
4345 |
"/ self syntaxError:'unterminated array-constant; '')'' expected' |
|
4346 |
"/ position:pos1 to:tokenPosition |
|
4347 |
"/ ]. |
|
4348 |
"/ ^ #Error |
|
4349 |
"/ ]. |
|
713 | 4350 |
elem isSymbol ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4351 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
713 | 4352 |
]. |
4353 |
elements add:elem. |
|
4354 |
self nextToken |
|
4355 |
]. |
|
4356 |
arr := Array withAll:elements. |
|
4357 |
||
4358 |
(ArraysAreImmutable and:[ImmutableArray notNil]) ifTrue:[ |
|
4359 |
arr changeClassTo:ImmutableArray. |
|
4360 |
]. |
|
4361 |
^ arr |
|
4362 |
||
4363 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
4364 |
! |
|
4365 |
||
4366 |
arrayConstant |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4367 |
|val| |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4368 |
|
713 | 4369 |
(tokenType == #Nil) ifTrue:[ |
4370 |
^ nil |
|
4371 |
]. |
|
4372 |
((tokenType == #Integer) |
|
4373 |
or:[tokenType == #Float]) ifTrue:[ |
|
4374 |
^ tokenValue |
|
4375 |
]. |
|
4376 |
((tokenType == #String) |
|
4377 |
or:[tokenType == #Character]) ifTrue:[ |
|
4378 |
^ tokenValue |
|
4379 |
]. |
|
4380 |
(tokenType == #True) ifTrue:[ |
|
4381 |
^ true |
|
4382 |
]. |
|
4383 |
(tokenType == #False) ifTrue:[ |
|
4384 |
^ false |
|
4385 |
]. |
|
4386 |
(tokenType == #Error) ifTrue:[ |
|
1062 | 4387 |
^ ParseErrorSignal raise. |
713 | 4388 |
]. |
4389 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
4390 |
^ tokenName asSymbol |
|
4391 |
]. |
|
4392 |
||
4393 |
"/ some more special symbol consts ... |
|
4394 |
(tokenType == $| ) ifTrue:[ |
|
4395 |
^ #| |
|
4396 |
]. |
|
4397 |
(tokenType == #Self ) ifTrue:[ |
|
4398 |
^ #'self' |
|
4399 |
]. |
|
4400 |
(tokenType == #Super ) ifTrue:[ |
|
4401 |
^ #'super' |
|
4402 |
]. |
|
4403 |
(tokenType == #Here ) ifTrue:[ |
|
4404 |
^ #'here' |
|
4405 |
]. |
|
4406 |
(tokenType == #ThisContext ) ifTrue:[ |
|
4407 |
^ #'thisContext' |
|
4408 |
]. |
|
4409 |
||
4410 |
((tokenType == #Keyword) |
|
4411 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
4412 |
^ tokenName asSymbol |
|
4413 |
]. |
|
4414 |
((tokenType == $() |
|
4415 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
4416 |
self nextToken. |
|
4417 |
^ self array |
|
4418 |
]. |
|
4419 |
((tokenType == $[) |
|
4420 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
4421 |
self nextToken. |
|
4422 |
^ self byteArray |
|
4423 |
]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4424 |
(tokenType == #HashLeftBrace) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4425 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4426 |
val := QualifiedName for:val name. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4427 |
^ val |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4428 |
]. |
713 | 4429 |
(tokenType == #Symbol) ifTrue:[ |
1066
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4430 |
parseForCode ifFalse:[ |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4431 |
self rememberSymbolUsed:tokenValue. |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4432 |
]. |
713 | 4433 |
^ tokenValue |
4434 |
]. |
|
4435 |
(tokenType == #EOF) ifTrue:[ |
|
4436 |
"just for the better error-hilight; let caller handle error" |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4437 |
self syntaxError:'error in array-constant; EOF unexpected'. |
1062 | 4438 |
^ ParseErrorSignal raise. |
713 | 4439 |
]. |
4440 |
self syntaxError:('error in array-constant; ' |
|
4441 |
, tokenType printString |
|
4442 |
, ' unexpected'). |
|
1062 | 4443 |
^ ParseErrorSignal raise. |
713 | 4444 |
|
4445 |
"Modified: / 14.4.1998 / 18:22:54 / cg" |
|
4446 |
! |
|
4447 |
||
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4448 |
arrayIndexingExpression |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4449 |
"parse an array index expression; this is a squeak/stx extension. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4450 |
foo[idx] is syntactic sugar for foo matrixAt:x |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4451 |
and foo[idx] := expr is syntactic sugar for foo matrixAt:x put:expr" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4452 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4453 |
|receiver argList selectorStream valNode| |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4454 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4455 |
receiver := self functionCallExpression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4456 |
tokenType == $[ ifFalse:[^ receiver]. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4457 |
AllowArrayIndexSyntaxExtension == true ifFalse:[^ receiver.]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4458 |
(receiver == #Error) ifTrue:[^ #Error]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4459 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4460 |
selectorStream := WriteStream on: (String new: 32). |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4461 |
argList := OrderedCollection new. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4462 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4463 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4464 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4465 |
|indexNode| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4466 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4467 |
self nextToken. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4468 |
indexNode := self primary. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4469 |
argList isEmpty ifTrue:[selectorStream nextPutAll:'_']. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4470 |
selectorStream nextPutAll:'at:'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4471 |
argList add: indexNode. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4472 |
(tokenType == #BinaryOperator ) and:[ token = ','] |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4473 |
] whileTrue. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4474 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4475 |
tokenType == $] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4476 |
self parseError:''']'' expected'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4477 |
^ #Error |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4478 |
]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4479 |
self nextToken. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4480 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4481 |
tokenType == $[ ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4482 |
receiver := MessageNode |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4483 |
receiver:receiver |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4484 |
selector:(selectorStream contents) |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4485 |
args:argList. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4486 |
selectorStream := WriteStream on: (String new: 32). |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4487 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4488 |
tokenType == $[ |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4489 |
] whileTrue. |
1411 | 4490 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4491 |
tokenType == #':=' ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4492 |
self nextToken. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4493 |
selectorStream nextPutAll:'put:'. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4494 |
valNode := self expression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4495 |
valNode == #Error ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4496 |
^ valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4497 |
]. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4498 |
"/ this was found in squeak - why make it a block ? |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4499 |
"/ (valNode isKindOf: BlockNode) ifFalse:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4500 |
"/ valNode _ BlockNode new |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4501 |
"/ arguments: #() |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4502 |
"/ statements: (OrderedCollection with: valNode) |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4503 |
"/ returns: false |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4504 |
"/ from: encoder. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4505 |
"/ ]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4506 |
argList add: valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4507 |
]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4508 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4509 |
^ MessageNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4510 |
receiver:receiver |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4511 |
selector:selectorStream contents |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4512 |
args:argList. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4513 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4514 |
" |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4515 |
AllowArrayIndexSyntaxExtension := true. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4516 |
AllowArrayIndexSyntaxExtension := false. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4517 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4518 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4519 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4520 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4521 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4522 |
foo := Array new:10 withAll:2. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4523 |
1 + foo[1]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4524 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4525 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4526 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4527 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4528 |
foo := Array new:10. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4529 |
foo[1] := 'hello'. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4530 |
foo[2]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4531 |
foo[1]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4532 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4533 |
! |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4534 |
|
713 | 4535 |
binaryExpression |
4536 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4537 |
||
1328 | 4538 |
|receiver| |
713 | 4539 |
|
4540 |
receiver := self unaryExpression. |
|
4541 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 4542 |
^ self binaryExpressionFor:receiver |
4543 |
! |
|
4544 |
||
4545 |
binaryExpressionFor:receiverArg |
|
4546 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4547 |
||
4548 |
|receiver theReceiver arg sel pos try lno note| |
|
4549 |
||
4550 |
receiver := receiverArg. |
|
4551 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
713 | 4552 |
|
4553 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
4554 |
expression or a negative constant, handle cases here" |
|
4555 |
||
4556 |
[(tokenType == #BinaryOperator) |
|
4557 |
or:[(tokenType == $|) |
|
4558 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
4559 |
and:[tokenValue < 0]]] |
|
4560 |
] whileTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4561 |
"/ kludge alarm: in a function-call argList, #, is not a binarySelector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4562 |
inFunctionCallArgument == true ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4563 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4564 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4565 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4566 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4567 |
|
713 | 4568 |
pos := tokenPosition. |
4569 |
lno := tokenLineNr. |
|
4570 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4571 |
"/ kludge alarm: bar and minus are not scanned as binop |
713 | 4572 |
(tokenType == $|) ifTrue:[ |
4573 |
sel := '|'. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4574 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:tokenPosition. |
713 | 4575 |
self nextToken |
4576 |
] ifFalse:[ |
|
4577 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4578 |
sel := tokenName. |
1022 | 4579 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
713 | 4580 |
self nextToken |
4581 |
] ifFalse:[ |
|
4582 |
sel := '-'. |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4583 |
token := tokenValue := tokenValue negated |
713 | 4584 |
] |
4585 |
]. |
|
864 | 4586 |
self markSelector:sel from:pos to:(pos + sel size - 1) receiverNode:receiver. |
713 | 4587 |
|
4588 |
arg := self unaryExpression. |
|
4589 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1061 | 4590 |
theReceiver := receiver. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4591 |
|
713 | 4592 |
try := BinaryNode receiver:receiver selector:sel arg:arg fold:foldConstants. |
4593 |
(try isMemberOf:String) ifTrue:[ |
|
4594 |
self parseError:try position:pos to:tokenPosition. |
|
4595 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
4596 |
receiver := BinaryNode receiver:receiver selector:sel arg:arg fold:nil. |
|
4597 |
] ifFalse:[ |
|
4598 |
receiver := try |
|
4599 |
]. |
|
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4600 |
note := self plausibilityCheck:receiver. |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4601 |
note notNil ifTrue:[ |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4602 |
self warning:note position:pos to:tokenPosition |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4603 |
]. |
713 | 4604 |
receiver lineNumber:lno. |
4605 |
receiver selectorPosition:pos. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4606 |
parseForCode ifFalse:[ |
1061 | 4607 |
self rememberSelectorUsed:sel receiver:theReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4608 |
]. |
713 | 4609 |
]. |
4610 |
^ receiver |
|
4611 |
||
4612 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
1022 | 4613 |
"Modified: / 19.1.2000 / 16:22:04 / cg" |
713 | 4614 |
! |
4615 |
||
4616 |
byteArray |
|
4617 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
4618 |
||
4619 |
|bytes index limit newArray elem pos1 pos2| |
|
4620 |
||
4621 |
pos1 := tokenPosition. |
|
4622 |
bytes := ByteArray uninitializedNew:5000. |
|
4623 |
index := 0. limit := 5000. |
|
4624 |
[tokenType ~~ $] ] whileTrue:[ |
|
4625 |
pos2 := tokenPosition. |
|
4626 |
" |
|
4627 |
this is not good programming style, but speeds up |
|
4628 |
reading of huge byte arrays (i.e. stored Images ...) |
|
4629 |
" |
|
4630 |
(tokenType == #Integer) ifTrue:[ |
|
4631 |
elem := tokenValue |
|
4632 |
] ifFalse:[ |
|
4633 |
elem := self arrayConstant. |
|
4634 |
(elem == #Error) ifTrue:[ |
|
4635 |
(tokenType == #EOF) ifTrue:[ |
|
4636 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
4637 |
position:pos1 to:tokenPosition |
|
4638 |
]. |
|
4639 |
^ #Error |
|
4640 |
]. |
|
4641 |
]. |
|
4642 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
4643 |
index := index + 1. |
|
4644 |
bytes at:index put:elem. |
|
4645 |
index == limit ifTrue:[ |
|
4646 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
4647 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
4648 |
limit := limit * 2. |
|
4649 |
bytes := newArray |
|
4650 |
]. |
|
4651 |
] ifFalse:[ |
|
4652 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
4653 |
]. |
|
4654 |
self nextToken. |
|
4655 |
]. |
|
4656 |
newArray := ByteArray uninitializedNew:index. |
|
4657 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
4658 |
^ newArray |
|
4659 |
! |
|
4660 |
||
4661 |
degeneratedKeywordExpressionForSelector |
|
1406 | 4662 |
"parse a keyword-expression without receiver - for the selector only. |
4663 |
Return the selector or nil (if it cannot be determined). |
|
4664 |
This is not used in normal parsing, but instead to extract the selector from a code fragment. |
|
4665 |
(for example, the system browsers 'implementors'-function uses this to extract a selector from |
|
4666 |
the selection)" |
|
713 | 4667 |
|
4668 |
|sel arg rec| |
|
4669 |
||
4670 |
(tokenType == #Keyword) ifTrue:[ |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4671 |
sel := tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4672 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4673 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4674 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4675 |
[tokenType == #Keyword] whileTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4676 |
sel := sel , tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4677 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4678 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4679 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4680 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4681 |
^ sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4682 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4683 |
|
1406 | 4684 |
(rec := self arrayIndexingExpression) == #Error ifTrue:[ ^ nil]. |
4685 |
sel := self degeneratedKeywordExpressionForSelector. |
|
4686 |
sel notNil ifTrue:[ ^ sel]. |
|
4687 |
||
1407 | 4688 |
rec isAssignment ifTrue:[ |
4689 |
rec := rec expression |
|
4690 |
]. |
|
1406 | 4691 |
rec isMessage ifTrue:[ |
4692 |
^ rec selector |
|
4693 |
]. |
|
4694 |
^ nil |
|
713 | 4695 |
! |
4696 |
||
4697 |
expression |
|
4698 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
4699 |
||
4700 |
expression ::= keywordExpression |
|
4701 |
| keywordExpression cascade |
|
4702 |
||
4703 |
cascade ::= ';' expressionSendPart |
|
4704 |
| cascade ';' expressionSendPart |
|
4705 |
||
4706 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
4707 |
| BINARYOPERATOR unaryExpression |
|
4708 |
| IDENTIFIER |
|
4709 |
" |
|
4710 |
||
864 | 4711 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 4712 |
|
4713 |
pos := tokenPosition. |
|
4714 |
receiver := self keywordExpression. |
|
4715 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
4716 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4717 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4718 |
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
|
4719 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4720 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4721 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4722 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4723 |
]. |
713 | 4724 |
[tokenType == $;] whileTrue:[ |
4725 |
self nextToken. |
|
4726 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4727 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4728 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4729 |
sel := tokenName. |
1022 | 4730 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 4731 |
receiver := CascadeNode receiver:receiver selector:sel. |
4732 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4733 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4734 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4735 |
]. |
713 | 4736 |
self nextToken. |
4737 |
] ifFalse:[ |
|
4738 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4739 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4740 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4741 |
sel := tokenName. |
1022 | 4742 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 4743 |
lno := tokenLineNr. |
4744 |
self nextToken. |
|
4745 |
arg := self unaryExpression. |
|
4746 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4747 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
4748 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4749 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4750 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4751 |
]. |
713 | 4752 |
] ifFalse:[ |
4753 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4754 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4755 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4756 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4757 |
pos2 := tokenEnd. |
713 | 4758 |
lno := tokenLineNr. |
4759 |
sel := tokenName. |
|
4760 |
self nextToken. |
|
4761 |
arg := self binaryExpression. |
|
4762 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4763 |
args := Array with:arg. |
|
4764 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4765 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4766 |
positions add:(tokenPosition to:tokenEnd). |
713 | 4767 |
sel := sel , tokenName. |
4768 |
self nextToken. |
|
4769 |
arg := self binaryExpression. |
|
4770 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4771 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4772 |
pos2 := tokenEnd |
713 | 4773 |
]. |
1022 | 4774 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
864 | 4775 |
|
4776 |
positions do:[:p | |
|
4777 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
4778 |
]. |
|
713 | 4779 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
4780 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4781 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4782 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4783 |
]. |
713 | 4784 |
] ifFalse:[ |
4785 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
4786 |
self syntaxError:('invalid cascade; ' , tokenType printString , ' unexpected') |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4787 |
position:tokenPosition to:source position1Based - 1. |
713 | 4788 |
^ #Error |
4789 |
] |
|
4790 |
] |
|
4791 |
] |
|
4792 |
]. |
|
4793 |
||
4794 |
"obscure (unspecified ?) if selector follows; Question: |
|
4795 |
||
4796 |
is |
|
4797 |
'expr sel1; sel2 sel3' |
|
4798 |
||
4799 |
to be parsed as: |
|
4800 |
(t := expr. |
|
4801 |
t sel1. |
|
4802 |
t sel2) sel3 |
|
4803 |
||
4804 |
or: |
|
4805 |
(t := expr. |
|
4806 |
t sel1. |
|
4807 |
t sel2 sel3) |
|
4808 |
" |
|
4809 |
((tokenType == #Identifier) |
|
4810 |
or:[(tokenType == #BinaryOperator) |
|
4811 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
1328 | 4812 |
self syntaxError:'ambigous cascade - please group using (...)' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4813 |
position:tokenPosition to:source position1Based - 1. |
713 | 4814 |
^ #Error |
1328 | 4815 |
"/ self warning: "syntaxError:" 'possibly ambigous cascade - please group using (...)' |
4816 |
"/ position:tokenPosition to:source position - 1. |
|
4817 |
"/ tokenType == #Identifier ifTrue:[ |
|
4818 |
"/ ^ self unaryExpressionFor:receiver |
|
4819 |
"/ ]. |
|
4820 |
"/ tokenType == #BinaryOperator ifTrue:[ |
|
4821 |
"/ ^ self binaryExpressionFor:receiver |
|
4822 |
"/ ]. |
|
4823 |
"/ ^ self keywordExpressionFor:receiver |
|
713 | 4824 |
] |
4825 |
]. |
|
4826 |
^ receiver |
|
4827 |
||
1022 | 4828 |
"Modified: / 19.1.2000 / 16:22:16 / cg" |
713 | 4829 |
! |
4830 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4831 |
functionCallArgList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4832 |
|argList arg prevInFunctionCallArgument| |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4833 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4834 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4835 |
tokenType == $) ifTrue:[ self nextToken. ^ #() ]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4836 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4837 |
argList := OrderedCollection new. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4838 |
[ true ] whileTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4839 |
prevInFunctionCallArgument := inFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4840 |
inFunctionCallArgument := true. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4841 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4842 |
arg := self expression. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4843 |
argList add:arg. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4844 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4845 |
inFunctionCallArgument := prevInFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4846 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4847 |
tokenType == $) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4848 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4849 |
^ argList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4850 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4851 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4852 |
self parseError:'"," or ")" expected'. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4853 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4854 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4855 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4856 |
! |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4857 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4858 |
functionCallExpression |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4859 |
"parse a functionCall; this is an st/x extension. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4860 |
foo(x) is syntactic sugar for foo value:x" |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4861 |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
4862 |
|receiver numArgs argList evalSelectors evalSelector| |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4863 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4864 |
receiver := self primary. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4865 |
tokenType == $( ifFalse:[^ receiver]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4866 |
AllowFunctionCallSyntaxForBlockEvaluation == true ifFalse:[^ receiver.]. |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4867 |
(receiver == #Error) ifTrue:[^ #Error]. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4868 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4869 |
receiver isVariable ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4870 |
((receiver isMessage or:[receiver isAssignment]) and:[receiver parenthized]) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4871 |
receiver isBlock ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4872 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4873 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4874 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4875 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4876 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4877 |
argList := self functionCallArgList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4878 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4879 |
"/ make it a block evaluation |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4880 |
numArgs := argList size. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4881 |
numArgs == 0 ifTrue:[ |
1341 | 4882 |
^ UnaryNode receiver:receiver selector:#value |
4883 |
]. |
|
4884 |
evalSelectors := #( #'value:' |
|
4885 |
#'value:value:' |
|
4886 |
#'value:value:value:' |
|
4887 |
#'value:value:value:value:' |
|
4888 |
#'value:value:value:value:value:' |
|
4889 |
#'value:value:value:value:value:value:' |
|
4890 |
#'value:value:value:value:value:value:value:' |
|
4891 |
#'value:value:value:value:value:value:value:value:' |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4892 |
). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4893 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4894 |
numArgs <= evalSelectors size ifTrue:[ |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
4895 |
evalSelector := evalSelectors at:numArgs. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4896 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4897 |
receiver:receiver |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
4898 |
selector:evalSelector |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4899 |
args:argList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4900 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4901 |
"/ gen argument vector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4902 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4903 |
receiver:receiver |
1341 | 4904 |
selector:#valueWithArguments: |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4905 |
args:(self genMakeArrayWith:argList). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4906 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4907 |
" |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4908 |
AllowFunctionCallSyntaxForBlockEvaluation := true. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4909 |
" |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4910 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4911 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4912 |
|foo| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4913 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4914 |
foo := [:x | x + 1]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4915 |
1 + foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4916 |
foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4917 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4918 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4919 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4920 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4921 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4922 |
add1 := addN(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4923 |
add1(10). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4924 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4925 |
"AllowFunctionCallSyntaxForBlockEvaluation := false." |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4926 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4927 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4928 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4929 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4930 |
add1 := addN value:1. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4931 |
add1 value:10 |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4932 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4933 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4934 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4935 |
genMakeArrayWith:elementExpressions |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4936 |
"return a node to generate an array at runtime. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4937 |
Will generate: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4938 |
Array with:el1 ... with:elN (if N <= 5) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4939 |
or: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4940 |
(Array new at:1 put:el1; ... at:N put:elN; yourself) (otherwise) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4941 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4942 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4943 |
|numEl arrRec sel expr| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4944 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4945 |
arrRec := VariableNode globalNamed:#Array. |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4946 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4947 |
numEl := elementExpressions size. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4948 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4949 |
(numEl between:1 and:8) ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4950 |
sel := #( |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4951 |
#'with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4952 |
#'with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4953 |
#'with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4954 |
#'with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4955 |
#'with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4956 |
#'with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4957 |
#'with:with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
4958 |
#'with:with:with:with:with:with:with:with:' |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4959 |
) at:numEl. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4960 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4961 |
^ MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4962 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4963 |
selector:sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4964 |
args:elementExpressions. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4965 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4966 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4967 |
"/ array creation expression ... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4968 |
expr := MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4969 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4970 |
selector:#new: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4971 |
arg:(ConstantNode type:#Integer value:numEl). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4972 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4973 |
numEl == 0 ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4974 |
^ expr. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4975 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4976 |
"/ followed by a bunch of #at:put: messages... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4977 |
elementExpressions keysAndValuesDo:[:idx :e | |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4978 |
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4979 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4980 |
selector:#at:put: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4981 |
arg1:(ConstantNode type:#Integer value:idx) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4982 |
arg2:e |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4983 |
fold:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4984 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4985 |
"/ followed by a #yourself: message... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4986 |
expr := CascadeNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4987 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4988 |
selector:#yourself. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4989 |
^ expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4990 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
4991 |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4992 |
isValidUnarySelector:tokenType |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4993 |
tokenType == #Identifier ifTrue:[^true]. |
1373 | 4994 |
tokenType == #Here ifTrue:[^true]. |
4995 |
||
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4996 |
AllowReservedWordsAsSelectors == true ifTrue:[ |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4997 |
tokenType == #Self ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4998 |
tokenType == #Nil ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4999 |
tokenType == #True ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5000 |
tokenType == #False ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5001 |
tokenType == #Super ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5002 |
tokenType == #ThisContext ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5003 |
]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5004 |
^ false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5005 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5006 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5007 |
AllowReservedWordsAsSelectors := true |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5008 |
AllowReservedWordsAsSelectors := false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5009 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5010 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5011 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5012 |
1234 self |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5013 |
1234 nil |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5014 |
1234 true |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5015 |
1234 false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5016 |
1234 here |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5017 |
1234 super |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5018 |
1234 thisContext |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5019 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5020 |
! |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5021 |
|
713 | 5022 |
keywordExpression |
5023 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5024 |
||
5025 |
keywordExpression ::= binaryexpression |
|
5026 |
| { KEYWORD-PART binaryExpression } |
|
5027 |
" |
|
5028 |
||
1328 | 5029 |
|receiver| |
5030 |
||
713 | 5031 |
receiver := self binaryExpression. |
5032 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 5033 |
^ self keywordExpressionFor:receiver |
5034 |
! |
|
5035 |
||
5036 |
keywordExpressionFor:receiverArg |
|
5037 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5038 |
||
5039 |
keywordExpression ::= binaryexpression |
|
5040 |
| { KEYWORD-PART binaryExpression } |
|
5041 |
" |
|
5042 |
||
5043 |
|lastReceiver receiver sel arg args posR1 posR2 pos1 pos2 try lno note positions| |
|
5044 |
||
5045 |
receiver := receiverArg. |
|
5046 |
posR1 := tokenPosition. |
|
713 | 5047 |
(tokenType == #Keyword) ifTrue:[ |
5048 |
pos1 := posR2 := tokenPosition. |
|
5049 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 5050 |
positions := OrderedCollection with:(pos1 to:pos2). |
713 | 5051 |
sel := tokenName. |
5052 |
lno := tokenLineNr. |
|
5053 |
self nextToken. |
|
5054 |
arg := self binaryExpression. |
|
5055 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5056 |
args := Array with:arg. |
|
5057 |
[tokenType == #Keyword] whileTrue:[ |
|
5058 |
sel := sel , tokenName. |
|
5059 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 5060 |
positions add:(tokenPosition to:pos2). |
713 | 5061 |
self nextToken. |
5062 |
arg := self binaryExpression. |
|
5063 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5064 |
args := args copyWith:arg. |
|
5065 |
]. |
|
864 | 5066 |
|
5067 |
positions do:[:p | |
|
5068 |
self markSelector:sel from:p start to:p stop receiverNode:receiver. |
|
5069 |
]. |
|
1022 | 5070 |
sel := self selectorCheck:sel for:receiver position:pos1 to:pos2. |
864 | 5071 |
|
1149 | 5072 |
ignoreErrors ifFalse:[ |
5073 |
(Class definitionSelectors includes:sel) ifTrue:[ |
|
5074 |
receiver isVariable ifTrue:[ |
|
5075 |
receiver isUndeclared ifTrue:[ |
|
5076 |
self parseError:('undefined superclass: ' , receiver name) position:pos1 to:pos2. |
|
5077 |
]. |
|
5078 |
] |
|
5079 |
]. |
|
964
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
5080 |
]. |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
5081 |
|
1065 | 5082 |
lastReceiver := receiver. |
713 | 5083 |
try := MessageNode receiver:receiver selector:sel args:args fold:foldConstants. |
5084 |
(try isMemberOf:String) ifTrue:[ |
|
5085 |
self parseError:try position:pos1 to:pos2. |
|
5086 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
5087 |
receiver := MessageNode receiver:receiver selector:sel args:args fold:nil. |
|
5088 |
] ifFalse:[ |
|
5089 |
receiver := try |
|
5090 |
]. |
|
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5091 |
note := self plausibilityCheck:receiver. |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5092 |
note notNil ifTrue:[ |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5093 |
self warning:note position:pos1 to:pos2 |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5094 |
]. |
713 | 5095 |
receiver lineNumber:lno. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5096 |
parseForCode ifFalse:[ |
1065 | 5097 |
self rememberSelectorUsed:sel receiver:lastReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5098 |
]. |
713 | 5099 |
|
1193 | 5100 |
"/ (contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
5101 |
"/ receiver isSuper ifTrue:[ |
|
5102 |
"/ sel ~= selector ifTrue:[ |
|
5103 |
"/ self warnCommonMistake:'possible bad super message (selector should be same as in current method) ?' |
|
5104 |
"/ position:posR1 to:posR2-1 |
|
5105 |
"/ ]. |
|
5106 |
"/ ]. |
|
5107 |
"/ ]. |
|
5108 |
"/ |
|
5109 |
(sel = #and: or:[sel = #or:]) ifTrue:[ |
|
713 | 5110 |
receiver arg1 isBlock ifFalse:[ |
5111 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
5112 |
position:pos2+1 to:tokenPosition-1 |
|
5113 |
] |
|
5114 |
]. |
|
1193 | 5115 |
(sel = #whileTrue: or:[sel = #whileFalse:]) ifTrue:[ |
713 | 5116 |
receiver receiver isBlock ifFalse:[ |
5117 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
5118 |
position:posR1 to:posR2-1 |
|
5119 |
] |
|
5120 |
]. |
|
5121 |
]. |
|
5122 |
^ receiver |
|
5123 |
||
1022 | 5124 |
"Modified: / 19.1.2000 / 16:22:22 / cg" |
713 | 5125 |
! |
5126 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5127 |
nodeForMethodArg:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5128 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5129 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5130 |
methodArgNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5131 |
varIndex := methodArgNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5132 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5133 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5134 |
var := methodArgs at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5135 |
"/ var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5136 |
^ VariableNode type:#MethodArg |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5137 |
name:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5138 |
token:var |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5139 |
index:varIndex |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5140 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5141 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5142 |
nodeForMethodVariable:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5143 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5144 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5145 |
methodVarNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5146 |
varIndex := methodVarNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5147 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5148 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5149 |
var := methodVars at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5150 |
var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5151 |
parseForCode ifFalse:[self rememberLocalUsed:varName]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5152 |
^ VariableNode type:#MethodVariable |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5153 |
name:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5154 |
token:var |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5155 |
index:varIndex |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5156 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5157 |
|
0 | 5158 |
primary |
1028 | 5159 |
"parse a primary-expression; return a node-tree, nil or #Error. |
5160 |
This also cares for namespace-access-pathes." |
|
0 | 5161 |
|
1227 | 5162 |
|val pos node eMsg| |
924 | 5163 |
|
44 | 5164 |
(tokenType == #Self) ifTrue:[ |
1227 | 5165 |
^ self primary_self. |
5166 |
]. |
|
5167 |
||
5168 |
pos := tokenPosition. |
|
0 | 5169 |
(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
|
5170 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5171 |
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
|
5172 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5173 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5174 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5175 |
(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
|
5176 |
tokenType := #Here. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5177 |
warnSTXHereExtensionUsed ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5178 |
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
|
5179 |
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
|
5180 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5181 |
only warn once |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5182 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5183 |
warnSTXHereExtensionUsed := false |
663 | 5184 |
]. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5185 |
^ self primary_here. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5186 |
] |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5187 |
]. |
1227 | 5188 |
^ self primary_identifier |
0 | 5189 |
]. |
49 | 5190 |
|
44 | 5191 |
((tokenType == #Integer) |
120 | 5192 |
or:[(tokenType == #String) |
44 | 5193 |
or:[(tokenType == #Character) |
5194 |
or:[(tokenType == #Float) |
|
5195 |
or:[(tokenType == #Symbol)]]]]) ifTrue:[ |
|
1227 | 5196 |
^ self primary_simpleLiteral. |
0 | 5197 |
]. |
924 | 5198 |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5199 |
(tokenType == #FixedPoint) ifTrue:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5200 |
AllowFixedPointLiterals == true ifFalse:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5201 |
self parseError:'non-Standard literal: FixedPoint. Please enable in settings.' position:pos to:tokenPosition. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5202 |
^ #Error |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5203 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5204 |
^ self primary_simpleLiteral. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5205 |
]. |
0 | 5206 |
(tokenType == #Nil) ifTrue:[ |
1227 | 5207 |
^ self primary_nil. |
5208 |
]. |
|
0 | 5209 |
(tokenType == #True) ifTrue:[ |
1227 | 5210 |
^ self primary_true |
0 | 5211 |
]. |
5212 |
(tokenType == #False) ifTrue:[ |
|
1227 | 5213 |
^ self primary_false |
5214 |
]. |
|
0 | 5215 |
(tokenType == #Super) ifTrue:[ |
1227 | 5216 |
^ self primary_super. |
5217 |
]. |
|
924 | 5218 |
|
0 | 5219 |
(tokenType == #ThisContext) ifTrue:[ |
1262 | 5220 |
^ self primary_thisContext |
0 | 5221 |
]. |
924 | 5222 |
|
0 | 5223 |
(tokenType == #HashLeftParen) ifTrue:[ |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5224 |
self inArrayLiteral:true. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5225 |
self nextToken. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5226 |
ParseErrorSignal handle:[:ex | |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5227 |
self inArrayLiteral:false. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5228 |
^ #Error |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5229 |
] do:[ |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5230 |
val := self array. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5231 |
]. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5232 |
self inArrayLiteral:false. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5233 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5234 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5235 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5236 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5237 |
^ ConstantNode type:#Array value:val |
0 | 5238 |
]. |
924 | 5239 |
|
5240 |
(tokenType == #HashLeftBrace) ifTrue:[ |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5241 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5242 |
self nextToken. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5243 |
^ val. |
924 | 5244 |
]. |
5245 |
||
0 | 5246 |
(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
|
5247 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5248 |
val := self byteArray. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5249 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5250 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5251 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5252 |
]. |
924 | 5253 |
^ ConstantNode type:#ByteArray value:val |
0 | 5254 |
]. |
432 | 5255 |
|
0 | 5256 |
(tokenType == $() ifTrue:[ |
1227 | 5257 |
^ self primary_expression. |
0 | 5258 |
]. |
924 | 5259 |
|
0 | 5260 |
(tokenType == $[ ) ifTrue:[ |
673 | 5261 |
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
|
5262 |
val := self block. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5263 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5264 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5265 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5266 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5267 |
^ val |
0 | 5268 |
]. |
19 | 5269 |
|
1262 | 5270 |
"/ EXPERIMENTAL - may be in next release |
1295 | 5271 |
AllowVariableReferences == true ifTrue:[ |
5272 |
((tokenType == #BinaryOperator) and:[token = '&']) ifTrue:[ |
|
5273 |
self nextToken. |
|
5274 |
node := self primary_identifier. |
|
5275 |
"/ generate a Reference |
|
5276 |
^ self makeReferenceFor:node |
|
5277 |
]. |
|
5278 |
]. |
|
5279 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5280 |
(tokenType == ${ ) ifTrue:[ |
1363 | 5281 |
allowSqueakExtensions == true ifFalse:[ |
1335 | 5282 |
self parseError:'non-Standard Squeak extension: Brace Computed Array. Enable in settings.' position:pos to:tokenPosition. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5283 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5284 |
]. |
1227 | 5285 |
^ self primary_squeakComputedArray. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5286 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5287 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5288 |
(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
|
5289 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5290 |
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
|
5291 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5292 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5293 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5294 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5295 |
|
1227 | 5296 |
tokenType == #HashHashLeftParen ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5297 |
self halt. |
1295 | 5298 |
self nextToken. |
5299 |
AllowDolphinExtensions == true ifFalse:[ |
|
1335 | 5300 |
self parseError:'non-Standard Dolphin extension: ##(..). Enable in settings.' position:pos to:tokenPosition. |
1227 | 5301 |
^ #Error |
5302 |
]. |
|
5303 |
^ self primary_dolphinComputedLiteral. |
|
5304 |
]. |
|
1299 | 5305 |
tokenType == #ExclaLeftBrack ifTrue:[ |
1295 | 5306 |
self nextToken. |
5307 |
AllowLazyValueExtension == true ifFalse:[ |
|
1335 | 5308 |
self parseError:'non-Standard LazyValue extension. Enable in classVariable.' position:pos to:tokenPosition. |
1295 | 5309 |
^ #Error |
5310 |
]. |
|
5311 |
^ self primary_lazyValue. |
|
5312 |
]. |
|
5313 |
tokenType == #HashHash ifTrue:[ |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
5314 |
self warnPossibleIncompatibility:'''##'' might be interpreted differently in other smalltalk systems' position:pos to:tokenPosition. |
1295 | 5315 |
tokenType := #Symbol. |
5316 |
token := tokenValue := tokenName := '#'. |
|
5317 |
^ self primary_simpleLiteral. |
|
5318 |
]. |
|
1227 | 5319 |
|
0 | 5320 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 5321 |
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
|
5322 |
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
|
5323 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5324 |
' unexpected') position:tokenPosition to:tokenPosition |
0 | 5325 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5326 |
(#(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
|
5327 |
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
|
5328 |
, tokenType printString , '(' , tokenName , ') ' , |
805 | 5329 |
' 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
|
5330 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5331 |
eMsg := ('error in primary; ' |
1295 | 5332 |
, (token ? '') , ' (', tokenType printString , |
5333 |
') unexpected') |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5334 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5335 |
self syntaxError:eMsg position:tokenPosition to:source position1Based - 1 |
0 | 5336 |
]. |
5337 |
^ #Error |
|
120 | 5338 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5339 |
"Created: / 13.9.1995 / 12:50:50 / claus" |
1068 | 5340 |
"Modified: / 18.8.2000 / 20:51:22 / cg" |
0 | 5341 |
! |
5342 |
||
1227 | 5343 |
primary_dolphinComputedLiteral |
1273
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5344 |
"parse a dolphin computed literal; return a node-tree, or raise an Error. |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5345 |
In dolphin, these are written as: ##( expression ) |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5346 |
and create a literal constant for the expressions value. |
1274 | 5347 |
Right now, only a subset is supported - Strings, ByteArrays and Characters. |
5348 |
WARNING: this is only supported to allow filing in dolphin code. |
|
5349 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
5350 |
if you ever plan to stc-compile it into a shared library" |
|
1227 | 5351 |
|
5352 |
|pos expr val| |
|
5353 |
||
5354 |
pos := tokenPosition. |
|
5355 |
||
5356 |
expr := self expression. |
|
5357 |
||
5358 |
tokenType ~~ $) ifTrue:[ |
|
5359 |
self parseError:''')'' expected' position:tokenPosition. |
|
5360 |
^ #Error |
|
5361 |
]. |
|
5362 |
self nextToken. |
|
5363 |
||
5364 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5365 |
^ #Error |
|
5366 |
]. |
|
5367 |
||
5368 |
val := expr evaluate. |
|
5369 |
||
5370 |
val isLiteral ifTrue:[ |
|
1272
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5371 |
val isString ifTrue:[ |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5372 |
^ ConstantNode type:#String value:val |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5373 |
]. |
1227 | 5374 |
val isByteArray ifTrue:[ |
5375 |
^ ConstantNode type:#ByteArray value:val |
|
5376 |
]. |
|
1234 | 5377 |
val isCharacter ifTrue:[ |
5378 |
^ ConstantNode type:#Character value:val |
|
5379 |
]. |
|
1295 | 5380 |
val isInteger ifTrue:[ |
5381 |
^ ConstantNode type:#Integer value:val |
|
5382 |
]. |
|
1328 | 5383 |
val isLimitedPrecisionReal ifTrue:[ |
5384 |
^ ConstantNode type:#Float value:val |
|
5385 |
]. |
|
1295 | 5386 |
val isArray ifTrue:[ |
5387 |
^ ConstantNode type:#Array value:val |
|
5388 |
]. |
|
1227 | 5389 |
] ifFalse:[ |
5390 |
self parseError:'must be representable as a literal (for now)' position:pos. |
|
5391 |
^ #Error |
|
5392 |
]. |
|
1326 | 5393 |
self halt:'unimplemented'. |
1227 | 5394 |
"/ "/ make it an array creation expression ... |
5395 |
"/ expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5396 |
"/ receiver:(VariableNode globalNamed:#Array) |
1227 | 5397 |
"/ selector:#new: |
5398 |
"/ arg:(ConstantNode type:#Integer value:(exprList size)). |
|
5399 |
"/ |
|
5400 |
"/ exprList size == 0 ifTrue:[ |
|
5401 |
"/ ^ expr. |
|
5402 |
"/ ]. |
|
5403 |
"/ exprList keysAndValuesDo:[:idx :e | |
|
5404 |
"/ expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
|
5405 |
"/ receiver:expr |
|
5406 |
"/ selector:#at:put: |
|
5407 |
"/ arg1:(ConstantNode type:#Integer value:idx) |
|
5408 |
"/ arg2:e |
|
5409 |
"/ fold:false. |
|
5410 |
"/ ]. |
|
5411 |
"/ expr := CascadeNode |
|
5412 |
"/ receiver:expr |
|
5413 |
"/ selector:#yourself. |
|
5414 |
"/ ^ expr |
|
5415 |
! |
|
5416 |
||
5417 |
primary_expression |
|
5418 |
"parse a parentized expression primary; return a node-tree, or raise an Error." |
|
5419 |
||
5420 |
|pos val eMsg| |
|
5421 |
||
5422 |
pos := tokenPosition. |
|
5423 |
||
5424 |
self nextToken. |
|
5425 |
val := self expression. |
|
5426 |
(val == #Error) ifTrue:[^ #Error]. |
|
5427 |
(tokenType ~~ $) ) ifTrue:[ |
|
5428 |
tokenType isCharacter ifTrue:[ |
|
5429 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
|
5430 |
] ifFalse:[ |
|
5431 |
eMsg := 'missing '')'''. |
|
5432 |
]. |
|
5433 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
|
5434 |
^ #Error |
|
5435 |
]. |
|
5436 |
self nextToken. |
|
5437 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5438 |
^ #Error |
|
5439 |
]. |
|
5440 |
val parenthized:true. |
|
5441 |
^ val |
|
5442 |
! |
|
5443 |
||
5444 |
primary_false |
|
5445 |
"parse a false primary; return a node-tree, or raise an Error." |
|
5446 |
||
5447 |
|pos| |
|
5448 |
||
5449 |
pos := tokenPosition. |
|
5450 |
||
5451 |
self nextToken. |
|
5452 |
(self noAssignmentAllowed:'assignment to ''false''' at:pos) ifFalse:[ |
|
5453 |
^ #Error |
|
5454 |
]. |
|
5455 |
self markBooleanConstantFrom:pos to:pos+4. |
|
5456 |
^ ConstantNode type:#False value:false |
|
5457 |
! |
|
5458 |
||
5459 |
primary_here |
|
5460 |
"parse a here primary; return a node-tree, nil or #Error." |
|
5461 |
||
5462 |
|pos| |
|
5463 |
||
5464 |
pos := tokenPosition. |
|
5465 |
||
5466 |
self nextToken. |
|
5467 |
(self noAssignmentAllowed:'assignment to pseudo variable ''here''' at:pos) ifFalse:[ |
|
5468 |
^ #Error |
|
5469 |
]. |
|
5470 |
classToCompileFor isNil ifTrue:[ |
|
5471 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
|
5472 |
]. |
|
5473 |
self markSelfFrom:pos to:pos+3. |
|
5474 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
|
5475 |
! |
|
5476 |
||
5477 |
primary_identifier |
|
5478 |
"parse a false primary; return a node-tree, or raise an Error." |
|
5479 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5480 |
|pos1 pos2 expr varName rawName var globlName nameSpace nameSpaceGlobal |
1359 | 5481 |
t cls lnr node holder autoHow| |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5482 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5483 |
pos1 := tokenPosition. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5484 |
pos2 := tokenPosition + tokenName size - 1. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5485 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5486 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5487 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5488 |
((selector isNil or:[selector == #doIt]) |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5489 |
and:[currentBlock isNil |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5490 |
and:[(requestor askFor:#isWorkspace) |
1359 | 5491 |
and:[(autoHow := requestor autoDefineVariables) notNil]]]) ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5492 |
var := self variableOrError:varName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5493 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5494 |
(var == #Error) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5495 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
1359 | 5496 |
autoHow == #workspace ifTrue:[ |
5497 |
holder := Workspace addWorkspaceVariable:varName. |
|
5498 |
var := VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
5499 |
] ifFalse:[ |
|
5500 |
holder := self addDoItTemporary:varName. |
|
5501 |
var := VariableNode type:#DoItTemporary holder:holder name:varName |
|
5502 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5503 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5504 |
var := self correctVariable:varName atPosition:pos1 to:pos2. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5505 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5506 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5507 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5508 |
var := self variable. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5509 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5510 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5511 |
|
1227 | 5512 |
"/ errorFlag == true ifTrue:[self halt]. |
5513 |
(var == #Error) ifTrue:[ |
|
5514 |
errorFlag := true |
|
5515 |
]. |
|
5516 |
||
5517 |
(tokenType == #'::') ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5518 |
globlName := rawName := varName. |
1227 | 5519 |
|
5520 |
"is it in a namespace ?" |
|
5521 |
nameSpace := self findNameSpaceWith:globlName. |
|
5522 |
nameSpace notNil ifTrue:[ |
|
5523 |
globlName := nameSpace name , '::' , globlName |
|
5524 |
]. |
|
5525 |
||
5526 |
[tokenType == #'::'] whileTrue:[ |
|
5527 |
nameSpace := globlName. |
|
5528 |
||
5529 |
self nextToken. |
|
5530 |
(tokenType == #Identifier) ifTrue:[ |
|
5531 |
ignoreWarnings ifFalse:[ |
|
5532 |
warnSTXNameSpaceUse ifTrue:[ |
|
5533 |
self warning:'nameSpaces are a nonstandard feature of ST/X' |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5534 |
position:pos1 to:(source position1Based). |
1227 | 5535 |
" |
5536 |
only warn once |
|
5537 |
" |
|
5538 |
warnSTXNameSpaceUse := false |
|
5539 |
] |
|
5540 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5541 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5542 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5543 |
globlName := (nameSpace , '::' , varName). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5544 |
rawName := (rawName , '::' , varName). |
1227 | 5545 |
|
5546 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
|
5547 |
nameSpaceGlobal isNil ifTrue:[ |
|
5548 |
warnedUnknownNamespaces isNil ifTrue:[ |
|
5549 |
warnedUnknownNamespaces := Set new. |
|
5550 |
]. |
|
5551 |
(warnedUnknownNamespaces includes:nameSpace) ifFalse:[ |
|
5552 |
self warning:('unknown nameSpace: ', nameSpace) |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5553 |
position:pos1 to:tokenPosition-1. |
1227 | 5554 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
5555 |
warnedUnknownNamespaces add:nameSpace. |
|
5556 |
] |
|
5557 |
] ifFalse:[ |
|
5558 |
nameSpaceGlobal isNameSpace ifTrue:[ |
|
5559 |
"/ for now: only Smalltalk is allowed |
|
5560 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
|
5561 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
|
5562 |
] ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5563 |
globlName := varName |
1227 | 5564 |
]. |
5565 |
] ifFalse:[ |
|
5566 |
nameSpaceGlobal isBehavior ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5567 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos1 to:tokenPosition-1. |
1227 | 5568 |
] ifTrue:[ |
1391 | 5569 |
nameSpaceGlobal isLoaded ifTrue:[ |
5570 |
(nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[ |
|
5571 |
self warning:('no private class: ' , varName , ' in class: ' , nameSpace) |
|
5572 |
position:pos1 to:tokenPosition-1. |
|
5573 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
|
5574 |
] |
|
1227 | 5575 |
] |
5576 |
] |
|
5577 |
]. |
|
5578 |
]. |
|
5579 |
self nextToken. |
|
5580 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5581 |
var := VariableNode globalNamed:globlName. |
1227 | 5582 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
5583 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5584 |
self markVariable:var from:pos1 to:pos1 + rawName size - 1. |
1227 | 5585 |
]. |
5586 |
||
5587 |
var == #Error ifTrue:[ |
|
5588 |
^ #Error |
|
5589 |
]. |
|
5590 |
||
5591 |
errorFlag ~~ true ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5592 |
self markVariable:var from:pos1 to:pos1 + varName size - 1. |
1227 | 5593 |
]. |
5594 |
(ignoreErrors or:[ignoreWarnings or:[parseForCode not]]) ifTrue:[ |
|
5595 |
errorFlag := false. |
|
5596 |
]. |
|
5597 |
||
5598 |
((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[ |
|
5599 |
parseForCode ifFalse:[ |
|
5600 |
var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name]. |
|
5601 |
var isClassVariable ifTrue:[ self rememberClassVarRead:var name]. |
|
5602 |
]. |
|
5603 |
^ var |
|
5604 |
]. |
|
5605 |
||
5606 |
"/ careful: it could already be an implicit self send |
|
5607 |
ImplicitSelfSends ifTrue:[ |
|
5608 |
var isMessage ifTrue:[ |
|
5609 |
self nextToken. |
|
5610 |
expr := self expression. |
|
5611 |
self isSyntaxHighlighter ifFalse:[ |
|
5612 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
5613 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5614 |
^ MessageNode receiver:(self selfNode) selector:('__' , varName , ':') asSymbol arg:expr. |
1227 | 5615 |
]. |
5616 |
]. |
|
5617 |
||
5618 |
(var ~~ #Error) ifTrue:[ |
|
5619 |
t := var type. |
|
5620 |
(t ~~ #MethodVariable) ifTrue:[ |
|
5621 |
(t == #PrivateClass) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5622 |
self parseError:'assignment to private class' position:pos1 to:pos2. |
1227 | 5623 |
] ifFalse:[ |
5624 |
(t == #MethodArg) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5625 |
self parseError:'assignment to method argument' position:pos1 to:pos2. |
1227 | 5626 |
] ifFalse:[ |
5627 |
(t == #BlockArg) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5628 |
self parseError:'assignment to block argument' position:pos1 to:pos2. |
1227 | 5629 |
] ifFalse:[ |
5630 |
(t == #InstanceVariable) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5631 |
varName := self classesInstVarNames at:(var index). |
1227 | 5632 |
|
5633 |
"/ ca once did this to `name' and wondered what happened to his class ... |
|
5634 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
|
5635 |
"/ and is hard to track down later) |
|
5636 |
||
5637 |
warnCommonMistakes ifTrue:[ |
|
5638 |
classToCompileFor isMeta ifTrue:[ |
|
5639 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
|
5640 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5641 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of `Class'')' withCRs position:pos1 to:pos2. |
1227 | 5642 |
] |
5643 |
] |
|
5644 |
] |
|
5645 |
]. |
|
5646 |
parseForCode ifFalse:[ |
|
5647 |
modifiedInstVars isNil ifTrue:[ |
|
5648 |
modifiedInstVars := Set new |
|
5649 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5650 |
modifiedInstVars add:varName |
1227 | 5651 |
] |
5652 |
] ifFalse:[ |
|
5653 |
(t == #ClassVariable) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5654 |
varName := var name. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5655 |
varName := varName copyFrom:((varName indexOf:$:) + 1). |
1227 | 5656 |
parseForCode ifFalse:[ |
5657 |
modifiedClassVars isNil ifTrue:[ |
|
5658 |
modifiedClassVars := Set new |
|
5659 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5660 |
modifiedClassVars add:varName |
1227 | 5661 |
] |
5662 |
] ifFalse:[ |
|
5663 |
(t == #GlobalVariable) ifTrue:[ |
|
5664 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
|
5665 |
cls name = var name ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5666 |
self warning:'assignment to global which refers to a class' position:pos1 to:pos2. |
1227 | 5667 |
] |
5668 |
]. |
|
5669 |
parseForCode ifFalse:[ |
|
5670 |
modifiedGlobals isNil ifTrue:[ |
|
5671 |
modifiedGlobals := Set new |
|
5672 |
]. |
|
5673 |
modifiedGlobals add:var name |
|
5674 |
] |
|
5675 |
] |
|
5676 |
] |
|
5677 |
] |
|
5678 |
] |
|
5679 |
] |
|
5680 |
] |
|
5681 |
]. |
|
5682 |
t == #MethodVariable ifTrue:[ |
|
5683 |
modifiedLocalVars isNil ifTrue:[ |
|
5684 |
modifiedLocalVars := Set new. |
|
5685 |
]. |
|
5686 |
modifiedLocalVars add:var name. |
|
5687 |
]. |
|
5688 |
]. |
|
5689 |
||
5690 |
lnr := tokenLineNr. |
|
5691 |
||
5692 |
self nextToken. |
|
5693 |
pos2 := tokenPosition. |
|
5694 |
expr := self expression. |
|
5695 |
||
5696 |
"/ a typical beginner error: |
|
5697 |
"/ expr ifTrue:[ |
|
5698 |
"/ var := super |
|
5699 |
"/ ] ifFalse:[ |
|
5700 |
"/ var := something-else |
|
5701 |
"/ ]. |
|
5702 |
"/ var messageSend |
|
5703 |
"/ |
|
5704 |
"/ does not what a beginner might think. |
|
5705 |
||
5706 |
self isSyntaxHighlighter ifTrue:[ |
|
5707 |
(expr == #Error) ifTrue:[^ #Error]. |
|
5708 |
] ifFalse:[ |
|
5709 |
warnCommonMistakes ifTrue:[ |
|
5710 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5711 |
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:pos1 to:pos2. |
1227 | 5712 |
]. |
5713 |
]. |
|
5714 |
||
5715 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
5716 |
expr isVariable ifTrue:[ |
|
5717 |
expr name = var name ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5718 |
self warning:('useless assignment to `' , var name, '''' ) position:pos1 to:pos2-1. |
1227 | 5719 |
]. |
5720 |
]. |
|
5721 |
]. |
|
5722 |
||
5723 |
node := AssignmentNode variable:var expression:expr. |
|
5724 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
5725 |
^ node |
|
5726 |
! |
|
5727 |
||
1295 | 5728 |
primary_lazyValue |
5729 |
|pos block expr| |
|
5730 |
||
5731 |
pos := tokenPosition. |
|
5732 |
||
5733 |
(tokenType == $: ) ifTrue:[ |
|
5734 |
self parseError:'lazyValues have no arguments' position:tokenPosition. |
|
5735 |
^ #Error |
|
5736 |
]. |
|
5737 |
||
5738 |
block := self blockBody:#(). |
|
5739 |
self nextToken. |
|
5740 |
||
5741 |
expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5742 |
receiver:(VariableNode globalNamed:#LazyValue) |
1295 | 5743 |
selector:#'block:' |
5744 |
arg:block. |
|
5745 |
^ expr |
|
5746 |
! |
|
5747 |
||
1227 | 5748 |
primary_nil |
5749 |
"parse a nil primary; return a node-tree, nil or #Error." |
|
5750 |
||
5751 |
|pos| |
|
5752 |
||
5753 |
pos := tokenPosition. |
|
5754 |
||
5755 |
self nextToken. |
|
5756 |
(self noAssignmentAllowed:'assignment to ''nil''' at:pos) ifFalse:[ |
|
5757 |
^ #Error |
|
5758 |
]. |
|
5759 |
"/ self markConstantFrom:pos to:pos+2. |
|
5760 |
nilNode isNil ifTrue:[ |
|
5761 |
nilNode := ConstantNode type:#Nil value:nil |
|
5762 |
]. |
|
5763 |
^ nilNode |
|
5764 |
! |
|
5765 |
||
5766 |
primary_self |
|
5767 |
"parse a self primary; return a node-tree, nil or #Error." |
|
5768 |
||
5769 |
|pos| |
|
5770 |
||
5771 |
pos := tokenPosition. |
|
5772 |
||
5773 |
self nextToken. |
|
5774 |
(self noAssignmentAllowed:'assignment to pseudo variable ''self''' at:pos) ifFalse:[ |
|
5775 |
^ ParseError raise |
|
5776 |
]. |
|
5777 |
self markSelfFrom:pos to:pos+3. |
|
1262 | 5778 |
^ self selfNode |
1227 | 5779 |
! |
5780 |
||
5781 |
primary_simpleLiteral |
|
5782 |
"parse a simple literal primary; return a node-tree, or raise an Error." |
|
5783 |
||
5784 |
|pos val| |
|
5785 |
||
5786 |
pos := tokenPosition. |
|
5787 |
||
5788 |
"/ |
|
5789 |
"/ ImmutableStrings are experimental |
|
5790 |
"/ |
|
5791 |
((tokenType == #String) |
|
5792 |
and:[(StringsAreImmutable == true) |
|
5793 |
and:[ImmutableString notNil]]) ifTrue:[ |
|
5794 |
tokenValue := tokenValue copy. |
|
5795 |
tokenValue changeClassTo:ImmutableString. |
|
5796 |
token := tokenValue |
|
5797 |
]. |
|
5798 |
(tokenType == #Symbol) ifTrue:[ |
|
5799 |
parseForCode ifFalse:[ |
|
5800 |
self rememberSymbolUsed:tokenValue |
|
5801 |
]. |
|
5802 |
]. |
|
5803 |
val := ConstantNode type:tokenType value:tokenValue. |
|
5804 |
||
5805 |
tokenValue isSymbol ifTrue:[ |
|
5806 |
self markSymbolFrom:tokenPosition to:tokenPosition+tokenValue size-1. |
|
5807 |
]. |
|
5808 |
||
5809 |
self nextToken. |
|
5810 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
|
5811 |
^ #Error |
|
5812 |
]. |
|
5813 |
^ val |
|
5814 |
! |
|
5815 |
||
5816 |
primary_squeakComputedArray |
|
1274 | 5817 |
"parse a squeak computed array literal; return a node-tree, or raise an Error. |
5818 |
In squeak, these are written as: { expr1 . expr2 . ... exprN ) |
|
5819 |
and create a literalArray containing the exprI values. |
|
5820 |
WARNING: this is only supported to allow filing in squeak code. |
|
5821 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
5822 |
if you ever plan to stc-compile it into a shared library" |
|
5823 |
||
1227 | 5824 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5825 |
|pos exprList| |
1227 | 5826 |
|
5827 |
pos := tokenPosition. |
|
5828 |
||
5829 |
self nextToken. |
|
5830 |
exprList := self squeakComputedArray. |
|
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5831 |
(exprList == #Error) ifTrue:[ ^ #Error ]. |
1227 | 5832 |
|
5833 |
tokenType ~~ $} ifTrue:[ |
|
5834 |
self parseError:'''}'' expected' position:tokenPosition. |
|
5835 |
^ #Error |
|
5836 |
]. |
|
5837 |
self nextToken. |
|
5838 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5839 |
^ #Error |
|
5840 |
]. |
|
5841 |
||
5842 |
"/ make it an array creation expression ... |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5843 |
^ self genMakeArrayWith:exprList |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5844 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5845 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5846 |
Compiler allowSqueakExtensions:true. |
1299 | 5847 |
" |
5848 |
||
5849 |
" |
|
5850 |
{ 1@2. 10 factorial. Date today }. |
|
5851 |
" |
|
5852 |
||
5853 |
" |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5854 |
Compiler allowSqueakExtensions:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5855 |
" |
1227 | 5856 |
! |
5857 |
||
5858 |
primary_super |
|
5859 |
"parse a super primary; return a node-tree, nil or #Error." |
|
5860 |
||
5861 |
|pos| |
|
5862 |
||
5863 |
pos := tokenPosition. |
|
5864 |
||
5865 |
usesSuper := true. |
|
5866 |
self nextToken. |
|
5867 |
(self noAssignmentAllowed:'assignment to pseudo variable ''super''' at:pos) ifFalse:[ |
|
5868 |
^ #Error |
|
5869 |
]. |
|
5870 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
|
5871 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
|
5872 |
]. |
|
5873 |
superNode isNil ifTrue:[ |
|
5874 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
|
5875 |
]. |
|
5876 |
self markSelfFrom:pos to:pos+4. |
|
5877 |
^ superNode |
|
5878 |
! |
|
5879 |
||
1262 | 5880 |
primary_thisContext |
5881 |
"parse a thisContext primary; return a node-tree, or raise an Error." |
|
5882 |
||
5883 |
|pos| |
|
5884 |
||
5885 |
pos := tokenPosition. |
|
5886 |
||
5887 |
self nextToken. |
|
5888 |
(self noAssignmentAllowed:'assignment to pseudo variable ''thisContext''' at:pos) ifFalse:[ |
|
5889 |
^ #Error |
|
5890 |
]. |
|
5891 |
self markIdentifierFrom:pos to:pos+10. |
|
5892 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn. "/ often nil |
|
5893 |
! |
|
5894 |
||
1227 | 5895 |
primary_true |
5896 |
"parse a true primary; return a node-tree, or raise an Error." |
|
5897 |
||
5898 |
|pos| |
|
5899 |
||
5900 |
pos := tokenPosition. |
|
5901 |
||
5902 |
self nextToken. |
|
5903 |
(self noAssignmentAllowed:'assignment to ''true''' at:pos) ifFalse:[ |
|
5904 |
^ #Error |
|
5905 |
]. |
|
5906 |
self markBooleanConstantFrom:pos to:pos+3. |
|
5907 |
^ ConstantNode type:#True value:true |
|
5908 |
! |
|
5909 |
||
924 | 5910 |
qualifiedName |
5911 |
"a vw3.x (and later) feature: QualifiedName is #{ id ... id } |
|
5912 |
and mapped to a global variable here. |
|
5913 |
The initial #{ is supposed to be not yet skipped." |
|
5914 |
||
5915 |
|elements elem pos1| |
|
5916 |
||
5917 |
pos1 := tokenPosition. |
|
5918 |
self nextToken. |
|
5919 |
elements := OrderedCollection new. |
|
5920 |
[tokenType ~~ $} ] whileTrue:[ |
|
5921 |
elem := self variable. |
|
5922 |
(elem == #Error) ifTrue:[ |
|
5923 |
(tokenType == #EOF) ifTrue:[ |
|
5924 |
self syntaxError:'unterminated qualifiedName; ''}'' expected' |
|
5925 |
position:pos1 to:tokenPosition |
|
5926 |
]. |
|
5927 |
^ #Error |
|
5928 |
]. |
|
1100
2a5a68297030
dont set error flag, when not parsing for code and
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
5929 |
errorFlag := false. |
924 | 5930 |
(elem isVariable and:[elem isGlobal]) ifFalse:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5931 |
self warning:'elements of a qualifiedName should be globalIdentifiers' |
924 | 5932 |
position:pos1 to:tokenPosition |
5933 |
]. |
|
5934 |
elements add:elem. |
|
1028 | 5935 |
|
5936 |
self nextToken. |
|
5937 |
tokenType == #'::' ifTrue:[ |
|
5938 |
"/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
5939 |
"/(which is a kludge) |
|
5940 |
self nextToken. |
|
5941 |
] ifFalse:[ |
|
5942 |
tokenType ~~ $} ifTrue:[ |
|
5943 |
self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
|
5944 |
position:pos1 to:tokenPosition. |
|
5945 |
^ #Error |
|
5946 |
]. |
|
5947 |
]. |
|
924 | 5948 |
]. |
5949 |
||
5950 |
elements size > 1 ifTrue:[ |
|
1028 | 5951 |
self syntaxError:'Sorry: qualified names are not yet implemented.'. |
924 | 5952 |
]. |
5953 |
^ elements first. |
|
5954 |
||
5955 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
5956 |
! |
|
5957 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5958 |
squeakComputedArray |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5959 |
|expressions elem pos1| |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5960 |
|
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5961 |
tokenType == $} ifTrue:[ |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5962 |
^ #() |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5963 |
]. |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5964 |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5965 |
pos1 := tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5966 |
expressions := OrderedCollection new:20. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5967 |
[true] whileTrue:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5968 |
elem := self expression. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5969 |
(elem == #Error) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5970 |
(tokenType == #EOF) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5971 |
self syntaxError:'unterminated computed-array-element; ''}'' expected' |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5972 |
position:pos1 to:tokenPosition |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5973 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5974 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5975 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5976 |
expressions add:elem. |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5977 |
tokenType == $. ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5978 |
^ expressions |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5979 |
]. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5980 |
self nextToken. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5981 |
tokenType == $} ifTrue:[ |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5982 |
^ expressions |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
5983 |
]. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5984 |
]. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5985 |
"/ not reached |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5986 |
! |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5987 |
|
141 | 5988 |
unaryExpression |
5989 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
5990 |
||
1328 | 5991 |
|receiver| |
141 | 5992 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5993 |
receiver := self arrayIndexingExpression. |
141 | 5994 |
(receiver == #Error) ifTrue:[^ #Error]. |
1328 | 5995 |
^ self unaryExpressionFor:receiver |
5996 |
! |
|
5997 |
||
5998 |
unaryExpressionFor:receiverArg |
|
5999 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6000 |
||
6001 |
|receiver thisReceiver sel pos pos2 try note| |
|
6002 |
||
6003 |
receiver := receiverArg. |
|
6004 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
6005 |
[ self isValidUnarySelector:tokenType ] whileTrue:[ |
663 | 6006 |
pos := tokenPosition. |
6007 |
pos2 := pos + tokenName size - 1. |
|
864 | 6008 |
self markSelector:tokenName from:pos to:pos2 receiverNode:receiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
6009 |
sel := tokenName. |
1022 | 6010 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
1061 | 6011 |
thisReceiver := receiver. |
663 | 6012 |
try := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
6013 |
(try isMemberOf:String) ifTrue:[ |
|
6014 |
self parseError:try position:pos to:pos2. |
|
6015 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
6016 |
receiver := UnaryNode receiver:receiver selector:sel fold:nil. |
|
6017 |
] ifFalse:[ |
|
6018 |
receiver := try |
|
6019 |
]. |
|
1193 | 6020 |
note := self plausibilityCheck:receiver. |
6021 |
note notNil ifTrue:[ |
|
6022 |
self warning:note position:pos to:pos2 |
|
6023 |
]. |
|
663 | 6024 |
receiver lineNumber:tokenLineNr. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
6025 |
parseForCode ifFalse:[ |
1061 | 6026 |
self rememberSelectorUsed:sel receiver:thisReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
6027 |
]. |
663 | 6028 |
self nextToken. |
141 | 6029 |
]. |
6030 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
6031 |
|
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
6032 |
"Modified: / 6.2.2000 / 14:54:20 / cg" |
141 | 6033 |
! |
6034 |
||
6035 |
variable |
|
1028 | 6036 |
"parse a simple (i.e. non-namespace-access path) variable; |
6037 |
return a node-tree, nil or #Error. |
|
6038 |
Does not advance to next token. |
|
6039 |
If undefined, notify error and correct if user wants to" |
|
141 | 6040 |
|
864 | 6041 |
|v pos1 pos2| |
687 | 6042 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6043 |
v := self variableOrError:tokenName. |
664 | 6044 |
(v ~~ #Error) ifTrue:[ |
663 | 6045 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 6046 |
self markVariable:v. |
663 | 6047 |
]. |
6048 |
^ v |
|
6049 |
]. |
|
865 | 6050 |
|
687 | 6051 |
pos1 := tokenPosition. |
864 | 6052 |
pos2 := pos1+tokenName size-1. |
6053 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 6054 |
|
1089 | 6055 |
parseForCode == true ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6056 |
v := self correctVariable:tokenName atPosition:pos1 to:pos2. |
1089 | 6057 |
(v ~~ #Error) ifTrue:[^ v]. |
6058 |
]. |
|
6059 |
||
6060 |
errorFlag := true. |
|
664 | 6061 |
|
141 | 6062 |
parseForCode ifFalse:[ |
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6063 |
self rememberGlobalUsed:(Smalltalk undeclaredPrefix) , tokenName. |
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6064 |
self rememberGlobalUsed:tokenName. |
141 | 6065 |
] ifTrue:[ |
663 | 6066 |
tokenName first isLowercase ifTrue:[ |
6067 |
ImplicitSelfSends ifTrue:[ |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6068 |
^ UnaryNode receiver:(self selfNode) selector:('__' , tokenName) asSymbol. |
663 | 6069 |
]. |
6070 |
^ #Error |
|
6071 |
] |
|
141 | 6072 |
]. |
865 | 6073 |
|
869 | 6074 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6075 |
^ VariableNode globalNamed:tokenName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6076 |
|
687 | 6077 |
"Modified: / 16.4.1998 / 18:46:45 / cg" |
141 | 6078 |
! |
6079 |
||
0 | 6080 |
variableOrError |
1028 | 6081 |
"parse a simple (i.e. non-namespace-access path) variable; |
6082 |
return a node-tree, nil or #Error. |
|
6083 |
Does not advance to next token." |
|
0 | 6084 |
|
21 | 6085 |
^ self variableOrError:tokenName |
6086 |
! |
|
6087 |
||
6088 |
variableOrError:varName |
|
1028 | 6089 |
"parse a simple (i.e. non-namespace-access path) variable; |
6090 |
return a node-tree, nil or #Error. |
|
6091 |
Does not advance to next token." |
|
21 | 6092 |
|
1351 | 6093 |
|varIndex aClass searchBlock args vars |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6094 |
tokenSymbol space classVarIndex holder node| |
0 | 6095 |
|
6096 |
"is it a block-arg or block-var ?" |
|
6097 |
searchBlock := currentBlock. |
|
6098 |
[searchBlock notNil] whileTrue:[ |
|
628 | 6099 |
vars := searchBlock variables. |
6100 |
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
|
6101 |
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
|
6102 |
varIndex ~~ 0 ifTrue:[ |
628 | 6103 |
^ VariableNode type:#BlockVariable |
6104 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6105 |
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
|
6106 |
index:varIndex |
628 | 6107 |
block:searchBlock |
6108 |
from:currentBlock |
|
6109 |
]. |
|
6110 |
]. |
|
6111 |
||
6112 |
args := searchBlock arguments. |
|
6113 |
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
|
6114 |
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
|
6115 |
varIndex ~~ 0 ifTrue:[ |
628 | 6116 |
^ VariableNode type:#BlockArg |
6117 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6118 |
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
|
6119 |
index:varIndex |
628 | 6120 |
block:searchBlock |
6121 |
from:currentBlock |
|
6122 |
]. |
|
6123 |
||
6124 |
]. |
|
6125 |
||
6126 |
searchBlock := searchBlock home |
|
0 | 6127 |
]. |
6128 |
||
6129 |
"is it a method-variable ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6130 |
(node := self nodeForMethodVariable:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6131 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6132 |
^ node |
0 | 6133 |
]. |
6134 |
||
6135 |
"is it a method-argument ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6136 |
(node := self nodeForMethodArg:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6137 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6138 |
^ node |
0 | 6139 |
]. |
6140 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6141 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6142 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6143 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6144 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6145 |
"/ 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
|
6146 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6147 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6148 |
[con notNil] whileTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6149 |
varNames := self class argAndVarNamesForContext:con. |
690 | 6150 |
varNames size > 0 ifTrue:[ |
6151 |
varIndex := varNames lastIndexOf:varName. |
|
6152 |
varIndex ~~ 0 ifTrue:[ |
|
6153 |
^ VariableNode type:#ContextVariable |
|
6154 |
name:varName |
|
6155 |
context:con |
|
6156 |
index:varIndex |
|
6157 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6158 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6159 |
con := con home. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6160 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6161 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6162 |
|
0 | 6163 |
classToCompileFor notNil ifTrue:[ |
628 | 6164 |
"is it an instance-variable ?" |
6165 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6166 |
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
|
6167 |
varIndex ~~ 0 ifTrue:[ |
628 | 6168 |
classToCompileFor isMeta ifTrue:[ |
6169 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6170 |
classVarIndex ~~ 0 ifTrue:[ |
|
6171 |
"/ give a warning - that maybe a common error |
|
825 | 6172 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
6173 |
alreadyWarnedClassInstVarRefs := Set new |
|
6174 |
]. |
|
6175 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
6176 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
6177 |
alreadyWarnedClassInstVarRefs add:varName. |
|
6178 |
]. |
|
628 | 6179 |
]. |
6180 |
]. |
|
6181 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
6182 |
^ VariableNode type:#InstanceVariable |
|
6183 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6184 |
index:varIndex |
628 | 6185 |
selfValue:selfValue |
6186 |
]. |
|
6187 |
||
6188 |
"/ see if there is a corresponding classVar (for the warning) |
|
6189 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6190 |
||
6191 |
"/ "is it a class-instance-variable ?" |
|
6192 |
"/ |
|
6193 |
"/ Notice: |
|
6194 |
"/ it is no longer allowed to fetch class-instance variables |
|
6195 |
"/ from instance methods ... |
|
6196 |
"/ (used to be in previous ST/X versions) |
|
6197 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6198 |
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
|
6199 |
varIndex ~~ 0 ifTrue:[ |
628 | 6200 |
aClass := self inWhichClassIsClassInstVar:varName. |
6201 |
aClass notNil ifTrue:[ |
|
6202 |
classToCompileFor isMeta ifFalse:[ |
|
6203 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6204 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6205 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6206 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6207 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6208 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6209 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6210 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6211 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6212 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6213 |
]. |
628 | 6214 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
6215 |
^ #Error. |
|
6216 |
] ifFalse:[ |
|
6217 |
"/ give a warning - that maybe a common error |
|
738 | 6218 |
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 | 6219 |
] |
6220 |
]. |
|
6221 |
||
6222 |
"/ OLD CODE: |
|
6223 |
"/ 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
|
6224 |
"/ |
628 | 6225 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
6226 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
6227 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6228 |
"/ index:varIndex |
628 | 6229 |
"/ selfClass:aClass |
6230 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6231 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6232 |
"/ self halt:'oops - should not happen'. |
628 | 6233 |
] |
6234 |
]. |
|
6235 |
||
6236 |
"is it a class-variable ?" |
|
6237 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6238 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6239 |
varIndex ~~ 0 ifTrue:[ |
628 | 6240 |
aClass := self inWhichClassIsClassVar:varName. |
6241 |
aClass notNil ifTrue:[ |
|
6242 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
6243 |
^ 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
|
6244 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6245 |
"/ self halt:'oops - should not happen'. |
628 | 6246 |
]. |
6247 |
||
6248 |
"is it a private-class ?" |
|
6249 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6250 |
aClass := self classToLookForClassVars. |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6251 |
aClass := aClass theNonMetaclass. |
628 | 6252 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
6253 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
6254 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
6255 |
]. |
|
418 | 6256 |
]. |
6257 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6258 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6259 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6260 |
space notNil ifTrue:[ |
628 | 6261 |
space ~~ Smalltalk ifTrue:[ |
6262 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6263 |
space isNameSpace ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6264 |
^ VariableNode globalNamed:(space name , '::' , varName) |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6265 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6266 |
^ VariableNode type:#PrivateClass class:space name:varName |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6267 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6268 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6269 |
^ VariableNode globalNamed:varName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6270 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6271 |
|
0 | 6272 |
"is it a global-variable ?" |
63 | 6273 |
tokenSymbol := varName asSymbolIfInterned. |
6274 |
tokenSymbol notNil ifTrue:[ |
|
628 | 6275 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
6276 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6277 |
^ VariableNode globalNamed:tokenSymbol |
628 | 6278 |
] |
0 | 6279 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6280 |
|
877 | 6281 |
"is it a workspace variable ?" |
6282 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6283 |
"/ when parsing doits, this is done twice; |
|
6284 |
"/ first, for the parse, then as a block-code |
|
6285 |
"/ for the code. |
|
6286 |
"/ We only care for WorkspaceVars in doIts |
|
6287 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
|
1295 | 6288 |
(Workspace notNil |
6289 |
and:[(holder := Workspace workspaceVariableAt:varName) notNil]) |
|
6290 |
ifTrue:[ |
|
6291 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
877 | 6292 |
] |
6293 |
] |
|
6294 |
]. |
|
1295 | 6295 |
"is it a doIt variable ?" |
6296 |
||
6297 |
"/ (requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6298 |
"/ when parsing doits, this is done twice; |
|
6299 |
"/ first, for the parse, then as a block-code |
|
6300 |
"/ for the code. |
|
6301 |
"/ We only care for WorkspaceVars in doIts |
|
6302 |
||
6303 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
|
6304 |
(doItTemporaries notNil |
|
6305 |
and:[(holder := doItTemporaries at:varName asSymbol ifAbsent:nil) notNil]) |
|
6306 |
ifTrue:[ |
|
6307 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
6308 |
] |
|
6309 |
]. |
|
6310 |
"/ ]. |
|
0 | 6311 |
^ #Error |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6312 |
"Modified: / 5.11.2001 / 16:45:35 / cg" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6313 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6314 |
|
1410 | 6315 |
!Parser methodsFor:'parsing-primitives & pragmas'! |
6316 |
||
6317 |
parseApiPragma |
|
6318 |
|cString| |
|
6319 |
||
6320 |
cString := source upTo:$>. |
|
6321 |
self nextToken. |
|
6322 |
"/ TODO: generate that interface ... |
|
6323 |
^ -1 |
|
6324 |
! |
|
6325 |
||
6326 |
parseCDeclPragma |
|
6327 |
|cString cStream cParser returnType functionName argTypes| |
|
6328 |
||
6329 |
cString := source upTo:$>. |
|
6330 |
self nextToken. |
|
6331 |
cStream := cString readStream. |
|
6332 |
||
6333 |
cParser := CParser new. |
|
6334 |
cParser source:cStream scannerClass:CDeclScanner. |
|
6335 |
cParser nextToken. |
|
6336 |
returnType := cParser type. |
|
6337 |
||
6338 |
cParser tokenType ~~ #String ifTrue:[ |
|
6339 |
self parseError:'invalid cdecl - functionName expected'. |
|
6340 |
^ -1 |
|
6341 |
]. |
|
6342 |
functionName := cParser token. |
|
6343 |
cParser nextToken. |
|
6344 |
argTypes := cParser parseFunctionArgumentSpec. |
|
6345 |
self halt. |
|
6346 |
"/ TODO: generate that ffi-calling code ... |
|
6347 |
^ -1 |
|
6348 |
! |
|
6349 |
||
6350 |
parseCPragma |
|
6351 |
|cString cParser cType| |
|
6352 |
||
6353 |
cString := source upTo:$>. |
|
6354 |
self nextToken. |
|
6355 |
"/ TODO: generate that type |
|
6356 |
cParser := CParser new. |
|
6357 |
cParser source:(cString , ';'). |
|
6358 |
cParser nextToken. |
|
6359 |
cType := cParser type. |
|
6360 |
||
6361 |
primitiveResource "primitiveType" := cType. |
|
6362 |
^ -1 |
|
6363 |
! |
|
6364 |
||
6365 |
parsePrimitive |
|
6366 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
|
6367 |
return primitive number or #Error. |
|
6368 |
or a Squeak-style primitive, as '< primitive: string >'; |
|
6369 |
return primitive name or #Error. |
|
6370 |
||
6371 |
Also, ST-80 style resource specs are parsed; the result is |
|
6372 |
left (as side effect) in primitiveResource. |
|
6373 |
(maybe someone else knows what to do with it ...) |
|
6374 |
Well, as we now have this mechanism, I'll use it to mark methods which |
|
6375 |
do keyboard processing ... <resource: keyboard ( keys )> |
|
6376 |
For faster finding of used keyboard accelerators, |
|
6377 |
and to mark resource methods (image, menu or canvas resources). |
|
6378 |
||
6379 |
prim ::= st80Primitive | st80Pragma | stxPragma |
|
6380 |
squeakPrimitive | newSTXPrimitive | resourceDecl |
|
6381 |
||
6382 |
st80Primitive ::= 'primitive:' INTEGER |
|
6383 |
st80Pragma ::= 'exception:' ( 'handle | 'raise' | 'unwind' ) |
|
6384 |
stxPragma ::= 'context:' 'return' |
|
6385 |
||
6386 |
squeakPrimitive ::= 'primitive:' STRING |
|
6387 |
||
6388 |
newSTXPrimitive ::= 'primitive' |
|
6389 |
||
6390 |
resourceDecl ::= 'resource:' SYMBOL - leave SYMBOL in primitiveResource |
|
6391 |
| 'resource:' SYMBOL (...) - leave (SYMBOL (...)) in primitiveResource |
|
6392 |
" |
|
6393 |
||
6394 |
|primNumber cString cParser cType| |
|
6395 |
||
6396 |
(tokenType == #Keyword or:[tokenType == #Identifier]) ifFalse:[ |
|
6397 |
self parseError:'bad primitive definition (keyword expected)'. |
|
6398 |
^ #Error |
|
6399 |
]. |
|
6400 |
||
6401 |
(tokenName = 'primitive:') ifTrue:[ |
|
6402 |
self nextToken. |
|
6403 |
(tokenType == #Integer) ifFalse:[ |
|
6404 |
allowSqueakExtensions ifTrue:[ |
|
6405 |
(tokenType == #String) ifFalse:[ |
|
6406 |
self parseError:'primitive number or name expected'. |
|
6407 |
^ #Error |
|
6408 |
] |
|
6409 |
] ifFalse:[ |
|
6410 |
self parseError:'primitive number expected'. |
|
6411 |
^ #Error |
|
6412 |
] |
|
6413 |
]. |
|
6414 |
primitiveNr notNil ifTrue:[ |
|
6415 |
self parseError:'only one primitive spec allowed'. |
|
6416 |
primNumber := -1. |
|
6417 |
] ifFalse:[ |
|
6418 |
primNumber := tokenValue. |
|
6419 |
]. |
|
6420 |
self nextToken. |
|
6421 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifFalse:[ |
|
6422 |
((tokenType == #Keyword) and:[tokenName = 'errorCode:']) ifTrue:[ |
|
6423 |
self nextToken. |
|
6424 |
(tokenType == #Identifier) ifTrue:[ |
|
6425 |
self nextToken. |
|
6426 |
] ifFalse:[ |
|
6427 |
self error:'not yet implemented'. |
|
6428 |
] |
|
6429 |
]. |
|
6430 |
] |
|
6431 |
] ifFalse:[ |
|
6432 |
(tokenName = 'primitive') ifTrue:[ |
|
6433 |
self nextToken. |
|
6434 |
primNumber := 0. |
|
6435 |
] ifFalse:[ |
|
6436 |
(tokenName = 'resource:') ifTrue:[ |
|
6437 |
self parseResourcePragma. |
|
6438 |
primNumber := -1. |
|
6439 |
] ifFalse:[ |
|
6440 |
(tokenName = 'exception:' |
|
6441 |
or:[tokenName = 'context:']) ifTrue:[ |
|
6442 |
self parseExceptionOrContextPragma. |
|
6443 |
] ifFalse:[ |
|
6444 |
(tokenName = 'C:') ifTrue:[ |
|
6445 |
^ self parseCPragma. |
|
6446 |
] ifFalse:[ |
|
6447 |
(tokenName = 'api:') ifTrue:[ |
|
6448 |
^ self parseApiPragma. |
|
6449 |
] ifFalse:[ |
|
6450 |
(tokenName = 'cdecl:') ifTrue:[ |
|
6451 |
^ self parseCDeclPragma. |
|
6452 |
] ifFalse:[ |
|
6453 |
self parseError:'unrecognized pragma: ' , tokenName. |
|
6454 |
||
6455 |
"/ skip |
|
6456 |
[tokenType ~~ #EOF] whileTrue:[ |
|
6457 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
|
6458 |
self nextToken. |
|
6459 |
^ -1 "/ primNr. |
|
6460 |
]. |
|
6461 |
self nextToken. |
|
6462 |
]. |
|
6463 |
]. |
|
6464 |
]. |
|
6465 |
]. |
|
6466 |
] |
|
6467 |
]. |
|
6468 |
]. |
|
6469 |
]. |
|
6470 |
||
6471 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifFalse:[ |
|
6472 |
self parseError:'bad primitive definition (> expected)'. |
|
6473 |
^ #Error |
|
6474 |
]. |
|
6475 |
self nextToken. |
|
6476 |
^ primNumber |
|
6477 |
||
6478 |
"Modified: 29.5.1996 / 17:24:09 / cg" |
|
6479 |
! |
|
6480 |
||
6481 |
parsePrimitiveOrResourceSpecOrEmpty |
|
6482 |
"parse a methods primitive or resource spec" |
|
6483 |
||
6484 |
|pos wmsg primNr primNrOrString| |
|
6485 |
||
6486 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
|
6487 |
"/ an ST-80 primitive or resourceSpec - parsed but ignored |
|
6488 |
||
6489 |
pos := tokenPosition. |
|
6490 |
self nextToken. |
|
6491 |
primNrOrString := self parsePrimitive. |
|
6492 |
||
6493 |
(primNrOrString == #Error) ifTrue:[^ #Error]. |
|
6494 |
wmsg := nil. |
|
6495 |
||
6496 |
primNrOrString isString ifTrue:[ |
|
6497 |
primNr := self primitiveNumberFromName:primNrOrString |
|
6498 |
] ifFalse:[ |
|
6499 |
primNr := primNrOrString |
|
6500 |
]. |
|
6501 |
||
6502 |
primNr notNil ifTrue:[ |
|
6503 |
primNr < 0 ifTrue:[ |
|
6504 |
WarnST80Directives == true ifTrue:[ |
|
6505 |
wmsg := 'ST-80/Squeak directive ignored'. |
|
6506 |
]. |
|
6507 |
] ifFalse:[ |
|
6508 |
primNr > 0 ifTrue:[ |
|
6509 |
primitiveNr := primNr. |
|
6510 |
wmsg := 'ST-80 primitive may not work' |
|
6511 |
] ifFalse:[ |
|
6512 |
primitiveNr := primNr. |
|
6513 |
wmsg := 'ST/X primitives only work in rel5 and newer' |
|
6514 |
] |
|
6515 |
]. |
|
6516 |
]. |
|
6517 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
|
6518 |
]. |
|
6519 |
||
6520 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
6521 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
|
6522 |
! |
|
6523 |
||
6524 |
parseResourcePragma |
|
6525 |
|keys resource resourceValue| |
|
6526 |
||
6527 |
"/ < resource: has already been parsed. |
|
6528 |
||
6529 |
self nextToken. |
|
6530 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
6531 |
self parseError:'symbol expected'. |
|
6532 |
^ #Error |
|
6533 |
]. |
|
6534 |
||
6535 |
resource := tokenValue. |
|
6536 |
resourceValue := true. |
|
6537 |
||
6538 |
self nextToken. |
|
6539 |
||
6540 |
tokenType == $( ifTrue:[ |
|
6541 |
self nextToken. |
|
6542 |
keys := OrderedCollection new. |
|
6543 |
[(tokenType == $)) or:[tokenType == #EOF] ] whileFalse:[ |
|
6544 |
keys add:tokenValue. |
|
6545 |
self nextToken. |
|
6546 |
]. |
|
6547 |
resourceValue := keys. |
|
6548 |
(tokenType == $)) ifFalse:[ |
|
6549 |
self parseError:'unterminated primitive/spec (missing '')'')'. |
|
6550 |
]. |
|
6551 |
self nextToken. |
|
6552 |
]. |
|
6553 |
||
6554 |
primitiveResource isNil ifTrue:[ |
|
6555 |
primitiveResource := IdentityDictionary new. |
|
6556 |
]. |
|
6557 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
6558 |
! |
|
6559 |
||
6560 |
primitiveNumberFromName:aPrimitiveName |
|
6561 |
"for future compatibility with Squeak ..." |
|
6562 |
||
6563 |
^ nil |
|
6564 |
! ! |
|
6565 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6566 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6567 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6568 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6569 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6570 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6571 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6572 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6573 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6574 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6575 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6576 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6577 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6578 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6579 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6580 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6581 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6582 |
"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
|
6583 |
"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
|
6584 |
"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
|
6585 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6586 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6587 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6588 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6589 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6590 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6591 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
6592 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6593 |
currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6594 |
|pkg| |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6595 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6596 |
pkg := currentPackage. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6597 |
pkg isNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6598 |
(requestor respondsTo:#currentPackage) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6599 |
pkg := requestor currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6600 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6601 |
pkg := Class packageQuerySignal query. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6602 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6603 |
currentPackage := pkg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6604 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6605 |
^ pkg |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6606 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6607 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6608 |
currentPackage:aPackageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6609 |
currentPackage := aPackageName. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6610 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
6611 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6612 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6613 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6614 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6615 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6616 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6617 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6618 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6619 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
6620 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6621 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6622 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6623 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6624 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6625 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6626 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6627 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6628 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6629 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
6630 |
"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
|
6631 |
"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
|
6632 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6633 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6634 |
findNameSpaceWith:aVariableName |
692 | 6635 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6636 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6637 |
"/ 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
|
6638 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6639 |
classToCompileFor notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6640 |
"/ Q: |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6641 |
"/ consider private classes of superclasses. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6642 |
"/ or search in the top owing classes namespace only ? |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6643 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6644 |
"/ for now, ignore other private classes - they are only |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6645 |
"/ known to the corresponding ownerClass. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6646 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6647 |
"is it in the classes namespace ?" |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6648 |
|
1315 | 6649 |
ns := classToCompileFor topNameSpace. |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6650 |
(ns notNil |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6651 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
1142 | 6652 |
ns isNameSpace ifTrue:[ |
6653 |
(ns at:aVariableName) notNil ifTrue:[ |
|
6654 |
^ ns |
|
6655 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6656 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6657 |
]. |
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
6658 |
|
495 | 6659 |
"/ ns := classToCompileFor nameSpace. |
6660 |
"/ ns notNil ifTrue:[ |
|
6661 |
"/ "is it in the current classes namespace ?" |
|
6662 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
6663 |
"/ ^ ns |
|
6664 |
"/ ] |
|
6665 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6666 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6667 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6668 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6669 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6670 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6671 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
1043 | 6672 |
currentSpace isNameSpace ifTrue:[ |
6673 |
(currentSpace at:aVariableName) notNil ifTrue:[ |
|
6674 |
^ currentSpace |
|
6675 |
] |
|
6676 |
] ifFalse:[ |
|
6677 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
6678 |
^ currentSpace |
|
6679 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6680 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6681 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6682 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6683 |
"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
|
6684 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6685 |
usedSpaces notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6686 |
usedSpaces do:[:aNameSpace | |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6687 |
(aNameSpace at:aVariableName) notNil ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6688 |
^ aNameSpace |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6689 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6690 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6691 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6692 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6693 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6694 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 6695 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 6696 |
! |
6697 |
||
1327 | 6698 |
implementedInAnyClass:selector |
6699 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
6700 |
(cls implements:selector) ifTrue:[^ true]. |
|
6701 |
]. |
|
6702 |
^ false |
|
6703 |
! |
|
6704 |
||
713 | 6705 |
inWhichClassIsClassInstVar:aString |
6706 |
"search class-chain for the class-instance variable named aString |
|
6707 |
- return the class or nil if not found" |
|
6708 |
||
6709 |
|aClass| |
|
6710 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6711 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6712 |
|
713 | 6713 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6714 |
(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
|
6715 |
aClass := aClass superclass |
713 | 6716 |
]. |
6717 |
^ nil |
|
6718 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6719 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 6720 |
! |
6721 |
||
6722 |
inWhichClassIsClassVar:aString |
|
6723 |
"search class-chain for the classvariable named aString |
|
6724 |
- return the class or nil if not found" |
|
6725 |
||
6726 |
|aClass className baseClass| |
|
6727 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6728 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6729 |
|
713 | 6730 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6731 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6732 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6733 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6734 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6735 |
] |
713 | 6736 |
]. |
6737 |
^ aClass whichClassDefinesClassVar:aString |
|
6738 |
||
6739 |
"/ [aClass notNil] whileTrue:[ |
|
6740 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
6741 |
"/ aClass := aClass superclass |
|
6742 |
"/ ]. |
|
6743 |
"/ ^ nil |
|
6744 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6745 |
"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
|
6746 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 6747 |
! |
6748 |
||
1262 | 6749 |
makeReferenceFor:aNode |
6750 |
|rec sel indexNode contextNode arg1 arg2| |
|
6751 |
||
6752 |
contextNode := VariableNode type:#ThisContext context:contextToEvaluateIn. |
|
6753 |
indexNode := ConstantNode type:#Integer value:aNode index. |
|
6754 |
||
6755 |
aNode isArgument ifTrue:[ |
|
6756 |
sel := #forArgument:in:. |
|
6757 |
arg1 := indexNode. |
|
6758 |
arg2 := contextNode. |
|
6759 |
] ifFalse:[ |
|
6760 |
aNode isLocal ifTrue:[ |
|
6761 |
sel := #forLocal:in:. |
|
6762 |
arg1 := indexNode. |
|
6763 |
arg2 := contextNode. |
|
6764 |
] ifFalse:[ |
|
6765 |
self parseError:'unsupported variable reference (must be local or argument)'. |
|
6766 |
^ aNode |
|
6767 |
] |
|
6768 |
]. |
|
6769 |
||
6770 |
parseForCode ifFalse:[self rememberGlobalUsed:'Reference']. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6771 |
rec := VariableNode globalNamed:'Reference'. |
1262 | 6772 |
|
6773 |
^ MessageNode receiver:rec selector:sel arg1:arg1 arg2:arg2. |
|
6774 |
! |
|
6775 |
||
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6776 |
noAssignmentAllowed:eMsg at:pos |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6777 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6778 |
self parseError:eMsg position:pos to:tokenPosition + tokenType size - 1. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6779 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6780 |
^ false |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6781 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6782 |
self nextToken. "/ eat the assign when doing highlighting only |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6783 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6784 |
^ true |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6785 |
! |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6786 |
|
787 | 6787 |
plausibilityCheck:aNode |
1193 | 6788 |
|note| |
6789 |
||
6790 |
note := aNode plausibilityCheck. |
|
6791 |
note isNil ifTrue:[ |
|
6792 |
aNode isMessage ifTrue:[ |
|
6793 |
(contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
|
6794 |
aNode receiver isSuper ifTrue:[ |
|
6795 |
aNode selector ~= selector ifTrue:[ |
|
6796 |
^ 'possible bad super message (selector should be same as in current method) ?' |
|
6797 |
]. |
|
6798 |
]. |
|
6799 |
]. |
|
6800 |
]. |
|
6801 |
]. |
|
6802 |
^ note |
|
1262 | 6803 |
! |
6804 |
||
6805 |
selfNode |
|
6806 |
selfNode isNil ifTrue:[ |
|
6807 |
selfNode := SelfNode value:selfValue |
|
6808 |
]. |
|
6809 |
^ selfNode |
|
141 | 6810 |
! ! |
6811 |
||
6812 |
!Parser methodsFor:'queries'! |
|
6813 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6814 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6815 |
"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
|
6816 |
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
|
6817 |
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
|
6818 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6819 |
|
1160 | 6820 |
|m who| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6821 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6822 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 6823 |
m := contextToEvaluateIn method. |
6824 |
m notNil ifTrue:[ |
|
6825 |
who := contextToEvaluateIn method who. |
|
6826 |
who notNil ifTrue:[ |
|
6827 |
^ who methodClass. |
|
6828 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6829 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6830 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6831 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6832 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6833 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6834 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 6835 |
"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
|
6836 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6837 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6838 |
classesClassInstVarNames |
141 | 6839 |
"caching allInstVarNames for next compilation saves time ..." |
6840 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6841 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6842 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6843 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6844 |
|cls| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6845 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6846 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6847 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6848 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6849 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6850 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6851 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6852 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6853 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6854 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6855 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6856 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6857 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6858 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6859 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6860 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6861 |
"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
|
6862 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 6863 |
! |
6864 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6865 |
classesClassVarNames |
141 | 6866 |
"caching allClassVarNames for next compilation saves time ..." |
6867 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6868 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6869 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6870 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6871 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6872 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6873 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6874 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6875 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6876 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6877 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6878 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6879 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6880 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6881 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6882 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6883 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6884 |
] |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6885 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6886 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6887 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6888 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6889 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6890 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6891 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
6892 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6893 |
"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
|
6894 |
"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
|
6895 |
"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
|
6896 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6897 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6898 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6899 |
"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
|
6900 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6901 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6902 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6903 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6904 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6905 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6906 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6907 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6908 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6909 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6910 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6911 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6912 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6913 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6914 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6915 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6916 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
6917 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6918 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6919 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 6920 |
! |
6921 |
||
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6922 |
contextMustBeReturnable |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6923 |
^ primitiveContextInfo notNil |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6924 |
and:[ ^ primitiveContextInfo includes:('context:' -> #return) ] |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6925 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6926 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6927 |
! |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
6928 |
|
141 | 6929 |
hasNonOptionalPrimitiveCode |
6930 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
6931 |
||
6932 |
^ hasNonOptionalPrimitiveCode |
|
0 | 6933 |
! |
6934 |
||
141 | 6935 |
hasPrimitiveCode |
6936 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
6937 |
||
6938 |
^ hasPrimitiveCode |
|
98 | 6939 |
! |
6940 |
||
883 | 6941 |
isSyntaxHighlighter |
6942 |
^ false |
|
6943 |
! |
|
6944 |
||
385 | 6945 |
lineNumberInfo |
6946 |
^ lineNumberInfo |
|
6947 |
||
6948 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
6949 |
! |
|
6950 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
6951 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
6952 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
6953 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
6954 |
"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
|
6955 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
6956 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6957 |
messagesSent |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6958 |
"return a collection with sent message selectors (valid after parsing). |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6959 |
Includes all sent messages (i.e. also sent super messages)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6960 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6961 |
^ (messagesSent ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6962 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6963 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6964 |
messagesSentToSelf |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6965 |
"return a collection with message selectors sent to self only (valid after parsing)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6966 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6967 |
^ (messagesSentToSelf ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6968 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6969 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6970 |
messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6971 |
"return a collection with message selectors sent to super only (valid after parsing)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6972 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6973 |
^ (messagesSentToSuper ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6974 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
6975 |
|
141 | 6976 |
methodArgs |
6977 |
"return an array with methodarg names (valid after parsing spec)" |
|
6978 |
||
6979 |
^ methodArgNames |
|
6980 |
! |
|
6981 |
||
6982 |
methodVars |
|
6983 |
"return a collection with method variablenames (valid after parsing)" |
|
6984 |
||
6985 |
^ methodVarNames |
|
23 | 6986 |
! |
6987 |
||
141 | 6988 |
modifiedClassVars |
6989 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
6990 |
||
541 | 6991 |
^ modifiedClassVars ? #() |
6992 |
||
6993 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 6994 |
! |
6995 |
||
6996 |
modifiedGlobals |
|
6997 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
6998 |
||
541 | 6999 |
^ modifiedGlobals ? #() |
7000 |
||
7001 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 7002 |
! |
7003 |
||
7004 |
modifiedInstVars |
|
7005 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
7006 |
||
541 | 7007 |
^ modifiedInstVars ? #() |
7008 |
||
7009 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 7010 |
! |
7011 |
||
141 | 7012 |
numberOfMethodArgs |
7013 |
"return the number of methodargs (valid after parsing spec)" |
|
7014 |
||
7015 |
^ methodArgs size |
|
7016 |
! |
|
7017 |
||
7018 |
numberOfMethodVars |
|
7019 |
"return the number of method variables (valid after parsing)" |
|
7020 |
||
7021 |
^ methodVars size |
|
7022 |
! |
|
7023 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7024 |
readClassVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7025 |
"return a collection with classvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7026 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7027 |
^ readClassVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7028 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7029 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7030 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7031 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7032 |
readInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7033 |
"return a collection with instvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7034 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7035 |
^ readInstVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7036 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7037 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7038 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7039 |
|
141 | 7040 |
selector |
7041 |
"return the selector (valid after parsing spec)" |
|
7042 |
||
7043 |
^ selector |
|
0 | 7044 |
! |
7045 |
||
141 | 7046 |
usedClassVars |
7047 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
7048 |
||
541 | 7049 |
^ usedClassVars ? #() |
7050 |
||
7051 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 7052 |
! |
7053 |
||
7054 |
usedGlobals |
|
7055 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
7056 |
||
541 | 7057 |
^ usedGlobals ? #() |
7058 |
||
7059 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 7060 |
! |
7061 |
||
7062 |
usedInstVars |
|
7063 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
7064 |
||
541 | 7065 |
^ usedInstVars ? #() |
7066 |
||
7067 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 7068 |
! |
7069 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7070 |
usedSymbols |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7071 |
"return a collection with used symbols (except for sent messages) (valid after parsing)" |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7072 |
|
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7073 |
^ (usedSymbols ? #()) |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7074 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7075 |
|
141 | 7076 |
usedVars |
7077 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
7078 |
||
541 | 7079 |
^ usedVars ? #() |
7080 |
||
7081 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 7082 |
! |
7083 |
||
141 | 7084 |
usesSuper |
7085 |
"return true if the parsed method uses super (valid after parsing)" |
|
7086 |
||
7087 |
^ usesSuper |
|
7088 |
! ! |
|
7089 |
||
7090 |
!Parser methodsFor:'setup'! |
|
7091 |
||
1220
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7092 |
classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7093 |
^ classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7094 |
|
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7095 |
"Created: / 15.11.2001 / 17:21:10 / cg" |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7096 |
! |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7097 |
|
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7098 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7099 |
"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
|
7100 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7101 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7102 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7103 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7104 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7105 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7106 |
|
141 | 7107 |
initialize |
7108 |
super initialize. |
|
7109 |
||
7110 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
7111 |
warnSTXHereExtensionUsed := WarnSTXSpecials. |
|
7112 |
usesSuper := false. |
|
7113 |
parseForCode := false. |
|
377 | 7114 |
foldConstants := FoldConstants. |
7115 |
lineNumberInfo := LineNumberInfo. |
|
607 | 7116 |
warnUndeclared := true. |
1160 | 7117 |
warnUnusedVars := WarnUnusedVars. |
607 | 7118 |
|
7119 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 7120 |
! |
7121 |
||
1363 | 7122 |
initializeFlagsFrom:aParser |
7123 |
"initialize flags from another scanner" |
|
7124 |
||
7125 |
super initializeFlagsFrom:aParser. |
|
7126 |
warnSTXHereExtensionUsed := aParser warnSTXHereExtensionUsed. |
|
7127 |
! |
|
7128 |
||
141 | 7129 |
parseForCode |
7130 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
7131 |
Use this when parsing for compilation or evaluation" |
|
7132 |
||
7133 |
parseForCode := true |
|
0 | 7134 |
! |
7135 |
||
141 | 7136 |
setClassToCompileFor:aClass |
7137 |
"set the class to be used for parsing/evaluating" |
|
7138 |
||
7139 |
classToCompileFor := aClass. |
|
7140 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
7141 |
PrevClass notNil ifTrue:[ |
|
7142 |
Parser update:PrevClass |
|
7143 |
] |
|
7144 |
] |
|
7145 |
! |
|
7146 |
||
7147 |
setContext:aContext |
|
7148 |
"set the context used while evaluating" |
|
7149 |
||
7150 |
contextToEvaluateIn := aContext |
|
7151 |
! |
|
7152 |
||
7153 |
setSelf:anObject |
|
7154 |
"set the value to be used for self while evaluating" |
|
7155 |
||
7156 |
selfValue := anObject. |
|
7157 |
classToCompileFor := anObject class. |
|
7158 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
7159 |
PrevClass notNil ifTrue:[ |
|
7160 |
Parser update:PrevClass |
|
7161 |
] |
|
7162 |
] |
|
607 | 7163 |
! |
7164 |
||
7165 |
warnUndeclared:aBoolean |
|
7166 |
warnUndeclared := aBoolean. |
|
7167 |
||
7168 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
1160 | 7169 |
! |
7170 |
||
7171 |
warnUnusedVars:aBoolean |
|
7172 |
warnUnusedVars := aBoolean. |
|
0 | 7173 |
! ! |
7174 |
||
84 | 7175 |
!Parser methodsFor:'statistic'! |
7176 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7177 |
rememberClassVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7178 |
readClassVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7179 |
readClassVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7180 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7181 |
readClassVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7182 |
self rememberClassVarUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7183 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7184 |
|
141 | 7185 |
rememberClassVarUsed:name |
7186 |
usedClassVars isNil ifTrue:[ |
|
7187 |
usedClassVars := Set new |
|
7188 |
]. |
|
7189 |
usedClassVars add:name. |
|
7190 |
self rememberVariableUsed:name |
|
7191 |
! |
|
7192 |
||
7193 |
rememberGlobalUsed:name |
|
7194 |
usedGlobals isNil ifTrue:[ |
|
7195 |
usedGlobals := Set new |
|
7196 |
]. |
|
7197 |
usedGlobals add:name. |
|
7198 |
self rememberVariableUsed:name |
|
7199 |
! |
|
7200 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7201 |
rememberInstVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7202 |
readInstVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7203 |
readInstVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7204 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7205 |
readInstVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7206 |
self rememberVariableUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7207 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7208 |
|
141 | 7209 |
rememberInstVarUsed:name |
7210 |
usedInstVars isNil ifTrue:[ |
|
7211 |
usedInstVars := Set new |
|
7212 |
]. |
|
7213 |
usedInstVars add:name. |
|
7214 |
self rememberVariableUsed:name |
|
7215 |
! |
|
7216 |
||
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7217 |
rememberLocalUsed:name |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7218 |
usedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7219 |
usedLocalVars := Set new |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7220 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7221 |
usedLocalVars add:name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7222 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7223 |
! |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7224 |
|
1231 | 7225 |
rememberReturnedValue:anExpressionNode |
7226 |
|expr| |
|
7227 |
||
7228 |
returnedValues isNil ifTrue:[returnedValues := Set new]. |
|
7229 |
||
7230 |
expr := anExpressionNode. |
|
7231 |
expr isAssignment ifTrue:[ |
|
7232 |
expr := expr expression. |
|
7233 |
]. |
|
7234 |
(expr isConstant or:[expr isSelf]) ifTrue:[ |
|
7235 |
returnedValues add:expr |
|
7236 |
]. |
|
7237 |
! |
|
7238 |
||
84 | 7239 |
rememberSelectorUsed:sel |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7240 |
messagesSent isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7241 |
messagesSent := IdentitySet new. |
84 | 7242 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7243 |
messagesSent add:sel |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7244 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7245 |
|
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7246 |
rememberSelectorUsed:sel receiver:receiverNode |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7247 |
self rememberSelectorUsed:sel. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7248 |
receiverNode isSuper ifTrue:[ |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7249 |
self rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7250 |
] ifFalse:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7251 |
receiverNode isSelf ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7252 |
self rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7253 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7254 |
]. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7255 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7256 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7257 |
rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7258 |
messagesSentToSelf isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7259 |
messagesSentToSelf := IdentitySet new. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7260 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7261 |
messagesSentToSelf add:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7262 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7263 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7264 |
rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7265 |
messagesSentToSuper isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7266 |
messagesSentToSuper := IdentitySet new. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7267 |
]. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7268 |
messagesSentToSuper add:sel |
84 | 7269 |
! |
7270 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7271 |
rememberSymbolUsed:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7272 |
usedSymbols isNil ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7273 |
usedSymbols := IdentitySet new. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7274 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7275 |
usedSymbols add:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7276 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7277 |
|
84 | 7278 |
rememberVariableUsed:name |
7279 |
usedVars isNil ifTrue:[ |
|
7280 |
usedVars := Set new |
|
7281 |
]. |
|
7282 |
usedVars add:name |
|
7283 |
! ! |
|
7284 |
||
1340 | 7285 |
!Parser::ParseError methodsFor:'accessing'! |
7286 |
||
1386 | 7287 |
description |
7288 |
^ super description , (errorMessage ? '') |
|
7289 |
! |
|
7290 |
||
1340 | 7291 |
endPosition |
7292 |
"return the value of the instance variable 'endPosition' (automatically generated)" |
|
7293 |
||
7294 |
^ endPosition |
|
7295 |
! |
|
7296 |
||
7297 |
errorMessage |
|
7298 |
"return the value of the instance variable 'errorMessage' (automatically generated)" |
|
7299 |
||
7300 |
^ errorMessage |
|
7301 |
! |
|
7302 |
||
7303 |
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg |
|
7304 |
"set instance variables (automatically generated)" |
|
7305 |
||
7306 |
errorMessage := errorMessageArg. |
|
7307 |
startPosition := startPositionArg. |
|
7308 |
endPosition := endPositionArg. |
|
7309 |
! |
|
7310 |
||
7311 |
parser |
|
7312 |
^ originator |
|
7313 |
! |
|
7314 |
||
7315 |
startPosition |
|
7316 |
"return the value of the instance variable 'startPosition' (automatically generated)" |
|
7317 |
||
7318 |
^ startPosition |
|
7319 |
! ! |
|
7320 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7321 |
!Parser::UndefinedVariableNotification methodsFor:'accessing'! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7322 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7323 |
parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7324 |
"return the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7325 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7326 |
^ parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7327 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7328 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7329 |
parser:something |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7330 |
"set the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7331 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7332 |
parser := something. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7333 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7334 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7335 |
variableName |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7336 |
^ parameter |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7337 |
! ! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7338 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7339 |
!Parser class methodsFor:'documentation'! |
148 | 7340 |
|
7341 |
version |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
7342 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.387 2003-05-07 10:31:09 cg Exp $' |
148 | 7343 |
! ! |
1322
da25e31f423c
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
7344 |
|
141 | 7345 |
Parser initialize! |