epic

Epic.Bytecode

# Documentation

type Local = Int

type TmpVar = Int

type StrVar = Int

data ByteOp

Constructors

CALL TmpVar Name [TmpVar] |
TAILCALL TmpVar Name [TmpVar] |
THUNK TmpVar Int Name [TmpVar] |
ADDARGS TmpVar TmpVar [TmpVar] |
FOREIGN Type TmpVar String [(TmpVar, Type)] |
VAR TmpVar Local |
GROWROOT Int |
ADDVARROOT Local |
ADDTMPROOT TmpVar |
DROPROOTS Int |
ASSIGN Local TmpVar |
TMPASSIGN TmpVar TmpVar |
NOASSIGN Local TmpVar |
CON TmpVar Tag [TmpVar] |
UNIT TmpVar |
UNUSED TmpVar |
INT TmpVar Int |
BIGINT TmpVar Integer |
FLOAT TmpVar Double |
BIGFLOAT TmpVar Double |
STRING TmpVar StrVar |
PROJ TmpVar TmpVar Int |
PROJVAR Local TmpVar Int |
CASE TmpVar [(Int, Bytecode)] (Maybe Bytecode) |
INTCASE TmpVar [(Int, Bytecode)] (Maybe Bytecode) |
IF TmpVar Bytecode Bytecode |
OP TmpVar Op TmpVar TmpVar |
LOCALS Int |
TMPS Int |
CONSTS [String] |
LABEL Int |
WHILE Bytecode Bytecode |
WHILEACC Bytecode TmpVar Bytecode |
MEMORY Allocator TmpVar TmpVar Bytecode |
BREAKFALSE TmpVar |
JFALSE TmpVar Int |
JUMP Int |
EVAL TmpVar Bool |
EVALINT TmpVar Bool |
RETURN TmpVar | LET TmpVar Local TmpVar
DRETURN |
ERROR String |
TRACE String [TmpVar] |
COMMENT String |

Instances

Show ByteOp |

type Bytecode = [ByteOp]

data FunCode

Constructors

Code Int [Type] Bytecode |

Instances

Show FunCode |

data CompileState

Constructors

CS |

Fields

arg_types :: [Type]
num_locals :: Int
next_tmp :: Int
string_pool :: [String]
max_tmp :: Int
next_label :: Int

compile :: Context -> Name -> Func -> FunCode

data TailCall

Constructors

Tail |
Middle |

scompile :: Context -> Name -> Func -> State CompileState Bytecode

peephole :: Bytecode -> Bytecode