idris-1.3.2: Functional Programming Language with Dependent Types

LicenseBSD3
MaintainerThe Idris Community.
Safe HaskellNone
LanguageHaskell2010

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 Source #

Constructors

RVal 
L Int 
T Int 
Tmp 
Instances
Eq Reg Source # 
Instance details

Defined in IRTS.Bytecode

Methods

(==) :: Reg -> Reg -> Bool #

(/=) :: Reg -> Reg -> Bool #

Show Reg Source # 
Instance details

Defined in IRTS.Bytecode

Methods

showsPrec :: Int -> Reg -> ShowS #

show :: Reg -> String #

showList :: [Reg] -> ShowS #

ToJSON Reg Source # 
Instance details

Defined in IRTS.Portable

data BC Source #

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 Source # 
Instance details

Defined in IRTS.Bytecode

Methods

showsPrec :: Int -> BC -> ShowS #

show :: BC -> String #

showList :: [BC] -> ShowS #

ToJSON BC Source # 
Instance details

Defined in IRTS.Portable

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

clean :: Bool -> [BC] Source #

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

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

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

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

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

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

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