author | Claus Gittinger <cg@exept.de> |
Thu, 14 May 1998 19:24:30 +0200 | |
changeset 710 | fc74f135494d |
parent 598 | f3e50cf083a0 |
child 744 | e871f9f072f8 |
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 |
||
116 |
codeLineNumber:nr on:aStream for:aCompiler |
|
117 |
"generate lineNumber information" |
|
118 |
||
119 |
nr > 0 ifTrue:[ |
|
120 |
nr <= 255 ifTrue:[ |
|
121 |
aStream nextPut:#lineno. |
|
122 |
aStream nextPut:nr |
|
123 |
] ifFalse:[ |
|
124 |
nr <= 16rFFFF ifTrue:[ |
|
125 |
aStream nextPut:#lineno16. |
|
126 |
aStream nextPut:((nr bitShift:-8) bitAnd:16rFF). |
|
127 |
aStream nextPut:(nr bitAnd:16rFF). |
|
128 |
] |
|
129 |
] |
|
130 |
] |
|
131 |
||
132 |
"Created: 21.10.1996 / 11:19:40 / cg" |
|
140 | 133 |
! ! |
134 |
||
135 |
!ParseNode methodsFor:'evaluation'! |
|
136 |
||
137 |
evaluateForCascade |
|
138 |
^ self evaluate |
|
139 |
! ! |
|
140 |
||
141 |
!ParseNode methodsFor:'printing'! |
|
142 |
||
143 |
printOn:aStream |
|
144 |
self printOn:aStream indent:0 |
|
145 |
! |
|
146 |
||
147 |
printString |
|
148 |
|stream| |
|
149 |
||
150 |
stream := WriteStream on:String new. |
|
151 |
self printOn:stream indent:0. |
|
152 |
^ stream contents |
|
153 |
! ! |
|
154 |
||
155 |
!ParseNode methodsFor:'private'! |
|
156 |
||
157 |
type:t |
|
158 |
"set the nodes type" |
|
159 |
||
160 |
type := t |
|
161 |
! ! |
|
162 |
||
0 | 163 |
!ParseNode methodsFor:'queries'! |
164 |
||
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
165 |
canReuseAsArg:anotherNode |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
166 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
167 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
168 |
"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
|
169 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
170 |
|
395 | 171 |
collectBlocksInto:aCollection |
172 |
^ self |
|
173 |
||
174 |
"Created: 23.10.1996 / 15:45:00 / cg" |
|
175 |
! |
|
176 |
||
140 | 177 |
isAssignment |
178 |
"return true, if this is a node for an assignment" |
|
179 |
||
180 |
^ false |
|
181 |
! |
|
182 |
||
183 |
isBinaryMessage |
|
184 |
"return true, if this is a node for a binary send" |
|
185 |
||
186 |
^ false |
|
187 |
! |
|
188 |
||
189 |
isBlockNode |
|
190 |
"return true, if this is a node for a block" |
|
191 |
||
192 |
^ false |
|
193 |
! |
|
194 |
||
0 | 195 |
isConstant |
13 | 196 |
"return true, if this is a node for a constant" |
197 |
||
198 |
^ false |
|
199 |
! |
|
200 |
||
53 | 201 |
isGlobal |
202 |
"return true, if this is a node for a global variable" |
|
203 |
||
204 |
^ false |
|
205 |
! |
|
206 |
||
140 | 207 |
isMessage |
208 |
"return true, if this is a node for a message expression" |
|
19 | 209 |
|
210 |
^ false |
|
211 |
! |
|
212 |
||
140 | 213 |
isPrimary |
214 |
"return true, if this is a node for a primary (i.e. non-send)" |
|
13 | 215 |
|
216 |
^ false |
|
217 |
! |
|
218 |
||
219 |
isReturnNode |
|
220 |
"return true, if this is a node for a return expression" |
|
221 |
||
0 | 222 |
^ false |
223 |
! |
|
224 |
||
140 | 225 |
isSuper |
226 |
"return true, if this is a super-node" |
|
13 | 227 |
|
0 | 228 |
^ false |
229 |
! |
|
230 |
||
231 |
isUnaryMessage |
|
13 | 232 |
"return true, if this is a node for a unary send" |
233 |
||
0 | 234 |
^ false |
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
235 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
236 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
237 |
isVariable |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
238 |
"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
|
239 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
240 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
241 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
242 |
"Created: 14.4.1996 / 00:46:44 / cg" |
0 | 243 |
! ! |
244 |
||
148 | 245 |
!ParseNode class methodsFor:'documentation'! |
246 |
||
247 |
version |
|
598 | 248 |
^ '$Header: /cvs/stx/stx/libcomp/ParseNode.st,v 1.22 1997-08-05 15:28:04 cg Exp $' |
148 | 249 |
! ! |