| Stability | stable |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
VM.Instruction.Struct
Description
Handles the creation of structures.
Synopsis
- instBuildStruct :: VirtualMachine ()
- instGetStructField :: VirtualMachine ()
- instAttrUpdate :: VirtualMachine ()
- pushStruct :: VMState -> Int -> VirtualMachine ()
Documentation
instBuildStruct :: VirtualMachine () Source #
Implements BUILD_STRUCT (Opcode 0x62).
@details
Pop n elements from the stack and wraps them in a VStruct.
1. Reads n (Int32).
2. Consumes n values.
3. Pushes VStruct.
instGetStructField :: VirtualMachine () Source #
Implements GET_STRUCT_FIELD (Opcode 0x63).
@details
Reads a field index and retrieves the value from a Struct on the stack.
1. Reads index (Int32).
2. Pops struct (VStruct).
3. Pushes 'struct[index]'.
@throws Error if the popped value is not a VStruct or if index is out of bounds.
instAttrUpdate :: VirtualMachine () Source #
Implements ATTR_UPDATE (Opcode 0x64).
@details Updates a field in a structure. Because structures are immutable, this creates a shallow copy.
Stack Order: Top -> New Value Next -> Field Index (Int) Bottom -> Struct
pushStruct :: VMState -> Int -> VirtualMachine () Source #
Helper for instBuildStruct to manipulate the stack.
@args - vm: Current VM state - count: Number of fields in the struct