# Generated by glacierdsl - DO NOT EDIT.

from enum import Enum


class OpCode(Enum):
    STRUCT_DEF = 0x0
    FUNCTION_DEF = 0x1
    SET_VAR = 0x2
    GET_VAR = 0x3
    CALL_FUNC = 0x4
    RETURN = 0x5
    RETURN_VAL = 0x6
    ADD = 0x7
    INT = 0x8
    STRING = 0x9
    SUBTRACT = 0xA
    MULTIPLY = 0xB
    DIVIDE = 0xC
    FUNCTION_JMP = 0xD
    HEADER_END = 0xE
    PRINT = 0xF
    EQ = 0x10
    JUMP_IF_TRUE = 0x11
    JUMP_IF_FALSE = 0x12
    JUMP = 0x13
    STRUCT = 0x14
    GET_STRUCT_MEMBER = 0x15
    SET_STRUCT_MEMBER = 0x16
    LT = 0x17
    VEC = 0x18
    VEC_ACCESS = 0x19
    MAP = 0x1A
    MAP_ACCESS = 0x1B
    VEC_PUSH = 0x1C
    VEC_LEN = 0x1D
    VEC_POP = 0x1E
    MAP_INSERT = 0x1F
    READ_STR = 0x20
    READ_INT = 0x21


class StructDef:
    def __init__(self, type_id=None, member_id=None):
        self._offset = None
        self.type_id = type_id
        self.member_id = member_id

    def serialise(self, bc):
        args = list()
        args.append(self.type_id)
        args.append(len(self.member_id))
        args.extend(self.member_id)
        bc.write_header(OpCode.STRUCT_DEF, args)
        return self


class FunctionDef:
    def __init__(self, function_id=None, num_args=None):
        self._offset = None
        self.function_id = function_id
        self.num_args = num_args

    def serialise(self, bc):
        args = list()
        args.append(self.function_id)
        args.append(self.num_args)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.FUNCTION_DEF, args)
        else:
            bc.write_op(OpCode.FUNCTION_DEF, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF, 0xFF]
        bc.write_op(OpCode.FUNCTION_DEF, args)
        return self

    def assign(self, function_id, num_args):
        self.function_id = function_id
        self.num_args = num_args
        return self


class SetVar:
    def __init__(self, variable_id=None):
        self._offset = None
        self.variable_id = variable_id

    def serialise(self, bc):
        args = list()
        args.append(self.variable_id)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.SET_VAR, args)
        else:
            bc.write_op(OpCode.SET_VAR, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.SET_VAR, args)
        return self

    def assign(self, variable_id):
        self.variable_id = variable_id
        return self


class GetVar:
    def __init__(self, variable_id=None):
        self._offset = None
        self.variable_id = variable_id

    def serialise(self, bc):
        args = list()
        args.append(self.variable_id)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.GET_VAR, args)
        else:
            bc.write_op(OpCode.GET_VAR, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.GET_VAR, args)
        return self

    def assign(self, variable_id):
        self.variable_id = variable_id
        return self


class CallFunc:
    def __init__(self, function_id=None):
        self._offset = None
        self.function_id = function_id

    def serialise(self, bc):
        args = list()
        args.append(self.function_id)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.CALL_FUNC, args)
        else:
            bc.write_op(OpCode.CALL_FUNC, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.CALL_FUNC, args)
        return self

    def assign(self, function_id):
        self.function_id = function_id
        return self


class Return:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.RETURN, args)
        return self


class ReturnVal:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.RETURN_VAL, args)
        return self


class Add:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.ADD, args)
        return self


class Int:
    def __init__(self, value=None):
        self._offset = None
        self.value = value

    def serialise(self, bc):
        args = list()
        args.append(self.value)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.INT, args)
        else:
            bc.write_op(OpCode.INT, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.INT, args)
        return self

    def assign(self, value):
        self.value = value
        return self


class String:
    def __init__(self, bytes=None):
        self._offset = None
        self.bytes = bytes

    def serialise(self, bc):
        args = list()
        args.append(len(self.bytes))
        args.extend(bytes(self.bytes, "utf-8"))
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.STRING, args)
        else:
            bc.write_op(OpCode.STRING, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.STRING, args)
        return self

    def assign(self, bytes):
        self.bytes = bytes
        return self


class Subtract:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.SUBTRACT, args)
        return self


class Multiply:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.MULTIPLY, args)
        return self


class Divide:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.DIVIDE, args)
        return self


class FunctionJmp:
    def __init__(self, function_id=None, offset=None):
        self._offset = None
        self.function_id = function_id
        self.offset = offset

    def serialise(self, bc):
        args = list()
        args.append(self.function_id)
        args.append(self.offset)
        bc.write_header(OpCode.FUNCTION_JMP, args)
        return self


class HeaderEnd:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.HEADER_END, args)
        return self


class Print:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.PRINT, args)
        return self


class Eq:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.EQ, args)
        return self


class JumpIfTrue:
    def __init__(self, offset=None):
        self._offset = None
        self.offset = offset

    def serialise(self, bc):
        args = list()
        args.append(self.offset)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.JUMP_IF_TRUE, args)
        else:
            bc.write_op(OpCode.JUMP_IF_TRUE, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.JUMP_IF_TRUE, args)
        return self

    def assign(self, offset):
        self.offset = offset
        return self


class JumpIfFalse:
    def __init__(self, offset=None):
        self._offset = None
        self.offset = offset

    def serialise(self, bc):
        args = list()
        args.append(self.offset)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.JUMP_IF_FALSE, args)
        else:
            bc.write_op(OpCode.JUMP_IF_FALSE, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.JUMP_IF_FALSE, args)
        return self

    def assign(self, offset):
        self.offset = offset
        return self


class Jump:
    def __init__(self, offset=None):
        self._offset = None
        self.offset = offset

    def serialise(self, bc):
        args = list()
        args.append(self.offset)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.JUMP, args)
        else:
            bc.write_op(OpCode.JUMP, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.JUMP, args)
        return self

    def assign(self, offset):
        self.offset = offset
        return self


class Struct:
    def __init__(self, struct_id=None):
        self._offset = None
        self.struct_id = struct_id

    def serialise(self, bc):
        args = list()
        args.append(self.struct_id)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.STRUCT, args)
        else:
            bc.write_op(OpCode.STRUCT, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.STRUCT, args)
        return self

    def assign(self, struct_id):
        self.struct_id = struct_id
        return self


class GetStructMember:
    def __init__(self, member_index=None):
        self._offset = None
        self.member_index = member_index

    def serialise(self, bc):
        args = list()
        args.append(self.member_index)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.GET_STRUCT_MEMBER, args)
        else:
            bc.write_op(OpCode.GET_STRUCT_MEMBER, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.GET_STRUCT_MEMBER, args)
        return self

    def assign(self, member_index):
        self.member_index = member_index
        return self


class SetStructMember:
    def __init__(self, member_index=None):
        self._offset = None
        self.member_index = member_index

    def serialise(self, bc):
        args = list()
        args.append(self.member_index)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.SET_STRUCT_MEMBER, args)
        else:
            bc.write_op(OpCode.SET_STRUCT_MEMBER, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.SET_STRUCT_MEMBER, args)
        return self

    def assign(self, member_index):
        self.member_index = member_index
        return self


class Lt:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.LT, args)
        return self


class Vec:
    def __init__(self, size=None):
        self._offset = None
        self.size = size

    def serialise(self, bc):
        args = list()
        args.append(self.size)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.VEC, args)
        else:
            bc.write_op(OpCode.VEC, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.VEC, args)
        return self

    def assign(self, size):
        self.size = size
        return self


class VecAccess:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.VEC_ACCESS, args)
        return self


class Map:
    def __init__(self, size=None):
        self._offset = None
        self.size = size

    def serialise(self, bc):
        args = list()
        args.append(self.size)
        if self._offset is not None:
            bc.edit_op(self._offset, OpCode.MAP, args)
        else:
            bc.write_op(OpCode.MAP, args)
        return self

    def reserve(self, bc):
        self._offset = bc.current_offset()
        args = [0xFF]
        bc.write_op(OpCode.MAP, args)
        return self

    def assign(self, size):
        self.size = size
        return self


class MapAccess:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.MAP_ACCESS, args)
        return self


class VecPush:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.VEC_PUSH, args)
        return self


class VecLen:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.VEC_LEN, args)
        return self


class VecPop:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.VEC_POP, args)
        return self


class MapInsert:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.MAP_INSERT, args)
        return self


class ReadStr:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.READ_STR, args)
        return self


class ReadInt:
    def __init__(self):
        pass

    def serialise(self, bc):
        args = list()
        bc.write_op(OpCode.READ_INT, args)
        return self
