author | Claus Gittinger <cg@exept.de> |
Wed, 21 Aug 2019 19:37:00 +0200 | |
changeset 4501 | d8b0a5d31348 |
parent 4471 | 970c73f20faf |
child 4506 | c5b6671d3761 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
53 | 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 |
" |
|
1044 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
3553 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
Object subclass:#ParseNode |
2550 | 17 |
instanceVariableNames:'parent type comments parenthized startPosition endPosition |
18 |
attributes' |
|
1046 | 19 |
classVariableNames:'' |
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
20 |
poolDictionaries:'' |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
21 |
category:'System-Compiler-Support' |
0 | 22 |
! |
23 |
||
20 | 24 |
!ParseNode class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
53 | 29 |
All Rights Reserved |
20 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
node for parse-trees; abstract class |
|
261 | 43 |
This is a helper class for the compiler. |
263 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
20 | 47 |
" |
48 |
! ! |
|
0 | 49 |
|
50 |
!ParseNode class methodsFor:'instance creation'! |
|
51 |
||
52 |
type:t |
|
53 |
^ (self basicNew) type:t |
|
54 |
! ! |
|
55 |
||
4471 | 56 |
!ParseNode methodsFor:'RBParser compatibility'! |
57 |
||
58 |
children |
|
59 |
^ ParseNodeVisitor collectChildrenOf:self |
|
60 |
! |
|
61 |
||
62 |
containedBy:anInterval |
|
63 |
startPosition isNil ifTrue:[^ false]. |
|
64 |
endPosition isNil ifTrue:[^ false]. |
|
65 |
^ anInterval first <= startPosition and:[anInterval last >= endPosition] |
|
66 |
! |
|
67 |
||
68 |
intersectsInterval: anInterval |
|
69 |
|myStart myStop ivStart ivStop| |
|
70 |
||
71 |
myStart := startPosition. |
|
72 |
myStop := endPosition. |
|
73 |
ivStart := anInterval first. |
|
74 |
ivStop := anInterval last. |
|
75 |
(myStart notNil and:[ivStop < myStart]) ifTrue:[^ false]. |
|
76 |
(myStop notNil and:[ivStart > myStop]) ifTrue:[^ false]. |
|
77 |
^ true |
|
78 |
! |
|
79 |
||
80 |
nodesDo:aBlock |
|
81 |
aBlock value: self. |
|
82 |
self children do: [:each | each nodesDo: aBlock] |
|
83 |
! |
|
84 |
||
85 |
start |
|
86 |
"for RBToken compat." |
|
87 |
||
88 |
^ self startPosition |
|
89 |
! |
|
90 |
||
91 |
whichNodeIntersects: anInterval |
|
92 |
| selectedChildren nChildren | |
|
93 |
||
94 |
(self intersectsInterval: anInterval) ifFalse: [^nil]. |
|
95 |
||
96 |
selectedChildren := self children select:[:each | |
|
97 |
each intersectsInterval: anInterval |
|
98 |
]. |
|
99 |
||
100 |
nChildren := selectedChildren size. |
|
101 |
nChildren == 0 ifTrue:[ |
|
102 |
^ self "/ I intersect |
|
103 |
]. |
|
104 |
nChildren == 1 ifTrue:[ |
|
105 |
^ selectedChildren first whichNodeIntersects: anInterval |
|
106 |
]. |
|
107 |
"/ self halt:'should this happen ?'. |
|
108 |
^ self "/ I intersect |
|
109 |
! |
|
110 |
||
111 |
whichNodeIsContainedBy: anInterval |
|
112 |
| selectedChildren | |
|
113 |
||
114 |
(self intersectsInterval: anInterval) ifFalse: [^nil]. |
|
115 |
(self containedBy: anInterval) ifTrue: [^self]. |
|
116 |
||
117 |
selectedChildren := self children |
|
118 |
select: [:each | each intersectsInterval: anInterval]. |
|
119 |
^ selectedChildren size == 1 |
|
120 |
ifTrue: [selectedChildren first whichNodeIsContainedBy: anInterval] |
|
121 |
ifFalse: [nil] |
|
122 |
! ! |
|
123 |
||
2819 | 124 |
!ParseNode methodsFor:'accessing'! |
2694 | 125 |
|
2819 | 126 |
enclosingBlock |
127 |
"Return closest enclosing block node or nil" |
|
128 |
||
129 |
| block | |
|
130 |
block := parent. |
|
3485 | 131 |
[ block notNil and:[block realNode isBlockNode not] ] whileTrue:[ |
132 |
block := block realNode parent. |
|
2819 | 133 |
]. |
134 |
^block. |
|
135 |
||
136 |
"Created: / 16-02-2012 / 22:46:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
137 |
! |
|
140 | 138 |
|
2505 | 139 |
endPosition |
3542 | 140 |
"the node's last character position in the original source" |
141 |
||
2505 | 142 |
^ endPosition |
143 |
! |
|
144 |
||
2265 | 145 |
endPosition:aCharacterPosition |
2505 | 146 |
|
147 |
endPosition := aCharacterPosition |
|
148 |
||
2618
256319b44ac8
More fixes for start/end position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2564
diff
changeset
|
149 |
"Modified: / 28-07-2011 / 10:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2265 | 150 |
! |
151 |
||
2548 | 152 |
line |
153 |
||
154 |
"Compatibility" |
|
155 |
||
156 |
^self lineNumber |
|
157 |
||
158 |
"Created: / 09-07-2011 / 22:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
159 |
! |
|
160 |
||
161 |
lineNumber |
|
162 |
||
163 |
^nil |
|
164 |
||
165 |
"Created: / 09-07-2011 / 22:30:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
166 |
! |
|
167 |
||
140 | 168 |
lineNumber:dummy |
169 |
"set linenumber - ignored here" |
|
170 |
||
171 |
^ self |
|
172 |
! |
|
173 |
||
2550 | 174 |
parent |
175 |
||
176 |
^parent |
|
177 |
||
178 |
"Created: / 11-07-2011 / 17:36:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
179 |
! |
|
180 |
||
181 |
parent: aParseNode |
|
182 |
||
183 |
parent := aParseNode |
|
184 |
||
185 |
"Created: / 11-07-2011 / 17:36:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
186 |
! |
|
187 |
||
1990
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
188 |
parenthesized |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
189 |
^ parenthized ? false |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
190 |
! |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
191 |
|
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
192 |
parenthesized:aBoolean |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
193 |
parenthized := aBoolean |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
194 |
! |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
195 |
|
140 | 196 |
parenthized |
1990
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
197 |
"obsolete - typo in message name - use parenthesized" |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
198 |
|
1338 | 199 |
^ parenthized ? false |
140 | 200 |
! |
201 |
||
202 |
parenthized:aBoolean |
|
1990
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
203 |
"obsolete - typo in message name - use parenthesized:" |
ede012b2bd5b
oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents:
1804
diff
changeset
|
204 |
|
140 | 205 |
parenthized := aBoolean |
206 |
! |
|
207 |
||
3483 | 208 |
realNode |
209 |
^ self |
|
210 |
! |
|
211 |
||
3300 | 212 |
selectorPartPositions:selectorPartPositions |
213 |
"/ ignored here, but implemented because sent without checking |
|
214 |
"/ when parsing keyword messages to an optimized messageNode |
|
215 |
"/ (which become optimized to a constantNode by the folder) |
|
216 |
||
217 |
"Created: / 28-08-2013 / 21:17:22 / cg" |
|
218 |
! |
|
219 |
||
598 | 220 |
selectorPosition:aCharacterPosition |
221 |
"ignored here" |
|
222 |
||
223 |
"Created: 5.8.1997 / 16:32:17 / cg" |
|
224 |
! |
|
225 |
||
2505 | 226 |
startPosition |
3542 | 227 |
"the node's character position in the original source" |
228 |
||
2505 | 229 |
^ startPosition |
230 |
! |
|
231 |
||
2550 | 232 |
startPosition:start |
2505 | 233 |
|
2550 | 234 |
startPosition := start |
2505 | 235 |
|
236 |
"Modified: / 08-04-2011 / 22:03:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2265 | 237 |
! |
238 |
||
2550 | 239 |
startPosition:start endPosition: end |
240 |
startPosition := start. |
|
2564
43f35a40884d
- parse tree nodes are no longer shared
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2550
diff
changeset
|
241 |
endPosition := end. |
2550 | 242 |
|
243 |
"Created: / 11-07-2011 / 17:44:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4352 | 244 |
"Modified: / 15-02-2019 / 14:39:10 / Claus Gittinger" |
2550 | 245 |
! |
246 |
||
140 | 247 |
type |
248 |
"return the nodes type" |
|
249 |
||
250 |
^ type |
|
251 |
! ! |
|
252 |
||
4471 | 253 |
|
2546
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
254 |
!ParseNode methodsFor:'attributes access'! |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
255 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
256 |
objectAttributes |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
257 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
258 |
^attributes |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
259 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
260 |
"Created: / 09-07-2011 / 12:17:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
261 |
! |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
262 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
263 |
objectAttributes: anObject |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
264 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
265 |
attributes := anObject |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
266 |
|
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
267 |
"Created: / 09-07-2011 / 12:18:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
268 |
! ! |
5ae96e911e36
ParseNode: added attributes instvar for other tools to store
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2533
diff
changeset
|
269 |
|
140 | 270 |
!ParseNode methodsFor:'checks'! |
271 |
||
2095 | 272 |
plausibilityCheckIn:aParser |
140 | 273 |
^ nil |
274 |
! ! |
|
275 |
||
276 |
!ParseNode methodsFor:'code generation'! |
|
277 |
||
278 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
279 |
"generate code for this statement - value not needed" |
|
280 |
||
281 |
self codeOn:aStream inBlock:b for:aCompiler. |
|
282 |
aStream nextPut:#drop |
|
373 | 283 |
! |
284 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
285 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
286 |
"generate code to return myself as a simple method return" |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
287 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
288 |
self codeOn:aStream inBlock:b for:aCompiler. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
289 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
290 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
291 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
292 |
aStream nextPut:#retTop. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
293 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
294 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
295 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
296 |
|
1056 | 297 |
codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
298 |
"generate code for this statement - value is needed" |
|
299 |
||
300 |
self codeOn:aStream inBlock:b for:aCompiler. |
|
301 |
! |
|
302 |
||
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
303 |
codeLineNumber:nr on:codeStream for:aCompiler |
373 | 304 |
"generate lineNumber information" |
305 |
||
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
306 |
aCompiler codeLineNumber:nr on:codeStream |
2029 | 307 |
! |
308 |
||
309 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
|
310 |
^ self subclassResponsibility |
|
140 | 311 |
! ! |
312 |
||
1804
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
313 |
!ParseNode methodsFor:'code generation helpers'! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
314 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
315 |
emitPushGlobalWithLiteralIndex:litIndex on:aTokenCodeStream for:aCompiler |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
316 |
litIndex <= 255 ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
317 |
aTokenCodeStream nextPut:#pushGlobalS; nextPut:litIndex |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
318 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
319 |
litIndex <= 16rFFFF ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
320 |
aTokenCodeStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
321 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
322 |
aTokenCodeStream nextPut:#pushGlobalVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
323 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
324 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
325 |
! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
326 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
327 |
emitPushLiteral:value on:aTokenCodeStream for:aCompiler |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
328 |
|index| |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
329 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
330 |
index := aCompiler addLiteral:value. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
331 |
self emitPushLiteralIndex:index on:aTokenCodeStream for:aCompiler |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
332 |
! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
333 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
334 |
emitPushLiteralIndex:index on:aTokenCodeStream for:aCompiler |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
335 |
index <= 8 ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
336 |
aTokenCodeStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
337 |
nextPut:(#(pushLit1 pushLit2 pushLit3 pushLit4 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
338 |
pushLit5 pushLit6 pushLit7 pushLit8) at:index). |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
339 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
340 |
index <= 255 ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
341 |
aTokenCodeStream nextPut:#pushLitS; nextPut:index |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
342 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
343 |
index <= 16rFFFF ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
344 |
aTokenCodeStream nextPut:#pushLitL; nextPut:index; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
345 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
346 |
aTokenCodeStream nextPut:#pushLitVL; nextPut:0; nextPut:index; nextPut:0; nextPut:0; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
347 |
] |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
348 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
349 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
350 |
! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
351 |
|
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
352 |
emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream for:aCompiler |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
353 |
lineNr >= 255 ifTrue:[ |
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
354 |
self codeLineNumber: lineNr on: aStream for:aCompiler. |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
355 |
]. |
1804
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
356 |
(litIndex <= 255) ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
357 |
nargs <= 3 ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
358 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
359 |
nextPut:(#(send0 send1 send2 send3) at:(nargs+1)); nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
360 |
nextPut:litIndex. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
361 |
^ self. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
362 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
363 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
364 |
nextPut:#send; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
365 |
nextPut:litIndex; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
366 |
nextPut:nargs. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
367 |
^ self. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
368 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
369 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
370 |
(litIndex <= 16rFFFF) ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
371 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
372 |
nextPut:#sendL; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
373 |
nextPut:litIndex; nextPut:0; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
374 |
nextPut:nargs. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
375 |
^ self. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
376 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
377 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
378 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
379 |
nextPut:#sendVL; nextPut:0; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
380 |
nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
381 |
nextPut:nargs. |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
382 |
|
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
383 |
"Modified: / 13-04-2013 / 11:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1804
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
384 |
! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
385 |
|
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
386 |
emitStoreGlobalWithLiteralIndex:litIndex on:aTokenCodeStream for:aCompiler |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
387 |
litIndex <= 255 ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
388 |
aTokenCodeStream nextPut:#storeGlobalS; nextPut:litIndex |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
389 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
390 |
litIndex <= 16rFFFF ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
391 |
aTokenCodeStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
392 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
393 |
aTokenCodeStream nextPut:#storeGlobalVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0; nextPut:0 |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
394 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
395 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
396 |
! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
397 |
|
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
398 |
emitSuperSendLiteralIndex:litIndex classLiteralIndex:clsLitIndex numArgs:nargs line:lineNr on:aStream for:aCompiler |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
399 |
lineNr >= 255 ifTrue:[ |
3165
7894a735faac
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
3110
diff
changeset
|
400 |
self codeLineNumber: lineNr on: aStream for:aCompiler. |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
401 |
]. |
1804
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
402 |
(litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
403 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
404 |
nextPut:#superSend; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
405 |
nextPut:litIndex; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
406 |
nextPut:nargs; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
407 |
nextPut:clsLitIndex. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
408 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
409 |
(litIndex <= 16rFFFF and:[clsLitIndex <= 16rFFFF]) ifTrue:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
410 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
411 |
nextPut:#superSendL; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
412 |
nextPut:litIndex; nextPut:0; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
413 |
nextPut:nargs; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
414 |
nextPut:clsLitIndex; nextPut:0. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
415 |
] ifFalse:[ |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
416 |
aStream |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
417 |
nextPut:#superSendVL; nextPut:0; nextPut:lineNr; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
418 |
nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
419 |
nextPut:nargs; |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
420 |
nextPut:clsLitIndex; nextPut:0; nextPut:0; nextPut:0. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
421 |
]. |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
422 |
]. |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
423 |
|
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
424 |
"Modified: / 13-04-2013 / 11:01:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1804
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
425 |
! ! |
7c22dbaa8d10
some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents:
1725
diff
changeset
|
426 |
|
1503 | 427 |
!ParseNode methodsFor:'enumeration'! |
428 |
||
3337 | 429 |
allNodesDo:aBlock |
430 |
"evaluate aBlock for each variable-node here and in subnodes" |
|
431 |
||
4232 | 432 |
aBlock value:self. |
433 |
self allSubNodesDo:aBlock. |
|
434 |
! |
|
435 |
||
436 |
allSubNodesDo:aBlock |
|
4234 | 437 |
"/ self subclassResponsibility. |
3337 | 438 |
! |
439 |
||
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
440 |
messageNodesDo:aBlock |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
441 |
"evaluate aBlock for each message-node here and in subnodes" |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
442 |
|
3315 | 443 |
self messagesDo:aBlock |
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
444 |
! |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
445 |
|
3276 | 446 |
messageSelectors |
3337 | 447 |
"return a collection of message selectors" |
3276 | 448 |
|
449 |
|setOfSymbols| |
|
450 |
||
451 |
setOfSymbols := Set new. |
|
3279 | 452 |
self messageSelectorsDo:[:each | setOfSymbols add:each ]. |
3276 | 453 |
^ setOfSymbols |
454 |
! |
|
455 |
||
3279 | 456 |
messageSelectorsDo:aBlock |
457 |
"evaluate aBlock for each message-selector here and in subnodes" |
|
458 |
||
459 |
^ self |
|
460 |
! |
|
461 |
||
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
462 |
messages |
3276 | 463 |
"return a collection of messageNodes" |
464 |
||
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
465 |
|setOfMessages| |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
466 |
|
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
467 |
setOfMessages := Set new. |
3279 | 468 |
self messagesDo:[:each | setOfMessages add:each ]. |
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
469 |
^ setOfMessages |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
470 |
! |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
471 |
|
1503 | 472 |
messagesDo:aBlock |
3275
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
473 |
"evaluate aBlock for each message-node here and in subnodes" |
921a8afad859
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
474 |
|
1503 | 475 |
^ self |
3315 | 476 |
! |
477 |
||
478 |
variableNodesDo:aBlock |
|
479 |
"evaluate aBlock for each variable-node here and in subnodes" |
|
480 |
||
481 |
^ self |
|
1503 | 482 |
! ! |
483 |
||
140 | 484 |
!ParseNode methodsFor:'evaluation'! |
485 |
||
1383 | 486 |
evaluate |
487 |
^ self evaluateIn:nil |
|
488 |
! |
|
489 |
||
140 | 490 |
evaluateForCascade |
1383 | 491 |
^ self evaluateForCascadeIn:nil |
492 |
! |
|
493 |
||
494 |
evaluateForCascadeIn:anEnvironment |
|
495 |
^ self evaluateIn:anEnvironment |
|
496 |
! |
|
497 |
||
498 |
evaluateIn:anEnvironment |
|
499 |
self subclassResponsibility |
|
2505 | 500 |
! |
501 |
||
502 |
isStatement |
|
503 |
^false. |
|
504 |
||
505 |
"Created: / 22-02-2011 / 16:29:50 / Jakub <zelenja7@fel.cvut.cz>" |
|
140 | 506 |
! ! |
507 |
||
4471 | 508 |
|
509 |
||
1080 | 510 |
!ParseNode methodsFor:'printing & storing'! |
140 | 511 |
|
512 |
printOn:aStream |
|
914 | 513 |
"append a user printed representation of the receiver to aStream. |
514 |
The format is suitable for a human - not meant to be read back." |
|
515 |
||
140 | 516 |
self printOn:aStream indent:0 |
517 |
! |
|
518 |
||
1588 | 519 |
printOn:aStream indent:indent |
520 |
"append a user printed representation of the receiver to aStream. |
|
521 |
The format is suitable for a human - not meant to be read back." |
|
522 |
||
523 |
self subclassResponsibility |
|
524 |
||
525 |
"Created: / 20-04-2005 / 14:21:46 / cg" |
|
526 |
! |
|
527 |
||
528 |
printOn:aStream indent:indent parenthized:parenthized |
|
529 |
parenthized ifTrue:[ |
|
530 |
aStream nextPutAll:'(' |
|
531 |
]. |
|
532 |
self printOn:aStream indent:indent. |
|
533 |
parenthized ifTrue:[ |
|
534 |
aStream nextPutAll:')' |
|
535 |
]. |
|
536 |
||
537 |
"Created: / 20-04-2005 / 14:21:28 / cg" |
|
4501 | 538 |
! |
539 |
||
540 |
printStatementListOn:aStream indent:i |
|
541 |
self printOn:aStream indent:i |
|
140 | 542 |
! ! |
543 |
||
544 |
!ParseNode methodsFor:'private'! |
|
545 |
||
546 |
type:t |
|
547 |
"set the nodes type" |
|
548 |
||
549 |
type := t |
|
550 |
! ! |
|
551 |
||
0 | 552 |
!ParseNode methodsFor:'queries'! |
553 |
||
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
554 |
canReuseAsArg:anotherNode |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
555 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
556 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
557 |
"Created: 14.4.1996 / 00:43:08 / cg" |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
558 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
559 |
|
395 | 560 |
collectBlocksInto:aCollection |
561 |
^ self |
|
562 |
||
563 |
"Created: 23.10.1996 / 15:45:00 / cg" |
|
564 |
! |
|
565 |
||
2382 | 566 |
containsReturn |
567 |
^ false |
|
568 |
! |
|
569 |
||
3296 | 570 |
positionToInsertPeriodForStatementSeparation |
571 |
^ self endPosition + (parenthized == true ifTrue:1 ifFalse:0) |
|
572 |
||
573 |
"Created: 14.4.1996 / 00:43:08 / cg" |
|
574 |
! |
|
575 |
||
2327 | 576 |
precedence |
577 |
^ 9999 |
|
578 |
! |
|
579 |
||
580 |
withConstantValueDo:aBlock |
|
581 |
"return true, if this evaluates to a constant value |
|
582 |
and evaluate aBlock with it" |
|
583 |
||
584 |
^ false |
|
585 |
! ! |
|
586 |
||
587 |
!ParseNode methodsFor:'testing'! |
|
588 |
||
140 | 589 |
isAssignment |
590 |
"return true, if this is a node for an assignment" |
|
591 |
||
592 |
^ false |
|
593 |
! |
|
594 |
||
595 |
isBinaryMessage |
|
596 |
"return true, if this is a node for a binary send" |
|
597 |
||
598 |
^ false |
|
599 |
! |
|
600 |
||
601 |
isBlockNode |
|
602 |
"return true, if this is a node for a block" |
|
603 |
||
604 |
^ false |
|
605 |
! |
|
606 |
||
2533 | 607 |
isBreakPointNode |
608 |
^ false |
|
609 |
||
610 |
"Created: / 05-07-2011 / 21:14:01 / cg" |
|
611 |
! |
|
612 |
||
744
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
613 |
isCascade |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
614 |
^ false |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
615 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
616 |
"Created: / 16.7.1998 / 20:11:33 / cg" |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
617 |
! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
618 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
619 |
isCascadeToSuper |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
620 |
^ false |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
621 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
622 |
"Created: / 16.7.1998 / 19:51:07 / cg" |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
623 |
! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
624 |
|
0 | 625 |
isConstant |
13 | 626 |
"return true, if this is a node for a constant" |
627 |
||
628 |
^ false |
|
629 |
! |
|
630 |
||
4277 | 631 |
isConstantNumber |
632 |
"return true, if this is a node for a constant number" |
|
633 |
||
634 |
^ false |
|
635 |
||
636 |
"Created: / 16-06-2018 / 08:47:03 / Claus Gittinger" |
|
637 |
! |
|
638 |
||
1533 | 639 |
isErrorNode |
640 |
^ false |
|
641 |
! |
|
642 |
||
4322 | 643 |
isFunctionCallNode |
644 |
^ false |
|
645 |
||
646 |
"Created: / 13-12-2018 / 22:35:28 / Claus Gittinger" |
|
647 |
! |
|
648 |
||
4330 | 649 |
isFunctionNode |
650 |
^ false |
|
651 |
||
652 |
"Created: / 08-02-2019 / 10:53:58 / Claus Gittinger" |
|
653 |
! |
|
654 |
||
53 | 655 |
isGlobal |
656 |
"return true, if this is a node for a global variable" |
|
657 |
||
658 |
^ false |
|
659 |
! |
|
660 |
||
2000 | 661 |
isGlobalNamed:globalName |
662 |
"return true, if this is a node for a particular global variable" |
|
663 |
||
664 |
^ false |
|
665 |
||
666 |
"Created: / 05-03-2007 / 15:13:23 / cg" |
|
667 |
! |
|
668 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
669 |
isGlobalVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
670 |
^ false |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
671 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
672 |
|
1528 | 673 |
isImmutable |
674 |
"not used with ST/X - |
|
675 |
for JavaScript nodes return true here." |
|
676 |
||
677 |
^ true |
|
678 |
! |
|
679 |
||
2403
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
680 |
isImplicitJavaScriptMessage |
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
681 |
"return true, if this is a node for an implicit getter/setter send" |
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
682 |
|
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
683 |
^ false |
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
684 |
|
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
685 |
"Created: / 05-07-2010 / 14:11:41 / cg" |
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
686 |
! |
79c95fae81e8
added: #isImplicitJavaScriptMessage
Claus Gittinger <cg@exept.de>
parents:
2402
diff
changeset
|
687 |
|
4237 | 688 |
isInnerFunction |
689 |
^ false |
|
690 |
! |
|
691 |
||
1725 | 692 |
isInnerJavaScriptBlock |
693 |
^ false |
|
694 |
! |
|
695 |
||
2862 | 696 |
isJAVA |
697 |
"Return true, if receiver is global variable node JAVA. |
|
698 |
Used to highlight Java class references." |
|
699 |
||
700 |
^false |
|
701 |
||
702 |
"Created: / 19-04-2012 / 09:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
703 |
! |
|
704 |
||
705 |
isJavaPackageReference |
|
706 |
"Return true, given node is JAVA package reference in form: |
|
707 |
JAVA package1 package2 |
|
708 |
" |
|
709 |
||
710 |
^false |
|
711 |
||
712 |
"Created: / 19-04-2012 / 09:53:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
713 |
! |
|
714 |
||
3184 | 715 |
isJavaScriptAndExpression |
716 |
^ false |
|
717 |
! |
|
718 |
||
2402
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
719 |
isJavaScriptArrayAccess |
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
720 |
"return true, if this is a node for a javascript array reference i.e. expr[]" |
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
721 |
|
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
722 |
^ false |
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
723 |
|
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
724 |
"Created: / 05-07-2010 / 14:04:27 / cg" |
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
725 |
! |
da3d16a4193d
changed: #testplanItem:groupPattern:executor:testPlanExecutor:
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
726 |
|
2400 | 727 |
isJavaScriptBlock |
728 |
"return true, if this is a node for a javascript block" |
|
729 |
||
730 |
^ false |
|
731 |
||
732 |
"Created: / 09-06-2010 / 01:53:19 / cg" |
|
733 |
! |
|
734 |
||
3438 | 735 |
isJavaScriptClassNode |
736 |
^ false |
|
737 |
! |
|
738 |
||
2401
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
739 |
isJavaScriptConditionalExpression |
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
740 |
"return true, if this is a node for a ?: expression" |
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
741 |
|
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
742 |
^ false |
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
743 |
|
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
744 |
"Created: / 09-06-2010 / 01:55:15 / cg" |
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
745 |
! |
3bfe65bdcc64
added: #isJavaScriptConditionalExpression
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
746 |
|
3184 | 747 |
isJavaScriptOrExpression |
748 |
^ false |
|
749 |
! |
|
750 |
||
3812 | 751 |
isLiteral |
752 |
"for compatibility with RB-AST" |
|
753 |
||
754 |
^ self isConstant |
|
755 |
! |
|
756 |
||
4471 | 757 |
isLiteralArray |
758 |
"for compatibility with RB-AST" |
|
759 |
||
760 |
^ false |
|
761 |
! |
|
762 |
||
763 |
isLiteralCString |
|
764 |
"for compatibility with RB-AST" |
|
765 |
||
766 |
^ false |
|
767 |
! |
|
768 |
||
3474 | 769 |
isLocalVariable |
770 |
^ false |
|
771 |
! |
|
772 |
||
140 | 773 |
isMessage |
774 |
"return true, if this is a node for a message expression" |
|
19 | 775 |
|
776 |
^ false |
|
777 |
! |
|
778 |
||
3414 | 779 |
isMethodNode |
780 |
^ false |
|
781 |
! |
|
782 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
783 |
isMethodVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
784 |
^ false |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
785 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1114
diff
changeset
|
786 |
|
2327 | 787 |
isNew |
788 |
"return true, if this is a new XXXX node" |
|
789 |
||
790 |
^ false |
|
791 |
! |
|
792 |
||
2088 | 793 |
isPostIncDec |
794 |
"for JavaScript" |
|
795 |
||
796 |
^ false |
|
797 |
! |
|
798 |
||
799 |
isPreIncDec |
|
800 |
"for JavaScript" |
|
801 |
||
802 |
^ false |
|
803 |
! |
|
804 |
||
140 | 805 |
isPrimary |
806 |
"return true, if this is a node for a primary (i.e. non-send)" |
|
13 | 807 |
|
808 |
^ false |
|
809 |
! |
|
810 |
||
811 |
isReturnNode |
|
812 |
"return true, if this is a node for a return expression" |
|
813 |
||
0 | 814 |
^ false |
815 |
! |
|
816 |
||
862 | 817 |
isSelf |
818 |
"return true, if this is a self-node" |
|
819 |
||
820 |
^ false |
|
821 |
! |
|
822 |
||
2505 | 823 |
isStatementNode |
824 |
"return true, if this is a statement node" |
|
825 |
||
826 |
^ false |
|
827 |
||
828 |
"Created: / 13-06-2011 / 11:26:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
829 |
! |
|
830 |
||
140 | 831 |
isSuper |
832 |
"return true, if this is a super-node" |
|
13 | 833 |
|
0 | 834 |
^ false |
835 |
! |
|
836 |
||
2089 | 837 |
isThis |
838 |
"for JavaScript" |
|
839 |
||
840 |
^ false |
|
841 |
! |
|
842 |
||
0 | 843 |
isUnaryMessage |
13 | 844 |
"return true, if this is a node for a unary send" |
845 |
||
0 | 846 |
^ false |
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
847 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
848 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
849 |
isVariable |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
850 |
"return true, if this is a node for a variable" |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
851 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
852 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
853 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
854 |
"Created: 14.4.1996 / 00:46:44 / cg" |
2694 | 855 |
! |
856 |
||
857 |
isVariableNode |
|
858 |
"return true, if this is a node for a variable" |
|
859 |
||
860 |
^ self isVariable |
|
861 |
||
862 |
"Created: / 12-09-2011 / 09:32:17 / cg" |
|
0 | 863 |
! ! |
864 |
||
148 | 865 |
!ParseNode class methodsFor:'documentation'! |
866 |
||
3276 | 867 |
version |
3812 | 868 |
^ '$Header$' |
3276 | 869 |
! |
870 |
||
2505 | 871 |
version_CVS |
3812 | 872 |
^ '$Header$' |
148 | 873 |
! ! |
3110
f517641d3673
Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2862
diff
changeset
|
874 |