idris-1.3.4: Functional Programming Language with Dependent Types

License | BSD3
Maintainer | The Idris Community.
Safe Haskell | None
Language | Haskell2010

IRTS.Bytecode

Description

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

Instances details

ToJSON Reg # |
Instance details Defined in IRTS.Portable Methods toJSON :: Reg -> Value # toEncoding :: Reg -> Encoding # toJSONList :: [Reg] -> Value # toEncodingList :: [Reg] -> Encoding # omitField :: Reg -> Bool #
Show Reg # |
Instance details Defined in IRTS.Bytecode Methods showsPrec :: Int -> Reg -> ShowS # show :: Reg -> String # showList :: [Reg] -> ShowS #
Eq Reg # |
Instance details Defined in IRTS.Bytecode Methods (==) :: Reg -> Reg -> Bool # (/=) :: Reg -> Reg -> Bool #

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)
RESERVENOALLOC Int |
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

Instances details

ToJSON BC # |
Instance details Defined in IRTS.Portable Methods toJSON :: BC -> Value # toEncoding :: BC -> Encoding # toJSONList :: [BC] -> Value # toEncodingList :: [BC] -> Encoding # omitField :: BC -> Bool #
Show BC # |
Instance details Defined in IRTS.Bytecode 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 :: p -> Reg -> Bool -> SAlt -> Maybe (Const, [BC]) #

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