0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
52
|
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 |
ParseNode subclass:#StatementNode
|
140
|
14 |
instanceVariableNames:'expression nextStatement'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Compiler-Support'
|
0
|
18 |
!
|
|
19 |
|
20
|
20 |
!StatementNode class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
52
|
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, representing statements
|
|
39 |
"
|
|
40 |
! !
|
0
|
41 |
|
|
42 |
!StatementNode class methodsFor:'instance creation'!
|
|
43 |
|
|
44 |
expression:e
|
|
45 |
^ (self basicNew) expression:e
|
|
46 |
! !
|
|
47 |
|
140
|
48 |
!StatementNode methodsFor:'accessing'!
|
0
|
49 |
|
140
|
50 |
expression
|
|
51 |
^ expression
|
0
|
52 |
!
|
|
53 |
|
140
|
54 |
expression:e
|
|
55 |
expression := e
|
0
|
56 |
!
|
|
57 |
|
|
58 |
last
|
|
59 |
"return the last statement in a list"
|
|
60 |
|
|
61 |
|last this|
|
|
62 |
|
|
63 |
"this could be done more elegant - but with lots of recursion"
|
|
64 |
last := self.
|
|
65 |
this := self.
|
|
66 |
[this notNil] whileTrue:[
|
52
|
67 |
last := this.
|
|
68 |
this := this nextStatement
|
0
|
69 |
].
|
|
70 |
^ last
|
|
71 |
!
|
|
72 |
|
|
73 |
nextStatement
|
|
74 |
^ nextStatement
|
|
75 |
!
|
|
76 |
|
140
|
77 |
nextStatement:s
|
|
78 |
nextStatement := s
|
|
79 |
! !
|
|
80 |
|
|
81 |
!StatementNode methodsFor:'code generation'!
|
|
82 |
|
|
83 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler
|
|
84 |
"generate code for this statement - value not needed"
|
|
85 |
|
|
86 |
expression codeForSideEffectOn:aStream inBlock:b for:aCompiler
|
0
|
87 |
!
|
|
88 |
|
140
|
89 |
codeOn:aStream inBlock:b for:aCompiler
|
|
90 |
"generate code for this statement"
|
|
91 |
|
|
92 |
expression codeOn:aStream inBlock:b for:aCompiler
|
0
|
93 |
! !
|
|
94 |
|
140
|
95 |
!StatementNode methodsFor:'evaluating'!
|
|
96 |
|
|
97 |
evaluate
|
|
98 |
|lastValue thisStatement|
|
52
|
99 |
|
140
|
100 |
"this could be done more elegant - but with lots of recursion"
|
|
101 |
thisStatement := self.
|
|
102 |
[thisStatement notNil] whileTrue:[
|
|
103 |
lastValue := thisStatement evaluateExpression.
|
|
104 |
thisStatement := thisStatement nextStatement
|
|
105 |
].
|
|
106 |
^ lastValue
|
|
107 |
!
|
|
108 |
|
|
109 |
evaluateExpression
|
|
110 |
^ expression evaluate
|
52
|
111 |
! !
|
|
112 |
|
0
|
113 |
!StatementNode methodsFor:'printing'!
|
|
114 |
|
|
115 |
printAllOn:aStream
|
|
116 |
self printAllOn:aStream indent:4
|
|
117 |
!
|
|
118 |
|
|
119 |
printAllOn:aStream indent:i
|
|
120 |
|thisStatement|
|
|
121 |
|
|
122 |
thisStatement := self.
|
|
123 |
[thisStatement notNil] whileTrue:[
|
98
|
124 |
aStream spaces:i.
|
52
|
125 |
thisStatement printOn:aStream indent:i.
|
|
126 |
thisStatement nextStatement notNil ifTrue:[
|
|
127 |
aStream nextPut:$..
|
|
128 |
aStream cr.
|
|
129 |
].
|
|
130 |
thisStatement := thisStatement nextStatement
|
0
|
131 |
]
|
140
|
132 |
!
|
|
133 |
|
|
134 |
printOn:aStream indent:i
|
|
135 |
expression printOn:aStream indent:i.
|
0
|
136 |
! !
|
140
|
137 |
|
|
138 |
!StatementNode methodsFor:'queries'!
|
|
139 |
|
|
140 |
isConstant
|
|
141 |
nextStatement notNil ifTrue:[^ false].
|
|
142 |
^ expression isConstant
|
|
143 |
! !
|
|
144 |
|
148
|
145 |
!StatementNode class methodsFor:'documentation'!
|
|
146 |
|
|
147 |
version
|
|
148 |
^ '$Header: /cvs/stx/stx/libcomp/Attic/StatNode.st,v 1.13 1995-12-03 12:17:26 cg Exp $'
|
|
149 |
! !
|