Skip to main content

Module format

Module format 

Source
Expand description

Binary bytecode container format (.mailangbc).

Layout (all multi-byte integers little-endian):

magic:   b"MAILBC01"          (8 bytes)
version: u16                  (currently 1)
flags:   u16                  (reserved, 0)
main:    u32                  (main chunk index)
n_globals: u32
  for each global: u32 len + utf8 bytes
n_chunks: u32
  for each chunk:
    name: u32 len + utf8 bytes
    n_const: u32
      for each constant: Value
    n_instr: u32
      for each instruction: opcode u8, has_operand u8, operand u32 (if has_operand), line u32

Value tags (u8): 0 Null, 1 Bool, 2 Int, 3 Float, 4 Str, 5 Char, 6 Array, 7 Map, 8 Tuple, 9 Function, 10 Closure, 11 Class, 12 Instance, 13 Ok, 14 Err, 15 Some, 16 Builtin

Enums§

BytecodeFormatError

Constants§

FORMAT_MAGIC
FORMAT_VERSION

Functions§

decode
Decode a .mailangbc container into bytecode.
encode
Encode bytecode into the .mailangbc container.