aboutsummaryrefslogtreecommitdiff
path: root/snug-clean/src/Snug/Compile/Simulate.dcl
blob: a36dc0dacca6a35ab46e52a8238b407d46d137e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
definition module Snug.Compile.Simulate

from Control.Applicative import class Applicative, class pure, class <*>
from Control.Monad import class Monad
from Control.Monad.Identity import :: Identity, instance Functor Identity,
	instance Monad Identity, instance pure Identity, instance <*> Identity
from Control.Monad.State import :: State, :: StateT,
	instance Functor (StateT s m), instance Monad (StateT s m),
	instance pure (StateT s m), instance <*> (StateT s m)
from Data.Functor import class Functor

from MIPS.MIPS32 import :: Instruction, :: Label
from Snug.Syntax import :: BasicValue

:: Simulator a :== State SimulationState a

:: SimulationState

simulate :: !(Simulator a) -> [Instruction]

//* Build a constructor node with *n* arguments and push it to the stack.
buildCons :: !Label !Int -> Simulator ()
//* Build a thunk node with *n* arguments and push it to the stack.
buildThunk :: !Label !Int -> Simulator ()

//* Push a basic value to the stack.
pushBasicValue :: !BasicValue -> Simulator ()

/**
 * Overwrite the node currently under evaluation with an indirection to the
 * node on top of the stack, and continue evaluating that node instead.
 */
indirectAndEval :: Simulator ()