author | Claus Gittinger <cg@exept.de> |
Tue, 07 Oct 2008 13:50:02 +0200 | |
changeset 2109 | 593859993fb6 |
parent 2108 | 653ffef8aa51 |
child 2110 | 2a2e7604dc16 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1576 | 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 |
" |
|
1043 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
0 | 14 |
Scanner subclass:#Parser |
1983 | 15 |
instanceVariableNames:'classToCompileFor selfValue contextToEvaluateIn selector |
16 |
methodArgs methodArgNames methodVars methodVarNames tree |
|
17 |
currentBlock parseForCode readInstVars readClassVars readGlobals |
|
18 |
usedInstVars usedClassVars usedVars modifiedInstVars |
|
19 |
modifiedClassVars modifiedGlobals usesSuper usedGlobals |
|
20 |
usedSymbols messagesSent messagesSentToSelf messagesSentToSuper |
|
21 |
localVarDefPosition evalExitBlock selfNode superNode nilNode |
|
22 |
hasPrimitiveCode hasNonOptionalPrimitiveCode primitiveNr |
|
23 |
primitiveResource logged warnedUndefVars warnedUnknownNamespaces |
|
24 |
correctedSource foldConstants lineNumberInfo currentNamespace |
|
25 |
currentUsedNamespaces methodNode alreadyWarnedClassInstVarRefs |
|
26 |
localBlockVarDefPosition endOfSelectorPosition |
|
27 |
beginOfBodyPosition startOfBlockPosition primitiveContextInfo |
|
28 |
usedLocalVars modifiedLocalVars alreadyWarnedUninitializedVars |
|
29 |
alreadyWarnedUnimplementedSelectors returnedValues currentPackage |
|
2062 | 30 |
doItTemporaries moreSharedPools inFunctionCallArgument |
1983 | 31 |
didWarnAboutSTXNameSpaceUse didWarnAboutSTXHereExtensionUsed |
32 |
parenthesisLevel didWarnAboutBadSupersend |
|
2108 | 33 |
didWarnAboutSqueakExtensions allowUndeclaredVariables' |
1983 | 34 |
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames |
35 |
PrevClassInstVarNames LazyCompilation FoldConstants |
|
36 |
LineNumberInfo SuppressDoItCompilation ParseErrorSignal |
|
37 |
RestartCompilationSignal' |
|
38 |
poolDictionaries:'' |
|
39 |
category:'System-Compiler' |
|
0 | 40 |
! |
41 |
||
1423 | 42 |
ProceedableError subclass:#ParseError |
1983 | 43 |
instanceVariableNames:'errorMessage startPosition endPosition lineNumber' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:Parser |
|
971 | 47 |
! |
48 |
||
1647 | 49 |
Notification subclass:#ParseWarning |
1983 | 50 |
instanceVariableNames:'errorMessage startPosition endPosition lineNumber' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:Parser |
|
1647 | 54 |
! |
55 |
||
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
56 |
Parser subclass:#PrimitiveSpecParser |
2038 | 57 |
instanceVariableNames:'masterParser' |
1983 | 58 |
classVariableNames:'' |
59 |
poolDictionaries:'' |
|
60 |
privateIn:Parser |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
61 |
! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
62 |
|
971 | 63 |
Parser::ParseError subclass:#UndefinedSuperclassError |
1983 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:Parser |
|
971 | 68 |
! |
69 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
70 |
Notification subclass:#UndefinedVariableNotification |
1983 | 71 |
instanceVariableNames:'parser' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:Parser |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
75 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
76 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
77 |
!Parser class methodsFor:'documentation'! |
19 | 78 |
|
20 | 79 |
copyright |
80 |
" |
|
81 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1576 | 82 |
All Rights Reserved |
20 | 83 |
|
84 |
This software is furnished under a license and may be used |
|
85 |
only in accordance with the terms of that license and with the |
|
86 |
inclusion of the above copyright notice. This software may not |
|
87 |
be provided or otherwise made available to, or used by, any |
|
88 |
other person. No title to or ownership of the software is |
|
89 |
hereby transferred. |
|
90 |
" |
|
91 |
! |
|
92 |
||
19 | 93 |
documentation |
94 |
" |
|
95 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
96 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
97 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
98 |
the (planned) MachineCodeCompiler. |
|
99 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
100 |
methods of main interest are: |
755 | 101 |
Parser evaluateExpression:... |
19 | 102 |
|
103 |
and: |
|
755 | 104 |
Parser parseExpression:... |
105 |
Parser parseMethod:... |
|
19 | 106 |
|
107 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
108 |
||
109 |
Parser is also used to find the referenced/modified inst/classvars of |
|
110 |
a method - this is done by sending parseXXX message to a parser and asking |
|
111 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
112 |
||
113 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
114 |
example analyzes the expressions in the changelist ...) by looking at the |
|
115 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 116 |
compilers internals ... better style is to add specialized query methods here) |
19 | 117 |
|
118 |
One instance of Parser is created to parse one method or expression - i.e. |
|
119 |
its not suggested to reuse parsers. |
|
120 |
||
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
121 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
122 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
123 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
124 |
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
|
125 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
126 |
(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
|
127 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
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
|
133 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 134 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
135 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
136 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
137 |
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
|
138 |
|
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 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
141 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
142 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
153 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
154 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
155 |
|
260 | 156 |
[Instance variables:] |
157 |
||
755 | 158 |
classToCompileFor <Class> the class (or nil) we are compiling for |
159 |
||
160 |
selfValue <any> value to use as self when interpreting |
|
161 |
||
162 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
163 |
||
164 |
selector <Symbol> the selector of the parsed method |
|
165 |
(valid after parseMethodSpecification) |
|
166 |
methodArgs internal |
|
167 |
||
168 |
methodArgNames <Collection> the names of the arguments |
|
169 |
(valid after parseMethodSpecification) |
|
170 |
||
171 |
methodVars internal |
|
172 |
||
173 |
methodVarNames <Collection> the names of the method locals |
|
174 |
(valid after parseMethodBodyVarSpec) |
|
175 |
||
176 |
tree <ParseTree> the parse tree - valid after parsing |
|
177 |
||
178 |
currentBlock if currently parsing for a block |
|
179 |
||
180 |
usedInstVars set of all accessed instances variables |
|
181 |
(valid after parsing) |
|
182 |
||
183 |
usedClassVars same for classVars |
|
184 |
||
185 |
usedVars all used variables (inst, class & globals) |
|
186 |
||
187 |
modifiedInstVars set of all modified instance variables |
|
188 |
||
189 |
modifiedClassVars same for clasVars |
|
190 |
||
191 |
localVarDefPosition <Integer> the character offset of the local variable |
|
192 |
def. (i.e. the first '|' if any) |
|
193 |
Not yet used - prepared for automatic add of |
|
194 |
undefined variables |
|
195 |
||
196 |
evalExitBlock internal for interpretation |
|
197 |
||
198 |
selfNode <Node> cached one-and-only 'self' node |
|
199 |
superNode <Node> cached one-and-only 'super' node |
|
200 |
||
201 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
202 |
hasNonOptionalPrimitiveCode |
|
203 |
<Boolean> true, if it contains ST/X style primitive code |
|
204 |
which is NOT flagged by the OPTIONAL directive. |
|
205 |
||
206 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
207 |
||
208 |
logged |
|
209 |
||
210 |
warnedUndefVars <Set> set of all variables which the parser has |
|
211 |
already output a warning (to avoid multiple |
|
212 |
warnings about the same variable) |
|
260 | 213 |
|
214 |
[Class variables:] |
|
215 |
||
755 | 216 |
PrevClass <Class> class, of which properties are |
217 |
cached in: |
|
218 |
||
219 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
220 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
221 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
222 |
||
223 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
224 |
||
225 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
226 |
as instances of ImmutableArray, |
|
227 |
which cannot be stored into. |
|
228 |
Default is false, for compatibility. |
|
229 |
Can be turned on while developping |
|
230 |
new code to make certain that side |
|
231 |
effects are avoided. |
|
232 |
||
1615 | 233 |
StringsAreImmutable <Boolean> same as above for string literals |
234 |
||
755 | 235 |
WarnST80Directives <Boolean> if true, give warnings about |
236 |
ST-80 directives (resource defs) |
|
237 |
which are ignored in st/x. |
|
238 |
defaults to false. |
|
239 |
||
240 |
FoldConstants <Symbol> controls how constant folding should be |
|
241 |
done. |
|
242 |
Can be one of: |
|
243 |
nil - no constant folding |
|
244 |
#level1 - numeric optimizations only |
|
245 |
#level2 - secure optimizations only |
|
246 |
#full - full folding |
|
247 |
||
248 |
level1: arithmetic on constant numbers |
|
249 |
||
250 |
level2: above PLUS array conversions with #asFloatArray, |
|
251 |
#asDoubleArray, string concatenation |
|
252 |
||
253 |
full: constant points. |
|
260 | 254 |
|
255 |
[see also:] |
|
755 | 256 |
ByteCodeCompiler Scanner ObjectFileLoader |
257 |
Workspace |
|
258 |
SystemBrowser |
|
263 | 259 |
|
260 |
[author:] |
|
755 | 261 |
Claus Gittinger |
19 | 262 |
" |
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
263 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
264 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
265 |
examples |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
266 |
" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
267 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
268 |
Parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
269 |
evaluate:'1+2*3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
270 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
271 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
272 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
273 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
274 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
275 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
276 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
277 |
Parser undefinedVariableNotification handle:[:ex | |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
278 |
|badName| |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
279 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
280 |
badName := ex variableName. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
281 |
ex proceedWith:(ConstantNode value:5). |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
282 |
] do:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
283 |
^ self compilerClass |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
284 |
evaluate:'foo * 3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
285 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
286 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
287 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
288 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
289 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
290 |
] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
291 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
292 |
" |
141 | 293 |
! ! |
294 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
295 |
!Parser class methodsFor:'instance creation'! |
141 | 296 |
|
297 |
for:aStringOrStream in:aClass |
|
298 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
299 |
||
300 |
|parser| |
|
301 |
||
302 |
parser := self for:aStringOrStream. |
|
303 |
parser setClassToCompileFor:aClass. |
|
304 |
^ parser |
|
305 |
! ! |
|
306 |
||
1419 | 307 |
!Parser class methodsFor:'Compatibility-ST80'! |
540 | 308 |
|
309 |
parse:aString class:aClass |
|
310 |
"same as #parseMethod:in: for ST80 compatibility." |
|
311 |
||
312 |
|parser| |
|
313 |
||
314 |
parser := self parseMethod:aString in:aClass. |
|
315 |
parser notNil ifTrue:[^ parser tree]. |
|
316 |
^ nil |
|
317 |
||
318 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
319 |
! ! |
|
320 |
||
1419 | 321 |
!Parser class methodsFor:'Compatibility-Squeak'! |
920 | 322 |
|
323 |
evaluate:someString for:aReceiver logged:logged |
|
324 |
^ self evaluate:someString receiver:aReceiver logged:logged |
|
325 |
||
326 |
||
327 |
||
328 |
! ! |
|
329 |
||
1062 | 330 |
!Parser class methodsFor:'Signal constants'! |
331 |
||
332 |
parseErrorSignal |
|
333 |
^ ParseErrorSignal |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
334 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
335 |
|
1468 | 336 |
restartCompilationSignal |
337 |
^ RestartCompilationSignal |
|
338 |
||
339 |
"Created: / 15.11.2001 / 22:57:05 / cg" |
|
340 |
! |
|
341 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
342 |
undefinedVariableNotification |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
343 |
^ UndefinedVariableNotification |
1062 | 344 |
! ! |
345 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
346 |
!Parser class methodsFor:'changes'! |
141 | 347 |
|
348 |
flushNameCache |
|
349 |
"unconditional flush name caches" |
|
350 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
351 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
352 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
353 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
354 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
355 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
356 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
357 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
358 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
359 |
] valueUninterruptably |
141 | 360 |
|
361 |
"Parser flushNameCache" |
|
362 |
! |
|
363 |
||
364 |
update:something with:someArgument from:changedObject |
|
365 |
"aClass has changed its definition - flush name caches if we have to" |
|
366 |
||
367 |
(changedObject == PrevClass) ifTrue:[ |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
368 |
something == #definition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
369 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
370 |
] |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
371 |
]. |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
372 |
(changedObject == Smalltalk) ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
373 |
something == #classDefinition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
374 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
375 |
] |
141 | 376 |
] |
377 |
! ! |
|
378 |
||
717 | 379 |
!Parser class methodsFor:'class initialization'! |
380 |
||
381 |
initialize |
|
382 |
LazyCompilation := false. "/ usually set to true in your .rc file |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
383 |
|
717 | 384 |
FoldConstants := #level1. |
385 |
LineNumberInfo := false. |
|
386 |
||
1062 | 387 |
ParseErrorSignal isNil ifTrue:[ |
1380 | 388 |
ParseErrorSignal := ParseError. |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
389 |
ParseErrorSignal notifierString:'Parse error:'. |
1380 | 390 |
|
391 |
"/ ParseErrorSignal := Error newSignalMayProceed:true. |
|
392 |
"/ ParseErrorSignal notifierString:'parse error'. |
|
393 |
"/ ParseErrorSignal nameClass:self message:#parseErrorSignal. |
|
1062 | 394 |
]. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
395 |
RestartCompilationSignal := Signal new. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
396 |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
397 |
Smalltalk addDependent:self. |
1062 | 398 |
|
717 | 399 |
" |
400 |
self initialize |
|
401 |
" |
|
402 |
||
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
403 |
"Modified: / 22-08-2006 / 13:41:51 / cg" |
717 | 404 |
! ! |
405 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
406 |
!Parser class methodsFor:'controlling compilation'! |
141 | 407 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
408 |
allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
409 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
410 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
411 |
^ ParserFlags allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
412 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
413 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
414 |
allowArrayIndexSyntaxExtension:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
415 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
416 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
417 |
ParserFlags allowArrayIndexSyntaxExtension:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
418 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
419 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
420 |
self allowArrayIndexSyntaxExtension:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
421 |
self allowArrayIndexSyntaxExtension:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
422 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
423 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
424 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
425 |
allowFunctionCallSyntaxForBlockEvaluation |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
426 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
427 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
428 |
^ ParserFlags allowFunctionCallSyntaxForBlockEvaluation |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
429 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
430 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
431 |
allowFunctionCallSyntaxForBlockEvaluation:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
432 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
433 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
434 |
ParserFlags allowFunctionCallSyntaxForBlockEvaluation:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
435 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
436 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
437 |
self allowFunctionCallSyntaxForBlockEvaluation:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
438 |
self allowFunctionCallSyntaxForBlockEvaluation:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
439 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
440 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
441 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
442 |
allowReservedWordsAsSelectors |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
443 |
"return true, if self, super, thisContext, nil, true and false are to be allowed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
444 |
as unary message selectors." |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
445 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
446 |
^ ParserFlags allowReservedWordsAsSelectors |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
447 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
448 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
449 |
allowReservedWordsAsSelectors:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
450 |
"enable/disable, if self, super, thisContext, nil, true and false are to be allowed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
451 |
as unary message selectors." |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
452 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
453 |
ParserFlags allowReservedWordsAsSelectors:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
454 |
self setupActions |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
455 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
456 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
457 |
self allowReservedWordsAsSelectors:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
458 |
self allowReservedWordsAsSelectors:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
459 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
460 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
461 |
|
141 | 462 |
arraysAreImmutable |
463 |
"return true if arrays are immutable literals" |
|
464 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
465 |
^ ParserFlags arraysAreImmutable |
141 | 466 |
! |
467 |
||
468 |
arraysAreImmutable:aBoolean |
|
469 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
470 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
471 |
ParserFlags arraysAreImmutable:aBoolean. |
141 | 472 |
|
473 |
" |
|
474 |
can be added to your private.rc file: |
|
475 |
||
476 |
Compiler arraysAreImmutable:true |
|
477 |
Compiler arraysAreImmutable:false |
|
478 |
" |
|
479 |
! |
|
480 |
||
481 |
compileLazy |
|
482 |
"return true if compiling lazy" |
|
483 |
||
484 |
^ LazyCompilation. |
|
485 |
! |
|
486 |
||
487 |
compileLazy:aBoolean |
|
488 |
"turn on/off lazy compilation - return previous setting. |
|
489 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
490 |
but it also controls the reporting of some errors here; therefore |
|
491 |
its located here" |
|
492 |
||
493 |
|oldLazy| |
|
494 |
||
495 |
oldLazy := LazyCompilation. |
|
496 |
LazyCompilation := aBoolean. |
|
497 |
^ oldLazy |
|
498 |
||
499 |
" |
|
500 |
Compiler compileLazy:false |
|
501 |
Compiler compileLazy:true |
|
502 |
" |
|
503 |
! |
|
504 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
505 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
506 |
"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
|
507 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
508 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
509 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
510 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
511 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
512 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
513 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
514 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
515 |
It can be: |
1576 | 516 |
nil - no constant folding |
517 |
#level1 - numeric constants only |
|
518 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
519 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
520 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
521 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
522 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
523 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
524 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
525 |
|
141 | 526 |
implicitSelfSends |
527 |
"return true if undefined variables with |
|
528 |
lowercase first character are to be turned |
|
529 |
into implicit self sends" |
|
530 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
531 |
^ ParserFlags implicitSelfSends |
141 | 532 |
! |
533 |
||
534 |
implicitSelfSends:aBoolean |
|
535 |
"turn on/off implicit self sends" |
|
536 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
537 |
ParserFlags implicitSelfSends:aBoolean |
141 | 538 |
|
539 |
" |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
540 |
ParserFlags implicitSelfSends:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
541 |
ParserFlags implicitSelfSends:false |
141 | 542 |
" |
377 | 543 |
! |
544 |
||
545 |
lineNumberInfo |
|
546 |
^ LineNumberInfo |
|
547 |
! |
|
548 |
||
549 |
lineNumberInfo:aBoolean |
|
550 |
LineNumberInfo := aBoolean |
|
752 | 551 |
! |
552 |
||
553 |
stringsAreImmutable |
|
554 |
"return true if strings are immutable literals" |
|
555 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
556 |
^ ParserFlags stringsAreImmutable |
752 | 557 |
|
558 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
559 |
! |
|
560 |
||
561 |
stringsAreImmutable:aBoolean |
|
562 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
563 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
564 |
ParserFlags stringsAreImmutable:aBoolean. |
752 | 565 |
|
566 |
" |
|
567 |
can be added to your private.rc file: |
|
568 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
569 |
ParserFlags stringsAreImmutable:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
570 |
ParserFlags stringsAreImmutable:false |
752 | 571 |
" |
572 |
||
573 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
1160 | 574 |
! |
575 |
||
1653 | 576 |
warnAboutBadComments:aBoolean |
577 |
"controls generation of warning messages about empty comments" |
|
578 |
||
579 |
ParserFlags warnAboutBadComments:aBoolean |
|
580 |
! |
|
581 |
||
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
582 |
warnAboutVariableNameConventions |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
583 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
584 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
585 |
^ ParserFlags warnAboutVariableNameConventions |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
586 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
587 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
588 |
warnAboutVariableNameConventions:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
589 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
590 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
591 |
ParserFlags warnAboutVariableNameConventions:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
592 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
593 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
594 |
warnAboutWrongVariableNames |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
595 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
596 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
597 |
^ ParserFlags warnAboutWrongVariableNames |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
598 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
599 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
600 |
warnAboutWrongVariableNames:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
601 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
602 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
603 |
ParserFlags warnAboutWrongVariableNames:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
604 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
605 |
|
1160 | 606 |
warnUnusedVars |
607 |
"controls generation of warning messages about unued method variables" |
|
608 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
609 |
^ ParserFlags warnUnusedVars |
1160 | 610 |
! |
611 |
||
612 |
warnUnusedVars:aBoolean |
|
613 |
"controls generation of warning messages about unued method variables" |
|
614 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
615 |
ParserFlags warnUnusedVars:aBoolean |
19 | 616 |
! ! |
0 | 617 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
618 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
619 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
620 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
621 |
"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
|
622 |
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
|
623 |
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
|
624 |
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
|
625 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
626 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
627 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
628 |
"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
|
629 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
630 |
|
1187 | 631 |
!Parser class methodsFor:'error correction'! |
632 |
||
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
633 |
findBest:nMax selectorsFor:aString in:aClassOrNil |
1187 | 634 |
"collect known selectors with their spelling distances to aString; |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
635 |
return the nMax best suggestions. If the argument, aClassOrNil is not nil, |
1187 | 636 |
the message is assumed to be sent to instances of that class (i.e. offer |
637 |
corrections from that hierarchy only)" |
|
638 |
||
1286 | 639 |
|info block lcSelector| |
1187 | 640 |
|
641 |
info := SortedCollection new. |
|
642 |
info sortBlock:[:a :b | a value > b value]. |
|
643 |
||
644 |
lcSelector := aString asLowercase. |
|
645 |
||
646 |
block := [:sym :mthd| |
|
1215 | 647 |
|dist lcSym keepThis| |
1187 | 648 |
|
649 |
lcSym := sym asLowercase. |
|
650 |
(info contains:[:i | i key == sym]) ifFalse:[ |
|
651 |
dist := lcSelector spellAgainst:lcSym. |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
652 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
653 |
(lcSym startsWith:lcSelector) ifTrue:[ |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
654 |
dist := dist + (aString size * 10). |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
655 |
]. |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
656 |
|
1215 | 657 |
(dist > 20) ifTrue:[ |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
658 |
(info contains:[:entry | entry key = sym]) ifFalse:[ |
1215 | 659 |
keepThis := true. |
660 |
info size >= nMax ifTrue:[ |
|
661 |
"will remove last entry anyway - so check if this one will remain ..." |
|
662 |
dist < info last value ifTrue:[ |
|
663 |
keepThis := false. |
|
664 |
] |
|
665 |
]. |
|
666 |
keepThis ifTrue:[ |
|
667 |
"expensive - therefore do this check at last" |
|
668 |
mthd isObsolete ifFalse:[ |
|
669 |
info add:(sym -> dist). |
|
670 |
info size > nMax ifTrue:[ |
|
671 |
info removeLast. |
|
672 |
] |
|
673 |
] |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
674 |
] |
1187 | 675 |
] |
676 |
] |
|
677 |
] |
|
678 |
]. |
|
679 |
||
680 |
aClassOrNil isNil ifTrue:[ |
|
681 |
Smalltalk allClassesDo:[:cls | |
|
682 |
cls methodDictionary keysAndValuesDo:block. |
|
683 |
cls class methodDictionary keysAndValuesDo:block. |
|
684 |
] |
|
685 |
] ifFalse:[ |
|
686 |
aClassOrNil withAllSuperclassesDo:[:cls | |
|
687 |
cls methodDictionary keysAndValuesDo:block. |
|
1323 | 688 |
"/ cls class methodDictionary keysAndValuesDo:block. |
1187 | 689 |
] |
690 |
]. |
|
691 |
||
692 |
^ info asOrderedCollection collect:[:a | a key] |
|
693 |
||
2033 | 694 |
"Modified: / 15-05-2007 / 12:46:24 / cg" |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
695 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
696 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
697 |
findBestSelectorsFor:aString |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
698 |
"collect known selectors with their spelling distances to aString; |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
699 |
return the 10 best suggestions" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
700 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
701 |
^ self findBestSelectorsFor:aString in:nil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
702 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
703 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
704 |
Parser findBestSelectorsFor:'at' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
705 |
Parser findBestSelectorsFor:'at:pu' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
706 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
707 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
708 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
709 |
findBestSelectorsFor:aString in:aClassOrNil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
710 |
"collect known selectors with their spelling distances to aString; |
2109 | 711 |
return the N best suggestions. If the argument, aClassOrNil is not nil, |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
712 |
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
|
713 |
corrections from that hierarchy only)" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
714 |
|
2109 | 715 |
^ self findBest:30 selectorsFor:aString in:aClassOrNil |
2033 | 716 |
|
717 |
"Modified: / 15-05-2007 / 12:39:28 / cg" |
|
1187 | 718 |
! ! |
719 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
720 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 721 |
|
19 | 722 |
evaluate:aStringOrStream |
71 | 723 |
"return the result of evaluating an expression in aStringOrStream. |
724 |
No doit-entry is added to the changeLog." |
|
0 | 725 |
|
19 | 726 |
^ self |
1576 | 727 |
evaluate:aStringOrStream |
728 |
in:nil |
|
729 |
receiver:nil |
|
730 |
notifying:nil |
|
731 |
logged:false |
|
732 |
ifFail:nil |
|
733 |
compile:true |
|
19 | 734 |
|
735 |
" |
|
736 |
Compiler evaluate:'1 + 2' |
|
737 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
738 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
739 |
" |
|
0 | 740 |
! |
741 |
||
71 | 742 |
evaluate:aStringOrStream compile:compile |
743 |
"return the result of evaluating aString, |
|
744 |
The compile argument specifies if the string should be compiled down to |
|
745 |
bytecode or instead be interpreted from the parseTree. |
|
746 |
The first should be done for doIts etc, where a readable walkback is |
|
747 |
required. |
|
748 |
The latter is better done for constants, styleSheet and resource |
|
749 |
reading and simple sends, where the overhead of compilation is bigger |
|
750 |
than the interpretation overhead." |
|
751 |
||
752 |
^ self |
|
1576 | 753 |
evaluate:aStringOrStream |
754 |
in:nil |
|
755 |
receiver:nil |
|
756 |
notifying:nil |
|
757 |
logged:false |
|
758 |
ifFail:nil |
|
759 |
compile:compile |
|
71 | 760 |
! |
761 |
||
20 | 762 |
evaluate:aStringOrStream ifFail:failBlock |
763 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 764 |
In case of any syntax errors, return the value of failBlock. |
765 |
No doit-entry is added to the changeLog." |
|
20 | 766 |
|
767 |
^ self |
|
1576 | 768 |
evaluate:aStringOrStream |
769 |
in:nil |
|
770 |
receiver:nil |
|
771 |
notifying:nil |
|
772 |
logged:false |
|
773 |
ifFail:failBlock |
|
774 |
compile:true |
|
20 | 775 |
" |
776 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
777 |
" |
|
778 |
! |
|
779 |
||
71 | 780 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
781 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
782 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
783 |
No doIt entry is added to the change-file. |
|
784 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
785 |
||
786 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
787 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
788 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
789 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
790 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
791 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
792 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
793 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
794 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
795 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 796 |
! |
797 |
||
798 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
799 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
800 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
801 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
802 |
is non-nil, it is evaluated if an error occurs." |
|
803 |
||
71 | 804 |
^ self |
1576 | 805 |
evaluate:aStringOrStream |
806 |
in:aContext |
|
807 |
receiver:anObject |
|
808 |
notifying:requestor |
|
809 |
logged:logged |
|
810 |
ifFail:failBlock |
|
811 |
compile:true |
|
71 | 812 |
! |
813 |
||
814 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
815 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
816 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
817 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
818 |
is non-nil, it is evaluated if an error occurs. |
|
819 |
Finally, compile specifies if the string should be compiled down to |
|
820 |
bytecode or instead be interpreted from the parseTree. |
|
821 |
The first should be done for doIts etc, where a readable walkback is |
|
822 |
required. |
|
823 |
The latter is better done for constants, styleSheet and resource |
|
824 |
reading and simple sends, where the overhead of compilation is bigger |
|
825 |
than the interpretation overhead." |
|
826 |
||
1363 | 827 |
^ self new |
2108 | 828 |
allowUndeclaredVariables:false; |
829 |
||
1548 | 830 |
evaluate:aStringOrStream |
831 |
in:aContext |
|
832 |
receiver:anObject |
|
833 |
notifying:requestor |
|
834 |
logged:logged |
|
835 |
ifFail:failBlock |
|
836 |
compile:compile |
|
1561
175735dcd732
do not check for endOfInput if parsing from a Stream
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
837 |
checkForEndOfInput:(aStringOrStream isStream not) |
141 | 838 |
! |
839 |
||
840 |
evaluate:aStringOrStream logged:logged |
|
841 |
"return the result of evaluating an expression in aStringOrStream. |
|
842 |
The argument log controls if an entry is added to the changeLog." |
|
843 |
||
844 |
^ self |
|
1576 | 845 |
evaluate:aStringOrStream |
846 |
in:nil |
|
847 |
receiver:nil |
|
848 |
notifying:nil |
|
849 |
logged:logged |
|
850 |
ifFail:nil |
|
851 |
compile:true |
|
141 | 852 |
" |
853 |
Compiler evaluate:'''some string''' logged:false |
|
854 |
Compiler evaluate:'''some string''' logged:true |
|
855 |
" |
|
856 |
! |
|
857 |
||
858 |
evaluate:aStringOrStream notifying:requestor |
|
859 |
"return the result of evaluating aString, |
|
860 |
errors are reported to requestor" |
|
861 |
||
862 |
^ self |
|
1576 | 863 |
evaluate:aStringOrStream |
864 |
in:nil |
|
865 |
receiver:nil |
|
866 |
notifying:requestor |
|
867 |
logged:false |
|
868 |
ifFail:nil |
|
869 |
compile:true |
|
141 | 870 |
! |
871 |
||
872 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
873 |
"return the result of evaluating aString, |
|
874 |
errors are reported to requestor. |
|
875 |
The compile argument specifies if the string should be compiled down to |
|
876 |
bytecode or instead be interpreted from the parseTree. |
|
877 |
The first should be done for doIts etc, where a readable walkback is |
|
878 |
required. |
|
879 |
The latter is better done for constants, styleSheet and resource |
|
880 |
reading and simple sends, where the overhead of compilation is bigger |
|
881 |
than the interpretation overhead." |
|
882 |
||
883 |
^ self |
|
1576 | 884 |
evaluate:aStringOrStream |
885 |
in:nil |
|
886 |
receiver:nil |
|
887 |
notifying:requestor |
|
888 |
logged:false |
|
889 |
ifFail:nil |
|
890 |
compile:compile |
|
141 | 891 |
! |
892 |
||
1025
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
893 |
evaluate:aStringOrStream notifying:requestor logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
894 |
"return the result of evaluating aString, |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
895 |
errors are reported to requestor" |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
896 |
|
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
897 |
^ self |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
898 |
evaluate:aStringOrStream |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
899 |
in:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
900 |
receiver:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
901 |
notifying:requestor |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
902 |
logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
903 |
ifFail:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
904 |
compile:true |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
905 |
! |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
906 |
|
572 | 907 |
evaluate:aStringOrStream receiver:anObject |
908 |
"return the result of evaluating aString, |
|
909 |
errors are reported to requestor. Allow access to |
|
910 |
anObject as self and to its instVars " |
|
911 |
||
912 |
^ self |
|
1576 | 913 |
evaluate:aStringOrStream |
914 |
in:nil |
|
915 |
receiver:anObject |
|
916 |
notifying:nil |
|
917 |
logged:false |
|
918 |
ifFail:nil |
|
919 |
compile:true |
|
572 | 920 |
|
921 |
" |
|
922 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
923 |
" |
|
924 |
||
925 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
926 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
927 |
! |
|
928 |
||
919 | 929 |
evaluate:aStringOrStream receiver:someOne logged:logged |
930 |
"return the result of evaluating an expression in aStringOrStream. |
|
931 |
The argument log controls if an entry is added to the changeLog." |
|
932 |
||
933 |
^ self |
|
934 |
evaluate:aStringOrStream |
|
935 |
in:nil |
|
936 |
receiver:someOne |
|
937 |
notifying:nil |
|
938 |
logged:logged |
|
939 |
ifFail:nil |
|
940 |
compile:true |
|
941 |
" |
|
942 |
Compiler evaluate:'''some string''' logged:false |
|
943 |
Compiler evaluate:'''some string''' logged:true |
|
944 |
Compiler evaluate:'self class' receiver:nil logged:false |
|
945 |
Compiler evaluate:'self class' receiver:1 logged:false |
|
946 |
" |
|
947 |
! |
|
948 |
||
141 | 949 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
950 |
"return the result of evaluating aString, |
|
951 |
errors are reported to requestor. Allow access to |
|
952 |
anObject as self and to its instVars (used in the inspector)" |
|
953 |
||
954 |
^ self |
|
1576 | 955 |
evaluate:aStringOrStream |
956 |
in:nil |
|
957 |
receiver:anObject |
|
958 |
notifying:requestor |
|
959 |
logged:false |
|
960 |
ifFail:nil |
|
961 |
compile:true |
|
141 | 962 |
|
963 |
" |
|
964 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
965 |
" |
|
966 |
! |
|
967 |
||
968 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
969 |
"return the result of evaluating aString, |
|
970 |
errors are reported to requestor. Allow access to |
|
971 |
anObject as self and to its instVars (used in the inspector). |
|
972 |
The compile argument specifies if the string should be compiled down to |
|
973 |
bytecode or instead be interpreted from the parseTree. |
|
974 |
The first should be done for doIts etc, where a readable walkback is |
|
975 |
required. |
|
976 |
The latter is better done for constants, styleSheet and resource |
|
977 |
reading and simple sends, where the overhead of compilation is bigger |
|
978 |
than the interpretation overhead." |
|
979 |
||
980 |
^ self |
|
1576 | 981 |
evaluate:aStringOrStream |
982 |
in:nil |
|
983 |
receiver:anObject |
|
984 |
notifying:requestor |
|
985 |
logged:false |
|
986 |
ifFail:nil |
|
987 |
compile:compile |
|
1548 | 988 |
! |
989 |
||
990 |
evaluateFrom:aStringOrStream ifFail:failBlock |
|
991 |
"return the result of evaluating an expression from aStringOrStream. |
|
992 |
In case of any syntax errors, return the value of failBlock. |
|
993 |
No doit-entry is added to the changeLog." |
|
994 |
||
995 |
^ self |
|
996 |
evaluateFrom:aStringOrStream |
|
997 |
in:nil |
|
998 |
receiver:nil |
|
999 |
notifying:nil |
|
1000 |
logged:false |
|
1001 |
ifFail:failBlock |
|
1002 |
compile:true |
|
1003 |
" |
|
1004 |
Compiler evaluate:'1 + 2' ifFail:['oops'] |
|
1005 |
" |
|
1006 |
! |
|
1007 |
||
1008 |
evaluateFrom:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
1009 |
"return the result of evaluating the next expression from aStringOrStream, errors are reported to requestor. |
|
1010 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
1011 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
1012 |
is non-nil, it is evaluated if an error occurs. |
|
1013 |
Finally, compile specifies if the string should be compiled down to |
|
1014 |
bytecode or instead be interpreted from the parseTree. |
|
1015 |
The first should be done for doIts etc, where a readable walkback is |
|
1016 |
required. |
|
1017 |
The latter is better done for constants, styleSheet and resource |
|
1018 |
reading and simple sends, where the overhead of compilation is bigger |
|
1019 |
than the interpretation overhead." |
|
1020 |
||
1021 |
^ self new |
|
1022 |
evaluate:aStringOrStream |
|
1023 |
in:aContext |
|
1024 |
receiver:anObject |
|
1025 |
notifying:requestor |
|
1026 |
logged:logged |
|
1027 |
ifFail:failBlock |
|
1028 |
compile:compile |
|
1029 |
checkForEndOfInput:false |
|
0 | 1030 |
! ! |
1031 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1032 |
!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
|
1033 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1034 |
argAndVarNamesForContext:aContext |
1546 | 1035 |
<resource:#obsolete> |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1036 |
self obsoleteMethodWarning. |
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1037 |
^ aContext argAndVarNames. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1038 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1039 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1040 |
!Parser class methodsFor:'parsing'! |
141 | 1041 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1042 |
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
|
1043 |
"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
|
1044 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1045 |
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
|
1046 |
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
|
1047 |
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
|
1048 |
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
|
1049 |
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
|
1050 |
|
429 | 1051 |
|compiler tree mSource who mClass blocks |
397 | 1052 |
maxSoFar innerBlock m| |
1053 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1054 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 1055 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1056 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
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 |
m := aMethod. |
1060 |
who := m who. |
|
1061 |
who isNil ifTrue:[ |
|
1062 |
m isWrapped ifTrue:[ |
|
1063 |
m := m wrapper. |
|
1064 |
m notNil ifTrue:[ |
|
1065 |
who := m who. |
|
1066 |
] |
|
1067 |
] |
|
1068 |
]. |
|
1069 |
who notNil ifTrue:[ |
|
1070 |
mClass := who methodClass. |
|
1071 |
mClass isNil ifTrue:[ ^ nil]. |
|
1072 |
]. |
|
1073 |
||
1074 |
mSource := m source. |
|
1075 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1076 |
] ifFalse:[ |
815 | 1077 |
aString notNil ifTrue:[ |
1078 |
mSource := aString. |
|
1079 |
mClass := UndefinedObject |
|
1080 |
] ifFalse:[ |
|
1081 |
^ nil |
|
1082 |
] |
|
397 | 1083 |
]. |
1084 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1085 |
"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
|
1086 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1087 |
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
|
1088 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1089 |
compiler notifying:nil. |
1365 | 1090 |
compiler ignoreWarnings:true. |
1091 |
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
|
1092 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1093 |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1094 |
Notification |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1095 |
handle: |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1096 |
[:ex | |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1097 |
ex proceed |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1098 |
] |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1099 |
do:[ |
1514 | 1100 |
aMethod notNil ifTrue:[ |
1101 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
|
1102 |
^ nil. |
|
1103 |
]. |
|
1104 |
||
1105 |
who notNil ifTrue:[ |
|
1106 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
1107 |
^ nil |
|
1108 |
] |
|
1109 |
]. |
|
1110 |
] ifFalse:[ |
|
1111 |
compiler nextToken. |
|
1112 |
]. |
|
1113 |
||
1114 |
tree := compiler parseMethodBody. |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1115 |
]. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1116 |
|
815 | 1117 |
(compiler errorFlag |
1118 |
or:[tree == #Error |
|
1119 |
or:[tree isNil]]) ifTrue:[ |
|
1120 |
^ nil |
|
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 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1123 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1124 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1125 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1126 |
blocks := blocks select:[:aBlock | |
815 | 1127 |
line between: aBlock lineNumber and:aBlock endLineNumber |
1128 |
||
1129 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1130 |
blocks size == 1 ifTrue:[ |
815 | 1131 |
^ 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
|
1132 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1133 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1134 |
nA notNil ifTrue:[ |
815 | 1135 |
blocks := blocks select:[:aBlock | |
1136 |
aBlock numArgs == nA |
|
1137 |
]. |
|
1138 |
blocks size == 1 ifTrue:[ |
|
1139 |
^ blocks at:1 |
|
1140 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1141 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1142 |
nV notNil ifTrue:[ |
815 | 1143 |
blocks := blocks select:[:aBlock | |
1144 |
aBlock numVars == nV |
|
1145 |
]. |
|
1146 |
blocks size == 1 ifTrue:[ |
|
1147 |
^ blocks at:1 |
|
1148 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1149 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1150 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1151 |
"/ 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
|
1152 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1153 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1154 |
blocks do:[:aBlock | |
815 | 1155 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1156 |
innerBlock := aBlock. |
|
1157 |
maxSoFar := aBlock lineNumber |
|
1158 |
] |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1159 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1160 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1161 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1162 |
"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
|
1163 |
"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
|
1164 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1165 |
|
1365 | 1166 |
checkMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
629 | 1167 |
"parse a method in a given class. |
1168 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1169 |
The parser can be queried for selector, receiver, args, locals, |
|
1170 |
used selectors, modified instvars, referenced classvars etc. |
|
1171 |
The noErrors and noWarnings arguments specify if error and warning |
|
1172 |
messages should be sent to the Transcript or suppressed." |
|
1173 |
||
1174 |
|parser tree| |
|
1175 |
||
1176 |
aString isNil ifTrue:[^ nil]. |
|
1177 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1178 |
parser ignoreErrors:ignoreErrors. |
1179 |
parser ignoreWarnings:ignoreWarnings. |
|
629 | 1180 |
tree := parser parseMethod. |
1181 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1182 |
||
1183 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1184 |
||
1185 |
" |
|
1186 |
self |
|
1187 |
checkMethod:'foo |
|
1188 |
|local1 local2 local3| |
|
1189 |
||
1190 |
local1 := local2. |
|
1191 |
^ local3 |
|
1192 |
' |
|
1193 |
in:UndefinedObject |
|
1194 |
ignoreErrors:true |
|
1195 |
ignoreWarnings:true |
|
1196 |
" |
|
1197 |
||
1198 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1199 |
! |
|
1200 |
||
141 | 1201 |
parseExpression:aString |
1202 |
"parse aString as an expression; |
|
1203 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1204 |
or comment only) or #Error (syntactic error). |
1205 |
Error and warning messages are suppressed." |
|
141 | 1206 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1207 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1208 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1209 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1210 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1211 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1212 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1213 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1214 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1215 |
|
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 |
Parser parseExpression:'self foo' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1218 |
Parser parseExpression:'self:123' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1219 |
Parser parseExpression:'self:123' onError:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1220 |
" |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1221 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1222 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1223 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1224 |
"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
|
1225 |
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
|
1226 |
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
|
1227 |
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
|
1228 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1229 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1230 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1231 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1232 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1233 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1234 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1235 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1236 |
inNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1237 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1238 |
"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
|
1239 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1240 |
! |
1241 |
||
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1242 |
parseExpression:aString inNameSpace:aNameSpaceOrNil onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1243 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1244 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1245 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1246 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1247 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1248 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1249 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1250 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1251 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1252 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1253 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1254 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1255 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1256 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1257 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1258 |
"Created: 24.6.1997 / 16:44:26 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1259 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1260 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1261 |
parseExpression:aString onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1262 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1263 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1264 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1265 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1266 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1267 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1268 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1269 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1270 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1271 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1272 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1273 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1274 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1275 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1276 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1277 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1278 |
|
141 | 1279 |
parseMethod:aString |
1280 |
"parse a method. |
|
1281 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1282 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1283 |
used selectors etc. |
1284 |
Error and warning messages are sent to the Transcript." |
|
141 | 1285 |
|
1286 |
^ self parseMethod:aString in:nil |
|
1287 |
||
1288 |
" |
|
1289 |
|p| |
|
1290 |
||
1291 |
p := Parser |
|
1576 | 1292 |
parseMethod:' |
1293 |
foo:arg1 bar:arg2 baz:arg3 |
|
1294 |
|l1 l2| |
|
1295 |
l1 := 0. |
|
1296 |
l2 := arg1. |
|
1297 |
^ self'. |
|
141 | 1298 |
|
1299 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1300 |
'args: ' print. p methodArgs printNL. |
|
1301 |
'sel: ' print. p selector printNL. |
|
1302 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1303 |
'locals: ' print. p methodVars printNL. |
|
1304 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1305 |
" |
|
258 | 1306 |
|
1307 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1308 |
! |
1309 |
||
1310 |
parseMethod:aString in:aClass |
|
1311 |
"parse a method in a given class. |
|
1312 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1313 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1314 |
used selectors, modified instvars, referenced classvars etc. |
1315 |
Error and warning messages are sent to the Transcript." |
|
141 | 1316 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1317 |
^ self |
1576 | 1318 |
parseMethod:aString |
1319 |
in:aClass |
|
1320 |
ignoreErrors:false |
|
1321 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1322 |
|
258 | 1323 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1324 |
! |
1325 |
||
1365 | 1326 |
parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1327 |
"parse a method in a given class. |
2003 | 1328 |
Return a parser (if ok) or #Error (syntax). |
141 | 1329 |
The parser can be queried for selector, receiver, args, locals, |
258 | 1330 |
used selectors, modified instvars, referenced classvars etc. |
1331 |
The noErrors and noWarnings arguments specify if error and warning |
|
1332 |
messages should be sent to the Transcript or suppressed." |
|
2004
75094715335a
parseMethod: now always returns the parser
Claus Gittinger <cg@exept.de>
parents:
2003
diff
changeset
|
1333 |
|
75094715335a
parseMethod: now always returns the parser
Claus Gittinger <cg@exept.de>
parents:
2003
diff
changeset
|
1334 |
|parser| |
141 | 1335 |
|
1842 | 1336 |
parser := self new. |
2004
75094715335a
parseMethod: now always returns the parser
Claus Gittinger <cg@exept.de>
parents:
2003
diff
changeset
|
1337 |
parser parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings. |
141 | 1338 |
^ parser |
258 | 1339 |
|
2004
75094715335a
parseMethod: now always returns the parser
Claus Gittinger <cg@exept.de>
parents:
2003
diff
changeset
|
1340 |
"Modified: / 06-03-2007 / 18:33:39 / cg" |
141 | 1341 |
! |
1342 |
||
1343 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1344 |
"parse a method in a given class. |
|
1345 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1346 |
The parser can be queried for selector, receiver, args, locals, |
|
1347 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1348 |
The warnBoolean arguments specifies if warning |
1349 |
messages should be sent to the Transcript or suppressed. |
|
1350 |
||
1351 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1352 |
||
1353 |
self obsoleteMethodWarning. |
|
141 | 1354 |
^ self |
1576 | 1355 |
parseMethod:aString |
1356 |
in:aClass |
|
1357 |
ignoreErrors:false |
|
1358 |
ignoreWarnings:warnBoolean not |
|
258 | 1359 |
|
1360 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1361 |
! |
1362 |
||
1363 |
parseMethodArgAndVarSpecification:aString |
|
1364 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1365 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1366 |
The parser can be queried for selector, receiver etc. |
1367 |
Error and warning messages are sent to the Transcript. |
|
1368 |
This method is OBSOLETE." |
|
1369 |
||
1370 |
self obsoleteMethodWarning. |
|
141 | 1371 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1372 |
||
1373 |
" |
|
1374 |
|p| |
|
1375 |
||
1376 |
p := Parser |
|
1576 | 1377 |
parseMethodArgAndVarSpecification:' |
1378 |
foo:arg1 bar:arg2 baz:arg3 |
|
1379 |
|l1 l2|'. |
|
141 | 1380 |
|
1381 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1382 |
'args: ' print. p methodArgs printNL. |
|
1383 |
'sel: ' print. p selector printNL. |
|
1384 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1385 |
'locals: ' print. p methodVars printNL. |
|
1386 |
" |
|
258 | 1387 |
|
1388 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1389 |
! |
1390 |
||
1391 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1392 |
"parse a methods selector, arg and var spec in a given class; |
|
1393 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1394 |
The parser can be queried for selector, receiver, args and locals. |
1395 |
Error and warning messages are sent to the Transcript. |
|
1396 |
This method is OBSOLETE." |
|
1397 |
||
1398 |
self obsoleteMethodWarning. |
|
141 | 1399 |
^ self parseMethodArgAndVarSpecification:aString |
1576 | 1400 |
in:aClass |
1401 |
ignoreErrors:false |
|
1402 |
ignoreWarnings:false |
|
1403 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1404 |
|
258 | 1405 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1406 |
! |
1407 |
||
1365 | 1408 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings parseBody:body |
141 | 1409 |
"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
|
1410 |
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
|
1411 |
(for primitives & resourceSpecs). |
258 | 1412 |
The noErrors and noWarnings arguments specify if error and warning |
1413 |
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
|
1414 |
|
141 | 1415 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1416 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1417 |
|
0 | 1418 |
|parser| |
1419 |
||
141 | 1420 |
aString isNil ifTrue:[^ nil]. |
1421 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1422 |
parser ignoreErrors:ignoreErrors. |
1423 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1424 |
"/ parser nextToken. |
141 | 1425 |
(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
|
1426 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1427 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1428 |
"/ - 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
|
1429 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1430 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1431 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1432 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1433 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1434 |
]. |
141 | 1435 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1436 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1437 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1438 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1439 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1440 |
! |
1441 |
||
1442 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1443 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1444 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1445 |
The parser can be queried for selector, receiver etc. |
|
258 | 1446 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1447 |
display error/warning messages on the transcript." |
1448 |
||
1449 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1450 |
|
1451 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1452 |
! |
1453 |
||
1454 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1455 |
"parse a methods selector, arg and var spec in a given class; |
|
1456 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1457 |
The parser can be queried for selector, receiver, args and locals. |
|
1458 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1459 |
display error/warning messages on the transcript." |
|
1460 |
||
1461 |
^ self parseMethodArgAndVarSpecification:aString |
|
1576 | 1462 |
in:aClass |
1463 |
ignoreErrors:true |
|
1464 |
ignoreWarnings:true |
|
1465 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1466 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1467 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1468 |
! |
1469 |
||
1470 |
parseMethodSilent:aString |
|
1471 |
"parse a method. |
|
1472 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1473 |
The parser can be queried for selector, receiver, args, locals, |
|
1474 |
used selectors etc. |
|
258 | 1475 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1476 |
|
1477 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1478 |
|
1479 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1480 |
! |
1481 |
||
1482 |
parseMethodSilent:aString in:aClass |
|
1483 |
"parse a method in a given class. |
|
1484 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1485 |
The parser can be queried for selector, receiver, args, locals, |
|
1486 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1487 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1488 |
||
1489 |
^ self |
|
1576 | 1490 |
parseMethod:aString |
1491 |
in:aClass |
|
1492 |
ignoreErrors:true |
|
1493 |
ignoreWarnings:true |
|
258 | 1494 |
|
1495 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1496 |
! |
1497 |
||
1498 |
parseMethodSpecification:aString |
|
1499 |
"parse a methods selector & arg specification; |
|
1500 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1501 |
The parser can be queried for selector, receiver etc." |
|
1502 |
||
1503 |
^ self parseMethodSpecification:aString in:nil |
|
1504 |
||
1505 |
" |
|
1506 |
|p| |
|
1507 |
||
1508 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1509 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1510 |
'args: ' print. p methodArgs printNL. |
|
1511 |
'sel: ' print. p selector printNL |
|
1512 |
" |
|
1513 |
! |
|
1514 |
||
1515 |
parseMethodSpecification:aString in:aClass |
|
1516 |
"parse a methods selector & arg spec for a given class; |
|
1517 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1518 |
The parser can be queried for selector, receiver etc." |
|
1519 |
||
1520 |
^ self parseMethodSpecification:aString |
|
1576 | 1521 |
in:aClass |
1522 |
ignoreErrors:false |
|
1523 |
ignoreWarnings:false |
|
141 | 1524 |
! |
1525 |
||
1365 | 1526 |
parseMethodSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1527 |
"parse a methods selector & arg spec for a given class; |
1528 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1529 |
The parser can be queried for selector, receiver etc. |
|
1530 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1531 |
to be output onto the Transcript." |
|
1532 |
||
1533 |
|parser tree| |
|
1534 |
||
1535 |
aString isNil ifTrue:[^ nil]. |
|
1536 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1537 |
parser ignoreErrors:ignoreErrors. |
1538 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1539 |
"/ parser nextToken. |
141 | 1540 |
tree := parser parseMethodSpec. |
1541 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1542 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1543 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1544 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1545 |
! |
1546 |
||
1547 |
parseMethodSpecificationSilent:aString |
|
1548 |
"parse a methods selector & arg specification; |
|
1549 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1550 |
The parser can be queried for selector, receiver etc. |
|
1551 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1552 |
||
1553 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1554 |
! |
|
1555 |
||
1556 |
parseMethodSpecificationSilent:aString in:aClass |
|
1557 |
"parse a methods selector & arg spec for a given class; |
|
1558 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1559 |
The parser can be queried for selector, receiver etc. |
|
1560 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1561 |
||
1562 |
^ self parseMethodSpecification:aString |
|
1576 | 1563 |
in:aClass |
1564 |
ignoreErrors:true |
|
1565 |
ignoreWarnings:true |
|
141 | 1566 |
|
1567 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1568 |
! |
|
0 | 1569 |
|
7 | 1570 |
selectorInExpression:aString |
47 | 1571 |
"parse an expression - return the selector. Even malformed expressions |
1572 |
(such as missing receiver or missing arg are parsed. |
|
1573 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1574 |
Returns nil if unparsable." |
7 | 1575 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1576 |
|tree parser sel| |
7 | 1577 |
|
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1578 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1579 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1580 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1581 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1582 |
do:[ |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1583 |
tree := self withSelf:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1584 |
parseExpression:aString |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1585 |
notifying:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1586 |
ignoreErrors:true |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1587 |
ignoreWarnings:true. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1588 |
]. |
21 | 1589 |
|
1590 |
" |
|
1591 |
special: take the expression of the right side, if its an |
|
1592 |
assignment or return |
|
1593 |
" |
|
7 | 1594 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1595 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1596 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1597 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1598 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1599 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1600 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1601 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1602 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1603 |
]. |
7 | 1604 |
]. |
1605 |
||
21 | 1606 |
" |
1607 |
mhmh, try expression without receiver |
|
1608 |
" |
|
7 | 1609 |
parser := self for:(ReadStream on:aString). |
1365 | 1610 |
parser ignoreErrors:true. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1611 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1612 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1613 |
do:[ |
1482
d80c83f1167a
catch twoByte string parsing in selectorInExpression
Claus Gittinger <cg@exept.de>
parents:
1471
diff
changeset
|
1614 |
parser nextToken. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1615 |
sel := parser degeneratedKeywordExpressionForSelector |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1616 |
]. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1617 |
^ sel |
7 | 1618 |
|
1619 |
" |
|
20 | 1620 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1621 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1622 |
Parser selectorInExpression:'a + 4' |
1623 |
Parser selectorInExpression:'a negated' |
|
20 | 1624 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1625 |
Parser selectorInExpression:'at:1 put:' |
1626 |
Parser selectorInExpression:'a at:1 put:5' |
|
1627 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1628 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1629 |
" |
451 | 1630 |
|
1631 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1632 |
! |
1633 |
||
1634 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1635 |
"parse aString as an expression with self set to anObject; |
|
21 | 1636 |
Return the parseTree (if ok), nil (for an empty string |
1637 |
or comment only ) or #Error (syntactic error). |
|
1638 |
||
1639 |
Errors and warnings are forwarded to someOne (usually some |
|
1640 |
codeView) which can highlight it and show a popup box." |
|
7 | 1641 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1642 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1643 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1644 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1645 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1646 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1647 |
ignoreErrors:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1648 |
ignoreWarnings:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1649 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1650 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1651 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1652 |
! |
1653 |
||
1654 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1655 |
"parse aString as an expression with self set to anObject; |
21 | 1656 |
Return the parseTree (if ok), nil (for an empty string |
1657 |
or comment only ) or #Error (syntactic error). |
|
1658 |
||
1659 |
Errors and warnings are forwarded to someOne (usually some |
|
1660 |
codeView) which can highlight it and show a popup box." |
|
1661 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1662 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1663 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1664 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1665 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1666 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1667 |
ignoreErrors:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1668 |
ignoreWarnings:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1669 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1670 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1671 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1672 |
! |
1673 |
||
1674 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1675 |
"parse aString as an expression with self set to anObject; |
|
1676 |
Return the parseTree (if ok), nil (for an empty string |
|
1677 |
or comment only ) or #Error (syntactic error). |
|
1678 |
||
1679 |
Errors and warnings are forwarded to someOne (usually some |
|
1680 |
codeView) which can highlight it and show a popup box, |
|
1681 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1682 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1683 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1684 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1685 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1686 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1687 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1688 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1689 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1690 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1691 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1692 |
"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
|
1693 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1694 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1695 |
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
|
1696 |
"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
|
1697 |
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
|
1698 |
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
|
1699 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1700 |
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
|
1701 |
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
|
1702 |
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
|
1703 |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1704 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1705 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1706 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1707 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1708 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1709 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1710 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1711 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1712 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1713 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1714 |
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
|
1715 |
"parse aString as an expression with self set to anObject; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1716 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1717 |
or comment only ) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1718 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1719 |
Errors and warnings are forwarded to someOne (usually some |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1720 |
codeView) which can highlight it and show a popup box, |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1721 |
iff ignoreErrors/ignoreWarnings is true respectively." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1722 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1723 |
|parser tree| |
0 | 1724 |
|
1725 |
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
|
1726 |
|
0 | 1727 |
parser := self for:(ReadStream on:aString). |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1728 |
tree := parser |
1006 | 1729 |
parseExpressionWithSelf:anObject |
1730 |
notifying:someOne |
|
1731 |
ignoreErrors:ignoreErrors |
|
1732 |
ignoreWarnings:ignoreWarnings |
|
1733 |
inNameSpace:aNameSpaceOrNil. |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1734 |
tree == #Error ifTrue:[ |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1735 |
^ errorValue value |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1736 |
]. |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1737 |
^ tree |
1006 | 1738 |
|
1739 |
"Modified: / 14.12.1999 / 15:12:16 / cg" |
|
0 | 1740 |
! ! |
1741 |
||
1621 | 1742 |
!Parser class methodsFor:'private'! |
1743 |
||
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1744 |
implementedInAnyClass:aSelectorStringOrSymbol |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1745 |
|selectorSymbol| |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1746 |
|
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1747 |
selectorSymbol := aSelectorStringOrSymbol asSymbolIfInterned. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1748 |
selectorSymbol isNil ifTrue:[^ false]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1749 |
|
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1750 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1751 |
(cls includesSelector:selectorSymbol) ifTrue:[^ true]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1752 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1753 |
^ false |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1754 |
|
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1755 |
"Modified: / 22-10-2006 / 02:25:37 / cg" |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1756 |
! |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
1757 |
|
1621 | 1758 |
makeImmutableArray:anArray |
1759 |
|newArray| |
|
1760 |
||
1761 |
newArray := anArray copy. |
|
1762 |
ImmutableArray notNil ifTrue:[ |
|
1763 |
newArray changeClassTo:ImmutableArray. |
|
1764 |
]. |
|
1765 |
newArray beImmutable. |
|
1766 |
^ newArray |
|
1767 |
! |
|
1768 |
||
1769 |
makeImmutableString:aString |
|
1770 |
|newString| |
|
1771 |
||
1772 |
newString := aString copy. |
|
1773 |
ImmutableString notNil ifTrue:[ |
|
1774 |
newString changeClassTo:ImmutableString. |
|
1775 |
]. |
|
1776 |
newString beImmutable. |
|
1777 |
^ newString |
|
1778 |
! ! |
|
1779 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1780 |
!Parser class methodsFor:'unparsing'! |
20 | 1781 |
|
1782 |
methodSpecificationForSelector:aSelector |
|
1783 |
"given a selector such as #foo:bar:, return a string that could |
|
1784 |
serve as a methods specification source code. |
|
1785 |
To be used for code generators" |
|
1786 |
||
807 | 1787 |
|argNames n| |
1788 |
||
1789 |
n := aSelector numArgs. |
|
1790 |
n == 1 ifTrue:[ |
|
1791 |
argNames := #('arg') |
|
1792 |
] ifFalse:[ |
|
1793 |
n <= 15 ifTrue:[ |
|
1794 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1795 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1796 |
'arg13' 'arg14' 'arg15') |
|
1797 |
] ifFalse:[ |
|
1798 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1799 |
]. |
|
1800 |
]. |
|
1801 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1802 |
||
20 | 1803 |
" |
807 | 1804 |
Parser methodSpecificationForSelector:#foo: |
20 | 1805 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1806 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1807 |
Parser methodSpecificationForSelector:#+ |
20 | 1808 |
Parser methodSpecificationForSelector:#negated |
1809 |
" |
|
807 | 1810 |
|
1811 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1812 |
! |
1813 |
||
1814 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1815 |
"given a selector such as #foo:bar:, return a string that could |
|
1816 |
serve as a methods specification source code. |
|
1817 |
To be used for code generators" |
|
1818 |
||
806 | 1819 |
|s nargs parts part| |
20 | 1820 |
|
1821 |
s := WriteStream on:String new. |
|
44 | 1822 |
nargs := aSelector numArgs. |
20 | 1823 |
nargs == 0 ifTrue:[ |
806 | 1824 |
s nextPutAll:aSelector |
20 | 1825 |
] ifFalse:[ |
806 | 1826 |
parts := aSelector partsIfSelector. |
1827 |
1 to:nargs do:[:i | |
|
1828 |
part := parts at:i. |
|
1829 |
s nextPutAll:part. |
|
1830 |
(part endsWith:$:) ifFalse:[ |
|
1831 |
s space. |
|
1832 |
]. |
|
1833 |
s nextPutAll:(argNames at:i). |
|
1834 |
i ~~ nargs ifTrue:[s space]. |
|
1835 |
] |
|
20 | 1836 |
]. |
1837 |
^ s contents |
|
1838 |
||
1839 |
" |
|
1840 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1841 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1842 |
Parser methodSpecificationForSelector:#negated |
|
1843 |
" |
|
806 | 1844 |
|
1845 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1846 |
! ! |
1847 |
||
1417 | 1848 |
!Parser methodsFor:'Compatibility-ST80'! |
0 | 1849 |
|
918 | 1850 |
evaluate:aString in:aClassOrContext to:to notifying:aRequestor ifFail:failBlock |
35 | 1851 |
|parseTree value| |
0 | 1852 |
|
1853 |
aString isNil ifTrue:[^ nil]. |
|
1854 |
self initializeFor:(ReadStream on:aString). |
|
918 | 1855 |
|
1856 |
"/ stupid - there seem to be differences among the various |
|
1857 |
"/ ST dialects ... |
|
1858 |
aClassOrContext isBehavior ifTrue:[ |
|
1859 |
self setClassToCompileFor:aClassOrContext. |
|
1860 |
selfValue := nil. |
|
1861 |
] ifFalse:[ |
|
1862 |
self setContext:aClassOrContext. |
|
1863 |
aClassOrContext notNil ifTrue:[ |
|
1864 |
self setSelf:(aClassOrContext receiver) |
|
1865 |
]. |
|
1866 |
]. |
|
0 | 1867 |
requestor := aRequestor. |
1868 |
||
1869 |
self nextToken. |
|
1870 |
parseTree := self parseMethodBody. |
|
1871 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1872 |
parseTree notNil ifTrue:[ |
|
918 | 1873 |
self evalExitBlock:[:value | ^ failBlock value]. |
1874 |
value := parseTree evaluate |
|
0 | 1875 |
]. |
35 | 1876 |
self release. |
1877 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1878 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1879 |
|
624 | 1880 |
parse:methodSource in:aClass notifying:aRequestor |
1881 |
"parse a methods source. |
|
1882 |
Return the methods parseTree" |
|
1883 |
||
1884 |
self initializeFor:methodSource. |
|
1885 |
classToCompileFor := aClass. |
|
1886 |
requestor := aRequestor. |
|
1887 |
self parseMethod. |
|
918 | 1888 |
|
624 | 1889 |
^ MethodNode new |
1890 |
selector:selector |
|
1891 |
arguments:methodArgs |
|
1892 |
locals:methodVars |
|
1207 | 1893 |
statements:tree asCollectionOfStatements |
624 | 1894 |
|
1214 | 1895 |
"Created: / 17.10.1997 / 12:35:01 / cg" |
1896 |
"Modified: / 5.11.2001 / 16:56:43 / cg" |
|
624 | 1897 |
! |
1898 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1899 |
parseSelector:aStringOrStream |
624 | 1900 |
"parse a methods source for the methods selector. |
1901 |
Return the selector" |
|
1902 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1903 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1904 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1905 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1906 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1907 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1908 |
Parser new |
624 | 1909 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1910 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1911 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1912 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1913 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1914 |
' |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1915 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1916 |
|
624 | 1917 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1918 |
! ! |
1919 |
||
44 | 1920 |
!Parser methodsFor:'accessing'! |
1921 |
||
2108 | 1922 |
allowUndeclaredVariables:something |
1923 |
allowUndeclaredVariables := something. |
|
1924 |
! |
|
1925 |
||
44 | 1926 |
correctedSource |
1927 |
^ correctedSource |
|
1928 |
! |
|
1929 |
||
1605
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1930 |
doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1931 |
^ doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1932 |
! |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1933 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1934 |
endOfLastToken |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1935 |
^ tokenPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1936 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1937 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1938 |
endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1939 |
"return the sourcePosition of the last character of the methods selector spec" |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1940 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1941 |
^ endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1942 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1943 |
|
141 | 1944 |
errorFlag |
1945 |
"return true if there where any errors (valid after parsing)" |
|
1946 |
||
1947 |
^ errorFlag |
|
1948 |
! |
|
1949 |
||
1950 |
evalExitBlock:aBlock |
|
1951 |
"when evaluating a return expression, this block is evaluated" |
|
1952 |
||
1953 |
evalExitBlock := aBlock |
|
1954 |
! |
|
1955 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1956 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1957 |
"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
|
1958 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1959 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1960 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1961 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1962 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1963 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1964 |
implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1965 |
^ parserFlags implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1966 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1967 |
|
1571 | 1968 |
implicitSelfSends:aBoolean |
1969 |
"turn on/off implicit self sends" |
|
1970 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1971 |
parserFlags implicitSelfSends:aBoolean |
1571 | 1972 |
! |
1973 |
||
2063 | 1974 |
moreSharedPools |
1975 |
^ moreSharedPools |
|
1976 |
! |
|
1977 |
||
2062 | 1978 |
moreSharedPools:aCollection |
1979 |
moreSharedPools := aCollection |
|
1980 |
! |
|
1981 |
||
19 | 1982 |
primitiveNumber |
1983 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1984 |
||
1985 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1986 |
! |
97 | 1987 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1988 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1989 |
"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
|
1990 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1991 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1992 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1993 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1994 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1995 |
|
35 | 1996 |
release |
664 | 1997 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1998 |
super release. |
664 | 1999 |
|
2000 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 2001 |
! |
2002 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
2003 |
setNameSpace:aNameSpaceName |
2106 | 2004 |
currentNamespace := aNameSpaceName isString |
2005 |
ifTrue:[ NameSpace fullName:aNameSpaceName ] |
|
2006 |
ifFalse:[ aNameSpaceName ]. |
|
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
2007 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
2008 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
2106 | 2009 |
|
2010 |
||
2011 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
2012 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
2013 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
2014 |
setPackage:aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
2015 |
currentPackage := aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
2016 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
2017 |
|
141 | 2018 |
targetClass |
2019 |
^ classToCompileFor |
|
2020 |
! |
|
2021 |
||
90 | 2022 |
targetClass:aClass |
117 | 2023 |
classToCompileFor := aClass |
2024 |
! |
|
2025 |
||
141 | 2026 |
tree |
2027 |
"return the parsetree" |
|
2028 |
||
2029 |
^tree |
|
2030 |
! |
|
2031 |
||
2032 |
tree:aTree |
|
2033 |
"private: set the tree - for internal use only" |
|
2034 |
||
2035 |
tree := aTree |
|
1363 | 2036 |
! |
2037 |
||
2038 |
warnSTXHereExtensionUsed |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2039 |
^ parserFlags warnSTXHereExtensionUsed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2040 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2041 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2042 |
warnSTXHereExtensionUsed:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2043 |
parserFlags warnSTXHereExtensionUsed:aBoolean |
141 | 2044 |
! ! |
2045 |
||
2085
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2046 |
!Parser methodsFor:'coding style checks'! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2047 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2048 |
checkBlockArgumentNameConventionsFor:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2049 |
self shouldPerformCodingStyleChecks ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2050 |
self checkLocalVariableNameConventionsFor:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2051 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2052 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2053 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2054 |
checkBlockVariableNameConventionsFor:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2055 |
self shouldPerformCodingStyleChecks ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2056 |
self checkLocalVariableNameConventionsFor:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2057 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2058 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2059 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2060 |
checkForLowercaseVariableName:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2061 |
|msg| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2062 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2063 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2064 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2065 |
aVariableName isUppercaseFirst ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2066 |
msg := ('variable "' , aVariableName , '" should be lowercase (by convention)'). |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2067 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2068 |
warning:msg |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2069 |
doNotShowAgainAction:[ ParserFlags warnAboutNonLowercaseLocalVariableNames:false] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2070 |
position:tokenPosition to:source position1Based - 1. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2071 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2072 |
Tools::ToDoListBrowser notNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2073 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2074 |
notifyTodo:msg position:tokenPosition |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2075 |
className:(self classToCompileFor name) selector:selector |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2076 |
severity:#warning priority:#medium |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2077 |
equalityParameter:nil |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2078 |
checkAction:nil. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2079 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2080 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2081 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2082 |
"Modified: / 18-10-2006 / 19:38:20 / cg" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2083 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2084 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2085 |
checkForProperUseOfArticleInVariableName:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2086 |
|soundsLikeVowel firstCharacterAfterArticle rest whatShouldItBeNamed msg| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2087 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2088 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2089 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2090 |
soundsLikeVowel := [:word | |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2091 |
|soundsLikeVowel firstCharacter| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2092 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2093 |
soundsLikeVowel := false. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2094 |
firstCharacter := word first. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2095 |
('AEIX' includes:firstCharacter) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2096 |
soundsLikeVowel := true. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2097 |
] ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2098 |
firstCharacter := word first. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2099 |
"/ U and H sound like a vowel, if followed by two more non-vowels |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2100 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2101 |
('UH' includes:firstCharacter) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2102 |
word size > 2 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2103 |
(word at:2) isVowel ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2104 |
(word at:3) isVowel ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2105 |
soundsLikeVowel := true. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2106 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2107 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2108 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2109 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2110 |
"/ O sound like a vowel, if not followed by 'ne' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2111 |
('O' includes:firstCharacter) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2112 |
word size > 2 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2113 |
(word copyTo:3) asLowercase = 'one' ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2114 |
soundsLikeVowel := true. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2115 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2116 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2117 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2118 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2119 |
soundsLikeVowel. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2120 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2121 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2122 |
aVariableName size > 4 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2123 |
(aVariableName startsWith:'an') ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2124 |
firstCharacterAfterArticle := aVariableName at:3. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2125 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2126 |
rest := aVariableName copyFrom:3. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2127 |
(soundsLikeVowel value:rest) ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2128 |
whatShouldItBeNamed := 'a' , rest. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2129 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2130 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2131 |
] ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2132 |
(aVariableName startsWith:'a') ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2133 |
firstCharacterAfterArticle := aVariableName at:2. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2134 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2135 |
rest := aVariableName copyFrom:2. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2136 |
(soundsLikeVowel value:rest) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2137 |
whatShouldItBeNamed := 'an' , rest. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2138 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2139 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2140 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2141 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2142 |
whatShouldItBeNamed notNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2143 |
"/ self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2144 |
"/ warnCommonMistake:('variable "',aVariableName,'" should be named "',whatShouldItBeNamed,'" (by english language rules)') |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2145 |
"/ position:tokenPosition to:source position1Based - 1. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2146 |
msg := ('variable "',aVariableName,'" should be named "',whatShouldItBeNamed,'" (by english language rules)'). |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2147 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2148 |
warning:msg |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2149 |
doNotShowAgainAction:[ ParserFlags warnAboutWrongVariableNames:false] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2150 |
position:tokenPosition to:source position1Based - 1. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2151 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2152 |
Tools::ToDoListBrowser notNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2153 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2154 |
notifyTodo:msg position:tokenPosition |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2155 |
className:(self classToCompileFor name) selector:selector |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2156 |
severity:#warning priority:#low |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2157 |
equalityParameter:nil |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2158 |
checkAction:nil. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2159 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2160 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2161 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2162 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2163 |
"Modified: / 18-10-2006 / 19:41:00 / cg" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2164 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2165 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2166 |
checkLocalVariableNameConventionsFor:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2167 |
|msg| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2168 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2169 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2170 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2171 |
parserFlags warnAboutVariableNameConventions == true ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2172 |
parserFlags warnAboutNonLowercaseLocalVariableNames == true ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2173 |
self checkForLowercaseVariableName:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2174 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2175 |
parserFlags warnAboutShortLocalVariableNames == true ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2176 |
aVariableName size <= 2 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2177 |
(#( |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2178 |
'x' 'y' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2179 |
) includes:aVariableName) |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2180 |
ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2181 |
msg := ('short variable name: "' , aVariableName , '"'). |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2182 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2183 |
warning:('short variable name: "' , aVariableName , '"') |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2184 |
doNotShowAgainAction:[ ParserFlags warnAboutShortLocalVariableNames:false] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2185 |
position:tokenPosition to:source position1Based - 1. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2186 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2187 |
Tools::ToDoListBrowser notNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2188 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2189 |
notifyTodo:msg position:tokenPosition |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2190 |
className:(self classToCompileFor name) selector:selector |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2191 |
severity:#warning priority:#medium |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2192 |
equalityParameter:nil |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2193 |
checkAction:nil. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2194 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2195 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2196 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2197 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2198 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2199 |
parserFlags warnAboutWrongVariableNames == true ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2200 |
self checkForProperUseOfArticleInVariableName:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2201 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2202 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2203 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2204 |
checkMethodArgumentNameConventionsFor:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2205 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2206 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2207 |
self checkLocalVariableNameConventionsFor:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2208 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2209 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2210 |
checkMethodVariableNameConventionsFor:aVariableName |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2211 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2212 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2213 |
self checkLocalVariableNameConventionsFor:aVariableName. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2214 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2215 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2216 |
checkReturnedValues |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2217 |
| returnsSelf returnsBoolean returnsNonBooleanLiteral| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2218 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2219 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2220 |
parserFlags warnInconsistentReturnValues ifFalse:[^ self]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2221 |
returnedValues isNil ifTrue:[^ self]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2222 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2223 |
returnsBoolean := returnedValues contains:[:node | node isConstant and:[node value isBoolean]]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2224 |
returnsNonBooleanLiteral := returnedValues contains:[:node | node isConstant and:[node value isBoolean not]]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2225 |
returnsSelf := returnedValues contains:[:node | node isSelf]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2226 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2227 |
returnsBoolean ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2228 |
(returnsNonBooleanLiteral or:[returnsSelf]) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2229 |
self |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2230 |
warning:'Possible Error Warning:\\Method returns both boolean and non-boolean values.' withCRs |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2231 |
doNotShowAgainAction:[ ParserFlags warnInconsistentReturnValues:false ] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2232 |
position:1 to:tokenPosition |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2233 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2234 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2235 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2236 |
"Created: / 17.11.2001 / 10:31:03 / cg" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2237 |
"Modified: / 17.11.2001 / 10:34:16 / cg" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2238 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2239 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2240 |
checkSelector:selector for:receiver inClass:cls |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2241 |
"check whether a method with selector exists in class cls and |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2242 |
that the method is not obsolete. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2243 |
If cls is nil, check all classes for the selector. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2244 |
Return an error string on error or nil on success" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2245 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2246 |
|err mthd implementor implementors allowed| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2247 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2248 |
self shouldPerformCodingStyleChecks ifFalse:[^ nil ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2249 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2250 |
cls isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2251 |
SystemBrowser isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2252 |
^ nil |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2253 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2254 |
"beware, this is sort of slow, especially for the SyntaxHighlighter" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2255 |
implementors := SystemBrowser |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2256 |
findImplementorsOf:selector |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2257 |
in:(Smalltalk allClasses) |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2258 |
ignoreCase:false. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2259 |
implementors size == 0 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2260 |
^ 'is nowhere implemented' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2261 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2262 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2263 |
(implementors conform:[:eachMethod| eachMethod isObsolete]) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2264 |
^ 'each implementation of this selector in the system is deprecated' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2265 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2266 |
^ nil |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2267 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2268 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2269 |
mthd := cls lookupMethodFor:selector. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2270 |
mthd isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2271 |
cls isBehavior ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2272 |
cls isMeta ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2273 |
mthd := Metaclass lookupMethodFor:selector. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2274 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2275 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2276 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2277 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2278 |
mthd isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2279 |
cls == Boolean ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2280 |
mthd := True compiledMethodAt:selector. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2281 |
mthd isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2282 |
mthd := False compiledMethodAt:selector. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2283 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2284 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2285 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2286 |
mthd isNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2287 |
"if it implements #doesNotUnderstand somewhere, assume it is ok" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2288 |
implementor := cls whichClassIncludesSelector:#doesNotUnderstand:. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2289 |
"/ (implementor isNil or:[implementor == Object]) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2290 |
err := 'is not implemented in ' , cls name allBold |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2291 |
"/ ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2292 |
] ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2293 |
(mthd sends:#shouldNotImplement) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2294 |
mthd messagesSent size == 1 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2295 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2296 |
allowed ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2297 |
err := 'is not (should not be) implemented' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2298 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2299 |
] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2300 |
] ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2301 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2302 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2303 |
allowed ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2304 |
"methods in abstract classes may send messages to abstract methods in meta class" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2305 |
(cls == classToCompileFor class) ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2306 |
allowed := receiver isMessage and:[receiver selector = 'class'] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2307 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2308 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2309 |
allowed ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2310 |
"/ not from cg to stefan: thats wrong - if not implemented in all subclasses, |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2311 |
"/ its a bug of the subclass not a bug here - that message send here |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2312 |
"/ is perfectly correct. (it is very annoying for a framework developped to get |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2313 |
"/ error messages for bugs which are not his... |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2314 |
"/ (self checkIfAllSubclassesOf:cls implement:selector) ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2315 |
"/ "if not all subclasses implement the selector - this is a possible bug" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2316 |
"/ allowed := false |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2317 |
"/ ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2318 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2319 |
allowed ifFalse:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2320 |
err := 'is subclassResponsibility' |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2321 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2322 |
] ifFalse:[mthd isObsolete ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2323 |
err := 'is deprecated'. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2324 |
]] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2325 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2326 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2327 |
^ err. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2328 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2329 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2330 |
checkUnusedMethodVars |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2331 |
| unused| |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2332 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2333 |
self shouldPerformCodingStyleChecks ifFalse:[^ self ]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2334 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2335 |
methodVars notNil ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2336 |
unused := methodVars select:[:var| var used ~~ true] thenCollect:[:var| var name]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2337 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2338 |
unused size > 0 ifTrue:[ |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2339 |
self warnUnused:unused. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2340 |
]. |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2341 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2342 |
"Created: / 17.11.2001 / 10:23:47 / cg" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2343 |
! ! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
2344 |
|
1418 | 2345 |
!Parser methodsFor:'dummy-syntax detection'! |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2346 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2347 |
markArgumentIdentifierFrom:pos1 to:pos2 |
1525 | 2348 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2349 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2350 |
|
883 | 2351 |
markBadIdentifierFrom:pos1 to:pos2 |
1525 | 2352 |
"intentionally left empty" |
883 | 2353 |
! |
2354 |
||
2054 | 2355 |
markBlockFrom:startPos to:endPos |
2356 |
"intentionally left empty" |
|
2357 |
||
2358 |
"Created: / 15-01-2008 / 11:51:35 / cg" |
|
2359 |
! |
|
2360 |
||
663 | 2361 |
markBooleanConstantFrom:pos1 to:pos2 |
1525 | 2362 |
"intentionally left empty" |
663 | 2363 |
! |
2364 |
||
673 | 2365 |
markBracketAt:pos |
1525 | 2366 |
"intentionally left empty" |
673 | 2367 |
! |
2368 |
||
663 | 2369 |
markConstantFrom:pos1 to:pos2 |
1525 | 2370 |
"intentionally left empty" |
663 | 2371 |
! |
2372 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2373 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
1525 | 2374 |
"intentionally left empty" |
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2375 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2376 |
|
663 | 2377 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1525 | 2378 |
"intentionally left empty" |
663 | 2379 |
! |
2380 |
||
2381 |
markHereFrom:pos1 to:pos2 |
|
1525 | 2382 |
"intentionally left empty" |
663 | 2383 |
! |
2384 |
||
2385 |
markIdentifierFrom:pos1 to:pos2 |
|
1525 | 2386 |
"intentionally left empty" |
663 | 2387 |
! |
2388 |
||
687 | 2389 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1525 | 2390 |
"intentionally left empty" |
687 | 2391 |
! |
2392 |
||
663 | 2393 |
markLocalIdentifierFrom:pos1 to:pos2 |
1525 | 2394 |
"intentionally left empty" |
663 | 2395 |
! |
2396 |
||
2397 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1525 | 2398 |
"intentionally left empty" |
663 | 2399 |
! |
2400 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2401 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2402 |
"intentionally left empty" |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2403 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2404 |
|
837 | 2405 |
markReturnAt:pos |
1525 | 2406 |
"intentionally left empty" |
837 | 2407 |
! |
2408 |
||
864 | 2409 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
1525 | 2410 |
"intentionally left empty" |
864 | 2411 |
! |
2412 |
||
663 | 2413 |
markSelfFrom:pos1 to:pos2 |
1525 | 2414 |
"intentionally left empty" |
663 | 2415 |
! |
2416 |
||
2417 |
markSuperFrom:pos1 to:pos2 |
|
1525 | 2418 |
"intentionally left empty" |
664 | 2419 |
! |
2420 |
||
2421 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
1525 | 2422 |
"intentionally left empty" |
687 | 2423 |
! |
2424 |
||
2425 |
markVariable:v |
|
1525 | 2426 |
"intentionally left empty" |
687 | 2427 |
! |
2428 |
||
2429 |
markVariable:v from:pos1 to:pos2 |
|
1525 | 2430 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2431 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2432 |
|
141 | 2433 |
!Parser methodsFor:'error correction'! |
2434 |
||
1295 | 2435 |
addDoItTemporary:varName |
2436 |
|holder| |
|
2437 |
||
2438 |
doItTemporaries isNil ifTrue:[ |
|
2439 |
doItTemporaries := IdentityDictionary new. |
|
2440 |
]. |
|
2441 |
doItTemporaries at:varName asSymbol put:(holder := ValueHolder new). |
|
2442 |
^ holder |
|
2443 |
! |
|
2444 |
||
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2445 |
alreadyWarnedUnimplementedSelectors |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2446 |
alreadyWarnedUnimplementedSelectors isNil ifTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2447 |
alreadyWarnedUnimplementedSelectors := Set new |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2448 |
]. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2449 |
^ alreadyWarnedUnimplementedSelectors |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2450 |
! |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2451 |
|
141 | 2452 |
askForCorrection:aString fromList:aList |
2453 |
"launch a selection box, which allows user to enter correction. |
|
2454 |
return newString or nil (for abort)" |
|
2455 |
||
1323 | 2456 |
|box rslt| |
141 | 2457 |
|
2458 |
"in systems without widgets ..." |
|
2459 |
ListSelectionBox isNil ifTrue:[ |
|
1285 | 2460 |
^ self confirm:aString |
141 | 2461 |
]. |
2462 |
box := ListSelectionBox title:aString. |
|
2463 |
box initialText:(aList at:1). |
|
2464 |
box list:aList. |
|
1285 | 2465 |
box okText:'Correct'. |
1323 | 2466 |
box action:[:aString | rslt := aString]. |
141 | 2467 |
box showAtPointer. |
1323 | 2468 |
box destroy. |
2469 |
^ rslt |
|
2470 |
! |
|
2471 |
||
2472 |
askForCorrection:aString fromList:aList for:originalSelector |
|
2473 |
"launch a selection box, which allows user to enter correction. |
|
2474 |
return newString or nil (for abort)" |
|
2475 |
||
2476 |
|box rslt| |
|
2477 |
||
2478 |
"in systems without widgets ..." |
|
2479 |
ListSelectionBox isNil ifTrue:[ |
|
2480 |
^ self confirm:aString |
|
2481 |
]. |
|
2482 |
box := ListSelectionBox title:aString. |
|
2483 |
box initialText:(aList at:1). |
|
2484 |
box list:aList. |
|
2485 |
box okText:'Correct'. |
|
2486 |
box action:[:aString | rslt := aString]. |
|
2487 |
box addButton:(Button label:'Keep Selector' action:[rslt := originalSelector. box hide]) after:(box okButton). |
|
2488 |
box showAtPointer. |
|
2489 |
box destroy. |
|
2490 |
^ rslt |
|
141 | 2491 |
! |
2492 |
||
1295 | 2493 |
askForVariableTypeWhenDeclaringUndefined:varName |
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2494 |
|l how varNameIsLowercase choice holder newClass owningClass| |
1295 | 2495 |
|
2496 |
l := #(). |
|
2497 |
how := #(). |
|
2498 |
||
2499 |
varNameIsLowercase := (varName at:1) isLowercase. |
|
2500 |
||
2501 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
|
2502 |
varNameIsLowercase ifTrue:[ |
|
2503 |
"/ currentBlock notNil ifTrue:[ |
|
2504 |
"/ l := l , #( 'Block local' ). |
|
2505 |
"/ how := how , #( BlockVariable ). |
|
2506 |
"/ ]. |
|
2507 |
selector notNil ifTrue:[ |
|
2508 |
l := l , #( 'Method Local Variable' ). |
|
2509 |
how := how , #( MethodVariable ). |
|
2510 |
]. |
|
2511 |
(classToCompileFor notNil |
|
2512 |
and:[classToCompileFor isMeta not |
|
2513 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2514 |
and:[(self isDoIt not)]]]) ifTrue:[ |
1295 | 2515 |
l := l copyWith:'Instance Variable'. |
2516 |
how := how copyWith: #InstanceVariable. |
|
2517 |
]. |
|
2518 |
] ifFalse:[ |
|
2519 |
l := l , #( 'New Class' 'Global' 'NameSpace' ). |
|
2520 |
how := how , #( NewClass GlobalVariable NameSpace ). |
|
2521 |
||
2522 |
(classToCompileFor notNil |
|
2523 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2524 |
and:[self isDoIt not]]) ifTrue:[ |
1295 | 2525 |
classToCompileFor isMeta ifTrue:[ |
2526 |
l := l , #('Class Instance Variable'). |
|
2527 |
how := how , #( ClassInstanceVariable). |
|
2528 |
]. |
|
2529 |
l := l , #('Class Variable' ). |
|
2530 |
how := how , #( ClassVariable). |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2531 |
l := l , #('Private Class' ). |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2532 |
how := how , #( PrivateClass). |
1295 | 2533 |
] |
2534 |
]. |
|
1440 | 2535 |
self isDoIt ifTrue:[ |
1295 | 2536 |
l size > 0 ifTrue:[ |
2537 |
l := l , #( '-' ). |
|
2538 |
how := how , #( nil ). |
|
2539 |
]. |
|
2540 |
l := l , #( 'Workspace Variable' 'DoIt Temporary'). |
|
2541 |
how := how , #( WorkspaceVariable DoItTemporary ). |
|
2542 |
]. |
|
2543 |
||
2544 |
l size > 0 ifTrue:[ |
|
2545 |
l := (Array with:('Declare ' , varName allBold , ' as:') |
|
2546 |
with:'-' |
|
2547 |
) , l. |
|
2548 |
how := #(nil nil) , how. |
|
2549 |
choice := (PopUpMenu labels:l) startUp. |
|
2550 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2551 |
choice := how at:choice. |
|
2552 |
||
2553 |
choice == #WorkspaceVariable ifTrue:[ |
|
2554 |
holder := Workspace addWorkspaceVariable:varName. |
|
2555 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2556 |
]. |
|
2557 |
choice == #DoItTemporary ifTrue:[ |
|
2558 |
holder := self addDoItTemporary:varName. |
|
2559 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
2560 |
]. |
|
2561 |
||
2562 |
choice == #GlobalVariable ifTrue:[ |
|
2563 |
Smalltalk at:varName asSymbol put:nil. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2564 |
^ VariableNode globalNamed:varName |
1295 | 2565 |
]. |
2566 |
||
2567 |
choice == #NewClass ifTrue:[ |
|
2568 |
newClass := Object subclass:varName asSymbol |
|
2569 |
instanceVariableNames:'' |
|
2570 |
classVariableNames:'' |
|
2571 |
poolDictionaries:'' |
|
2572 |
category:'* As yet uncategorized *'. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2573 |
^ VariableNode globalNamed:newClass name |
1295 | 2574 |
]. |
2575 |
||
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2576 |
choice == #PrivateClass ifTrue:[ |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2577 |
owningClass := classToCompileFor theNonMetaclass. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2578 |
newClass := Object subclass:varName asSymbol |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2579 |
instanceVariableNames:'' |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2580 |
classVariableNames:'' |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2581 |
poolDictionaries:'' |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2582 |
privateIn:owningClass. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2583 |
^ VariableNode type:#PrivateClass class:owningClass name:newClass name |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2584 |
]. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2585 |
|
1295 | 2586 |
choice == #NameSpace ifTrue:[ |
2587 |
NameSpace name:varName. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2588 |
^ VariableNode globalNamed:varName |
1295 | 2589 |
]. |
2590 |
||
2591 |
choice == #ClassVariable ifTrue:[ |
|
2592 |
classToCompileFor theNonMetaclass addClassVarName:varName. |
|
2593 |
^ VariableNode type:#ClassVariable class:classToCompileFor theNonMetaclass name:varName |
|
2594 |
]. |
|
2595 |
||
2596 |
choice == #InstanceVariable ifTrue:[ |
|
2597 |
classToCompileFor theNonMetaclass addInstVarName:varName. |
|
2598 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2599 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2600 |
RestartCompilationSignal raise. |
|
2601 |
"/ not reached - restarted compile will not arrive here again |
|
2602 |
self error:'restart compile failed'. |
|
2603 |
]. |
|
2604 |
||
2605 |
choice == #ClassInstanceVariable ifTrue:[ |
|
2606 |
classToCompileFor theMetaclass addInstVarName:varName. |
|
2607 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2608 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2609 |
RestartCompilationSignal raise. |
|
2610 |
"/ not reached - restarted compile will not arrive here again |
|
2611 |
self error:'restart compile failed'. |
|
2612 |
]. |
|
2613 |
||
2614 |
choice == #MethodVariable ifTrue:[ |
|
2615 |
|varIndex var endLocalsPos posToInsert ins| |
|
2616 |
||
2617 |
localVarDefPosition size == 2 ifTrue:[ |
|
2618 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
|
2619 |
ins := ' ' , varName. |
|
2620 |
] ifFalse:[ |
|
2621 |
endOfSelectorPosition notNil ifTrue:[ |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2622 |
posToInsert := beginOfBodyPosition. |
1295 | 2623 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
2624 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
|
2625 |
] |
|
2626 |
]. |
|
2627 |
posToInsert notNil ifTrue:[ |
|
2628 |
requestor |
|
2629 |
insertString:ins |
|
2630 |
atCharacterPosition:posToInsert. |
|
2631 |
||
2632 |
endLocalsPos notNil ifTrue:[ |
|
2633 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
|
2634 |
||
2635 |
methodVarNames := methodVarNames copyWith:varName. |
|
2636 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
|
2637 |
] ifFalse:[ |
|
2638 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
|
2639 |
||
2640 |
methodVarNames := Array with:varName. |
|
2641 |
methodVars := Array with:(var := Variable new name:varName). |
|
2642 |
]. |
|
2643 |
correctedSource := requestor currentSourceCode. |
|
2644 |
source := (ReadStream on:correctedSource) |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2645 |
position:(source position1Based + ins size). |
1295 | 2646 |
|
2647 |
varIndex := methodVarNames size. |
|
2648 |
var used:true. |
|
2649 |
^ VariableNode type:#MethodVariable |
|
2650 |
name:varName |
|
2651 |
token:var |
|
2652 |
index:varIndex |
|
2653 |
]. |
|
2654 |
]. |
|
2655 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
|
2656 |
]. |
|
2657 |
]. |
|
2658 |
^ nil. |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2659 |
|
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2660 |
"Modified: / 05-09-2006 / 12:26:13 / cg" |
1295 | 2661 |
! |
2662 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2663 |
checkIfAllSubclassesOf:aClass implement:aSelector |
1907 | 2664 |
^ aClass subclasses conform:[:cls | (cls implements:aSelector)] |
2665 |
||
2666 |
"Modified: / 13-09-2006 / 11:40:52 / cg" |
|
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2667 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2668 |
|
141 | 2669 |
correctByDeleting |
2670 |
"correct (by deleting token) if user wants to; |
|
2671 |
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
|
2672 |
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
|
2673 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2674 |
|selectionSize| |
141 | 2675 |
|
2676 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
2677 |
||
2678 |
" |
|
2679 |
tell requestor (i.e. CodeView) about the change |
|
2680 |
this will update what the requestor shows. |
|
2681 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2682 |
selectionSize := requestor selection size. |
141 | 2683 |
requestor deleteSelection. |
2684 |
||
2685 |
" |
|
2686 |
get the updated source-string |
|
2687 |
which is needed, when we eventually install the new method |
|
2688 |
" |
|
2689 |
correctedSource := requestor currentSourceCode. |
|
1167 | 2690 |
"/ 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
|
2691 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2692 |
position:(source position1Based - selectionSize). |
1369
2304dd8c3173
recompilation after correct-by-deleting unused local
Claus Gittinger <cg@exept.de>
parents:
1368
diff
changeset
|
2693 |
|
141 | 2694 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2695 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2696 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 2697 |
! |
2698 |
||
1439 | 2699 |
correctSelector:aSelectorString message:msg positions:posVector in:aClassOrNil for:receiverNode |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2700 |
"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
|
2701 |
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
|
2702 |
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
|
2703 |
|
1439 | 2704 |
|correctIt suggestedNames newSelector className classToGenerateCode pos1 pos2| |
2705 |
||
2706 |
pos1 := posVector first start. |
|
2707 |
pos2 := posVector last stop. |
|
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2708 |
|
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
2709 |
(self alreadyWarnedUnimplementedSelectors includes:aSelectorString) ifTrue:[ |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2710 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2711 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2712 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2713 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2714 |
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
|
2715 |
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
|
2716 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2717 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2718 |
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
|
2719 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2720 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2721 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2722 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2723 |
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
|
2724 |
correctIt == #generate ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2725 |
receiverNode isSelf ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2726 |
classToGenerateCode := classToCompileFor |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2727 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2728 |
receiverNode isVariable ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2729 |
receiverNode isGlobal ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2730 |
classToGenerateCode := receiverNode evaluate. |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2731 |
classToGenerateCode isBehavior ifTrue:[ |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2732 |
classToGenerateCode := classToGenerateCode theMetaclass. |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2733 |
] ifFalse:[ |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2734 |
classToGenerateCode := nil |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2735 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2736 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2737 |
] |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2738 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2739 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2740 |
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
|
2741 |
className size == 0 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2742 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2743 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2744 |
classToGenerateCode := Smalltalk at:className asSymbol. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2745 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2746 |
self warn:'No such class.'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2747 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2748 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2749 |
]. |
1252
666db3206028
#implements: -> #includesSelector:
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2750 |
(classToGenerateCode includesSelector:aSelectorString asSymbol) ifFalse:[ |
2098
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2751 |
|code category wantSetter wantGetter| |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2752 |
|
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2753 |
wantSetter := wantGetter := false. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2754 |
|
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2755 |
(aSelectorString isKeywordSelector |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2756 |
and:[aSelectorString numArgs == 1 |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2757 |
and:[classToGenerateCode instVarNames includes:(aSelectorString copyWithoutLast:1)]]) ifTrue:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2758 |
"/ want a setter ? |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2759 |
wantSetter := Dialog confirmWithCancel:('Create a setter for %1 ?' bindWith:(aSelectorString copyWithoutLast:1) allBold). |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2760 |
wantSetter isNil ifTrue:[^ aSelectorString]. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2761 |
] ifFalse:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2762 |
(aSelectorString isUnarySelector |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2763 |
and:[classToGenerateCode instVarNames includes:aSelectorString]) ifTrue:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2764 |
"/ want a getter ? |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2765 |
wantGetter := Dialog confirmWithCancel:('Create a getter for %1 ?' bindWith:aSelectorString allBold). |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2766 |
wantGetter isNil ifTrue:[^ aSelectorString]. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2767 |
] |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2768 |
]. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2769 |
wantSetter ifTrue:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2770 |
code := ('%1:something\ %1 := something.' bindWith:(aSelectorString copyWithoutLast:1)) withCRs. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2771 |
category := 'accessing'. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2772 |
] ifFalse:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2773 |
wantGetter ifTrue:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2774 |
code := ('%1\ ^ %1.' bindWith:aSelectorString) withCRs. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2775 |
category := 'accessing'. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2776 |
] ifFalse:[ |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2777 |
code := (self class methodSpecificationForSelector:aSelectorString) , '\ self shouldImplement' withCRs. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2778 |
category := Compiler defaultMethodCategory. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2779 |
]. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2780 |
]. |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2781 |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2782 |
"do not overwrite an already existant (deprecated) method" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2783 |
classToGenerateCode |
2098
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2784 |
compile:code |
a03891b6fc30
more intelligent genertion of missing method
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
2785 |
classified:category. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2786 |
]. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2787 |
correctIt := false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2788 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2789 |
correctIt ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2790 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2791 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2792 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2793 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2794 |
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
|
2795 |
suggestedNames notNil ifTrue:[ |
1323 | 2796 |
newSelector := self askForCorrection:'Correct Selector to: ' fromList:suggestedNames for:aSelectorString. |
2797 |
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
|
2798 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2799 |
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
|
2800 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2801 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2802 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2803 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2804 |
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
|
2805 |
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
|
2806 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2807 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2808 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2809 |
get the updated source-string |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2810 |
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
|
2811 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2812 |
correctedSource := requestor currentSourceCode. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2813 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2814 |
position:(source position1Based + 1 + (newSelector size - aSelectorString size)). |
1361 | 2815 |
"/ Parser murks. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2816 |
^ newSelector |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2817 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2818 |
"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
|
2819 |
"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
|
2820 |
"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
|
2821 |
! |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2822 |
|
1167 | 2823 |
correctSourceByDeletingFrom:start to:stop |
2824 |
"correct (by deleting token) if user wants to; |
|
2825 |
return #Error if there was no correction; |
|
2826 |
nil if there was one." |
|
2827 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2828 |
|deleteSize localDefsStart localDefsStop newPos| |
1167 | 2829 |
|
2830 |
" |
|
2831 |
tell requestor (i.e. CodeView) about the change |
|
2832 |
this will update what the requestor shows. |
|
2833 |
" |
|
2834 |
deleteSize := stop - start + 1. |
|
2835 |
requestor deleteFromCharacterPosition:start to:stop. |
|
2836 |
||
2837 |
" |
|
2838 |
get the updated source-string |
|
2839 |
which is needed, when we eventually install the new method |
|
2840 |
" |
|
2841 |
correctedSource := requestor currentSourceCode. |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2842 |
|
1167 | 2843 |
"/ update the current source position |
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2844 |
source atEnd ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2845 |
newPos := correctedSource size. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2846 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2847 |
source position1Based >= stop ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2848 |
newPos := source position1Based - deleteSize |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2849 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2850 |
source position1Based < start ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2851 |
newPos := source position1Based |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2852 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2853 |
newPos := start |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2854 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2855 |
] |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2856 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2857 |
source := (ReadStream on:correctedSource) position1Based:newPos. |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2858 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2859 |
localDefsStart := localVarDefPosition at:1. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2860 |
localDefsStop := localVarDefPosition at:2. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2861 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2862 |
localDefsStop <= start ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2863 |
localDefsStart >= stop ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2864 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2865 |
(localDefsStart >= start and:[localDefsStop <= stop]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2866 |
localVarDefPosition := nil. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2867 |
^ self |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2868 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2869 |
|
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2870 |
"/ must update |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2871 |
(start > localDefsStart and:[stop < localDefsStop]) ifTrue:[ |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2872 |
localVarDefPosition at:2 put:(localDefsStop - (stop-start+1)). |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2873 |
^ self. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2874 |
]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2875 |
^ self |
1167 | 2876 |
! |
2877 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2878 |
correctVariable:varName atPosition:pos1 to:pos2 |
141 | 2879 |
"notify error and correct if user wants to; |
2880 |
return #Error if there was no correction |
|
2881 |
or a ParseNode as returned by variable" |
|
2882 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2883 |
|correctIt suggestedNames newName rslt |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2884 |
varNameIsLowercase undeclared boldName| |
141 | 2885 |
|
877 | 2886 |
varNameIsLowercase := (varName at:1) isLowercase. |
2887 |
||
141 | 2888 |
correctIt := self undefError:varName position:pos1 to:pos2. |
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2889 |
correctIt == #Error ifTrue:[ |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2890 |
^ #Error |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2891 |
]. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2892 |
|
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2893 |
correctIt == #declare ifTrue:[ |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2894 |
"/ declare it |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2895 |
rslt := self askForVariableTypeWhenDeclaringUndefined:varName. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2896 |
rslt notNil ifTrue:[ |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2897 |
^ rslt |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2898 |
]. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2899 |
correctIt := #continue. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2900 |
]. |
887 | 2901 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 2902 |
"/ no correction wanted. |
2903 |
||
2904 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
2905 |
"/ allowing easy search for bad-spots later. |
|
1285 | 2906 |
boldName := varName allBold. |
877 | 2907 |
|
2908 |
varNameIsLowercase ifTrue:[ |
|
1205 | 2909 |
undeclared := Smalltalk at:#Undeclared. |
2910 |
((undeclared notNil) |
|
2911 |
and:[(undeclared includes:varName asSymbol)]) ifFalse:[ |
|
1285 | 2912 |
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
|
2913 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2914 |
^ self defineAsUndeclaredVariable:varName |
877 | 2915 |
]. |
2916 |
||
2917 |
"/ upperCase vars are declared as global |
|
1716
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
2918 |
parserFlags warnings ifTrue:[ |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
2919 |
(warnedUndefVars isNil or:[(warnedUndefVars includes:varName) not]) ifTrue:[ |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
2920 |
(warnedUnknownNamespaces isNil or:[(warnedUnknownNamespaces includes:varName) not]) ifTrue:[ |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
2921 |
self warning:('adding ''' , boldName , ''' as Global.') withCRs position:pos1 to:pos2. |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
2922 |
] |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2923 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2924 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2925 |
^ VariableNode globalNamed:varName |
877 | 2926 |
]. |
2927 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2928 |
(correctIt isKindOf:ParseNode) ifTrue:[ |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2929 |
^ correctIt |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2930 |
]. |
141 | 2931 |
|
2932 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2933 |
suggestedNames isNil ifTrue:[ |
1285 | 2934 |
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
|
2935 |
^ #Error |
141 | 2936 |
]. |
2937 |
||
1285 | 2938 |
newName := self askForCorrection:'Correct Variable to: ' fromList:suggestedNames. |
877 | 2939 |
newName isNil ifTrue:[^ #Error]. |
2940 |
" |
|
2941 |
newName := suggestedNames at:1. |
|
2942 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2943 |
" |
|
2944 |
||
141 | 2945 |
" |
2946 |
tell requestor (i.e. CodeView) about the change |
|
2947 |
this will update what the requestor shows. |
|
2948 |
" |
|
2949 |
requestor replaceSelectionBy:newName. |
|
2950 |
" |
|
2951 |
get the updated source-string |
|
2952 |
which is needed, when we eventually install the new method |
|
2953 |
" |
|
2954 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2955 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2956 |
position:(source position1Based + newName size - tokenName size). |
141 | 2957 |
|
2958 |
"redo parse with new value" |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
2959 |
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
|
2960 |
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
|
2961 |
|
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
|
2962 |
"/ 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
|
2963 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2964 |
"/ 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
|
2965 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2966 |
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
|
2967 |
]. |
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
|
2968 |
^ 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
|
2969 |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2970 |
"Modified: / 22-01-1998 / 16:34:01 / stefan" |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
2971 |
"Modified: / 05-09-2006 / 12:27: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
|
2972 |
! |
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
|
2973 |
|
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
|
2974 |
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
|
2975 |
"define varName as undeclared variable |
629 | 2976 |
(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
|
2977 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2978 |
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
|
2979 |
|
1206 | 2980 |
|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
|
2981 |
|
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
|
2982 |
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
|
2983 |
|
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
|
2984 |
"/ 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
|
2985 |
|
1206 | 2986 |
undeclared := Smalltalk at:#Undeclared. |
2987 |
undeclared isNil ifTrue:[ |
|
2988 |
Smalltalk at:#Undeclared put:(undeclared := IdentitySet new). |
|
2989 |
]. |
|
2990 |
undeclared add:tokenName asSymbol. |
|
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
2991 |
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
|
2992 |
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
|
2993 |
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
|
2994 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2995 |
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
|
2996 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2997 |
^ 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
|
2998 |
|
629 | 2999 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 3000 |
! |
3001 |
||
1167 | 3002 |
deleteDefinitionOf:varName in:defStartPos to:defEndPos |
1393 | 3003 |
"this removes the definition of varName from the declaration part i.e. |
3004 |
if the source was '... | foo bar baz |...' |
|
3005 |
deleting the var 'bar' changes the source to '... | foo baz |...'. |
|
3006 |
The code below tries to be somewhat smart w.r.t. spaces by |
|
3007 |
trying to remove the whiteSpace around the removed variable also. |
|
3008 |
However, this seems to not always work correctly" |
|
3009 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3010 |
|source startSearch pos pos2 nextChar varSlot p p2| |
1172 | 3011 |
|
3012 |
varSlot := methodVars detect:[:var | var name = varName]. |
|
3013 |
methodVars removeIdentical:varSlot. |
|
1167 | 3014 |
|
3015 |
source := requestor currentSourceCode. |
|
3016 |
startSearch := defStartPos+1. |
|
3017 |
||
1779 | 3018 |
[true] whileTrue:[ |
1393 | 3019 |
|prevChar isFirstVar didPassEndOfLine| |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3020 |
|
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3021 |
"/ search this name's position in the declaration part ... |
1167 | 3022 |
pos := source indexOfSubCollection:varName startingAt:startSearch ifAbsent:0. |
1326 | 3023 |
(pos == 0 or:[pos >= defEndPos]) ifTrue:[ |
3024 |
self error:'should not happen' mayProceed:true. |
|
1167 | 3025 |
^ self. |
3026 |
]. |
|
3027 |
||
3028 |
pos2 := pos + varName size - 1. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3029 |
pos > 1 ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3030 |
prevChar := source at:pos-1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3031 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3032 |
(prevChar isNil or:[prevChar isLetterOrDigit not]) ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3033 |
nextChar := source at:pos2+1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3034 |
nextChar isLetterOrDigit ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3035 |
"/ halfway intuitive space-removal behavior; |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3036 |
"/ if there was a space after/before the |-char, |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3037 |
"/ leave it; otherwise remove it. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3038 |
isFirstVar := pos == (defStartPos+1). |
1393 | 3039 |
(source at:pos-1) isSeparator ifTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3040 |
pos := pos - 1. |
1393 | 3041 |
[ (source at:pos-1) isSeparator] whileTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3042 |
pos := pos - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3043 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3044 |
(source at:pos-1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3045 |
"/ there was a space before - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3046 |
pos := pos + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3047 |
isFirstVar := true. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3048 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3049 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3050 |
|
1393 | 3051 |
(source at:pos2+1) isSeparator ifTrue:[ |
3052 |
didPassEndOfLine := (source at:pos2+1) == Character cr. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3053 |
pos2 := pos2 + 1. |
1393 | 3054 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
3055 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3056 |
pos2 := pos2 + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3057 |
]. |
1393 | 3058 |
|
3059 |
didPassEndOfLine ifFalse:[ |
|
3060 |
(source at:pos2+1) == $" ifTrue:[ |
|
3061 |
"/ comment follows - assume it belongs to the removed variable |
|
3062 |
pos2 := pos2 + 1. |
|
3063 |
(source at:pos2+1) == $/ ifTrue:[ |
|
3064 |
"/ EOL comment |
|
3065 |
[ (source at:pos2+1) == Character cr ] whileFalse:[ |
|
3066 |
pos2 := pos2 + 1. |
|
3067 |
]. |
|
3068 |
pos2 := pos2 + 1. |
|
3069 |
] ifFalse:[ |
|
3070 |
"/ regular comment |
|
3071 |
[ (source at:pos2+1) == $" ] whileFalse:[ |
|
3072 |
pos2 := pos2 + 1. |
|
3073 |
]. |
|
3074 |
pos2 := pos2 + 1. |
|
3075 |
]. |
|
3076 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
|
3077 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
3078 |
pos2 := pos2 + 1. |
|
3079 |
]. |
|
3080 |
] |
|
3081 |
]. |
|
3082 |
||
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3083 |
(source at:pos2+1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3084 |
"/ there was a space after - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3085 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3086 |
] ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3087 |
isFirstVar ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3088 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3089 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3090 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3091 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3092 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3093 |
"/ if this was the last, remove empty var-declaration completely |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3094 |
((source at:pos-1) == $| |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3095 |
and:[ (source at:pos2+1) == $| ]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3096 |
pos := pos - 1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3097 |
pos2 := pos2 + 1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3098 |
"/ see if that gives us an empty line |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3099 |
p := pos. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3100 |
p2 := pos2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3101 |
|
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3102 |
[(source at:p-1) == Character space] whileTrue:[ p := p - 1 ]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3103 |
[(source at:p2+1) == Character space] whileTrue:[ p2 := p2 + 1 ]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3104 |
((source at:p-1) == Character cr and:[ (source at:p2+1) == Character cr]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3105 |
pos := p-1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3106 |
pos2 := p2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3107 |
(((source at:pos-1) == Character cr) and:[((source at:pos-2) == Character cr)]) |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3108 |
ifTrue:[ pos := pos - 1 ] |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3109 |
ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3110 |
(((source at:pos2+1) == Character cr) and:[((source at:pos2+2) == Character cr)]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3111 |
pos2 := pos2 + 1 ]]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3112 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3113 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
3114 |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3115 |
self correctSourceByDeletingFrom:pos to:pos2. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
3116 |
^ self. |
1167 | 3117 |
]. |
3118 |
]. |
|
3119 |
startSearch := pos2 + 1. |
|
1779 | 3120 |
] |
3121 |
||
3122 |
"Modified: / 18-07-2006 / 08:56:25 / cg" |
|
1167 | 3123 |
! |
3124 |
||
141 | 3125 |
findBestSelectorsFor:aString |
3126 |
"collect known selectors with their spelling distances to aString; |
|
3127 |
return the 10 best suggestions" |
|
3128 |
||
1187 | 3129 |
^ self class findBestSelectorsFor:aString |
141 | 3130 |
|
3131 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
3132 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
3133 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
3134 |
! |
|
3135 |
||
1022 | 3136 |
findBestSelectorsFor:aString in:aClassOrNil |
3137 |
"collect known selectors with their spelling distances to aString; |
|
2109 | 3138 |
return the N best suggestions. If the argument, aClassOrNil is not nil, |
1022 | 3139 |
the message is assumed to be sent to instances of that class (i.e. offer |
3140 |
corrections from that hierarchy only)" |
|
3141 |
||
1187 | 3142 |
^ self class findBestSelectorsFor:aString in:aClassOrNil |
1022 | 3143 |
! |
3144 |
||
141 | 3145 |
findBestVariablesFor:aString |
3146 |
"collect known variables with their spelling distances to aString; |
|
3147 |
return the 10 best suggestions" |
|
3148 |
||
1200 | 3149 |
|names dists searchBlock args vars "aClass className baseClass" |
1647 | 3150 |
n instVarNames classVarNames spellAgainstNodeAction spellAgainstAction| |
141 | 3151 |
|
3152 |
names := OrderedCollection new. |
|
3153 |
dists := OrderedCollection new. |
|
3154 |
||
1200 | 3155 |
spellAgainstAction := |
3156 |
[:givenName | |
|
3157 |
|dist| |
|
3158 |
||
3159 |
names add:givenName. |
|
3160 |
dist := aString spellAgainst:givenName. |
|
3161 |
(aString startsWith:givenName) ifTrue:[ |
|
1647 | 3162 |
dist := dist + (givenName size * 10). |
1200 | 3163 |
]. |
3164 |
dists add:dist |
|
3165 |
]. |
|
3166 |
||
1647 | 3167 |
spellAgainstNodeAction := |
3168 |
[:aVarNode | |
|
3169 |
spellAgainstAction value:(aVarNode name). |
|
3170 |
]. |
|
3171 |
||
3172 |
"block arguments" |
|
3173 |
searchBlock := currentBlock. |
|
3174 |
[searchBlock notNil] whileTrue:[ |
|
3175 |
args := searchBlock arguments. |
|
3176 |
args notNil ifTrue:[ |
|
3177 |
args do:spellAgainstNodeAction |
|
3178 |
]. |
|
3179 |
||
3180 |
vars := searchBlock variables. |
|
3181 |
vars notNil ifTrue:[ |
|
3182 |
vars do:spellAgainstNodeAction |
|
3183 |
]. |
|
3184 |
searchBlock := searchBlock home |
|
3185 |
]. |
|
3186 |
||
141 | 3187 |
"method-variables" |
3188 |
methodVars notNil ifTrue:[ |
|
1200 | 3189 |
methodVarNames do:spellAgainstAction |
141 | 3190 |
]. |
3191 |
||
3192 |
"method-arguments" |
|
3193 |
methodArgs notNil ifTrue:[ |
|
1200 | 3194 |
methodArgNames do:spellAgainstAction |
141 | 3195 |
]. |
3196 |
||
3197 |
"instance-variables" |
|
3198 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 3199 |
self classesInstVarNames do:spellAgainstAction |
141 | 3200 |
]. |
3201 |
||
3202 |
"class-variables" |
|
3203 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 3204 |
self classesClassVarNames do:spellAgainstAction. |
141 | 3205 |
|
3206 |
"/ aClass := classToCompileFor. |
|
3207 |
"/ aClass isMeta ifTrue:[ |
|
3208 |
"/ className := aClass name. |
|
3209 |
"/ className := className copyWithoutLast:5. |
|
3210 |
"/ baseClass := Smalltalk at:(className asSymbol). |
|
3211 |
"/ baseClass notNil ifTrue:[ |
|
3212 |
"/ aClass := baseClass |
|
3213 |
"/ ] |
|
3214 |
"/ ]. |
|
3215 |
"/ [aClass notNil] whileTrue:[ |
|
3216 |
"/ (aClass classVarNames) do:[:classVarName | |
|
3217 |
"/ names add:classVarName. |
|
3218 |
"/ dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
3219 |
"/ ]. |
|
3220 |
"/ aClass := aClass superclass |
|
3221 |
"/ ] |
|
3222 |
||
3223 |
]. |
|
3224 |
||
3225 |
"globals" |
|
3226 |
Smalltalk keysDo:[:aKey | |
|
1647 | 3227 |
|globalVarName parts| |
1200 | 3228 |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3229 |
globalVarName := aKey asString. |
1200 | 3230 |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3231 |
"only compare strings where length is about right" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3232 |
((globalVarName size - aString size) abs < 3) ifTrue:[ |
1200 | 3233 |
spellAgainstAction value:globalVarName. |
1647 | 3234 |
]. |
3235 |
(globalVarName includes:$:) ifTrue:[ |
|
3236 |
parts := globalVarName asCollectionOfSubCollectionsSeparatedByAll:'::'. |
|
3237 |
parts size > 1 ifTrue:[ |
|
3238 |
parts do:[:eachPart | |
|
3239 |
|dist| |
|
3240 |
((eachPart size - aString size) abs < 3) ifTrue:[ |
|
3241 |
names add:globalVarName. |
|
3242 |
dist := aString spellAgainst:eachPart. |
|
3243 |
(aString startsWith:eachPart) ifTrue:[ |
|
3244 |
dist := dist + (eachPart size * 10). |
|
3245 |
]. |
|
3246 |
dists add:dist |
|
3247 |
]. |
|
3248 |
]. |
|
3249 |
]. |
|
3250 |
]. |
|
141 | 3251 |
]. |
3252 |
||
3253 |
"misc" |
|
1200 | 3254 |
#('self' 'super' 'nil' 'thisContext') do:spellAgainstAction. |
141 | 3255 |
|
3256 |
(dists size ~~ 0) ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3257 |
dists sortWith:names. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3258 |
dists := dists reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3259 |
names := names reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3260 |
n := names size min:10. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3261 |
names := names copyTo:n. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3262 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3263 |
"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
|
3264 |
(aString at:1) isLowercase ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3265 |
methodVarNames size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3266 |
names add:'---- method locals ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3267 |
methodVarNames asSortedCollection do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3268 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3269 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3270 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3271 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3272 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3273 |
methodArgs size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3274 |
names add:'---- method arguments ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3275 |
methodArgNames asSortedCollection do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3276 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3277 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3278 |
]. |
1078 | 3279 |
classToCompileFor notNil ifTrue:[ |
3280 |
instVarNames := OrderedCollection new. |
|
3281 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
3282 |
(instVarNames includes:instVarName) ifFalse:[ |
|
3283 |
instVarNames add:instVarName. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3284 |
] |
1078 | 3285 |
]. |
3286 |
||
3287 |
instVarNames size > 0 ifTrue:[ |
|
3288 |
(classToCompileFor notNil and:[classToCompileFor isMeta]) ifTrue:[ |
|
3289 |
names add:'---- class instance variables ----'. |
|
3290 |
] ifFalse:[ |
|
3291 |
names add:'---- instance variables ----'. |
|
3292 |
]. |
|
3293 |
instVarNames do:[:instVarName | |
|
3294 |
(names includes:instVarName) ifFalse:[ |
|
3295 |
names add:instVarName. |
|
3296 |
] |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3297 |
] |
1078 | 3298 |
]. |
3299 |
||
3300 |
classVarNames := OrderedCollection new. |
|
3301 |
self classesClassVarNames asSortedCollection do:[:classVarName | |
|
3302 |
(classVarNames includes:classVarName) ifFalse:[ |
|
3303 |
classVarNames add:classVarName. |
|
3304 |
] |
|
3305 |
]. |
|
3306 |
||
3307 |
classVarNames size > 0 ifTrue:[ |
|
3308 |
names add:'---- class variables ----'. |
|
3309 |
classVarNames do:[:classVarName | |
|
3310 |
(names includes:classVarName) ifFalse:[ |
|
3311 |
names add:classVarName. |
|
3312 |
] |
|
3313 |
] |
|
3314 |
]. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3315 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3316 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3317 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3318 |
^ names |
141 | 3319 |
]. |
3320 |
^ nil |
|
450 | 3321 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
3322 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 3323 |
! |
3324 |
||
3325 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
1439 | 3326 |
^ self selectorCheck:aSelectorString for:receiver positions:(Array with:(pos1 to:pos2)). |
3327 |
! |
|
3328 |
||
3329 |
selectorCheck:aSelectorString for:receiver positions:posVector |
|
141 | 3330 |
"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
|
3331 |
has the same name as a variable, cannot be understood or is obsolete. |
141 | 3332 |
Simple, but catches many typos" |
3333 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3334 |
|isSyntaxHighlighter err selectorSymbol rec names recType selClass newSelector nm nowhereImplemented |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3335 |
pos1 pos2 canDefine| |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3336 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3337 |
isSyntaxHighlighter := self isSyntaxHighlighter. |
141 | 3338 |
" |
3339 |
if compiling lazy, or errors are to be ignored, or there |
|
3340 |
is no requestor, do not check |
|
3341 |
" |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3342 |
isSyntaxHighlighter ifFalse:[ |
1545 | 3343 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
1022 | 3344 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
3345 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
1714
ba7113f4bce1
honor disabled warning flags
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
3346 |
parserFlags warnings ifFalse:[^ aSelectorString]. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
3347 |
]. |
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3348 |
"/ do not check messages to undefined variables... |
1936 | 3349 |
(receiver isVariable and:[receiver isUndeclared]) ifTrue:[ |
3350 |
^ aSelectorString |
|
3351 |
]. |
|
3352 |
self isDoIt ifTrue:[ |
|
3353 |
^ aSelectorString |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3354 |
]. |
141 | 3355 |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3356 |
canDefine := false. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3357 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3358 |
pos1 := posVector first start. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3359 |
pos2 := posVector last stop. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3360 |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3361 |
aSelectorString = '#' ifTrue:[ |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3362 |
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
|
3363 |
]. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3364 |
|
141 | 3365 |
" |
3366 |
check if the selector is known at all |
|
3367 |
- if not, it cannot be understood |
|
3368 |
" |
|
1327 | 3369 |
nowhereImplemented := false. |
3370 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3371 |
selectorSymbol := aSelectorString asSymbolIfInterned. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3372 |
selectorSymbol isNil ifTrue:[ |
1327 | 3373 |
nowhereImplemented := true. |
1518 | 3374 |
] ifFalse:[ |
3375 |
"/ temporarily disabled - too slow. |
|
3376 |
"/ self isSyntaxHighlighter ifTrue:[ |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3377 |
"/ nowhereImplemented := (self class implementedInAnyClass:selectorSymbol) not. |
1518 | 3378 |
"/ ] |
1327 | 3379 |
]. |
3380 |
||
3381 |
nowhereImplemented ifTrue:[ |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3382 |
isSyntaxHighlighter ifFalse:[ |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3383 |
self classToCompileFor notNil ifTrue:[ |
1983 | 3384 |
Tools::ToDoListBrowser notNil ifTrue:[ |
3385 |
"/ experimental |
|
3386 |
self |
|
3387 |
notifyTodo:('"%1" is nowhere implemented' bindWith:aSelectorString) position:posVector first |
|
3388 |
className:(self classToCompileFor name) selector:selector |
|
2013
496847ce52e6
oops - should not need to know about ToDoList
Claus Gittinger <cg@exept.de>
parents:
2009
diff
changeset
|
3389 |
severity:#warning priority:#high |
1983 | 3390 |
equalityParameter:aSelectorString |
3391 |
checkAction:[:e | |
|
3392 |
e problemMethod notNil |
|
3393 |
and:[(e problemMethod sends:aSelectorString asSymbol) |
|
3394 |
and:[self class implementedInAnyClass:aSelectorString]] ] |
|
3395 |
]. |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3396 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3397 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3398 |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3399 |
err := ' is currently nowhere implemented'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3400 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3401 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3402 |
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
|
3403 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3404 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3405 |
or:[(methodArgNames notNil and:[methodArgNames includes:aSelectorString]) |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3406 |
or:[classToCompileFor notNil |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3407 |
and:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString]) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3408 |
or:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString]) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3409 |
or:[(names := self classesClassVarNames) notNil and:[names includes:aSelectorString] |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3410 |
]]]]]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3411 |
err := ' is currently nowhere implemented .. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3412 |
.. but a variable with that name is defined. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3413 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3414 |
Missing ''.'' after the previous expression |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3415 |
or missing keyword/receiver before that word ?'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3416 |
]. |
1327 | 3417 |
] ifFalse:[ |
3418 |
receiver notNil ifTrue:[ |
|
3419 |
selClass := self typeOfNode:receiver. |
|
3420 |
selClass notNil ifTrue:[ |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3421 |
"this could be performed if selClass isNil, but it is too slow" |
1507 | 3422 |
err := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3423 |
]. |
3424 |
||
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3425 |
err notNil ifTrue:[ |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3426 |
isSyntaxHighlighter ifFalse:[ |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3427 |
self classToCompileFor notNil ifTrue:[ |
1983 | 3428 |
Tools::ToDoListBrowser notNil ifTrue:[ |
3429 |
"/ experimental |
|
3430 |
self |
|
3431 |
notifyTodo:(selectorSymbol ,' ',err) position:posVector first |
|
3432 |
className:(self classToCompileFor name) selector:selector |
|
2013
496847ce52e6
oops - should not need to know about ToDoList
Claus Gittinger <cg@exept.de>
parents:
2009
diff
changeset
|
3433 |
severity:#warning priority:#high |
1983 | 3434 |
equalityParameter:selectorSymbol |
3435 |
checkAction:[:e | |
|
3436 |
|selClass| |
|
3437 |
||
3438 |
selClass := self typeOfNode:receiver. |
|
3439 |
e problemMethod notNil |
|
3440 |
and:[(e problemMethod sends:aSelectorString asSymbol) |
|
3441 |
and:[(self checkSelector:selectorSymbol for:receiver inClass:selClass) notNil]]]. |
|
3442 |
]. |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3443 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3444 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3445 |
]. |
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3446 |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3447 |
(receiver isConstant or:[receiver isBlock]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3448 |
err notNil ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3449 |
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
|
3450 |
]. |
1327 | 3451 |
] ifFalse:[(((recType := receiver type) == #GlobalVariable) |
3452 |
or:[recType == #PrivateClass]) ifTrue:[ |
|
3453 |
rec := receiver evaluate. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3454 |
"/ dont check autoloaded classes - it may work after loading |
1327 | 3455 |
(rec isNil |
3456 |
or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[ |
|
3457 |
^ aSelectorString |
|
3458 |
]. |
|
3459 |
||
3460 |
err notNil ifTrue:[ |
|
3461 |
(rec isBehavior |
|
3462 |
and:[rec theNonMetaclass name = receiver name]) ifTrue:[ |
|
3463 |
err := err, ' in ' , rec theNonMetaclass name. |
|
3464 |
] ifFalse:[ |
|
3465 |
err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'. |
|
3466 |
] |
|
3467 |
]. |
|
3468 |
] ifFalse:[receiver isSuper ifTrue:[ |
|
3469 |
receiver isHere ifFalse:[ |
|
3470 |
err notNil ifTrue:[ |
|
3471 |
err := err, ' in superclass chain'. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3472 |
]. |
1327 | 3473 |
] ifTrue:[ |
3474 |
err notNil ifTrue:[ |
|
3475 |
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
|
3476 |
]. |
1327 | 3477 |
] |
3478 |
] ifFalse:[receiver isSelf ifTrue:[ |
|
3479 |
err notNil ifTrue:[ |
|
3480 |
|subErr| |
|
3481 |
||
3482 |
"/ understood by all subclasses ? |
|
3483 |
classToCompileFor allSubclassesDo:[:eachSubclass | |
|
3484 |
subErr isNil ifTrue:[ |
|
3485 |
selClass := eachSubclass. |
|
1507 | 3486 |
subErr := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3487 |
]. |
3488 |
]. |
|
3489 |
subErr notNil ifTrue:[ |
|
3490 |
err := subErr, ' in this class, superclass chain or all subclasses' |
|
3491 |
] ifFalse:[ |
|
3492 |
err := err, ' in this class or superclass chain'. |
|
1440 | 3493 |
]. |
3494 |
canDefine := true. |
|
1327 | 3495 |
]. |
3496 |
] ifFalse:[(receiver isUnaryMessage |
|
3497 |
and:[receiver selector == #class |
|
3498 |
and:[receiver receiver isSelf]]) ifTrue:[ |
|
3499 |
"its a message to self class - can check this too ..." |
|
3500 |
err notNil ifTrue:[ |
|
3501 |
classToCompileFor isMeta ifTrue:[ |
|
3502 |
err := err, ' for the classes class'. |
|
1507 | 3503 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3504 |
err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'. |
3505 |
err := err withCRs. |
|
3506 |
]. |
|
3507 |
] ifFalse:[ |
|
3508 |
err := err, ' for my class'. |
|
1507 | 3509 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3510 |
err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'. |
3511 |
err := err withCRs. |
|
3512 |
]. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3513 |
]. |
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3514 |
]. |
1327 | 3515 |
] ifFalse:[(receiver isMethodVariable and:[receiver token type isNil]) ifTrue:[ |
3516 |
"if it is an uninitialized variable ..." |
|
3517 |
((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not]) |
|
1441 | 3518 |
and:[hasPrimitiveCode not |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3519 |
and:[currentBlock isNil |
1327 | 3520 |
and:[alreadyWarnedUninitializedVars isNil |
1442 | 3521 |
or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]]) |
1327 | 3522 |
ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3523 |
((#(at: at:put: basicAt: basicAt:put:) includes:selectorSymbol) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3524 |
or:[(nil respondsTo:selectorSymbol) not])ifTrue:[ |
1327 | 3525 |
"/ avoid trouble in miniTalk |
3526 |
"/ during bootstrap |
|
3527 |
nm := receiver name. |
|
3528 |
Text notNil ifTrue:[ |
|
3529 |
nm := nm allItalic |
|
3530 |
]. |
|
3531 |
err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'. |
|
3532 |
alreadyWarnedUninitializedVars isNil ifTrue:[ |
|
3533 |
alreadyWarnedUninitializedVars := Set new |
|
3534 |
]. |
|
3535 |
alreadyWarnedUninitializedVars add:receiver name |
|
3536 |
] |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3537 |
] |
1327 | 3538 |
] ifFalse:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3539 |
(err notNil and:[selClass notNil]) ifTrue:[ |
1327 | 3540 |
err := err, ' (message to ' , selClass nameWithArticle , ')'. |
3541 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3542 |
]]]]]]. |
1327 | 3543 |
] |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3544 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3545 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3546 |
err notNil ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3547 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3548 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3549 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3550 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3551 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3552 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3553 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3554 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3555 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3556 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 3557 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3558 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3559 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3560 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3561 |
"/ it may work after loading/defining |
1022 | 3562 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3563 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3564 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3565 |
Text notNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3566 |
err := '"' , aSelectorString allBold, '" ', err |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
3567 |
] ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3568 |
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
|
3569 |
]. |
1157
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3570 |
"/ 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
|
3571 |
(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
|
3572 |
^ aSelectorString |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3573 |
]. |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3574 |
isSyntaxHighlighter ifTrue:[ |
1439 | 3575 |
posVector do:[:p | |
3576 |
self markUnknownIdentifierFrom:(p start) to:(p stop). |
|
3577 |
]. |
|
3578 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3579 |
isSyntaxHighlighter ifFalse:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3580 |
err := err , '\\This is a warning from the compiler - the code has not yet been executed/compiled.'. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3581 |
newSelector := self correctSelector:aSelectorString |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3582 |
message:err withCRs |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3583 |
positions:posVector in:selClass for:receiver. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3584 |
"/ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3585 |
^ newSelector. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3586 |
]. |
141 | 3587 |
]. |
1022 | 3588 |
^ aSelectorString |
141 | 3589 |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3590 |
"Modified: / 05-09-1995 / 17:02:11 / claus" |
1983 | 3591 |
"Modified: / 10-02-2007 / 21:36:31 / cg" |
1327 | 3592 |
! |
3593 |
||
3594 |
typeOfNode:aNode |
|
1687 | 3595 |
|nodeVal nodeType classHint rClass| |
1327 | 3596 |
|
3597 |
aNode isConstant ifTrue:[ |
|
1687 | 3598 |
"if the receiver is a constant, we know its class..." |
1327 | 3599 |
nodeVal := aNode evaluate. |
3600 |
^ nodeVal class. |
|
3601 |
]. |
|
3602 |
||
3603 |
aNode isBlock ifTrue:[ |
|
1687 | 3604 |
"/ this should help with typos, sending #ifTrue to blocks ... |
1327 | 3605 |
^ Block |
3606 |
]. |
|
1687 | 3607 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3608 |
aNode isVariable ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3609 |
nodeType := aNode type. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3610 |
(nodeType == #GlobalVariable or:[nodeType == #PrivateClass]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3611 |
"if the receiver is a global, we check it too ..." |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3612 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3613 |
nodeVal := aNode evaluate. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3614 |
"/ dont check autoloaded classes |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3615 |
"/ - it may work after loading |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3616 |
(nodeVal isNil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3617 |
or:[nodeVal isBehavior and:[nodeVal isLoaded not]]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3618 |
^ nil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3619 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3620 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3621 |
^ nodeVal class. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3622 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3623 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3624 |
(aNode isLocal) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3625 |
classHint := aNode token classHint. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3626 |
classHint notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3627 |
^ Smalltalk classNamed:classHint |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3628 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3629 |
]. |
1327 | 3630 |
]. |
3631 |
||
3632 |
aNode isSuper ifTrue:[ |
|
3633 |
"if its a super- or here-send, we can do more checking" |
|
3634 |
aNode isHere ifFalse:[ |
|
3635 |
^ classToCompileFor superclass ? UndefinedObject. |
|
3636 |
]. |
|
3637 |
^ classToCompileFor. |
|
3638 |
]. |
|
3639 |
aNode isSelf ifTrue:[ |
|
3640 |
^ classToCompileFor. |
|
3641 |
]. |
|
3642 |
||
3643 |
(aNode isUnaryMessage) ifTrue:[ |
|
3644 |
(aNode selector == #class) ifTrue:[ |
|
1687 | 3645 |
"/ aNode receiver isSelf ifTrue:[ |
3646 |
"/ "its a message to self class - can check this too ..." |
|
3647 |
"/ ^ classToCompileFor class. |
|
3648 |
"/ ]. |
|
3649 |
rClass := self typeOfNode:aNode receiver. |
|
3650 |
rClass notNil ifTrue:[ |
|
3651 |
^ rClass class. |
|
1327 | 3652 |
]. |
3653 |
]. |
|
3654 |
( #(#'isNil' #'notNil') includes:aNode selector) ifTrue:[ |
|
3655 |
^ Boolean. |
|
3656 |
] |
|
3657 |
]. |
|
3658 |
aNode isBinaryMessage ifTrue:[ |
|
3659 |
( #(#'<' #'>' #'>=' #'<=' #'=' #'==' #'~=' #'~~') includes:aNode selector) ifTrue:[ |
|
3660 |
^ Boolean. |
|
3661 |
] |
|
3662 |
]. |
|
3663 |
||
3664 |
^ nil |
|
0 | 3665 |
! ! |
3666 |
||
3667 |
!Parser methodsFor:'error handling'! |
|
3668 |
||
1259 | 3669 |
blockArgRedefined:tokenName from:pos1 to:pos2 |
3670 |
"argname reuse" |
|
3671 |
||
3672 |
self isSyntaxHighlighter ifTrue:[ |
|
3673 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3674 |
] ifFalse:[ |
|
3675 |
self |
|
3676 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3677 |
position:pos1 to:pos2 |
|
3678 |
]. |
|
3679 |
! |
|
3680 |
||
1495 | 3681 |
errorMessageForUndefined:aName |
3682 |
|idx implementors| |
|
3683 |
||
3684 |
classToCompileFor notNil ifTrue:[ |
|
3685 |
"/ is it an instance-variable marked inaccessable ? |
|
3686 |
||
3687 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
3688 |
idx ~~ 0 ifTrue:[ |
|
3689 |
^ '''%1'' is a hidden instvar (not accessable from ST-code)'. |
|
3690 |
]. |
|
3691 |
||
3692 |
"/ is it an instance variable, while evaluateing for the class ? |
|
3693 |
classToCompileFor isMeta ifTrue:[ |
|
3694 |
(classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[ |
|
3695 |
^ 'Warning: ''%1'' is an instvar\(hint: you are evaluating/compiling in the classes context)'. |
|
3696 |
] |
|
3697 |
] |
|
3698 |
]. |
|
3699 |
self isDoIt ifTrue:[ |
|
1576 | 3700 |
SystemBrowser notNil ifTrue:[ |
1569
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3701 |
implementors := SystemBrowser |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3702 |
findImplementorsOf:aName |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3703 |
in:(Smalltalk allClasses) |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3704 |
ignoreCase:false. |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3705 |
implementors size > 0 ifTrue:[ |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3706 |
^ '''%1'' is undefined but known as a message selector.\(hint: did you forget to select the receiver ?)'. |
1576 | 3707 |
]. |
1495 | 3708 |
]. |
3709 |
]. |
|
3710 |
^ '''%1'' is undefined'. |
|
3711 |
! |
|
3712 |
||
141 | 3713 |
exitWith:something |
3714 |
"this is the longjump out of evaluation via a return expression" |
|
3715 |
||
3716 |
evalExitBlock value:something |
|
3717 |
! |
|
3718 |
||
3719 |
identifierExpectedIn:what |
|
3720 |
|msg| |
|
3721 |
||
3722 |
(#(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
|
3723 |
msg := 'Reserved keyword in ' |
141 | 3724 |
] ifFalse:[ |
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3725 |
msg := 'Identifier expected in ' |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3726 |
]. |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3727 |
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
|
3728 |
position:tokenPosition to:source position1Based - 1. |
141 | 3729 |
^ #Error |
3730 |
! |
|
3731 |
||
1259 | 3732 |
methodArgRedefined:tokenName from:pos1 to:pos2 |
3733 |
"argname reuse" |
|
3734 |
||
3735 |
self isSyntaxHighlighter ifTrue:[ |
|
3736 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3737 |
] ifFalse:[ |
|
3738 |
self |
|
3739 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3740 |
position:pos1 to:pos2 |
|
3741 |
]. |
|
3742 |
! |
|
3743 |
||
0 | 3744 |
showErrorMessage:aMessage position:pos |
19 | 3745 |
"redefined since parser can give more detailed info about |
3746 |
the class & selector where the error occured." |
|
3747 |
||
1534 | 3748 |
|msg| |
71 | 3749 |
|
19 | 3750 |
ignoreErrors ifFalse:[ |
1985 | 3751 |
Smalltalk silentLoading ifFalse:[ |
1534 | 3752 |
msg := ''. |
1160 | 3753 |
pos notNil ifTrue:[ |
1534 | 3754 |
msg := msg , (pos printString). |
3755 |
msg := msg , ' '. |
|
1160 | 3756 |
]. |
1534 | 3757 |
msg := msg , aMessage. |
1160 | 3758 |
selector notNil ifTrue:[ |
1534 | 3759 |
msg := msg , ' in '. |
1160 | 3760 |
classToCompileFor notNil ifTrue:[ |
1534 | 3761 |
msg := msg , classToCompileFor name , '>>' |
3762 |
]. |
|
3763 |
msg := msg , selector. |
|
1160 | 3764 |
] ifFalse:[ |
3765 |
classToCompileFor notNil ifTrue:[ |
|
1534 | 3766 |
msg := msg , ' (' , classToCompileFor name , ')' |
1160 | 3767 |
] |
3768 |
]. |
|
1534 | 3769 |
|
3770 |
UserInformation isHandled ifTrue:[ |
|
3771 |
UserInformation raiseErrorString:msg |
|
3772 |
] ifFalse:[ |
|
3773 |
Transcript showCR:msg. |
|
3774 |
] |
|
1160 | 3775 |
] |
0 | 3776 |
] |
273 | 3777 |
|
3778 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 3779 |
! |
3780 |
||
171 | 3781 |
showErrorMessageForClass:aClass |
3782 |
"/ compiler parseError:'syntax error'. |
|
3783 |
Transcript show:' '. |
|
3784 |
aClass notNil ifTrue:[ |
|
1576 | 3785 |
Transcript show:aClass name , '>>' |
171 | 3786 |
]. |
3787 |
selector notNil ifTrue:[ |
|
1576 | 3788 |
Transcript show:(selector) |
171 | 3789 |
]. |
273 | 3790 |
Transcript showCR:' -> Error'. |
171 | 3791 |
|
3792 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 3793 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 3794 |
! |
3795 |
||
0 | 3796 |
undefError:aName position:pos1 to:pos2 |
3 | 3797 |
"report an undefined variable error - return true, if it should be |
86 | 3798 |
corrected. If not corrected, only one warning is made per undefined |
3799 |
variable." |
|
3800 |
||
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3801 |
|ex doCorrect boldName errMsg| |
1400 | 3802 |
|
3803 |
ex := UndefinedVariableNotification newException. |
|
3804 |
ex parser:self. |
|
3805 |
ex parameter:aName. |
|
3806 |
ex suspendedContext:thisContext. |
|
3807 |
doCorrect := ex raiseRequest. |
|
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3808 |
doCorrect notNil ifTrue:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3809 |
^ doCorrect |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3810 |
]. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3811 |
|
86 | 3812 |
" |
1985 | 3813 |
already warned about this one ? |
86 | 3814 |
" |
3815 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 3816 |
(warnedUndefVars includes:aName) ifTrue:[ |
3817 |
"already warned about this one" |
|
3818 |
^ false |
|
3819 |
]. |
|
86 | 3820 |
]. |
3821 |
||
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3822 |
"/ ignoreWarnings ifTrue:[^ false]. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3823 |
parserFlags warnUndeclared ifFalse:[^ false]. |
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3824 |
|
131 | 3825 |
"/ (classToCompileFor notNil |
3826 |
"/ and:[classToCompileFor superclass notNil |
|
3827 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
3828 |
"/ 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
|
3829 |
"/ ^ false |
131 | 3830 |
"/ ]. |
3831 |
||
1285 | 3832 |
boldName := aName allBold. |
3833 |
||
131 | 3834 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3835 |
errMsg := 'Error: "%1" is undefined' bindWith:boldName. |
1696 | 3836 |
aName isUppercaseFirst ifFalse:[ |
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3837 |
self showErrorMessage:errMsg position:pos1. |
877 | 3838 |
]. |
3839 |
doCorrect := false. |
|
86 | 3840 |
] ifFalse:[ |
877 | 3841 |
" |
3842 |
ask requestor for correct/continue/abort ... |
|
3843 |
it is supposed to raise abort or return true/false. |
|
3844 |
True return means that correction is wanted. |
|
3845 |
" |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3846 |
errMsg := (self errorMessageForUndefined:aName) bindWith:boldName. |
1495 | 3847 |
doCorrect := self |
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3848 |
correctableError:errMsg withCRs |
1495 | 3849 |
position:pos1 to:pos2 |
86 | 3850 |
]. |
3851 |
||
877 | 3852 |
doCorrect == false ifTrue:[ |
3853 |
warnedUndefVars isNil ifTrue:[ |
|
3854 |
warnedUndefVars := Set new. |
|
3855 |
]. |
|
3856 |
warnedUndefVars add:aName. |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3857 |
self classToCompileFor notNil ifTrue:[ |
1983 | 3858 |
Tools::ToDoListBrowser notNil ifTrue:[ |
3859 |
"/ experimental |
|
3860 |
self |
|
3861 |
notifyTodo:errMsg position:pos1 |
|
3862 |
className:(self classToCompileFor name) selector:selector |
|
2076 | 3863 |
severity:#error priority:#high |
1983 | 3864 |
equalityParameter:aName |
3865 |
checkAction:[:e | |
|
3866 |
e problemMethod notNil |
|
3867 |
and:[(e problemMethod usedGlobals includes:aName) |
|
3868 |
and:[(Smalltalk includesKey:aName) not]] ]. |
|
3869 |
]. |
|
1934
1abdc93d3bf7
experimental toDoList support
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
3870 |
]. |
3 | 3871 |
]. |
0 | 3872 |
|
86 | 3873 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
3874 |
|
1983 | 3875 |
"Modified: / 10-02-2007 / 21:36:45 / cg" |
1160 | 3876 |
! |
3877 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3878 |
warnSTXHereExtensionUsedAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3879 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3880 |
didWarnAboutSTXHereExtensionUsed ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3881 |
parserFlags warnSTXHereExtensionUsed ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3882 |
self warning:'here-sends are a nonstandard feature of ST/X' |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3883 |
position:position to:position+3. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3884 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3885 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3886 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3887 |
didWarnAboutSTXHereExtensionUsed := true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3888 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3889 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3890 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3891 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3892 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3893 |
warnSTXNameSpaceUseAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3894 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3895 |
didWarnAboutSTXNameSpaceUse ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3896 |
parserFlags warnSTXNameSpaceUse ifTrue:[ |
1664 | 3897 |
self warning:'NameSpaces are a nonstandard feature of ST/X' |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3898 |
doNotShowAgainAction:[ ParserFlags warnSTXSpecials:false ] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3899 |
position:position to:(source position1Based). |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3900 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3901 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3902 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3903 |
didWarnAboutSTXNameSpaceUse := false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3904 |
] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3905 |
] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3906 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3907 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3908 |
|
1160 | 3909 |
warnUnused:aNameCollection |
3910 |
"report an unused method variable" |
|
3911 |
||
1654 | 3912 |
|msg answer lineLength first| |
1160 | 3913 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3914 |
(ignoreErrors not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3915 |
and:[ignoreWarnings not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3916 |
and:[parserFlags warnUnusedVars]]) ifTrue:[ |
1638 | 3917 |
msg := 'Unused method variable(s): '. |
1654 | 3918 |
lineLength := msg size. |
3919 |
first := true. |
|
1160 | 3920 |
aNameCollection asSortedCollection do:[:name| |
1654 | 3921 |
first ifTrue:[ first := false ] ifFalse:[msg := msg , ', ']. |
3922 |
msg := msg , ('"',name allBold,'"'). |
|
3923 |
lineLength := lineLength + 2 + name size + 1. |
|
3924 |
lineLength > 60 ifTrue:[ |
|
3925 |
msg := msg , '\' withCRs. |
|
3926 |
lineLength := 0. |
|
3927 |
]. |
|
1638 | 3928 |
]. |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3929 |
|
1160 | 3930 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3931 |
self showErrorMessage:('Warning: ', msg) position:nil. |
1160 | 3932 |
] ifFalse:[ |
1167 | 3933 |
answer := requestor |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3934 |
unusedVariableWarning:msg |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3935 |
position:(localVarDefPosition first) to:(localVarDefPosition last) from:self. |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3936 |
|
1167 | 3937 |
answer == true ifTrue:[ |
3938 |
"/ delete the definitions ... |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3939 |
aNameCollection do:[:eachName | |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3940 |
self deleteDefinitionOf:eachName in:(localVarDefPosition first) to:(localVarDefPosition last). |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3941 |
]. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3942 |
RestartCompilationSignal raise |
1167 | 3943 |
]. |
1160 | 3944 |
]. |
2007 | 3945 |
|
3946 |
Tools::ToDoListBrowser notNil ifTrue:[ |
|
3947 |
"/ experimental |
|
3948 |
self |
|
3949 |
notifyTodo:msg position:(localVarDefPosition first) |
|
3950 |
className:(self classToCompileFor name) selector:selector |
|
2076 | 3951 |
severity:#warning priority:#low |
2007 | 3952 |
equalityParameter:nil |
3953 |
checkAction:nil. |
|
3954 |
]. |
|
3955 |
||
1160 | 3956 |
]. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3957 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3958 |
"Modified: / 17.11.2001 / 10:30:47 / cg" |
0 | 3959 |
! ! |
3960 |
||
1363 | 3961 |
!Parser methodsFor:'evaluating expressions'! |
3962 |
||
1683 | 3963 |
evaluate:aStringOrStream |
3964 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3965 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3966 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3967 |
is non-nil, it is evaluated if an error occurs. |
|
3968 |
Finally, compile specifies if the string should be compiled down to |
|
3969 |
bytecode or instead be interpreted from the parseTree. |
|
3970 |
The first should be done for doIts etc, where a readable walkback is |
|
3971 |
required. |
|
3972 |
The latter is better done for constants, styleSheet and resource |
|
3973 |
reading and simple sends, where the overhead of compilation is bigger |
|
3974 |
than the interpretation overhead." |
|
3975 |
||
3976 |
^ self |
|
3977 |
evaluate:aStringOrStream |
|
3978 |
in:nil |
|
3979 |
receiver:nil |
|
3980 |
notifying:requestor |
|
3981 |
logged:logged |
|
3982 |
ifFail:[ self error:'error in eval' ] |
|
3983 |
compile:false |
|
3984 |
checkForEndOfInput:true |
|
3985 |
! |
|
3986 |
||
1963 | 3987 |
evaluate:aStringOrStream compile:compile |
3988 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3989 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3990 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3991 |
is non-nil, it is evaluated if an error occurs. |
|
3992 |
Finally, compile specifies if the string should be compiled down to |
|
3993 |
bytecode or instead be interpreted from the parseTree. |
|
3994 |
The first should be done for doIts etc, where a readable walkback is |
|
3995 |
required. |
|
3996 |
The latter is better done for constants, styleSheet and resource |
|
3997 |
reading and simple sends, where the overhead of compilation is bigger |
|
3998 |
than the interpretation overhead." |
|
3999 |
||
4000 |
^ self |
|
4001 |
evaluate:aStringOrStream |
|
4002 |
in:nil |
|
4003 |
receiver:nil |
|
4004 |
notifying:requestor |
|
4005 |
logged:logged |
|
4006 |
ifFail:[ self error:'error in eval' ] |
|
4007 |
compile:compile |
|
4008 |
checkForEndOfInput:true |
|
4009 |
||
4010 |
"Created: / 07-12-2006 / 19:30:04 / cg" |
|
4011 |
! |
|
4012 |
||
1683 | 4013 |
evaluate:aStringOrStream ifFail:failBlock |
4014 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4015 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4016 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4017 |
is non-nil, it is evaluated if an error occurs. |
|
4018 |
Finally, compile specifies if the string should be compiled down to |
|
4019 |
bytecode or instead be interpreted from the parseTree. |
|
4020 |
The first should be done for doIts etc, where a readable walkback is |
|
4021 |
required. |
|
4022 |
The latter is better done for constants, styleSheet and resource |
|
4023 |
reading and simple sends, where the overhead of compilation is bigger |
|
4024 |
than the interpretation overhead." |
|
4025 |
||
4026 |
^ self |
|
4027 |
evaluate:aStringOrStream |
|
4028 |
in:nil |
|
4029 |
receiver:nil |
|
4030 |
notifying:requestor |
|
4031 |
logged:logged |
|
4032 |
ifFail:failBlock |
|
4033 |
compile:false |
|
4034 |
checkForEndOfInput:true |
|
4035 |
! |
|
4036 |
||
4037 |
evaluate:aStringOrStream in:aContext receiver:anObject |
|
4038 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4039 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4040 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4041 |
is non-nil, it is evaluated if an error occurs. |
|
4042 |
Finally, compile specifies if the string should be compiled down to |
|
4043 |
bytecode or instead be interpreted from the parseTree. |
|
4044 |
The first should be done for doIts etc, where a readable walkback is |
|
4045 |
required. |
|
4046 |
The latter is better done for constants, styleSheet and resource |
|
4047 |
reading and simple sends, where the overhead of compilation is bigger |
|
4048 |
than the interpretation overhead." |
|
4049 |
||
4050 |
^ self |
|
4051 |
evaluate:aStringOrStream |
|
4052 |
in:aContext |
|
4053 |
receiver:anObject |
|
4054 |
notifying:requestor |
|
4055 |
logged:logged |
|
4056 |
ifFail:[ self error:'error in eval' ] |
|
4057 |
compile:false |
|
4058 |
checkForEndOfInput:true |
|
4059 |
! |
|
4060 |
||
4061 |
evaluate:aStringOrStream in:aContext receiver:anObject ifFail:failBlock |
|
4062 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4063 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4064 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4065 |
is non-nil, it is evaluated if an error occurs. |
|
4066 |
Finally, compile specifies if the string should be compiled down to |
|
4067 |
bytecode or instead be interpreted from the parseTree. |
|
4068 |
The first should be done for doIts etc, where a readable walkback is |
|
4069 |
required. |
|
4070 |
The latter is better done for constants, styleSheet and resource |
|
4071 |
reading and simple sends, where the overhead of compilation is bigger |
|
4072 |
than the interpretation overhead." |
|
4073 |
||
4074 |
^ self |
|
4075 |
evaluate:aStringOrStream |
|
4076 |
in:aContext |
|
4077 |
receiver:anObject |
|
4078 |
notifying:requestor |
|
4079 |
logged:logged |
|
4080 |
ifFail:failBlock |
|
4081 |
compile:false |
|
4082 |
checkForEndOfInput:true |
|
4083 |
! |
|
4084 |
||
2063 | 4085 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
4086 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4087 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4088 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4089 |
is non-nil, it is evaluated if an error occurs. |
|
4090 |
Finally, compile specifies if the string should be compiled down to |
|
4091 |
bytecode or instead be interpreted from the parseTree. |
|
4092 |
The first should be done for doIts etc, where a readable walkback is |
|
4093 |
required. |
|
4094 |
The latter is better done for constants, styleSheet and resource |
|
4095 |
reading and simple sends, where the overhead of compilation is bigger |
|
4096 |
than the interpretation overhead." |
|
4097 |
||
4098 |
^ self |
|
4099 |
evaluate:aStringOrStream |
|
4100 |
in:aContext |
|
4101 |
receiver:anObject |
|
4102 |
notifying:requestor |
|
4103 |
logged:logged |
|
4104 |
ifFail:failBlock |
|
4105 |
compile:true |
|
4106 |
! |
|
4107 |
||
1363 | 4108 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
4109 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4110 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4111 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4112 |
is non-nil, it is evaluated if an error occurs. |
|
4113 |
Finally, compile specifies if the string should be compiled down to |
|
4114 |
bytecode or instead be interpreted from the parseTree. |
|
4115 |
The first should be done for doIts etc, where a readable walkback is |
|
4116 |
required. |
|
4117 |
The latter is better done for constants, styleSheet and resource |
|
4118 |
reading and simple sends, where the overhead of compilation is bigger |
|
4119 |
than the interpretation overhead." |
|
4120 |
||
1548 | 4121 |
^ self |
4122 |
evaluate:aStringOrStream |
|
4123 |
in:aContext |
|
4124 |
receiver:anObject |
|
4125 |
notifying:requestor |
|
4126 |
logged:logged |
|
4127 |
ifFail:failBlock |
|
4128 |
compile:compile |
|
4129 |
checkForEndOfInput:true |
|
4130 |
! |
|
4131 |
||
4132 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile checkForEndOfInput:checkForEndOfInput |
|
4133 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4134 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4135 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4136 |
is non-nil, it is evaluated if an error occurs. |
|
4137 |
Finally, compile specifies if the string should be compiled down to |
|
4138 |
bytecode or instead be interpreted from the parseTree. |
|
4139 |
The first should be done for doIts etc, where a readable walkback is |
|
4140 |
required. |
|
4141 |
The latter is better done for constants, styleSheet and resource |
|
4142 |
reading and simple sends, where the overhead of compilation is bigger |
|
4143 |
than the interpretation overhead." |
|
4144 |
||
1363 | 4145 |
|tree mustBackup loggedString chgStream value s sReal spc |
4146 |
nameSpaceQuerySignal compiler| |
|
4147 |
||
4148 |
aStringOrStream isNil ifTrue:[ |
|
4149 |
EmptySourceNotificationSignal raiseRequest. |
|
4150 |
^ nil |
|
4151 |
]. |
|
4152 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
|
4153 |
s := aStringOrStream. |
|
4154 |
] ifFalse:[ |
|
4155 |
loggedString := aStringOrStream. |
|
4156 |
s := ReadStream on:aStringOrStream. |
|
4157 |
]. |
|
4158 |
||
4159 |
self source:s. |
|
4160 |
||
4161 |
self parseForCode. |
|
4162 |
self foldConstants:nil. |
|
4163 |
self setSelf:anObject. |
|
4164 |
self setContext:aContext. |
|
4165 |
aContext notNil ifTrue:[ |
|
4166 |
self setSelf:(aContext receiver). |
|
4167 |
"/ aContext method notNil ifTrue:[ |
|
4168 |
"/ cls := aContext method mclass |
|
4169 |
"/ ]. |
|
4170 |
"/ self setClassToCompileFor:(cls ? aContext receiver class). |
|
4171 |
self setClassToCompileFor:(aContext receiver class). |
|
4172 |
]. |
|
4173 |
self notifying:requestor. |
|
4174 |
self nextToken. |
|
4175 |
self evalExitBlock:[:value | self release. ^ value]. |
|
4176 |
tree := self parseMethodBodyOrEmpty. |
|
4177 |
||
1548 | 4178 |
checkForEndOfInput ifTrue:[self checkForEndOfInput]. |
1363 | 4179 |
|
4180 |
"if reading from a stream, backup for next expression" |
|
4181 |
mustBackup ifTrue:[ |
|
4182 |
self backupPosition |
|
4183 |
]. |
|
4184 |
||
4185 |
(self errorFlag or:[tree == #Error]) ifTrue:[ |
|
4186 |
failBlock notNil ifTrue:[ |
|
4187 |
^ failBlock value |
|
4188 |
]. |
|
4189 |
^ #Error |
|
4190 |
]. |
|
4191 |
||
4192 |
tree isNil ifTrue:[ |
|
4193 |
EmptySourceNotificationSignal raiseRequest. |
|
4194 |
^ nil |
|
4195 |
]. |
|
4196 |
||
4197 |
(logged |
|
4198 |
and:[loggedString notNil |
|
4199 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
4200 |
Class updateChangeFileQuerySignal query ifTrue:[ |
|
4201 |
chgStream := Class changesStream. |
|
4202 |
chgStream notNil ifTrue:[ |
|
4203 |
chgStream nextChunkPut:loggedString. |
|
4204 |
chgStream cr. |
|
4205 |
chgStream close |
|
4206 |
] |
|
4207 |
]. |
|
4208 |
Project notNil ifTrue:[ |
|
4209 |
Class updateChangeListQuerySignal query ifTrue:[ |
|
4210 |
Project addDoIt:loggedString |
|
4211 |
] |
|
4212 |
] |
|
4213 |
]. |
|
4214 |
||
4215 |
" |
|
4216 |
during the evaluation, handle nameSpace queries |
|
4217 |
from the value as defined by any namespace directive. |
|
4218 |
This, if its a class definition expression, the class will |
|
4219 |
be installed there. |
|
4220 |
" |
|
4221 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
4222 |
||
4223 |
spc := self getNameSpace. |
|
4224 |
spc isNil ifTrue:[ |
|
4225 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
|
4226 |
spc := requestor currentNameSpace |
|
4227 |
] ifFalse:[ |
|
4228 |
spc := nameSpaceQuerySignal query. |
|
4229 |
] |
|
4230 |
]. |
|
4231 |
||
4232 |
nameSpaceQuerySignal answer:spc |
|
4233 |
do:[ |
|
4234 |
|method| |
|
4235 |
||
4236 |
" |
|
4237 |
if compile is false, or the parse tree is that of a constant, |
|
4238 |
or a variable, quickly return its value. |
|
4239 |
This is used for example, when reading simple objects |
|
4240 |
via #readFrom:. |
|
4241 |
The overhead of compiling a method is avoided in this case. |
|
4242 |
" |
|
4243 |
((SuppressDoItCompilation == true) |
|
4244 |
or:[compile not |
|
2063 | 4245 |
or:[tree isSimpleConstant |
4246 |
or:[tree isSimpleVariable |
|
1363 | 4247 |
or:[aStringOrStream isStream |
4248 |
or:[aContext notNil]]]]]) ifTrue:[ |
|
4249 |
^ tree evaluate |
|
4250 |
]. |
|
4251 |
||
4252 |
" |
|
4253 |
if I am the ByteCodeCompiler, |
|
4254 |
generate a dummy method, execute it and return the value. |
|
4255 |
otherwise, just evaluate the tree; slower, but not too bad ... |
|
4256 |
||
4257 |
This allows systems to be delivered without the ByteCodeCompiler, |
|
4258 |
and still evaluate expressions |
|
4259 |
(needed to read resource files or to process .rc files). |
|
4260 |
" |
|
4261 |
self == Parser ifTrue:[ |
|
4262 |
self evalExitBlock:[:value | self release. ^ value]. |
|
4263 |
value := tree evaluate. |
|
4264 |
self evalExitBlock:nil. |
|
4265 |
] ifFalse:[ |
|
4266 |
s := self correctedSource. |
|
4267 |
s isNil ifTrue:[ |
|
4268 |
aStringOrStream isStream ifTrue:[ |
|
4269 |
s := self collectedSource. "/ does not work yet ... |
|
4270 |
] ifFalse:[ |
|
4271 |
s := aStringOrStream |
|
4272 |
]. |
|
4273 |
]. |
|
4274 |
||
4275 |
"/ actually, its a block, to allow |
|
4276 |
"/ easy return ... |
|
4277 |
||
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
4278 |
sReal := 'doIt ^[ ' , s , '\] value' withCRs. |
1363 | 4279 |
|
1366
f91f6a0a56d5
when required to compile, use Compiler instead of self class.
Claus Gittinger <cg@exept.de>
parents:
1365
diff
changeset
|
4280 |
compiler := ByteCodeCompiler new. |
1363 | 4281 |
compiler initializeFlagsFrom:self. |
4282 |
method := compiler |
|
4283 |
compile:sReal |
|
4284 |
forClass:anObject class |
|
4285 |
inCategory:'_temporary_' |
|
4286 |
notifying:requestor |
|
4287 |
install:false |
|
4288 |
skipIfSame:false |
|
4289 |
silent:true |
|
4290 |
foldConstants:false. |
|
4291 |
||
4292 |
method notNil ifTrue:[ |
|
4293 |
method ~~ #Error ifTrue:[ |
|
4294 |
" |
|
4295 |
fake: patch the source string, to what the user expects |
|
4296 |
in the browser |
|
4297 |
" |
|
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
4298 |
method source:"' ' , "s string. |
1363 | 4299 |
" |
4300 |
dont do any just-in-time compilation on it. |
|
4301 |
" |
|
4302 |
method checked:true. |
|
4303 |
||
4304 |
value := method |
|
4305 |
valueWithReceiver:anObject |
|
4306 |
arguments:nil "/ (Array with:m) |
|
1440 | 4307 |
selector:(requestor isNil ifTrue:#'doItX' ifFalse:#'doIt') "/ #doIt: |
1363 | 4308 |
search:nil |
4309 |
sender:nil. |
|
4310 |
] ifFalse:[ |
|
4311 |
self evalExitBlock:[:value | self release. ^ value]. |
|
4312 |
value := tree evaluate. |
|
4313 |
self evalExitBlock:nil. |
|
4314 |
] |
|
4315 |
]. |
|
4316 |
] |
|
4317 |
]. |
|
4318 |
self release. |
|
4319 |
^ value |
|
4320 |
||
4321 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
|
4322 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
|
4323 |
"Modified: / 6.2.2000 / 15:01:57 / cg" |
|
1683 | 4324 |
! |
4325 |
||
2106 | 4326 |
evaluate:aStringOrStream logged:logged |
4327 |
^ self |
|
4328 |
evaluate:aStringOrStream |
|
4329 |
in:nil |
|
4330 |
receiver:nil |
|
4331 |
notifying:nil |
|
4332 |
logged:logged |
|
4333 |
ifFail:[ self error:'error in eval' ] |
|
4334 |
compile:true |
|
4335 |
! |
|
4336 |
||
1683 | 4337 |
evaluate:aStringOrStream receiver:anObject |
4338 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4339 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4340 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4341 |
is non-nil, it is evaluated if an error occurs. |
|
4342 |
Finally, compile specifies if the string should be compiled down to |
|
4343 |
bytecode or instead be interpreted from the parseTree. |
|
4344 |
The first should be done for doIts etc, where a readable walkback is |
|
4345 |
required. |
|
4346 |
The latter is better done for constants, styleSheet and resource |
|
4347 |
reading and simple sends, where the overhead of compilation is bigger |
|
4348 |
than the interpretation overhead." |
|
4349 |
||
4350 |
^ self |
|
4351 |
evaluate:aStringOrStream |
|
4352 |
in:nil |
|
4353 |
receiver:anObject |
|
4354 |
notifying:requestor |
|
4355 |
logged:logged |
|
4356 |
ifFail:[ self error:'error in eval' ] |
|
4357 |
compile:false |
|
4358 |
checkForEndOfInput:true |
|
4359 |
! |
|
4360 |
||
4361 |
evaluate:aStringOrStream receiver:anObject ifFail:failBlock |
|
4362 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
4363 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
4364 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
4365 |
is non-nil, it is evaluated if an error occurs. |
|
4366 |
Finally, compile specifies if the string should be compiled down to |
|
4367 |
bytecode or instead be interpreted from the parseTree. |
|
4368 |
The first should be done for doIts etc, where a readable walkback is |
|
4369 |
required. |
|
4370 |
The latter is better done for constants, styleSheet and resource |
|
4371 |
reading and simple sends, where the overhead of compilation is bigger |
|
4372 |
than the interpretation overhead." |
|
4373 |
||
4374 |
^ self |
|
4375 |
evaluate:aStringOrStream |
|
4376 |
in:nil |
|
4377 |
receiver:anObject |
|
4378 |
notifying:requestor |
|
4379 |
logged:logged |
|
4380 |
ifFail:failBlock |
|
4381 |
compile:false |
|
4382 |
checkForEndOfInput:true |
|
1363 | 4383 |
! ! |
4384 |
||
2063 | 4385 |
!Parser methodsFor:'initialization'! |
4386 |
||
4387 |
initializeFlagsFrom:aParser |
|
4388 |
"initialize flags from another scanner" |
|
4389 |
||
4390 |
super initializeFlagsFrom:aParser. |
|
4391 |
||
4392 |
moreSharedPools := aParser moreSharedPools. |
|
4393 |
doItTemporaries := aParser doItTemporaries. |
|
4394 |
selector := aParser selector. |
|
4395 |
! ! |
|
4396 |
||
0 | 4397 |
!Parser methodsFor:'parsing'! |
4398 |
||
141 | 4399 |
block |
4400 |
"parse a block; return a node-tree, nil or #Error" |
|
4401 |
||
2054 | 4402 |
|startPos endPos node args argNames arg pos pos2 lno| |
4403 |
||
4404 |
startPos := tokenPosition. |
|
141 | 4405 |
|
4406 |
lno := tokenLineNr. |
|
4407 |
self nextToken. |
|
4408 |
(tokenType == $: ) ifTrue:[ |
|
663 | 4409 |
[tokenType == $:] whileTrue:[ |
4410 |
pos := tokenPosition. |
|
4411 |
self nextToken. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
4412 |
|
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
4413 |
(pos == (tokenPosition - 1)) ifFalse:[ |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
4414 |
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
|
4415 |
]. |
883 | 4416 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 4417 |
^ self identifierExpectedIn:'block-arg declaration' |
4418 |
]. |
|
883 | 4419 |
|
4420 |
pos2 := tokenPosition + tokenName size - 1. |
|
4421 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4422 |
self checkBlockArgumentNameConventionsFor:tokenName. |
663 | 4423 |
arg := Variable name:tokenName. |
4424 |
args isNil ifTrue:[ |
|
4425 |
args := Array with:arg. |
|
4426 |
argNames := Array with:tokenName. |
|
4427 |
] ifFalse:[ |
|
4428 |
(argNames includes:tokenName) ifTrue:[ |
|
1259 | 4429 |
self blockArgRedefined:tokenName from:tokenPosition to:pos2 |
663 | 4430 |
]. |
4431 |
args := args copyWith:arg. |
|
4432 |
argNames := argNames copyWith:tokenName. |
|
4433 |
]. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
4434 |
self nextToken. |
663 | 4435 |
]. |
4436 |
(tokenType ~~ $| ) ifTrue:[ |
|
4437 |
"ST-80 allows [:arg ]" |
|
4438 |
(tokenType == $] ) ifTrue:[ |
|
4439 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
4440 |
node lineNumber:lno. |
|
4441 |
^ node |
|
4442 |
]. |
|
4443 |
self syntaxError:'| expected after block-arg declaration'. |
|
4444 |
^ #Error |
|
4445 |
]. |
|
4446 |
self nextToken |
|
141 | 4447 |
]. |
4448 |
node := self blockBody:args. |
|
4449 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 4450 |
node lineNumber:lno. |
141 | 4451 |
]. |
2054 | 4452 |
|
4453 |
endPos := tokenPosition. |
|
4454 |
self markBlockFrom:startPos to:endPos. |
|
4455 |
||
141 | 4456 |
^ node |
663 | 4457 |
|
2054 | 4458 |
"Modified: / 15-01-2008 / 11:51:39 / cg" |
141 | 4459 |
! |
4460 |
||
4461 |
blockBody:args |
|
4462 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
4463 |
||
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
4464 |
|stats node var vars lno pos2| |
141 | 4465 |
|
4466 |
lno := tokenLineNr. |
|
4467 |
(tokenType == $| ) ifTrue:[ |
|
668 | 4468 |
self nextToken. |
4469 |
[tokenType == $|] whileFalse:[ |
|
4470 |
(tokenType == #Identifier) ifFalse:[ |
|
4471 |
^ self identifierExpectedIn:'block-var declaration' |
|
4472 |
]. |
|
883 | 4473 |
pos2 := tokenPosition + tokenName size - 1. |
4474 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4475 |
self checkBlockVariableNameConventionsFor:tokenName. |
668 | 4476 |
var := Variable name:tokenName. |
4477 |
vars isNil ifTrue:[ |
|
4478 |
vars := Array with:var. |
|
4479 |
] 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
|
4480 |
(vars contains:[:var | var name = tokenName]) ifTrue:[ |
883 | 4481 |
"/ varname reuse |
4482 |
self isSyntaxHighlighter ifTrue:[ |
|
4483 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
4484 |
] ifFalse:[ |
|
4485 |
self |
|
4486 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
4487 |
position:tokenPosition to:pos2. |
|
4488 |
] |
|
668 | 4489 |
] ifFalse:[ |
4490 |
vars := vars copyWith:var. |
|
4491 |
] |
|
4492 |
]. |
|
4493 |
self nextToken. |
|
1471 | 4494 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4495 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 4496 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
4497 |
self nextToken. |
|
4498 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
1987
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
4499 |
self shouldImplement. |
1471 | 4500 |
] |
4501 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4502 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 4503 |
(tokenType == $() ifTrue:[ |
4504 |
self variableTypeDeclarationFor:var. |
|
4505 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4506 |
]. |
668 | 4507 |
]. |
4508 |
self nextToken |
|
141 | 4509 |
]. |
382 | 4510 |
|
141 | 4511 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
4512 |
node lineNumber:lno. |
|
4513 |
currentBlock := node. |
|
4514 |
stats := self blockStatementList. |
|
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4515 |
(stats == #Error) ifTrue:[^ #Error]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4516 |
|
382 | 4517 |
lineNumberInfo == #full ifTrue:[ |
668 | 4518 |
node endLineNumber:tokenLineNr |
382 | 4519 |
]. |
141 | 4520 |
node statements:stats. |
4521 |
currentBlock := node home. |
|
4522 |
^ node |
|
382 | 4523 |
|
668 | 4524 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 4525 |
! |
4526 |
||
4527 |
blockExpression |
|
4528 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
4529 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
4530 |
||
4531 |
tokenType ~~ $[ ifTrue:[ |
|
1576 | 4532 |
self syntaxError:'[ expected'. |
4533 |
^ #Error. |
|
141 | 4534 |
]. |
4535 |
^ self block |
|
4536 |
! |
|
4537 |
||
4538 |
blockStatementList |
|
4539 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
4540 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4541 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 4542 |
|
4543 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
4544 |
thisStatement := self statement. |
|
4545 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4546 |
firstStatement := thisStatement. |
|
4547 |
[tokenType == $] ] whileFalse:[ |
|
673 | 4548 |
(tokenType == $.) ifFalse:[ |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4549 |
(tokenType == #EOF) ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4550 |
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
|
4551 |
^ #Error. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4552 |
]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4553 |
|
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4554 |
(tokenType == $) ) ifTrue:[ |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4555 |
eMsg := 'missing '']'' or bad '')'' in block' |
673 | 4556 |
] ifFalse:[ |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4557 |
eMsg := 'missing ''.'' between statements (i.e. ''' , tokenType printString , '''-token unexpected)' |
673 | 4558 |
]. |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4559 |
self syntaxError:eMsg position:tokenPosition to:tokenPosition. |
673 | 4560 |
^ #Error |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4561 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4562 |
prevStatement := thisStatement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4563 |
self nextToken. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4564 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4565 |
tokenType == $] ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4566 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4567 |
*** 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
|
4568 |
*** 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
|
4569 |
*** 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
|
4570 |
*** became annoying |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4571 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4572 |
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
|
4573 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4574 |
self markBracketAt:tokenPosition. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4575 |
^ firstStatement |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4576 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4577 |
thisStatement := self statement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4578 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4579 |
prevStatement nextStatement:thisStatement |
141 | 4580 |
]. |
673 | 4581 |
self markBracketAt:tokenPosition. |
141 | 4582 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4583 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4584 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 4585 |
! |
4586 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4587 |
checkForEndOfInput |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4588 |
|what msg endPos| |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4589 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4590 |
(tokenType ~~ #EOF) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4591 |
"/ just for the nicer error message |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4592 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4593 |
msg := '"',tokenName allBold,'" unexpected (missing "." or ":" before ' , tokenName , ' ?)'. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4594 |
endPos := tokenPosition + tokenName size - 1. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4595 |
] ifFalse:[ |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4596 |
tokenType isCharacter ifTrue:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4597 |
what := '"' , tokenType asString allBold, '"'. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4598 |
] ifFalse:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4599 |
what := tokenType printString allBold. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4600 |
]. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4601 |
msg := what , ' unexpected. (missing ".", ":" or selector before it ?)'. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4602 |
endPos := source position1Based-1. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4603 |
]. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4604 |
self parseError:msg position:tokenPosition to:endPos. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4605 |
^#Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4606 |
] |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4607 |
|
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
4608 |
"Modified: / 22-08-2006 / 14:22:45 / cg" |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4609 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4610 |
|
1951 | 4611 |
emptyStatement |
2059
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
4612 |
(parserFlags allowEmptyStatements |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
4613 |
or:[parserFlags allowSqueakExtensions == true]) ifTrue:[ |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
4614 |
self warnAboutEmptyStatement. |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
4615 |
self nextToken. |
1951 | 4616 |
]. |
4617 |
||
4618 |
"Created: / 20-11-2006 / 14:04:14 / cg" |
|
1983 | 4619 |
"Modified: / 10-02-2007 / 21:35:34 / cg" |
1951 | 4620 |
! |
4621 |
||
1006 | 4622 |
parseExpressionWithSelf:anObject notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
4623 |
"parse aString as an expression with self set to anObject; |
|
4624 |
Return the parseTree (if ok), nil (for an empty string |
|
4625 |
or comment only ) or #Error (syntactic error). |
|
4626 |
||
4627 |
Errors and warnings are forwarded to someOne (usually some |
|
4628 |
codeView) which can highlight it and show a popup box, |
|
4629 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
4630 |
||
4631 |
|tree token| |
|
4632 |
||
4633 |
aNameSpaceOrNil notNil ifTrue:[ |
|
4634 |
self currentNameSpace:aNameSpaceOrNil |
|
4635 |
]. |
|
4636 |
self setSelf:anObject. |
|
4637 |
self notifying:someOne. |
|
1365 | 4638 |
self ignoreErrors:ignoreErrors. |
4639 |
self ignoreWarnings:ignoreWarnings. |
|
1006 | 4640 |
token := self nextToken. |
4641 |
(token == $^) ifTrue:[ |
|
4642 |
self nextToken. |
|
4643 |
]. |
|
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4644 |
(token == #EOF) ifTrue:[ |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4645 |
^ nil |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4646 |
]. |
1006 | 4647 |
tree := self expression. |
4648 |
(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
|
4649 |
"/ tokenType ~~ #EOF ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4650 |
"/ 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
|
4651 |
"/ ]. |
1006 | 4652 |
^ tree |
4653 |
||
4654 |
"Created: / 14.12.1999 / 15:11:37 / cg" |
|
4655 |
! |
|
4656 |
||
1259 | 4657 |
parseExtendedMethodSpec |
4658 |
|pos1 pos2 var| |
|
4659 |
||
4660 |
"/ EXPERIMENTAL |
|
4661 |
false ifTrue:[ |
|
4662 |
(tokenType == #Symbol) ifTrue:[ |
|
4663 |
pos1 := tokenPosition. |
|
4664 |
selector := token asSymbol. |
|
4665 |
self nextToken. |
|
4666 |
self markMethodSelectorFrom:pos1 to:(tokenPosition-1). |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4667 |
beginOfBodyPosition := tokenPosition. |
1259 | 4668 |
|
4669 |
tokenType == $( ifTrue:[ |
|
4670 |
self nextToken. |
|
4671 |
[ tokenType ~~ $) ] whileTrue:[ |
|
4672 |
||
4673 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
|
4674 |
pos2 := tokenPosition+tokenName size-1. |
|
4675 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
4676 |
var := Variable name:tokenName. |
|
4677 |
methodArgs isNil ifTrue:[ |
|
4678 |
methodArgs := Array with:var. |
|
4679 |
methodArgNames := Array with:tokenName |
|
4680 |
] ifFalse:[ |
|
4681 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4682 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
|
4683 |
]. |
|
4684 |
methodArgs := methodArgs copyWith:var. |
|
4685 |
methodArgNames := methodArgNames copyWith:tokenName |
|
4686 |
]. |
|
4687 |
self nextToken. |
|
4688 |
]. |
|
4689 |
self nextToken. |
|
4690 |
]. |
|
4691 |
||
4692 |
^ self |
|
4693 |
]. |
|
4694 |
]. |
|
4695 |
^ #Error |
|
4696 |
! |
|
4697 |
||
0 | 4698 |
parseMethod |
19 | 4699 |
"parse a method. |
4700 |
Return the parseTree or #Error. |
|
4701 |
||
4702 |
method ::= methodSpec methodBody |
|
4703 |
" |
|
0 | 4704 |
|
4705 |
|parseTree| |
|
4706 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4707 |
"/ self nextToken. |
0 | 4708 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
4709 |
parseTree := self parseMethodBody. |
|
4710 |
(parseTree == #Error) ifFalse:[ |
|
1171
0c43ce981f1b
oops - remove unused vars does not work (yet)
Claus Gittinger <cg@exept.de>
parents:
1169
diff
changeset
|
4711 |
self tree:parseTree |
0 | 4712 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4713 |
self checkForEndOfInput. |
0 | 4714 |
^ parseTree |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4715 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4716 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 4717 |
! |
4718 |
||
1842 | 4719 |
parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
4720 |
"parse a method in a given class. |
|
4721 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
4722 |
The parser can be queried for selector, receiver, args, locals, |
|
4723 |
used selectors, modified instvars, referenced classvars etc. |
|
4724 |
The noErrors and noWarnings arguments specify if error and warning |
|
4725 |
messages should be sent to the Transcript or suppressed." |
|
4726 |
||
4727 |
|parser tree| |
|
4728 |
||
4729 |
aString isNil ifTrue:[^ nil]. |
|
4730 |
||
4731 |
self initializeFor:(ReadStream on:aString). |
|
4732 |
self setClassToCompileFor:aClass. |
|
4733 |
self ignoreErrors:ignoreErrors. |
|
4734 |
self ignoreWarnings:ignoreWarnings. |
|
4735 |
tree := self parseMethod. |
|
4736 |
(self errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
4737 |
^ tree |
|
4738 |
||
4739 |
"Created: / 21-08-2006 / 18:26:36 / cg" |
|
4740 |
! |
|
4741 |
||
19 | 4742 |
parseMethodBody |
4743 |
"parse a methods body (locals & statements). |
|
4744 |
No more tokens may follow. |
|
4745 |
Return a node-tree, or #Error |
|
4746 |
||
4747 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 4748 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 4749 |
|
4750 |
" |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4751 |
|stats| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4752 |
|
1951 | 4753 |
tokenType == $. ifTrue:[ |
4754 |
self emptyStatement. |
|
4755 |
]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4756 |
stats := self parseMethodBodyOrEmpty. |
19 | 4757 |
(stats == #Error) ifFalse:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4758 |
self checkForEndOfInput. |
19 | 4759 |
]. |
1160 | 4760 |
ignoreWarnings ifFalse:[ |
1714
ba7113f4bce1
honor disabled warning flags
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
4761 |
parserFlags warnings ifTrue:[ |
ba7113f4bce1
honor disabled warning flags
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
4762 |
self checkUnusedMethodVars. |
ba7113f4bce1
honor disabled warning flags
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
4763 |
self checkReturnedValues. |
ba7113f4bce1
honor disabled warning flags
Claus Gittinger <cg@exept.de>
parents:
1710
diff
changeset
|
4764 |
] |
1160 | 4765 |
]. |
19 | 4766 |
^ stats |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
4767 |
|
1951 | 4768 |
"Modified: / 20-11-2006 / 14:04:24 / cg" |
19 | 4769 |
! |
4770 |
||
79 | 4771 |
parseMethodBodyOrEmpty |
0 | 4772 |
"parse a methods body (locals & statements); |
19 | 4773 |
return a node-tree, nil or #Error. |
4774 |
empty (or comment only) input is accepted and returns nil. |
|
4775 |
||
4776 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4777 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4778 |
| <empty> |
19 | 4779 |
" |
0 | 4780 |
|
265 | 4781 |
|stats| |
0 | 4782 |
|
4783 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
4784 |
||
1951 | 4785 |
tokenType == $. ifTrue:[ |
4786 |
self emptyStatement. |
|
4787 |
]. |
|
0 | 4788 |
(tokenType ~~ #EOF) ifTrue:[ |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4789 |
stats := self statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4790 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4791 |
"/ (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
|
4792 |
"/ 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
|
4793 |
"/ ^ #Error |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4794 |
"/ ]. |
1231 | 4795 |
(stats notNil |
4796 |
and:[stats ~~ #Error]) ifTrue:[ |
|
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
4797 |
(self isStatementAnUnconditionalReturn:stats last) ifFalse:[ |
1231 | 4798 |
"/ remember a returned self here. |
1262 | 4799 |
self rememberReturnedValue:(self selfNode) |
1231 | 4800 |
]. |
4801 |
]. |
|
1551 | 4802 |
tree notNil ifTrue:[ |
4803 |
tree last nextStatement:stats. |
|
4804 |
^ tree. |
|
4805 |
]. |
|
0 | 4806 |
^ stats |
265 | 4807 |
|
1951 | 4808 |
"Modified: / 20-11-2006 / 14:04:40 / cg" |
0 | 4809 |
! |
4810 |
||
19 | 4811 |
parseMethodBodyVarSpec |
265 | 4812 |
"parse a methods local variable specification, handling |
4813 |
possible primitive or resourceSpecs. |
|
4814 |
. |
|
19 | 4815 |
Leave spec of locals in methodLocals as a side effect. |
4816 |
Return #Error or nil. |
|
0 | 4817 |
|
19 | 4818 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 4819 |
| <empty> |
19 | 4820 |
" |
0 | 4821 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4822 |
|var pos pos2 msg classHint| |
0 | 4823 |
|
265 | 4824 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 4825 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 4826 |
]. |
4827 |
||
0 | 4828 |
(tokenType == $|) ifTrue:[ |
663 | 4829 |
"memorize position for declaration in correction" |
883 | 4830 |
|
1638 | 4831 |
localVarDefPosition := Array with:tokenPosition with:nil. |
663 | 4832 |
self nextToken. |
4833 |
pos := tokenPosition. |
|
4834 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 4835 |
pos2 := tokenPosition + tokenName size - 1. |
4836 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4837 |
self checkMethodVariableNameConventionsFor:tokenName. |
663 | 4838 |
var := Variable name:tokenName. |
883 | 4839 |
|
663 | 4840 |
methodVars isNil ifTrue:[ |
4841 |
methodVars := OrderedCollection with:var. |
|
4842 |
methodVarNames := OrderedCollection with:tokenName |
|
4843 |
] ifFalse:[ |
|
4844 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 4845 |
"/ redefinition |
4846 |
self isSyntaxHighlighter ifTrue:[ |
|
4847 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
4848 |
] ifFalse:[ |
|
4849 |
self |
|
1638 | 4850 |
parseError:'redefinition of ''' , tokenName , ''' in local variables.' |
883 | 4851 |
position:tokenPosition to:pos2. |
4852 |
] |
|
663 | 4853 |
] ifFalse:[ |
4854 |
methodVars add:var. |
|
4855 |
methodVarNames add:tokenName |
|
4856 |
] |
|
4857 |
]. |
|
883 | 4858 |
|
1638 | 4859 |
parserFlags warnHiddenVariables ifTrue:[ |
4860 |
methodArgNames notNil ifTrue:[ |
|
4861 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4862 |
self |
|
4863 |
warning:'local variable "' , tokenName allBold , '" hides method argument.' |
|
1683 | 4864 |
doNotShowAgainAction:[ ParserFlags warnHiddenVariables:false ] |
1638 | 4865 |
position:tokenPosition to:pos2 |
4866 |
] |
|
4867 |
]. |
|
4868 |
classToCompileFor notNil ifTrue:[ |
|
4869 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
|
1675
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4870 |
classToCompileFor isMeta ifTrue:[ |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4871 |
self |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4872 |
warning:'local variable "' , tokenName allBold , '" hides class instance variable.' |
1683 | 4873 |
doNotShowAgainAction:[ ParserFlags warnHiddenVariables:false ] |
1675
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4874 |
position:tokenPosition to:pos2 |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4875 |
] ifFalse:[ |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4876 |
self |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4877 |
warning:'local variable "' , tokenName allBold , '" hides instance variable.' |
1683 | 4878 |
doNotShowAgainAction:[ ParserFlags warnHiddenVariables:false ] |
1675
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4879 |
position:tokenPosition to:pos2 |
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
4880 |
] |
1638 | 4881 |
] |
4882 |
]. |
|
663 | 4883 |
]. |
1638 | 4884 |
|
663 | 4885 |
self nextToken. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4886 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4887 |
classHint := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4888 |
lastDirective notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4889 |
lastDirective isClassHintDirective ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4890 |
var classHint:lastDirective className. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4891 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4892 |
lastDirective := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4893 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4894 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4895 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 4896 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
4897 |
self nextToken. |
|
4898 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
1987
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
4899 |
self shouldImplement. |
1471 | 4900 |
] |
4901 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4902 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 4903 |
(tokenType == $() ifTrue:[ |
4904 |
self variableTypeDeclarationFor:var. |
|
4905 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4906 |
]. |
663 | 4907 |
pos := tokenPosition |
4908 |
]. |
|
883 | 4909 |
|
663 | 4910 |
(tokenType ~~ $|) ifTrue:[ |
4911 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
1638 | 4912 |
msg := 'reserved keyword "',tokenName allBold,'" in local var declaration'. |
883 | 4913 |
pos2 := tokenPosition + tokenName size - 1. |
4914 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 4915 |
] ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4916 |
pos2 := source position1Based-1. |
663 | 4917 |
msg := 'Identifier or | expected in local var declaration' |
4918 |
]. |
|
883 | 4919 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 4920 |
^ #Error |
4921 |
]. |
|
1638 | 4922 |
localVarDefPosition at:2 put:tokenPosition. |
663 | 4923 |
self nextToken |
0 | 4924 |
]. |
984 | 4925 |
|
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
4926 |
(parserFlags allowSqueakPrimitives |
1744 | 4927 |
or:[ parserFlags allowSqueakExtensions |
1710 | 4928 |
or:[ parserFlags allowVisualAgePrimitives |
1744 | 4929 |
or:[ parserFlags allowSTVPrimitives ]]]) ifTrue:[ |
984 | 4930 |
"/ allow for primitiveSpec after local-var decl. |
4931 |
||
4932 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
|
4933 |
self parsePrimitiveOrResourceSpecOrEmpty. |
|
4934 |
] |
|
4935 |
]. |
|
4936 |
||
0 | 4937 |
^ nil |
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
4938 |
|
663 | 4939 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 4940 |
! |
4941 |
||
141 | 4942 |
parseMethodSpec |
4943 |
"parse a methods selector & arg specification; |
|
4944 |
Set selector and methodArgs in the receiver as a side effect. |
|
4945 |
Return the receiver or #Error. |
|
4946 |
||
4947 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4948 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4949 |
| IDENTIFIER |
141 | 4950 |
" |
4951 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4952 |
|arg pos2| |
141 | 4953 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4954 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4955 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4956 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4957 |
|
141 | 4958 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4959 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4960 |
[tokenType == #Keyword] whileTrue:[ |
663 | 4961 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4962 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4963 |
self nextToken. |
883 | 4964 |
|
1259 | 4965 |
(tokenType ~~ #Identifier) ifTrue:[ |
4966 |
"/ ^ #Error]. |
|
4967 |
^ self identifierExpectedIn:'method-arg declaration' |
|
4968 |
]. |
|
4969 |
||
883 | 4970 |
pos2 := tokenPosition+tokenName size-1. |
4971 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4972 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4973 |
arg := Variable name:tokenName. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4974 |
methodArgs isNil ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4975 |
methodArgs := Array with:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4976 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4977 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4978 |
(methodArgNames includes:tokenName) ifTrue:[ |
1259 | 4979 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4980 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4981 |
methodArgs := methodArgs copyWith:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4982 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4983 |
]. |
1638 | 4984 |
parserFlags warnHiddenVariables ifTrue:[ |
1776
65df22979f49
plausibilityCheck of unary expression fixed
Claus Gittinger <cg@exept.de>
parents:
1774
diff
changeset
|
4985 |
classToCompileFor isClass ifTrue:[ |
1638 | 4986 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
4987 |
self |
|
4988 |
warning:'argument "' , tokenName allBold , '" hides instance variable.' |
|
4989 |
position:tokenPosition to:pos2 |
|
4990 |
] |
|
4991 |
]. |
|
4992 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4993 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4994 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4995 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4996 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4997 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4998 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4999 |
selector := selector asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5000 |
endOfSelectorPosition := pos2. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5001 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5002 |
^ self |
141 | 5003 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5004 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5005 |
(self isValidUnarySelector:tokenType) ifTrue:[ |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5006 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5007 |
self markMethodSelectorFrom:tokenPosition to:pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5008 |
selector := tokenName asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5009 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5010 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5011 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5012 |
^ self |
141 | 5013 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5014 |
|
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
5015 |
"/ 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
|
5016 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5017 |
tokenType := #BinaryOperator. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
5018 |
token := tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
5019 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
5020 |
|
141 | 5021 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 5022 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5023 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5024 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5025 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5026 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5027 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
1519 | 5028 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5029 |
arg := Variable name:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5030 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5031 |
methodArgs := Array with:arg. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5032 |
methodArgNames := Array with:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5033 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5034 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5035 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
5036 |
beginOfBodyPosition := tokenPosition. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5037 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5038 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5039 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5040 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
5041 |
^ self |
141 | 5042 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
5043 |
|
1259 | 5044 |
^ self parseExtendedMethodSpec |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
5045 |
|
1776
65df22979f49
plausibilityCheck of unary expression fixed
Claus Gittinger <cg@exept.de>
parents:
1774
diff
changeset
|
5046 |
"Modified: / 17-07-2006 / 00:44:26 / cg" |
141 | 5047 |
! |
5048 |
||
713 | 5049 |
statement |
5050 |
"parse a statement; return a node-tree or #Error. |
|
5051 |
||
5052 |
statement ::= '^' expression |
|
5053 |
| PRIMITIVECODE |
|
5054 |
| expression |
|
5055 |
" |
|
5056 |
||
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
5057 |
|expr node lnr code| |
713 | 5058 |
|
5059 |
(tokenType == $^) ifTrue:[ |
|
837 | 5060 |
self markReturnAt:tokenPosition. |
713 | 5061 |
lnr := tokenLineNr. |
5062 |
self nextToken. |
|
5063 |
expr := self expression. |
|
5064 |
(expr == #Error) ifTrue:[^ #Error]. |
|
5065 |
node := ReturnNode expression:expr. |
|
5066 |
node home:self blockHome:currentBlock. |
|
1946
7d7c1dc9fa5f
care for lineNumbers in Return statements.
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
5067 |
true "(lineNumberInfo == #full)" ifTrue:[node lineNumber:lnr]. |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
5068 |
|
1231 | 5069 |
self rememberReturnedValue:expr. |
713 | 5070 |
^ node |
5071 |
]. |
|
5072 |
||
5073 |
(tokenType == #Primitive) ifTrue:[ |
|
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
5074 |
code := tokenValue. |
713 | 5075 |
self nextToken. |
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
5076 |
node := PrimitiveNode code:code. |
713 | 5077 |
node isOptional ifFalse:[ |
5078 |
hasNonOptionalPrimitiveCode := true |
|
5079 |
]. |
|
5080 |
hasPrimitiveCode := true. |
|
5081 |
^ node |
|
5082 |
]. |
|
5083 |
||
5084 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5085 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5086 |
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
|
5087 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5088 |
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
|
5089 |
]. |
713 | 5090 |
^ #Error |
5091 |
]. |
|
5092 |
||
984 | 5093 |
(tokenType == $.) ifTrue:[ |
2059
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5094 |
(parserFlags allowEmptyStatements |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5095 |
or:[parserFlags allowSqueakExtensions == true]) ifTrue:[ |
984 | 5096 |
"/ allow empty statement |
2059
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5097 |
self warnAboutEmptyStatement. |
984 | 5098 |
^ StatementNode expression:nil. |
5099 |
]. |
|
5100 |
]. |
|
5101 |
||
713 | 5102 |
expr := self expression. |
5103 |
(expr == #Error) ifTrue:[^ #Error]. |
|
5104 |
||
5105 |
"/ classToCompileFor notNil ifTrue:[ |
|
5106 |
"/ currentBlock isNil ifTrue:[ |
|
5107 |
"/ expr isPrimary ifTrue:[ |
|
5108 |
"/ self warning:'useless computation - missing ^ ?' |
|
5109 |
"/ ] |
|
5110 |
"/ ] |
|
5111 |
"/ ]. |
|
5112 |
||
5113 |
node := StatementNode expression:expr. |
|
5114 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
5115 |
^ node |
|
5116 |
||
1946
7d7c1dc9fa5f
care for lineNumbers in Return statements.
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
5117 |
"Modified: / 16-11-2006 / 14:37:06 / cg" |
713 | 5118 |
! |
5119 |
||
5120 |
statementList |
|
5121 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
5122 |
Statements must be separated by periods. |
|
5123 |
||
5124 |
statementList ::= <statement> |
|
988 | 5125 |
| <statementList> . <statement> |
713 | 5126 |
" |
5127 |
||
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
5128 |
|thisStatement prevStatement firstStatement periodPos prevExpr| |
713 | 5129 |
|
5130 |
thisStatement := self statement. |
|
5131 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
5132 |
firstStatement := thisStatement. |
|
5133 |
[tokenType == $.] whileTrue:[ |
|
988 | 5134 |
prevExpr := thisStatement expression. |
5135 |
(prevExpr notNil |
|
5136 |
and:[prevExpr isMessage |
|
5137 |
and:[thisStatement isReturnNode not]]) ifTrue:[ |
|
5138 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
1487 | 5139 |
self warning:'useless computation - mistyped assignment (i.e. did you mean '':='') ?' position:prevExpr selectorPosition |
988 | 5140 |
]. |
5141 |
]. |
|
5142 |
||
5143 |
periodPos := tokenPosition. |
|
5144 |
self nextToken. |
|
1951 | 5145 |
tokenType == $. ifTrue:[ |
5146 |
self emptyStatement. |
|
5147 |
]. |
|
988 | 5148 |
(tokenType == $]) ifTrue:[ |
5149 |
currentBlock isNil ifTrue:[ |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
5150 |
self parseError:''']'' unexpected (block nesting error)'. |
988 | 5151 |
]. |
5152 |
^ firstStatement |
|
5153 |
]. |
|
5154 |
(tokenType == #EOF) ifTrue:[ |
|
5155 |
currentBlock notNil ifTrue:[ |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
5156 |
self parseError:''']'' expected (block nesting error)'. |
988 | 5157 |
]. |
5158 |
^ firstStatement |
|
5159 |
]. |
|
5160 |
||
5161 |
prevStatement := thisStatement. |
|
5162 |
prevStatement isReturnNode ifTrue:[ |
|
5163 |
self warning:'statements after return' position:tokenPosition |
|
5164 |
]. |
|
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
5165 |
|
988 | 5166 |
thisStatement := self statement. |
5167 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
5168 |
prevStatement nextStatement:thisStatement |
|
713 | 5169 |
]. |
5170 |
^ firstStatement |
|
5171 |
||
1951 | 5172 |
"Modified: / 20-11-2006 / 14:05:52 / cg" |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5173 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5174 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5175 |
variableTypeDeclarationFor:aVariable |
1471 | 5176 |
"experimental support for Domain variables (constraint programming support): |
5177 |
a variable-declaration of the form |
|
5178 |
|var (domain) ... | |
|
5179 |
declares var as a domainVariable. |
|
5180 |
Valid domains are: |
|
5181 |
min %% max - integer range domain |
|
5182 |
Bool - boolean domain |
|
5183 |
Nat - positive integer domain |
|
5184 |
Int - integer domain |
|
5185 |
#sym1 ... #sym2 - enumerated symbolic domain |
|
5186 |
" |
|
5187 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5188 |
|min max domain enumValues| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5189 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5190 |
(tokenType == $() ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5191 |
self syntaxError:'''('' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5192 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5193 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5194 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5195 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5196 |
(tokenType == #Integer) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5197 |
min := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5198 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5199 |
((tokenType == #BinaryOperator) and:[token = '%%']) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5200 |
self syntaxError:'''%%'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5201 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5202 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5203 |
(tokenType == #Integer) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5204 |
self syntaxError:'Integer (upper bound) expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5205 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5206 |
max := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5207 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5208 |
domain := IntegerDomain min:min max:max. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5209 |
] ifFalse:[ |
1696 | 5210 |
((tokenType == #Identifier) and:[token isUppercaseFirst]) ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5211 |
token = 'Bool' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5212 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5213 |
domain := BooleanDomain new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5214 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5215 |
token = 'Nat' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5216 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5217 |
domain := IntegerDomain min:0 max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5218 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5219 |
token = 'Int' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5220 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5221 |
domain := IntegerDomain min:(SmallInteger minVal) max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5222 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5223 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5224 |
((tokenType == #Symbol) or:[(tokenType == #Identifier)]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5225 |
enumValues := OrderedCollection new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5226 |
[((tokenType == #Symbol) or:[(tokenType == #Identifier)])] whileTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5227 |
enumValues add:token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5228 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5229 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5230 |
domain := EnumeratedDomain new values:enumValues. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5231 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5232 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5233 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5234 |
domain isNil ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5235 |
self syntaxError:'invalid domain' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5236 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5237 |
aVariable domain:domain. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5238 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5239 |
(tokenType == $)) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5240 |
self syntaxError:''')'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5241 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5242 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5243 |
self nextToken. |
2059
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5244 |
! |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5245 |
|
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5246 |
warnAboutEmptyStatement |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5247 |
parserFlags warnAboutPossibleSTCCompilationProblems ifTrue:[ |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5248 |
self |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5249 |
warning:'stc will not compile empty statements' |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5250 |
line:lineNr. |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5251 |
|
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5252 |
Tools::ToDoListBrowser notNil ifTrue:[ |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5253 |
self |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5254 |
notifyTodo:'stc will not compile empty statements' position:tokenPosition |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5255 |
className:(self classToCompileFor name) selector:selector |
2076 | 5256 |
severity:#warning priority:#medium |
2059
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5257 |
equalityParameter:nil |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5258 |
checkAction:nil. |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5259 |
]. |
25c8eb0ff9df
empty statement parsing (squeak compat.)
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
5260 |
]. |
713 | 5261 |
! ! |
5262 |
||
5263 |
!Parser methodsFor:'parsing-expressions'! |
|
5264 |
||
5265 |
array |
|
5266 |
|arr elements elem pos1| |
|
5267 |
||
5268 |
pos1 := tokenPosition. |
|
5269 |
elements := OrderedCollection new:20. |
|
5270 |
[tokenType ~~ $) ] whileTrue:[ |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5271 |
elem := self arrayConstant. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5272 |
|
1062 | 5273 |
"/ (elem == #Error) ifTrue:[ |
5274 |
"/ (tokenType == #EOF) ifTrue:[ |
|
5275 |
"/ self syntaxError:'unterminated array-constant; '')'' expected' |
|
5276 |
"/ position:pos1 to:tokenPosition |
|
5277 |
"/ ]. |
|
5278 |
"/ ^ #Error |
|
5279 |
"/ ]. |
|
713 | 5280 |
elem isSymbol ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5281 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
713 | 5282 |
]. |
5283 |
elements add:elem. |
|
1951 | 5284 |
self nextToken. |
5285 |
tokenType == $. ifTrue:[ |
|
5286 |
self emptyStatement. |
|
5287 |
]. |
|
713 | 5288 |
]. |
5289 |
arr := Array withAll:elements. |
|
5290 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5291 |
parserFlags arraysAreImmutable ifTrue:[ |
1615 | 5292 |
^ self makeImmutableArray:arr |
713 | 5293 |
]. |
5294 |
^ arr |
|
5295 |
||
1951 | 5296 |
"Modified: / 20-11-2006 / 14:07:39 / cg" |
713 | 5297 |
! |
5298 |
||
5299 |
arrayConstant |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5300 |
|val| |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5301 |
|
713 | 5302 |
(tokenType == #Nil) ifTrue:[ |
1683 | 5303 |
self warnPossibleIncompatibility:'nil in array constant is interpreted as #nil (symbol) in other smalltalks' position:tokenPosition to:tokenPosition+token size - 1. |
5304 |
^ tokenValue |
|
5305 |
]. |
|
5306 |
(tokenType == #True) ifTrue:[ |
|
5307 |
self warnPossibleIncompatibility:'true in array constant is interpreted as #true (symbol) in other smalltalks' position:tokenPosition to:tokenPosition+token size - 1. |
|
5308 |
^ tokenValue |
|
5309 |
]. |
|
5310 |
(tokenType == #False) ifTrue:[ |
|
5311 |
self warnPossibleIncompatibility:'false in array constant is interpreted as #false (symbol) in other smalltalks' position:tokenPosition to:tokenPosition+token size - 1. |
|
5312 |
^ tokenValue |
|
713 | 5313 |
]. |
5314 |
((tokenType == #Integer) |
|
5315 |
or:[tokenType == #Float]) ifTrue:[ |
|
5316 |
^ tokenValue |
|
5317 |
]. |
|
1615 | 5318 |
(tokenType == #String) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5319 |
parserFlags stringsAreImmutable ifTrue:[^ self makeImmutableString:tokenValue]. |
1615 | 5320 |
^ tokenValue |
5321 |
]. |
|
5322 |
(tokenType == #Character) ifTrue:[ |
|
713 | 5323 |
^ tokenValue |
5324 |
]. |
|
5325 |
(tokenType == #Error) ifTrue:[ |
|
1062 | 5326 |
^ ParseErrorSignal raise. |
713 | 5327 |
]. |
5328 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5329 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5330 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5331 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5332 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5333 |
^ val |
713 | 5334 |
]. |
5335 |
||
5336 |
"/ some more special symbol consts ... |
|
5337 |
(tokenType == $| ) ifTrue:[ |
|
5338 |
^ #| |
|
5339 |
]. |
|
5340 |
(tokenType == #Self ) ifTrue:[ |
|
5341 |
^ #'self' |
|
5342 |
]. |
|
5343 |
(tokenType == #Super ) ifTrue:[ |
|
5344 |
^ #'super' |
|
5345 |
]. |
|
5346 |
(tokenType == #Here ) ifTrue:[ |
|
5347 |
^ #'here' |
|
5348 |
]. |
|
5349 |
(tokenType == #ThisContext ) ifTrue:[ |
|
5350 |
^ #'thisContext' |
|
5351 |
]. |
|
5352 |
||
5353 |
((tokenType == #Keyword) |
|
5354 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5355 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5356 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5357 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5358 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5359 |
^ val |
713 | 5360 |
]. |
5361 |
((tokenType == $() |
|
5362 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
5363 |
self nextToken. |
|
5364 |
^ self array |
|
5365 |
]. |
|
5366 |
((tokenType == $[) |
|
5367 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
5368 |
self nextToken. |
|
5369 |
^ self byteArray |
|
5370 |
]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5371 |
(tokenType == #HashLeftBrace) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5372 |
val := self qualifiedName. |
1716
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
5373 |
"/ val := QualifiedName for:val name. |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
5374 |
val := val value. |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5375 |
^ val |
1683 | 5376 |
]. |
713 | 5377 |
(tokenType == #Symbol) ifTrue:[ |
1066
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
5378 |
parseForCode ifFalse:[ |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
5379 |
self rememberSymbolUsed:tokenValue. |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
5380 |
]. |
713 | 5381 |
^ tokenValue |
5382 |
]. |
|
5383 |
(tokenType == #EOF) ifTrue:[ |
|
5384 |
"just for the better error-hilight; let caller handle error" |
|
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
5385 |
self syntaxError:'EOF unexpected in array-constant'. |
1062 | 5386 |
^ ParseErrorSignal raise. |
713 | 5387 |
]. |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
5388 |
self syntaxError:('"' |
713 | 5389 |
, tokenType printString |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
5390 |
, '" unexpected in array-constant'). |
1062 | 5391 |
^ ParseErrorSignal raise. |
713 | 5392 |
|
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
5393 |
"Modified: / 22-08-2006 / 14:21:16 / cg" |
713 | 5394 |
! |
5395 |
||
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5396 |
arrayIndexingExpression |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5397 |
"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
|
5398 |
foo[idx] is syntactic sugar for foo matrixAt:x |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5399 |
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
|
5400 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5401 |
|receiver argList selectorStream valNode| |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5402 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5403 |
receiver := self functionCallExpression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5404 |
tokenType == $[ ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5405 |
parserFlags allowArrayIndexSyntaxExtension == true ifFalse:[^ receiver.]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5406 |
(receiver == #Error) ifTrue:[^ #Error]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5407 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5408 |
selectorStream := WriteStream on: (String new: 32). |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5409 |
argList := OrderedCollection new. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5410 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5411 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5412 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5413 |
|indexNode| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5414 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5415 |
self nextToken. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5416 |
indexNode := self primary. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5417 |
argList isEmpty ifTrue:[selectorStream nextPutAll:'_']. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5418 |
selectorStream nextPutAll:'at:'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5419 |
argList add: indexNode. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5420 |
(tokenType == #BinaryOperator ) and:[ token = ','] |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5421 |
] whileTrue. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5422 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5423 |
tokenType == $] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5424 |
self parseError:''']'' expected'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5425 |
^ #Error |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5426 |
]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5427 |
self nextToken. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5428 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5429 |
tokenType == $[ ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5430 |
receiver := MessageNode |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5431 |
receiver:receiver |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5432 |
selector:(selectorStream contents) |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5433 |
args:argList. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5434 |
selectorStream := WriteStream on: (String new: 32). |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5435 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5436 |
tokenType == $[ |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5437 |
] whileTrue. |
1411 | 5438 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5439 |
tokenType == #':=' ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5440 |
self nextToken. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5441 |
selectorStream nextPutAll:'put:'. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5442 |
valNode := self expression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5443 |
valNode == #Error ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5444 |
^ valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5445 |
]. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5446 |
"/ 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
|
5447 |
"/ (valNode isKindOf: BlockNode) ifFalse:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5448 |
"/ valNode _ BlockNode new |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5449 |
"/ arguments: #() |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5450 |
"/ statements: (OrderedCollection with: valNode) |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5451 |
"/ returns: false |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5452 |
"/ from: encoder. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5453 |
"/ ]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5454 |
argList add: valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5455 |
]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5456 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5457 |
^ MessageNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5458 |
receiver:receiver |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5459 |
selector:selectorStream contents |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5460 |
args:argList. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5461 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5462 |
" |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5463 |
AllowArrayIndexSyntaxExtension := true. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5464 |
AllowArrayIndexSyntaxExtension := false. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5465 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5466 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5467 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5468 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5469 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5470 |
foo := Array new:10 withAll:2. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5471 |
1 + foo[1]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5472 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5473 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5474 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5475 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5476 |
foo := Array new:10. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5477 |
foo[1] := 'hello'. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5478 |
foo[2]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
5479 |
foo[1]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5480 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5481 |
! |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
5482 |
|
713 | 5483 |
binaryExpression |
5484 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
5485 |
||
1328 | 5486 |
|receiver| |
713 | 5487 |
|
5488 |
receiver := self unaryExpression. |
|
5489 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 5490 |
^ self binaryExpressionFor:receiver |
5491 |
! |
|
5492 |
||
5493 |
binaryExpressionFor:receiverArg |
|
5494 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
5495 |
||
1547 | 5496 |
|receiver expr arg sel pos1 pos2 lno note| |
1328 | 5497 |
|
5498 |
receiver := receiverArg. |
|
5499 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
713 | 5500 |
|
5501 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
5502 |
expression or a negative constant, handle cases here" |
|
5503 |
||
5504 |
[(tokenType == #BinaryOperator) |
|
5505 |
or:[(tokenType == $|) |
|
5506 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
5507 |
and:[tokenValue < 0]]] |
|
5508 |
] whileTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5509 |
"/ 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
|
5510 |
inFunctionCallArgument == true ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5511 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5512 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5513 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5514 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5515 |
|
1547 | 5516 |
pos1 := tokenPosition. |
713 | 5517 |
lno := tokenLineNr. |
5518 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5519 |
"/ kludge alarm: bar and minus are not scanned as binop |
713 | 5520 |
(tokenType == $|) ifTrue:[ |
5521 |
sel := '|'. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5522 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:tokenPosition. |
713 | 5523 |
self nextToken |
5524 |
] ifFalse:[ |
|
5525 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5526 |
sel := tokenName. |
1022 | 5527 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
713 | 5528 |
self nextToken |
5529 |
] ifFalse:[ |
|
5530 |
sel := '-'. |
|
1683 | 5531 |
token := tokenValue := tokenValue negated. |
5532 |
tokenPosition := tokenPosition + 1. "/ to skip the sign |
|
713 | 5533 |
] |
5534 |
]. |
|
1547 | 5535 |
|
5536 |
pos2 := pos1 + sel size - 1. |
|
5537 |
self markSelector:sel from:pos1 to:pos2 receiverNode:receiver. |
|
713 | 5538 |
|
5539 |
arg := self unaryExpression. |
|
5540 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5541 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5542 |
expr := BinaryNode receiver:receiver selector:sel arg:arg fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5543 |
expr isErrorNode ifTrue:[ |
1547 | 5544 |
self parseError:(expr errorString) position:pos1 to:tokenPosition. |
713 | 5545 |
errorFlag := false. "ok, user wants it - so he'll get it" |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5546 |
expr := BinaryNode receiver:receiver selector:sel arg:arg fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5547 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5548 |
expr lineNumber:lno. |
1547 | 5549 |
expr selectorPosition:pos1. |
1687 | 5550 |
|
5551 |
(ignoreErrors or:[ignoreWarnings]) ifFalse:[ |
|
5552 |
note := self plausibilityCheck:expr. |
|
5553 |
note notNil ifTrue:[ |
|
5554 |
self warning:note position:pos1 to:pos2 |
|
5555 |
]. |
|
5556 |
]. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5557 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5558 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5559 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5560 |
receiver := expr. "/ for next message |
713 | 5561 |
]. |
5562 |
^ receiver |
|
5563 |
||
5564 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
1022 | 5565 |
"Modified: / 19.1.2000 / 16:22:04 / cg" |
713 | 5566 |
! |
5567 |
||
5568 |
byteArray |
|
5569 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
5570 |
||
5571 |
|bytes index limit newArray elem pos1 pos2| |
|
5572 |
||
5573 |
pos1 := tokenPosition. |
|
5574 |
bytes := ByteArray uninitializedNew:5000. |
|
5575 |
index := 0. limit := 5000. |
|
5576 |
[tokenType ~~ $] ] whileTrue:[ |
|
1576 | 5577 |
pos2 := tokenPosition. |
5578 |
" |
|
5579 |
this is not good programming style, but speeds up |
|
5580 |
reading of huge byte arrays (i.e. stored Images ...) |
|
5581 |
" |
|
5582 |
(tokenType == #Integer) ifTrue:[ |
|
5583 |
elem := tokenValue |
|
5584 |
] ifFalse:[ |
|
5585 |
elem := self arrayConstant. |
|
5586 |
(elem == #Error) ifTrue:[ |
|
5587 |
(tokenType == #EOF) ifTrue:[ |
|
5588 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
5589 |
position:pos1 to:tokenPosition |
|
5590 |
]. |
|
5591 |
^ #Error |
|
5592 |
]. |
|
5593 |
]. |
|
5594 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
5595 |
index := index + 1. |
|
5596 |
bytes at:index put:elem. |
|
5597 |
index == limit ifTrue:[ |
|
5598 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
5599 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
5600 |
limit := limit * 2. |
|
5601 |
bytes := newArray |
|
5602 |
]. |
|
5603 |
] ifFalse:[ |
|
5604 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
5605 |
]. |
|
5606 |
self nextToken. |
|
713 | 5607 |
]. |
5608 |
newArray := ByteArray uninitializedNew:index. |
|
5609 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
5610 |
^ newArray |
|
5611 |
! |
|
5612 |
||
5613 |
degeneratedKeywordExpressionForSelector |
|
1406 | 5614 |
"parse a keyword-expression without receiver - for the selector only. |
5615 |
Return the selector or nil (if it cannot be determined). |
|
5616 |
This is not used in normal parsing, but instead to extract the selector from a code fragment. |
|
5617 |
(for example, the system browsers 'implementors'-function uses this to extract a selector from |
|
5618 |
the selection)" |
|
713 | 5619 |
|
5620 |
|sel arg rec| |
|
5621 |
||
5622 |
(tokenType == #Keyword) ifTrue:[ |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5623 |
sel := tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5624 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5625 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5626 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5627 |
[tokenType == #Keyword] whileTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5628 |
sel := sel , tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5629 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5630 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5631 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5632 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5633 |
^ sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5634 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5635 |
|
1406 | 5636 |
(rec := self arrayIndexingExpression) == #Error ifTrue:[ ^ nil]. |
5637 |
sel := self degeneratedKeywordExpressionForSelector. |
|
5638 |
sel notNil ifTrue:[ ^ sel]. |
|
5639 |
||
1407 | 5640 |
rec isAssignment ifTrue:[ |
5641 |
rec := rec expression |
|
5642 |
]. |
|
1406 | 5643 |
rec isMessage ifTrue:[ |
5644 |
^ rec selector |
|
5645 |
]. |
|
5646 |
^ nil |
|
1524 | 5647 |
|
5648 |
" |
|
5649 |
(self new source:'hello:world:') nextToken; degeneratedKeywordExpressionForSelector |
|
5650 |
(self new source:'hello:world') nextToken; degeneratedKeywordExpressionForSelector |
|
5651 |
(self new source:'hello:') nextToken; degeneratedKeywordExpressionForSelector |
|
5652 |
" |
|
713 | 5653 |
! |
5654 |
||
5655 |
expression |
|
5656 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
5657 |
||
5658 |
expression ::= keywordExpression |
|
5659 |
| keywordExpression cascade |
|
5660 |
||
5661 |
cascade ::= ';' expressionSendPart |
|
5662 |
| cascade ';' expressionSendPart |
|
5663 |
||
5664 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
5665 |
| BINARYOPERATOR unaryExpression |
|
5666 |
| IDENTIFIER |
|
5667 |
" |
|
5668 |
||
864 | 5669 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 5670 |
|
5671 |
pos := tokenPosition. |
|
5672 |
receiver := self keywordExpression. |
|
5673 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
5674 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5675 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5676 |
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
|
5677 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5678 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5679 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5680 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5681 |
]. |
713 | 5682 |
[tokenType == $;] whileTrue:[ |
5683 |
self nextToken. |
|
5684 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5685 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5686 |
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
|
5687 |
sel := tokenName. |
1022 | 5688 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5689 |
receiver := CascadeNode receiver:receiver selector:sel. |
5690 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5691 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5692 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5693 |
]. |
713 | 5694 |
self nextToken. |
5695 |
] ifFalse:[ |
|
5696 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5697 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5698 |
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
|
5699 |
sel := tokenName. |
1022 | 5700 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5701 |
lno := tokenLineNr. |
5702 |
self nextToken. |
|
5703 |
arg := self unaryExpression. |
|
5704 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5705 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
5706 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5707 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5708 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5709 |
]. |
713 | 5710 |
] ifFalse:[ |
5711 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5712 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5713 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5714 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5715 |
pos2 := tokenEnd. |
713 | 5716 |
lno := tokenLineNr. |
5717 |
sel := tokenName. |
|
5718 |
self nextToken. |
|
5719 |
arg := self binaryExpression. |
|
5720 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5721 |
args := Array with:arg. |
|
5722 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5723 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5724 |
positions add:(tokenPosition to:tokenEnd). |
713 | 5725 |
sel := sel , tokenName. |
5726 |
self nextToken. |
|
5727 |
arg := self binaryExpression. |
|
5728 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5729 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5730 |
pos2 := tokenEnd |
713 | 5731 |
]. |
864 | 5732 |
positions do:[:p | |
5733 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
5734 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5735 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5736 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5737 |
|
713 | 5738 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
5739 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5740 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5741 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5742 |
]. |
713 | 5743 |
] ifFalse:[ |
5744 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
5745 |
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
|
5746 |
position:tokenPosition to:source position1Based - 1. |
713 | 5747 |
^ #Error |
5748 |
] |
|
5749 |
] |
|
5750 |
] |
|
5751 |
]. |
|
5752 |
||
5753 |
"obscure (unspecified ?) if selector follows; Question: |
|
5754 |
||
5755 |
is |
|
5756 |
'expr sel1; sel2 sel3' |
|
5757 |
||
5758 |
to be parsed as: |
|
5759 |
(t := expr. |
|
5760 |
t sel1. |
|
5761 |
t sel2) sel3 |
|
5762 |
||
5763 |
or: |
|
5764 |
(t := expr. |
|
5765 |
t sel1. |
|
5766 |
t sel2 sel3) |
|
5767 |
" |
|
5768 |
((tokenType == #Identifier) |
|
5769 |
or:[(tokenType == #BinaryOperator) |
|
5770 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
1328 | 5771 |
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
|
5772 |
position:tokenPosition to:source position1Based - 1. |
713 | 5773 |
^ #Error |
1328 | 5774 |
"/ self warning: "syntaxError:" 'possibly ambigous cascade - please group using (...)' |
5775 |
"/ position:tokenPosition to:source position - 1. |
|
5776 |
"/ tokenType == #Identifier ifTrue:[ |
|
5777 |
"/ ^ self unaryExpressionFor:receiver |
|
5778 |
"/ ]. |
|
5779 |
"/ tokenType == #BinaryOperator ifTrue:[ |
|
5780 |
"/ ^ self binaryExpressionFor:receiver |
|
5781 |
"/ ]. |
|
5782 |
"/ ^ self keywordExpressionFor:receiver |
|
713 | 5783 |
] |
5784 |
]. |
|
5785 |
^ receiver |
|
5786 |
||
1022 | 5787 |
"Modified: / 19.1.2000 / 16:22:16 / cg" |
713 | 5788 |
! |
5789 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5790 |
functionCallArgList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5791 |
|argList arg prevInFunctionCallArgument| |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5792 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5793 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5794 |
tokenType == $) ifTrue:[ self nextToken. ^ #() ]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5795 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5796 |
argList := OrderedCollection new. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5797 |
[ true ] whileTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5798 |
prevInFunctionCallArgument := inFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5799 |
inFunctionCallArgument := true. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5800 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5801 |
arg := self expression. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5802 |
argList add:arg. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5803 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5804 |
inFunctionCallArgument := prevInFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5805 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5806 |
tokenType == $) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5807 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5808 |
^ argList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5809 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5810 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5811 |
self parseError:'"," or ")" expected'. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5812 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5813 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5814 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5815 |
! |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5816 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5817 |
functionCallExpression |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5818 |
"parse a functionCall; |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5819 |
this is an st/x extension. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5820 |
foo(x) |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5821 |
is syntactic sugar for |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5822 |
foo value:x |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5823 |
" |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5824 |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5825 |
|receiver numArgs argList evalSelectors evalSelector| |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5826 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5827 |
receiver := self primary. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5828 |
tokenType == $( ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5829 |
parserFlags allowFunctionCallSyntaxForBlockEvaluation ifFalse:[^ receiver.]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5830 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5831 |
(receiver == #Error) ifTrue:[^ #Error]. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5832 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5833 |
receiver isVariable ifFalse:[ |
1991
a5f7cd07dcb6
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1987
diff
changeset
|
5834 |
((receiver isMessage or:[receiver isAssignment]) and:[receiver parenthesized]) ifFalse:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5835 |
receiver isBlock ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5836 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5837 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5838 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5839 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5840 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5841 |
argList := self functionCallArgList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5842 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5843 |
"/ make it a block evaluation |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5844 |
numArgs := argList size. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5845 |
numArgs == 0 ifTrue:[ |
1341 | 5846 |
^ UnaryNode receiver:receiver selector:#value |
5847 |
]. |
|
1579 | 5848 |
evalSelectors := #(#'value:' |
1341 | 5849 |
#'value:value:' |
5850 |
#'value:value:value:' |
|
5851 |
#'value:value:value:value:' |
|
5852 |
#'value:value:value:value:value:' |
|
5853 |
#'value:value:value:value:value:value:' |
|
5854 |
#'value:value:value:value:value:value:value:' |
|
5855 |
#'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
|
5856 |
). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5857 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5858 |
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
|
5859 |
evalSelector := evalSelectors at:numArgs. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5860 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5861 |
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
|
5862 |
selector:evalSelector |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5863 |
args:argList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5864 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5865 |
"/ gen argument vector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5866 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5867 |
receiver:receiver |
1341 | 5868 |
selector:#valueWithArguments: |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5869 |
args:(self genMakeArrayWith:argList). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5870 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5871 |
" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5872 |
Parser allowFunctionCallSyntaxForBlockEvaluation:true. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5873 |
" |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5874 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5875 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5876 |
|foo| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5877 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5878 |
foo := [:x | x + 1]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5879 |
1 + foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5880 |
foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5881 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5882 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5883 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5884 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5885 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5886 |
add1 := addN(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5887 |
add1(10). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5888 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5889 |
"AllowFunctionCallSyntaxForBlockEvaluation := false." |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5890 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5891 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5892 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5893 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5894 |
add1 := addN value:1. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5895 |
add1 value:10 |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5896 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5897 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5898 |
|
713 | 5899 |
keywordExpression |
5900 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5901 |
||
5902 |
keywordExpression ::= binaryexpression |
|
5903 |
| { KEYWORD-PART binaryExpression } |
|
5904 |
" |
|
5905 |
||
1328 | 5906 |
|receiver| |
5907 |
||
713 | 5908 |
receiver := self binaryExpression. |
5909 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 5910 |
^ self keywordExpressionFor:receiver |
5911 |
! |
|
5912 |
||
5913 |
keywordExpressionFor:receiverArg |
|
5914 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5915 |
||
5916 |
keywordExpression ::= binaryexpression |
|
5917 |
| { KEYWORD-PART binaryExpression } |
|
5918 |
" |
|
5919 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5920 |
|expr receiver sel arg args posR1 posR2 pos1 pos2 lno note positions| |
1328 | 5921 |
|
5922 |
receiver := receiverArg. |
|
5923 |
posR1 := tokenPosition. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5924 |
(tokenType == #Keyword) ifFalse:[^ receiver]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5925 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5926 |
pos1 := posR2 := tokenPosition. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5927 |
pos2 := tokenPosition + tokenName size - 1. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5928 |
positions := OrderedCollection with:(pos1 to:pos2). |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5929 |
sel := tokenName. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5930 |
lno := tokenLineNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5931 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5932 |
arg := self binaryExpression. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5933 |
(arg == #Error) ifTrue:[^ #Error]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5934 |
args := Array with:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5935 |
[tokenType == #Keyword] whileTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5936 |
sel := sel , tokenName. |
713 | 5937 |
pos2 := tokenPosition + tokenName size - 1. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5938 |
positions add:(tokenPosition to:pos2). |
713 | 5939 |
self nextToken. |
5940 |
arg := self binaryExpression. |
|
5941 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5942 |
args := args copyWith:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5943 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5944 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5945 |
positions do:[:p | |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5946 |
self markSelector:sel from:p start to:p stop receiverNode:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5947 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5948 |
sel := self selectorCheck:sel for:receiver positions:positions. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5949 |
|
1987
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
5950 |
ignoreWarnings ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5951 |
(Class definitionSelectors includes:sel) ifTrue:[ |
1987
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
5952 |
(receiver isVariable and:[receiver isUndeclared]) ifTrue:[ |
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
5953 |
"this is not an error - the undefined class may be loaded after this code!!" |
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
5954 |
self warning:('as yet undefined superclass: ' , receiver name) position:pos1 to:pos2. |
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
5955 |
]. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5956 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5957 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5958 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5959 |
expr := MessageNode receiver:receiver selector:sel args:args fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5960 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5961 |
self parseError:(expr errorString) position:pos1 to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5962 |
errorFlag := false. "ok, user wants it - so he'll get it" |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5963 |
expr := MessageNode receiver:receiver selector:sel args:args fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5964 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5965 |
expr lineNumber:lno. |
1687 | 5966 |
(ignoreErrors or:[ignoreWarnings]) ifFalse:[ |
5967 |
note := self plausibilityCheck:expr. |
|
5968 |
note notNil ifTrue:[ |
|
5969 |
self warning:note position:pos1 to:pos2 |
|
5970 |
]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5971 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5972 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5973 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5974 |
]. |
713 | 5975 |
|
1193 | 5976 |
"/ (contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
5977 |
"/ receiver isSuper ifTrue:[ |
|
5978 |
"/ sel ~= selector ifTrue:[ |
|
5979 |
"/ self warnCommonMistake:'possible bad super message (selector should be same as in current method) ?' |
|
5980 |
"/ position:posR1 to:posR2-1 |
|
5981 |
"/ ]. |
|
5982 |
"/ ]. |
|
5983 |
"/ ]. |
|
5984 |
"/ |
|
1685 | 5985 |
(ignoreErrors or:[ignoreWarnings]) ifFalse:[ |
5986 |
(sel = #and: or:[sel = #or:]) ifTrue:[ |
|
5987 |
expr arg1 isBlock ifFalse:[ |
|
5988 |
(expr arg1 isVariable |
|
5989 |
and:[ (expr arg1 name asLowercase includesString:'block')]) ifFalse:[ |
|
5990 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
5991 |
position:pos2+1 to:tokenPosition-1 |
|
5992 |
] |
|
1576 | 5993 |
]. |
1685 | 5994 |
^ expr. |
5995 |
]. |
|
5996 |
||
5997 |
(sel = #whileTrue: or:[sel = #whileFalse:]) ifTrue:[ |
|
5998 |
expr receiver isBlock ifFalse:[ |
|
5999 |
(expr receiver isVariable |
|
6000 |
and:[ (expr receiver name asLowercase includesString:'block')]) ifFalse:[ |
|
6001 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
6002 |
position:posR1 to:posR2-1 |
|
6003 |
] |
|
6004 |
]. |
|
6005 |
^ expr. |
|
6006 |
]. |
|
6007 |
||
6008 |
(sel = #ifTrue: or:[sel = #ifFalse:]) ifTrue:[ |
|
6009 |
expr receiver isMessage ifTrue:[ |
|
6010 |
(expr receiver selector = #whileTrue or:[expr receiver selector = #whileFalse]) ifTrue:[ |
|
6011 |
self warnCommonMistake:'strange receiver expression' |
|
6012 |
position:posR1 to:posR2-1 |
|
6013 |
]. |
|
6014 |
]. |
|
6015 |
^ expr |
|
6016 |
]. |
|
1576 | 6017 |
]. |
6018 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6019 |
^ expr. |
713 | 6020 |
|
1022 | 6021 |
"Modified: / 19.1.2000 / 16:22:22 / cg" |
713 | 6022 |
! |
6023 |
||
0 | 6024 |
primary |
1028 | 6025 |
"parse a primary-expression; return a node-tree, nil or #Error. |
6026 |
This also cares for namespace-access-pathes." |
|
0 | 6027 |
|
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6028 |
|val pos node eMsg endPos| |
924 | 6029 |
|
44 | 6030 |
(tokenType == #Self) ifTrue:[ |
1227 | 6031 |
^ self primary_self. |
6032 |
]. |
|
6033 |
||
6034 |
pos := tokenPosition. |
|
0 | 6035 |
(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
|
6036 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6037 |
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
|
6038 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6039 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6040 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6041 |
(self variableOrError:tokenName) == #Error ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6042 |
self warnSTXHereExtensionUsedAt:pos. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6043 |
tokenType := #Here. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6044 |
^ 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
|
6045 |
] |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6046 |
]. |
1227 | 6047 |
^ self primary_identifier |
0 | 6048 |
]. |
49 | 6049 |
|
44 | 6050 |
((tokenType == #Integer) |
120 | 6051 |
or:[(tokenType == #String) |
44 | 6052 |
or:[(tokenType == #Character) |
6053 |
or:[(tokenType == #Float) |
|
1657 | 6054 |
or:[(tokenType == #Symbol) |
6055 |
or:[(tokenType == #ESSymbol)]]]]]) ifTrue:[ |
|
1227 | 6056 |
^ self primary_simpleLiteral. |
0 | 6057 |
]. |
924 | 6058 |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
6059 |
(tokenType == #FixedPoint) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6060 |
parserFlags allowFixedPointLiterals == true ifFalse:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
6061 |
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
|
6062 |
^ #Error |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
6063 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
6064 |
^ self primary_simpleLiteral. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
6065 |
]. |
0 | 6066 |
(tokenType == #Nil) ifTrue:[ |
1227 | 6067 |
^ self primary_nil. |
6068 |
]. |
|
0 | 6069 |
(tokenType == #True) ifTrue:[ |
1227 | 6070 |
^ self primary_true |
0 | 6071 |
]. |
6072 |
(tokenType == #False) ifTrue:[ |
|
1227 | 6073 |
^ self primary_false |
6074 |
]. |
|
0 | 6075 |
(tokenType == #Super) ifTrue:[ |
1227 | 6076 |
^ self primary_super. |
6077 |
]. |
|
924 | 6078 |
|
0 | 6079 |
(tokenType == #ThisContext) ifTrue:[ |
1262 | 6080 |
^ self primary_thisContext |
0 | 6081 |
]. |
924 | 6082 |
|
0 | 6083 |
(tokenType == #HashLeftParen) ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6084 |
self nextToken. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
6085 |
self inArrayLiteral:true. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
6086 |
ParseErrorSignal handle:[:ex | |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
6087 |
self inArrayLiteral:false. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
6088 |
^ #Error |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
6089 |
] do:[ |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
6090 |
val := self array. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
6091 |
]. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
6092 |
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
|
6093 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6094 |
(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
|
6095 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6096 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6097 |
^ ConstantNode type:#Array value:val |
0 | 6098 |
]. |
924 | 6099 |
|
6100 |
(tokenType == #HashLeftBrace) ifTrue:[ |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6101 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6102 |
self nextToken. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6103 |
^ val. |
924 | 6104 |
]. |
6105 |
||
0 | 6106 |
(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
|
6107 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6108 |
val := self byteArray. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6109 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6110 |
(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
|
6111 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6112 |
]. |
924 | 6113 |
^ ConstantNode type:#ByteArray value:val |
0 | 6114 |
]. |
432 | 6115 |
|
0 | 6116 |
(tokenType == $() ifTrue:[ |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
6117 |
parenthesisLevel := parenthesisLevel + 1. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
6118 |
self markParenthesisAt:tokenPosition. |
1227 | 6119 |
^ self primary_expression. |
0 | 6120 |
]. |
924 | 6121 |
|
0 | 6122 |
(tokenType == $[ ) ifTrue:[ |
673 | 6123 |
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
|
6124 |
val := self block. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6125 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
6126 |
(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
|
6127 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6128 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6129 |
^ val |
0 | 6130 |
]. |
19 | 6131 |
|
1262 | 6132 |
"/ EXPERIMENTAL - may be in next release |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6133 |
parserFlags allowVariableReferences == true ifTrue:[ |
1295 | 6134 |
((tokenType == #BinaryOperator) and:[token = '&']) ifTrue:[ |
6135 |
self nextToken. |
|
6136 |
node := self primary_identifier. |
|
6137 |
"/ generate a Reference |
|
6138 |
^ self makeReferenceFor:node |
|
6139 |
]. |
|
6140 |
]. |
|
6141 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6142 |
(tokenType == ${ ) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6143 |
parserFlags allowSqueakExtensions == true ifFalse:[ |
1931 | 6144 |
didWarnAboutSqueakExtensions~~ true ifTrue:[ |
6145 |
didWarnAboutSqueakExtensions := true. |
|
6146 |
"/ self parseError:'non-Standard Squeak extension: Brace Computed Array. Enable in settings.' position:pos to:tokenPosition. |
|
6147 |
self |
|
6148 |
warning:('non-Standard Squeak extension: Brace Computed Array. Enable in settings.') |
|
6149 |
doNotShowAgainAction:[ ParserFlags allowSqueakExtensions:true ] |
|
6150 |
position:pos to:tokenPosition. |
|
6151 |
||
6152 |
"/ errorFlag := false. |
|
6153 |
]. |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6154 |
]. |
1227 | 6155 |
^ self primary_squeakComputedArray. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6156 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6157 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
6158 |
(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
|
6159 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6160 |
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
|
6161 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6162 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6163 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
6164 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
6165 |
|
1227 | 6166 |
tokenType == #HashHashLeftParen ifTrue:[ |
1295 | 6167 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6168 |
parserFlags allowDolphinExtensions == true ifFalse:[ |
1335 | 6169 |
self parseError:'non-Standard Dolphin extension: ##(..). Enable in settings.' position:pos to:tokenPosition. |
1227 | 6170 |
^ #Error |
6171 |
]. |
|
6172 |
^ self primary_dolphinComputedLiteral. |
|
6173 |
]. |
|
1299 | 6174 |
tokenType == #ExclaLeftBrack ifTrue:[ |
1295 | 6175 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6176 |
parserFlags allowLazyValueExtension == true ifFalse:[ |
1335 | 6177 |
self parseError:'non-Standard LazyValue extension. Enable in classVariable.' position:pos to:tokenPosition. |
1295 | 6178 |
^ #Error |
6179 |
]. |
|
6180 |
^ self primary_lazyValue. |
|
6181 |
]. |
|
6182 |
tokenType == #HashHash ifTrue:[ |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
6183 |
self warnPossibleIncompatibility:'''##'' might be interpreted differently in other smalltalk systems' position:pos to:tokenPosition. |
1295 | 6184 |
tokenType := #Symbol. |
6185 |
token := tokenValue := tokenName := '#'. |
|
6186 |
^ self primary_simpleLiteral. |
|
6187 |
]. |
|
1227 | 6188 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6189 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6190 |
((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6191 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6192 |
(tokenType == $( ) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6193 |
self parseError:'''('' expected after #.' position:pos to:tokenPosition. |
2005 | 6194 |
^ #Error. |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6195 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6196 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6197 |
self inArrayLiteral:true. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6198 |
ParseErrorSignal handle:[:ex | |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6199 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6200 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6201 |
] do:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6202 |
val := self array. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6203 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6204 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6205 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6206 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6207 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6208 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6209 |
^ ConstantNode type:#Array value:val |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6210 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6211 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6212 |
|
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6213 |
((tokenType == #BinaryOperator) and:[token = '-']) ifTrue:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6214 |
self nextToken. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6215 |
((tokenType == #Integer) |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6216 |
or:[(tokenType == #Float)]) ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6217 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 6218 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6219 |
]. |
1710 | 6220 |
((parserFlags allowSqueakExtensions == true) |
6221 |
or:[parserFlags allowSTVExtensions == true]) ifFalse:[ |
|
6222 |
self parseError:'non-Standard Squeak (or ST/V) extension: space between sign and number. Enable in settings.' position:pos to:tokenPosition. |
|
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6223 |
errorFlag := false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
6224 |
]. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6225 |
|
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6226 |
node := self primary_simpleLiteral. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6227 |
node isConstant ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6228 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 6229 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6230 |
]. |
1557
311e94185248
oops - parser clobbered Const1Node (negated)
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
6231 |
^ ConstantNode type:(node type) value:(node value negated). |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6232 |
]. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
6233 |
|
0 | 6234 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 6235 |
tokenType isCharacter ifTrue:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6236 |
eMsg := '"',tokenType printString,'" unexpected in primary.'. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6237 |
endPos := tokenPosition. |
0 | 6238 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6239 |
(#(BinaryOperator Keyword) includes:tokenType) ifTrue:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6240 |
eMsg := tokenType printString,' ("' , tokenName , '") ',' unexpected in primary. (missing receiver ?)' |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6241 |
] ifFalse:[ |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6242 |
(#(Integer Float) includes:tokenType) ifTrue:[ |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6243 |
eMsg := tokenType printString,' (' , tokenValue , ') ',' unexpected in primary. (missing receiver ?)' |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6244 |
] ifFalse:[ |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6245 |
eMsg := '"',(token ? ''),'" (',tokenType printString,') unexpected in primary.' |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6246 |
] |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6247 |
]. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6248 |
endPos :=source position1Based - 1. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6249 |
]. |
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6250 |
self syntaxError:eMsg position:tokenPosition to:endPos. |
0 | 6251 |
^ #Error |
120 | 6252 |
|
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6253 |
"Created: / 13-09-1995 / 12:50:50 / claus" |
1931 | 6254 |
"Modified: / 18-10-2006 / 19:37:50 / cg" |
0 | 6255 |
! |
6256 |
||
1227 | 6257 |
primary_dolphinComputedLiteral |
1273
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
6258 |
"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
|
6259 |
In dolphin, these are written as: ##( expression ) |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
6260 |
and create a literal constant for the expressions value. |
1274 | 6261 |
Right now, only a subset is supported - Strings, ByteArrays and Characters. |
6262 |
WARNING: this is only supported to allow filing in dolphin code. |
|
6263 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
6264 |
if you ever plan to stc-compile it into a shared library" |
|
1227 | 6265 |
|
6266 |
|pos expr val| |
|
6267 |
||
6268 |
pos := tokenPosition. |
|
6269 |
||
6270 |
expr := self expression. |
|
6271 |
||
6272 |
tokenType ~~ $) ifTrue:[ |
|
6273 |
self parseError:''')'' expected' position:tokenPosition. |
|
6274 |
^ #Error |
|
6275 |
]. |
|
6276 |
self nextToken. |
|
6277 |
||
6278 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
6279 |
^ #Error |
|
6280 |
]. |
|
6281 |
||
6282 |
val := expr evaluate. |
|
6283 |
||
6284 |
val isLiteral ifTrue:[ |
|
1272
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
6285 |
val isString ifTrue:[ |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
6286 |
^ ConstantNode type:#String value:val |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
6287 |
]. |
1227 | 6288 |
val isByteArray ifTrue:[ |
6289 |
^ ConstantNode type:#ByteArray value:val |
|
6290 |
]. |
|
1234 | 6291 |
val isCharacter ifTrue:[ |
6292 |
^ ConstantNode type:#Character value:val |
|
6293 |
]. |
|
1295 | 6294 |
val isInteger ifTrue:[ |
6295 |
^ ConstantNode type:#Integer value:val |
|
6296 |
]. |
|
1328 | 6297 |
val isLimitedPrecisionReal ifTrue:[ |
6298 |
^ ConstantNode type:#Float value:val |
|
6299 |
]. |
|
1295 | 6300 |
val isArray ifTrue:[ |
6301 |
^ ConstantNode type:#Array value:val |
|
6302 |
]. |
|
1227 | 6303 |
] ifFalse:[ |
6304 |
self parseError:'must be representable as a literal (for now)' position:pos. |
|
6305 |
^ #Error |
|
6306 |
]. |
|
1987
9e2e24397b1f
Do no treat subclass creation messages to undefined classes as error when filing in.
Stefan Vogel <sv@exept.de>
parents:
1985
diff
changeset
|
6307 |
self shouldImplement. |
1227 | 6308 |
"/ "/ make it an array creation expression ... |
6309 |
"/ expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6310 |
"/ receiver:(VariableNode globalNamed:#Array) |
1227 | 6311 |
"/ selector:#new: |
6312 |
"/ arg:(ConstantNode type:#Integer value:(exprList size)). |
|
6313 |
"/ |
|
6314 |
"/ exprList size == 0 ifTrue:[ |
|
6315 |
"/ ^ expr. |
|
6316 |
"/ ]. |
|
6317 |
"/ exprList keysAndValuesDo:[:idx :e | |
|
6318 |
"/ expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
|
6319 |
"/ receiver:expr |
|
6320 |
"/ selector:#at:put: |
|
6321 |
"/ arg1:(ConstantNode type:#Integer value:idx) |
|
6322 |
"/ arg2:e |
|
6323 |
"/ fold:false. |
|
6324 |
"/ ]. |
|
6325 |
"/ expr := CascadeNode |
|
6326 |
"/ receiver:expr |
|
6327 |
"/ selector:#yourself. |
|
6328 |
"/ ^ expr |
|
6329 |
! |
|
6330 |
||
6331 |
primary_expression |
|
6332 |
"parse a parentized expression primary; return a node-tree, or raise an Error." |
|
6333 |
||
6334 |
|pos val eMsg| |
|
6335 |
||
6336 |
pos := tokenPosition. |
|
6337 |
||
6338 |
self nextToken. |
|
6339 |
val := self expression. |
|
6340 |
(val == #Error) ifTrue:[^ #Error]. |
|
1758 | 6341 |
(tokenType == $) ) ifFalse:[ |
1227 | 6342 |
tokenType isCharacter ifTrue:[ |
6343 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
|
6344 |
] ifFalse:[ |
|
6345 |
eMsg := 'missing '')'''. |
|
6346 |
]. |
|
6347 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
|
6348 |
^ #Error |
|
6349 |
]. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
6350 |
self markParenthesisAt:tokenPosition. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
6351 |
parenthesisLevel := parenthesisLevel - 1. |
1227 | 6352 |
self nextToken. |
6353 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
6354 |
^ #Error |
|
6355 |
]. |
|
1991
a5f7cd07dcb6
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1987
diff
changeset
|
6356 |
val parenthesized:true. |
1227 | 6357 |
^ val |
6358 |
! |
|
6359 |
||
6360 |
primary_false |
|
6361 |
"parse a false primary; return a node-tree, or raise an Error." |
|
6362 |
||
6363 |
|pos| |
|
6364 |
||
6365 |
pos := tokenPosition. |
|
6366 |
||
6367 |
self nextToken. |
|
6368 |
(self noAssignmentAllowed:'assignment to ''false''' at:pos) ifFalse:[ |
|
6369 |
^ #Error |
|
6370 |
]. |
|
6371 |
self markBooleanConstantFrom:pos to:pos+4. |
|
6372 |
^ ConstantNode type:#False value:false |
|
6373 |
! |
|
6374 |
||
6375 |
primary_here |
|
6376 |
"parse a here primary; return a node-tree, nil or #Error." |
|
6377 |
||
6378 |
|pos| |
|
6379 |
||
6380 |
pos := tokenPosition. |
|
6381 |
||
6382 |
self nextToken. |
|
6383 |
(self noAssignmentAllowed:'assignment to pseudo variable ''here''' at:pos) ifFalse:[ |
|
6384 |
^ #Error |
|
6385 |
]. |
|
6386 |
classToCompileFor isNil ifTrue:[ |
|
6387 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
|
6388 |
]. |
|
6389 |
self markSelfFrom:pos to:pos+3. |
|
6390 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
|
6391 |
! |
|
6392 |
||
6393 |
primary_identifier |
|
1638 | 6394 |
"parse a primary; return a node-tree, or raise an Error." |
1227 | 6395 |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6396 |
|pos1 pos2 expr varName rawName var globlName nameSpace nameSpaceGlobal |
1551 | 6397 |
t cls lnr node holder autoHow assignmentAllowed| |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6398 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6399 |
pos1 := tokenPosition. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6400 |
pos2 := tokenPosition + tokenName size - 1. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6401 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6402 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6403 |
|
1440 | 6404 |
(self isDoIt |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
6405 |
and:[currentBlock isNil |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6406 |
and:[(requestor askFor:#isWorkspace) |
1359 | 6407 |
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
|
6408 |
var := self variableOrError:varName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6409 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6410 |
(var == #Error) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6411 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
1359 | 6412 |
autoHow == #workspace ifTrue:[ |
6413 |
holder := Workspace addWorkspaceVariable:varName. |
|
6414 |
var := VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
6415 |
] ifFalse:[ |
|
6416 |
holder := self addDoItTemporary:varName. |
|
6417 |
var := VariableNode type:#DoItTemporary holder:holder name:varName |
|
6418 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6419 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6420 |
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
|
6421 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6422 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6423 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6424 |
var := self variable. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6425 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6426 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6427 |
|
1227 | 6428 |
"/ errorFlag == true ifTrue:[self halt]. |
6429 |
(var == #Error) ifTrue:[ |
|
6430 |
errorFlag := true |
|
6431 |
]. |
|
6432 |
||
6433 |
(tokenType == #'::') ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6434 |
globlName := rawName := varName. |
1227 | 6435 |
|
6436 |
"is it in a namespace ?" |
|
6437 |
nameSpace := self findNameSpaceWith:globlName. |
|
6438 |
nameSpace notNil ifTrue:[ |
|
6439 |
globlName := nameSpace name , '::' , globlName |
|
6440 |
]. |
|
6441 |
||
6442 |
[tokenType == #'::'] whileTrue:[ |
|
6443 |
nameSpace := globlName. |
|
6444 |
||
6445 |
self nextToken. |
|
6446 |
(tokenType == #Identifier) ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6447 |
self warnSTXNameSpaceUseAt:pos1. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6448 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6449 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6450 |
globlName := (nameSpace , '::' , varName). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6451 |
rawName := (rawName , '::' , varName). |
1227 | 6452 |
|
6453 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
|
6454 |
nameSpaceGlobal isNil ifTrue:[ |
|
6455 |
warnedUnknownNamespaces isNil ifTrue:[ |
|
6456 |
warnedUnknownNamespaces := Set new. |
|
6457 |
]. |
|
6458 |
(warnedUnknownNamespaces includes:nameSpace) ifFalse:[ |
|
6459 |
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
|
6460 |
position:pos1 to:tokenPosition-1. |
1227 | 6461 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
6462 |
warnedUnknownNamespaces add:nameSpace. |
|
6463 |
] |
|
6464 |
] ifFalse:[ |
|
6465 |
nameSpaceGlobal isNameSpace ifTrue:[ |
|
6466 |
"/ for now: only Smalltalk is allowed |
|
6467 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
|
6468 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
|
6469 |
] ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6470 |
globlName := varName |
1227 | 6471 |
]. |
6472 |
] ifFalse:[ |
|
6473 |
nameSpaceGlobal isBehavior ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6474 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos1 to:tokenPosition-1. |
1227 | 6475 |
] ifTrue:[ |
1391 | 6476 |
nameSpaceGlobal isLoaded ifTrue:[ |
6477 |
(nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[ |
|
1570 | 6478 |
(Smalltalk at:rawName asSymbol) notNil ifTrue:[ |
6479 |
self warning:('Possible name clash (global: ' , rawName , ' vs. private: ' , (nameSpace , '::', varName) , ') - assume globl.') |
|
2072
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6480 |
position:pos1 to:source position "tokenPosition-1". |
1570 | 6481 |
globlName := rawName asSymbol. |
6482 |
] ifFalse:[ |
|
2072
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6483 |
self warning:('no private class: ' , varName allBold , ' in class: ' , nameSpace) |
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6484 |
position:pos1 to:source position "tokenPosition-1". |
1391 | 6485 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
1570 | 6486 |
] |
2072
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6487 |
] ifFalse:[ |
2086
eebe71ac03d9
dont complain access to my own private classes
Claus Gittinger <cg@exept.de>
parents:
2085
diff
changeset
|
6488 |
"/ reference to a private class |
eebe71ac03d9
dont complain access to my own private classes
Claus Gittinger <cg@exept.de>
parents:
2085
diff
changeset
|
6489 |
nameSpaceGlobal ~~ classToCompileFor ifTrue:[ |
2090
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6490 |
self classToCompileFor notNil ifTrue:[ |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6491 |
self isDoIt ifFalse:[ |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6492 |
parserFlags warnAboutReferenceToPrivateClass ifTrue:[ |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6493 |
self warning:('Referring to private class ''' , varName allBold , ''' here.') |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6494 |
doNotShowAgainAction:[ ParserFlags warnAboutReferenceToPrivateClass:false ] |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6495 |
position:pos1 to:source position " tokenPosition-1". |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6496 |
]. |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6497 |
Tools::ToDoListBrowser notNil ifTrue:[ |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6498 |
self |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6499 |
notifyTodo:('Referring to private class ''' , varName allBold , ''' here.') position:pos1 |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6500 |
className:(self classToCompileFor name) selector:selector |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6501 |
severity:#warning priority:#medium |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6502 |
equalityParameter:nil |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6503 |
checkAction:nil. |
6db4ec183b04
avoid error in error handling (no classToCompileFor)
Claus Gittinger <cg@exept.de>
parents:
2086
diff
changeset
|
6504 |
]. |
2086
eebe71ac03d9
dont complain access to my own private classes
Claus Gittinger <cg@exept.de>
parents:
2085
diff
changeset
|
6505 |
]. |
2074 | 6506 |
]. |
2072
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6507 |
] |
17d549904c26
warn about access to another classes private class
Claus Gittinger <cg@exept.de>
parents:
2071
diff
changeset
|
6508 |
]. |
1227 | 6509 |
] |
6510 |
] |
|
6511 |
]. |
|
6512 |
]. |
|
6513 |
self nextToken. |
|
6514 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6515 |
var := VariableNode globalNamed:globlName. |
1227 | 6516 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
6517 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6518 |
self markVariable:var from:pos1 to:pos1 + rawName size - 1. |
1227 | 6519 |
]. |
6520 |
||
6521 |
var == #Error ifTrue:[ |
|
6522 |
^ #Error |
|
6523 |
]. |
|
6524 |
||
6525 |
errorFlag ~~ true ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6526 |
self markVariable:var from:pos1 to:pos1 + varName size - 1. |
1227 | 6527 |
]. |
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
6528 |
(ignoreErrors or:[parseForCode not and:[ignoreWarnings]]) ifTrue:[ |
1227 | 6529 |
errorFlag := false. |
6530 |
]. |
|
6531 |
||
6532 |
((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[ |
|
6533 |
parseForCode ifFalse:[ |
|
6534 |
var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name]. |
|
6535 |
var isClassVariable ifTrue:[ self rememberClassVarRead:var name]. |
|
6536 |
]. |
|
6537 |
^ var |
|
6538 |
]. |
|
6539 |
||
1551 | 6540 |
"/ assignment... |
6541 |
||
1227 | 6542 |
"/ careful: it could already be an implicit self send |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6543 |
parserFlags implicitSelfSends ifTrue:[ |
1227 | 6544 |
var isMessage ifTrue:[ |
6545 |
self nextToken. |
|
6546 |
expr := self expression. |
|
6547 |
self isSyntaxHighlighter ifFalse:[ |
|
6548 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6549 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6550 |
^ MessageNode receiver:(self selfNode) selector:('__' , varName , ':') asSymbol arg:expr. |
1227 | 6551 |
]. |
6552 |
]. |
|
6553 |
||
1551 | 6554 |
assignmentAllowed := true. |
6555 |
||
1227 | 6556 |
(var ~~ #Error) ifTrue:[ |
6557 |
t := var type. |
|
6558 |
t == #MethodVariable ifTrue:[ |
|
6559 |
modifiedLocalVars isNil ifTrue:[ |
|
6560 |
modifiedLocalVars := Set new. |
|
6561 |
]. |
|
6562 |
modifiedLocalVars add:var name. |
|
1551 | 6563 |
] ifFalse:[ (t == #InstanceVariable) ifTrue:[ |
6564 |
varName := self classesInstVarNames at:(var index). |
|
6565 |
||
6566 |
"/ ca once did this to "name" and wondered what happened to his class ... |
|
6567 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
|
6568 |
"/ and is hard to track down later) |
|
6569 |
||
1664 | 6570 |
ignoreWarnings ifFalse:[ |
1756 | 6571 |
parserFlags warnings ifTrue:[ |
6572 |
parserFlags warnCommonMistakes ifTrue:[ |
|
6573 |
classToCompileFor isMeta ifTrue:[ |
|
6574 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
|
6575 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
|
6576 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of "Class")' withCRs position:pos1 to:pos2. |
|
6577 |
] |
|
1664 | 6578 |
] |
1551 | 6579 |
] |
1756 | 6580 |
]. |
1664 | 6581 |
]. |
1551 | 6582 |
]. |
1664 | 6583 |
|
1551 | 6584 |
parseForCode ifFalse:[ |
2053 | 6585 |
self rememberInstVarModified:varName |
1551 | 6586 |
] |
6587 |
] ifFalse:[ (t == #ClassVariable) ifTrue:[ |
|
6588 |
varName := var name. |
|
6589 |
varName := varName copyFrom:((varName indexOf:$:) + 1). |
|
6590 |
parseForCode ifFalse:[ |
|
2053 | 6591 |
self rememberClassVarModified:varName |
1551 | 6592 |
] |
6593 |
] ifFalse:[ (t == #GlobalVariable) ifTrue:[ |
|
6594 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
|
6595 |
cls name = var name ifTrue:[ |
|
6596 |
self warning:'assignment to global which refers to a class' position:pos1 to:pos2. |
|
6597 |
] |
|
6598 |
]. |
|
6599 |
parseForCode ifFalse:[ |
|
2053 | 6600 |
self rememberGlobalModified:var name |
1551 | 6601 |
] |
6602 |
] ifFalse:[ |
|
6603 |
(t == #PrivateClass) ifTrue:[ |
|
6604 |
assignmentAllowed := false. |
|
6605 |
self parseError:'assignment to private class' position:pos1 to:pos2. |
|
6606 |
] ifFalse:[ (t == #MethodArg) ifTrue:[ |
|
6607 |
assignmentAllowed := false. |
|
6608 |
self parseError:'assignment to method argument' position:pos1 to:pos2. |
|
6609 |
] ifFalse:[ (t == #BlockArg) ifTrue:[ |
|
6610 |
assignmentAllowed := false. |
|
6611 |
self parseError:'assignment to block argument' position:pos1 to:pos2. |
|
6612 |
] ifFalse:[ (t == #PoolVariable) ifTrue:[ |
|
6613 |
self isDoIt ifTrue:[ |
|
6614 |
self warning:'assignment to pool variable' position:pos1 to:pos2. |
|
6615 |
assignmentAllowed := true. |
|
6616 |
] ifFalse:[ |
|
6617 |
self parseError:'assignment to pool variable' position:pos1 to:pos2. |
|
6618 |
] |
|
6619 |
]]]]]]] |
|
1227 | 6620 |
]. |
6621 |
]. |
|
6622 |
||
6623 |
lnr := tokenLineNr. |
|
6624 |
||
6625 |
self nextToken. |
|
6626 |
pos2 := tokenPosition. |
|
6627 |
expr := self expression. |
|
6628 |
||
6629 |
"/ a typical beginner error: |
|
6630 |
"/ expr ifTrue:[ |
|
6631 |
"/ var := super |
|
6632 |
"/ ] ifFalse:[ |
|
6633 |
"/ var := something-else |
|
6634 |
"/ ]. |
|
6635 |
"/ var messageSend |
|
6636 |
"/ |
|
6637 |
"/ does not what a beginner might think. |
|
6638 |
||
6639 |
self isSyntaxHighlighter ifTrue:[ |
|
6640 |
(expr == #Error) ifTrue:[^ #Error]. |
|
6641 |
] ifFalse:[ |
|
1756 | 6642 |
parserFlags warnings ifTrue:[ |
6643 |
parserFlags warnCommonMistakes ifTrue:[ |
|
6644 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
|
6645 |
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. |
|
6646 |
]. |
|
1227 | 6647 |
]. |
6648 |
]. |
|
6649 |
||
6650 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6651 |
expr isVariable ifTrue:[ |
|
6652 |
expr name = var name ifTrue:[ |
|
1551 | 6653 |
self warning:('useless assignment to "' , var name, '"' ) position:pos1 to:pos2-1. |
1227 | 6654 |
]. |
6655 |
]. |
|
6656 |
]. |
|
1551 | 6657 |
assignmentAllowed ifTrue:[ |
6658 |
node := AssignmentNode variable:var expression:expr. |
|
6659 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
6660 |
] ifFalse:[ |
|
6661 |
self parseError:('assignment to "' , var name, '" suppressed' ) position:pos1 to:pos2-1. |
|
6662 |
node := expr. |
|
6663 |
]. |
|
1227 | 6664 |
^ node |
1901
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
6665 |
|
a539817c2dde
undefined variables error is not turned off by disabling warnings.
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
6666 |
"Modified: / 05-09-2006 / 12:36:01 / cg" |
1227 | 6667 |
! |
6668 |
||
1295 | 6669 |
primary_lazyValue |
6670 |
|pos block expr| |
|
6671 |
||
6672 |
pos := tokenPosition. |
|
6673 |
||
6674 |
(tokenType == $: ) ifTrue:[ |
|
6675 |
self parseError:'lazyValues have no arguments' position:tokenPosition. |
|
6676 |
^ #Error |
|
6677 |
]. |
|
6678 |
||
6679 |
block := self blockBody:#(). |
|
6680 |
self nextToken. |
|
6681 |
||
6682 |
expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6683 |
receiver:(VariableNode globalNamed:#LazyValue) |
1295 | 6684 |
selector:#'block:' |
6685 |
arg:block. |
|
6686 |
^ expr |
|
6687 |
! |
|
6688 |
||
1227 | 6689 |
primary_nil |
6690 |
"parse a nil primary; return a node-tree, nil or #Error." |
|
6691 |
||
6692 |
|pos| |
|
6693 |
||
6694 |
pos := tokenPosition. |
|
6695 |
||
6696 |
self nextToken. |
|
6697 |
(self noAssignmentAllowed:'assignment to ''nil''' at:pos) ifFalse:[ |
|
6698 |
^ #Error |
|
6699 |
]. |
|
6700 |
"/ self markConstantFrom:pos to:pos+2. |
|
6701 |
nilNode isNil ifTrue:[ |
|
6702 |
nilNode := ConstantNode type:#Nil value:nil |
|
6703 |
]. |
|
6704 |
^ nilNode |
|
6705 |
! |
|
6706 |
||
6707 |
primary_self |
|
6708 |
"parse a self primary; return a node-tree, nil or #Error." |
|
6709 |
||
6710 |
|pos| |
|
6711 |
||
6712 |
pos := tokenPosition. |
|
6713 |
||
6714 |
self nextToken. |
|
6715 |
(self noAssignmentAllowed:'assignment to pseudo variable ''self''' at:pos) ifFalse:[ |
|
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6716 |
^ ParseError raiseErrorString:'Assignment to self'. |
1227 | 6717 |
]. |
6718 |
self markSelfFrom:pos to:pos+3. |
|
1262 | 6719 |
^ self selfNode |
1855
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6720 |
|
61936f01108e
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
6721 |
"Modified: / 22-08-2006 / 13:42:44 / cg" |
1227 | 6722 |
! |
6723 |
||
6724 |
primary_simpleLiteral |
|
6725 |
"parse a simple literal primary; return a node-tree, or raise an Error." |
|
6726 |
||
6727 |
|pos val| |
|
6728 |
||
6729 |
pos := tokenPosition. |
|
6730 |
||
6731 |
"/ |
|
6732 |
"/ ImmutableStrings are experimental |
|
6733 |
"/ |
|
6734 |
((tokenType == #String) |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6735 |
and:[(parserFlags stringsAreImmutable)]) ifTrue:[ |
1615 | 6736 |
token := tokenValue := self makeImmutableString:tokenValue. |
1227 | 6737 |
]. |
1657 | 6738 |
|
6739 |
((tokenType == #Symbol) or:[tokenType == #ESSymbol]) ifTrue:[ |
|
1227 | 6740 |
parseForCode ifFalse:[ |
6741 |
self rememberSymbolUsed:tokenValue |
|
6742 |
]. |
|
6743 |
]. |
|
6744 |
val := ConstantNode type:tokenType value:tokenValue. |
|
6745 |
||
1683 | 6746 |
((tokenType == #Symbol) or:[tokenType == #ESSymbol]) ifTrue:[ |
1227 | 6747 |
self markSymbolFrom:tokenPosition to:tokenPosition+tokenValue size-1. |
1683 | 6748 |
] ifFalse:[ |
6749 |
tokenType == #String ifTrue:[ |
|
6750 |
self markStringFrom:pos to:source position1Based-1. |
|
6751 |
] ifFalse:[ |
|
6752 |
self markConstantFrom:pos to:source position1Based-1. |
|
6753 |
]. |
|
1227 | 6754 |
]. |
6755 |
||
6756 |
self nextToken. |
|
6757 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
|
6758 |
^ #Error |
|
6759 |
]. |
|
6760 |
^ val |
|
6761 |
! |
|
6762 |
||
6763 |
primary_squeakComputedArray |
|
1274 | 6764 |
"parse a squeak computed array literal; return a node-tree, or raise an Error. |
6765 |
In squeak, these are written as: { expr1 . expr2 . ... exprN ) |
|
1762 | 6766 |
and create a message to construct an Array containing the exprI values. |
1274 | 6767 |
WARNING: this is only supported to allow filing in squeak code. |
6768 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
6769 |
if you ever plan to stc-compile it into a shared library" |
|
6770 |
||
1227 | 6771 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6772 |
|pos exprList| |
1227 | 6773 |
|
6774 |
pos := tokenPosition. |
|
6775 |
||
6776 |
self nextToken. |
|
6777 |
exprList := self squeakComputedArray. |
|
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6778 |
(exprList == #Error) ifTrue:[ ^ #Error ]. |
1227 | 6779 |
|
6780 |
tokenType ~~ $} ifTrue:[ |
|
2005 | 6781 |
self parseError:'"." or "}" expected' position:tokenPosition. |
1227 | 6782 |
^ #Error |
6783 |
]. |
|
6784 |
self nextToken. |
|
6785 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
6786 |
^ #Error |
|
6787 |
]. |
|
6788 |
||
6789 |
"/ make it an array creation expression ... |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6790 |
^ self genMakeArrayWith:exprList |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6791 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6792 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6793 |
Compiler allowSqueakExtensions:true. |
1299 | 6794 |
" |
6795 |
||
6796 |
" |
|
6797 |
{ 1@2. 10 factorial. Date today }. |
|
6798 |
" |
|
6799 |
||
1762 | 6800 |
" |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6801 |
Compiler allowSqueakExtensions:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6802 |
" |
1227 | 6803 |
! |
6804 |
||
6805 |
primary_super |
|
6806 |
"parse a super primary; return a node-tree, nil or #Error." |
|
6807 |
||
6808 |
|pos| |
|
6809 |
||
6810 |
pos := tokenPosition. |
|
6811 |
||
6812 |
usesSuper := true. |
|
6813 |
self nextToken. |
|
6814 |
(self noAssignmentAllowed:'assignment to pseudo variable ''super''' at:pos) ifFalse:[ |
|
6815 |
^ #Error |
|
6816 |
]. |
|
6817 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
|
6818 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
|
6819 |
]. |
|
6820 |
superNode isNil ifTrue:[ |
|
6821 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
|
6822 |
]. |
|
6823 |
self markSelfFrom:pos to:pos+4. |
|
6824 |
^ superNode |
|
6825 |
! |
|
6826 |
||
1262 | 6827 |
primary_thisContext |
6828 |
"parse a thisContext primary; return a node-tree, or raise an Error." |
|
6829 |
||
6830 |
|pos| |
|
6831 |
||
6832 |
pos := tokenPosition. |
|
6833 |
||
6834 |
self nextToken. |
|
6835 |
(self noAssignmentAllowed:'assignment to pseudo variable ''thisContext''' at:pos) ifFalse:[ |
|
6836 |
^ #Error |
|
6837 |
]. |
|
6838 |
self markIdentifierFrom:pos to:pos+10. |
|
6839 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn. "/ often nil |
|
6840 |
! |
|
6841 |
||
1227 | 6842 |
primary_true |
6843 |
"parse a true primary; return a node-tree, or raise an Error." |
|
6844 |
||
6845 |
|pos| |
|
6846 |
||
6847 |
pos := tokenPosition. |
|
6848 |
||
6849 |
self nextToken. |
|
6850 |
(self noAssignmentAllowed:'assignment to ''true''' at:pos) ifFalse:[ |
|
6851 |
^ #Error |
|
6852 |
]. |
|
6853 |
self markBooleanConstantFrom:pos to:pos+3. |
|
6854 |
^ ConstantNode type:#True value:true |
|
6855 |
! |
|
6856 |
||
924 | 6857 |
qualifiedName |
6858 |
"a vw3.x (and later) feature: QualifiedName is #{ id ... id } |
|
6859 |
and mapped to a global variable here. |
|
6860 |
The initial #{ is supposed to be not yet skipped." |
|
6861 |
||
1436 | 6862 |
|elements elem pos1 nm| |
924 | 6863 |
|
6864 |
pos1 := tokenPosition. |
|
6865 |
self nextToken. |
|
6866 |
elements := OrderedCollection new. |
|
1436 | 6867 |
[ tokenType ~~ $} ] whileTrue:[ |
6868 |
(tokenType == #Identifier) ifFalse:[ |
|
6869 |
self syntaxError:'bad qualifiedName; Identifier expected' |
|
924 | 6870 |
position:pos1 to:tokenPosition |
6871 |
]. |
|
1436 | 6872 |
elem := tokenName. |
924 | 6873 |
elements add:elem. |
1028 | 6874 |
|
6875 |
self nextToken. |
|
1436 | 6876 |
tokenType = $} ifTrue:[ |
1028 | 6877 |
] ifFalse:[ |
1436 | 6878 |
tokenType == #'::' ifTrue:[ |
6879 |
"/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6880 |
"/(which is a kludge) |
|
6881 |
self nextToken. |
|
6882 |
] ifFalse:[ |
|
1028 | 6883 |
self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
6884 |
position:pos1 to:tokenPosition. |
|
6885 |
]. |
|
6886 |
]. |
|
1436 | 6887 |
|
6888 |
"/ elem := self variable. |
|
6889 |
"/ (elem == #Error) ifTrue:[ |
|
6890 |
"/ (tokenType == #EOF) ifTrue:[ |
|
6891 |
"/ self syntaxError:'unterminated qualifiedName; ''}'' expected' |
|
6892 |
"/ position:pos1 to:tokenPosition |
|
6893 |
"/ ]. |
|
6894 |
"/ ^ #Error |
|
6895 |
"/ ]. |
|
6896 |
"/ errorFlag := false. |
|
6897 |
"/ (elem isVariable and:[elem isGlobal]) ifFalse:[ |
|
6898 |
"/ self warning:'elements of a qualifiedName should be globalIdentifiers' |
|
6899 |
"/ position:pos1 to:tokenPosition |
|
6900 |
"/ ]. |
|
6901 |
"/ elements add:elem. |
|
6902 |
"/ |
|
6903 |
"/ self nextToken. |
|
6904 |
"/ tokenType == #'::' ifTrue:[ |
|
6905 |
"/ "/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6906 |
"/ "/(which is a kludge) |
|
6907 |
"/ self nextToken. |
|
6908 |
"/ ] ifFalse:[ |
|
6909 |
"/ tokenType ~~ $} ifTrue:[ |
|
6910 |
"/ self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
|
6911 |
"/ position:pos1 to:tokenPosition. |
|
6912 |
"/ ^ #Error |
|
6913 |
"/ ]. |
|
6914 |
"/ ]. |
|
6915 |
]. |
|
1716
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6916 |
|
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6917 |
parserFlags flattenVisualWorksNamespaces ifTrue:[ |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6918 |
"/ temporary kludge when loading VW UIBuilder code... |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6919 |
( #('UI' 'Core' 'Graphics') includes:elements first) ifTrue:[ |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6920 |
elements := elements copyFrom:2. |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6921 |
]. |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6922 |
]. |
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
6923 |
|
1437 | 6924 |
nm := (elements asStringWith:'::') asSymbol. |
1436 | 6925 |
^ ConstantNode type:#Symbol value:nm |
6926 |
||
6927 |
"/ elements size > 1 ifTrue:[ |
|
6928 |
"/ self syntaxError:'Sorry: qualified names are not yet implemented.'. |
|
6929 |
"/ ]. |
|
6930 |
"/ ^ elements first. |
|
924 | 6931 |
|
6932 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
6933 |
! |
|
6934 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6935 |
squeakComputedArray |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6936 |
|expressions elem pos1| |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6937 |
|
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6938 |
tokenType == $} ifTrue:[ |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6939 |
^ #() |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6940 |
]. |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6941 |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6942 |
pos1 := tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6943 |
expressions := OrderedCollection new:20. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6944 |
[true] whileTrue:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6945 |
elem := self expression. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6946 |
(elem == #Error) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6947 |
(tokenType == #EOF) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6948 |
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
|
6949 |
position:pos1 to:tokenPosition |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6950 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6951 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6952 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6953 |
expressions add:elem. |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6954 |
tokenType == $. ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6955 |
^ expressions |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6956 |
]. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6957 |
self nextToken. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6958 |
tokenType == $} ifTrue:[ |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6959 |
^ expressions |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6960 |
]. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6961 |
]. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6962 |
"/ not reached |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6963 |
! |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6964 |
|
141 | 6965 |
unaryExpression |
6966 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6967 |
||
1328 | 6968 |
|receiver| |
141 | 6969 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
6970 |
receiver := self arrayIndexingExpression. |
141 | 6971 |
(receiver == #Error) ifTrue:[^ #Error]. |
1328 | 6972 |
^ self unaryExpressionFor:receiver |
6973 |
! |
|
6974 |
||
6975 |
unaryExpressionFor:receiverArg |
|
6976 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6977 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6978 |
|receiver expr sel pos pos2 note lNr arguments| |
1328 | 6979 |
|
6980 |
receiver := receiverArg. |
|
6981 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1776
65df22979f49
plausibilityCheck of unary expression fixed
Claus Gittinger <cg@exept.de>
parents:
1774
diff
changeset
|
6982 |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
6983 |
[ self isValidUnarySelector:tokenType ] whileTrue:[ |
663 | 6984 |
pos := tokenPosition. |
6985 |
pos2 := pos + tokenName size - 1. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6986 |
lNr := tokenLineNr. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
6987 |
sel := tokenName. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6988 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6989 |
self markSelector:sel from:pos to:pos2 receiverNode:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6990 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6991 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6992 |
tokenType == $( ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6993 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6994 |
"/ croquet/squeak extension - c/java-style arguments |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6995 |
arguments := self functionCallArgList. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6996 |
"/ synthetic selector: foo[:[with:[with:[...]]]] |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6997 |
arguments notEmpty ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6998 |
sel := sel , ':'. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6999 |
arguments size - 1 timesRepeat:[ sel := sel , 'with:' ]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7000 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7001 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7002 |
expr := MessageNode receiver:receiver selector:sel args:arguments fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7003 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7004 |
self parseError:(expr errorString) position:pos to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7005 |
errorFlag := false. "ok, user wants it - so he'll get it" |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7006 |
expr := MessageNode receiver:receiver selector:sel args:arguments fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7007 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7008 |
expr lineNumber:lNr. |
1687 | 7009 |
(ignoreErrors or:[ignoreWarnings]) ifFalse:[ |
7010 |
note := self plausibilityCheck:receiver. |
|
7011 |
note notNil ifTrue:[ |
|
7012 |
self warning:note position:pos to:pos2 |
|
7013 |
]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7014 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7015 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7016 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7017 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7018 |
^ expr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7019 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7020 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7021 |
|
1022 | 7022 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7023 |
expr := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7024 |
expr isErrorNode ifTrue:[ |
1675
7812281ecfbd
some errors are really warnings.
Claus Gittinger <cg@exept.de>
parents:
1664
diff
changeset
|
7025 |
self warning:(expr errorString , '.\\If you proceed, that error will happen at runtime.') withCRs position:pos to:pos2. |
663 | 7026 |
errorFlag := false. "ok, user wants it - so he'll get it" |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7027 |
expr := UnaryNode receiver:receiver selector:sel fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7028 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7029 |
expr lineNumber:lNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7030 |
|
1687 | 7031 |
(ignoreErrors or:[ignoreWarnings]) ifFalse:[ |
1776
65df22979f49
plausibilityCheck of unary expression fixed
Claus Gittinger <cg@exept.de>
parents:
1774
diff
changeset
|
7032 |
note := self plausibilityCheck:expr. |
1687 | 7033 |
note notNil ifTrue:[ |
7034 |
self warning:note position:pos to:pos2 |
|
7035 |
]. |
|
1193 | 7036 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7037 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7038 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7039 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7040 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
7041 |
receiver := expr. "/ for next message |
141 | 7042 |
]. |
7043 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
7044 |
|
1776
65df22979f49
plausibilityCheck of unary expression fixed
Claus Gittinger <cg@exept.de>
parents:
1774
diff
changeset
|
7045 |
"Modified: / 16-07-2006 / 16:15:22 / cg" |
141 | 7046 |
! |
7047 |
||
7048 |
variable |
|
1028 | 7049 |
"parse a simple (i.e. non-namespace-access path) variable; |
7050 |
return a node-tree, nil or #Error. |
|
7051 |
Does not advance to next token. |
|
7052 |
If undefined, notify error and correct if user wants to" |
|
141 | 7053 |
|
864 | 7054 |
|v pos1 pos2| |
687 | 7055 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
7056 |
v := self variableOrError:tokenName. |
664 | 7057 |
(v ~~ #Error) ifTrue:[ |
663 | 7058 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 7059 |
self markVariable:v. |
663 | 7060 |
]. |
7061 |
^ v |
|
7062 |
]. |
|
865 | 7063 |
|
687 | 7064 |
pos1 := tokenPosition. |
864 | 7065 |
pos2 := pos1+tokenName size-1. |
7066 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 7067 |
|
2108 | 7068 |
parseForCode ifTrue:[ |
7069 |
allowUndeclaredVariables ifFalse:[ |
|
7070 |
self parseError:'Parser [error]: undeclared variable: ',tokenName. |
|
7071 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
7072 |
v := self correctVariable:tokenName atPosition:pos1 to:pos2. |
1089 | 7073 |
(v ~~ #Error) ifTrue:[^ v]. |
2108 | 7074 |
|
1952
9e74d1e8f34c
error for undefined variables are'nt if not parsing for code
Claus Gittinger <cg@exept.de>
parents:
1951
diff
changeset
|
7075 |
self errorFlag:true. |
9e74d1e8f34c
error for undefined variables are'nt if not parsing for code
Claus Gittinger <cg@exept.de>
parents:
1951
diff
changeset
|
7076 |
|
663 | 7077 |
tokenName first isLowercase ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7078 |
parserFlags implicitSelfSends ifTrue:[ |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
7079 |
^ UnaryNode receiver:(self selfNode) selector:('__' , tokenName) asSymbol. |
663 | 7080 |
]. |
7081 |
^ #Error |
|
7082 |
] |
|
2108 | 7083 |
] ifFalse:[ |
7084 |
self rememberGlobalUsed:(Smalltalk undeclaredPrefix) , tokenName. |
|
7085 |
self rememberGlobalUsed:tokenName. |
|
141 | 7086 |
]. |
865 | 7087 |
|
869 | 7088 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7089 |
^ VariableNode globalNamed:tokenName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
7090 |
|
1952
9e74d1e8f34c
error for undefined variables are'nt if not parsing for code
Claus Gittinger <cg@exept.de>
parents:
1951
diff
changeset
|
7091 |
"Modified: / 21-11-2006 / 16:25:03 / cg" |
141 | 7092 |
! |
7093 |
||
0 | 7094 |
variableOrError |
1028 | 7095 |
"parse a simple (i.e. non-namespace-access path) variable; |
7096 |
return a node-tree, nil or #Error. |
|
7097 |
Does not advance to next token." |
|
0 | 7098 |
|
21 | 7099 |
^ self variableOrError:tokenName |
7100 |
! |
|
7101 |
||
7102 |
variableOrError:varName |
|
1028 | 7103 |
"parse a simple (i.e. non-namespace-access path) variable; |
7104 |
return a node-tree, nil or #Error. |
|
7105 |
Does not advance to next token." |
|
21 | 7106 |
|
2062 | 7107 |
|varIndex aClass searchBlock args vars |
7108 |
tokenSymbol space classVarIndex holder node |
|
7109 |
checkSharedPoolAction| |
|
7110 |
||
7111 |
checkSharedPoolAction := |
|
7112 |
[:eachPoolName | |
|
7113 |
|sharedPool| |
|
7114 |
||
7115 |
sharedPool := Smalltalk classNamed:eachPoolName. |
|
7116 |
sharedPool isNil ifTrue:[ |
|
7117 |
Transcript showCR:'No such pool: ' , eachPoolName. |
|
7118 |
"/ self warning:('No such pool: ' , eachPoolName). |
|
7119 |
] ifFalse:[ |
|
7120 |
(sharedPool includesKey:varName) ifTrue:[ |
|
7121 |
parseForCode ifFalse:[self rememberGlobalUsed:(sharedPool name , ':' , varName)]. |
|
7122 |
^ VariableNode type:#PoolVariable class:sharedPool name:varName |
|
7123 |
]. |
|
7124 |
]. |
|
7125 |
]. |
|
0 | 7126 |
|
7127 |
"is it a block-arg or block-var ?" |
|
7128 |
searchBlock := currentBlock. |
|
7129 |
[searchBlock notNil] whileTrue:[ |
|
628 | 7130 |
vars := searchBlock variables. |
7131 |
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
|
7132 |
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
|
7133 |
varIndex ~~ 0 ifTrue:[ |
628 | 7134 |
^ VariableNode type:#BlockVariable |
7135 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7136 |
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
|
7137 |
index:varIndex |
628 | 7138 |
block:searchBlock |
7139 |
from:currentBlock |
|
7140 |
]. |
|
7141 |
]. |
|
7142 |
||
7143 |
args := searchBlock arguments. |
|
7144 |
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
|
7145 |
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
|
7146 |
varIndex ~~ 0 ifTrue:[ |
628 | 7147 |
^ VariableNode type:#BlockArg |
7148 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7149 |
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
|
7150 |
index:varIndex |
628 | 7151 |
block:searchBlock |
7152 |
from:currentBlock |
|
7153 |
]. |
|
7154 |
||
7155 |
]. |
|
7156 |
||
7157 |
searchBlock := searchBlock home |
|
0 | 7158 |
]. |
7159 |
||
7160 |
"is it a method-variable ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7161 |
(node := self nodeForMethodVariable:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7162 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7163 |
^ node |
0 | 7164 |
]. |
7165 |
||
7166 |
"is it a method-argument ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7167 |
(node := self nodeForMethodArg:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7168 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7169 |
^ node |
0 | 7170 |
]. |
7171 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7172 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7173 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7174 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7175 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7176 |
"/ 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
|
7177 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7178 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7179 |
[con notNil] whileTrue:[ |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
7180 |
varNames := con argAndVarNames. |
690 | 7181 |
varNames size > 0 ifTrue:[ |
7182 |
varIndex := varNames lastIndexOf:varName. |
|
7183 |
varIndex ~~ 0 ifTrue:[ |
|
7184 |
^ VariableNode type:#ContextVariable |
|
7185 |
name:varName |
|
7186 |
context:con |
|
7187 |
index:varIndex |
|
7188 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7189 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7190 |
con := con home. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7191 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7192 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7193 |
|
0 | 7194 |
classToCompileFor notNil ifTrue:[ |
628 | 7195 |
"is it an instance-variable ?" |
7196 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7197 |
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
|
7198 |
varIndex ~~ 0 ifTrue:[ |
628 | 7199 |
classToCompileFor isMeta ifTrue:[ |
7200 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
7201 |
classVarIndex ~~ 0 ifTrue:[ |
|
7202 |
"/ give a warning - that maybe a common error |
|
825 | 7203 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
7204 |
alreadyWarnedClassInstVarRefs := Set new |
|
7205 |
]. |
|
7206 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
7207 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
7208 |
alreadyWarnedClassInstVarRefs add:varName. |
|
7209 |
]. |
|
628 | 7210 |
]. |
7211 |
]. |
|
7212 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
7213 |
^ VariableNode type:#InstanceVariable |
|
7214 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7215 |
index:varIndex |
628 | 7216 |
selfValue:selfValue |
7217 |
]. |
|
7218 |
||
7219 |
"/ see if there is a corresponding classVar (for the warning) |
|
7220 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
7221 |
||
7222 |
"/ "is it a class-instance-variable ?" |
|
7223 |
"/ |
|
7224 |
"/ Notice: |
|
7225 |
"/ it is no longer allowed to fetch class-instance variables |
|
7226 |
"/ from instance methods ... |
|
7227 |
"/ (used to be in previous ST/X versions) |
|
7228 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7229 |
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
|
7230 |
varIndex ~~ 0 ifTrue:[ |
628 | 7231 |
aClass := self inWhichClassIsClassInstVar:varName. |
7232 |
aClass notNil ifTrue:[ |
|
7233 |
classToCompileFor isMeta ifFalse:[ |
|
7234 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7235 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7236 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7237 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7238 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7239 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7240 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7241 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7242 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7243 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
7244 |
]. |
628 | 7245 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
7246 |
^ #Error. |
|
7247 |
] ifFalse:[ |
|
7248 |
"/ give a warning - that maybe a common error |
|
738 | 7249 |
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 | 7250 |
] |
7251 |
]. |
|
7252 |
||
7253 |
"/ OLD CODE: |
|
7254 |
"/ 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
|
7255 |
"/ |
628 | 7256 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
7257 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
7258 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7259 |
"/ index:varIndex |
628 | 7260 |
"/ selfClass:aClass |
7261 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7262 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7263 |
"/ self halt:'oops - should not happen'. |
628 | 7264 |
] |
7265 |
]. |
|
7266 |
||
7267 |
"is it a class-variable ?" |
|
7268 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7269 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
7270 |
varIndex ~~ 0 ifTrue:[ |
628 | 7271 |
aClass := self inWhichClassIsClassVar:varName. |
7272 |
aClass notNil ifTrue:[ |
|
7273 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
7274 |
^ 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
|
7275 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7276 |
"/ self halt:'oops - should not happen'. |
628 | 7277 |
]. |
7278 |
||
7279 |
"is it a private-class ?" |
|
7280 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7281 |
aClass := self classToLookForClassVars. |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
7282 |
aClass := aClass theNonMetaclass. |
1907 | 7283 |
aClass isLoaded ifTrue:[ |
7284 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
|
7285 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
7286 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
7287 |
]. |
|
628 | 7288 |
]. |
1551 | 7289 |
|
7290 |
" is it a pool-variable ?" |
|
2062 | 7291 |
classToCompileFor theNonMetaclass realSharedPools do:checkSharedPoolAction. |
7292 |
]. |
|
7293 |
||
7294 |
(self isDoIt) ifTrue:[ |
|
7295 |
moreSharedPools notNil ifTrue:[ |
|
7296 |
moreSharedPools do:checkSharedPoolAction. |
|
1551 | 7297 |
]. |
418 | 7298 |
]. |
7299 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7300 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7301 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7302 |
space notNil ifTrue:[ |
628 | 7303 |
space ~~ Smalltalk ifTrue:[ |
7304 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7305 |
space isNameSpace ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7306 |
^ VariableNode globalNamed:(space name , '::' , varName) |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
7307 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
7308 |
^ VariableNode type:#PrivateClass class:space name:varName |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
7309 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
7310 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7311 |
^ VariableNode globalNamed:varName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
7312 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
7313 |
|
0 | 7314 |
"is it a global-variable ?" |
63 | 7315 |
tokenSymbol := varName asSymbolIfInterned. |
7316 |
tokenSymbol notNil ifTrue:[ |
|
628 | 7317 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
7318 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7319 |
^ VariableNode globalNamed:tokenSymbol |
628 | 7320 |
] |
0 | 7321 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7322 |
|
877 | 7323 |
"is it a workspace variable ?" |
7324 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
7325 |
"/ when parsing doits, this is done twice; |
|
7326 |
"/ first, for the parse, then as a block-code |
|
7327 |
"/ for the code. |
|
7328 |
"/ We only care for WorkspaceVars in doIts |
|
1440 | 7329 |
(self isDoIt) ifTrue:[ |
1295 | 7330 |
(Workspace notNil |
7331 |
and:[(holder := Workspace workspaceVariableAt:varName) notNil]) |
|
7332 |
ifTrue:[ |
|
7333 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
877 | 7334 |
] |
7335 |
] |
|
7336 |
]. |
|
1295 | 7337 |
"is it a doIt variable ?" |
7338 |
||
7339 |
"/ (requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
7340 |
"/ when parsing doits, this is done twice; |
|
7341 |
"/ first, for the parse, then as a block-code |
|
7342 |
"/ for the code. |
|
7343 |
"/ We only care for WorkspaceVars in doIts |
|
7344 |
||
1440 | 7345 |
(self isDoIt) ifTrue:[ |
1295 | 7346 |
(doItTemporaries notNil |
7347 |
and:[(holder := doItTemporaries at:varName asSymbol ifAbsent:nil) notNil]) |
|
7348 |
ifTrue:[ |
|
7349 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
7350 |
] |
|
7351 |
]. |
|
7352 |
"/ ]. |
|
0 | 7353 |
^ #Error |
1907 | 7354 |
|
2038 | 7355 |
"Modified: / 07-06-2007 / 11:42:38 / cg" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7356 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7357 |
|
1410 | 7358 |
!Parser methodsFor:'parsing-primitives & pragmas'! |
7359 |
||
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7360 |
checkForClosingAngle |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7361 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7362 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7363 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7364 |
self parseError:'bad primitive definition (''>'' expected)'. |
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7365 |
self skipForClosingAngle. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7366 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7367 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7368 |
|
1817 | 7369 |
generateCallToExternalFunction:fn lineNr:lineNr |
7370 |
|args sel node| |
|
7371 |
||
2041 | 7372 |
fn argumentTypes size ~~ (methodArgNames size |
7373 |
"the following stuff was commented (2007-07-30), to make ole: work. |
|
7374 |
Ask felix or stefan" |
|
7375 |
" + (fn isCPPFunction ifTrue:1 ifFalse:0)") ifTrue:[ |
|
1817 | 7376 |
self |
1937 | 7377 |
ignorableParseError:('Number of method args (%1) does not match function arg list (ST/V api call)' |
1817 | 7378 |
bindWith: methodArgNames size). |
7379 |
]. |
|
7380 |
||
7381 |
args := (methodArgNames ? #()) collect:[:eachArgName | self nodeForMethodArg:eachArgName]. |
|
7382 |
fn isVirtualCPP ifTrue:[ |
|
7383 |
sel := #( |
|
7384 |
invokeCPPVirtualOn: |
|
7385 |
invokeCPPVirtualOn:with: |
|
7386 |
invokeCPPVirtualOn:with:with: |
|
7387 |
invokeCPPVirtualOn:with:with:with: |
|
7388 |
) at:args size+1 ifAbsent:nil. |
|
7389 |
sel isNil ifTrue:[ |
|
7390 |
args := Array with:(self selfNode) with:(self genMakeArrayWith:args). |
|
7391 |
sel := #invokeCPPVirtualOn:withArguments:. |
|
7392 |
] ifFalse:[ |
|
7393 |
args := (Array with:(self selfNode)) , args. |
|
7394 |
]. |
|
7395 |
] ifFalse:[ |
|
7396 |
fn isNonVirtualCPP ifTrue:[ |
|
7397 |
args := (Array with:(self selfNode)) , args |
|
7398 |
]. |
|
7399 |
sel := #( |
|
7400 |
invoke |
|
7401 |
invokeWith: |
|
7402 |
invokeWith:with: |
|
7403 |
invokeWith:with:with: |
|
7404 |
) at:args size+1 ifAbsent:nil. |
|
7405 |
sel isNil ifTrue:[ |
|
7406 |
args := Array with:(self genMakeArrayWith:args). |
|
7407 |
sel := #invokeWithArguments:. |
|
7408 |
]. |
|
7409 |
]. |
|
7410 |
||
7411 |
node := MessageNode |
|
7412 |
receiver:(ConstantNode type:nil value:fn) |
|
7413 |
selector:sel |
|
7414 |
args:args |
|
7415 |
fold:false. |
|
7416 |
node lineNumber:lineNr. |
|
7417 |
tree := ReturnNode new expression:node. |
|
7418 |
tree lineNumber:lineNr. |
|
7419 |
||
7420 |
"Created: / 01-08-2006 / 13:47:44 / cg" |
|
1937 | 7421 |
"Modified: / 25-10-2006 / 11:28:21 / cg" |
1817 | 7422 |
! |
7423 |
||
2051 | 7424 |
generateReturnOfValue:aValue |
1741 | 7425 |
|node| |
7426 |
||
2051 | 7427 |
node := ConstantNode type:nil value:aValue. |
1741 | 7428 |
node lineNumber:tokenLineNr. |
7429 |
tree := ReturnNode new expression:node. |
|
1946
7d7c1dc9fa5f
care for lineNumbers in Return statements.
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
7430 |
tree lineNumber:tokenLineNr. |
7d7c1dc9fa5f
care for lineNumbers in Return statements.
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
7431 |
|
7d7c1dc9fa5f
care for lineNumbers in Return statements.
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
7432 |
"Modified: / 16-11-2006 / 14:36:35 / cg" |
1741 | 7433 |
! |
7434 |
||
1764 | 7435 |
generateTrapCodeForUnavailableCParser |
7436 |
|args node| |
|
7437 |
||
7438 |
self ignorableParseError:'CParser Missing'. |
|
7439 |
||
7440 |
args := Array with:(ConstantNode type:nil value:'External function call error - CParser missing.'). |
|
7441 |
node := MessageNode receiver:(self selfNode) selector:#error: args:args fold:false. |
|
7442 |
node lineNumber:lineNr. |
|
7443 |
tree := ReturnNode new expression:node. |
|
7444 |
tree lineNumber:lineNr. |
|
7445 |
^ -1 |
|
7446 |
||
7447 |
"Created: / 21-06-2006 / 09:58:43 / cg" |
|
7448 |
! |
|
7449 |
||
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7450 |
parseExceptionOrContextPragma |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7451 |
|pragmaType| |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7452 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7453 |
"/ notice: '<' has already been parsed. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7454 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7455 |
pragmaType := tokenName. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7456 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7457 |
self nextToken. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7458 |
(tokenType ~~ #Symbol) ifTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7459 |
self parseError:'symbol expected'. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7460 |
^ #Error |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7461 |
]. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7462 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7463 |
((pragmaType = 'exception:' |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7464 |
and:[tokenValue == #'handle' |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7465 |
or:[tokenValue == #'raise' |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7466 |
or:[tokenValue == #'unwind']]]) |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7467 |
or:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7468 |
pragmaType = 'context:' |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7469 |
and:[(tokenValue == #'return')]]) |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7470 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7471 |
ifTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7472 |
primitiveContextInfo isNil ifTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7473 |
primitiveContextInfo := Set new. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7474 |
]. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7475 |
primitiveContextInfo add:(pragmaType->tokenValue). |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7476 |
] ifFalse:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7477 |
self parseError:'unrecognized exception pragma: ' , tokenValue. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7478 |
]. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7479 |
self nextToken. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7480 |
! |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7481 |
|
1551 | 7482 |
parseExternalFunctionCallDeclaration |
1741 | 7483 |
|callType cString cStream returnType |
7484 |
functionName argTypes moduleName fn node args sel |
|
7485 |
type dictionaryOfKnownTypes function functionOrType lineNr| |
|
7486 |
||
7487 |
"callType is one of c: / cdecl: / api: / apicall: ..." |
|
7488 |
callType := tokenName asLowercase. |
|
7489 |
||
7490 |
lineNr := tokenLineNr. |
|
1410 | 7491 |
cString := source upTo:$>. |
7492 |
self nextToken. |
|
1741 | 7493 |
|
7494 |
parseForCode ifFalse:[^ -1]. |
|
1764 | 7495 |
|
7496 |
CParser notNil ifTrue:[ |
|
7497 |
"/ collect existing types... |
|
7498 |
dictionaryOfKnownTypes := Dictionary new. |
|
7499 |
classToCompileFor methodsDo:[:m | |
|
7500 |
m literalsDo:[:lit | |
|
7501 |
(lit isKindOf:CType) ifTrue:[ |
|
7502 |
self assert:lit name notNil. |
|
7503 |
dictionaryOfKnownTypes at:lit name put:lit. |
|
7504 |
]. |
|
1551 | 7505 |
]. |
1741 | 7506 |
]. |
7507 |
]. |
|
7508 |
||
7509 |
cStream := cString readStream. |
|
7510 |
||
1748 | 7511 |
(#('apicall:' 'cdecl:' 'stdcall:' 'virtual') includes:callType ) ifTrue:[ |
1937 | 7512 |
"/ squeak/dolphin/stx external function definition |
1741 | 7513 |
self |
1937 | 7514 |
parseSTXOrSqueakOrDolphinExternalFunctionDeclarationFrom:cStream |
1741 | 7515 |
definitionType:callType |
7516 |
knownDefinitions:dictionaryOfKnownTypes |
|
7517 |
lineNr:lineNr. |
|
7518 |
^ -1 |
|
7519 |
]. |
|
7520 |
||
7521 |
callType = 'c:' ifTrue:[ |
|
7522 |
"/ VW external function definition |
|
7523 |
self |
|
7524 |
parseVWTypeOrExternalFunctionDeclarationFrom:cStream |
|
7525 |
definitionType:callType |
|
7526 |
knownDefinitions:dictionaryOfKnownTypes |
|
7527 |
lineNr:lineNr. |
|
7528 |
^ -1 |
|
7529 |
]. |
|
7530 |
||
7531 |
(callType = 'api:' or:[ callType = 'ole:' ]) ifTrue:[ |
|
7532 |
"/ ST/V external function definition |
|
7533 |
self |
|
7534 |
parseSTVExternalFunctionDeclarationFrom:cStream |
|
7535 |
definitionType:callType |
|
7536 |
knownDefinitions:dictionaryOfKnownTypes |
|
7537 |
lineNr:lineNr. |
|
1551 | 7538 |
^ -1 |
7539 |
]. |
|
7540 |
||
1710 | 7541 |
self ignorableParseError:'unsupported external function call type: ' , callType. |
1410 | 7542 |
^ -1 |
1551 | 7543 |
|
7544 |
" |
|
7545 |
(Parser for:'foo <cdecl: void ''glFlush'' (void) module: ''GL''>') |
|
7546 |
nextToken; |
|
7547 |
parseMethod |
|
7548 |
" |
|
1764 | 7549 |
|
1937 | 7550 |
"Modified: / 25-10-2006 / 12:03:33 / cg" |
1410 | 7551 |
! |
7552 |
||
7553 |
parsePrimitive |
|
7554 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
|
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7555 |
(return primitive number or #Error) |
1410 | 7556 |
or a Squeak-style primitive, as '< primitive: string >'; |
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7557 |
(return primitive name or #Error) |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7558 |
or a V'Age-style primitive, as '< primitive: identifier >'; |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7559 |
(return primitive name or #Error) |
1410 | 7560 |
|
1741 | 7561 |
Also, resource specs are parsed; the result is left (as side effect) in primitiveResource. |
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7562 |
It is used to flag methods, for faster finding of used keyboard accelerators, |
1410 | 7563 |
and to mark resource methods (image, menu or canvas resources). |
7564 |
||
7565 |
prim ::= st80Primitive | st80Pragma | stxPragma |
|
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7566 |
squeakPrimitive | vAgePrimitive | newSTXPrimitive | resourceDecl |
1410 | 7567 |
|
7568 |
st80Primitive ::= 'primitive:' INTEGER |
|
7569 |
st80Pragma ::= 'exception:' ( 'handle | 'raise' | 'unwind' ) |
|
7570 |
stxPragma ::= 'context:' 'return' |
|
7571 |
||
7572 |
squeakPrimitive ::= 'primitive:' STRING |
|
7573 |
||
7574 |
newSTXPrimitive ::= 'primitive' |
|
7575 |
||
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7576 |
vAgePrimitive ::= 'primitive:' IDENTIFIER |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7577 |
| 'sysprim:' IDENTIFIER |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7578 |
|
1410 | 7579 |
resourceDecl ::= 'resource:' SYMBOL - leave SYMBOL in primitiveResource |
7580 |
| 'resource:' SYMBOL (...) - leave (SYMBOL (...)) in primitiveResource |
|
7581 |
" |
|
7582 |
||
1741 | 7583 |
|lcTokenName| |
7584 |
||
1410 | 7585 |
(tokenType == #Keyword or:[tokenType == #Identifier]) ifFalse:[ |
7586 |
self parseError:'bad primitive definition (keyword expected)'. |
|
7587 |
^ #Error |
|
7588 |
]. |
|
7589 |
||
7590 |
(tokenName = 'primitive:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7591 |
^ self parseTraditionalPrimitive. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7592 |
]. |
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7593 |
(tokenName = 'sysprim:') ifTrue:[ |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7594 |
parserFlags allowVisualAgePrimitives ifTrue:[ |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7595 |
^ self parseTraditionalPrimitive. |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7596 |
]. |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7597 |
]. |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7598 |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7599 |
(tokenName = 'primitive') ifTrue:[ |
1410 | 7600 |
self nextToken. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7601 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7602 |
^ 0. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7603 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7604 |
(tokenName = 'resource:') ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7605 |
self parseResourcePragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7606 |
^ nil. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7607 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7608 |
(tokenName = 'exception:' |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7609 |
or:[tokenName = 'context:']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7610 |
self parseExceptionOrContextPragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7611 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7612 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7613 |
]. |
1741 | 7614 |
|
7615 |
lcTokenName := tokenName asLowercase. |
|
7616 |
((lcTokenName = 'c:') "/ vw external function definition |
|
7617 |
or:[ lcTokenName = 'api:' "/ st/v external function definition |
|
7618 |
or:[ lcTokenName = 'ole:' "/ st/v external function definition |
|
7619 |
or:[ lcTokenName = 'apicall:' "/ squeak external function definition |
|
7620 |
or:[ lcTokenName = 'cdecl:' "/ squeak external function definition |
|
1748 | 7621 |
or:[ lcTokenName = 'stdcall:' "/ dolphin external function definition |
7622 |
]]]]]) ifTrue:[ |
|
1551 | 7623 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7624 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7625 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7626 |
|
1716
cfbef30a7cb7
qualified names again (VW7);
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
7627 |
self ignorableParseError:'unrecognized pragma: ' , tokenName. |
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7628 |
self skipForClosingAngle. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7629 |
^ nil "/ no primitive number |
1410 | 7630 |
! |
7631 |
||
7632 |
parsePrimitiveOrResourceSpecOrEmpty |
|
7633 |
"parse a methods primitive or resource spec" |
|
7634 |
||
7635 |
|pos wmsg primNr primNrOrString| |
|
7636 |
||
7637 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
|
7638 |
pos := tokenPosition. |
|
7639 |
self nextToken. |
|
7640 |
primNrOrString := self parsePrimitive. |
|
7641 |
||
7642 |
(primNrOrString == #Error) ifTrue:[^ #Error]. |
|
7643 |
wmsg := nil. |
|
7644 |
||
7645 |
primNrOrString isString ifTrue:[ |
|
7646 |
primNr := self primitiveNumberFromName:primNrOrString |
|
7647 |
] ifFalse:[ |
|
7648 |
primNr := primNrOrString |
|
7649 |
]. |
|
7650 |
||
7651 |
primNr notNil ifTrue:[ |
|
7652 |
primNr < 0 ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7653 |
parserFlags warnST80Directives == true ifTrue:[ |
1410 | 7654 |
wmsg := 'ST-80/Squeak directive ignored'. |
7655 |
]. |
|
7656 |
] ifFalse:[ |
|
7657 |
primNr > 0 ifTrue:[ |
|
7658 |
primitiveNr := primNr. |
|
7659 |
wmsg := 'ST-80 primitive may not work' |
|
7660 |
] ifFalse:[ |
|
7661 |
primitiveNr := primNr. |
|
7662 |
wmsg := 'ST/X primitives only work in rel5 and newer' |
|
7663 |
] |
|
7664 |
]. |
|
1551 | 7665 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
7666 |
]. |
|
1410 | 7667 |
]. |
7668 |
||
7669 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
7670 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
|
7671 |
! |
|
7672 |
||
7673 |
parseResourcePragma |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7674 |
" '< resource:' has already been parsed." |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7675 |
|
1410 | 7676 |
|keys resource resourceValue| |
7677 |
||
7678 |
self nextToken. |
|
7679 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
7680 |
self parseError:'symbol expected'. |
|
7681 |
^ #Error |
|
7682 |
]. |
|
7683 |
||
7684 |
resource := tokenValue. |
|
7685 |
resourceValue := true. |
|
7686 |
||
7687 |
self nextToken. |
|
7688 |
||
7689 |
tokenType == $( ifTrue:[ |
|
7690 |
self nextToken. |
|
7691 |
keys := OrderedCollection new. |
|
7692 |
[(tokenType == $)) or:[tokenType == #EOF] ] whileFalse:[ |
|
7693 |
keys add:tokenValue. |
|
7694 |
self nextToken. |
|
7695 |
]. |
|
7696 |
resourceValue := keys. |
|
7697 |
(tokenType == $)) ifFalse:[ |
|
7698 |
self parseError:'unterminated primitive/spec (missing '')'')'. |
|
7699 |
]. |
|
7700 |
self nextToken. |
|
7701 |
]. |
|
7702 |
||
7703 |
primitiveResource isNil ifTrue:[ |
|
7704 |
primitiveResource := IdentityDictionary new. |
|
7705 |
]. |
|
7706 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7707 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7708 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7709 |
|
1741 | 7710 |
parseSTVExternalFunctionDeclarationFrom:aStream definitionType:definitionType knownDefinitions:dictionaryOfTypesOrNil lineNr:lineNr |
7711 |
"parses ST/V function declarations of the forms |
|
1748 | 7712 |
'<api: functionName argType1 .. argTypeN returnType>' |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7713 |
'<ole: vFunctionIndex argType1 .. argTypeN returnType>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7714 |
" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7715 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7716 |
|primParser function| |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7717 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7718 |
primParser := PrimitiveSpecParser new. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7719 |
function := primParser |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7720 |
parseSTVExternalFunctionDeclarationFrom:aStream |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7721 |
definitionType:definitionType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7722 |
lineNr:lineNr |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7723 |
for:self. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7724 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7725 |
function owningClass:classToCompileFor. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7726 |
self generateCallToExternalFunction:function lineNr:lineNr. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7727 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7728 |
"Modified: / 01-08-2006 / 16:16:53 / cg" |
1748 | 7729 |
! |
7730 |
||
1937 | 7731 |
parseSTXOrSqueakOrDolphinExternalFunctionDeclarationFrom:aStream definitionType:definitionType |
1748 | 7732 |
knownDefinitions:dictionaryOfTypesOrNil lineNr:lineNr |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7733 |
|
1937 | 7734 |
"parses squeak/dolphin/stx function declarations of the forms |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7735 |
'<stdcall: [virtual|nonVirtual] returnType functionNameOrIndex argType1..argTypeN>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7736 |
'<cdecl: [virtual|nonVirtual] returnType functionNameOrIndex argType1..argTypeN>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7737 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7738 |
'<cdecl: [async] [virtual|nonVirtual] returnType functionNameOrIndex ( argType1..argTypeN ) module: moduleName >' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7739 |
'<apicall: [async] [virtual|nonVirtual] returnType functionNameOrIndex ( argType1..argTypeN ) module: moduleName >' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7740 |
" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7741 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7742 |
|primParser function| |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7743 |
|
1816 | 7744 |
primParser := PrimitiveSpecParser new setClassToCompileFor:classToCompileFor. |
7745 |
primParser notifying:requestor. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7746 |
function := primParser |
1937 | 7747 |
parseSTXOrSqueakOrDolphinExternalFunctionDeclarationFrom:aStream |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7748 |
definitionType:definitionType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7749 |
lineNr:lineNr |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7750 |
for:self. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7751 |
|
1816 | 7752 |
function notNil ifTrue:[ |
7753 |
function owningClass:classToCompileFor. |
|
7754 |
self generateCallToExternalFunction:function lineNr:lineNr. |
|
7755 |
]. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7756 |
|
1937 | 7757 |
"Created: / 25-10-2006 / 12:03:24 / cg" |
1741 | 7758 |
! |
7759 |
||
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7760 |
parseTraditionalPrimitive |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7761 |
"parse everything after the initial '<primitive:'" |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7762 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7763 |
|primNumber| |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7764 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7765 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7766 |
(tokenType == #Integer) ifFalse:[ |
1744 | 7767 |
(parserFlags allowSqueakExtensions |
7768 |
or:[ parserFlags allowSqueakPrimitives ]) ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7769 |
(tokenType == #String) ifFalse:[ |
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7770 |
self parseError:'primitive name as string expected'. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7771 |
^ #Error |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7772 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7773 |
] ifFalse:[ |
1690
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7774 |
parserFlags allowVisualAgePrimitives ifTrue:[ |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7775 |
(tokenType == #Identifier) ifFalse:[ |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7776 |
self parseError:'primitive name expected'. |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7777 |
^ #Error |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7778 |
] |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7779 |
] ifFalse:[ |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7780 |
self parseError:'primitive number expected'. |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7781 |
^ #Error |
9878628e15ac
support parsing (at least) of V'Age primitives
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
7782 |
]. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7783 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7784 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7785 |
primitiveNr notNil ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7786 |
self parseError:'only one primitive spec allowed'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7787 |
primNumber := -1. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7788 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7789 |
primNumber := tokenValue. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7790 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7791 |
self nextToken. |
1556 | 7792 |
|
7793 |
(tokenType == #Keyword) ifTrue:[ |
|
7794 |
(tokenName = 'errorCode:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7795 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7796 |
(tokenType == #Identifier) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7797 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7798 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7799 |
self error:'not yet implemented'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7800 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7801 |
]. |
1744 | 7802 |
(tokenName = 'module:') ifTrue:[ |
7803 |
self nextToken. |
|
7804 |
(tokenType == #String) ifTrue:[ |
|
1556 | 7805 |
self nextToken. |
1744 | 7806 |
] ifFalse:[ |
7807 |
self error:'not yet implemented'. |
|
7808 |
] |
|
1556 | 7809 |
]. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7810 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7811 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7812 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7813 |
^ primNumber |
1410 | 7814 |
! |
7815 |
||
1741 | 7816 |
parseVWTypeOrExternalFunctionDeclarationFrom:aStream definitionType:definitionType knownDefinitions:dictionaryOfTypesOrNil lineNr:lineNr |
7817 |
"parses visualWorks type/function declarations of the form: |
|
7818 |
'<c: ...>'" |
|
7819 |
||
2052 | 7820 |
|primParser functionOrTypeOrValue| |
7821 |
||
7822 |
primParser := PrimitiveSpecParser new setClassToCompileFor:classToCompileFor. |
|
7823 |
functionOrTypeOrValue := primParser |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7824 |
parseVWTypeOrExternalFunctionDeclarationFrom:aStream |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7825 |
definitionType:definitionType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7826 |
knownDefinitions:dictionaryOfTypesOrNil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7827 |
lineNr:lineNr |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7828 |
for: self. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7829 |
|
2051 | 7830 |
functionOrTypeOrValue isNil ifTrue:[^ self]. |
7831 |
||
7832 |
(functionOrTypeOrValue isKindOf:ExternalLibraryFunction) ifFalse:[ |
|
7833 |
self generateReturnOfValue:functionOrTypeOrValue. |
|
1741 | 7834 |
^ self |
7835 |
]. |
|
7836 |
||
2051 | 7837 |
functionOrTypeOrValue owningClass:classToCompileFor. |
7838 |
self generateCallToExternalFunction:functionOrTypeOrValue lineNr:lineNr. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7839 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
7840 |
"Modified: / 01-08-2006 / 16:21:36 / cg" |
1741 | 7841 |
! |
7842 |
||
1410 | 7843 |
primitiveNumberFromName:aPrimitiveName |
7844 |
"for future compatibility with Squeak ..." |
|
7845 |
||
7846 |
^ nil |
|
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7847 |
! |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7848 |
|
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7849 |
skipForClosingAngle |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7850 |
"/ skip |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7851 |
[tokenType ~~ #EOF] whileTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7852 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7853 |
self nextToken. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7854 |
^ nil "/ no primitive number |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7855 |
]. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7856 |
self nextToken. |
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
7857 |
]. |
1410 | 7858 |
! ! |
7859 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7860 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7861 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7862 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7863 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7864 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7865 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7866 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7867 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7868 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7869 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7870 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7871 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7872 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7873 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7874 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7875 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7876 |
"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
|
7877 |
"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
|
7878 |
"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
|
7879 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7880 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7881 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7882 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7883 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7884 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7885 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7886 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7887 |
currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7888 |
|pkg| |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7889 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7890 |
pkg := currentPackage. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7891 |
pkg isNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7892 |
(requestor respondsTo:#currentPackage) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7893 |
pkg := requestor currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7894 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7895 |
pkg := Class packageQuerySignal query. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7896 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7897 |
currentPackage := pkg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7898 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7899 |
^ pkg |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7900 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7901 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7902 |
currentPackage:aPackageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7903 |
currentPackage := aPackageName. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7904 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7905 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7906 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7907 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7908 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7909 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7910 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7911 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7912 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7913 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7914 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7915 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7916 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7917 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7918 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7919 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7920 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7921 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7922 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7923 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7924 |
"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
|
7925 |
"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
|
7926 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7927 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7928 |
findNameSpaceWith:aVariableName |
692 | 7929 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7930 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7931 |
"/ 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
|
7932 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7933 |
classToCompileFor notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7934 |
"/ Q: |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7935 |
"/ consider private classes of superclasses. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7936 |
"/ 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
|
7937 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7938 |
"/ 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
|
7939 |
"/ known to the corresponding ownerClass. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7940 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7941 |
"is it in the classes namespace ?" |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7942 |
|
1315 | 7943 |
ns := classToCompileFor topNameSpace. |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7944 |
(ns notNil |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7945 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
1142 | 7946 |
ns isNameSpace ifTrue:[ |
7947 |
(ns at:aVariableName) notNil ifTrue:[ |
|
7948 |
^ ns |
|
7949 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7950 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7951 |
]. |
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
7952 |
|
495 | 7953 |
"/ ns := classToCompileFor nameSpace. |
7954 |
"/ ns notNil ifTrue:[ |
|
7955 |
"/ "is it in the current classes namespace ?" |
|
7956 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
7957 |
"/ ^ ns |
|
7958 |
"/ ] |
|
7959 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7960 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7961 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7962 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7963 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7964 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7965 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
1043 | 7966 |
currentSpace isNameSpace ifTrue:[ |
7967 |
(currentSpace at:aVariableName) notNil ifTrue:[ |
|
7968 |
^ currentSpace |
|
7969 |
] |
|
7970 |
] ifFalse:[ |
|
7971 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
7972 |
^ currentSpace |
|
7973 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7974 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7975 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7976 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7977 |
"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
|
7978 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7979 |
usedSpaces notNil ifTrue:[ |
1696 | 7980 |
^ usedSpaces detect:[:aNameSpace | (aNameSpace at:aVariableName) notNil] ifNone:nil. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7981 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7982 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7983 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7984 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 7985 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 7986 |
! |
7987 |
||
1762 | 7988 |
genMakeArrayWith:elementExpressions |
7989 |
"return a node to generate an array at runtime. |
|
7990 |
Will generate: |
|
7991 |
Array with:el1 ... with:elN (if N <= 5) |
|
7992 |
or: |
|
7993 |
(Array new at:1 put:el1; ... at:N put:elN; yourself) (otherwise) |
|
7994 |
" |
|
7995 |
||
7996 |
|numEl arrRec sel expr| |
|
7997 |
||
7998 |
arrRec := VariableNode globalNamed:#Array. |
|
7999 |
||
8000 |
numEl := elementExpressions size. |
|
8001 |
||
8002 |
(numEl between:1 and:8) ifTrue:[ |
|
8003 |
sel := #( |
|
8004 |
#'with:' |
|
8005 |
#'with:with:' |
|
8006 |
#'with:with:with:' |
|
8007 |
#'with:with:with:with:' |
|
8008 |
#'with:with:with:with:with:' |
|
8009 |
#'with:with:with:with:with:with:' |
|
8010 |
#'with:with:with:with:with:with:with:' |
|
8011 |
#'with:with:with:with:with:with:with:with:' |
|
8012 |
) at:numEl. |
|
8013 |
||
8014 |
^ MessageNode |
|
8015 |
receiver:arrRec |
|
8016 |
selector:sel |
|
8017 |
args:elementExpressions. |
|
8018 |
]. |
|
8019 |
||
8020 |
"/ array creation expression ... |
|
8021 |
expr := MessageNode |
|
8022 |
receiver:arrRec |
|
8023 |
selector:#new: |
|
8024 |
arg:(ConstantNode type:#Integer value:numEl). |
|
8025 |
||
8026 |
numEl == 0 ifTrue:[ |
|
8027 |
^ expr. |
|
8028 |
]. |
|
8029 |
"/ followed by a bunch of #at:put: messages... |
|
8030 |
elementExpressions keysAndValuesDo:[:idx :e | |
|
8031 |
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
|
8032 |
receiver:expr |
|
8033 |
selector:#at:put: |
|
8034 |
arg1:(ConstantNode type:#Integer value:idx) |
|
8035 |
arg2:e |
|
8036 |
fold:false. |
|
8037 |
]. |
|
8038 |
"/ followed by a #yourself: message... |
|
8039 |
expr := CascadeNode |
|
8040 |
receiver:expr |
|
8041 |
selector:#yourself. |
|
8042 |
^ expr |
|
8043 |
! |
|
8044 |
||
713 | 8045 |
inWhichClassIsClassInstVar:aString |
8046 |
"search class-chain for the class-instance variable named aString |
|
8047 |
- return the class or nil if not found" |
|
8048 |
||
8049 |
|aClass| |
|
8050 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8051 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8052 |
|
713 | 8053 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8054 |
(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
|
8055 |
aClass := aClass superclass |
713 | 8056 |
]. |
8057 |
^ nil |
|
8058 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8059 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 8060 |
! |
8061 |
||
8062 |
inWhichClassIsClassVar:aString |
|
8063 |
"search class-chain for the classvariable named aString |
|
8064 |
- return the class or nil if not found" |
|
8065 |
||
8066 |
|aClass className baseClass| |
|
8067 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8068 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8069 |
|
713 | 8070 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8071 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8072 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8073 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8074 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8075 |
] |
713 | 8076 |
]. |
8077 |
^ aClass whichClassDefinesClassVar:aString |
|
8078 |
||
8079 |
"/ [aClass notNil] whileTrue:[ |
|
8080 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
8081 |
"/ aClass := aClass superclass |
|
8082 |
"/ ]. |
|
8083 |
"/ ^ nil |
|
8084 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8085 |
"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
|
8086 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 8087 |
! |
8088 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8089 |
isStatementAnUnconditionalReturn:aStatementNode |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8090 |
|expr selector block1 block2 stats1 stats2| |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8091 |
|
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8092 |
aStatementNode isReturnNode ifTrue:[^ true ]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8093 |
((expr := aStatementNode expression) notNil |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8094 |
and:[expr isMessage]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8095 |
selector := expr selector. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8096 |
(selector == #'ifTrue:ifFalse:' or:[selector == #'ifFalse:ifTrue:']) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8097 |
block1 := expr arg1. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8098 |
block2 := expr arguments at:2. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8099 |
(block1 isBlockNode and:[ block2 isBlockNode]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8100 |
stats1 := block1 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8101 |
stats2 := block2 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8102 |
(stats1 notEmptyOrNil and:[ stats2 notEmptyOrNil]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8103 |
^ (self isStatementAnUnconditionalReturn:stats1 last) |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8104 |
and:[self isStatementAnUnconditionalReturn:stats2 last] |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8105 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8106 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8107 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8108 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8109 |
^ false. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8110 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
8111 |
|
1762 | 8112 |
isValidUnarySelector:tokenType |
8113 |
tokenType == #Identifier ifTrue:[^true]. |
|
8114 |
tokenType == #Here ifTrue:[^true]. |
|
8115 |
||
8116 |
parserFlags allowReservedWordsAsSelectors == true ifTrue:[ |
|
8117 |
tokenType == #Self ifTrue:[^true]. |
|
8118 |
tokenType == #Nil ifTrue:[^true]. |
|
8119 |
tokenType == #True ifTrue:[^true]. |
|
8120 |
tokenType == #False ifTrue:[^true]. |
|
8121 |
tokenType == #Super ifTrue:[^true]. |
|
8122 |
tokenType == #ThisContext ifTrue:[^true]. |
|
8123 |
]. |
|
8124 |
^ false |
|
8125 |
||
8126 |
" |
|
8127 |
ParserFlags allowReservedWordsAsSelectors:true. |
|
8128 |
1234 self. |
|
8129 |
||
8130 |
ParserFlags allowReservedWordsAsSelectors:false |
|
8131 |
1234 self. |
|
8132 |
" |
|
8133 |
||
8134 |
" |
|
8135 |
1234 self |
|
8136 |
1234 nil |
|
8137 |
1234 true |
|
8138 |
1234 false |
|
8139 |
1234 here |
|
8140 |
1234 super |
|
8141 |
1234 thisContext |
|
8142 |
" |
|
8143 |
! |
|
8144 |
||
1615 | 8145 |
makeImmutableArray:anArray |
1621 | 8146 |
^ self class makeImmutableArray:anArray |
1615 | 8147 |
! |
8148 |
||
8149 |
makeImmutableString:aString |
|
1621 | 8150 |
^ self class makeImmutableString:aString |
1615 | 8151 |
! |
8152 |
||
1262 | 8153 |
makeReferenceFor:aNode |
8154 |
|rec sel indexNode contextNode arg1 arg2| |
|
8155 |
||
8156 |
contextNode := VariableNode type:#ThisContext context:contextToEvaluateIn. |
|
8157 |
indexNode := ConstantNode type:#Integer value:aNode index. |
|
8158 |
||
8159 |
aNode isArgument ifTrue:[ |
|
8160 |
sel := #forArgument:in:. |
|
8161 |
arg1 := indexNode. |
|
8162 |
arg2 := contextNode. |
|
8163 |
] ifFalse:[ |
|
8164 |
aNode isLocal ifTrue:[ |
|
8165 |
sel := #forLocal:in:. |
|
8166 |
arg1 := indexNode. |
|
8167 |
arg2 := contextNode. |
|
8168 |
] ifFalse:[ |
|
8169 |
self parseError:'unsupported variable reference (must be local or argument)'. |
|
8170 |
^ aNode |
|
8171 |
] |
|
8172 |
]. |
|
8173 |
||
8174 |
parseForCode ifFalse:[self rememberGlobalUsed:'Reference']. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
8175 |
rec := VariableNode globalNamed:'Reference'. |
1262 | 8176 |
|
8177 |
^ MessageNode receiver:rec selector:sel arg1:arg1 arg2:arg2. |
|
8178 |
! |
|
8179 |
||
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8180 |
noAssignmentAllowed:eMsg at:pos |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8181 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8182 |
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
|
8183 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8184 |
^ false |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8185 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8186 |
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
|
8187 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8188 |
^ true |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8189 |
! |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
8190 |
|
1762 | 8191 |
nodeForMethodArg:varName |
8192 |
|varIndex var| |
|
8193 |
||
8194 |
methodArgNames isNil ifTrue:[^ nil]. |
|
8195 |
varIndex := methodArgNames indexOf:varName. |
|
8196 |
varIndex == 0 ifTrue:[^ nil]. |
|
8197 |
||
8198 |
var := methodArgs at:varIndex. |
|
8199 |
"/ var used:true. |
|
8200 |
^ VariableNode type:#MethodArg |
|
8201 |
name:varName |
|
8202 |
token:var |
|
8203 |
index:varIndex |
|
8204 |
! |
|
8205 |
||
8206 |
nodeForMethodVariable:varName |
|
8207 |
|varIndex var| |
|
8208 |
||
8209 |
methodVarNames isNil ifTrue:[^ nil]. |
|
8210 |
varIndex := methodVarNames indexOf:varName. |
|
8211 |
varIndex == 0 ifTrue:[^ nil]. |
|
8212 |
||
8213 |
var := methodVars at:varIndex. |
|
8214 |
var used:true. |
|
8215 |
parseForCode ifFalse:[self rememberLocalUsed:varName]. |
|
8216 |
^ VariableNode type:#MethodVariable |
|
8217 |
name:varName |
|
8218 |
token:var |
|
8219 |
index:varIndex |
|
8220 |
! |
|
8221 |
||
787 | 8222 |
plausibilityCheck:aNode |
1687 | 8223 |
|note rcvr| |
1193 | 8224 |
|
2093
b6b27c9c4d26
remember already warned unimplemented selectors;
Claus Gittinger <cg@exept.de>
parents:
2090
diff
changeset
|
8225 |
note := aNode plausibilityCheckIn:self. |
1193 | 8226 |
note isNil ifTrue:[ |
8227 |
aNode isMessage ifTrue:[ |
|
8228 |
(contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
|
1687 | 8229 |
rcvr := aNode receiver. |
8230 |
(rcvr isSuper and:[rcvr isHere not]) ifTrue:[ |
|
8231 |
aNode selector ~= selector ifTrue:[ |
|
1803
ea888d90dfef
only warn once about bad super-message
Claus Gittinger <cg@exept.de>
parents:
1782
diff
changeset
|
8232 |
didWarnAboutBadSupersend ifFalse:[ |
ea888d90dfef
only warn once about bad super-message
Claus Gittinger <cg@exept.de>
parents:
1782
diff
changeset
|
8233 |
didWarnAboutBadSupersend := true. |
2100 | 8234 |
note := 'possible bad super message ? (selector should be same as in current method)'. |
1803
ea888d90dfef
only warn once about bad super-message
Claus Gittinger <cg@exept.de>
parents:
1782
diff
changeset
|
8235 |
] |
1193 | 8236 |
]. |
8237 |
]. |
|
8238 |
]. |
|
8239 |
]. |
|
8240 |
]. |
|
2100 | 8241 |
note isNil ifTrue:[ ^ nil]. |
8242 |
^ note withCRs |
|
8243 |
||
8244 |
||
8245 |
||
8246 |
||
8247 |
||
8248 |
||
8249 |
||
8250 |
||
8251 |
||
8252 |
||
8253 |
||
8254 |
||
8255 |
||
1262 | 8256 |
! |
8257 |
||
8258 |
selfNode |
|
8259 |
selfNode isNil ifTrue:[ |
|
8260 |
selfNode := SelfNode value:selfValue |
|
8261 |
]. |
|
8262 |
^ selfNode |
|
141 | 8263 |
! ! |
8264 |
||
8265 |
!Parser methodsFor:'queries'! |
|
8266 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8267 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8268 |
"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
|
8269 |
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
|
8270 |
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
|
8271 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8272 |
|
1160 | 8273 |
|m who| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8274 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8275 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 8276 |
m := contextToEvaluateIn method. |
8277 |
m notNil ifTrue:[ |
|
8278 |
who := contextToEvaluateIn method who. |
|
8279 |
who notNil ifTrue:[ |
|
8280 |
^ who methodClass. |
|
8281 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8282 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8283 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8284 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8285 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8286 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8287 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 8288 |
"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
|
8289 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8290 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8291 |
classesClassInstVarNames |
141 | 8292 |
"caching allInstVarNames for next compilation saves time ..." |
8293 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8294 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8295 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8296 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8297 |
|cls| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8298 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8299 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8300 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8301 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8302 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8303 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8304 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8305 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8306 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8307 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8308 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8309 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8310 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8311 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8312 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8313 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8314 |
"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
|
8315 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 8316 |
! |
8317 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8318 |
classesClassVarNames |
141 | 8319 |
"caching allClassVarNames for next compilation saves time ..." |
8320 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8321 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8322 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8323 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8324 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8325 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8326 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
8327 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8328 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8329 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8330 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8331 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8332 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8333 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8334 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8335 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8336 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8337 |
] |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8338 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8339 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8340 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8341 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8342 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8343 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8344 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
8345 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
8346 |
"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
|
8347 |
"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
|
8348 |
"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
|
8349 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8350 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8351 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8352 |
"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
|
8353 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8354 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8355 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8356 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8357 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8358 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8359 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8360 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8361 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8362 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8363 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8364 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8365 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8366 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8367 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8368 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8369 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
8370 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8371 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8372 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 8373 |
! |
8374 |
||
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8375 |
contextMustBeReturnable |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8376 |
^ primitiveContextInfo notNil |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8377 |
and:[ ^ primitiveContextInfo includes:('context:' -> #return) ] |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8378 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8379 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8380 |
! |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
8381 |
|
141 | 8382 |
hasNonOptionalPrimitiveCode |
8383 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
8384 |
||
8385 |
^ hasNonOptionalPrimitiveCode |
|
0 | 8386 |
! |
8387 |
||
141 | 8388 |
hasPrimitiveCode |
8389 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
8390 |
||
8391 |
^ hasPrimitiveCode |
|
98 | 8392 |
! |
8393 |
||
2085
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8394 |
isCompiling |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8395 |
"return true if compiling code as opposed to evaluating" |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8396 |
|
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8397 |
^ false |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8398 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8399 |
|
1440 | 8400 |
isDoIt |
8401 |
^ (selector isNil or:[selector == #'doIt' or:[selector == #'doIt:']]) |
|
8402 |
! |
|
8403 |
||
883 | 8404 |
isSyntaxHighlighter |
8405 |
^ false |
|
8406 |
! |
|
8407 |
||
385 | 8408 |
lineNumberInfo |
8409 |
^ lineNumberInfo |
|
8410 |
||
8411 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
8412 |
! |
|
8413 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
8414 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
8415 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
8416 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
8417 |
"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
|
8418 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
8419 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8420 |
messagesSent |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8421 |
"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
|
8422 |
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
|
8423 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8424 |
^ (messagesSent ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8425 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8426 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8427 |
messagesSentToSelf |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8428 |
"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
|
8429 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8430 |
^ (messagesSentToSelf ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8431 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8432 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8433 |
messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8434 |
"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
|
8435 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8436 |
^ (messagesSentToSuper ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8437 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8438 |
|
141 | 8439 |
methodArgs |
8440 |
"return an array with methodarg names (valid after parsing spec)" |
|
8441 |
||
8442 |
^ methodArgNames |
|
8443 |
! |
|
8444 |
||
8445 |
methodVars |
|
8446 |
"return a collection with method variablenames (valid after parsing)" |
|
8447 |
||
8448 |
^ methodVarNames |
|
23 | 8449 |
! |
8450 |
||
141 | 8451 |
modifiedClassVars |
8452 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
8453 |
||
541 | 8454 |
^ modifiedClassVars ? #() |
8455 |
||
8456 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 8457 |
! |
8458 |
||
8459 |
modifiedGlobals |
|
8460 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
8461 |
||
541 | 8462 |
^ modifiedGlobals ? #() |
8463 |
||
8464 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 8465 |
! |
8466 |
||
8467 |
modifiedInstVars |
|
8468 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
8469 |
||
541 | 8470 |
^ modifiedInstVars ? #() |
8471 |
||
8472 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 8473 |
! |
8474 |
||
141 | 8475 |
numberOfMethodArgs |
8476 |
"return the number of methodargs (valid after parsing spec)" |
|
8477 |
||
8478 |
^ methodArgs size |
|
8479 |
! |
|
8480 |
||
8481 |
numberOfMethodVars |
|
8482 |
"return the number of method variables (valid after parsing)" |
|
8483 |
||
8484 |
^ methodVars size |
|
8485 |
! |
|
8486 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8487 |
readClassVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8488 |
"return a collection with classvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8489 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8490 |
^ readClassVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8491 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8492 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8493 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8494 |
|
2053 | 8495 |
readGlobals |
8496 |
"return a collection with global varNames read by method (valid after parsing)" |
|
8497 |
||
8498 |
^ readGlobals ? #() |
|
8499 |
||
8500 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
8501 |
! |
|
8502 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8503 |
readInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8504 |
"return a collection with instvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8505 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8506 |
^ readInstVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8507 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8508 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8509 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8510 |
|
141 | 8511 |
selector |
8512 |
"return the selector (valid after parsing spec)" |
|
8513 |
||
8514 |
^ selector |
|
0 | 8515 |
! |
8516 |
||
2085
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8517 |
shouldPerformCodingStyleChecks |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8518 |
^ ignoreWarnings not and:[ self isCompiling ] |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8519 |
! |
9e68a92eb94a
Enable coding style checks only when compiling
Stefan Vogel <sv@exept.de>
parents:
2082
diff
changeset
|
8520 |
|
141 | 8521 |
usedClassVars |
8522 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
8523 |
||
541 | 8524 |
^ usedClassVars ? #() |
8525 |
||
8526 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 8527 |
! |
8528 |
||
8529 |
usedGlobals |
|
8530 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
8531 |
||
541 | 8532 |
^ usedGlobals ? #() |
8533 |
||
8534 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 8535 |
! |
8536 |
||
8537 |
usedInstVars |
|
8538 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
8539 |
||
541 | 8540 |
^ usedInstVars ? #() |
8541 |
||
8542 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 8543 |
! |
8544 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8545 |
usedSymbols |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8546 |
"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
|
8547 |
|
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8548 |
^ (usedSymbols ? #()) |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8549 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8550 |
|
141 | 8551 |
usedVars |
8552 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
8553 |
||
541 | 8554 |
^ usedVars ? #() |
8555 |
||
8556 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 8557 |
! |
8558 |
||
141 | 8559 |
usesSuper |
8560 |
"return true if the parsed method uses super (valid after parsing)" |
|
8561 |
||
8562 |
^ usesSuper |
|
8563 |
! ! |
|
8564 |
||
8565 |
!Parser methodsFor:'setup'! |
|
8566 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8567 |
arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8568 |
^ parserFlags arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8569 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8570 |
|
1615 | 8571 |
arraysAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8572 |
parserFlags arraysAreImmutable:aBoolean. |
1615 | 8573 |
! |
8574 |
||
1220
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8575 |
classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8576 |
^ classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8577 |
|
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8578 |
"Created: / 15.11.2001 / 17:21:10 / cg" |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8579 |
! |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
8580 |
|
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8581 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8582 |
"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
|
8583 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8584 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8585 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8586 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8587 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8588 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
8589 |
|
141 | 8590 |
initialize |
8591 |
super initialize. |
|
8592 |
||
8593 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
8594 |
usesSuper := false. |
|
8595 |
parseForCode := false. |
|
2108 | 8596 |
allowUndeclaredVariables := true. |
377 | 8597 |
foldConstants := FoldConstants. |
8598 |
lineNumberInfo := LineNumberInfo. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
8599 |
parenthesisLevel := 0. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8600 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8601 |
didWarnAboutSTXNameSpaceUse := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8602 |
didWarnAboutSTXHereExtensionUsed := false. |
1803
ea888d90dfef
only warn once about bad super-message
Claus Gittinger <cg@exept.de>
parents:
1782
diff
changeset
|
8603 |
didWarnAboutBadSupersend := false. |
607 | 8604 |
|
8605 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 8606 |
! |
8607 |
||
8608 |
parseForCode |
|
8609 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
8610 |
Use this when parsing for compilation or evaluation" |
|
8611 |
||
8612 |
parseForCode := true |
|
0 | 8613 |
! |
8614 |
||
141 | 8615 |
setClassToCompileFor:aClass |
8616 |
"set the class to be used for parsing/evaluating" |
|
8617 |
||
8618 |
classToCompileFor := aClass. |
|
8619 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 8620 |
PrevClass notNil ifTrue:[ |
8621 |
Parser update:PrevClass |
|
8622 |
] |
|
141 | 8623 |
] |
8624 |
! |
|
8625 |
||
8626 |
setContext:aContext |
|
8627 |
"set the context used while evaluating" |
|
8628 |
||
8629 |
contextToEvaluateIn := aContext |
|
8630 |
! |
|
8631 |
||
8632 |
setSelf:anObject |
|
8633 |
"set the value to be used for self while evaluating" |
|
8634 |
||
8635 |
selfValue := anObject. |
|
8636 |
classToCompileFor := anObject class. |
|
8637 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 8638 |
PrevClass notNil ifTrue:[ |
8639 |
Parser update:PrevClass |
|
8640 |
] |
|
141 | 8641 |
] |
607 | 8642 |
! |
8643 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8644 |
stringsAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8645 |
^ parserFlags stringsAreImmutable. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8646 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8647 |
|
1615 | 8648 |
stringsAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8649 |
parserFlags stringsAreImmutable:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8650 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8651 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8652 |
warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8653 |
^ parserFlags warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8654 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8655 |
"Created: 7.9.1997 / 02:05:00 / cg" |
1615 | 8656 |
! |
8657 |
||
607 | 8658 |
warnUndeclared:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8659 |
parserFlags warnUndeclared:aBoolean. |
607 | 8660 |
|
8661 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
1160 | 8662 |
! |
8663 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8664 |
warnUnusedVars |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8665 |
^ parserFlags warnUnusedVars |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8666 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8667 |
|
1160 | 8668 |
warnUnusedVars:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
8669 |
parserFlags warnUnusedVars:aBoolean. |
0 | 8670 |
! ! |
8671 |
||
84 | 8672 |
!Parser methodsFor:'statistic'! |
8673 |
||
2053 | 8674 |
rememberClassVarModified:name |
8675 |
modifiedClassVars isNil ifTrue:[ |
|
8676 |
modifiedClassVars := Set new |
|
8677 |
]. |
|
8678 |
modifiedClassVars add:name. |
|
8679 |
self rememberClassVarUsed:name |
|
8680 |
! |
|
8681 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8682 |
rememberClassVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8683 |
readClassVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8684 |
readClassVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8685 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8686 |
readClassVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8687 |
self rememberClassVarUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8688 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8689 |
|
141 | 8690 |
rememberClassVarUsed:name |
8691 |
usedClassVars isNil ifTrue:[ |
|
1576 | 8692 |
usedClassVars := Set new |
141 | 8693 |
]. |
8694 |
usedClassVars add:name. |
|
8695 |
self rememberVariableUsed:name |
|
8696 |
! |
|
8697 |
||
2053 | 8698 |
rememberGlobalModified:name |
8699 |
modifiedGlobals isNil ifTrue:[ |
|
8700 |
modifiedGlobals := Set new |
|
8701 |
]. |
|
8702 |
modifiedGlobals add:name. |
|
8703 |
self rememberGlobalUsed:name. |
|
8704 |
! |
|
8705 |
||
8706 |
rememberGlobalRead:name |
|
8707 |
readGlobals isNil ifTrue:[ |
|
8708 |
readGlobals := Set new |
|
8709 |
]. |
|
8710 |
readGlobals add:name. |
|
8711 |
self rememberGlobalUsed:name |
|
8712 |
! |
|
8713 |
||
141 | 8714 |
rememberGlobalUsed:name |
8715 |
usedGlobals isNil ifTrue:[ |
|
1576 | 8716 |
usedGlobals := Set new |
141 | 8717 |
]. |
8718 |
usedGlobals add:name. |
|
8719 |
self rememberVariableUsed:name |
|
8720 |
! |
|
8721 |
||
2053 | 8722 |
rememberInstVarModified:name |
8723 |
modifiedInstVars isNil ifTrue:[ |
|
8724 |
modifiedInstVars := Set new |
|
8725 |
]. |
|
8726 |
modifiedInstVars add:name. |
|
8727 |
self rememberInstVarUsed:name. |
|
8728 |
! |
|
8729 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8730 |
rememberInstVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8731 |
readInstVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8732 |
readInstVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8733 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8734 |
readInstVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8735 |
self rememberVariableUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8736 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
8737 |
|
141 | 8738 |
rememberInstVarUsed:name |
8739 |
usedInstVars isNil ifTrue:[ |
|
1576 | 8740 |
usedInstVars := Set new |
141 | 8741 |
]. |
8742 |
usedInstVars add:name. |
|
8743 |
self rememberVariableUsed:name |
|
8744 |
! |
|
8745 |
||
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8746 |
rememberLocalUsed:name |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8747 |
usedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8748 |
usedLocalVars := Set new |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8749 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8750 |
usedLocalVars add:name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8751 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8752 |
! |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
8753 |
|
1231 | 8754 |
rememberReturnedValue:anExpressionNode |
8755 |
|expr| |
|
8756 |
||
8757 |
returnedValues isNil ifTrue:[returnedValues := Set new]. |
|
8758 |
||
8759 |
expr := anExpressionNode. |
|
8760 |
expr isAssignment ifTrue:[ |
|
8761 |
expr := expr expression. |
|
8762 |
]. |
|
8763 |
(expr isConstant or:[expr isSelf]) ifTrue:[ |
|
8764 |
returnedValues add:expr |
|
8765 |
]. |
|
8766 |
! |
|
8767 |
||
84 | 8768 |
rememberSelectorUsed:sel |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8769 |
messagesSent isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8770 |
messagesSent := IdentitySet new. |
84 | 8771 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8772 |
messagesSent add:sel |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8773 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8774 |
|
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8775 |
rememberSelectorUsed:sel receiver:receiverNode |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8776 |
self rememberSelectorUsed:sel. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8777 |
receiverNode isSuper ifTrue:[ |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8778 |
self rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8779 |
] ifFalse:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8780 |
receiverNode isSelf ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8781 |
self rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8782 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8783 |
]. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8784 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8785 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8786 |
rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8787 |
messagesSentToSelf isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8788 |
messagesSentToSelf := IdentitySet new. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
8789 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8790 |
messagesSentToSelf add:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8791 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8792 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8793 |
rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8794 |
messagesSentToSuper isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8795 |
messagesSentToSuper := IdentitySet new. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8796 |
]. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
8797 |
messagesSentToSuper add:sel |
84 | 8798 |
! |
8799 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8800 |
rememberSymbolUsed:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8801 |
usedSymbols isNil ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8802 |
usedSymbols := IdentitySet new. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8803 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8804 |
usedSymbols add:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8805 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
8806 |
|
84 | 8807 |
rememberVariableUsed:name |
8808 |
usedVars isNil ifTrue:[ |
|
1576 | 8809 |
usedVars := Set new |
84 | 8810 |
]. |
8811 |
usedVars add:name |
|
8812 |
! ! |
|
8813 |
||
1340 | 8814 |
!Parser::ParseError methodsFor:'accessing'! |
8815 |
||
1386 | 8816 |
description |
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8817 |
|s| |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8818 |
|
1461 | 8819 |
s := super description. |
8820 |
s last isSeparator ifFalse:[ |
|
8821 |
errorMessage size > 0 ifTrue:[ |
|
8822 |
s := s , ' ' |
|
8823 |
] |
|
8824 |
]. |
|
8825 |
s := s , (errorMessage ? ''). |
|
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8826 |
lineNumber notNil ifTrue:[ |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8827 |
s := s , ' [' , lineNumber asString , ']' |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8828 |
]. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8829 |
^ s |
1386 | 8830 |
! |
8831 |
||
1340 | 8832 |
endPosition |
8833 |
^ endPosition |
|
8834 |
! |
|
8835 |
||
8836 |
errorMessage |
|
8837 |
^ errorMessage |
|
8838 |
! |
|
8839 |
||
1460 | 8840 |
errorMessage:errorMessageArg startPosition:startPositionArg |
8841 |
errorMessage := errorMessageArg. |
|
8842 |
startPosition := startPositionArg. |
|
8843 |
! |
|
8844 |
||
1340 | 8845 |
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg |
8846 |
errorMessage := errorMessageArg. |
|
8847 |
startPosition := startPositionArg. |
|
8848 |
endPosition := endPositionArg. |
|
8849 |
! |
|
8850 |
||
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8851 |
lineNumber:something |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8852 |
lineNumber := something. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8853 |
! |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
8854 |
|
1340 | 8855 |
parser |
8856 |
^ originator |
|
8857 |
! |
|
8858 |
||
8859 |
startPosition |
|
8860 |
^ startPosition |
|
8861 |
! ! |
|
8862 |
||
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8863 |
!Parser::PrimitiveSpecParser methodsFor:'initialization'! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8864 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8865 |
initialize |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8866 |
super initialize. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8867 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8868 |
actionArray := actionArray copy. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8869 |
actionArray at:$" codePoint put:(actionArray at:$' codePoint). |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8870 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8871 |
"Created: / 01-08-2006 / 14:39:24 / cg" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8872 |
! ! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8873 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8874 |
!Parser::PrimitiveSpecParser methodsFor:'parsing'! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8875 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8876 |
parseSTVExternalFunctionDeclarationFrom:aStream definitionType:definitionType lineNr:lineNr for:aParserOrNil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8877 |
"parses ST/V function declarations of the forms |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8878 |
'<api: functionName argType1 .. argTypeN returnType>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8879 |
'<ccall: functionName argType1 .. argTypeN returnType>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8880 |
'<ole: vFunctionIndex argType1 .. argTypeN returnType>' |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8881 |
" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8882 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8883 |
|returnType functionName argTypes type |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8884 |
function typeFromSTVTypeSpec virtualFunctionIndex| |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8885 |
|
2038 | 8886 |
masterParser := aParserOrNil. |
8887 |
||
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8888 |
self source:aStream. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8889 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8890 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8891 |
(definitionType = 'ole:') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8892 |
(tokenType == #Integer) ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8893 |
self parseError:'virtual function number expected (got ' , token printString , ')'. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8894 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8895 |
virtualFunctionIndex := token. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8896 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8897 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8898 |
(tokenType == #Identifier) ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8899 |
self parseError:'function identifier expected (got ' , token printString , ')'. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8900 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8901 |
functionName := token asSymbol. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8902 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8903 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8904 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8905 |
argTypes := OrderedCollection new. |
1816 | 8906 |
[ token notNil and:[ (token ~= '>') and:[ (tokenType ~~ #BinaryOperator) or:[tokenName ~= '>']]]] whileTrue:[ |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8907 |
argTypes add:(self typeMappingFor:token). |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8908 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8909 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8910 |
returnType := argTypes last. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8911 |
argTypes := argTypes copyWithoutLast:1. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8912 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8913 |
function := ExternalLibraryFunction |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8914 |
name:(functionName ? virtualFunctionIndex) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8915 |
module:nil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8916 |
returnType:returnType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8917 |
argumentTypes:argTypes asArray. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8918 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8919 |
(definitionType = 'api:') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8920 |
function beCallTypeAPI |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8921 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8922 |
(definitionType = 'ole:') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8923 |
function beCallTypeOLE |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8924 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8925 |
function beCallTypeC |
1782 | 8926 |
]. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8927 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8928 |
^ function |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8929 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8930 |
"Created: / 01-08-2006 / 16:11:24 / cg" |
2038 | 8931 |
"Modified: / 07-06-2007 / 13:13:20 / cg" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8932 |
! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8933 |
|
1937 | 8934 |
parseSTXOrSqueakOrDolphinExternalFunctionDeclarationFrom:aStream definitionType:definitionType lineNr:lineNrArg for: aParserOrNil |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8935 |
"parses squeak/dolphin function declarations of the forms |
1937 | 8936 |
'<stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>' |
8937 |
'<cdecl: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN>' |
|
8938 |
||
8939 |
'<cdecl: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >' |
|
8940 |
'<apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName >' |
|
1820 | 8941 |
" |
8942 |
||
8943 |
|isVirtualCall isNonVirtualCall isAsyncCall isUnlimitedStack isConst scanningCallModifiers |
|
1818 | 8944 |
returnType functionName virtualFunctionIndex argTypes moduleName argType function |
8945 |
parentized thisType| |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8946 |
|
2038 | 8947 |
masterParser := aParserOrNil. |
1820 | 8948 |
isVirtualCall := isNonVirtualCall := isAsyncCall := isUnlimitedStack := isConst := false. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8949 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8950 |
"/ self knownDefinitions:dictionaryOfTypesOrNil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8951 |
self source:aStream. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8952 |
lineNr := lineNrArg. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8953 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8954 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8955 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8956 |
scanningCallModifiers := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8957 |
[scanningCallModifiers] whileTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8958 |
scanningCallModifiers := false. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8959 |
(tokenType == #Identifier) ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8960 |
(token = 'async') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8961 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8962 |
isAsyncCall := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8963 |
scanningCallModifiers := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8964 |
] ifFalse:[ (token = 'virtual') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8965 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8966 |
isVirtualCall := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8967 |
scanningCallModifiers := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8968 |
] ifFalse:[ (token = 'nonVirtual') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8969 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8970 |
isNonVirtualCall := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8971 |
scanningCallModifiers := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8972 |
] ifFalse:[ (token = 'unlimitedStack') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8973 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8974 |
isUnlimitedStack := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8975 |
scanningCallModifiers := true. |
1820 | 8976 |
] ifFalse:[ (token = 'const') ifTrue:[ |
8977 |
self nextToken. |
|
8978 |
isConst := true. |
|
8979 |
scanningCallModifiers := true. |
|
8980 |
]]]]] |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8981 |
] |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8982 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8983 |
|
1818 | 8984 |
returnType := self parseTypeSpec. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8985 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8986 |
isVirtualCall ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8987 |
tokenType ~~ #Integer ifTrue:[ |
2038 | 8988 |
(masterParser ? self) ignorableParseError:'invalid cdecl - virtual function index expected'. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8989 |
^ nil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8990 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8991 |
virtualFunctionIndex := token. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8992 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8993 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8994 |
tokenType ~~ #String ifTrue:[ |
2038 | 8995 |
(masterParser ? self) ignorableParseError:'invalid cdecl - functionName expected'. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8996 |
^ nil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8997 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8998 |
functionName := token asSymbol. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
8999 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9000 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9001 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9002 |
tokenType = $( ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9003 |
parentized := true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9004 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9005 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9006 |
parentized := false. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9007 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9008 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9009 |
argTypes := OrderedCollection new. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9010 |
[ tokenType == #EOF |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9011 |
or:[ parentized and:[tokenType = $) ]] ] whileFalse:[ |
1818 | 9012 |
argType := self parseTypeSpec. |
9013 |
argTypes add:argType. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9014 |
(tokenType = $, |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9015 |
or:[ tokenType == #BinaryOperator and:[token = ','] ]) ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9016 |
self nextToken |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9017 |
] |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9018 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9019 |
tokenType = $) ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9020 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9021 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9022 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9023 |
((tokenType == #Identifier and:[token = 'module']) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9024 |
or:[tokenType == #Keyword and:[ token = 'module:']]) ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9025 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9026 |
tokenType == $: ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9027 |
self nextToken. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9028 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9029 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9030 |
tokenType ~~ #String ifTrue:[ |
2038 | 9031 |
(masterParser ? self) ignorableParseError:'Invalid declaration - moduleName expected'. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9032 |
^ nil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9033 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9034 |
moduleName := token asSymbol. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9035 |
]. |
1816 | 9036 |
(argTypes size == 1 and:[argTypes first == #void "isCVoid"]) ifTrue:[ |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9037 |
argTypes := #() |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9038 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9039 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9040 |
isNonVirtualCall ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9041 |
(classToCompileFor isSubclassOf:ExternalStructure) ifTrue:[ |
1816 | 9042 |
thisType := classToCompileFor name. |
9043 |
"/ (thisType := classToCompileFor cType) isNil ifTrue:[ |
|
9044 |
"/ "/ self warning:'missing CType definition in ' , tok printString. |
|
9045 |
"/ thisType := CType newStructType. |
|
9046 |
"/ thisType name:(classToCompileFor nameWithoutPrefix). |
|
9047 |
"/ thisType := CType pointerTypeClass new baseType:thisType. |
|
9048 |
"/ ]. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9049 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9050 |
thisType := thisType ? #pointer. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9051 |
argTypes := (Array with:thisType) , argTypes. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9052 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9053 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9054 |
function := ExternalLibraryFunction |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9055 |
name:(functionName ? virtualFunctionIndex) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9056 |
module:moduleName |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9057 |
returnType:returnType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9058 |
argumentTypes:argTypes asArray. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9059 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9060 |
(definitionType = 'apicall:') ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9061 |
function beCallTypeAPI |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9062 |
] ifFalse:[ |
1782 | 9063 |
(definitionType = 'olecall:') ifTrue:[ |
9064 |
function beCallTypeOLE |
|
9065 |
] ifFalse:[ |
|
9066 |
function beCallTypeC |
|
9067 |
]. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9068 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9069 |
isNonVirtualCall ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9070 |
function beNonVirtualCPP |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9071 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9072 |
isAsyncCall ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9073 |
function beAsync |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9074 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9075 |
isUnlimitedStack ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9076 |
function beUnlimitedStack |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9077 |
]. |
1820 | 9078 |
isConst ifTrue:[ |
9079 |
function beConstReturnValue |
|
9080 |
]. |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9081 |
^ function |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9082 |
|
1937 | 9083 |
"Created: / 25-10-2006 / 12:03:59 / cg" |
2038 | 9084 |
"Modified: / 07-06-2007 / 13:13:35 / cg" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9085 |
! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9086 |
|
1818 | 9087 |
parseTypeSpec |
9088 |
|type typeName ns cls| |
|
9089 |
||
9090 |
typeName := token. |
|
9091 |
self nextToken. |
|
9092 |
||
9093 |
((tokenType == #'::') or:[(tokenType == #'.')]) ifTrue:[ |
|
9094 |
"/ namespace... |
|
9095 |
[(tokenType == #'::') or:[(tokenType == #'.')]] whileTrue:[ |
|
9096 |
typeName := typeName , '::'. |
|
9097 |
self nextToken. |
|
9098 |
tokenType ~~ #Identifier ifTrue:[ |
|
2038 | 9099 |
(masterParser ? self) parseError:'invalid type identifier'. |
1818 | 9100 |
]. |
9101 |
typeName := typeName , token. |
|
9102 |
self nextToken. |
|
9103 |
] |
|
9104 |
]. |
|
9105 |
||
9106 |
type := self typeMappingFor:typeName. |
|
2039 | 9107 |
[(tokenType = $*) |
9108 |
or:[((tokenType == #BinaryOperator) and:[tokenName = '*']) |
|
9109 |
or:[(tokenType == #BinaryOperator) and:[tokenName = '**']]] |
|
9110 |
] whileTrue:[ |
|
1818 | 9111 |
type := self pointerTypeMappingFor:type. |
2039 | 9112 |
tokenName = '**' ifTrue:[ |
9113 |
type := self pointerTypeMappingFor:type. |
|
9114 |
]. |
|
1818 | 9115 |
self nextToken. |
9116 |
]. |
|
9117 |
||
9118 |
type first isUppercase ifTrue:[ |
|
9119 |
(ns := classToCompileFor nameSpace) notNil ifTrue:[ |
|
9120 |
cls := ns at:type. |
|
9121 |
]. |
|
9122 |
cls isNil ifTrue:[ |
|
9123 |
cls := Smalltalk at:type. |
|
9124 |
]. |
|
1819 | 9125 |
cls isNil ifTrue:[ |
2038 | 9126 |
(masterParser ? self) ignorableParseError:'possibly unknown type: ', type allBold. |
1819 | 9127 |
] ifFalse:[ |
9128 |
cls autoload. |
|
9129 |
(cls isSubclassOf:ExternalBytes) ifFalse:[ |
|
2038 | 9130 |
(masterParser ? self) ignorableParseError:'possibly wrong type: ', type allBold. |
1819 | 9131 |
]. |
1818 | 9132 |
type := cls name. |
9133 |
]. |
|
9134 |
]. |
|
9135 |
||
9136 |
^ type |
|
2038 | 9137 |
|
9138 |
"Modified: / 07-06-2007 / 13:14:59 / cg" |
|
9139 |
! |
|
9140 |
||
9141 |
parseVWTypeOrExternalFunctionDeclarationFrom:aStream definitionType:definitionType knownDefinitions:dictionaryOfTypesOrNil lineNr:lineNr for:aParserOrNil |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9142 |
"parses visualWorks type/function declarations of the form: |
2051 | 9143 |
'<c: ...>' |
9144 |
'<c: #define NAME value>'" |
|
9145 |
||
9146 |
|cParser moduleName type name |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9147 |
nameAndFunctionOrType functionOrType function | |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9148 |
|
2038 | 9149 |
masterParser := aParserOrNil. |
9150 |
||
2051 | 9151 |
self source:aStream. |
9152 |
self nextToken. |
|
9153 |
((tokenType == #Symbol) and:[token = #define]) ifTrue:[ |
|
9154 |
self nextToken. |
|
9155 |
(tokenType == #Identifier) ifFalse:[ |
|
9156 |
(masterParser ? self) ignorableParseError:'invalid cdecl - identifier expected'. |
|
9157 |
self generateTrapCodeForUnavailableCParser. |
|
9158 |
^ nil. |
|
9159 |
]. |
|
9160 |
name := token. |
|
9161 |
self nextToken. |
|
9162 |
"/ for now, only allow integer, string or floats. |
|
9163 |
(#(Integer String Float) includes:tokenType) ifTrue:[ |
|
9164 |
^ token |
|
9165 |
]. |
|
9166 |
(masterParser ? self) ignorableParseError:'invalid cdecl - integer, float or string expected'. |
|
9167 |
self generateTrapCodeForUnavailableCParser. |
|
9168 |
^ nil. |
|
9169 |
]. |
|
9170 |
||
9171 |
aStream reset. |
|
9172 |
||
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9173 |
CParser isNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9174 |
self generateTrapCodeForUnavailableCParser. |
2005 | 9175 |
^ nil. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9176 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9177 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9178 |
cParser := CParser new. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9179 |
cParser knownDefinitions:dictionaryOfTypesOrNil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9180 |
cParser allowRedefinitions:true. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9181 |
cParser source:aStream scannerClass:CDeclScanner. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9182 |
cParser nextToken. |
2052 | 9183 |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9184 |
cParser tokenType == #struct ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9185 |
type := cParser type. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9186 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9187 |
cParser tokenType == #typedef ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9188 |
type := cParser typedef. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9189 |
] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9190 |
nameAndFunctionOrType := cParser typeOrFunctionDeclaration. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9191 |
functionOrType := nameAndFunctionOrType second. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9192 |
functionOrType isCFunction ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9193 |
type := functionOrType. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9194 |
function := nil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9195 |
] ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9196 |
function := functionOrType. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9197 |
type := nil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9198 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9199 |
] |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9200 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9201 |
cParser token notNil ifTrue:[ |
2038 | 9202 |
(masterParser ? self) ignorableParseError:'invalid cdecl - nothing more expected'. |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9203 |
^ nil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9204 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9205 |
type notNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9206 |
^ type. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9207 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9208 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9209 |
moduleName isNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9210 |
moduleName := classToCompileFor theNonMetaclass libraryName asSymbol. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9211 |
]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9212 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9213 |
function := ExternalLibraryFunction |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9214 |
name:function name |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9215 |
module:moduleName |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9216 |
returnType:function returnType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9217 |
argumentTypes:function argumentTypes asArray. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9218 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9219 |
function beCallTypeC. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9220 |
^ function |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9221 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9222 |
"Created: / 01-08-2006 / 16:18:05 / cg" |
2038 | 9223 |
"Modified: / 07-06-2007 / 13:14:06 / cg" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9224 |
! ! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9225 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9226 |
!Parser::PrimitiveSpecParser methodsFor:'parsing-primitives & pragmas'! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9227 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9228 |
pointerTypeMappingFor: aTypeSymbol |
2039 | 9229 |
"given a type, make it a 'pointer to that-type'" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9230 |
|e| |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9231 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9232 |
e := #( |
2038 | 9233 |
(void voidPointer ) |
2039 | 9234 |
(voidPointer voidPointerPointer ) |
9235 |
(voidPointerPointer voidPointerPointer ) |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9236 |
(char charPointer ) |
2038 | 9237 |
(byte bytePointer ) |
2039 | 9238 |
(uint8 uint8Pointer ) |
9239 |
(uint16 uint16Pointer ) |
|
9240 |
(uint32 uint32Pointer ) |
|
9241 |
(int16 int16Pointer ) |
|
9242 |
(int32 int32Pointer ) |
|
9243 |
(int intPointer ) |
|
9244 |
(short shortPointer ) |
|
9245 |
(ushort ushortPointer ) |
|
9246 |
(long longPointer ) |
|
9247 |
(uint uintPointer ) |
|
9248 |
(ulong ulongPointer ) |
|
2038 | 9249 |
(float floatPointer ) |
9250 |
(double doublePointer ) |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9251 |
) detect:[:p | p first = aTypeSymbol] ifNone:nil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9252 |
e notNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9253 |
^ e second |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9254 |
]. |
2038 | 9255 |
(masterParser ? self) ignorableParseError:'missing pointer type mapping for type: ', aTypeSymbol allBold. |
9256 |
^ #pointer "/ aTypeSymbol asSymbol |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9257 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9258 |
"Created: / 01-08-2006 / 15:33:53 / cg" |
2038 | 9259 |
"Modified: / 11-06-2007 / 01:51:26 / cg" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9260 |
! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9261 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9262 |
typeMappingFor:aTypeSymbol |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9263 |
|e| |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9264 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9265 |
e := #( |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9266 |
(short int16 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9267 |
(long int32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9268 |
(int int32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9269 |
(ushort uint16 ) |
2040 | 9270 |
(ulong uint32 ) |
9271 |
(unsignedByte uint8 ) |
|
9272 |
(unsignedChar uint8 ) |
|
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9273 |
(unsignedShort uint16 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9274 |
(unsignedLong uint32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9275 |
(double double ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9276 |
(float float ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9277 |
(char char ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9278 |
(uchar uint8 ) |
2040 | 9279 |
(byte uint8 ) |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9280 |
(void void ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9281 |
(bool bool ) |
2040 | 9282 |
(boolean bool ) |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9283 |
(dword uint32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9284 |
(sdword int32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9285 |
(word uint16 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9286 |
(sword int16 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9287 |
(handle voidPointer ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9288 |
(lpstr charPointer ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9289 |
(hresult uint32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9290 |
(ulongReturn uint32 ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9291 |
(none void ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9292 |
(struct voidPointer ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9293 |
(structIn voidPointer ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9294 |
(structOut voidPointer ) |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9295 |
) detect:[:p | p first = aTypeSymbol] ifNone:nil. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9296 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9297 |
e notNil ifTrue:[ ^ e second ]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9298 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9299 |
"/ the following is now done in ExternalFunction (if at all), as the ctype is not required to |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9300 |
"/ be present right now, and also to allow for stc-compilation, where no |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9301 |
"/ ctypes are avaliable at all. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9302 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9303 |
"/ e isNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9304 |
"/ cls := classToCompileFor nameSpace classNamed:tok. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9305 |
"/ cls isNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9306 |
"/ cls := Smalltalk classNamed:tok. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9307 |
"/ ]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9308 |
"/ cls notNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9309 |
"/ (cls isSubclassOf:ExternalStructure) ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9310 |
"/ (cType := cls cType) isNil ifTrue:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9311 |
"/ "/ self warning:'missing CType definition in ' , tok printString. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9312 |
"/ cType := CType newStructType. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9313 |
"/ cType name:cls name. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9314 |
"/ ]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9315 |
"/ cType |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9316 |
"/ ] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9317 |
"/ cls |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9318 |
"/ ]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9319 |
"/ ] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9320 |
"/ self parseError:'ulong, ushort, or another valid Squeak type identifier expected (got ' , tok printString , ')'. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9321 |
"/ nil |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9322 |
"/ ] |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9323 |
"/ ] ifFalse:[ |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9324 |
"/ e second |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9325 |
"/ ]. |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9326 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9327 |
^ aTypeSymbol asSymbol |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9328 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9329 |
"Created: / 01-08-2006 / 15:35:52 / cg" |
2040 | 9330 |
"Modified: / 14-06-2007 / 17:18:54 / cg" |
1780
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9331 |
! ! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9332 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9333 |
!Parser::PrimitiveSpecParser methodsFor:'reading next token'! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9334 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9335 |
isCommentCharacter:ch |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9336 |
"no comments" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9337 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9338 |
^ false |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9339 |
|
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9340 |
"Created: / 01-08-2006 / 14:54:48 / cg" |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9341 |
! ! |
572da5701f89
rewrite & cleanup of primitive parsing code
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
9342 |
|
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9343 |
!Parser::UndefinedVariableNotification methodsFor:'accessing'! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9344 |
|
1514 | 9345 |
description |
1516 | 9346 |
^ 'undefined variable: ' , self variableName |
1514 | 9347 |
! |
9348 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9349 |
parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9350 |
"return the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9351 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9352 |
^ parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9353 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9354 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9355 |
parser:something |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9356 |
"set the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9357 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9358 |
parser := something. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9359 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9360 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9361 |
variableName |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9362 |
^ parameter |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9363 |
! ! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
9364 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
9365 |
!Parser class methodsFor:'documentation'! |
148 | 9366 |
|
9367 |
version |
|
2109 | 9368 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.577 2008-10-07 11:50:02 cg Exp $' |
148 | 9369 |
! ! |
1322
da25e31f423c
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
9370 |
|
141 | 9371 |
Parser initialize! |