diff options
Diffstat (limited to 'snug-clean/src/Snug/Compile/Simulate.dcl')
-rw-r--r-- | snug-clean/src/Snug/Compile/Simulate.dcl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/snug-clean/src/Snug/Compile/Simulate.dcl b/snug-clean/src/Snug/Compile/Simulate.dcl index a36dc0d..bf01675 100644 --- a/snug-clean/src/Snug/Compile/Simulate.dcl +++ b/snug-clean/src/Snug/Compile/Simulate.dcl @@ -9,14 +9,24 @@ from Control.Monad.State import :: State, :: StateT, instance pure (StateT s m), instance <*> (StateT s m) from Data.Functor import class Functor -from MIPS.MIPS32 import :: Instruction, :: Label +from MIPS.MIPS32 import :: Immediate, :: Instruction, :: Label, :: Offset, + :: Register from Snug.Syntax import :: BasicValue :: Simulator a :== State SimulationState a :: SimulationState -simulate :: !(Simulator a) -> [Instruction] +:: StackValue + = SVIndirect !Offset !Register //* value stored in reg + offset + | SVRegOffset !Register !Offset //* value is reg + offset + + /* for internal use only: */ + | SVImmediate !Immediate + +simulate :: ![StackValue] !(Simulator a) -> [Instruction] + +stackSize :: Simulator Int //* Build a constructor node with *n* arguments and push it to the stack. buildCons :: !Label !Int -> Simulator () @@ -27,6 +37,13 @@ buildThunk :: !Label !Int -> Simulator () pushBasicValue :: !BasicValue -> Simulator () /** + * Push the *j*th argument of the *i*th element on the stack onto the stack. + * @param *i* + * @param *j* + */ +pushArg :: !Int !Int -> Simulator () + +/** * Overwrite the node currently under evaluation with an indirection to the * node on top of the stack, and continue evaluating that node instead. */ |