glados-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

VM.Instruction.List

Synopsis

Documentation

instCons :: VirtualMachine () Source #

Implements CONS (Opcode 0x90).

@details Constructs a new list by prepending an element. Stack: [..., elem, list] -> [..., new_list] Note: Pops list first (Right), then elem (Left).

instHead :: VirtualMachine () Source #

Implements HEAD (Opcode 0x91).

@details Extracts the first element of a list. Stack: [..., list] -> [..., head]

@throws Error if list is empty.

instTail :: VirtualMachine () Source #

Implements TAIL (Opcode 0x92).

@details Extracts the rest of the list (minus the first element). Stack: [..., list] -> [..., tail]

@throws Error if list is empty.

instNth :: VirtualMachine () Source #

Implements NTH (Opcode 0x93).

@details Access to a list element. Stack: [index, list] -> [element]

instNthUpdate :: VirtualMachine () Source #

Implements NTH_UPDATE (Opcode 0x95).

@details Updates an element in a list at a given index. Note: Since VMValues are immutable, this pushes a NEW list.

Stack Order (arg order: list, index, value): Top -> Value Next -> Index Bottom -> List

instBuildList :: VirtualMachine () Source #

Implements BUILD_LIST (Opcode 0x94).

@details Pop n elements from the stack and creates a VList. Preserves the order: [e1, e2] -> push e1 -> push e2 -> BuildList 2 -> VList [e1, e2]