idris-1.0: Functional Programming Language with Dependent Types

Copyright | License : BSD3
Maintainer | The Idris Community.
Safe Haskell | None
Language | Haskell98

IRTS.Bytecode

Description

BASE: Current stack frame's base TOP: Top of stack OLDBASE: Passed in to each function, the previous stack frame's base

L i refers to the stack item at BASE + i T i refers to the stack item at TOP + i

RVal is a register in which computed values (essentially, what a function returns) are stored.

# Documentation

data Reg #

Constructors

RVal |
L Int |
T Int |
Tmp |

Instances

Eq Reg # |
Methods (==) :: Reg -> Reg -> Bool # (/=) :: Reg -> Reg -> Bool #
Show Reg # |
Methods showsPrec :: Int -> Reg -> ShowS # show :: Reg -> String # showList :: [Reg] -> ShowS #

data BC #

Constructors

ASSIGN Reg Reg | reg1 = reg2
ASSIGNCONST Reg Const | reg = const
UPDATE Reg Reg | reg1 = reg2 (same as assign, it seems)
MKCON Reg (Maybe Reg) Int [Reg] | reg = constructor, where constructor consists of a tag and values from registers, e.g. (cons tag args) the 'Maybe Reg', if set, is a register which can be overwritten (i.e. safe for mutable update), though this can be ignored
CASE Bool Reg [(Int, [BC])] (Maybe [BC]) | Matching on value of reg: usually (but not always) there are constructors, hence Int for patterns (that's a tag on which we should match), and the following [BC] is just a list of instructions for the corresponding case. The last argument is for default case. When it's not necessary a constructor in the reg, the Bool should be False, indicating that it's not safe to work with that as with a constructor, so a check should be added. If it's not a constructor, default case should be used.
PROJECT Reg Int Int | get a value from register, which should be a constructor, and put its arguments into the stack, starting from (base + int1) and onwards; second Int provides arity
PROJECTINTO Reg Reg Int | probably not used
CONSTCASE Reg [(Const, [BC])] (Maybe [BC]) | same as CASE, but there's an exact value (not constructor) in reg
CALL Name | just call a function, passing MYOLDBASE (see below) to it
TAILCALL Name | same, perhaps exists just for TCO
FOREIGNCALL Reg FDesc FDesc [(FDesc, Reg)] | set reg to (apply string args),
SLIDE Int | move this number of elements from TOP to BASE
REBASE | set BASE = OLDBASE
RESERVE Int | reserve n more stack items (i.e. check there's space, grow if necessary)
ADDTOP Int | move the top of stack up
TOPBASE Int | set TOP = BASE + n
BASETOP Int | set BASE = TOP + n
STOREOLD | set MYOLDBASE = BASE, where MYOLDBASE is a function-local variable, set to OLDBASE by default, and passed on function call to called functions as their OLDBASE
OP Reg PrimFn [Reg] | reg = apply primitive_function args
NULL Reg | clear reg
ERROR String | throw an error

Instances

Show BC # |
Methods showsPrec :: Int -> BC -> ShowS # show :: BC -> String # showList :: [BC] -> ShowS #

toBC :: (Name, SDecl) -> (Name, [BC]) #

clean :: Bool -> [BC] #

bc :: Reg -> SExp -> Bool -> [BC] #

isConst :: [SAlt] -> Bool #

moveReg :: Int -> [LVar] -> [BC] #

assign :: Reg -> Reg -> [BC] #

conCase :: Bool -> Reg -> Reg -> [SAlt] -> Bool -> [BC] #

constCase :: Reg -> Reg -> [SAlt] -> Bool -> [BC] #

caseAlt :: Reg -> Reg -> Bool -> SAlt -> Maybe (Int, [BC]) #

constAlt :: t -> Reg -> Bool -> SAlt -> Maybe (Const, [BC]) #

defaultAlt :: Reg -> [SAlt] -> Bool -> Maybe [BC] #