IRInterpreter.st
changeset 1 0dd36941955f
child 5 b94aea1d3710
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRInterpreter.st	Wed Jun 11 14:54:42 2008 +0000
@@ -0,0 +1,100 @@
+"{ Package: 'stx:goodies/newcompiler' }"
+
+Object subclass:#IRInterpreter
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'NewCompiler-IR'
+!
+
+IRInterpreter comment:'I visit each IRInstruction in an IRMethod in order.  Each instruction sends its instruction message to me upon being visited.  See my ''instructions'' method category for complete list of instructions.  Subclasses should override them.'
+!
+
+
+!IRInterpreter methodsFor:'instructions'!
+
+blockReturnTop
+!
+
+goto: seqNum
+!
+
+if: bool goto: seqNum1 otherwise: seqNum2
+!
+
+jumpOverBlock: blockSeq to: dest
+!
+
+label: seqNum
+!
+
+popTop
+!
+
+pushBlock: irMethod
+!
+
+pushBlockMethod: irMethod
+!
+
+pushDup
+!
+
+pushInstVar: aSmallInteger 
+!
+
+pushLiteral: object
+!
+
+pushLiteralVariable: object
+!
+
+pushTemp: index
+!
+
+remoteReturn
+!
+
+returnTop
+!
+
+send: selector
+!
+
+send: selector toSuperOf: behavior
+!
+
+storeLiteralVariable: index
+!
+
+storeTemp: index
+! !
+
+!IRInterpreter methodsFor:'interpret'!
+
+interpret: ir
+
+	self interpretAll: ir allSequences
+!
+
+interpretAll: irSequences
+
+	irSequences do: [:seq | self interpretSequence: seq]
+!
+
+interpretInstruction: irInstruction
+
+	irInstruction executeOn: self
+!
+
+interpretSequence: instructionSequence
+
+	self label: instructionSequence orderNumber.
+	instructionSequence do: [:instr | self interpretInstruction: instr].
+! !
+
+!IRInterpreter class methodsFor:'documentation'!
+
+version
+    ^'$Id$'
+! !