author | Claus Gittinger <cg@exept.de> |
Tue, 12 Nov 1996 13:18:57 +0100 | |
changeset 441 | fa5637faa969 |
parent 395 | 16156d8711c2 |
child 598 | f3e50cf083a0 |
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 |
||
89 |
type |
|
90 |
"return the nodes type" |
|
91 |
||
92 |
^ type |
|
93 |
! ! |
|
94 |
||
95 |
!ParseNode methodsFor:'checks'! |
|
96 |
||
97 |
plausibilityCheck |
|
98 |
^ nil |
|
99 |
! ! |
|
100 |
||
101 |
!ParseNode methodsFor:'code generation'! |
|
102 |
||
103 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
104 |
"generate code for this statement - value not needed" |
|
105 |
||
106 |
self codeOn:aStream inBlock:b for:aCompiler. |
|
107 |
aStream nextPut:#drop |
|
373 | 108 |
! |
109 |
||
110 |
codeLineNumber:nr on:aStream for:aCompiler |
|
111 |
"generate lineNumber information" |
|
112 |
||
113 |
nr > 0 ifTrue:[ |
|
114 |
nr <= 255 ifTrue:[ |
|
115 |
aStream nextPut:#lineno. |
|
116 |
aStream nextPut:nr |
|
117 |
] ifFalse:[ |
|
118 |
nr <= 16rFFFF ifTrue:[ |
|
119 |
aStream nextPut:#lineno16. |
|
120 |
aStream nextPut:((nr bitShift:-8) bitAnd:16rFF). |
|
121 |
aStream nextPut:(nr bitAnd:16rFF). |
|
122 |
] |
|
123 |
] |
|
124 |
] |
|
125 |
||
126 |
"Created: 21.10.1996 / 11:19:40 / cg" |
|
140 | 127 |
! ! |
128 |
||
129 |
!ParseNode methodsFor:'evaluation'! |
|
130 |
||
131 |
evaluateForCascade |
|
132 |
^ self evaluate |
|
133 |
! ! |
|
134 |
||
135 |
!ParseNode methodsFor:'printing'! |
|
136 |
||
137 |
printOn:aStream |
|
138 |
self printOn:aStream indent:0 |
|
139 |
! |
|
140 |
||
141 |
printString |
|
142 |
|stream| |
|
143 |
||
144 |
stream := WriteStream on:String new. |
|
145 |
self printOn:stream indent:0. |
|
146 |
^ stream contents |
|
147 |
! ! |
|
148 |
||
149 |
!ParseNode methodsFor:'private'! |
|
150 |
||
151 |
type:t |
|
152 |
"set the nodes type" |
|
153 |
||
154 |
type := t |
|
155 |
! ! |
|
156 |
||
0 | 157 |
!ParseNode methodsFor:'queries'! |
158 |
||
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
159 |
canReuseAsArg:anotherNode |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
160 |
^ false |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
161 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
162 |
"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
|
163 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
164 |
|
395 | 165 |
collectBlocksInto:aCollection |
166 |
^ self |
|
167 |
||
168 |
"Created: 23.10.1996 / 15:45:00 / cg" |
|
169 |
! |
|
170 |
||
140 | 171 |
isAssignment |
172 |
"return true, if this is a node for an assignment" |
|
173 |
||
174 |
^ false |
|
175 |
! |
|
176 |
||
177 |
isBinaryMessage |
|
178 |
"return true, if this is a node for a binary send" |
|
179 |
||
180 |
^ false |
|
181 |
! |
|
182 |
||
183 |
isBlockNode |
|
184 |
"return true, if this is a node for a block" |
|
185 |
||
186 |
^ false |
|
187 |
! |
|
188 |
||
0 | 189 |
isConstant |
13 | 190 |
"return true, if this is a node for a constant" |
191 |
||
192 |
^ false |
|
193 |
! |
|
194 |
||
53 | 195 |
isGlobal |
196 |
"return true, if this is a node for a global variable" |
|
197 |
||
198 |
^ false |
|
199 |
! |
|
200 |
||
140 | 201 |
isMessage |
202 |
"return true, if this is a node for a message expression" |
|
19 | 203 |
|
204 |
^ false |
|
205 |
! |
|
206 |
||
140 | 207 |
isPrimary |
208 |
"return true, if this is a node for a primary (i.e. non-send)" |
|
13 | 209 |
|
210 |
^ false |
|
211 |
! |
|
212 |
||
213 |
isReturnNode |
|
214 |
"return true, if this is a node for a return expression" |
|
215 |
||
0 | 216 |
^ false |
217 |
! |
|
218 |
||
140 | 219 |
isSuper |
220 |
"return true, if this is a super-node" |
|
13 | 221 |
|
0 | 222 |
^ false |
223 |
! |
|
224 |
||
225 |
isUnaryMessage |
|
13 | 226 |
"return true, if this is a node for a unary send" |
227 |
||
0 | 228 |
^ false |
244
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
229 |
! |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
230 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
231 |
isVariable |
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
232 |
"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
|
233 |
|
2ce60e837d52
use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
234 |
^ false |
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 |
"Created: 14.4.1996 / 00:46:44 / cg" |
0 | 237 |
! ! |
238 |
||
148 | 239 |
!ParseNode class methodsFor:'documentation'! |
240 |
||
241 |
version |
|
395 | 242 |
^ '$Header: /cvs/stx/stx/libcomp/ParseNode.st,v 1.21 1996-10-23 15:33:05 cg Exp $' |
148 | 243 |
! ! |