author | Claus Gittinger <cg@exept.de> |
Thu, 26 Oct 2000 16:26:02 +0200 | |
changeset 1103 | b75a71996388 |
parent 1100 | 2a5a68297030 |
child 1109 | ff6766ac4388 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
44 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1043 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
0 | 15 |
Scanner subclass:#Parser |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
instanceVariableNames:'classToCompileFor selfValue contextToEvaluateIn selector |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
17 |
methodArgs methodArgNames methodVars methodVarNames tree |
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
18 |
currentBlock parseForCode readInstVars readClassVars readGlobals |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
19 |
usedInstVars usedClassVars usedVars modifiedInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
20 |
modifiedClassVars modifiedGlobals usesSuper usedGlobals |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
21 |
usedSymbols messagesSent messagesSentToSelf messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
22 |
localVarDefPosition evalExitBlock selfNode superNode nilNode |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
23 |
hasPrimitiveCode hasNonOptionalPrimitiveCode primitiveNr |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
24 |
primitiveResource logged warnedUndefVars warnedUnknownNamespaces |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
25 |
warnSTXHereExtensionUsed correctedSource foldConstants |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
26 |
lineNumberInfo currentNamespace currentUsedNamespaces |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
27 |
warnUndeclared methodNode alreadyWarnedClassInstVarRefs |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
28 |
localBlockVarDefPosition endOfSelectorPosition |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
29 |
startOfBlockPosition primitiveContextInfo usedLocalVars |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
30 |
modifiedLocalVars alreadyWarnedUninitializedVars' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
31 |
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
32 |
PrevClassInstVarNames LazyCompilation ArraysAreImmutable |
601 | 33 |
ImplicitSelfSends WarnST80Directives FoldConstants LineNumberInfo |
1062 | 34 |
SuppressDoItCompilation StringsAreImmutable ParseErrorSignal' |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
35 |
poolDictionaries:'' |
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
36 |
category:'System-Compiler' |
0 | 37 |
! |
38 |
||
971 | 39 |
Exception subclass:#ParseError |
40 |
instanceVariableNames:'' |
|
41 |
classVariableNames:'' |
|
42 |
poolDictionaries:'' |
|
43 |
privateIn:Parser |
|
44 |
! |
|
45 |
||
46 |
Parser::ParseError subclass:#UndefinedSuperclassError |
|
47 |
instanceVariableNames:'' |
|
48 |
classVariableNames:'' |
|
49 |
poolDictionaries:'' |
|
50 |
privateIn:Parser |
|
51 |
! |
|
52 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
53 |
!Parser class methodsFor:'documentation'! |
19 | 54 |
|
20 | 55 |
copyright |
56 |
" |
|
57 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
44 | 58 |
All Rights Reserved |
20 | 59 |
|
60 |
This software is furnished under a license and may be used |
|
61 |
only in accordance with the terms of that license and with the |
|
62 |
inclusion of the above copyright notice. This software may not |
|
63 |
be provided or otherwise made available to, or used by, any |
|
64 |
other person. No title to or ownership of the software is |
|
65 |
hereby transferred. |
|
66 |
" |
|
67 |
! |
|
68 |
||
19 | 69 |
documentation |
70 |
" |
|
71 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
72 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
73 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
74 |
the (planned) MachineCodeCompiler. |
|
75 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
76 |
methods of main interest are: |
755 | 77 |
Parser evaluateExpression:... |
19 | 78 |
|
79 |
and: |
|
755 | 80 |
Parser parseExpression:... |
81 |
Parser parseMethod:... |
|
19 | 82 |
|
83 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
84 |
||
85 |
Parser is also used to find the referenced/modified inst/classvars of |
|
86 |
a method - this is done by sending parseXXX message to a parser and asking |
|
87 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
88 |
||
89 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
90 |
example analyzes the expressions in the changelist ...) by looking at the |
|
91 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 92 |
compilers internals ... better style is to add specialized query methods here) |
19 | 93 |
|
94 |
One instance of Parser is created to parse one method or expression - i.e. |
|
95 |
its not suggested to reuse parsers. |
|
96 |
||
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
97 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
98 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
99 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
100 |
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
|
101 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
102 |
(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
|
103 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 110 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
111 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
112 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
113 |
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
|
114 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
115 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
116 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
117 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
118 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
123 |
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
|
124 |
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
|
125 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
129 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
130 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
131 |
|
260 | 132 |
[Instance variables:] |
133 |
||
755 | 134 |
classToCompileFor <Class> the class (or nil) we are compiling for |
135 |
||
136 |
selfValue <any> value to use as self when interpreting |
|
137 |
||
138 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
139 |
||
140 |
selector <Symbol> the selector of the parsed method |
|
141 |
(valid after parseMethodSpecification) |
|
142 |
methodArgs internal |
|
143 |
||
144 |
methodArgNames <Collection> the names of the arguments |
|
145 |
(valid after parseMethodSpecification) |
|
146 |
||
147 |
methodVars internal |
|
148 |
||
149 |
methodVarNames <Collection> the names of the method locals |
|
150 |
(valid after parseMethodBodyVarSpec) |
|
151 |
||
152 |
tree <ParseTree> the parse tree - valid after parsing |
|
153 |
||
154 |
currentBlock if currently parsing for a block |
|
155 |
||
156 |
usedInstVars set of all accessed instances variables |
|
157 |
(valid after parsing) |
|
158 |
||
159 |
usedClassVars same for classVars |
|
160 |
||
161 |
usedVars all used variables (inst, class & globals) |
|
162 |
||
163 |
modifiedInstVars set of all modified instance variables |
|
164 |
||
165 |
modifiedClassVars same for clasVars |
|
166 |
||
167 |
localVarDefPosition <Integer> the character offset of the local variable |
|
168 |
def. (i.e. the first '|' if any) |
|
169 |
Not yet used - prepared for automatic add of |
|
170 |
undefined variables |
|
171 |
||
172 |
evalExitBlock internal for interpretation |
|
173 |
||
174 |
selfNode <Node> cached one-and-only 'self' node |
|
175 |
superNode <Node> cached one-and-only 'super' node |
|
176 |
||
177 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
178 |
hasNonOptionalPrimitiveCode |
|
179 |
<Boolean> true, if it contains ST/X style primitive code |
|
180 |
which is NOT flagged by the OPTIONAL directive. |
|
181 |
||
182 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
183 |
||
184 |
logged |
|
185 |
||
186 |
warnedUndefVars <Set> set of all variables which the parser has |
|
187 |
already output a warning (to avoid multiple |
|
188 |
warnings about the same variable) |
|
260 | 189 |
|
190 |
[Class variables:] |
|
191 |
||
755 | 192 |
PrevClass <Class> class, of which properties are |
193 |
cached in: |
|
194 |
||
195 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
196 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
197 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
198 |
||
199 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
200 |
||
201 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
202 |
as instances of ImmutableArray, |
|
203 |
which cannot be stored into. |
|
204 |
Default is false, for compatibility. |
|
205 |
Can be turned on while developping |
|
206 |
new code to make certain that side |
|
207 |
effects are avoided. |
|
208 |
||
209 |
WarnST80Directives <Boolean> if true, give warnings about |
|
210 |
ST-80 directives (resource defs) |
|
211 |
which are ignored in st/x. |
|
212 |
defaults to false. |
|
213 |
||
214 |
FoldConstants <Symbol> controls how constant folding should be |
|
215 |
done. |
|
216 |
Can be one of: |
|
217 |
nil - no constant folding |
|
218 |
#level1 - numeric optimizations only |
|
219 |
#level2 - secure optimizations only |
|
220 |
#full - full folding |
|
221 |
||
222 |
level1: arithmetic on constant numbers |
|
223 |
||
224 |
level2: above PLUS array conversions with #asFloatArray, |
|
225 |
#asDoubleArray, string concatenation |
|
226 |
||
227 |
full: constant points. |
|
260 | 228 |
|
229 |
[see also:] |
|
755 | 230 |
ByteCodeCompiler Scanner ObjectFileLoader |
231 |
Workspace |
|
232 |
SystemBrowser |
|
263 | 233 |
|
234 |
[author:] |
|
755 | 235 |
Claus Gittinger |
19 | 236 |
" |
141 | 237 |
! ! |
238 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
239 |
!Parser class methodsFor:'instance creation'! |
141 | 240 |
|
241 |
for:aStringOrStream in:aClass |
|
242 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
243 |
||
244 |
|parser| |
|
245 |
||
246 |
parser := self for:aStringOrStream. |
|
247 |
parser setClassToCompileFor:aClass. |
|
248 |
^ parser |
|
249 |
! ! |
|
250 |
||
1020 | 251 |
!Parser class methodsFor:'Compatibility - ST80'! |
540 | 252 |
|
253 |
parse:aString class:aClass |
|
254 |
"same as #parseMethod:in: for ST80 compatibility." |
|
255 |
||
256 |
|parser| |
|
257 |
||
258 |
parser := self parseMethod:aString in:aClass. |
|
259 |
parser notNil ifTrue:[^ parser tree]. |
|
260 |
^ nil |
|
261 |
||
262 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
263 |
! ! |
|
264 |
||
920 | 265 |
!Parser class methodsFor:'Compatibility - Squeak'! |
266 |
||
267 |
evaluate:someString for:aReceiver logged:logged |
|
268 |
^ self evaluate:someString receiver:aReceiver logged:logged |
|
269 |
||
270 |
||
271 |
||
272 |
! ! |
|
273 |
||
1062 | 274 |
!Parser class methodsFor:'Signal constants'! |
275 |
||
276 |
parseErrorSignal |
|
277 |
^ ParseErrorSignal |
|
278 |
! ! |
|
279 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
280 |
!Parser class methodsFor:'changes'! |
141 | 281 |
|
282 |
flushNameCache |
|
283 |
"unconditional flush name caches" |
|
284 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
285 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
286 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
287 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
288 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
289 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
290 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
291 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
292 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
293 |
] valueUninterruptably |
141 | 294 |
|
295 |
"Parser flushNameCache" |
|
296 |
! |
|
297 |
||
298 |
update:something with:someArgument from:changedObject |
|
299 |
"aClass has changed its definition - flush name caches if we have to" |
|
300 |
||
301 |
(changedObject == PrevClass) ifTrue:[ |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
302 |
something == #definition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
303 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
304 |
] |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
305 |
]. |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
306 |
(changedObject == Smalltalk) ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
307 |
something == #classDefinition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
308 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
309 |
] |
141 | 310 |
] |
311 |
! ! |
|
312 |
||
717 | 313 |
!Parser class methodsFor:'class initialization'! |
314 |
||
315 |
initialize |
|
316 |
LazyCompilation := false. "/ usually set to true in your .rc file |
|
752 | 317 |
ArraysAreImmutable := false. "/ usually left false for ST-80 compatibility |
318 |
StringsAreImmutable := false. "/ usually left false for ST-80 compatibility |
|
319 |
||
717 | 320 |
ImplicitSelfSends := false. |
321 |
WarnST80Directives := false. |
|
322 |
FoldConstants := #level1. |
|
323 |
LineNumberInfo := false. |
|
324 |
||
1062 | 325 |
ParseErrorSignal isNil ifTrue:[ |
326 |
ParseErrorSignal := Signal new mayProceed:true. |
|
327 |
ParseErrorSignal notifierString:'parse error'. |
|
328 |
ParseErrorSignal nameClass:self message:#parseErrorSignal. |
|
329 |
]. |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
330 |
Smalltalk addDependent:self. |
1062 | 331 |
|
717 | 332 |
" |
333 |
self initialize |
|
334 |
" |
|
335 |
||
752 | 336 |
"Modified: / 3.8.1998 / 14:53:47 / cg" |
717 | 337 |
! ! |
338 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
339 |
!Parser class methodsFor:'controlling compilation'! |
141 | 340 |
|
341 |
arraysAreImmutable |
|
342 |
"return true if arrays are immutable literals" |
|
343 |
||
344 |
^ ArraysAreImmutable |
|
345 |
! |
|
346 |
||
347 |
arraysAreImmutable:aBoolean |
|
348 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
349 |
||
350 |
ArraysAreImmutable := aBoolean. |
|
351 |
||
352 |
" |
|
353 |
can be added to your private.rc file: |
|
354 |
||
355 |
Compiler arraysAreImmutable:true |
|
356 |
Compiler arraysAreImmutable:false |
|
357 |
" |
|
358 |
! |
|
359 |
||
360 |
compileLazy |
|
361 |
"return true if compiling lazy" |
|
362 |
||
363 |
^ LazyCompilation. |
|
364 |
! |
|
365 |
||
366 |
compileLazy:aBoolean |
|
367 |
"turn on/off lazy compilation - return previous setting. |
|
368 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
369 |
but it also controls the reporting of some errors here; therefore |
|
370 |
its located here" |
|
371 |
||
372 |
|oldLazy| |
|
373 |
||
374 |
oldLazy := LazyCompilation. |
|
375 |
LazyCompilation := aBoolean. |
|
376 |
^ oldLazy |
|
377 |
||
378 |
" |
|
379 |
usually set in your .rc file |
|
380 |
||
381 |
Compiler compileLazy:false |
|
382 |
Compiler compileLazy:true |
|
383 |
" |
|
384 |
! |
|
385 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
386 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
387 |
"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
|
388 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
389 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
390 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
391 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
392 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
393 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
394 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
395 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
396 |
It can be: |
619 | 397 |
nil - no constant folding |
398 |
#level1 - numeric constants only |
|
399 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
400 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
401 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
402 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
403 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
404 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
405 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
406 |
|
141 | 407 |
implicitSelfSends |
408 |
"return true if undefined variables with |
|
409 |
lowercase first character are to be turned |
|
410 |
into implicit self sends" |
|
411 |
||
412 |
^ ImplicitSelfSends |
|
413 |
! |
|
414 |
||
415 |
implicitSelfSends:aBoolean |
|
416 |
"turn on/off implicit self sends" |
|
417 |
||
418 |
ImplicitSelfSends := aBoolean |
|
419 |
||
420 |
" |
|
421 |
Compiler implicitSelfSends:true |
|
422 |
Compiler implicitSelfSends:false |
|
423 |
" |
|
377 | 424 |
! |
425 |
||
426 |
lineNumberInfo |
|
427 |
^ LineNumberInfo |
|
428 |
! |
|
429 |
||
430 |
lineNumberInfo:aBoolean |
|
431 |
LineNumberInfo := aBoolean |
|
752 | 432 |
! |
433 |
||
434 |
stringsAreImmutable |
|
435 |
"return true if strings are immutable literals" |
|
436 |
||
437 |
^ StringsAreImmutable |
|
438 |
||
439 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
440 |
! |
|
441 |
||
442 |
stringsAreImmutable:aBoolean |
|
443 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
444 |
||
445 |
StringsAreImmutable := aBoolean. |
|
446 |
||
447 |
" |
|
448 |
can be added to your private.rc file: |
|
449 |
||
450 |
Compiler stringsAreImmutable:true |
|
451 |
Compiler stringsAreImmutable:false |
|
452 |
" |
|
453 |
||
454 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
19 | 455 |
! ! |
0 | 456 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
457 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
458 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
459 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
460 |
"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
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
465 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
466 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
467 |
"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
|
468 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
469 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
470 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 471 |
|
19 | 472 |
evaluate:aStringOrStream |
71 | 473 |
"return the result of evaluating an expression in aStringOrStream. |
474 |
No doit-entry is added to the changeLog." |
|
0 | 475 |
|
19 | 476 |
^ self |
44 | 477 |
evaluate:aStringOrStream |
478 |
in:nil |
|
479 |
receiver:nil |
|
480 |
notifying:nil |
|
481 |
logged:false |
|
482 |
ifFail:nil |
|
71 | 483 |
compile:true |
19 | 484 |
|
485 |
" |
|
486 |
Compiler evaluate:'1 + 2' |
|
487 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
488 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
489 |
" |
|
0 | 490 |
! |
491 |
||
71 | 492 |
evaluate:aStringOrStream compile:compile |
493 |
"return the result of evaluating aString, |
|
494 |
The compile argument specifies if the string should be compiled down to |
|
495 |
bytecode or instead be interpreted from the parseTree. |
|
496 |
The first should be done for doIts etc, where a readable walkback is |
|
497 |
required. |
|
498 |
The latter is better done for constants, styleSheet and resource |
|
499 |
reading and simple sends, where the overhead of compilation is bigger |
|
500 |
than the interpretation overhead." |
|
501 |
||
502 |
^ self |
|
503 |
evaluate:aStringOrStream |
|
504 |
in:nil |
|
505 |
receiver:nil |
|
506 |
notifying:nil |
|
507 |
logged:false |
|
508 |
ifFail:nil |
|
509 |
compile:compile |
|
510 |
! |
|
511 |
||
20 | 512 |
evaluate:aStringOrStream ifFail:failBlock |
513 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 514 |
In case of any syntax errors, return the value of failBlock. |
515 |
No doit-entry is added to the changeLog." |
|
20 | 516 |
|
517 |
^ self |
|
44 | 518 |
evaluate:aStringOrStream |
519 |
in:nil |
|
520 |
receiver:nil |
|
521 |
notifying:nil |
|
522 |
logged:false |
|
523 |
ifFail:failBlock |
|
71 | 524 |
compile:true |
20 | 525 |
" |
526 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
527 |
" |
|
528 |
! |
|
529 |
||
71 | 530 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
531 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
532 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
533 |
No doIt entry is added to the change-file. |
|
534 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
535 |
||
536 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
537 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
538 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
539 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
540 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
541 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
542 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
543 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
544 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
545 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 546 |
! |
547 |
||
548 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
549 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
550 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
551 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
552 |
is non-nil, it is evaluated if an error occurs." |
|
553 |
||
71 | 554 |
^ self |
555 |
evaluate:aStringOrStream |
|
556 |
in:aContext |
|
557 |
receiver:anObject |
|
558 |
notifying:requestor |
|
559 |
logged:logged |
|
560 |
ifFail:failBlock |
|
561 |
compile:true |
|
562 |
! |
|
563 |
||
564 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
565 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
566 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
567 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
568 |
is non-nil, it is evaluated if an error occurs. |
|
569 |
Finally, compile specifies if the string should be compiled down to |
|
570 |
bytecode or instead be interpreted from the parseTree. |
|
571 |
The first should be done for doIts etc, where a readable walkback is |
|
572 |
required. |
|
573 |
The latter is better done for constants, styleSheet and resource |
|
574 |
reading and simple sends, where the overhead of compilation is bigger |
|
575 |
than the interpretation overhead." |
|
576 |
||
1087 | 577 |
|parser tree mustBackup loggedString chgStream value s sReal spc cls| |
0 | 578 |
|
619 | 579 |
aStringOrStream isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
580 |
EmptySourceNotificationSignal raiseRequest. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
581 |
^ nil |
619 | 582 |
]. |
493
77e0d6979865
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
492
diff
changeset
|
583 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
584 |
s := aStringOrStream. |
0 | 585 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
586 |
loggedString := aStringOrStream. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
587 |
s := ReadStream on:aStringOrStream. |
0 | 588 |
]. |
260 | 589 |
parser := self for:s. |
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
590 |
parser parseForCode. |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
591 |
parser foldConstants:nil. |
0 | 592 |
parser setSelf:anObject. |
593 |
parser setContext:aContext. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
594 |
aContext notNil ifTrue:[ |
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
595 |
parser setSelf:(aContext receiver). |
1087 | 596 |
aContext method notNil ifTrue:[ |
597 |
cls := aContext method mclass |
|
598 |
]. |
|
599 |
parser setClassToCompileFor:(cls ? aContext receiver class). |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
600 |
]. |
0 | 601 |
parser notifying:requestor. |
602 |
parser nextToken. |
|
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
603 |
parser evalExitBlock:[:value | parser release. ^ value]. |
79 | 604 |
tree := parser parseMethodBodyOrEmpty. |
0 | 605 |
|
606 |
"if reading from a stream, backup for next expression" |
|
607 |
mustBackup ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
608 |
parser backupPosition |
0 | 609 |
]. |
610 |
||
611 |
(parser errorFlag or:[tree == #Error]) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
612 |
failBlock notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
613 |
^ failBlock value |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
614 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
615 |
^ #Error |
619 | 616 |
]. |
617 |
||
618 |
tree isNil ifTrue:[ |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
619 |
EmptySourceNotificationSignal raiseRequest. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
620 |
^ nil |
619 | 621 |
]. |
622 |
||
623 |
(logged |
|
624 |
and:[loggedString notNil |
|
625 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
626 |
Class updateChangeFileQuerySignal query ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
627 |
chgStream := Class changesStream. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
628 |
chgStream notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
629 |
chgStream nextChunkPut:loggedString. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
630 |
chgStream cr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
631 |
chgStream close |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
632 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
633 |
]. |
619 | 634 |
]. |
635 |
||
636 |
" |
|
637 |
during the evaluation, handle nameSpace queries |
|
638 |
from the value as defined by any namespace directive. |
|
639 |
This, if its a class definition expression, the class will |
|
640 |
be installed there. |
|
641 |
" |
|
642 |
spc := parser getNameSpace. |
|
643 |
spc isNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
644 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
645 |
spc := requestor currentNameSpace |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
646 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
647 |
spc := Class nameSpaceQuerySignal query. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
648 |
] |
0 | 649 |
]. |
260 | 650 |
|
619 | 651 |
Class nameSpaceQuerySignal answer:spc |
652 |
do:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
653 |
|method| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
654 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
655 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
656 |
if compile is false, or the parse tree is that of a constant, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
657 |
or a variable, quickly return its value. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
658 |
This is used for example, when reading simple objects |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
659 |
via #readFrom:. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
660 |
The overhead of compiling a method is avoided in this case. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
661 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
662 |
((SuppressDoItCompilation == true) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
663 |
or:[compile not |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
664 |
or:[tree isConstant |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
665 |
or:[tree isVariable |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
666 |
or:[aStringOrStream isStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
667 |
or:[aContext notNil]]]]]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
668 |
^ tree evaluate |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
669 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
670 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
671 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
672 |
if I am the ByteCodeCompiler, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
673 |
generate a dummy method, execute it and return the value. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
674 |
otherwise, just evaluate the tree; slower, but not too bad ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
675 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
676 |
This allows systems to be delivered without the ByteCodeCompiler, |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
677 |
and still evaluate expressions |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
678 |
(needed to read resource files or to process .rc files). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
679 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
680 |
self == Parser ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
681 |
parser evalExitBlock:[:value | parser release. ^ value]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
682 |
value := tree evaluate. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
683 |
parser evalExitBlock:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
684 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
685 |
aStringOrStream isStream ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
686 |
s := parser collectedSource. "/ does not work yet ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
687 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
688 |
s := aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
689 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
690 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
691 |
"/ actually, its a block, to allow |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
692 |
"/ easy return ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
693 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
694 |
sReal := 'doIt ^[\' withCRs , s , '\] value' withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
695 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
696 |
method := self |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
697 |
compile:sReal |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
698 |
forClass:anObject class |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
699 |
inCategory:'_temporary_' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
700 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
701 |
install:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
702 |
skipIfSame:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
703 |
silent:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
704 |
foldConstants:false. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
705 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
706 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
707 |
method ~~ #Error ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
708 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
709 |
fake: patch the source string, to what the user expects |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
710 |
in the browser |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
711 |
" |
688
4079c5dd2dca
doIt method should have no emphasis
Claus Gittinger <cg@exept.de>
parents:
687
diff
changeset
|
712 |
method source:' \' withCRs , s string. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
713 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
714 |
dont do any just-in-time compilation on it. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
715 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
716 |
method checked:true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
717 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
718 |
value := method |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
719 |
valueWithReceiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
720 |
arguments:nil "/ (Array with:m) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
721 |
selector:#doIt "/ #doIt: |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
722 |
search:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
723 |
sender:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
724 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
725 |
parser evalExitBlock:[:value | parser release. ^ value]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
726 |
value := tree evaluate. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
727 |
parser evalExitBlock:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
728 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
729 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
730 |
] |
0 | 731 |
]. |
35 | 732 |
parser release. |
733 |
^ value |
|
260 | 734 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
735 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
736 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
737 |
"Modified: / 6.2.2000 / 15:01:57 / cg" |
141 | 738 |
! |
739 |
||
740 |
evaluate:aStringOrStream logged:logged |
|
741 |
"return the result of evaluating an expression in aStringOrStream. |
|
742 |
The argument log controls if an entry is added to the changeLog." |
|
743 |
||
744 |
^ self |
|
745 |
evaluate:aStringOrStream |
|
746 |
in:nil |
|
747 |
receiver:nil |
|
748 |
notifying:nil |
|
749 |
logged:logged |
|
750 |
ifFail:nil |
|
751 |
compile:true |
|
752 |
" |
|
753 |
Compiler evaluate:'''some string''' logged:false |
|
754 |
Compiler evaluate:'''some string''' logged:true |
|
755 |
" |
|
756 |
! |
|
757 |
||
758 |
evaluate:aStringOrStream notifying:requestor |
|
759 |
"return the result of evaluating aString, |
|
760 |
errors are reported to requestor" |
|
761 |
||
762 |
^ self |
|
763 |
evaluate:aStringOrStream |
|
764 |
in:nil |
|
765 |
receiver:nil |
|
766 |
notifying:requestor |
|
767 |
logged:false |
|
768 |
ifFail:nil |
|
769 |
compile:true |
|
770 |
! |
|
771 |
||
772 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
773 |
"return the result of evaluating aString, |
|
774 |
errors are reported to requestor. |
|
775 |
The compile argument specifies if the string should be compiled down to |
|
776 |
bytecode or instead be interpreted from the parseTree. |
|
777 |
The first should be done for doIts etc, where a readable walkback is |
|
778 |
required. |
|
779 |
The latter is better done for constants, styleSheet and resource |
|
780 |
reading and simple sends, where the overhead of compilation is bigger |
|
781 |
than the interpretation overhead." |
|
782 |
||
783 |
^ self |
|
784 |
evaluate:aStringOrStream |
|
785 |
in:nil |
|
786 |
receiver:nil |
|
787 |
notifying:requestor |
|
788 |
logged:false |
|
789 |
ifFail:nil |
|
790 |
compile:compile |
|
791 |
! |
|
792 |
||
1025
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
793 |
evaluate:aStringOrStream notifying:requestor logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
794 |
"return the result of evaluating aString, |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
795 |
errors are reported to requestor" |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
796 |
|
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
797 |
^ self |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
798 |
evaluate:aStringOrStream |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
799 |
in:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
800 |
receiver:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
801 |
notifying:requestor |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
802 |
logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
803 |
ifFail:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
804 |
compile:true |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
805 |
! |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
806 |
|
572 | 807 |
evaluate:aStringOrStream receiver:anObject |
808 |
"return the result of evaluating aString, |
|
809 |
errors are reported to requestor. Allow access to |
|
810 |
anObject as self and to its instVars " |
|
811 |
||
812 |
^ self |
|
619 | 813 |
evaluate:aStringOrStream |
814 |
in:nil |
|
815 |
receiver:anObject |
|
816 |
notifying:nil |
|
817 |
logged:false |
|
818 |
ifFail:nil |
|
819 |
compile:true |
|
572 | 820 |
|
821 |
" |
|
822 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
823 |
" |
|
824 |
||
825 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
826 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
827 |
! |
|
828 |
||
919 | 829 |
evaluate:aStringOrStream receiver:someOne logged:logged |
830 |
"return the result of evaluating an expression in aStringOrStream. |
|
831 |
The argument log controls if an entry is added to the changeLog." |
|
832 |
||
833 |
^ self |
|
834 |
evaluate:aStringOrStream |
|
835 |
in:nil |
|
836 |
receiver:someOne |
|
837 |
notifying:nil |
|
838 |
logged:logged |
|
839 |
ifFail:nil |
|
840 |
compile:true |
|
841 |
" |
|
842 |
Compiler evaluate:'''some string''' logged:false |
|
843 |
Compiler evaluate:'''some string''' logged:true |
|
844 |
Compiler evaluate:'self class' receiver:nil logged:false |
|
845 |
Compiler evaluate:'self class' receiver:1 logged:false |
|
846 |
" |
|
847 |
! |
|
848 |
||
141 | 849 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
850 |
"return the result of evaluating aString, |
|
851 |
errors are reported to requestor. Allow access to |
|
852 |
anObject as self and to its instVars (used in the inspector)" |
|
853 |
||
854 |
^ self |
|
855 |
evaluate:aStringOrStream |
|
856 |
in:nil |
|
857 |
receiver:anObject |
|
858 |
notifying:requestor |
|
859 |
logged:false |
|
860 |
ifFail:nil |
|
861 |
compile:true |
|
862 |
||
863 |
" |
|
864 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
865 |
" |
|
866 |
! |
|
867 |
||
868 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
869 |
"return the result of evaluating aString, |
|
870 |
errors are reported to requestor. Allow access to |
|
871 |
anObject as self and to its instVars (used in the inspector). |
|
872 |
The compile argument specifies if the string should be compiled down to |
|
873 |
bytecode or instead be interpreted from the parseTree. |
|
874 |
The first should be done for doIts etc, where a readable walkback is |
|
875 |
required. |
|
876 |
The latter is better done for constants, styleSheet and resource |
|
877 |
reading and simple sends, where the overhead of compilation is bigger |
|
878 |
than the interpretation overhead." |
|
879 |
||
880 |
^ self |
|
881 |
evaluate:aStringOrStream |
|
882 |
in:nil |
|
883 |
receiver:anObject |
|
884 |
notifying:requestor |
|
885 |
logged:false |
|
886 |
ifFail:nil |
|
887 |
compile:compile |
|
0 | 888 |
! ! |
889 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
890 |
!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
|
891 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
892 |
argAndVarNamesForContext:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
893 |
"helper: given a context, return a collection of arg&var names" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
894 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
895 |
|homeContext method numArgs numVars m src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
896 |
blockNode argNames varNames vars sel isDoIt| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
897 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
898 |
numArgs := aContext numArgs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
899 |
numVars := aContext numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
900 |
(numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
901 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
902 |
homeContext := aContext methodHome. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
903 |
sel := homeContext selector. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
904 |
method := homeContext method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
905 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
906 |
"/ #doIt needs special handling below |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
907 |
isDoIt := (sel == #doIt) or:[sel == #doIt:]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
908 |
aContext isBlockContext ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
909 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
910 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
911 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
912 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
913 |
src := ('[' , method source , '\]') withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
914 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
915 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
916 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
917 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
918 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
919 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
920 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
921 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
922 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
923 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
924 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
925 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
926 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
927 |
argNames := vars collect:[:var | var name] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
928 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
929 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
930 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
931 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
932 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
933 |
varNames := vars collect:[:var | var name]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
934 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
935 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
936 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
937 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
938 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
939 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
940 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
941 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
942 |
^ method methodArgAndVarNames. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
943 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
944 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
945 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
946 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
947 |
method notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
948 |
isDoIt ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
949 |
"/ special for #doIt |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
950 |
"/ my source is found in the method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
951 |
m := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
952 |
src := ('[' , method source , '\]') withCRs. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
953 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
954 |
m := method. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
955 |
src := nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
956 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
957 |
blockNode := Compiler |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
958 |
blockAtLine:(aContext lineNumber) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
959 |
in:m |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
960 |
orSource:src |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
961 |
numArgs:numArgs |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
962 |
numVars:numVars. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
963 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
964 |
blockNode notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
965 |
argNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
966 |
varNames := #(). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
967 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
968 |
numArgs > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
969 |
vars := blockNode arguments. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
970 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
971 |
argNames := vars collect:[:var | var name] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
972 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
973 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
974 |
numVars > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
975 |
vars := blockNode variables. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
976 |
vars size > 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
977 |
varNames := vars collect:[:var | var name]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
978 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
979 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
980 |
^ argNames , varNames |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
981 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
982 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
983 |
^ #() |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
984 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
985 |
"Created: / 17.1.1998 / 03:18:05 / cg" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
986 |
"Modified: / 17.1.1998 / 03:55:44 / cg" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
987 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
988 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
989 |
!Parser class methodsFor:'parsing'! |
141 | 990 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
991 |
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
|
992 |
"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
|
993 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
994 |
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
|
995 |
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
|
996 |
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
|
997 |
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
|
998 |
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
|
999 |
|
429 | 1000 |
|compiler tree mSource who mClass blocks |
397 | 1001 |
maxSoFar innerBlock m| |
1002 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1003 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 1004 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1005 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1006 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1007 |
aMethod notNil ifTrue:[ |
815 | 1008 |
m := aMethod. |
1009 |
who := m who. |
|
1010 |
who isNil ifTrue:[ |
|
1011 |
m isWrapped ifTrue:[ |
|
1012 |
m := m wrapper. |
|
1013 |
m notNil ifTrue:[ |
|
1014 |
who := m who. |
|
1015 |
] |
|
1016 |
] |
|
1017 |
]. |
|
1018 |
who notNil ifTrue:[ |
|
1019 |
mClass := who methodClass. |
|
1020 |
mClass isNil ifTrue:[ ^ nil]. |
|
1021 |
]. |
|
1022 |
||
1023 |
mSource := m source. |
|
1024 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1025 |
] ifFalse:[ |
815 | 1026 |
aString notNil ifTrue:[ |
1027 |
mSource := aString. |
|
1028 |
mClass := UndefinedObject |
|
1029 |
] ifFalse:[ |
|
1030 |
^ nil |
|
1031 |
] |
|
397 | 1032 |
]. |
1033 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1034 |
"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
|
1035 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1036 |
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
|
1037 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1038 |
compiler notifying:nil. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1039 |
compiler ignoreWarnings. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1040 |
compiler ignoreErrors. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1041 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1042 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1043 |
aMethod notNil ifTrue:[ |
815 | 1044 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
1045 |
^ nil. |
|
1046 |
]. |
|
1047 |
||
1048 |
who notNil ifTrue:[ |
|
1049 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
1050 |
^ nil |
|
1051 |
] |
|
1052 |
]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1053 |
] ifFalse:[ |
815 | 1054 |
compiler nextToken. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1055 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1056 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1057 |
tree := compiler parseMethodBody. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1058 |
|
815 | 1059 |
(compiler errorFlag |
1060 |
or:[tree == #Error |
|
1061 |
or:[tree isNil]]) ifTrue:[ |
|
1062 |
^ nil |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1063 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1064 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1065 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1066 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1067 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1068 |
blocks := blocks select:[:aBlock | |
815 | 1069 |
line between: aBlock lineNumber and:aBlock endLineNumber |
1070 |
||
1071 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1072 |
blocks size == 1 ifTrue:[ |
815 | 1073 |
^ 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
|
1074 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1075 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1076 |
nA notNil ifTrue:[ |
815 | 1077 |
blocks := blocks select:[:aBlock | |
1078 |
aBlock numArgs == nA |
|
1079 |
]. |
|
1080 |
blocks size == 1 ifTrue:[ |
|
1081 |
^ blocks at:1 |
|
1082 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1083 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1084 |
nV notNil ifTrue:[ |
815 | 1085 |
blocks := blocks select:[:aBlock | |
1086 |
aBlock numVars == nV |
|
1087 |
]. |
|
1088 |
blocks size == 1 ifTrue:[ |
|
1089 |
^ blocks at:1 |
|
1090 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1091 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1092 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1093 |
"/ 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
|
1094 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1095 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1096 |
blocks do:[:aBlock | |
815 | 1097 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1098 |
innerBlock := aBlock. |
|
1099 |
maxSoFar := aBlock lineNumber |
|
1100 |
] |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1101 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1102 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1103 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1104 |
"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
|
1105 |
"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
|
1106 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1107 |
|
629 | 1108 |
checkMethod:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
1109 |
"parse a method in a given class. |
|
1110 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1111 |
The parser can be queried for selector, receiver, args, locals, |
|
1112 |
used selectors, modified instvars, referenced classvars etc. |
|
1113 |
The noErrors and noWarnings arguments specify if error and warning |
|
1114 |
messages should be sent to the Transcript or suppressed." |
|
1115 |
||
1116 |
|parser tree| |
|
1117 |
||
1118 |
aString isNil ifTrue:[^ nil]. |
|
1119 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1120 |
noErrors ifTrue:[ |
|
1121 |
parser ignoreErrors |
|
1122 |
]. |
|
1123 |
noWarnings ifTrue:[ |
|
1124 |
parser ignoreWarnings |
|
1125 |
]. |
|
1126 |
tree := parser parseMethod. |
|
1127 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1128 |
||
1129 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1130 |
||
1131 |
" |
|
1132 |
self |
|
1133 |
checkMethod:'foo |
|
1134 |
|local1 local2 local3| |
|
1135 |
||
1136 |
local1 := local2. |
|
1137 |
^ local3 |
|
1138 |
' |
|
1139 |
in:UndefinedObject |
|
1140 |
ignoreErrors:true |
|
1141 |
ignoreWarnings:true |
|
1142 |
" |
|
1143 |
||
1144 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1145 |
! |
|
1146 |
||
141 | 1147 |
parseExpression:aString |
1148 |
"parse aString as an expression; |
|
1149 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1150 |
or comment only) or #Error (syntactic error). |
1151 |
Error and warning messages are suppressed." |
|
141 | 1152 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1153 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1154 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1155 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1156 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1157 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1158 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1159 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1160 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1161 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1162 |
" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1163 |
Parser parseExpression:'self foo' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1164 |
Parser parseExpression:'self:123' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1165 |
Parser parseExpression:'self:123' onError:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1166 |
" |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1167 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1168 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1169 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1170 |
"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
|
1171 |
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
|
1172 |
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
|
1173 |
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
|
1174 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1175 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1176 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1177 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1178 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1179 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1180 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1181 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1182 |
inNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1183 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1184 |
"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
|
1185 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1186 |
! |
1187 |
||
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1188 |
parseExpression:aString inNameSpace:aNameSpaceOrNil onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1189 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1190 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1191 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1192 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1193 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1194 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1195 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1196 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1197 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1198 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1199 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1200 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1201 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1202 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1203 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1204 |
"Created: 24.6.1997 / 16:44:26 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1205 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1206 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1207 |
parseExpression:aString onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1208 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1209 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1210 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1211 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1212 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1213 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1214 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1215 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1216 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1217 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1218 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1219 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1220 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1221 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1222 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1223 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1224 |
|
141 | 1225 |
parseMethod:aString |
1226 |
"parse a method. |
|
1227 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1228 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1229 |
used selectors etc. |
1230 |
Error and warning messages are sent to the Transcript." |
|
141 | 1231 |
|
1232 |
^ self parseMethod:aString in:nil |
|
1233 |
||
1234 |
" |
|
1235 |
|p| |
|
1236 |
||
1237 |
p := Parser |
|
619 | 1238 |
parseMethod:' |
1239 |
foo:arg1 bar:arg2 baz:arg3 |
|
1240 |
|l1 l2| |
|
1241 |
l1 := 0. |
|
1242 |
l2 := arg1. |
|
1243 |
^ self'. |
|
141 | 1244 |
|
1245 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1246 |
'args: ' print. p methodArgs printNL. |
|
1247 |
'sel: ' print. p selector printNL. |
|
1248 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1249 |
'locals: ' print. p methodVars printNL. |
|
1250 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1251 |
" |
|
258 | 1252 |
|
1253 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1254 |
! |
1255 |
||
1256 |
parseMethod:aString in:aClass |
|
1257 |
"parse a method in a given class. |
|
1258 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1259 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1260 |
used selectors, modified instvars, referenced classvars etc. |
1261 |
Error and warning messages are sent to the Transcript." |
|
141 | 1262 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1263 |
^ self |
619 | 1264 |
parseMethod:aString |
1265 |
in:aClass |
|
1266 |
ignoreErrors:false |
|
1267 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1268 |
|
258 | 1269 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1270 |
! |
1271 |
||
1272 |
parseMethod:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
|
1273 |
"parse a method in a given class. |
|
1274 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1275 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1276 |
used selectors, modified instvars, referenced classvars etc. |
1277 |
The noErrors and noWarnings arguments specify if error and warning |
|
1278 |
messages should be sent to the Transcript or suppressed." |
|
141 | 1279 |
|
1280 |
|parser tree| |
|
1281 |
||
1282 |
aString isNil ifTrue:[^ nil]. |
|
1283 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1284 |
noErrors ifTrue:[ |
|
1091 | 1285 |
parser ignoreErrors |
141 | 1286 |
]. |
1287 |
noWarnings ifTrue:[ |
|
1091 | 1288 |
parser ignoreWarnings |
141 | 1289 |
]. |
1290 |
tree := parser parseMethod. |
|
1291 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1292 |
^ parser |
|
258 | 1293 |
|
1294 |
"Modified: 24.4.1996 / 13:19:23 / cg" |
|
141 | 1295 |
! |
1296 |
||
1297 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1298 |
"parse a method in a given class. |
|
1299 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1300 |
The parser can be queried for selector, receiver, args, locals, |
|
1301 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1302 |
The warnBoolean arguments specifies if warning |
1303 |
messages should be sent to the Transcript or suppressed. |
|
1304 |
||
1305 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1306 |
||
1307 |
self obsoleteMethodWarning. |
|
141 | 1308 |
^ self |
619 | 1309 |
parseMethod:aString |
1310 |
in:aClass |
|
1311 |
ignoreErrors:false |
|
1312 |
ignoreWarnings:warnBoolean not |
|
258 | 1313 |
|
1314 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1315 |
! |
1316 |
||
1317 |
parseMethodArgAndVarSpecification:aString |
|
1318 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1319 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1320 |
The parser can be queried for selector, receiver etc. |
1321 |
Error and warning messages are sent to the Transcript. |
|
1322 |
This method is OBSOLETE." |
|
1323 |
||
1324 |
self obsoleteMethodWarning. |
|
141 | 1325 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1326 |
||
1327 |
" |
|
1328 |
|p| |
|
1329 |
||
1330 |
p := Parser |
|
619 | 1331 |
parseMethodArgAndVarSpecification:' |
1332 |
foo:arg1 bar:arg2 baz:arg3 |
|
1333 |
|l1 l2|'. |
|
141 | 1334 |
|
1335 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1336 |
'args: ' print. p methodArgs printNL. |
|
1337 |
'sel: ' print. p selector printNL. |
|
1338 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1339 |
'locals: ' print. p methodVars printNL. |
|
1340 |
" |
|
258 | 1341 |
|
1342 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1343 |
! |
1344 |
||
1345 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1346 |
"parse a methods selector, arg and var spec in a given class; |
|
1347 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1348 |
The parser can be queried for selector, receiver, args and locals. |
1349 |
Error and warning messages are sent to the Transcript. |
|
1350 |
This method is OBSOLETE." |
|
1351 |
||
1352 |
self obsoleteMethodWarning. |
|
141 | 1353 |
^ self parseMethodArgAndVarSpecification:aString |
619 | 1354 |
in:aClass |
1355 |
ignoreErrors:false |
|
1356 |
ignoreWarnings:false |
|
1357 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1358 |
|
258 | 1359 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1360 |
! |
1361 |
||
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1362 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings parseBody:body |
141 | 1363 |
"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
|
1364 |
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
|
1365 |
(for primitives & resourceSpecs). |
258 | 1366 |
The noErrors and noWarnings arguments specify if error and warning |
1367 |
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
|
1368 |
|
141 | 1369 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1370 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1371 |
|
0 | 1372 |
|parser| |
1373 |
||
141 | 1374 |
aString isNil ifTrue:[^ nil]. |
1375 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1376 |
noErrors ifTrue:[ |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1377 |
parser ignoreErrors |
141 | 1378 |
]. |
1379 |
noWarnings ifTrue:[ |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1380 |
parser ignoreWarnings |
141 | 1381 |
]. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1382 |
"/ parser nextToken. |
141 | 1383 |
(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
|
1384 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1385 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1386 |
"/ - 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
|
1387 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1388 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1389 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1390 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1391 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1392 |
]. |
141 | 1393 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1394 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1395 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1396 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1397 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1398 |
! |
1399 |
||
1400 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1401 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1402 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1403 |
The parser can be queried for selector, receiver etc. |
|
258 | 1404 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1405 |
display error/warning messages on the transcript." |
1406 |
||
1407 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1408 |
|
1409 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1410 |
! |
1411 |
||
1412 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1413 |
"parse a methods selector, arg and var spec in a given class; |
|
1414 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1415 |
The parser can be queried for selector, receiver, args and locals. |
|
1416 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1417 |
display error/warning messages on the transcript." |
|
1418 |
||
1419 |
^ self parseMethodArgAndVarSpecification:aString |
|
619 | 1420 |
in:aClass |
1421 |
ignoreErrors:true |
|
1422 |
ignoreWarnings:true |
|
1423 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1424 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1425 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1426 |
! |
1427 |
||
1428 |
parseMethodSilent:aString |
|
1429 |
"parse a method. |
|
1430 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1431 |
The parser can be queried for selector, receiver, args, locals, |
|
1432 |
used selectors etc. |
|
258 | 1433 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1434 |
|
1435 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1436 |
|
1437 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1438 |
! |
1439 |
||
1440 |
parseMethodSilent:aString in:aClass |
|
1441 |
"parse a method in a given class. |
|
1442 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1443 |
The parser can be queried for selector, receiver, args, locals, |
|
1444 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1445 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1446 |
||
1447 |
^ self |
|
619 | 1448 |
parseMethod:aString |
1449 |
in:aClass |
|
1450 |
ignoreErrors:true |
|
1451 |
ignoreWarnings:true |
|
258 | 1452 |
|
1453 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1454 |
! |
1455 |
||
1456 |
parseMethodSpecification:aString |
|
1457 |
"parse a methods selector & arg specification; |
|
1458 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1459 |
The parser can be queried for selector, receiver etc." |
|
1460 |
||
1461 |
^ self parseMethodSpecification:aString in:nil |
|
1462 |
||
1463 |
" |
|
1464 |
|p| |
|
1465 |
||
1466 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1467 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1468 |
'args: ' print. p methodArgs printNL. |
|
1469 |
'sel: ' print. p selector printNL |
|
1470 |
" |
|
1471 |
! |
|
1472 |
||
1473 |
parseMethodSpecification:aString in:aClass |
|
1474 |
"parse a methods selector & arg spec for a given class; |
|
1475 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1476 |
The parser can be queried for selector, receiver etc." |
|
1477 |
||
1478 |
^ self parseMethodSpecification:aString |
|
1479 |
in:aClass |
|
1480 |
ignoreErrors:false |
|
1481 |
ignoreWarnings:false |
|
1482 |
! |
|
1483 |
||
1484 |
parseMethodSpecification:aString in:aClass ignoreErrors:noErrors ignoreWarnings:noWarnings |
|
1485 |
"parse a methods selector & arg spec for a given class; |
|
1486 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1487 |
The parser can be queried for selector, receiver etc. |
|
1488 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1489 |
to be output onto the Transcript." |
|
1490 |
||
1491 |
|parser tree| |
|
1492 |
||
1493 |
aString isNil ifTrue:[^ nil]. |
|
1494 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1495 |
noErrors ifTrue:[ |
|
619 | 1496 |
parser ignoreErrors |
141 | 1497 |
]. |
1498 |
noWarnings ifTrue:[ |
|
619 | 1499 |
parser ignoreWarnings |
141 | 1500 |
]. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1501 |
"/ parser nextToken. |
141 | 1502 |
tree := parser parseMethodSpec. |
1503 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1504 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1505 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1506 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1507 |
! |
1508 |
||
1509 |
parseMethodSpecificationSilent:aString |
|
1510 |
"parse a methods selector & arg specification; |
|
1511 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1512 |
The parser can be queried for selector, receiver etc. |
|
1513 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1514 |
||
1515 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1516 |
! |
|
1517 |
||
1518 |
parseMethodSpecificationSilent:aString in:aClass |
|
1519 |
"parse a methods selector & arg spec for a given class; |
|
1520 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1521 |
The parser can be queried for selector, receiver etc. |
|
1522 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1523 |
||
1524 |
^ self parseMethodSpecification:aString |
|
1525 |
in:aClass |
|
1526 |
ignoreErrors:true |
|
1527 |
ignoreWarnings:true |
|
1528 |
||
1529 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1530 |
! |
|
0 | 1531 |
|
7 | 1532 |
selectorInExpression:aString |
47 | 1533 |
"parse an expression - return the selector. Even malformed expressions |
1534 |
(such as missing receiver or missing arg are parsed. |
|
1535 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1536 |
Returns nil if unparsable." |
7 | 1537 |
|
1538 |
|tree parser| |
|
1539 |
||
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1540 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1541 |
|
21 | 1542 |
tree := self withSelf:nil |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1543 |
parseExpression:aString |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1544 |
notifying:nil |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1545 |
ignoreErrors:true |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1546 |
ignoreWarnings:true. |
21 | 1547 |
|
1548 |
" |
|
1549 |
special: take the expression of the right side, if its an |
|
1550 |
assignment or return |
|
1551 |
" |
|
7 | 1552 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1553 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1554 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1555 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1556 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1557 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1558 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1559 |
|
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1560 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1561 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1562 |
]. |
7 | 1563 |
]. |
1564 |
||
21 | 1565 |
" |
1566 |
mhmh, try expression without receiver |
|
1567 |
" |
|
7 | 1568 |
parser := self for:(ReadStream on:aString). |
1569 |
parser ignoreErrors. |
|
1570 |
parser nextToken. |
|
1571 |
^ parser degeneratedKeywordExpressionForSelector |
|
1572 |
||
1573 |
" |
|
20 | 1574 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1575 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1576 |
Parser selectorInExpression:'a + 4' |
1577 |
Parser selectorInExpression:'a negated' |
|
20 | 1578 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1579 |
Parser selectorInExpression:'at:1 put:' |
1580 |
Parser selectorInExpression:'a at:1 put:5' |
|
1581 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1582 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1583 |
" |
451 | 1584 |
|
1585 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1586 |
! |
1587 |
||
1588 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1589 |
"parse aString as an expression with self set to anObject; |
|
21 | 1590 |
Return the parseTree (if ok), nil (for an empty string |
1591 |
or comment only ) or #Error (syntactic error). |
|
1592 |
||
1593 |
Errors and warnings are forwarded to someOne (usually some |
|
1594 |
codeView) which can highlight it and show a popup box." |
|
7 | 1595 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1596 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1597 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1598 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1599 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1600 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1601 |
ignoreErrors:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1602 |
ignoreWarnings:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1603 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1604 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1605 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1606 |
! |
1607 |
||
1608 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1609 |
"parse aString as an expression with self set to anObject; |
21 | 1610 |
Return the parseTree (if ok), nil (for an empty string |
1611 |
or comment only ) or #Error (syntactic error). |
|
1612 |
||
1613 |
Errors and warnings are forwarded to someOne (usually some |
|
1614 |
codeView) which can highlight it and show a popup box." |
|
1615 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1616 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1617 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1618 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1619 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1620 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1621 |
ignoreErrors:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1622 |
ignoreWarnings:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1623 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1624 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1625 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1626 |
! |
1627 |
||
1628 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1629 |
"parse aString as an expression with self set to anObject; |
|
1630 |
Return the parseTree (if ok), nil (for an empty string |
|
1631 |
or comment only ) or #Error (syntactic error). |
|
1632 |
||
1633 |
Errors and warnings are forwarded to someOne (usually some |
|
1634 |
codeView) which can highlight it and show a popup box, |
|
1635 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1636 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1637 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1638 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1639 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1640 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1641 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1642 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1643 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1644 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1645 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1646 |
"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
|
1647 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1648 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1649 |
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
|
1650 |
"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
|
1651 |
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
|
1652 |
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
|
1653 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1654 |
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
|
1655 |
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
|
1656 |
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
|
1657 |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1658 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1659 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1660 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1661 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1662 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1663 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1664 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1665 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1666 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1667 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1668 |
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
|
1669 |
"parse aString as an expression with self set to anObject; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1670 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1671 |
or comment only ) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1672 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1673 |
Errors and warnings are forwarded to someOne (usually some |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1674 |
codeView) which can highlight it and show a popup box, |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1675 |
iff ignoreErrors/ignoreWarnings is true respectively." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1676 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1677 |
|parser tree| |
0 | 1678 |
|
1679 |
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
|
1680 |
|
0 | 1681 |
parser := self for:(ReadStream on:aString). |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1682 |
tree := parser |
1006 | 1683 |
parseExpressionWithSelf:anObject |
1684 |
notifying:someOne |
|
1685 |
ignoreErrors:ignoreErrors |
|
1686 |
ignoreWarnings:ignoreWarnings |
|
1687 |
inNameSpace:aNameSpaceOrNil. |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1688 |
tree == #Error ifTrue:[ |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1689 |
^ errorValue value |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1690 |
]. |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1691 |
^ tree |
1006 | 1692 |
|
1693 |
"Modified: / 14.12.1999 / 15:12:16 / cg" |
|
0 | 1694 |
! ! |
1695 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1696 |
!Parser class methodsFor:'unparsing'! |
20 | 1697 |
|
1698 |
methodSpecificationForSelector:aSelector |
|
1699 |
"given a selector such as #foo:bar:, return a string that could |
|
1700 |
serve as a methods specification source code. |
|
1701 |
To be used for code generators" |
|
1702 |
||
807 | 1703 |
|argNames n| |
1704 |
||
1705 |
n := aSelector numArgs. |
|
1706 |
n == 1 ifTrue:[ |
|
1707 |
argNames := #('arg') |
|
1708 |
] ifFalse:[ |
|
1709 |
n <= 15 ifTrue:[ |
|
1710 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1711 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1712 |
'arg13' 'arg14' 'arg15') |
|
1713 |
] ifFalse:[ |
|
1714 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1715 |
]. |
|
1716 |
]. |
|
1717 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1718 |
||
20 | 1719 |
" |
807 | 1720 |
Parser methodSpecificationForSelector:#foo: |
20 | 1721 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1722 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1723 |
Parser methodSpecificationForSelector:#+ |
20 | 1724 |
Parser methodSpecificationForSelector:#negated |
1725 |
" |
|
807 | 1726 |
|
1727 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1728 |
! |
1729 |
||
1730 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1731 |
"given a selector such as #foo:bar:, return a string that could |
|
1732 |
serve as a methods specification source code. |
|
1733 |
To be used for code generators" |
|
1734 |
||
806 | 1735 |
|s nargs parts part| |
20 | 1736 |
|
1737 |
s := WriteStream on:String new. |
|
44 | 1738 |
nargs := aSelector numArgs. |
20 | 1739 |
nargs == 0 ifTrue:[ |
806 | 1740 |
s nextPutAll:aSelector |
20 | 1741 |
] ifFalse:[ |
806 | 1742 |
parts := aSelector partsIfSelector. |
1743 |
1 to:nargs do:[:i | |
|
1744 |
part := parts at:i. |
|
1745 |
s nextPutAll:part. |
|
1746 |
(part endsWith:$:) ifFalse:[ |
|
1747 |
s space. |
|
1748 |
]. |
|
1749 |
s nextPutAll:(argNames at:i). |
|
1750 |
i ~~ nargs ifTrue:[s space]. |
|
1751 |
] |
|
20 | 1752 |
]. |
1753 |
^ s contents |
|
1754 |
||
1755 |
" |
|
1756 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1757 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1758 |
Parser methodSpecificationForSelector:#negated |
|
1759 |
" |
|
806 | 1760 |
|
1761 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1762 |
! ! |
1763 |
||
1020 | 1764 |
!Parser methodsFor:'Compatibility - ST80'! |
0 | 1765 |
|
918 | 1766 |
evaluate:aString in:aClassOrContext to:to notifying:aRequestor ifFail:failBlock |
35 | 1767 |
|parseTree value| |
0 | 1768 |
|
1769 |
aString isNil ifTrue:[^ nil]. |
|
1770 |
self initializeFor:(ReadStream on:aString). |
|
918 | 1771 |
|
1772 |
"/ stupid - there seem to be differences among the various |
|
1773 |
"/ ST dialects ... |
|
1774 |
aClassOrContext isBehavior ifTrue:[ |
|
1775 |
self setClassToCompileFor:aClassOrContext. |
|
1776 |
selfValue := nil. |
|
1777 |
] ifFalse:[ |
|
1778 |
self setContext:aClassOrContext. |
|
1779 |
aClassOrContext notNil ifTrue:[ |
|
1780 |
self setSelf:(aClassOrContext receiver) |
|
1781 |
]. |
|
1782 |
]. |
|
0 | 1783 |
requestor := aRequestor. |
1784 |
||
1785 |
self nextToken. |
|
1786 |
parseTree := self parseMethodBody. |
|
1787 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1788 |
parseTree notNil ifTrue:[ |
|
918 | 1789 |
self evalExitBlock:[:value | ^ failBlock value]. |
1790 |
value := parseTree evaluate |
|
0 | 1791 |
]. |
35 | 1792 |
self release. |
1793 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1794 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1795 |
|
624 | 1796 |
parse:methodSource in:aClass notifying:aRequestor |
1797 |
"parse a methods source. |
|
1798 |
Return the methods parseTree" |
|
1799 |
||
1800 |
self initializeFor:methodSource. |
|
1801 |
classToCompileFor := aClass. |
|
1802 |
requestor := aRequestor. |
|
1803 |
self parseMethod. |
|
918 | 1804 |
|
624 | 1805 |
^ MethodNode new |
1806 |
selector:selector |
|
1807 |
arguments:methodArgs |
|
1808 |
locals:methodVars |
|
1809 |
statements:tree |
|
1810 |
||
1811 |
"Created: 17.10.1997 / 12:35:01 / cg" |
|
1812 |
"Modified: 17.10.1997 / 12:40:34 / cg" |
|
1813 |
! |
|
1814 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1815 |
parseSelector:aStringOrStream |
624 | 1816 |
"parse a methods source for the methods selector. |
1817 |
Return the selector" |
|
1818 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1819 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1820 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1821 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1822 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1823 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1824 |
Parser new |
624 | 1825 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1826 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1827 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1828 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1829 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1830 |
' |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1831 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1832 |
|
624 | 1833 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1834 |
! ! |
1835 |
||
44 | 1836 |
!Parser methodsFor:'accessing'! |
1837 |
||
1838 |
correctedSource |
|
1839 |
^ correctedSource |
|
1840 |
! |
|
1841 |
||
141 | 1842 |
errorFlag |
1843 |
"return true if there where any errors (valid after parsing)" |
|
1844 |
||
1845 |
^ errorFlag |
|
1846 |
! |
|
1847 |
||
1848 |
evalExitBlock:aBlock |
|
1849 |
"when evaluating a return expression, this block is evaluated" |
|
1850 |
||
1851 |
evalExitBlock := aBlock |
|
1852 |
! |
|
1853 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1854 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1855 |
"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
|
1856 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1857 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1858 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1859 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1860 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1861 |
|
19 | 1862 |
primitiveNumber |
1863 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1864 |
||
1865 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1866 |
! |
97 | 1867 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1868 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1869 |
"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
|
1870 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1871 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1872 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1873 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1874 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1875 |
|
35 | 1876 |
release |
664 | 1877 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1878 |
super release. |
664 | 1879 |
|
1880 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 1881 |
! |
1882 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1883 |
setNameSpace:aNameSpaceName |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
1884 |
currentNamespace := NameSpace fullName:aNameSpaceName |
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1885 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1886 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1887 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1888 |
|
141 | 1889 |
targetClass |
1890 |
^ classToCompileFor |
|
1891 |
! |
|
1892 |
||
90 | 1893 |
targetClass:aClass |
117 | 1894 |
classToCompileFor := aClass |
1895 |
! |
|
1896 |
||
141 | 1897 |
tree |
1898 |
"return the parsetree" |
|
1899 |
||
1900 |
^tree |
|
1901 |
! |
|
1902 |
||
1903 |
tree:aTree |
|
1904 |
"private: set the tree - for internal use only" |
|
1905 |
||
1906 |
tree := aTree |
|
1907 |
! ! |
|
1908 |
||
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1909 |
!Parser methodsFor:'dummy - syntax detection'! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1910 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1911 |
markArgumentIdentifierFrom:pos1 to:pos2 |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1912 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1913 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1914 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1915 |
|
883 | 1916 |
markBadIdentifierFrom:pos1 to:pos2 |
1917 |
||
1918 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
1919 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
1920 |
! |
|
1921 |
||
663 | 1922 |
markBooleanConstantFrom:pos1 to:pos2 |
1923 |
||
1924 |
"Created: / 31.3.1998 / 18:06:22 / cg" |
|
1925 |
! |
|
1926 |
||
673 | 1927 |
markBracketAt:pos |
1928 |
! |
|
1929 |
||
663 | 1930 |
markConstantFrom:pos1 to:pos2 |
1931 |
||
1932 |
"Created: / 31.3.1998 / 18:06:24 / cg" |
|
1933 |
! |
|
1934 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1935 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1936 |
|
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1937 |
"Created: / 4.3.1999 / 12:52:45 / cg" |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1938 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
1939 |
|
663 | 1940 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1941 |
||
1942 |
"Created: / 31.3.1998 / 15:29:39 / cg" |
|
1943 |
! |
|
1944 |
||
1945 |
markHereFrom:pos1 to:pos2 |
|
1946 |
||
1947 |
"Created: / 31.3.1998 / 17:39:01 / cg" |
|
1948 |
! |
|
1949 |
||
1950 |
markIdentifierFrom:pos1 to:pos2 |
|
1951 |
||
1952 |
"Created: / 31.3.1998 / 18:06:17 / cg" |
|
1953 |
! |
|
1954 |
||
687 | 1955 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1956 |
||
1957 |
"Created: / 16.4.1998 / 18:34:10 / cg" |
|
1958 |
! |
|
1959 |
||
663 | 1960 |
markLocalIdentifierFrom:pos1 to:pos2 |
1961 |
||
1962 |
"Created: / 31.3.1998 / 15:29:35 / cg" |
|
1963 |
! |
|
1964 |
||
1965 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1966 |
||
1967 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
1968 |
"Created: / 31.3.1998 / 16:39:44 / cg" |
|
1969 |
! |
|
1970 |
||
837 | 1971 |
markReturnAt:pos |
1972 |
||
1973 |
"Created: / 5.1.1980 / 00:48:24 / cg" |
|
1974 |
! |
|
1975 |
||
864 | 1976 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
1977 |
||
1978 |
"Created: / 31.3.1998 / 13:22:15 / cg" |
|
1979 |
"Modified: / 31.3.1998 / 13:30:09 / cg" |
|
1980 |
! |
|
1981 |
||
663 | 1982 |
markSelfFrom:pos1 to:pos2 |
1983 |
||
1984 |
"Created: / 31.3.1998 / 17:49:38 / cg" |
|
1985 |
! |
|
1986 |
||
1987 |
markSuperFrom:pos1 to:pos2 |
|
1988 |
||
1989 |
"Created: / 31.3.1998 / 17:40:20 / cg" |
|
664 | 1990 |
! |
1991 |
||
1992 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
1993 |
||
1994 |
"Modified: / 31.3.1998 / 19:16:26 / cg" |
|
1995 |
"Created: / 31.3.1998 / 19:35:53 / cg" |
|
687 | 1996 |
! |
1997 |
||
1998 |
markVariable:v |
|
1999 |
"support for syntaxColoring" |
|
2000 |
||
2001 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
2002 |
! |
|
2003 |
||
2004 |
markVariable:v from:pos1 to:pos2 |
|
2005 |
"support for syntaxColoring" |
|
2006 |
||
2007 |
"Modified: / 16.4.1998 / 18:47:45 / cg" |
|
2008 |
"Created: / 16.4.1998 / 18:50:03 / cg" |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2009 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2010 |
|
141 | 2011 |
!Parser methodsFor:'error correction'! |
2012 |
||
2013 |
askForCorrection:aString fromList:aList |
|
2014 |
"launch a selection box, which allows user to enter correction. |
|
2015 |
return newString or nil (for abort)" |
|
2016 |
||
2017 |
|box| |
|
2018 |
||
2019 |
"in systems without widgets ..." |
|
2020 |
ListSelectionBox isNil ifTrue:[ |
|
2021 |
^ self confirm:aString |
|
2022 |
]. |
|
2023 |
box := ListSelectionBox title:aString. |
|
2024 |
box initialText:(aList at:1). |
|
2025 |
box list:aList. |
|
2026 |
box okText:'correct'. |
|
2027 |
box action:[:aString | ^ aString]. |
|
2028 |
box showAtPointer. |
|
2029 |
^ nil |
|
2030 |
! |
|
2031 |
||
2032 |
correctByDeleting |
|
2033 |
"correct (by deleting token) if user wants to; |
|
2034 |
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
|
2035 |
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
|
2036 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2037 |
|selectionSize| |
141 | 2038 |
|
2039 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
2040 |
||
2041 |
" |
|
2042 |
tell requestor (i.e. CodeView) about the change |
|
2043 |
this will update what the requestor shows. |
|
2044 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2045 |
selectionSize := requestor selection size. |
141 | 2046 |
requestor deleteSelection. |
2047 |
||
2048 |
" |
|
2049 |
get the updated source-string |
|
2050 |
which is needed, when we eventually install the new method |
|
2051 |
" |
|
2052 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2053 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2054 |
position:(source position - selectionSize). |
141 | 2055 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2056 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2057 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 2058 |
! |
2059 |
||
1022 | 2060 |
correctSelector:aSelectorString message:msg position:pos1 to:pos2 in:aClassOrNil |
141 | 2061 |
"notify error and correct if user wants to; |
2062 |
return #Error if there was no correction |
|
2063 |
or a ParseNode as returned by variable" |
|
2064 |
||
2065 |
|correctIt suggestedNames newSelector| |
|
2066 |
||
2067 |
" |
|
2068 |
sorry, but I cannot handle keywords with more than one-part |
|
2069 |
currently (too much work - maybe Ill do it later when everything else works :-) |
|
2070 |
" |
|
2071 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2072 |
self warning:msg position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2073 |
^ aSelectorString |
141 | 2074 |
]. |
2075 |
||
1022 | 2076 |
correctIt := self correctableSelectorWarning:msg position:pos1 to:pos2. |
141 | 2077 |
correctIt ifFalse:[^ aSelectorString]. |
2078 |
||
1022 | 2079 |
suggestedNames := self findBestSelectorsFor:aSelectorString in:aClassOrNil. |
141 | 2080 |
suggestedNames notNil ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2081 |
newSelector := self askForCorrection:'correct selector to: ' fromList:suggestedNames. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2082 |
newSelector isNil ifTrue:[^ aSelectorString]. |
141 | 2083 |
] ifFalse:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2084 |
self information:'no good correction found'. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2085 |
^ aSelectorString |
141 | 2086 |
]. |
2087 |
||
2088 |
" |
|
2089 |
tell requestor (i.e. CodeView) about the change |
|
2090 |
this will update what the requestor shows. |
|
2091 |
" |
|
2092 |
||
2093 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
|
2094 |
" |
|
2095 |
get the updated source-string |
|
2096 |
which is needed, when we eventually install the new method |
|
2097 |
" |
|
2098 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2099 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2100 |
position:(source position + newSelector size - aSelectorString size). |
141 | 2101 |
|
2102 |
^ newSelector |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2103 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2104 |
"Modified: / 22.1.1998 / 16:36:04 / stefan" |
1022 | 2105 |
"Created: / 19.1.2000 / 16:34:01 / cg" |
2106 |
"Modified: / 19.1.2000 / 16:34:55 / cg" |
|
141 | 2107 |
! |
2108 |
||
2109 |
correctVariable |
|
2110 |
"notify error and correct if user wants to; |
|
2111 |
return #Error if there was no correction |
|
2112 |
or a ParseNode as returned by variable" |
|
2113 |
||
877 | 2114 |
|correctIt varName suggestedNames newName pos1 pos2 rslt |
2115 |
varNameIsLowercase l how choice holder| |
|
141 | 2116 |
|
2117 |
pos1 := tokenPosition. |
|
2118 |
varName := tokenName. |
|
2119 |
pos2 := pos1 + varName size - 1. |
|
2120 |
||
877 | 2121 |
varNameIsLowercase := (varName at:1) isLowercase. |
2122 |
||
141 | 2123 |
"OLD: |
877 | 2124 |
varNameIsLowercase ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2125 |
correctIt := self undefError:varName position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2126 |
correctIt ifFalse:[^ #Error] |
141 | 2127 |
] ifFalse:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2128 |
correctIt := self warning:('''' , varName , ''' is undefined') position:pos1 to:pos2. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2129 |
correctIt ifFalse:[ |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2130 |
^ VariableNode type:#GlobalVariable name:(varName asSymbol) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2131 |
] |
141 | 2132 |
]. |
2133 |
" |
|
2134 |
||
2135 |
correctIt := self undefError:varName position:pos1 to:pos2. |
|
887 | 2136 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 2137 |
"/ no correction wanted. |
2138 |
||
2139 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
2140 |
"/ allowing easy search for bad-spots later. |
|
2141 |
||
2142 |
varNameIsLowercase ifTrue:[ |
|
725
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2143 |
((Smalltalk includesKey:#Undeclared) |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2144 |
and:[((Smalltalk at:#Undeclared) includes:varName asSymbol)]) ifFalse:[ |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2145 |
self warning:('adding ''' , varName , ''' as Undeclared.\\Remember to fix that later.') withCRs position:pos1 to:pos2. |
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2146 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2147 |
^ self defineAsUndeclaredVariable:varName |
877 | 2148 |
]. |
2149 |
||
2150 |
"/ upperCase vars are declared as global |
|
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2151 |
(warnedUndefVars isNil or:[(warnedUndefVars includes:varName) not]) ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2152 |
(warnedUnknownNamespaces isNil or:[(warnedUnknownNamespaces includes:varName) not]) ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2153 |
self warning:('adding ''' , varName , ''' as Global.') withCRs position:pos1 to:pos2. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2154 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2155 |
]. |
877 | 2156 |
^ VariableNode type:#GlobalVariable name:(varName asSymbol) |
2157 |
]. |
|
2158 |
||
2159 |
correctIt == #declare ifTrue:[ |
|
2160 |
"/ declare it |
|
2161 |
l := #(). |
|
2162 |
how := #(). |
|
2163 |
||
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2164 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
877 | 2165 |
varNameIsLowercase ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2166 |
"/ currentBlock notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2167 |
"/ l := l , #( 'Block local' ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2168 |
"/ how := how , #( BlockVariable ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2169 |
"/ ]. |
877 | 2170 |
selector notNil ifTrue:[ |
2171 |
l := l , #( 'Method local' ). |
|
2172 |
how := how , #( MethodVariable ). |
|
2173 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2174 |
"/ (classToCompileFor notNil |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2175 |
"/ and:[classToCompileFor isMeta not |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2176 |
"/ and:[classToCompileFor isBuiltInClass not]]) ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2177 |
"/ l := l , (Array with:( 'Instance variable of ' , classToCompileFor name )). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2178 |
"/ how := how , #( InstanceVariable ). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2179 |
"/ ]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2180 |
] ifFalse:[ |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2181 |
l := l , #( 'Global' 'NameSpace' ). |
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2182 |
how := how , #( GlobalVariable NameSpace ). |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2183 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2184 |
(classToCompileFor notNil |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2185 |
and:[classToCompileFor isBuiltInClass not |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2186 |
and:[selector notNil and:[selector ~~ #doIt]]]) ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2187 |
l := l , (Array |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2188 |
with:'Class Variable in ' , classToCompileFor name |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2189 |
"/ with:'Class Instance Variable in ' , classToCompileFor name |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2190 |
). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2191 |
how := how , #( ClassVariable ClassInstVariable). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2192 |
] |
877 | 2193 |
]. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2194 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
877 | 2195 |
l size > 0 ifTrue:[ |
2196 |
l := l , #( '-' ). |
|
2197 |
how := how , #( nil ). |
|
2198 |
]. |
|
2199 |
l := l , #( 'Workspace variable' ). |
|
2200 |
how := how , #( WorkspaceVariable ). |
|
2201 |
]. |
|
2202 |
l size > 0 ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2203 |
l := (Array with:('Declare ' , varName asText allBold , ' as:') |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2204 |
with:'-' |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2205 |
) , l. |
877 | 2206 |
how := #(nil nil) , how. |
2207 |
choice := (PopUpMenu labels:l) startUp. |
|
2208 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2209 |
choice := how at:choice. |
|
2210 |
||
2211 |
choice == #WorkspaceVariable ifTrue:[ |
|
2212 |
holder := Workspace addWorkspaceVariable:varName. |
|
2213 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2214 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2215 |
choice == #GlobalVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2216 |
Smalltalk at:varName asSymbol put:nil. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2217 |
^ VariableNode type:#GlobalVariable name:varName asSymbol |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2218 |
]. |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2219 |
choice == #NameSpace ifTrue:[ |
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2220 |
NameSpace name:varName. |
1028 | 2221 |
^ VariableNode type:#GlobalVariable name:varName asSymbol |
2222 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2223 |
choice == #ClassVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2224 |
classToCompileFor addClassVarName:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2225 |
^ VariableNode type:#ClassVariable class:classToCompileFor name:varName |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2226 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2227 |
choice == #MethodVariable ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2228 |
|varIndex var endLocalsPos posToInsert ins| |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2229 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2230 |
localVarDefPosition size == 2 ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2231 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2232 |
ins := ' ' , varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2233 |
] ifFalse:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2234 |
endOfSelectorPosition notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2235 |
posToInsert := endOfSelectorPosition. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2236 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2237 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2238 |
] |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2239 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2240 |
posToInsert notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2241 |
requestor |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2242 |
insertString:ins |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2243 |
atCharacterPosition:posToInsert. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2244 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2245 |
endLocalsPos notNil ifTrue:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2246 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2247 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2248 |
methodVarNames := methodVarNames copyWith:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2249 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2250 |
] ifFalse:[ |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2251 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2252 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2253 |
methodVarNames := Array with:varName. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2254 |
methodVars := Array with:(var := Variable new name:varName). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2255 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2256 |
correctedSource := requestor currentSourceCode. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2257 |
source := (ReadStream on:correctedSource) |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2258 |
position:(source position + ins size). |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2259 |
|
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2260 |
varIndex := methodVarNames size. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2261 |
var used:true. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2262 |
^ VariableNode type:#MethodVariable |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2263 |
name:varName |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2264 |
token:var |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2265 |
index:varIndex |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2266 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2267 |
]. |
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2268 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
877 | 2269 |
]. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
2270 |
^ #Error |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2271 |
] |
141 | 2272 |
]. |
2273 |
||
2274 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2275 |
suggestedNames isNil ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2276 |
self information:'no good correction found'. |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2277 |
^ #Error |
141 | 2278 |
]. |
2279 |
||
877 | 2280 |
newName := self askForCorrection:'correct variable to: ' fromList:suggestedNames. |
2281 |
newName isNil ifTrue:[^ #Error]. |
|
2282 |
" |
|
2283 |
newName := suggestedNames at:1. |
|
2284 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2285 |
" |
|
2286 |
||
141 | 2287 |
" |
2288 |
tell requestor (i.e. CodeView) about the change |
|
2289 |
this will update what the requestor shows. |
|
2290 |
" |
|
2291 |
requestor replaceSelectionBy:newName. |
|
2292 |
" |
|
2293 |
get the updated source-string |
|
2294 |
which is needed, when we eventually install the new method |
|
2295 |
" |
|
2296 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2297 |
source := (ReadStream on:correctedSource) |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2298 |
position:(source position + newName size - tokenName size). |
141 | 2299 |
|
2300 |
"redo parse with new value" |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
2301 |
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
|
2302 |
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
|
2303 |
|
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
|
2304 |
"/ 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
|
2305 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2306 |
"/ 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
|
2307 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2308 |
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
|
2309 |
]. |
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
|
2310 |
^ 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
|
2311 |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2312 |
"Modified: / 22.1.1998 / 16:34:01 / stefan" |
887 | 2313 |
"Modified: / 4.7.1999 / 19:24:10 / cg" |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2314 |
! |
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
|
2315 |
|
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
|
2316 |
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
|
2317 |
"define varName as undeclared variable |
629 | 2318 |
(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
|
2319 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2320 |
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
|
2321 |
|
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
|
2322 |
|varName| |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2323 |
|
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
|
2324 |
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
|
2325 |
|
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
|
2326 |
"/ 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
|
2327 |
|
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
|
2328 |
(Smalltalk includesKey:#Undeclared) ifFalse:[ |
629 | 2329 |
Smalltalk at:#Undeclared put:(IdentitySet new). |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2330 |
]. |
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
|
2331 |
(Smalltalk at:#Undeclared) add:tokenName asSymbol. |
629 | 2332 |
varName := (Smalltalk underclaredPrefix) , tokenName. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2333 |
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
|
2334 |
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
|
2335 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2336 |
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
|
2337 |
|
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
|
2338 |
^ VariableNode type:#GlobalVariable name:varName |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2339 |
|
629 | 2340 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 2341 |
! |
2342 |
||
2343 |
findBestSelectorsFor:aString |
|
2344 |
"collect known selectors with their spelling distances to aString; |
|
2345 |
return the 10 best suggestions" |
|
2346 |
||
2347 |
|info n| |
|
2348 |
||
2349 |
info := SortedCollection new. |
|
2350 |
info sortBlock:[:a :b | a value > b value]. |
|
2351 |
||
2352 |
n := 0. |
|
2353 |
||
2354 |
Symbol allInstancesDo:[:sym | |
|
2355 |
|dist| |
|
2356 |
||
2357 |
dist := aString spellAgainst:sym. |
|
2358 |
dist > 20 ifTrue:[ |
|
2359 |
info add:(sym -> dist). |
|
2360 |
n := n + 1. |
|
2361 |
n > 10 ifTrue:[ |
|
2362 |
info removeLast. |
|
2363 |
] |
|
2364 |
] |
|
2365 |
]. |
|
2366 |
||
2367 |
^ info asOrderedCollection collect:[:a | a key] |
|
2368 |
||
2369 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
2370 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
2371 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
2372 |
! |
|
2373 |
||
1022 | 2374 |
findBestSelectorsFor:aString in:aClassOrNil |
2375 |
"collect known selectors with their spelling distances to aString; |
|
2376 |
return the 10 best suggestions. If the argument, aClassOrNil is not nil, |
|
2377 |
the message is assumed to be sent to instances of that class (i.e. offer |
|
2378 |
corrections from that hierarchy only)" |
|
2379 |
||
2380 |
|info n block lcSelector| |
|
2381 |
||
2382 |
info := SortedCollection new. |
|
2383 |
info sortBlock:[:a :b | a value > b value]. |
|
2384 |
||
2385 |
n := 0. |
|
2386 |
||
2387 |
lcSelector := aString asLowercase. |
|
2388 |
||
2389 |
block := [:sym | |
|
2390 |
|dist lcSym| |
|
2391 |
||
2392 |
lcSym := sym asLowercase. |
|
2393 |
(info contains:[:i | i key == sym]) ifFalse:[ |
|
2394 |
dist := lcSelector spellAgainst:lcSym. |
|
2395 |
dist > 20 ifTrue:[ |
|
2396 |
info add:(sym -> dist). |
|
2397 |
n := n + 1. |
|
2398 |
n > 10 ifTrue:[ |
|
2399 |
info removeLast. |
|
2400 |
] |
|
2401 |
] |
|
2402 |
] |
|
2403 |
]. |
|
2404 |
||
2405 |
aClassOrNil isNil ifTrue:[ |
|
2406 |
Smalltalk allClassesDo:[:cls | |
|
2407 |
cls methodDictionary keys do:block. |
|
2408 |
cls class methodDictionary keys do:block. |
|
2409 |
] |
|
2410 |
] ifFalse:[ |
|
1084 | 2411 |
aClassOrNil withAllSuperclassesDo:[:cls | |
1022 | 2412 |
cls methodDictionary keys do:block. |
2413 |
cls class methodDictionary keys do:block. |
|
2414 |
] |
|
2415 |
]. |
|
2416 |
||
2417 |
^ info asOrderedCollection collect:[:a | a key] |
|
2418 |
||
2419 |
"Modified: / 19.1.2000 / 16:43:37 / cg" |
|
2420 |
! |
|
2421 |
||
141 | 2422 |
findBestVariablesFor:aString |
2423 |
"collect known variables with their spelling distances to aString; |
|
2424 |
return the 10 best suggestions" |
|
2425 |
||
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2426 |
|names dists searchBlock args vars globalVarName "aClass className baseClass" |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2427 |
n instVarNames classVarNames| |
141 | 2428 |
|
2429 |
names := OrderedCollection new. |
|
2430 |
dists := OrderedCollection new. |
|
2431 |
||
2432 |
"block arguments" |
|
2433 |
searchBlock := currentBlock. |
|
2434 |
[searchBlock notNil] whileTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2435 |
args := searchBlock arguments. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2436 |
args notNil ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2437 |
args do:[:aBlockArg | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2438 |
names add:(aBlockArg name). |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2439 |
dists add:(aString spellAgainst: "levenshteinTo:"(aBlockArg name)) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2440 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2441 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2442 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2443 |
vars := searchBlock variables. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2444 |
vars notNil ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2445 |
vars do:[:aBlockVar | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2446 |
names add:(aBlockVar name). |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2447 |
dists add:(aString spellAgainst: "levenshteinTo:"(aBlockVar name)) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2448 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2449 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2450 |
searchBlock := searchBlock home |
141 | 2451 |
]. |
2452 |
||
2453 |
"method-variables" |
|
2454 |
methodVars notNil ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2455 |
methodVarNames do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2456 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2457 |
dists add:(aString spellAgainst: "levenshteinTo:"methodVarName) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2458 |
] |
141 | 2459 |
]. |
2460 |
||
2461 |
"method-arguments" |
|
2462 |
methodArgs notNil ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2463 |
methodArgNames do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2464 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2465 |
dists add:(aString spellAgainst: "levenshteinTo:"methodArgName) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2466 |
] |
141 | 2467 |
]. |
2468 |
||
2469 |
"instance-variables" |
|
2470 |
classToCompileFor notNil ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2471 |
self classesInstVarNames do:[:instVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2472 |
names add:instVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2473 |
dists add:(aString spellAgainst: "levenshteinTo:"instVarName) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2474 |
] |
141 | 2475 |
]. |
2476 |
||
2477 |
"class-variables" |
|
2478 |
classToCompileFor notNil ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2479 |
self classesClassVarNames do:[:classVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2480 |
names add:classVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2481 |
dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2482 |
]. |
141 | 2483 |
|
2484 |
"/ aClass := classToCompileFor. |
|
2485 |
"/ aClass isMeta ifTrue:[ |
|
2486 |
"/ className := aClass name. |
|
2487 |
"/ className := className copyWithoutLast:5. |
|
2488 |
"/ baseClass := Smalltalk at:(className asSymbol). |
|
2489 |
"/ baseClass notNil ifTrue:[ |
|
2490 |
"/ aClass := baseClass |
|
2491 |
"/ ] |
|
2492 |
"/ ]. |
|
2493 |
"/ [aClass notNil] whileTrue:[ |
|
2494 |
"/ (aClass classVarNames) do:[:classVarName | |
|
2495 |
"/ names add:classVarName. |
|
2496 |
"/ dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
2497 |
"/ ]. |
|
2498 |
"/ aClass := aClass superclass |
|
2499 |
"/ ] |
|
2500 |
||
2501 |
]. |
|
2502 |
||
2503 |
"globals" |
|
2504 |
Smalltalk keysDo:[:aKey | |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2505 |
globalVarName := aKey asString. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2506 |
"only compare strings where length is about right" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2507 |
((globalVarName size - aString size) abs < 3) ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2508 |
names add:globalVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2509 |
dists add:(aString spellAgainst: "levenshteinTo:"globalVarName) |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2510 |
] |
141 | 2511 |
]. |
2512 |
||
2513 |
"misc" |
|
2514 |
#('self' 'super' 'nil' 'thisContext') do:[:name | |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2515 |
names add:name. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2516 |
dists add:(aString spellAgainst: "levenshteinTo:"name) |
141 | 2517 |
]. |
2518 |
||
2519 |
(dists size ~~ 0) ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2520 |
dists sortWith:names. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2521 |
dists := dists reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2522 |
names := names reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2523 |
n := names size min:10. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2524 |
names := names copyTo:n. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2525 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2526 |
"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
|
2527 |
(aString at:1) isLowercase ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2528 |
methodVarNames size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2529 |
names add:'---- method locals ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2530 |
methodVarNames asSortedCollection do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2531 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2532 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2533 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2534 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2535 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2536 |
methodArgs size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2537 |
names add:'---- method arguments ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2538 |
methodArgNames asSortedCollection do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2539 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2540 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2541 |
]. |
1078 | 2542 |
classToCompileFor notNil ifTrue:[ |
2543 |
instVarNames := OrderedCollection new. |
|
2544 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
2545 |
(instVarNames includes:instVarName) ifFalse:[ |
|
2546 |
instVarNames add:instVarName. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2547 |
] |
1078 | 2548 |
]. |
2549 |
||
2550 |
instVarNames size > 0 ifTrue:[ |
|
2551 |
(classToCompileFor notNil and:[classToCompileFor isMeta]) ifTrue:[ |
|
2552 |
names add:'---- class instance variables ----'. |
|
2553 |
] ifFalse:[ |
|
2554 |
names add:'---- instance variables ----'. |
|
2555 |
]. |
|
2556 |
instVarNames do:[:instVarName | |
|
2557 |
(names includes:instVarName) ifFalse:[ |
|
2558 |
names add:instVarName. |
|
2559 |
] |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2560 |
] |
1078 | 2561 |
]. |
2562 |
||
2563 |
classVarNames := OrderedCollection new. |
|
2564 |
self classesClassVarNames asSortedCollection do:[:classVarName | |
|
2565 |
(classVarNames includes:classVarName) ifFalse:[ |
|
2566 |
classVarNames add:classVarName. |
|
2567 |
] |
|
2568 |
]. |
|
2569 |
||
2570 |
classVarNames size > 0 ifTrue:[ |
|
2571 |
names add:'---- class variables ----'. |
|
2572 |
classVarNames do:[:classVarName | |
|
2573 |
(names includes:classVarName) ifFalse:[ |
|
2574 |
names add:classVarName. |
|
2575 |
] |
|
2576 |
] |
|
2577 |
]. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2578 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2579 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2580 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2581 |
^ names |
141 | 2582 |
]. |
2583 |
^ nil |
|
450 | 2584 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
2585 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 2586 |
! |
2587 |
||
2588 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
2589 |
"just a quick check: if a selector is totally unknown as a symbol, |
|
2590 |
or has the same name as a variable or cannot be understood. |
|
2591 |
Simple, but catches many typos" |
|
2592 |
||
1022 | 2593 |
|ok err sym rec superCls names recType sCls selClass newSelector| |
141 | 2594 |
|
2595 |
" |
|
2596 |
if compiling lazy, or errors are to be ignored, or there |
|
2597 |
is no requestor, do not check |
|
2598 |
" |
|
1022 | 2599 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2600 |
self isSyntaxHighlighter ifFalse:[ |
1022 | 2601 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
2602 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2603 |
]. |
141 | 2604 |
err := ' is currently nowhere implemented'. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2605 |
|
141 | 2606 |
" |
2607 |
if the selector has the name of a variable, use another message |
|
2608 |
" |
|
2609 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
|
2610 |
or:[(methodArgNames notNil and:[methodArgNames includes:aSelectorString]) |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2611 |
or:[(classToCompileFor notNil |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2612 |
and:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString])]) |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2613 |
or:[(classToCompileFor notNil |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2614 |
and:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString])]) |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2615 |
or:[classToCompileFor notNil |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2616 |
and:[((names := self classesClassVarNames) notNil and:[names includes:aSelectorString])]]]]]) ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2617 |
err := ' is currently nowhere implemented .. |
141 | 2618 |
.. but a variable with that name is defined. |
2619 |
||
143 | 2620 |
Missing ''.'' after the previous expression |
2621 |
or missing keyword/receiver before that word ?'. |
|
141 | 2622 |
]. |
2623 |
||
2624 |
" |
|
2625 |
check if the selector is known at all |
|
2626 |
- if not, it cannot be understood |
|
2627 |
" |
|
2628 |
ok := false. |
|
2629 |
sym := aSelectorString asSymbolIfInterned. |
|
2630 |
sym notNil ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2631 |
ok := true. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2632 |
receiver notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2633 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2634 |
if the receiver is a constant, we can check if it responds |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2635 |
to this selector |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2636 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2637 |
receiver isConstant ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2638 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2639 |
ok := rec respondsTo:sym. |
1022 | 2640 |
selClass := rec class. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2641 |
err := ' will not be understood here (message to ' , rec classNameWithArticle , ')'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2642 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2643 |
receiver isBlock ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2644 |
"/ this should help with typos, sending #ifTrue to blocks ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2645 |
ok := [] respondsTo:sym. |
1022 | 2646 |
selClass := Block. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2647 |
err := ' will not be understood here (message to a Block)'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2648 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2649 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2650 |
if the receiver is a global, we check it too ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2651 |
" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2652 |
(((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2653 |
or:[recType == #PrivateClass]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2654 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2655 |
"/ - it may work after loading" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2656 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2657 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2658 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2659 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2660 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 2661 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2662 |
]. |
926 | 2663 |
rec isNil ifTrue:[ |
1022 | 2664 |
^ aSelectorString |
926 | 2665 |
]. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2666 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2667 |
ok := rec respondsTo:sym. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2668 |
ok ifFalse:[ |
1022 | 2669 |
selClass := rec class. |
798
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2670 |
sCls := rec class. |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2671 |
[sCls notNil and:[sCls ~~ Object]] whileTrue:[ |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2672 |
"if it implements #doesNotUnderstand somewhere, assume its ok" |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2673 |
(sCls implements:#doesNotUnderstand:) ifTrue:[ |
1022 | 2674 |
^ aSelectorString |
798
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2675 |
]. |
5b1da806cdf6
no selector warning if doesNotUnderstand is redefined.
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
2676 |
sCls := sCls superclass |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2677 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2678 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2679 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2680 |
err := ' may not be understood here (is currently ' , rec classNameWithArticle , ')'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2681 |
] ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2682 |
"if its a super send, we can do more checking" |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2683 |
receiver isSuper ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2684 |
receiver isHere ifFalse:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2685 |
((superCls := classToCompileFor superclass) notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2686 |
and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2687 |
err := ' is currently not implemented in any superclass'. |
1022 | 2688 |
ok := false. |
2689 |
selClass := superCls. |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2690 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2691 |
] ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2692 |
(classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2693 |
err := ' is currently not implemented in this class'. |
1022 | 2694 |
ok := false. |
2695 |
selClass := classToCompileFor. |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2696 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2697 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2698 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2699 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2700 |
(receiver isUnaryMessage |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2701 |
and:[receiver selector == #class |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2702 |
and:[receiver receiver type == #Self]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2703 |
"its a message to self class - can check this too ..." |
1022 | 2704 |
selClass := classToCompileFor class. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2705 |
(classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2706 |
ok := false. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2707 |
classToCompileFor allSubclasses do:[:subclass | |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2708 |
(subclass class implements:sym) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2709 |
ok := true |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2710 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2711 |
]. |
944
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2712 |
sCls := classToCompileFor class. |
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2713 |
[sCls notNil and:[sCls ~~ Object]] whileTrue:[ |
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2714 |
"if it implements #doesNotUnderstand somewhere, assume its ok" |
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2715 |
(sCls implements:#doesNotUnderstand:) ifTrue:[ |
1022 | 2716 |
^ aSelectorString |
944
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2717 |
]. |
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2718 |
sCls := sCls superclass |
992e734d878b
if its a class message, also check for redefined doesNotUnderstand.
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2719 |
]. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2720 |
err := ' is currently not implemented in the class'. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2721 |
] |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2722 |
] ifFalse:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2723 |
"if it is an uninitialized variable ..." |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2724 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2725 |
(receiver type == #MethodVariable) ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2726 |
(modifiedLocalVars isNil |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2727 |
or:[(modifiedLocalVars includes:receiver name) not]) ifTrue:[ |
1008
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2728 |
(alreadyWarnedUninitializedVars isNil |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2729 |
or:[(alreadyWarnedUninitializedVars includes:receiver name) not]) ifTrue:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2730 |
(#( #'at:' #'at:put:' #'basicAt:' #'basicAt:put:' |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2731 |
) includes:sym) ifTrue:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2732 |
ok := false |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2733 |
] ifFalse:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2734 |
ok := nil respondsTo:sym. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2735 |
]. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2736 |
"/ avoid trouble in miniTalk |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2737 |
"/ during bootstrap |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2738 |
Text notNil ifTrue:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2739 |
err := ' sent to possibly uninitialized variable ''' , receiver name asText allBold , ''' here'. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2740 |
] ifFalse:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2741 |
err := ' sent to possibly uninitialized variable ''' , receiver name , ''' here'. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2742 |
]. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2743 |
alreadyWarnedUninitializedVars isNil ifTrue:[ |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2744 |
alreadyWarnedUninitializedVars := Set new |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2745 |
]. |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2746 |
alreadyWarnedUninitializedVars add:receiver name |
88d4d5002fb8
only warn once for possibly uninitialized vars
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2747 |
] |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2748 |
] |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
2749 |
]. |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2750 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2751 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2752 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2753 |
] |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2754 |
] |
141 | 2755 |
]. |
2756 |
||
2757 |
ok ifFalse:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2758 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2759 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2760 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2761 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2762 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2763 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2764 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2765 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2766 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2767 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 2768 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2769 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2770 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2771 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2772 |
"/ it may work after loading/defining |
1022 | 2773 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2774 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2775 |
]. |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2776 |
Text isNil ifTrue:[ |
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2777 |
err := aSelectorString , err |
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2778 |
] ifFalse:[ |
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2779 |
err := aSelectorString asText allBold , err |
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2780 |
]. |
1022 | 2781 |
newSelector := self correctSelector:aSelectorString |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
2782 |
message:err position:pos1 to:pos2 in:selClass. |
1022 | 2783 |
"/ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2. |
2784 |
^ newSelector. |
|
141 | 2785 |
]. |
1022 | 2786 |
^ aSelectorString |
141 | 2787 |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
2788 |
"Modified: / 5.9.1995 / 17:02:11 / claus" |
1022 | 2789 |
"Modified: / 19.1.2000 / 16:34:03 / cg" |
0 | 2790 |
! ! |
2791 |
||
2792 |
!Parser methodsFor:'error handling'! |
|
2793 |
||
141 | 2794 |
exitWith:something |
2795 |
"this is the longjump out of evaluation via a return expression" |
|
2796 |
||
2797 |
evalExitBlock value:something |
|
2798 |
! |
|
2799 |
||
2800 |
identifierExpectedIn:what |
|
2801 |
|msg| |
|
2802 |
||
2803 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
2804 |
msg := 'Reserved keyword in ' |
|
2805 |
] ifFalse:[ |
|
2806 |
msg := 'Identifier expected in ' |
|
2807 |
]. |
|
2808 |
self syntaxError:msg , what position:tokenPosition to:source position - 1. |
|
2809 |
^ #Error |
|
2810 |
! |
|
2811 |
||
0 | 2812 |
showErrorMessage:aMessage position:pos |
19 | 2813 |
"redefined since parser can give more detailed info about |
2814 |
the class & selector where the error occured." |
|
2815 |
||
71 | 2816 |
|text| |
2817 |
||
19 | 2818 |
ignoreErrors ifFalse:[ |
619 | 2819 |
Smalltalk silentLoading == true ifFalse:[ |
2820 |
Transcript show:(pos printString). |
|
2821 |
Transcript show:' '. |
|
2822 |
selector notNil ifTrue:[ |
|
2823 |
Transcript show:aMessage. |
|
2824 |
classToCompileFor notNil ifTrue:[ |
|
2825 |
text := ' in ' , classToCompileFor name , '>>' , selector |
|
2826 |
] ifFalse:[ |
|
2827 |
text := ' in ' , selector |
|
2828 |
] |
|
2829 |
] ifFalse:[ |
|
2830 |
classToCompileFor notNil ifTrue:[ |
|
2831 |
text := aMessage , ' (' , classToCompileFor name , ')' |
|
2832 |
] ifFalse:[ |
|
2833 |
text := aMessage |
|
2834 |
] |
|
2835 |
]. |
|
2836 |
Transcript showCR:text. |
|
2837 |
] |
|
0 | 2838 |
] |
273 | 2839 |
|
2840 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 2841 |
! |
2842 |
||
171 | 2843 |
showErrorMessageForClass:aClass |
2844 |
"/ compiler parseError:'syntax error'. |
|
2845 |
Transcript show:' '. |
|
2846 |
aClass notNil ifTrue:[ |
|
619 | 2847 |
Transcript show:aClass name , '>>' |
171 | 2848 |
]. |
2849 |
selector notNil ifTrue:[ |
|
619 | 2850 |
Transcript show:(selector) |
171 | 2851 |
]. |
273 | 2852 |
Transcript showCR:' -> Error'. |
171 | 2853 |
|
2854 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 2855 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 2856 |
! |
2857 |
||
0 | 2858 |
undefError:aName position:pos1 to:pos2 |
3 | 2859 |
"report an undefined variable error - return true, if it should be |
86 | 2860 |
corrected. If not corrected, only one warning is made per undefined |
2861 |
variable." |
|
2862 |
||
429 | 2863 |
|doCorrect msg idx| |
86 | 2864 |
|
607 | 2865 |
warnUndeclared ifFalse:[^ false]. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2866 |
ignoreWarnings ifTrue:[^ false]. |
607 | 2867 |
|
86 | 2868 |
" |
2869 |
alredy warned about this one ? |
|
2870 |
" |
|
2871 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 2872 |
(warnedUndefVars includes:aName) ifTrue:[ |
2873 |
"already warned about this one" |
|
2874 |
^ false |
|
2875 |
]. |
|
86 | 2876 |
]. |
2877 |
||
131 | 2878 |
"/ (classToCompileFor notNil |
2879 |
"/ and:[classToCompileFor superclass notNil |
|
2880 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
2881 |
"/ 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
|
2882 |
"/ ^ false |
131 | 2883 |
"/ ]. |
2884 |
||
2885 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
|
877 | 2886 |
aName first isUppercase ifFalse:[ |
2887 |
self showErrorMessage:('Error: ''' , aName , ''' is undefined') position:pos1. |
|
2888 |
]. |
|
2889 |
doCorrect := false. |
|
86 | 2890 |
] ifFalse:[ |
877 | 2891 |
" |
2892 |
ask requestor for correct/continue/abort ... |
|
2893 |
it is supposed to raise abort or return true/false. |
|
2894 |
True return means that correction is wanted. |
|
2895 |
" |
|
2896 |
msg := 'Warning: ''' , aName , ''' is undefined'. |
|
2897 |
classToCompileFor notNil ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2898 |
"/ is it an instance-variable marked inaccessable ? |
877 | 2899 |
|
2900 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
2901 |
idx ~~ 0 ifTrue:[ |
|
2902 |
msg := 'Warning: ' , aName , ' is a hidden instvar (not accessable from ST-code)'. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2903 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2904 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2905 |
"/ is it an instance variable, while evaluateing for the class ? |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2906 |
classToCompileFor isMeta ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2907 |
(classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2908 |
msg := 'Warning: ' , aName , ' is an instvar\(hint: you are evaluating/compiling in the classes context)' withCRs. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2909 |
] |
877 | 2910 |
] |
2911 |
]. |
|
2912 |
||
2913 |
doCorrect := self correctableError:msg position:pos1 to:pos2 |
|
86 | 2914 |
]. |
2915 |
||
877 | 2916 |
doCorrect == false ifTrue:[ |
2917 |
warnedUndefVars isNil ifTrue:[ |
|
2918 |
warnedUndefVars := Set new. |
|
2919 |
]. |
|
2920 |
warnedUndefVars add:aName. |
|
3 | 2921 |
]. |
0 | 2922 |
|
86 | 2923 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
2924 |
|
607 | 2925 |
"Modified: 7.9.1997 / 02:14:36 / cg" |
0 | 2926 |
! ! |
2927 |
||
2928 |
!Parser methodsFor:'parsing'! |
|
2929 |
||
141 | 2930 |
block |
2931 |
"parse a block; return a node-tree, nil or #Error" |
|
2932 |
||
883 | 2933 |
|node args argNames arg pos pos2 lno| |
141 | 2934 |
|
2935 |
lno := tokenLineNr. |
|
2936 |
self nextToken. |
|
2937 |
(tokenType == $: ) ifTrue:[ |
|
663 | 2938 |
[tokenType == $:] whileTrue:[ |
2939 |
pos := tokenPosition. |
|
2940 |
self nextToken. |
|
883 | 2941 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 2942 |
^ self identifierExpectedIn:'block-arg declaration' |
2943 |
]. |
|
883 | 2944 |
|
2945 |
pos2 := tokenPosition + tokenName size - 1. |
|
2946 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
663 | 2947 |
arg := Variable name:tokenName. |
2948 |
args isNil ifTrue:[ |
|
2949 |
args := Array with:arg. |
|
2950 |
argNames := Array with:tokenName. |
|
2951 |
] ifFalse:[ |
|
2952 |
(argNames includes:tokenName) ifTrue:[ |
|
883 | 2953 |
"/ argname reuse |
2954 |
self isSyntaxHighlighter ifTrue:[ |
|
2955 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
2956 |
] ifFalse:[ |
|
2957 |
self |
|
2958 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
2959 |
position:tokenPosition to:pos2 |
|
2960 |
] |
|
663 | 2961 |
]. |
2962 |
args := args copyWith:arg. |
|
2963 |
argNames := argNames copyWith:tokenName. |
|
2964 |
]. |
|
2965 |
self nextToken |
|
2966 |
]. |
|
2967 |
(tokenType ~~ $| ) ifTrue:[ |
|
2968 |
"ST-80 allows [:arg ]" |
|
2969 |
(tokenType == $] ) ifTrue:[ |
|
2970 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
2971 |
node lineNumber:lno. |
|
2972 |
^ node |
|
2973 |
]. |
|
2974 |
self syntaxError:'| expected after block-arg declaration'. |
|
2975 |
^ #Error |
|
2976 |
]. |
|
2977 |
self nextToken |
|
141 | 2978 |
]. |
2979 |
node := self blockBody:args. |
|
2980 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 2981 |
node lineNumber:lno. |
141 | 2982 |
]. |
2983 |
^ node |
|
663 | 2984 |
|
2985 |
"Modified: / 31.3.1998 / 17:31:34 / cg" |
|
141 | 2986 |
! |
2987 |
||
2988 |
blockBody:args |
|
2989 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
2990 |
||
883 | 2991 |
|stats node var vars lno names pos2| |
141 | 2992 |
|
2993 |
lno := tokenLineNr. |
|
2994 |
(tokenType == $| ) ifTrue:[ |
|
668 | 2995 |
self nextToken. |
2996 |
[tokenType == $|] whileFalse:[ |
|
2997 |
(tokenType == #Identifier) ifFalse:[ |
|
2998 |
^ self identifierExpectedIn:'block-var declaration' |
|
2999 |
]. |
|
883 | 3000 |
pos2 := tokenPosition + tokenName size - 1. |
3001 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
668 | 3002 |
var := Variable name:tokenName. |
3003 |
vars isNil ifTrue:[ |
|
3004 |
vars := Array with:var. |
|
3005 |
names := Array with:tokenName |
|
3006 |
] ifFalse:[ |
|
3007 |
(names includes:tokenName) ifTrue:[ |
|
883 | 3008 |
"/ varname reuse |
3009 |
self isSyntaxHighlighter ifTrue:[ |
|
3010 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3011 |
] ifFalse:[ |
|
3012 |
self |
|
3013 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3014 |
position:tokenPosition to:pos2. |
|
3015 |
] |
|
668 | 3016 |
] ifFalse:[ |
3017 |
vars := vars copyWith:var. |
|
3018 |
names := names copyWith:tokenName |
|
3019 |
] |
|
3020 |
]. |
|
3021 |
self nextToken. |
|
3022 |
]. |
|
3023 |
self nextToken |
|
141 | 3024 |
]. |
382 | 3025 |
|
141 | 3026 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
3027 |
node lineNumber:lno. |
|
3028 |
currentBlock := node. |
|
3029 |
stats := self blockStatementList. |
|
382 | 3030 |
lineNumberInfo == #full ifTrue:[ |
668 | 3031 |
node endLineNumber:tokenLineNr |
382 | 3032 |
]. |
141 | 3033 |
node statements:stats. |
3034 |
currentBlock := node home. |
|
3035 |
(stats == #Error) ifTrue:[^ #Error]. |
|
3036 |
^ node |
|
382 | 3037 |
|
668 | 3038 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 3039 |
! |
3040 |
||
3041 |
blockExpression |
|
3042 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
3043 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
3044 |
||
3045 |
tokenType ~~ $[ ifTrue:[ |
|
3046 |
self syntaxError:'[ expected'. |
|
3047 |
^ #Error. |
|
3048 |
]. |
|
3049 |
^ self block |
|
3050 |
! |
|
3051 |
||
3052 |
blockStatementList |
|
3053 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
3054 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3055 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 3056 |
|
3057 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
3058 |
thisStatement := self statement. |
|
3059 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3060 |
firstStatement := thisStatement. |
|
3061 |
[tokenType == $] ] whileFalse:[ |
|
673 | 3062 |
(tokenType == $.) ifFalse:[ |
3063 |
((tokenType == #EOF) or:[tokenType == $)]) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3064 |
eMsg := 'missing '']'' in block' |
673 | 3065 |
] ifFalse:[ |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3066 |
eMsg := 'missing ''.'' between statements (i.e. ' , tokenType printString , ' token unexpected)' |
673 | 3067 |
]. |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3068 |
self syntaxError:eMsg "position:tokenPosition". |
673 | 3069 |
^ #Error |
3070 |
] ifTrue:[ |
|
3071 |
prevStatement := thisStatement. |
|
3072 |
self nextToken. |
|
3073 |
tokenType == $] ifTrue:[ |
|
141 | 3074 |
" |
673 | 3075 |
*** I had a warning here (since it was not defined |
3076 |
*** in the blue-book; but PD-code contains a lot of |
|
3077 |
*** code with periods at the end so that the warnings |
|
3078 |
*** became annoying |
|
3079 |
||
3080 |
self warning:'period after last statement in block'. |
|
141 | 3081 |
" |
673 | 3082 |
self markBracketAt:tokenPosition. |
3083 |
^ firstStatement |
|
3084 |
]. |
|
3085 |
thisStatement := self statement. |
|
3086 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3087 |
prevStatement nextStatement:thisStatement |
|
3088 |
] |
|
141 | 3089 |
]. |
673 | 3090 |
self markBracketAt:tokenPosition. |
141 | 3091 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3092 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3093 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 3094 |
! |
3095 |
||
1006 | 3096 |
parseExpressionWithSelf:anObject notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
3097 |
"parse aString as an expression with self set to anObject; |
|
3098 |
Return the parseTree (if ok), nil (for an empty string |
|
3099 |
or comment only ) or #Error (syntactic error). |
|
3100 |
||
3101 |
Errors and warnings are forwarded to someOne (usually some |
|
3102 |
codeView) which can highlight it and show a popup box, |
|
3103 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
3104 |
||
3105 |
|tree token| |
|
3106 |
||
3107 |
aNameSpaceOrNil notNil ifTrue:[ |
|
3108 |
self currentNameSpace:aNameSpaceOrNil |
|
3109 |
]. |
|
3110 |
self setSelf:anObject. |
|
3111 |
self notifying:someOne. |
|
3112 |
ignoreErrors ifTrue:[self ignoreErrors]. |
|
3113 |
ignoreWarnings ifTrue:[self ignoreWarnings]. |
|
3114 |
token := self nextToken. |
|
3115 |
(token == $^) ifTrue:[ |
|
3116 |
self nextToken. |
|
3117 |
]. |
|
3118 |
tree := self expression. |
|
3119 |
(self errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
3120 |
^ tree |
|
3121 |
||
3122 |
"Created: / 14.12.1999 / 15:11:37 / cg" |
|
3123 |
! |
|
3124 |
||
0 | 3125 |
parseMethod |
19 | 3126 |
"parse a method. |
3127 |
Return the parseTree or #Error. |
|
3128 |
||
3129 |
method ::= methodSpec methodBody |
|
3130 |
" |
|
0 | 3131 |
|
3132 |
|parseTree| |
|
3133 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3134 |
"/ self nextToken. |
0 | 3135 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
3136 |
parseTree := self parseMethodBody. |
|
3137 |
(parseTree == #Error) ifFalse:[ |
|
619 | 3138 |
self tree:parseTree |
0 | 3139 |
]. |
3140 |
^ parseTree |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3141 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3142 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 3143 |
! |
3144 |
||
19 | 3145 |
parseMethodBody |
3146 |
"parse a methods body (locals & statements). |
|
3147 |
No more tokens may follow. |
|
3148 |
Return a node-tree, or #Error |
|
3149 |
||
3150 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 3151 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 3152 |
|
3153 |
" |
|
429 | 3154 |
|stats| |
19 | 3155 |
|
883 | 3156 |
"/ classToCompileFor notNil ifTrue:[ |
3157 |
"/ stats := self parseMethodBodyOrEmpty. |
|
3158 |
"/ ] ifFalse:[ |
|
3159 |
stats := self parseMethodBodyOrEmpty. |
|
3160 |
"/ ]. |
|
19 | 3161 |
(stats == #Error) ifFalse:[ |
883 | 3162 |
(tokenType ~~ #EOF) ifTrue:[ |
3163 |
"/ just for the nicer error message |
|
3164 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
|
3165 |
self parseError:tokenName , ' unexpected (missing ''.'' before ' , tokenName , ' ?)' |
|
3166 |
position:tokenPosition to:(tokenPosition + tokenName size - 1) |
|
3167 |
] ifFalse:[ |
|
3168 |
self parseError:(tokenType printString , ' unexpected (missing ''.'' or selector before it ?)') |
|
3169 |
position:tokenPosition to:source position-1. |
|
3170 |
]. |
|
3171 |
^#Error |
|
3172 |
] |
|
19 | 3173 |
]. |
3174 |
^ stats |
|
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3175 |
|
619 | 3176 |
"Modified: 14.10.1997 / 20:53:17 / cg" |
19 | 3177 |
! |
3178 |
||
79 | 3179 |
parseMethodBodyOrEmpty |
0 | 3180 |
"parse a methods body (locals & statements); |
19 | 3181 |
return a node-tree, nil or #Error. |
3182 |
empty (or comment only) input is accepted and returns nil. |
|
3183 |
||
3184 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
619 | 3185 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
3186 |
| <empty> |
|
19 | 3187 |
" |
0 | 3188 |
|
265 | 3189 |
|stats| |
0 | 3190 |
|
3191 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
3192 |
||
3193 |
(tokenType ~~ #EOF) ifTrue:[ |
|
619 | 3194 |
stats := self statementList |
0 | 3195 |
]. |
3196 |
^ stats |
|
265 | 3197 |
|
3198 |
"Modified: 27.4.1996 / 16:57:56 / cg" |
|
0 | 3199 |
! |
3200 |
||
19 | 3201 |
parseMethodBodyVarSpec |
265 | 3202 |
"parse a methods local variable specification, handling |
3203 |
possible primitive or resourceSpecs. |
|
3204 |
. |
|
19 | 3205 |
Leave spec of locals in methodLocals as a side effect. |
3206 |
Return #Error or nil. |
|
0 | 3207 |
|
19 | 3208 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 3209 |
| <empty> |
19 | 3210 |
" |
0 | 3211 |
|
883 | 3212 |
|var pos pos2 msg| |
0 | 3213 |
|
265 | 3214 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 3215 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 3216 |
]. |
3217 |
||
0 | 3218 |
(tokenType == $|) ifTrue:[ |
663 | 3219 |
"memorize position for declaration in correction" |
883 | 3220 |
|
663 | 3221 |
localVarDefPosition := tokenPosition. |
3222 |
self nextToken. |
|
3223 |
pos := tokenPosition. |
|
3224 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 3225 |
pos2 := tokenPosition + tokenName size - 1. |
3226 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
663 | 3227 |
var := Variable name:tokenName. |
883 | 3228 |
|
663 | 3229 |
methodVars isNil ifTrue:[ |
3230 |
methodVars := OrderedCollection with:var. |
|
3231 |
methodVarNames := OrderedCollection with:tokenName |
|
3232 |
] ifFalse:[ |
|
3233 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 3234 |
"/ redefinition |
3235 |
self isSyntaxHighlighter ifTrue:[ |
|
3236 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3237 |
] ifFalse:[ |
|
3238 |
self |
|
3239 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3240 |
position:tokenPosition to:pos2. |
|
3241 |
] |
|
663 | 3242 |
] ifFalse:[ |
3243 |
methodVars add:var. |
|
3244 |
methodVarNames add:tokenName |
|
3245 |
] |
|
3246 |
]. |
|
883 | 3247 |
|
663 | 3248 |
methodArgNames notNil ifTrue:[ |
3249 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
883 | 3250 |
self |
3251 |
warning:'local variable ''' , tokenName , ''' hides argument.' |
|
3252 |
position:tokenPosition to:pos2 |
|
663 | 3253 |
] |
3254 |
]. |
|
3255 |
self nextToken. |
|
3256 |
pos := tokenPosition |
|
3257 |
]. |
|
883 | 3258 |
|
663 | 3259 |
(tokenType ~~ $|) ifTrue:[ |
3260 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
883 | 3261 |
msg := 'Reserved keyword in local var declaration'. |
3262 |
pos2 := tokenPosition + tokenName size - 1. |
|
3263 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 3264 |
] ifFalse:[ |
883 | 3265 |
pos2 := source position-1. |
663 | 3266 |
msg := 'Identifier or | expected in local var declaration' |
3267 |
]. |
|
883 | 3268 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 3269 |
^ #Error |
3270 |
]. |
|
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3271 |
localVarDefPosition := Array with:localVarDefPosition with:tokenPosition. |
663 | 3272 |
self nextToken |
0 | 3273 |
]. |
984 | 3274 |
|
3275 |
AllowSqueakExtensions ifTrue:[ |
|
3276 |
"/ allow for primitiveSpec after local-var decl. |
|
3277 |
||
3278 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
|
3279 |
self parsePrimitiveOrResourceSpecOrEmpty. |
|
3280 |
] |
|
3281 |
]. |
|
3282 |
||
0 | 3283 |
^ nil |
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
3284 |
|
663 | 3285 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 3286 |
! |
3287 |
||
141 | 3288 |
parseMethodSpec |
3289 |
"parse a methods selector & arg specification; |
|
3290 |
Set selector and methodArgs in the receiver as a side effect. |
|
3291 |
Return the receiver or #Error. |
|
3292 |
||
3293 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3294 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3295 |
| IDENTIFIER |
141 | 3296 |
" |
3297 |
||
883 | 3298 |
|var pos2| |
141 | 3299 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3300 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3301 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3302 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3303 |
|
141 | 3304 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3305 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3306 |
[tokenType == #Keyword] whileTrue:[ |
663 | 3307 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3308 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3309 |
self nextToken. |
883 | 3310 |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3311 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
883 | 3312 |
pos2 := tokenPosition+tokenName size-1. |
3313 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3314 |
var := Variable name:tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3315 |
methodArgs isNil ifTrue:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3316 |
methodArgs := Array with:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3317 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3318 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3319 |
(methodArgNames includes:tokenName) ifTrue:[ |
883 | 3320 |
"/ argname reuse |
3321 |
self isSyntaxHighlighter ifTrue:[ |
|
3322 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3323 |
] ifFalse:[ |
|
3324 |
self |
|
3325 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3326 |
position:tokenPosition to:pos2 |
|
3327 |
] |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3328 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3329 |
methodArgs := methodArgs copyWith:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3330 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3331 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3332 |
self nextToken |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3333 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3334 |
selector := selector asSymbol. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3335 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3336 |
^ self |
141 | 3337 |
]. |
3338 |
(tokenType == #Identifier) ifTrue:[ |
|
663 | 3339 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3340 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3341 |
self nextToken. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3342 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3343 |
^ self |
141 | 3344 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3345 |
|
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3346 |
"/ 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
|
3347 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3348 |
tokenType := #BinaryOperator. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
3349 |
token := tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3350 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3351 |
|
141 | 3352 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 3353 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3354 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3355 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3356 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
663 | 3357 |
self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3358 |
var := Variable name:tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3359 |
|
141 | 3360 |
"/ methodArgs isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3361 |
methodArgs := Array with:var. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3362 |
methodArgNames := Array with:tokenName. |
141 | 3363 |
"/ ] ifFalse:[ |
3364 |
"/ methodArgs := methodArgs copyWith:var. |
|
3365 |
"/ methodArgNames := methodArgNames copyWith:tokenName |
|
3366 |
"/ ]. |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3367 |
self nextToken. |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
3368 |
endOfSelectorPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
3369 |
^ self |
141 | 3370 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
3371 |
|
141 | 3372 |
^ #Error |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
3373 |
|
663 | 3374 |
"Modified: / 31.3.1998 / 17:31:59 / cg" |
141 | 3375 |
! |
3376 |
||
897 | 3377 |
parsePrimitive |
7 | 3378 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
19 | 3379 |
return primitive number or #Error. |
897 | 3380 |
or a Squeak-style primitive, as '< primitive: string >'; |
3381 |
return primitive name or #Error. |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3382 |
|
97 | 3383 |
Also, ST-80 style resource specs are parsed; the result is |
3384 |
left (as side effect) in primitiveResource. |
|
3385 |
(maybe someone else knows what to do with it ...) |
|
3386 |
Well, as we now have this mechanism, I'll use it to mark methods which |
|
3387 |
do keyboard processing ... <resource: keyboard ( keys )> |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3388 |
For faster finding of used keyboard accelerators, |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3389 |
and to mark resource methods (image, menu or canvas resources). |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3390 |
|
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3391 |
prim ::= st80Primitive | st80Pragma | stxPragma |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3392 |
squeakPrimitive | resourceDecl |
19 | 3393 |
|
3394 |
st80Primitive ::= 'primitive:' INTEGER |
|
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3395 |
st80Pragma ::= 'exception:' ( 'handle | 'raise' | 'unwind' ) |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3396 |
stxPragma ::= 'context:' 'return' |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3397 |
|
897 | 3398 |
squeakPrimitive ::= 'primitive:' STRING |
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3399 |
|
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3400 |
resourceDecl ::= 'resource:' SYMBOL - leave SYMBOL in primitiveResource |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3401 |
| 'resource:' SYMBOL (...) - leave (SYMBOL (...)) in primitiveResource |
19 | 3402 |
" |
0 | 3403 |
|
1098
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3404 |
|primNumber keys resource resourceValue pragmaType cString cParser cType| |
0 | 3405 |
|
60 | 3406 |
(tokenType ~~ #Keyword) ifTrue:[ |
897 | 3407 |
self parseError:'bad primitive definition (keyword expected)'. |
3408 |
^ #Error |
|
0 | 3409 |
]. |
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3410 |
|
60 | 3411 |
(tokenName = 'primitive:') ifTrue:[ |
897 | 3412 |
self nextToken. |
3413 |
(tokenType == #Integer) ifFalse:[ |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3414 |
AllowSqueakExtensions ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3415 |
(tokenType == #String) ifFalse:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3416 |
self parseError:'primitive number or name expected'. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3417 |
^ #Error |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3418 |
] |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3419 |
] ifFalse:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3420 |
self parseError:'primitive number expected'. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3421 |
^ #Error |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3422 |
] |
897 | 3423 |
]. |
3424 |
primitiveNr notNil ifTrue:[ |
|
3425 |
self parseError:'only one primitive spec allowed'. |
|
3426 |
primNumber := -1. |
|
3427 |
] ifFalse:[ |
|
3428 |
primNumber := tokenValue. |
|
3429 |
]. |
|
3430 |
self nextToken. |
|
1099 | 3431 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifFalse:[ |
3432 |
((tokenType == #Keyword) and:[tokenName = 'errorCode:']) ifTrue:[ |
|
3433 |
self nextToken. |
|
3434 |
(tokenType == #Identifier) ifTrue:[ |
|
3435 |
self nextToken. |
|
3436 |
] ifFalse:[ |
|
3437 |
self halt. |
|
3438 |
] |
|
3439 |
]. |
|
3440 |
] |
|
60 | 3441 |
] ifFalse:[ |
897 | 3442 |
(tokenName = 'resource:') ifTrue:[ |
3443 |
self nextToken. |
|
3444 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
3445 |
self parseError:'symbol expected'. |
|
3446 |
^ #Error |
|
3447 |
]. |
|
3448 |
primNumber := -1. |
|
3449 |
resource := tokenValue. |
|
3450 |
resourceValue := true. |
|
3451 |
||
3452 |
self nextToken. |
|
3453 |
||
3454 |
tokenType == $( ifTrue:[ |
|
3455 |
self nextToken. |
|
3456 |
keys := OrderedCollection new. |
|
1036 | 3457 |
[(tokenType == $)) or:[tokenType == #EOF] ] whileFalse:[ |
897 | 3458 |
keys add:tokenValue. |
3459 |
self nextToken. |
|
3460 |
]. |
|
3461 |
resourceValue := keys. |
|
1036 | 3462 |
(tokenType == $)) ifFalse:[ |
3463 |
self parseError:'unterminated primitive/spec (missing '')'')'. |
|
3464 |
]. |
|
897 | 3465 |
self nextToken. |
3466 |
]. |
|
3467 |
||
3468 |
primitiveResource isNil ifTrue:[ |
|
3469 |
primitiveResource := IdentityDictionary new. |
|
3470 |
]. |
|
3471 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
3472 |
] ifFalse:[ |
|
938 | 3473 |
(tokenName = 'exception:' |
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3474 |
or:[tokenName = 'context:']) ifTrue:[ |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3475 |
pragmaType := tokenName. |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3476 |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3477 |
self nextToken. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3478 |
(tokenType ~~ #Symbol) ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3479 |
self parseError:'symbol expected'. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3480 |
^ #Error |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3481 |
]. |
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3482 |
|
938 | 3483 |
((pragmaType = 'exception:' |
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3484 |
and:[tokenValue == #'handle' |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3485 |
or:[tokenValue == #'raise' |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3486 |
or:[tokenValue == #'unwind']]]) |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3487 |
or:[ |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3488 |
pragmaType = 'context:' |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3489 |
and:[(tokenValue == #'return')]]) |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3490 |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3491 |
ifTrue:[ |
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3492 |
primitiveContextInfo isNil ifTrue:[ |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3493 |
primitiveContextInfo := Set new. |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3494 |
]. |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
3495 |
primitiveContextInfo add:(pragmaType->tokenValue). |
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3496 |
] ifFalse:[ |
938 | 3497 |
self parseError:'unrecognized exception pragma: ' , tokenValue. |
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3498 |
]. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3499 |
self nextToken. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3500 |
] ifFalse:[ |
1098
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3501 |
(tokenName = 'C:') ifTrue:[ |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3502 |
cString := source upTo:$>. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3503 |
self nextToken. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3504 |
"/ generate that type |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3505 |
cParser := CParser parse:(cString , ';'). |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3506 |
cType := cParser types first. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3507 |
primitiveResource "primitiveType" := cType. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3508 |
^ -1 |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3509 |
] ifFalse:[ |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3510 |
self parseError:'unrecognized pragma: ' , tokenName. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3511 |
|
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3512 |
"/ skip |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3513 |
[tokenType ~~ #EOF] whileTrue:[ |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3514 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3515 |
self nextToken. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3516 |
^ -1 "/ primNr. |
fe08dc90f4ac
preps for <C: ...> - interface declaration
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3517 |
]. |
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3518 |
self nextToken. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3519 |
]. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3520 |
]. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3521 |
] |
897 | 3522 |
]. |
0 | 3523 |
]. |
97 | 3524 |
|
0 | 3525 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifFalse:[ |
897 | 3526 |
self parseError:'bad primitive definition (> expected)'. |
3527 |
^ #Error |
|
0 | 3528 |
]. |
3529 |
self nextToken. |
|
3530 |
^ primNumber |
|
221
35b92bf6d9ef
parse style-resource directive
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
3531 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
3532 |
"Modified: 29.5.1996 / 17:24:09 / cg" |
0 | 3533 |
! |
3534 |
||
897 | 3535 |
parsePrimitiveOrResourceSpecOrEmpty |
3536 |
"parse a methods primitive or resource spec" |
|
3537 |
||
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3538 |
|pos wmsg primNr primNrOrString| |
897 | 3539 |
|
3540 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
|
3541 |
"/ an ST-80 primitive or resourceSpec - parsed but ignored |
|
3542 |
||
3543 |
pos := tokenPosition. |
|
3544 |
self nextToken. |
|
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3545 |
primNrOrString := self parsePrimitive. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3546 |
|
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3547 |
(primNrOrString == #Error) ifTrue:[^ #Error]. |
897 | 3548 |
wmsg := nil. |
3549 |
||
930
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3550 |
primNrOrString isString ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3551 |
primNr := self primitiveNumberFromName:primNrOrString |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3552 |
] ifFalse:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3553 |
primNr := primNrOrString |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3554 |
]. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3555 |
|
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3556 |
primNr notNil ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3557 |
primNr < 0 ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3558 |
WarnST80Directives == true ifTrue:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3559 |
wmsg := 'ST-80/Squeak directive ignored'. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3560 |
]. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3561 |
] ifFalse:[ |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3562 |
primitiveNr := primNr. |
2dadf9a83ed9
also parse #exception pragmas;
Claus Gittinger <cg@exept.de>
parents:
926
diff
changeset
|
3563 |
wmsg := 'ST-80 primitive may not work' |
897 | 3564 |
]. |
3565 |
]. |
|
3566 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
|
3567 |
]. |
|
3568 |
||
3569 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
3570 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
|
3571 |
! |
|
3572 |
||
984 | 3573 |
primitiveNumberFromName:aPrimitiveName |
3574 |
"for future compatibility with Squeak ..." |
|
3575 |
||
3576 |
^ nil |
|
3577 |
! |
|
3578 |
||
713 | 3579 |
statement |
3580 |
"parse a statement; return a node-tree or #Error. |
|
3581 |
||
3582 |
statement ::= '^' expression |
|
3583 |
| PRIMITIVECODE |
|
3584 |
| expression |
|
3585 |
" |
|
3586 |
||
3587 |
|expr node lnr| |
|
3588 |
||
3589 |
(tokenType == $^) ifTrue:[ |
|
837 | 3590 |
self markReturnAt:tokenPosition. |
713 | 3591 |
lnr := tokenLineNr. |
3592 |
self nextToken. |
|
3593 |
expr := self expression. |
|
3594 |
(expr == #Error) ifTrue:[^ #Error]. |
|
3595 |
node := ReturnNode expression:expr. |
|
3596 |
node home:self blockHome:currentBlock. |
|
3597 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
3598 |
^ node |
|
3599 |
]. |
|
3600 |
||
3601 |
(tokenType == #Primitive) ifTrue:[ |
|
3602 |
self nextToken. |
|
3603 |
node := PrimitiveNode code:tokenValue. |
|
3604 |
node isOptional ifFalse:[ |
|
3605 |
hasNonOptionalPrimitiveCode := true |
|
3606 |
]. |
|
3607 |
hasPrimitiveCode := true. |
|
3608 |
^ node |
|
3609 |
]. |
|
3610 |
||
3611 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3612 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3613 |
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
|
3614 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3615 |
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
|
3616 |
]. |
713 | 3617 |
^ #Error |
3618 |
]. |
|
3619 |
||
984 | 3620 |
(tokenType == $.) ifTrue:[ |
3621 |
AllowSqueakExtensions == true ifTrue:[ |
|
3622 |
"/ allow empty statement |
|
3623 |
^ StatementNode expression:nil. |
|
3624 |
]. |
|
3625 |
]. |
|
3626 |
||
713 | 3627 |
expr := self expression. |
3628 |
(expr == #Error) ifTrue:[^ #Error]. |
|
3629 |
||
3630 |
"/ classToCompileFor notNil ifTrue:[ |
|
3631 |
"/ currentBlock isNil ifTrue:[ |
|
3632 |
"/ expr isPrimary ifTrue:[ |
|
3633 |
"/ self warning:'useless computation - missing ^ ?' |
|
3634 |
"/ ] |
|
3635 |
"/ ] |
|
3636 |
"/ ]. |
|
3637 |
||
3638 |
node := StatementNode expression:expr. |
|
3639 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
3640 |
^ node |
|
3641 |
||
837 | 3642 |
"Modified: / 5.1.1980 / 00:45:20 / cg" |
713 | 3643 |
! |
3644 |
||
3645 |
statementList |
|
3646 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
3647 |
Statements must be separated by periods. |
|
3648 |
||
3649 |
statementList ::= <statement> |
|
988 | 3650 |
| <statementList> . <statement> |
713 | 3651 |
" |
3652 |
||
3653 |
|thisStatement prevStatement firstStatement correctIt periodPos |
|
3654 |
prevExpr| |
|
3655 |
||
3656 |
thisStatement := self statement. |
|
3657 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3658 |
firstStatement := thisStatement. |
|
3659 |
[tokenType == $.] whileTrue:[ |
|
988 | 3660 |
prevExpr := thisStatement expression. |
3661 |
(prevExpr notNil |
|
3662 |
and:[prevExpr isMessage |
|
3663 |
and:[thisStatement isReturnNode not]]) ifTrue:[ |
|
3664 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
3665 |
self warning:'useless computation - mistyped assignment ?' |
|
3666 |
]. |
|
3667 |
]. |
|
3668 |
||
3669 |
periodPos := tokenPosition. |
|
3670 |
self nextToken. |
|
3671 |
(tokenType == $]) ifTrue:[ |
|
3672 |
currentBlock isNil ifTrue:[ |
|
3673 |
self parseError:'block nesting error'. |
|
3674 |
errorFlag := true |
|
713 | 3675 |
" |
988 | 3676 |
*** I had a warning here (since it was not defined |
3677 |
*** in the blue-book; but PD-code contains a lot of |
|
3678 |
*** code with periods at the end so that the warnings |
|
3679 |
*** became annoying |
|
3680 |
||
3681 |
] ifFalse:[ |
|
3682 |
self warning:'period after last statement' position:periodPos |
|
713 | 3683 |
" |
988 | 3684 |
]. |
3685 |
^ firstStatement |
|
3686 |
]. |
|
3687 |
(tokenType == #EOF) ifTrue:[ |
|
3688 |
currentBlock notNil ifTrue:[ |
|
3689 |
self parseError:'block nesting error (expected '']'')'. |
|
3690 |
errorFlag := true |
|
713 | 3691 |
" |
988 | 3692 |
*** I had a warning here (since it was not defined |
3693 |
*** in the blue-book; but PD-code contains a lot of |
|
3694 |
*** code with periods at the end so that the warnings |
|
3695 |
*** became annoying |
|
3696 |
||
3697 |
] ifFalse:[ |
|
3698 |
self warning:'period after last statement' position:periodPos |
|
713 | 3699 |
" |
988 | 3700 |
]. |
3701 |
^ firstStatement |
|
3702 |
]. |
|
3703 |
||
3704 |
prevStatement := thisStatement. |
|
3705 |
prevStatement isReturnNode ifTrue:[ |
|
3706 |
self warning:'statements after return' position:tokenPosition |
|
3707 |
]. |
|
713 | 3708 |
" |
988 | 3709 |
periodPos := tokenPosition. |
3710 |
self nextToken. |
|
713 | 3711 |
" |
3712 |
||
988 | 3713 |
((tokenType == $]) or:[tokenType == #EOF]) ifTrue:[ |
3714 |
(currentBlock isNil and:[tokenType == $]]) ifTrue:[ |
|
3715 |
self parseError:'block nesting error'. |
|
3716 |
errorFlag := true |
|
3717 |
] ifFalse:[ |
|
3718 |
correctIt := self correctableError:'period after last statement in block' |
|
3719 |
position:periodPos to:(periodPos + 1). |
|
3720 |
correctIt ifTrue:[ |
|
3721 |
(self correctByDeleting == #Error) ifTrue:[ |
|
3722 |
errorFlag := true |
|
3723 |
] |
|
3724 |
] |
|
3725 |
]. |
|
3726 |
^ firstStatement |
|
3727 |
]. |
|
3728 |
thisStatement := self statement. |
|
3729 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3730 |
prevStatement nextStatement:thisStatement |
|
713 | 3731 |
]. |
3732 |
^ firstStatement |
|
3733 |
||
3734 |
"Modified: 14.4.1997 / 20:46:46 / cg" |
|
3735 |
! ! |
|
3736 |
||
3737 |
!Parser methodsFor:'parsing-expressions'! |
|
3738 |
||
3739 |
array |
|
3740 |
|arr elements elem pos1| |
|
3741 |
||
3742 |
pos1 := tokenPosition. |
|
3743 |
elements := OrderedCollection new:20. |
|
3744 |
[tokenType ~~ $) ] whileTrue:[ |
|
1062 | 3745 |
ParseErrorSignal handle:[:ex | |
713 | 3746 |
^ #Error |
1062 | 3747 |
] do:[ |
3748 |
elem := self arrayConstant. |
|
713 | 3749 |
]. |
1062 | 3750 |
"/ (elem == #Error) ifTrue:[ |
3751 |
"/ (tokenType == #EOF) ifTrue:[ |
|
3752 |
"/ self syntaxError:'unterminated array-constant; '')'' expected' |
|
3753 |
"/ position:pos1 to:tokenPosition |
|
3754 |
"/ ]. |
|
3755 |
"/ ^ #Error |
|
3756 |
"/ ]. |
|
713 | 3757 |
elem isSymbol ifTrue:[ |
3758 |
self markSymbolFrom:tokenPosition to:(source position-1). |
|
3759 |
]. |
|
3760 |
elements add:elem. |
|
3761 |
self nextToken |
|
3762 |
]. |
|
3763 |
arr := Array withAll:elements. |
|
3764 |
||
3765 |
(ArraysAreImmutable and:[ImmutableArray notNil]) ifTrue:[ |
|
3766 |
arr changeClassTo:ImmutableArray. |
|
3767 |
]. |
|
3768 |
^ arr |
|
3769 |
||
3770 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
1062 | 3771 |
|
3772 |
||
713 | 3773 |
! |
3774 |
||
3775 |
arrayConstant |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3776 |
|val| |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3777 |
|
713 | 3778 |
(tokenType == #Nil) ifTrue:[ |
3779 |
^ nil |
|
3780 |
]. |
|
3781 |
((tokenType == #Integer) |
|
3782 |
or:[tokenType == #Float]) ifTrue:[ |
|
3783 |
^ tokenValue |
|
3784 |
]. |
|
3785 |
((tokenType == #String) |
|
3786 |
or:[tokenType == #Character]) ifTrue:[ |
|
3787 |
^ tokenValue |
|
3788 |
]. |
|
3789 |
(tokenType == #True) ifTrue:[ |
|
3790 |
^ true |
|
3791 |
]. |
|
3792 |
(tokenType == #False) ifTrue:[ |
|
3793 |
^ false |
|
3794 |
]. |
|
3795 |
(tokenType == #Error) ifTrue:[ |
|
1062 | 3796 |
^ ParseErrorSignal raise. |
713 | 3797 |
]. |
3798 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
3799 |
^ tokenName asSymbol |
|
3800 |
]. |
|
3801 |
||
3802 |
"/ some more special symbol consts ... |
|
3803 |
(tokenType == $| ) ifTrue:[ |
|
3804 |
^ #| |
|
3805 |
]. |
|
3806 |
(tokenType == #Self ) ifTrue:[ |
|
3807 |
^ #'self' |
|
3808 |
]. |
|
3809 |
(tokenType == #Super ) ifTrue:[ |
|
3810 |
^ #'super' |
|
3811 |
]. |
|
3812 |
(tokenType == #Here ) ifTrue:[ |
|
3813 |
^ #'here' |
|
3814 |
]. |
|
3815 |
(tokenType == #ThisContext ) ifTrue:[ |
|
3816 |
^ #'thisContext' |
|
3817 |
]. |
|
3818 |
||
3819 |
((tokenType == #Keyword) |
|
3820 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
3821 |
^ tokenName asSymbol |
|
3822 |
]. |
|
3823 |
((tokenType == $() |
|
3824 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
3825 |
self nextToken. |
|
3826 |
^ self array |
|
3827 |
]. |
|
3828 |
((tokenType == $[) |
|
3829 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
3830 |
self nextToken. |
|
3831 |
^ self byteArray |
|
3832 |
]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3833 |
(tokenType == #HashLeftBrace) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3834 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3835 |
val := QualifiedName for:val name. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3836 |
^ val |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
3837 |
]. |
713 | 3838 |
(tokenType == #Symbol) ifTrue:[ |
1066
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
3839 |
parseForCode ifFalse:[ |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
3840 |
self rememberSymbolUsed:tokenValue. |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
3841 |
]. |
713 | 3842 |
^ tokenValue |
3843 |
]. |
|
3844 |
(tokenType == #EOF) ifTrue:[ |
|
3845 |
"just for the better error-hilight; let caller handle error" |
|
1062 | 3846 |
^ ParseErrorSignal raise. |
713 | 3847 |
]. |
3848 |
self syntaxError:('error in array-constant; ' |
|
3849 |
, tokenType printString |
|
3850 |
, ' unexpected'). |
|
1062 | 3851 |
^ ParseErrorSignal raise. |
713 | 3852 |
|
3853 |
"Modified: / 14.4.1998 / 18:22:54 / cg" |
|
3854 |
! |
|
3855 |
||
3856 |
binaryExpression |
|
3857 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
3858 |
||
1061 | 3859 |
|receiver theReceiver arg sel pos try lno note| |
713 | 3860 |
|
3861 |
receiver := self unaryExpression. |
|
3862 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
3863 |
||
3864 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
3865 |
expression or a negative constant, handle cases here" |
|
3866 |
||
3867 |
[(tokenType == #BinaryOperator) |
|
3868 |
or:[(tokenType == $|) |
|
3869 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
3870 |
and:[tokenValue < 0]]] |
|
3871 |
] whileTrue:[ |
|
3872 |
pos := tokenPosition. |
|
3873 |
||
3874 |
lno := tokenLineNr. |
|
3875 |
||
3876 |
"kludge here: bar and minus are not scanned as binop " |
|
3877 |
(tokenType == $|) ifTrue:[ |
|
3878 |
sel := '|'. |
|
3879 |
self nextToken |
|
3880 |
] ifFalse:[ |
|
3881 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
3882 |
sel := tokenName. |
1022 | 3883 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
713 | 3884 |
self nextToken |
3885 |
] ifFalse:[ |
|
3886 |
sel := '-'. |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
3887 |
token := tokenValue := tokenValue negated |
713 | 3888 |
] |
3889 |
]. |
|
864 | 3890 |
self markSelector:sel from:pos to:(pos + sel size - 1) receiverNode:receiver. |
713 | 3891 |
|
3892 |
arg := self unaryExpression. |
|
3893 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1061 | 3894 |
theReceiver := receiver. |
713 | 3895 |
try := BinaryNode receiver:receiver selector:sel arg:arg fold:foldConstants. |
3896 |
(try isMemberOf:String) ifTrue:[ |
|
3897 |
self parseError:try position:pos to:tokenPosition. |
|
3898 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
3899 |
receiver := BinaryNode receiver:receiver selector:sel arg:arg fold:nil. |
|
3900 |
] ifFalse:[ |
|
3901 |
receiver := try |
|
3902 |
]. |
|
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
3903 |
note := self plausibilityCheck:receiver. |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
3904 |
note notNil ifTrue:[ |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
3905 |
self warning:note position:pos to:tokenPosition |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
3906 |
]. |
713 | 3907 |
receiver lineNumber:lno. |
3908 |
receiver selectorPosition:pos. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
3909 |
parseForCode ifFalse:[ |
1061 | 3910 |
self rememberSelectorUsed:sel receiver:theReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
3911 |
]. |
713 | 3912 |
]. |
3913 |
^ receiver |
|
3914 |
||
3915 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
1022 | 3916 |
"Modified: / 19.1.2000 / 16:22:04 / cg" |
713 | 3917 |
! |
3918 |
||
3919 |
byteArray |
|
3920 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
3921 |
||
3922 |
|bytes index limit newArray elem pos1 pos2| |
|
3923 |
||
3924 |
pos1 := tokenPosition. |
|
3925 |
bytes := ByteArray uninitializedNew:5000. |
|
3926 |
index := 0. limit := 5000. |
|
3927 |
[tokenType ~~ $] ] whileTrue:[ |
|
3928 |
pos2 := tokenPosition. |
|
3929 |
" |
|
3930 |
this is not good programming style, but speeds up |
|
3931 |
reading of huge byte arrays (i.e. stored Images ...) |
|
3932 |
" |
|
3933 |
(tokenType == #Integer) ifTrue:[ |
|
3934 |
elem := tokenValue |
|
3935 |
] ifFalse:[ |
|
3936 |
elem := self arrayConstant. |
|
3937 |
(elem == #Error) ifTrue:[ |
|
3938 |
(tokenType == #EOF) ifTrue:[ |
|
3939 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
3940 |
position:pos1 to:tokenPosition |
|
3941 |
]. |
|
3942 |
^ #Error |
|
3943 |
]. |
|
3944 |
]. |
|
3945 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
3946 |
index := index + 1. |
|
3947 |
bytes at:index put:elem. |
|
3948 |
index == limit ifTrue:[ |
|
3949 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
3950 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
3951 |
limit := limit * 2. |
|
3952 |
bytes := newArray |
|
3953 |
]. |
|
3954 |
] ifFalse:[ |
|
3955 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
3956 |
]. |
|
3957 |
self nextToken. |
|
3958 |
]. |
|
3959 |
newArray := ByteArray uninitializedNew:index. |
|
3960 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
3961 |
^ newArray |
|
3962 |
! |
|
3963 |
||
3964 |
degeneratedKeywordExpressionForSelector |
|
3965 |
"parse a keyword-expression without receiver - for the selector |
|
3966 |
only. return the selector or nil. This is not used in normal parsing, |
|
3967 |
but instead to extract the selector from a code fragment. |
|
3968 |
(for example, the system browsers implementors-function uses this)" |
|
3969 |
||
3970 |
|sel arg rec| |
|
3971 |
||
3972 |
(tokenType == #Keyword) ifTrue:[ |
|
3973 |
sel := tokenName. |
|
3974 |
self nextToken. |
|
3975 |
arg := self binaryExpression. |
|
3976 |
(arg == #Error) ifTrue:[^ sel]. |
|
3977 |
[tokenType == #Keyword] whileTrue:[ |
|
3978 |
sel := sel , tokenName. |
|
3979 |
self nextToken. |
|
3980 |
arg := self binaryExpression. |
|
3981 |
(arg == #Error) ifTrue:[^ sel]. |
|
3982 |
]. |
|
3983 |
^ sel |
|
3984 |
]. |
|
3985 |
||
3986 |
(rec := self primary) ~~ #Error ifTrue:[ |
|
3987 |
sel := self degeneratedKeywordExpressionForSelector. |
|
3988 |
sel isNil ifTrue:[ |
|
3989 |
rec isMessage ifTrue:[ |
|
3990 |
sel := rec selector |
|
3991 |
] ifFalse:[ |
|
3992 |
rec isAssignment ifTrue:[ |
|
3993 |
rec expression isMessage ifTrue:[ |
|
3994 |
sel := rec expression selector |
|
3995 |
] |
|
3996 |
] |
|
3997 |
] |
|
3998 |
] |
|
3999 |
]. |
|
4000 |
^ sel |
|
4001 |
! |
|
4002 |
||
4003 |
expression |
|
4004 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
4005 |
||
4006 |
expression ::= keywordExpression |
|
4007 |
| keywordExpression cascade |
|
4008 |
||
4009 |
cascade ::= ';' expressionSendPart |
|
4010 |
| cascade ';' expressionSendPart |
|
4011 |
||
4012 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
4013 |
| BINARYOPERATOR unaryExpression |
|
4014 |
| IDENTIFIER |
|
4015 |
" |
|
4016 |
||
864 | 4017 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 4018 |
|
4019 |
pos := tokenPosition. |
|
4020 |
receiver := self keywordExpression. |
|
4021 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
4022 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4023 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4024 |
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
|
4025 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4026 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4027 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4028 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4029 |
]. |
713 | 4030 |
[tokenType == $;] whileTrue:[ |
4031 |
self nextToken. |
|
4032 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4033 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4034 |
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
|
4035 |
sel := tokenName. |
1022 | 4036 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 4037 |
receiver := CascadeNode receiver:receiver selector:sel. |
4038 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4039 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4040 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4041 |
]. |
713 | 4042 |
self nextToken. |
4043 |
] ifFalse:[ |
|
4044 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4045 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4046 |
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
|
4047 |
sel := tokenName. |
1022 | 4048 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 4049 |
lno := tokenLineNr. |
4050 |
self nextToken. |
|
4051 |
arg := self unaryExpression. |
|
4052 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4053 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
4054 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4055 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4056 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4057 |
]. |
713 | 4058 |
] ifFalse:[ |
4059 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4060 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4061 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4062 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4063 |
pos2 := tokenEnd. |
713 | 4064 |
lno := tokenLineNr. |
4065 |
sel := tokenName. |
|
4066 |
self nextToken. |
|
4067 |
arg := self binaryExpression. |
|
4068 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4069 |
args := Array with:arg. |
|
4070 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4071 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 4072 |
positions add:(tokenPosition to:tokenEnd). |
713 | 4073 |
sel := sel , tokenName. |
4074 |
self nextToken. |
|
4075 |
arg := self binaryExpression. |
|
4076 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4077 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
4078 |
pos2 := tokenEnd |
713 | 4079 |
]. |
1022 | 4080 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
864 | 4081 |
|
4082 |
positions do:[:p | |
|
4083 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
4084 |
]. |
|
713 | 4085 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
4086 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4087 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4088 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4089 |
]. |
713 | 4090 |
] ifFalse:[ |
4091 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
4092 |
self syntaxError:('invalid cascade; ' , tokenType printString , ' unexpected') |
|
4093 |
position:tokenPosition to:source position - 1. |
|
4094 |
^ #Error |
|
4095 |
] |
|
4096 |
] |
|
4097 |
] |
|
4098 |
]. |
|
4099 |
||
4100 |
"obscure (unspecified ?) if selector follows; Question: |
|
4101 |
||
4102 |
is |
|
4103 |
'expr sel1; sel2 sel3' |
|
4104 |
||
4105 |
to be parsed as: |
|
4106 |
(t := expr. |
|
4107 |
t sel1. |
|
4108 |
t sel2) sel3 |
|
4109 |
||
4110 |
or: |
|
4111 |
(t := expr. |
|
4112 |
t sel1. |
|
4113 |
t sel2 sel3) |
|
4114 |
" |
|
4115 |
((tokenType == #Identifier) |
|
4116 |
or:[(tokenType == #BinaryOperator) |
|
4117 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
4118 |
self syntaxError:'ambigous cascade - please group using ( ...)' |
|
4119 |
position:tokenPosition to:source position - 1. |
|
4120 |
^ #Error |
|
4121 |
] |
|
4122 |
]. |
|
4123 |
^ receiver |
|
4124 |
||
1022 | 4125 |
"Modified: / 19.1.2000 / 16:22:16 / cg" |
713 | 4126 |
! |
4127 |
||
4128 |
keywordExpression |
|
4129 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
4130 |
||
4131 |
keywordExpression ::= binaryexpression |
|
4132 |
| { KEYWORD-PART binaryExpression } |
|
4133 |
" |
|
4134 |
||
1065 | 4135 |
|lastReceiver receiver sel arg args posR1 posR2 pos1 pos2 try lno note positions| |
713 | 4136 |
|
4137 |
posR1 := tokenPosition. |
|
4138 |
receiver := self binaryExpression. |
|
4139 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
4140 |
(tokenType == #Keyword) ifTrue:[ |
|
4141 |
pos1 := posR2 := tokenPosition. |
|
4142 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 4143 |
positions := OrderedCollection with:(pos1 to:pos2). |
713 | 4144 |
sel := tokenName. |
4145 |
lno := tokenLineNr. |
|
4146 |
self nextToken. |
|
4147 |
arg := self binaryExpression. |
|
4148 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4149 |
args := Array with:arg. |
|
4150 |
[tokenType == #Keyword] whileTrue:[ |
|
4151 |
sel := sel , tokenName. |
|
4152 |
pos2 := tokenPosition + tokenName size - 1. |
|
864 | 4153 |
positions add:(tokenPosition to:pos2). |
713 | 4154 |
self nextToken. |
4155 |
arg := self binaryExpression. |
|
4156 |
(arg == #Error) ifTrue:[^ #Error]. |
|
4157 |
args := args copyWith:arg. |
|
4158 |
]. |
|
864 | 4159 |
|
4160 |
positions do:[:p | |
|
4161 |
self markSelector:sel from:p start to:p stop receiverNode:receiver. |
|
4162 |
]. |
|
1022 | 4163 |
sel := self selectorCheck:sel for:receiver position:pos1 to:pos2. |
864 | 4164 |
|
964
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4165 |
(Class definitionSelectors includes:sel) ifTrue:[ |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4166 |
receiver isVariable ifTrue:[ |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4167 |
receiver isUndeclared ifTrue:[ |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4168 |
self parseError:('undefined superclass: ' , receiver name) position:pos1 to:pos2. |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4169 |
]. |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4170 |
] |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4171 |
]. |
5fa44b4ff2cb
check for undeclared class when evaluating subclass
Claus Gittinger <cg@exept.de>
parents:
944
diff
changeset
|
4172 |
|
1065 | 4173 |
lastReceiver := receiver. |
713 | 4174 |
try := MessageNode receiver:receiver selector:sel args:args fold:foldConstants. |
4175 |
(try isMemberOf:String) ifTrue:[ |
|
4176 |
self parseError:try position:pos1 to:pos2. |
|
4177 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
4178 |
receiver := MessageNode receiver:receiver selector:sel args:args fold:nil. |
|
4179 |
] ifFalse:[ |
|
4180 |
receiver := try |
|
4181 |
]. |
|
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4182 |
note := self plausibilityCheck:receiver. |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4183 |
note notNil ifTrue:[ |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4184 |
self warning:note position:pos1 to:pos2 |
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4185 |
]. |
713 | 4186 |
receiver lineNumber:lno. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4187 |
parseForCode ifFalse:[ |
1065 | 4188 |
self rememberSelectorUsed:sel receiver:lastReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4189 |
]. |
713 | 4190 |
|
4191 |
(sel = #and: |
|
4192 |
or:[sel = #or:]) ifTrue:[ |
|
4193 |
receiver arg1 isBlock ifFalse:[ |
|
4194 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
4195 |
position:pos2+1 to:tokenPosition-1 |
|
4196 |
] |
|
4197 |
]. |
|
4198 |
(sel = #whileTrue: |
|
4199 |
or:[sel = #whileFalse:]) ifTrue:[ |
|
4200 |
receiver receiver isBlock ifFalse:[ |
|
4201 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
4202 |
position:posR1 to:posR2-1 |
|
4203 |
] |
|
4204 |
]. |
|
4205 |
]. |
|
4206 |
^ receiver |
|
4207 |
||
1022 | 4208 |
"Modified: / 19.1.2000 / 16:22:22 / cg" |
713 | 4209 |
! |
4210 |
||
0 | 4211 |
primary |
1028 | 4212 |
"parse a primary-expression; return a node-tree, nil or #Error. |
4213 |
This also cares for namespace-access-pathes." |
|
0 | 4214 |
|
390
5ba190b979d4
warn about another beginners error
Claus Gittinger <cg@exept.de>
parents:
387
diff
changeset
|
4215 |
|val var expr pos name t cls nameSpace nameSpaceGlobal globlName lnr node |
1068 | 4216 |
pos2 eMsg exprList rawName| |
0 | 4217 |
|
4218 |
pos := tokenPosition. |
|
924 | 4219 |
|
44 | 4220 |
(tokenType == #Self) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4221 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4222 |
(self noAssignmentAllowed:'assignment to pseudo variable ''self''' at:pos) ifFalse:[ |
1062 | 4223 |
^ ParseError raise |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4224 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4225 |
selfNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4226 |
selfNode := SelfNode value:selfValue |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4227 |
]. |
663 | 4228 |
self markSelfFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4229 |
^ selfNode |
44 | 4230 |
]. |
869 | 4231 |
|
0 | 4232 |
(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
|
4233 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4234 |
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
|
4235 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4236 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4237 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4238 |
(self variableOrError:tokenName) == #Error ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4239 |
tokenType := #Here. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4240 |
warnSTXHereExtensionUsed ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4241 |
self warning:'here-sends are a nonstandard feature of ST/X' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4242 |
position:pos to:pos+3. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4243 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4244 |
only warn once |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4245 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4246 |
warnSTXHereExtensionUsed := false |
663 | 4247 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4248 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4249 |
] |
49 | 4250 |
]. |
4251 |
||
4252 |
(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
|
4253 |
name := tokenName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4254 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4255 |
var := self variable. |
1091 | 4256 |
"/ errorFlag == true ifTrue:[self halt]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4257 |
(var == #Error) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4258 |
errorFlag := true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4259 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4260 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4261 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4262 |
(tokenType == #'::') ifTrue:[ |
1068 | 4263 |
globlName := rawName := name. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4264 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4265 |
"is it in a namespace ?" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4266 |
nameSpace := self findNameSpaceWith:globlName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4267 |
nameSpace notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4268 |
globlName := nameSpace name , '::' , globlName |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4269 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4270 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4271 |
[tokenType == #'::'] whileTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4272 |
nameSpace := globlName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4273 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4274 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4275 |
(tokenType == #Identifier) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4276 |
ignoreWarnings ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4277 |
warnSTXNameSpaceUse ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4278 |
self warning:'nameSpaces are a nonstandard feature of ST/X' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4279 |
position:pos to:(source position). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4280 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4281 |
only warn once |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4282 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4283 |
warnSTXNameSpaceUse := false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4284 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4285 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4286 |
name := tokenName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4287 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4288 |
globlName := (nameSpace , '::' , name). |
1068 | 4289 |
rawName := (rawName , '::' , name). |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4290 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4291 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4292 |
nameSpaceGlobal isNil ifTrue:[ |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4293 |
warnedUnknownNamespaces isNil ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4294 |
warnedUnknownNamespaces := Set new. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4295 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4296 |
(warnedUnknownNamespaces includes:nameSpace) ifFalse:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4297 |
self warning:('unknown nameSpace: ', nameSpace) |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4298 |
position:pos to:tokenPosition-1. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4299 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4300 |
warnedUnknownNamespaces add:nameSpace. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
4301 |
] |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4302 |
] ifFalse:[ |
1040
543ba303a6d3
#isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents:
1039
diff
changeset
|
4303 |
nameSpaceGlobal isNameSpace ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4304 |
"/ for now: only Smalltalk is allowed |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4305 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
424 | 4306 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4307 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4308 |
globlName := name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4309 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4310 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4311 |
nameSpaceGlobal isBehavior ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4312 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos to:tokenPosition-1. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4313 |
] ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4314 |
(nameSpaceGlobal privateClassesAt:name asSymbol) isNil ifTrue:[ |
647
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
4315 |
self warning:('no private class: ' , name , ' in class: ' , nameSpace) |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
4316 |
position:pos to:tokenPosition-1. |
c59efd909f71
treat missing nameSpaces as warning
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
4317 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4318 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4319 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4320 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4321 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4322 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4323 |
]. |
938 | 4324 |
var := VariableNode type:#GlobalVariable name:globlName asSymbol. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4325 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
869 | 4326 |
]. |
1068 | 4327 |
self markVariable:var from:pos to:pos + rawName size - 1. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4328 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4329 |
|
869 | 4330 |
var == #Error ifTrue:[ |
4331 |
^ #Error |
|
4332 |
]. |
|
687 | 4333 |
|
1089 | 4334 |
errorFlag ~~ true ifTrue:[ |
4335 |
self markVariable:var from:pos to:pos + name size - 1. |
|
4336 |
]. |
|
1100
2a5a68297030
dont set error flag, when not parsing for code and
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
4337 |
(ignoreErrors or:[ignoreWarnings or:[parseForCode not]]) ifTrue:[ |
2a5a68297030
dont set error flag, when not parsing for code and
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
4338 |
errorFlag := false. |
2a5a68297030
dont set error flag, when not parsing for code and
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
4339 |
]. |
1068 | 4340 |
|
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4341 |
((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[ |
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
4342 |
parseForCode ifFalse:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
4343 |
var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
4344 |
var isClassVariable ifTrue:[ self rememberClassVarRead:var name]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
4345 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4346 |
^ var |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4347 |
]. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4348 |
pos2 := tokenPosition + tokenType size - 1. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4349 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4350 |
"/ careful: it could already be an implicit self send |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4351 |
ImplicitSelfSends ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4352 |
var isMessage ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4353 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4354 |
expr := self expression. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4355 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4356 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4357 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4358 |
selfNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4359 |
selfNode := SelfNode value:selfValue |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4360 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4361 |
^ MessageNode receiver:selfNode selector:('implicit_' , name , ':') asSymbol arg:expr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4362 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4363 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4364 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4365 |
(var ~~ #Error) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4366 |
t := var type. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4367 |
(t ~~ #MethodVariable) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4368 |
(t == #PrivateClass) ifTrue:[ |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4369 |
self parseError:'assignment to private class' position:pos to:pos2. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4370 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4371 |
(t == #MethodArg) ifTrue:[ |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4372 |
self parseError:'assignment to method argument' position:pos to:pos2. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4373 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4374 |
(t == #BlockArg) ifTrue:[ |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4375 |
self parseError:'assignment to block argument' position:pos to:pos2. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4376 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4377 |
(t == #InstanceVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4378 |
name := self classesInstVarNames at:(var index). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4379 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4380 |
"/ ca once did this to `name' and wondered what happened to his class ... |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4381 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4382 |
"/ and is hard to track down later) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4383 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4384 |
warnCommonMistakes ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4385 |
classToCompileFor isMeta ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4386 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4387 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4388 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of `Class'')' withCRs position:pos to:pos2. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4389 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4390 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4391 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4392 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4393 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4394 |
modifiedInstVars isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4395 |
modifiedInstVars := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4396 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4397 |
modifiedInstVars add:name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4398 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4399 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4400 |
(t == #ClassVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4401 |
name := var name. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4402 |
name := name copyFrom:((name indexOf:$:) + 1). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4403 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4404 |
modifiedClassVars isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4405 |
modifiedClassVars := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4406 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4407 |
modifiedClassVars add:name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4408 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4409 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4410 |
(t == #GlobalVariable) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4411 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4412 |
cls name = var name ifTrue:[ |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4413 |
self warning:'assignment to global which refers to a class' position:pos to:pos2. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4414 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4415 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4416 |
parseForCode ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4417 |
modifiedGlobals isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4418 |
modifiedGlobals := Set new |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4419 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4420 |
modifiedGlobals add:var name |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4421 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4422 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4423 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4424 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4425 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4426 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4427 |
] |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4428 |
]. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4429 |
t == #MethodVariable ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4430 |
modifiedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4431 |
modifiedLocalVars := Set new. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4432 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4433 |
modifiedLocalVars add:var name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4434 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4435 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4436 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4437 |
lnr := tokenLineNr. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4438 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4439 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4440 |
pos2 := tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4441 |
expr := self expression. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4442 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4443 |
"/ a typical beginner error: |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4444 |
"/ expr ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4445 |
"/ var := super |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4446 |
"/ ] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4447 |
"/ var := something-else |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4448 |
"/ ]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4449 |
"/ var messageSend |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4450 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4451 |
"/ does not what a beginner might think. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4452 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4453 |
warnCommonMistakes ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4454 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4455 |
self warning:'followup messageSends to `' , var name , ''' will have normal send semantics\(i.e. NO super- or here-sends). Use self to avoid confusion.' withCRs position:pos to:pos2. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4456 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4457 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4458 |
|
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4459 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4460 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4461 |
]. |
1069 | 4462 |
|
4463 |
expr isVariable ifTrue:[ |
|
4464 |
expr name = var name ifTrue:[ |
|
1070 | 4465 |
self warning:('useless assignment to `' , var name, '''' ) position:pos to:pos2-1. |
1069 | 4466 |
]. |
4467 |
]. |
|
4468 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4469 |
node := AssignmentNode variable:var expression:expr. |
712 | 4470 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4471 |
^ node |
0 | 4472 |
]. |
49 | 4473 |
|
44 | 4474 |
((tokenType == #Integer) |
120 | 4475 |
or:[(tokenType == #String) |
44 | 4476 |
or:[(tokenType == #Character) |
4477 |
or:[(tokenType == #Float) |
|
4478 |
or:[(tokenType == #Symbol)]]]]) ifTrue:[ |
|
924 | 4479 |
"/ |
4480 |
"/ ImmutableStrings are experimental |
|
4481 |
"/ |
|
752 | 4482 |
((tokenType == #String) |
4483 |
and:[(StringsAreImmutable == true) |
|
4484 |
and:[ImmutableString notNil]]) ifTrue:[ |
|
4485 |
tokenValue := tokenValue copy. |
|
4486 |
tokenValue changeClassTo:ImmutableString. |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4487 |
token := tokenValue |
752 | 4488 |
]. |
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
4489 |
(tokenType == #Symbol) ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
4490 |
parseForCode ifFalse:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
4491 |
self rememberSymbolUsed:tokenValue |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
4492 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
4493 |
]. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4494 |
val := ConstantNode type:tokenType value:tokenValue. |
1085
efdc7aaf7e54
fixed highlighting of symbol-literals
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4495 |
|
efdc7aaf7e54
fixed highlighting of symbol-literals
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4496 |
tokenValue isSymbol ifTrue:[ |
efdc7aaf7e54
fixed highlighting of symbol-literals
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4497 |
self markSymbolFrom:tokenPosition to:tokenPosition+tokenValue size-1. |
efdc7aaf7e54
fixed highlighting of symbol-literals
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4498 |
]. |
efdc7aaf7e54
fixed highlighting of symbol-literals
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4499 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4500 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4501 |
(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
|
4502 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4503 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4504 |
^ val |
0 | 4505 |
]. |
924 | 4506 |
|
0 | 4507 |
(tokenType == #Nil) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4508 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4509 |
(self noAssignmentAllowed:'assignment to ''nil''' 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
|
4510 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4511 |
]. |
670 | 4512 |
"/ self markConstantFrom:pos to:pos+2. |
664 | 4513 |
nilNode isNil ifTrue:[ |
4514 |
nilNode := ConstantNode type:#Nil value:nil |
|
4515 |
]. |
|
4516 |
^ nilNode |
|
0 | 4517 |
]. |
924 | 4518 |
|
0 | 4519 |
(tokenType == #True) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4520 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4521 |
(self noAssignmentAllowed:'assignment to ''true''' 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
|
4522 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4523 |
]. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4524 |
self markBooleanConstantFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4525 |
^ ConstantNode type:#True value:true |
0 | 4526 |
]. |
4527 |
(tokenType == #False) ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4528 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4529 |
(self noAssignmentAllowed:'assignment to ''false''' 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
|
4530 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4531 |
]. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4532 |
self markBooleanConstantFrom:pos to:pos+4. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4533 |
^ ConstantNode type:#False value:false |
0 | 4534 |
]. |
924 | 4535 |
|
0 | 4536 |
(tokenType == #Super) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4537 |
usesSuper := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4538 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4539 |
(self noAssignmentAllowed:'assignment to pseudo variable ''super''' 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
|
4540 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4541 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4542 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4543 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4544 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4545 |
superNode isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4546 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4547 |
]. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4548 |
self markSelfFrom:pos to:pos+4. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4549 |
^ superNode |
0 | 4550 |
]. |
924 | 4551 |
|
49 | 4552 |
(tokenType == #Here) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4553 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4554 |
(self noAssignmentAllowed:'assignment to pseudo variable ''here''' 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
|
4555 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4556 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4557 |
classToCompileFor isNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4558 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4559 |
]. |
869 | 4560 |
self markSelfFrom:pos to:pos+3. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4561 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
49 | 4562 |
]. |
924 | 4563 |
|
0 | 4564 |
(tokenType == #ThisContext) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4565 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4566 |
(self noAssignmentAllowed:'assignment to pseudo variable ''thisContext''' 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
|
4567 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4568 |
]. |
663 | 4569 |
self markIdentifierFrom:pos to:pos+10. |
924 | 4570 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn. "/ often nil |
0 | 4571 |
]. |
924 | 4572 |
|
0 | 4573 |
(tokenType == #HashLeftParen) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4574 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4575 |
val := self array. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4576 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4577 |
(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
|
4578 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4579 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4580 |
^ ConstantNode type:#Array value:val |
0 | 4581 |
]. |
924 | 4582 |
|
4583 |
(tokenType == #HashLeftBrace) ifTrue:[ |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4584 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4585 |
self nextToken. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4586 |
^ val. |
924 | 4587 |
]. |
4588 |
||
0 | 4589 |
(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
|
4590 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4591 |
val := self byteArray. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4592 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4593 |
(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
|
4594 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4595 |
]. |
924 | 4596 |
^ ConstantNode type:#ByteArray value:val |
0 | 4597 |
]. |
432 | 4598 |
|
0 | 4599 |
(tokenType == $() ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4600 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4601 |
val := self expression. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4602 |
(val == #Error) ifTrue:[^ #Error]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4603 |
(tokenType ~~ $) ) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4604 |
tokenType isCharacter ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4605 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4606 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4607 |
eMsg := 'missing '')'''. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4608 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4609 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4610 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4611 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4612 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4613 |
(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
|
4614 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4615 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4616 |
val parenthized:true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4617 |
^ val |
0 | 4618 |
]. |
924 | 4619 |
|
0 | 4620 |
(tokenType == $[ ) ifTrue:[ |
673 | 4621 |
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
|
4622 |
val := self block. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4623 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4624 |
(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
|
4625 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4626 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4627 |
^ val |
0 | 4628 |
]. |
19 | 4629 |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4630 |
(tokenType == ${ ) ifTrue:[ |
897 | 4631 |
AllowSqueakExtensions ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4632 |
self parseError:'non-Standard Squeak extension (enable in settings)' position:pos to:tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4633 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4634 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4635 |
self nextToken. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4636 |
exprList := self squeakComputedArray. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4637 |
|
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4638 |
tokenType ~~ $} ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4639 |
self parseError:'''}'' expected' position:tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4640 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4641 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4642 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
4643 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4644 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4645 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4646 |
|
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4647 |
"/ make it an array creation expression ... |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4648 |
expr := MessageNode |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4649 |
receiver:(VariableNode type:#GlobalVariable name:#Array) |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4650 |
selector:#new: |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4651 |
arg:(ConstantNode type:#Integer value:(exprList size)). |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4652 |
|
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4653 |
exprList size == 0 ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4654 |
^ expr. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4655 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4656 |
exprList keysAndValuesDo:[:idx :e | |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4657 |
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4658 |
receiver:expr |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4659 |
selector:#at:put: |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4660 |
arg1:(ConstantNode type:#Integer value:idx) |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4661 |
arg2:e |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4662 |
fold:false. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4663 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4664 |
expr := CascadeNode |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4665 |
receiver:expr |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4666 |
selector:#yourself. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4667 |
^ expr |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4668 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4669 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4670 |
(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
|
4671 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4672 |
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
|
4673 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4674 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4675 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4676 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
4677 |
|
0 | 4678 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 4679 |
tokenType isCharacter ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4680 |
self syntaxError:('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4681 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4682 |
' unexpected') position:tokenPosition to:tokenPosition |
0 | 4683 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4684 |
(#(BinaryOperator Keyword) includes:tokenType) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4685 |
eMsg := ('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4686 |
, tokenType printString , '(' , tokenName , ') ' , |
805 | 4687 |
' unexpected (missing receiver ?)') |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4688 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4689 |
eMsg := ('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4690 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4691 |
' unexpected') |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4692 |
]. |
805 | 4693 |
self syntaxError:eMsg position:tokenPosition to:source position |
0 | 4694 |
]. |
4695 |
^ #Error |
|
120 | 4696 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4697 |
"Created: / 13.9.1995 / 12:50:50 / claus" |
1068 | 4698 |
"Modified: / 18.8.2000 / 20:51:22 / cg" |
0 | 4699 |
! |
4700 |
||
924 | 4701 |
qualifiedName |
4702 |
"a vw3.x (and later) feature: QualifiedName is #{ id ... id } |
|
4703 |
and mapped to a global variable here. |
|
4704 |
The initial #{ is supposed to be not yet skipped." |
|
4705 |
||
4706 |
|elements elem pos1| |
|
4707 |
||
4708 |
pos1 := tokenPosition. |
|
4709 |
self nextToken. |
|
4710 |
elements := OrderedCollection new. |
|
4711 |
[tokenType ~~ $} ] whileTrue:[ |
|
4712 |
elem := self variable. |
|
4713 |
(elem == #Error) ifTrue:[ |
|
4714 |
(tokenType == #EOF) ifTrue:[ |
|
4715 |
self syntaxError:'unterminated qualifiedName; ''}'' expected' |
|
4716 |
position:pos1 to:tokenPosition |
|
4717 |
]. |
|
4718 |
^ #Error |
|
4719 |
]. |
|
1100
2a5a68297030
dont set error flag, when not parsing for code and
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
4720 |
errorFlag := false. |
924 | 4721 |
(elem isVariable and:[elem isGlobal]) ifFalse:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4722 |
self warning:'elements of a qualifiedName should be globalIdentifiers' |
924 | 4723 |
position:pos1 to:tokenPosition |
4724 |
]. |
|
4725 |
elements add:elem. |
|
1028 | 4726 |
|
4727 |
self nextToken. |
|
4728 |
tokenType == #'::' ifTrue:[ |
|
4729 |
"/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
4730 |
"/(which is a kludge) |
|
4731 |
self nextToken. |
|
4732 |
] ifFalse:[ |
|
4733 |
tokenType ~~ $} ifTrue:[ |
|
4734 |
self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
|
4735 |
position:pos1 to:tokenPosition. |
|
4736 |
^ #Error |
|
4737 |
]. |
|
4738 |
]. |
|
924 | 4739 |
]. |
4740 |
||
4741 |
elements size > 1 ifTrue:[ |
|
1028 | 4742 |
self syntaxError:'Sorry: qualified names are not yet implemented.'. |
924 | 4743 |
]. |
4744 |
^ elements first. |
|
4745 |
||
4746 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
4747 |
! |
|
4748 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4749 |
squeakComputedArray |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4750 |
|expressions elem pos1| |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4751 |
|
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4752 |
pos1 := tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4753 |
expressions := OrderedCollection new:20. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4754 |
[tokenType ~~ $} ] whileTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4755 |
elem := self expression. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4756 |
(elem == #Error) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4757 |
(tokenType == #EOF) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4758 |
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
|
4759 |
position:pos1 to:tokenPosition |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4760 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4761 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4762 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4763 |
expressions add:elem. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4764 |
tokenType == $. ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4765 |
self nextToken. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4766 |
] ifFalse:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4767 |
^ expressions |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4768 |
] |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4769 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4770 |
^ expressions |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4771 |
! |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
4772 |
|
141 | 4773 |
unaryExpression |
4774 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
4775 |
||
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4776 |
|receiver thisReceiver sel pos pos2 try| |
141 | 4777 |
|
4778 |
receiver := self primary. |
|
4779 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
4780 |
[tokenType == #Identifier] whileTrue:[ |
|
663 | 4781 |
pos := tokenPosition. |
4782 |
pos2 := pos + tokenName size - 1. |
|
864 | 4783 |
self markSelector:tokenName from:pos to:pos2 receiverNode:receiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4784 |
sel := tokenName. |
1022 | 4785 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
1061 | 4786 |
thisReceiver := receiver. |
663 | 4787 |
try := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
4788 |
(try isMemberOf:String) ifTrue:[ |
|
4789 |
self parseError:try position:pos to:pos2. |
|
4790 |
errorFlag := false. "ok, user wants it - so he'll get it" |
|
4791 |
receiver := UnaryNode receiver:receiver selector:sel fold:nil. |
|
4792 |
] ifFalse:[ |
|
4793 |
receiver := try |
|
4794 |
]. |
|
4795 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4796 |
parseForCode ifFalse:[ |
1061 | 4797 |
self rememberSelectorUsed:sel receiver:thisReceiver |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4798 |
]. |
663 | 4799 |
self nextToken. |
141 | 4800 |
]. |
4801 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
4802 |
|
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
4803 |
"Modified: / 6.2.2000 / 14:54:20 / cg" |
141 | 4804 |
! |
4805 |
||
4806 |
variable |
|
1028 | 4807 |
"parse a simple (i.e. non-namespace-access path) variable; |
4808 |
return a node-tree, nil or #Error. |
|
4809 |
Does not advance to next token. |
|
4810 |
If undefined, notify error and correct if user wants to" |
|
141 | 4811 |
|
864 | 4812 |
|v pos1 pos2| |
687 | 4813 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4814 |
v := self variableOrError:tokenName. |
664 | 4815 |
(v ~~ #Error) ifTrue:[ |
663 | 4816 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 4817 |
self markVariable:v. |
663 | 4818 |
]. |
4819 |
^ v |
|
4820 |
]. |
|
865 | 4821 |
|
687 | 4822 |
pos1 := tokenPosition. |
864 | 4823 |
pos2 := pos1+tokenName size-1. |
4824 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 4825 |
|
1089 | 4826 |
parseForCode == true ifTrue:[ |
4827 |
v := self correctVariable. |
|
4828 |
(v ~~ #Error) ifTrue:[^ v]. |
|
4829 |
]. |
|
4830 |
||
4831 |
errorFlag := true. |
|
664 | 4832 |
|
141 | 4833 |
parseForCode ifFalse:[ |
663 | 4834 |
self rememberGlobalUsed:tokenName |
141 | 4835 |
] ifTrue:[ |
663 | 4836 |
tokenName first isLowercase ifTrue:[ |
4837 |
ImplicitSelfSends ifTrue:[ |
|
4838 |
selfNode isNil ifTrue:[ |
|
4839 |
selfNode := SelfNode value:selfValue |
|
4840 |
]. |
|
4841 |
^ UnaryNode receiver:selfNode selector:('implicit_' , tokenName) asSymbol. |
|
4842 |
]. |
|
4843 |
^ #Error |
|
4844 |
] |
|
141 | 4845 |
]. |
865 | 4846 |
|
869 | 4847 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
141 | 4848 |
^ VariableNode type:#GlobalVariable name:tokenName asSymbol |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
4849 |
|
687 | 4850 |
"Modified: / 16.4.1998 / 18:46:45 / cg" |
141 | 4851 |
! |
4852 |
||
0 | 4853 |
variableOrError |
1028 | 4854 |
"parse a simple (i.e. non-namespace-access path) variable; |
4855 |
return a node-tree, nil or #Error. |
|
4856 |
Does not advance to next token." |
|
0 | 4857 |
|
21 | 4858 |
^ self variableOrError:tokenName |
4859 |
! |
|
4860 |
||
4861 |
variableOrError:varName |
|
1028 | 4862 |
"parse a simple (i.e. non-namespace-access path) variable; |
4863 |
return a node-tree, nil or #Error. |
|
4864 |
Does not advance to next token." |
|
21 | 4865 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4866 |
|var varIndex aClass searchBlock args vars |
877 | 4867 |
tokenSymbol space classVarIndex holder| |
0 | 4868 |
|
4869 |
"is it a block-arg or block-var ?" |
|
4870 |
searchBlock := currentBlock. |
|
4871 |
[searchBlock notNil] whileTrue:[ |
|
628 | 4872 |
vars := searchBlock variables. |
4873 |
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
|
4874 |
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
|
4875 |
varIndex ~~ 0 ifTrue:[ |
628 | 4876 |
^ VariableNode type:#BlockVariable |
4877 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4878 |
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
|
4879 |
index:varIndex |
628 | 4880 |
block:searchBlock |
4881 |
from:currentBlock |
|
4882 |
]. |
|
4883 |
]. |
|
4884 |
||
4885 |
args := searchBlock arguments. |
|
4886 |
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
|
4887 |
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
|
4888 |
varIndex ~~ 0 ifTrue:[ |
628 | 4889 |
^ VariableNode type:#BlockArg |
4890 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4891 |
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
|
4892 |
index:varIndex |
628 | 4893 |
block:searchBlock |
4894 |
from:currentBlock |
|
4895 |
]. |
|
4896 |
||
4897 |
]. |
|
4898 |
||
4899 |
searchBlock := searchBlock home |
|
0 | 4900 |
]. |
4901 |
||
4902 |
"is it a method-variable ?" |
|
4903 |
methodVars notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4904 |
varIndex := methodVarNames indexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4905 |
varIndex ~~ 0 ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4906 |
var := methodVars at:varIndex. |
628 | 4907 |
var used:true. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4908 |
parseForCode ifFalse:[self rememberLocalUsed:varName]. |
628 | 4909 |
^ VariableNode type:#MethodVariable |
4910 |
name:varName |
|
4911 |
token:var |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4912 |
index:varIndex |
628 | 4913 |
] |
0 | 4914 |
]. |
4915 |
||
4916 |
"is it a method-argument ?" |
|
4917 |
methodArgs notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4918 |
varIndex := methodArgNames indexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4919 |
varIndex ~~ 0 ifTrue:[ |
628 | 4920 |
^ VariableNode type:#MethodArg |
4921 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4922 |
token:(methodArgs at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4923 |
index:varIndex |
628 | 4924 |
] |
0 | 4925 |
]. |
4926 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4927 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4928 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4929 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4930 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4931 |
"/ 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
|
4932 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4933 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4934 |
[con notNil] whileTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4935 |
varNames := self class argAndVarNamesForContext:con. |
690 | 4936 |
varNames size > 0 ifTrue:[ |
4937 |
varIndex := varNames lastIndexOf:varName. |
|
4938 |
varIndex ~~ 0 ifTrue:[ |
|
4939 |
^ VariableNode type:#ContextVariable |
|
4940 |
name:varName |
|
4941 |
context:con |
|
4942 |
index:varIndex |
|
4943 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4944 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4945 |
con := con home. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4946 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4947 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4948 |
|
0 | 4949 |
classToCompileFor notNil ifTrue:[ |
628 | 4950 |
"is it an instance-variable ?" |
4951 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4952 |
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
|
4953 |
varIndex ~~ 0 ifTrue:[ |
628 | 4954 |
classToCompileFor isMeta ifTrue:[ |
4955 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
4956 |
classVarIndex ~~ 0 ifTrue:[ |
|
4957 |
"/ give a warning - that maybe a common error |
|
825 | 4958 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
4959 |
alreadyWarnedClassInstVarRefs := Set new |
|
4960 |
]. |
|
4961 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
4962 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
4963 |
alreadyWarnedClassInstVarRefs add:varName. |
|
4964 |
]. |
|
628 | 4965 |
]. |
4966 |
]. |
|
4967 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
4968 |
^ VariableNode type:#InstanceVariable |
|
4969 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4970 |
index:varIndex |
628 | 4971 |
selfValue:selfValue |
4972 |
]. |
|
4973 |
||
4974 |
"/ see if there is a corresponding classVar (for the warning) |
|
4975 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
4976 |
||
4977 |
"/ "is it a class-instance-variable ?" |
|
4978 |
"/ |
|
4979 |
"/ Notice: |
|
4980 |
"/ it is no longer allowed to fetch class-instance variables |
|
4981 |
"/ from instance methods ... |
|
4982 |
"/ (used to be in previous ST/X versions) |
|
4983 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
4984 |
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
|
4985 |
varIndex ~~ 0 ifTrue:[ |
628 | 4986 |
aClass := self inWhichClassIsClassInstVar:varName. |
4987 |
aClass notNil ifTrue:[ |
|
4988 |
classToCompileFor isMeta ifFalse:[ |
|
4989 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4990 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4991 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4992 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4993 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4994 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4995 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4996 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4997 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4998 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
4999 |
]. |
628 | 5000 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
5001 |
^ #Error. |
|
5002 |
] ifFalse:[ |
|
5003 |
"/ give a warning - that maybe a common error |
|
738 | 5004 |
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 | 5005 |
] |
5006 |
]. |
|
5007 |
||
5008 |
"/ OLD CODE: |
|
5009 |
"/ 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
|
5010 |
"/ |
628 | 5011 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
5012 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
5013 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5014 |
"/ index:varIndex |
628 | 5015 |
"/ selfClass:aClass |
5016 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5017 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5018 |
"/ self halt:'oops - should not happen'. |
628 | 5019 |
] |
5020 |
]. |
|
5021 |
||
5022 |
"is it a class-variable ?" |
|
5023 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5024 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5025 |
varIndex ~~ 0 ifTrue:[ |
628 | 5026 |
aClass := self inWhichClassIsClassVar:varName. |
5027 |
aClass notNil ifTrue:[ |
|
5028 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
5029 |
^ 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
|
5030 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5031 |
"/ self halt:'oops - should not happen'. |
628 | 5032 |
]. |
5033 |
||
5034 |
"is it a private-class ?" |
|
5035 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5036 |
aClass := self classToLookForClassVars. |
628 | 5037 |
aClass isMeta ifTrue:[ |
5038 |
aClass := aClass soleInstance. |
|
5039 |
]. |
|
5040 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
|
5041 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
5042 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
5043 |
]. |
|
418 | 5044 |
]. |
5045 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5046 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5047 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5048 |
space notNil ifTrue:[ |
628 | 5049 |
space ~~ Smalltalk ifTrue:[ |
5050 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5051 |
space isNameSpace ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5052 |
^ VariableNode type:#GlobalVariable name:(space name , '::' , varName) asSymbol |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5053 |
] ifFalse:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5054 |
^ VariableNode type:#PrivateClass class:space name:varName |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5055 |
] |
628 | 5056 |
] ifFalse:[ |
5057 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
5058 |
^ VariableNode type:#GlobalVariable name:varName asSymbol |
|
5059 |
] |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
5060 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
5061 |
|
0 | 5062 |
"is it a global-variable ?" |
63 | 5063 |
tokenSymbol := varName asSymbolIfInterned. |
5064 |
tokenSymbol notNil ifTrue:[ |
|
628 | 5065 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
5066 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
5067 |
^ VariableNode type:#GlobalVariable name:tokenSymbol |
|
5068 |
] |
|
0 | 5069 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5070 |
|
877 | 5071 |
"is it a workspace variable ?" |
5072 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
5073 |
"/ when parsing doits, this is done twice; |
|
5074 |
"/ first, for the parse, then as a block-code |
|
5075 |
"/ for the code. |
|
5076 |
"/ We only care for WorkspaceVars in doIts |
|
5077 |
(selector isNil or:[selector == #doIt]) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5078 |
Workspace notNil and:[ |
942
366981f31cd6
care for no workspace class present
Claus Gittinger <cg@exept.de>
parents:
938
diff
changeset
|
5079 |
(holder := Workspace workspaceVariableAt:varName) notNil ifTrue:[ |
366981f31cd6
care for no workspace class present
Claus Gittinger <cg@exept.de>
parents:
938
diff
changeset
|
5080 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5081 |
] |
877 | 5082 |
] |
5083 |
] |
|
5084 |
]. |
|
5085 |
||
0 | 5086 |
^ #Error |
353 | 5087 |
|
825 | 5088 |
"Modified: / 8.3.1999 / 01:35:56 / cg" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5089 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5090 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5091 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5092 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5093 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5094 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5095 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5096 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5097 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5098 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5099 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5100 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5101 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5102 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5103 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5104 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5105 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5106 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5107 |
"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
|
5108 |
"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
|
5109 |
"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
|
5110 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5111 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5112 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5113 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5114 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5115 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5116 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
5117 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5118 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5119 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5120 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5121 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5122 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5123 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5124 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5125 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
5126 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5127 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5128 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5129 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5130 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5131 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5132 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5133 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5134 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5135 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
5136 |
"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
|
5137 |
"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
|
5138 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5139 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5140 |
findNameSpaceWith:aVariableName |
692 | 5141 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5142 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5143 |
"/ 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
|
5144 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5145 |
classToCompileFor notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5146 |
"/ Q: |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5147 |
"/ consider private classes of superclasses. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5148 |
"/ 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
|
5149 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5150 |
"/ 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
|
5151 |
"/ known to the corresponding ownerClass. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5152 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5153 |
"is it in the classes namespace ?" |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5154 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5155 |
classToCompileFor isPrivate ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5156 |
ns := classToCompileFor topOwningClass nameSpace |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5157 |
] ifFalse:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5158 |
ns := classToCompileFor nameSpace. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5159 |
]. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5160 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5161 |
(ns notNil |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5162 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5163 |
(ns at:aVariableName) notNil ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5164 |
^ ns |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5165 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5166 |
]. |
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
5167 |
|
495 | 5168 |
"/ ns := classToCompileFor nameSpace. |
5169 |
"/ ns notNil ifTrue:[ |
|
5170 |
"/ "is it in the current classes namespace ?" |
|
5171 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
5172 |
"/ ^ ns |
|
5173 |
"/ ] |
|
5174 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5175 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5176 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5177 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5178 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5179 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5180 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
1043 | 5181 |
currentSpace isNameSpace ifTrue:[ |
5182 |
(currentSpace at:aVariableName) notNil ifTrue:[ |
|
5183 |
^ currentSpace |
|
5184 |
] |
|
5185 |
] ifFalse:[ |
|
5186 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
5187 |
^ currentSpace |
|
5188 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5189 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5190 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5191 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5192 |
"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
|
5193 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5194 |
usedSpaces notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5195 |
usedSpaces do:[:aNameSpace | |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5196 |
(aNameSpace at:aVariableName) notNil ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5197 |
^ aNameSpace |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5198 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5199 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5200 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5201 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5202 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
5203 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 5204 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 5205 |
! |
5206 |
||
5207 |
inWhichClassIsClassInstVar:aString |
|
5208 |
"search class-chain for the class-instance variable named aString |
|
5209 |
- return the class or nil if not found" |
|
5210 |
||
5211 |
|aClass| |
|
5212 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5213 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5214 |
|
713 | 5215 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5216 |
(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
|
5217 |
aClass := aClass superclass |
713 | 5218 |
]. |
5219 |
^ nil |
|
5220 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5221 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 5222 |
! |
5223 |
||
5224 |
inWhichClassIsClassVar:aString |
|
5225 |
"search class-chain for the classvariable named aString |
|
5226 |
- return the class or nil if not found" |
|
5227 |
||
5228 |
|aClass className baseClass| |
|
5229 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5230 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5231 |
|
713 | 5232 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5233 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5234 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5235 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5236 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5237 |
] |
713 | 5238 |
]. |
5239 |
^ aClass whichClassDefinesClassVar:aString |
|
5240 |
||
5241 |
"/ [aClass notNil] whileTrue:[ |
|
5242 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
5243 |
"/ aClass := aClass superclass |
|
5244 |
"/ ]. |
|
5245 |
"/ ^ nil |
|
5246 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5247 |
"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
|
5248 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 5249 |
! |
5250 |
||
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5251 |
noAssignmentAllowed:eMsg at:pos |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5252 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5253 |
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
|
5254 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5255 |
^ false |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5256 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5257 |
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
|
5258 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5259 |
^ true |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5260 |
|
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5261 |
|
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5262 |
|
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5263 |
|
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5264 |
|
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5265 |
! |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5266 |
|
787 | 5267 |
plausibilityCheck:aNode |
5268 |
^ aNode plausibilityCheck |
|
5269 |
||
5270 |
"Created: / 19.10.1998 / 19:56:09 / cg" |
|
5271 |
"Modified: / 19.10.1998 / 19:56:29 / cg" |
|
141 | 5272 |
! ! |
5273 |
||
5274 |
!Parser methodsFor:'queries'! |
|
5275 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5276 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5277 |
"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
|
5278 |
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
|
5279 |
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
|
5280 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5281 |
|
748 | 5282 |
|names m who cls| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5283 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5284 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 5285 |
m := contextToEvaluateIn method. |
5286 |
m notNil ifTrue:[ |
|
5287 |
who := contextToEvaluateIn method who. |
|
5288 |
who notNil ifTrue:[ |
|
5289 |
^ who methodClass. |
|
5290 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5291 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5292 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5293 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5294 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5295 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5296 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 5297 |
"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
|
5298 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5299 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5300 |
classesClassInstVarNames |
141 | 5301 |
"caching allInstVarNames for next compilation saves time ..." |
5302 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5303 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5304 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5305 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5306 |
|cls| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5307 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5308 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5309 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5310 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5311 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5312 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5313 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5314 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5315 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5316 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5317 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5318 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5319 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5320 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5321 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5322 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5323 |
"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
|
5324 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 5325 |
! |
5326 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5327 |
classesClassVarNames |
141 | 5328 |
"caching allClassVarNames for next compilation saves time ..." |
5329 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5330 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5331 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5332 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5333 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5334 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5335 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
5336 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5337 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5338 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5339 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5340 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5341 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5342 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5343 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5344 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5345 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5346 |
] |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5347 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5348 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5349 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5350 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5351 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5352 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5353 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
5354 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
5355 |
"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
|
5356 |
"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
|
5357 |
"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
|
5358 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5359 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5360 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5361 |
"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
|
5362 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5363 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5364 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5365 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5366 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5367 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5368 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5369 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5370 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5371 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5372 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5373 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5374 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5375 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5376 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5377 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5378 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
5379 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5380 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5381 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 5382 |
! |
5383 |
||
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5384 |
contextMustBeReturnable |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5385 |
^ primitiveContextInfo notNil |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5386 |
and:[ ^ primitiveContextInfo includes:('context:' -> #return) ] |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5387 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5388 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5389 |
! |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
5390 |
|
141 | 5391 |
hasNonOptionalPrimitiveCode |
5392 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
5393 |
||
5394 |
^ hasNonOptionalPrimitiveCode |
|
0 | 5395 |
! |
5396 |
||
141 | 5397 |
hasPrimitiveCode |
5398 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
5399 |
||
5400 |
^ hasPrimitiveCode |
|
98 | 5401 |
! |
5402 |
||
883 | 5403 |
isSyntaxHighlighter |
5404 |
^ false |
|
5405 |
! |
|
5406 |
||
385 | 5407 |
lineNumberInfo |
5408 |
^ lineNumberInfo |
|
5409 |
||
5410 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
5411 |
! |
|
5412 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
5413 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
5414 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
5415 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
5416 |
"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
|
5417 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
5418 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5419 |
messagesSent |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5420 |
"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
|
5421 |
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
|
5422 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5423 |
^ (messagesSent ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5424 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5425 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5426 |
messagesSentToSelf |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5427 |
"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
|
5428 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5429 |
^ (messagesSentToSelf ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5430 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5431 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5432 |
messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5433 |
"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
|
5434 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5435 |
^ (messagesSentToSuper ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5436 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5437 |
|
141 | 5438 |
methodArgs |
5439 |
"return an array with methodarg names (valid after parsing spec)" |
|
5440 |
||
5441 |
^ methodArgNames |
|
5442 |
! |
|
5443 |
||
5444 |
methodVars |
|
5445 |
"return a collection with method variablenames (valid after parsing)" |
|
5446 |
||
5447 |
^ methodVarNames |
|
23 | 5448 |
! |
5449 |
||
141 | 5450 |
modifiedClassVars |
5451 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
5452 |
||
541 | 5453 |
^ modifiedClassVars ? #() |
5454 |
||
5455 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 5456 |
! |
5457 |
||
5458 |
modifiedGlobals |
|
5459 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
5460 |
||
541 | 5461 |
^ modifiedGlobals ? #() |
5462 |
||
5463 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 5464 |
! |
5465 |
||
5466 |
modifiedInstVars |
|
5467 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
5468 |
||
541 | 5469 |
^ modifiedInstVars ? #() |
5470 |
||
5471 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 5472 |
! |
5473 |
||
141 | 5474 |
numberOfMethodArgs |
5475 |
"return the number of methodargs (valid after parsing spec)" |
|
5476 |
||
5477 |
^ methodArgs size |
|
5478 |
! |
|
5479 |
||
5480 |
numberOfMethodVars |
|
5481 |
"return the number of method variables (valid after parsing)" |
|
5482 |
||
5483 |
^ methodVars size |
|
5484 |
! |
|
5485 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5486 |
readClassVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5487 |
"return a collection with classvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5488 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5489 |
^ readClassVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5490 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5491 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5492 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5493 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5494 |
readInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5495 |
"return a collection with instvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5496 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5497 |
^ readInstVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5498 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5499 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5500 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5501 |
|
141 | 5502 |
selector |
5503 |
"return the selector (valid after parsing spec)" |
|
5504 |
||
5505 |
^ selector |
|
0 | 5506 |
! |
5507 |
||
141 | 5508 |
usedClassVars |
5509 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
5510 |
||
541 | 5511 |
^ usedClassVars ? #() |
5512 |
||
5513 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 5514 |
! |
5515 |
||
5516 |
usedGlobals |
|
5517 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
5518 |
||
541 | 5519 |
^ usedGlobals ? #() |
5520 |
||
5521 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 5522 |
! |
5523 |
||
5524 |
usedInstVars |
|
5525 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
5526 |
||
541 | 5527 |
^ usedInstVars ? #() |
5528 |
||
5529 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 5530 |
! |
5531 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5532 |
usedSymbols |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5533 |
"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
|
5534 |
|
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5535 |
^ (usedSymbols ? #()) |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5536 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5537 |
|
141 | 5538 |
usedVars |
5539 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
5540 |
||
541 | 5541 |
^ usedVars ? #() |
5542 |
||
5543 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 5544 |
! |
5545 |
||
141 | 5546 |
usesSuper |
5547 |
"return true if the parsed method uses super (valid after parsing)" |
|
5548 |
||
5549 |
^ usesSuper |
|
5550 |
! ! |
|
5551 |
||
5552 |
!Parser methodsFor:'setup'! |
|
5553 |
||
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5554 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5555 |
"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
|
5556 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5557 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5558 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5559 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5560 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5561 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
5562 |
|
141 | 5563 |
initialize |
5564 |
super initialize. |
|
5565 |
||
5566 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
5567 |
warnSTXHereExtensionUsed := WarnSTXSpecials. |
|
5568 |
usesSuper := false. |
|
5569 |
parseForCode := false. |
|
377 | 5570 |
foldConstants := FoldConstants. |
5571 |
lineNumberInfo := LineNumberInfo. |
|
607 | 5572 |
warnUndeclared := true. |
5573 |
||
5574 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 5575 |
! |
5576 |
||
5577 |
parseForCode |
|
5578 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
5579 |
Use this when parsing for compilation or evaluation" |
|
5580 |
||
5581 |
parseForCode := true |
|
0 | 5582 |
! |
5583 |
||
141 | 5584 |
setClassToCompileFor:aClass |
5585 |
"set the class to be used for parsing/evaluating" |
|
5586 |
||
5587 |
classToCompileFor := aClass. |
|
5588 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
5589 |
PrevClass notNil ifTrue:[ |
|
5590 |
Parser update:PrevClass |
|
5591 |
] |
|
5592 |
] |
|
5593 |
! |
|
5594 |
||
5595 |
setContext:aContext |
|
5596 |
"set the context used while evaluating" |
|
5597 |
||
5598 |
contextToEvaluateIn := aContext |
|
5599 |
! |
|
5600 |
||
5601 |
setSelf:anObject |
|
5602 |
"set the value to be used for self while evaluating" |
|
5603 |
||
5604 |
selfValue := anObject. |
|
5605 |
classToCompileFor := anObject class. |
|
5606 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
5607 |
PrevClass notNil ifTrue:[ |
|
5608 |
Parser update:PrevClass |
|
5609 |
] |
|
5610 |
] |
|
607 | 5611 |
! |
5612 |
||
5613 |
warnUndeclared:aBoolean |
|
5614 |
warnUndeclared := aBoolean. |
|
5615 |
||
5616 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
0 | 5617 |
! ! |
5618 |
||
84 | 5619 |
!Parser methodsFor:'statistic'! |
5620 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5621 |
rememberClassVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5622 |
readClassVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5623 |
readClassVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5624 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5625 |
readClassVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5626 |
self rememberClassVarUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5627 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5628 |
|
141 | 5629 |
rememberClassVarUsed:name |
5630 |
usedClassVars isNil ifTrue:[ |
|
5631 |
usedClassVars := Set new |
|
5632 |
]. |
|
5633 |
usedClassVars add:name. |
|
5634 |
self rememberVariableUsed:name |
|
5635 |
! |
|
5636 |
||
5637 |
rememberGlobalUsed:name |
|
5638 |
usedGlobals isNil ifTrue:[ |
|
5639 |
usedGlobals := Set new |
|
5640 |
]. |
|
5641 |
usedGlobals add:name. |
|
5642 |
self rememberVariableUsed:name |
|
5643 |
! |
|
5644 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5645 |
rememberInstVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5646 |
readInstVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5647 |
readInstVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5648 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5649 |
readInstVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5650 |
self rememberVariableUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5651 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
5652 |
|
141 | 5653 |
rememberInstVarUsed:name |
5654 |
usedInstVars isNil ifTrue:[ |
|
5655 |
usedInstVars := Set new |
|
5656 |
]. |
|
5657 |
usedInstVars add:name. |
|
5658 |
self rememberVariableUsed:name |
|
5659 |
! |
|
5660 |
||
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5661 |
rememberLocalUsed:name |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5662 |
usedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5663 |
usedLocalVars := Set new |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5664 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5665 |
usedLocalVars add:name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5666 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5667 |
! |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5668 |
|
84 | 5669 |
rememberSelectorUsed:sel |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5670 |
messagesSent isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5671 |
messagesSent := IdentitySet new. |
84 | 5672 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5673 |
messagesSent add:sel |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5674 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5675 |
|
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5676 |
rememberSelectorUsed:sel receiver:receiverNode |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5677 |
self rememberSelectorUsed:sel. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5678 |
receiverNode isSuper ifTrue:[ |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5679 |
self rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5680 |
] ifFalse:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5681 |
receiverNode isSelf ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5682 |
self rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5683 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5684 |
]. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5685 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5686 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5687 |
rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5688 |
messagesSentToSelf isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5689 |
messagesSentToSelf := IdentitySet new. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5690 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5691 |
messagesSentToSelf add:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5692 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5693 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5694 |
rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5695 |
messagesSentToSuper isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5696 |
messagesSentToSuper := IdentitySet new. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5697 |
]. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
5698 |
messagesSentToSuper add:sel |
84 | 5699 |
! |
5700 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5701 |
rememberSymbolUsed:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5702 |
usedSymbols isNil ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5703 |
usedSymbols := IdentitySet new. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5704 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5705 |
usedSymbols add:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5706 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
5707 |
|
84 | 5708 |
rememberVariableUsed:name |
5709 |
usedVars isNil ifTrue:[ |
|
5710 |
usedVars := Set new |
|
5711 |
]. |
|
5712 |
usedVars add:name |
|
5713 |
! ! |
|
5714 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
5715 |
!Parser class methodsFor:'documentation'! |
148 | 5716 |
|
5717 |
version |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
5718 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.271 2000-10-26 14:26:02 cg Exp $' |
148 | 5719 |
! ! |
141 | 5720 |
Parser initialize! |