IRInterpreter.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 24 Mar 2010 07:50:55 +0000
changeset 30 1b7ff9c8c40b
parent 26 db19d89eef60
child 37 be8c2dd09dff
permissions -rw-r--r--
Fixed bug that caused bad code generation for closures with more than one basic blocks.

"{ Package: 'cvut: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
!

line: line

    "Created: / 02-12-2008 / 09:00:27 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

popTop
!

pushBlock: irMethod
!

pushBlockMethod: irMethod
!

pushDup
!

pushInstVar: aSmallInteger 
!

pushLiteral: object
!

pushLiteralVariable: object
!

pushTemp: index kind: kind level: level

    "Created: / 30-03-2009 / 14:02:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

remoteReturn
!

returnTop
!

send: selector numArgs: numArgs

    "Created: / 01-12-2008 / 19:40:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

send: selector numArgs: numArgs toSuperOf: behavior

    "Modified: / 01-12-2008 / 19:45:19 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

storeIntoLiteralVariable: index

    "Created: / 11-05-2009 / 22:38:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

storeTemp: index kind: kind level: level

    "Created: / 30-03-2009 / 14:05:26 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!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
    ^ '$Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRInterpreter.st,v 1.3 2009/10/08 11:58:54 fm Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRInterpreter.st,v 1.3 2009/10/08 11:58:54 fm Exp $'
!

version_SVN
    ^ '$Id$'
! !