glados-0.1.0.0
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

VM.Bytecode.Reader

Description

This module provides low-level functions to consume bytes from the VM's bytecode stream. It supports reading signed and unsigned integers of 8, 16, 32, and 64 bits in Big Endian format (Network Byte Order).

Synopsis

Documentation

readByte :: VirtualMachine Word8 Source #

Reads a single raw byte (8 bits) from the bytecode.

@details Retrieves the byte at the current bytecodeIndex and increments the index. Performs a bounds check to prevent reading past the end of the bytecode.

@throws Error "VM Error: Unexpected End of Bytecode" if the index is out of bounds.

@return The read Word8.

readInt8 :: VirtualMachine Int8 Source #

Reads a signed 8-bit integer.

@return The value as Int8.

readWord8 :: VirtualMachine Word8 Source #

Reads an unsigned 8-bit integer.

@return The value as Word8.

readInt16 :: VirtualMachine Int16 Source #

Reads a signed 16-bit integer (Big Endian).

@return The value as Int16.

readWord16 :: VirtualMachine Word16 Source #

Reads an unsigned 16-bit integer (Big Endian).

@return The value as Word16.

readInt32 :: VirtualMachine Int Source #

Reads a signed 32-bit integer (Big Endian) and returns it as a native Int.

@details This function is optimized for general usage (like jumping or vector indexing). It reads 4 bytes, interprets them as a signed Int32, and casts to the native Int type. On 64-bit systems, this preserves the sign correctly.

@return The value as a standard Int.

readWord32 :: VirtualMachine Word32 Source #

Reads an unsigned 32-bit integer (Big Endian).

@return The value as Word32.

readInt64 :: VirtualMachine Int64 Source #

Reads a signed 64-bit integer (Big Endian).

@return The value as Int64.

readWord64 :: VirtualMachine Word64 Source #

Reads an unsigned 64-bit integer (Big Endian).

@return The value as Word64.