author | Claus Gittinger <cg@exept.de> |
Thu, 15 Jul 1999 21:42:42 +0200 | |
changeset 914 | e67e983a8897 |
parent 862 | 2e3aefb24308 |
child 1044 | 03b2cc4a5d5f |
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 |
" |
|
12 |
||
13 |
Object subclass:#ParseNode |
|
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
14 |
instanceVariableNames:'type comments parenthized' |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
15 |
classVariableNames:'' |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
poolDictionaries:'' |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
17 |
category:'System-Compiler-Support' |
0 | 18 |
! |
19 |
||
20 | 20 |
!ParseNode class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
53 | 25 |
All Rights Reserved |
20 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
node for parse-trees; abstract class |
|
261 | 39 |
This is a helper class for the compiler. |
263 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
20 | 43 |
" |
44 |
! ! |
|
0 | 45 |
|
46 |
!ParseNode class methodsFor:'instance creation'! |
|
47 |
||
48 |
type:t |
|
49 |
^ (self basicNew) type:t |
|
50 |
! ! |
|
51 |
||
383 | 52 |
!ParseNode class methodsFor:'code generation helper'! |
53 |
||
54 |
codeLineNumber:nr on:aStream for:aCompiler |
|
55 |
"generate lineNumber information" |
|
56 |
||
57 |
nr > 0 ifTrue:[ |
|
58 |
nr <= 255 ifTrue:[ |
|
59 |
aStream nextPut:#lineno. |
|
60 |
aStream nextPut:nr |
|
61 |
] ifFalse:[ |
|
62 |
nr <= 16rFFFF ifTrue:[ |
|
63 |
aStream nextPut:#lineno16. |
|
64 |
aStream nextPut:((nr bitShift:-8) bitAnd:16rFF). |
|
65 |
aStream nextPut:(nr bitAnd:16rFF). |
|
66 |
] |
|
67 |
] |
|
68 |
] |
|
69 |
||
70 |
"Created: 21.10.1996 / 14:42:27 / cg" |
|
71 |
! ! |
|
72 |
||
140 | 73 |
!ParseNode methodsFor:'accessing'! |
74 |
||
75 |
lineNumber:dummy |
|
76 |
"set linenumber - ignored here" |
|
77 |
||
78 |
^ self |
|
79 |
! |
|
80 |
||
81 |
parenthized |
|
82 |
^ parenthized |
|
83 |
! |
|
84 |
||
85 |
parenthized:aBoolean |
|
86 |
parenthized := aBoolean |
|
87 |
! |
|
88 |
||
598 | 89 |
selectorPosition:aCharacterPosition |
90 |
"ignored here" |
|
91 |
||
92 |
"Created: 5.8.1997 / 16:32:17 / cg" |
|
93 |
! |
|
94 |
||
140 | 95 |
type |
96 |
"return the nodes type" |
|
97 |
||
98 |
^ type |
|
99 |
! ! |
|
100 |
||
101 |
!ParseNode methodsFor:'checks'! |
|
102 |
||
103 |
plausibilityCheck |
|
104 |
^ nil |
|
105 |
! ! |
|
106 |
||
107 |
!ParseNode methodsFor:'code generation'! |
|
108 |
||
109 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
110 |
"generate code for this statement - value not needed" |
|
111 |
||
112 |
self codeOn:aStream inBlock:b for:aCompiler. |
|
113 |
aStream nextPut:#drop |
|
373 | 114 |
! |
115 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
116 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
117 |
"generate code to return myself as a simple method return" |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
118 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
119 |
self codeOn:aStream inBlock:b for:aCompiler. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
120 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
121 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
122 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
123 |
aStream nextPut:#retTop. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
124 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
125 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
126 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
127 |
|
373 | 128 |
codeLineNumber:nr on:aStream for:aCompiler |
129 |
"generate lineNumber information" |
|
130 |
||
816 | 131 |
self class codeLineNumber:nr on:aStream for:aCompiler |
140 | 132 |
! ! |
133 |
||
134 |
!ParseNode methodsFor:'evaluation'! |
|
135 |
||
136 |
evaluateForCascade |
|
137 |
^ self evaluate |
|
138 |
! ! |
|
139 |
||
140 |
!ParseNode methodsFor:'printing'! |
|
141 |
||
142 |
printOn:aStream |
|
914 | 143 |
"append a user printed representation of the receiver to aStream. |
144 |
The format is suitable for a human - not meant to be read back." |
|
145 |
||
140 | 146 |
self printOn:aStream indent:0 |
147 |
! |
|
148 |
||
149 |
printString |
|
150 |
|stream| |
|
151 |
||
152 |
stream := WriteStream on:String new. |
|
153 |
self printOn:stream indent:0. |
|
154 |
^ stream contents |
|
155 |
! ! |
|
156 |
||
157 |
!ParseNode methodsFor:'private'! |
|
158 |
||
159 |
type:t |
|
160 |
"set the nodes type" |
|
161 |
||
162 |
type := t |
|
163 |
! ! |
|
164 |
||
0 | 165 |
!ParseNode methodsFor:'queries'! |
166 |
||
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
167 |
canReuseAsArg:anotherNode |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
168 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
169 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
170 |
"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
|
171 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
172 |
|
395 | 173 |
collectBlocksInto:aCollection |
174 |
^ self |
|
175 |
||
176 |
"Created: 23.10.1996 / 15:45:00 / cg" |
|
177 |
! |
|
178 |
||
140 | 179 |
isAssignment |
180 |
"return true, if this is a node for an assignment" |
|
181 |
||
182 |
^ false |
|
183 |
! |
|
184 |
||
185 |
isBinaryMessage |
|
186 |
"return true, if this is a node for a binary send" |
|
187 |
||
188 |
^ false |
|
189 |
! |
|
190 |
||
191 |
isBlockNode |
|
192 |
"return true, if this is a node for a block" |
|
193 |
||
194 |
^ false |
|
195 |
! |
|
196 |
||
744
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
197 |
isCascade |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
198 |
^ false |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
199 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
200 |
"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
|
201 |
! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
202 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
203 |
isCascadeToSuper |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
204 |
^ false |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
205 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
206 |
"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
|
207 |
! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
208 |
|
0 | 209 |
isConstant |
13 | 210 |
"return true, if this is a node for a constant" |
211 |
||
212 |
^ false |
|
213 |
! |
|
214 |
||
53 | 215 |
isGlobal |
216 |
"return true, if this is a node for a global variable" |
|
217 |
||
218 |
^ false |
|
219 |
! |
|
220 |
||
140 | 221 |
isMessage |
222 |
"return true, if this is a node for a message expression" |
|
19 | 223 |
|
224 |
^ false |
|
225 |
! |
|
226 |
||
140 | 227 |
isPrimary |
228 |
"return true, if this is a node for a primary (i.e. non-send)" |
|
13 | 229 |
|
230 |
^ false |
|
231 |
! |
|
232 |
||
233 |
isReturnNode |
|
234 |
"return true, if this is a node for a return expression" |
|
235 |
||
0 | 236 |
^ false |
237 |
! |
|
238 |
||
862 | 239 |
isSelf |
240 |
"return true, if this is a self-node" |
|
241 |
||
242 |
^ false |
|
243 |
! |
|
244 |
||
140 | 245 |
isSuper |
246 |
"return true, if this is a super-node" |
|
13 | 247 |
|
0 | 248 |
^ false |
249 |
! |
|
250 |
||
251 |
isUnaryMessage |
|
13 | 252 |
"return true, if this is a node for a unary send" |
253 |
||
0 | 254 |
^ false |
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
255 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
256 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
257 |
isVariable |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
258 |
"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
|
259 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
260 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
261 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
262 |
"Created: 14.4.1996 / 00:46:44 / cg" |
0 | 263 |
! ! |
264 |
||
148 | 265 |
!ParseNode class methodsFor:'documentation'! |
266 |
||
267 |
version |
|
914 | 268 |
^ '$Header: /cvs/stx/stx/libcomp/ParseNode.st,v 1.27 1999-07-15 19:42:42 cg Exp $' |
148 | 269 |
! ! |