flisp/src/byte_defs.h
2025-03-02 22:47:04 +01:00

83 lines
1.1 KiB
C

#include "types.h"
#pragma once
#define FL_EPSILON (1e-6f)
enum OpTypes {
OP_add = 0,
OP_sub = 1,
OP_mul = 2,
OP_div = 3,
OP_mod = 4,
OP_call = 5,
OP_ret = 6,
OP_mov = 7,
OP_copy = 8,
OP_get = 9,
OP_set = 10,
OP_gt = 11,
OP_ge = 12,
OP_eq = 13,
OP_jmp = 14,
OP_brt = 15,
OP_cast = 16,
OP_fcast = 17,
OP_init = 18,
OP_fcall = 19,
OP_pop = 20,
OP_popl = 21,
OP_cst0 = 22,
OP_cst1 = 23,
OP_iter = 24
};
typedef struct {
u8 type; // OpTypes
u8 o1;
u8 o2;
u8 o3;
} PACKED Opcode;
typedef struct {
u8 __padding[2];
u32 value;
} PACKED Value4B;
typedef struct {
u16 len;
u32 pos; // Offset from stack allocator
} PACKED ValueArray;
typedef struct {
u8 len;
union {
char str[5];
struct {
u8 __padding;
u32 pos;
};
};
} PACKED ValueStr;
typedef struct {
uint is_array : 1;
uint type : 15;
PACKED union {
Value4B v4B;
ValueArray varray;
};
} PACKED Value;
_Static_assert(sizeof(Value) == 8);