--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/StatementNode.st Fri Jul 16 11:38:57 1993 +0200
@@ -0,0 +1,122 @@
+"
+ COPYRIGHT (c) 1989-93 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+ParseNode subclass:#StatementNode
+ instanceVariableNames:'expression nextStatement'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'System-Compiler-Support'
+!
+
+StatementNode comment:'
+
+COPYRIGHT (c) 1989-93 by Claus Gittinger
+ All Rights Reserved
+
+%W% %E%
+'!
+
+!StatementNode class methodsFor:'instance creation'!
+
+expression:e
+ ^ (self basicNew) expression:e
+! !
+
+!StatementNode methodsFor:'evaluating'!
+
+evaluateExpression
+ ^ expression evaluate
+!
+
+evaluate
+ |lastValue thisStatement|
+
+ "this could be done more elegant - but with lots of recursion"
+ thisStatement := self.
+ [thisStatement notNil] whileTrue:[
+ lastValue := thisStatement evaluateExpression.
+ thisStatement := thisStatement nextStatement
+ ].
+ ^ lastValue
+! !
+
+!StatementNode methodsFor:'code generation'!
+
+codeOn:aStream inBlock:b
+ "generate code for this statement"
+
+ expression codeOn:aStream inBlock:b
+!
+
+codeForSideEffectOn:aStream inBlock:b
+ "generate code for this statement - value not needed"
+
+ expression codeForSideEffectOn:aStream inBlock:b
+! !
+
+!StatementNode methodsFor:'accessing'!
+
+last
+ "return the last statement in a list"
+
+ |last this|
+
+ "this could be done more elegant - but with lots of recursion"
+ last := self.
+ this := self.
+ [this notNil] whileTrue:[
+ last := this.
+ this := this nextStatement
+ ].
+ ^ last
+!
+
+nextStatement:s
+ nextStatement := s
+!
+
+nextStatement
+ ^ nextStatement
+!
+
+expression:e
+ expression := e
+!
+
+expression
+ ^ expression
+! !
+
+!StatementNode methodsFor:'printing'!
+
+printOn:aStream indent:i
+ expression printOn:aStream indent:i.
+!
+
+printAllOn:aStream
+ self printAllOn:aStream indent:4
+!
+
+printAllOn:aStream indent:i
+ |thisStatement|
+
+ thisStatement := self.
+ [thisStatement notNil] whileTrue:[
+ i timesRepeat:[aStream space].
+ thisStatement printOn:aStream indent:i.
+ thisStatement nextStatement notNil ifTrue:[
+ aStream nextPut:$..
+ aStream cr.
+ ].
+ thisStatement := thisStatement nextStatement
+ ]
+! !