Move stuff
This commit is contained in:
@@ -1,69 +1,5 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
typedef enum noomC_InstrType : unsigned char {
|
|
||||||
NOOMC_INSTR_NOP = 0,
|
|
||||||
NOOMC_INSTR_LOADC,
|
|
||||||
NOOMC_INSTR_LOAD_NIL,
|
|
||||||
NOOMC_INSTR_LOAD_TRUE,
|
|
||||||
NOOMC_INSTR_LOAD_FALSE,
|
|
||||||
NOOMC_INSTR_COPY,
|
|
||||||
|
|
||||||
NOOMC_INSTR_JMP,
|
|
||||||
NOOMC_INSTR_JC,
|
|
||||||
|
|
||||||
|
|
||||||
NOOMC_INSTR_ADD,
|
|
||||||
NOOMC_INSTR_SUB,
|
|
||||||
NOOMC_INSTR_NEG,
|
|
||||||
NOOMC_INSTR_MUL,
|
|
||||||
NOOMC_INSTR_DIV,
|
|
||||||
NOOMC_INSTR_MOD,
|
|
||||||
NOOMC_INSTR_FLOOR_DIV,
|
|
||||||
NOOMC_INSTR_POW,
|
|
||||||
|
|
||||||
NOOMC_INSTR_EQ,
|
|
||||||
NOOMC_INSTR_NEQ,
|
|
||||||
NOOMC_INSTR_LT,
|
|
||||||
NOOMC_INSTR_LTE,
|
|
||||||
NOOMC_INSTR_GT,
|
|
||||||
NOOMC_INSTR_GTE,
|
|
||||||
|
|
||||||
NOOMC_INSTR_NOT,
|
|
||||||
|
|
||||||
NOOMC_INSTR_BAND,
|
|
||||||
NOOMC_INSTR_BOR,
|
|
||||||
NOOMC_INSTR_BXOR,
|
|
||||||
NOOMC_INSTR_BNOT,
|
|
||||||
NOOMC_INSTR_LSHIFT,
|
|
||||||
NOOMC_INSTR_RSHIFT,
|
|
||||||
|
|
||||||
NOOMC_INSTR_CONCAT,
|
|
||||||
NOOMC_INSTR_LEN,
|
|
||||||
NOOMC_INSTR_GET,
|
|
||||||
NOOMC_INSTR_GETI,
|
|
||||||
NOOMC_INSTR_SET,
|
|
||||||
NOOMC_INSTR_SETI,
|
|
||||||
|
|
||||||
#ifdef NOOM_USE_NFT
|
|
||||||
NOOMC_INSTR_LOAD_NFT,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NOOMC_INSTR_NOP2 = 0xff,
|
|
||||||
} noomC_InstrType;
|
|
||||||
|
|
||||||
typedef struct noomC_Instr {
|
|
||||||
noomC_InstrType type;
|
|
||||||
unsigned char a;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char b;
|
|
||||||
unsigned char c;
|
|
||||||
};
|
|
||||||
unsigned short u;
|
|
||||||
short s;
|
|
||||||
};
|
|
||||||
} noomC_Instr;
|
|
||||||
|
|
||||||
typedef enum noomC_ImmType {
|
typedef enum noomC_ImmType {
|
||||||
NOOMC_IMM_INT,
|
NOOMC_IMM_INT,
|
||||||
NOOMC_IMM_FLOAT,
|
NOOMC_IMM_FLOAT,
|
||||||
@@ -140,12 +76,3 @@ typedef struct noomC_Imm {
|
|||||||
// ░░
|
// ░░
|
||||||
};
|
};
|
||||||
} noomC_Imm;
|
} noomC_Imm;
|
||||||
|
|
||||||
typedef struct noomC_Function {
|
|
||||||
noomC_Imm *immediates;
|
|
||||||
noomC_Instr *instructions;
|
|
||||||
} noomC_Function;
|
|
||||||
|
|
||||||
typedef struct noomC_Module {
|
|
||||||
noomC_Function *functions;
|
|
||||||
} noomC_Module;
|
|
||||||
|
|||||||
60
src/vm.h
60
src/vm.h
@@ -61,20 +61,66 @@ typedef struct noomV_Pointer {
|
|||||||
} noomV_Pointer;
|
} noomV_Pointer;
|
||||||
|
|
||||||
typedef enum noomV_Opcode : unsigned char {
|
typedef enum noomV_Opcode : unsigned char {
|
||||||
NOOMV_NOP,
|
NOOMV_INSTR_NOP = 0,
|
||||||
// TODO: rest of ops
|
NOOMV_INSTR_LOADC,
|
||||||
|
NOOMV_INSTR_LOAD_NIL,
|
||||||
|
NOOMV_INSTR_LOAD_TRUE,
|
||||||
|
NOOMV_INSTR_LOAD_FALSE,
|
||||||
|
NOOMV_INSTR_COPY,
|
||||||
|
|
||||||
|
NOOMV_INSTR_JMP,
|
||||||
|
NOOMV_INSTR_JC,
|
||||||
|
|
||||||
|
|
||||||
|
NOOMV_INSTR_ADD,
|
||||||
|
NOOMV_INSTR_SUB,
|
||||||
|
NOOMV_INSTR_NEG,
|
||||||
|
NOOMV_INSTR_MUL,
|
||||||
|
NOOMV_INSTR_DIV,
|
||||||
|
NOOMV_INSTR_MOD,
|
||||||
|
NOOMV_INSTR_FLOOR_DIV,
|
||||||
|
NOOMV_INSTR_POW,
|
||||||
|
|
||||||
|
NOOMV_INSTR_EQ,
|
||||||
|
NOOMV_INSTR_NEQ,
|
||||||
|
NOOMV_INSTR_LT,
|
||||||
|
NOOMV_INSTR_LTE,
|
||||||
|
NOOMV_INSTR_GT,
|
||||||
|
NOOMV_INSTR_GTE,
|
||||||
|
|
||||||
|
NOOMV_INSTR_NOT,
|
||||||
|
|
||||||
|
NOOMV_INSTR_BAND,
|
||||||
|
NOOMV_INSTR_BOR,
|
||||||
|
NOOMV_INSTR_BXOR,
|
||||||
|
NOOMV_INSTR_BNOT,
|
||||||
|
NOOMV_INSTR_LSHIFT,
|
||||||
|
NOOMV_INSTR_RSHIFT,
|
||||||
|
|
||||||
|
NOOMV_INSTR_CONCAT,
|
||||||
|
NOOMV_INSTR_LEN,
|
||||||
|
NOOMV_INSTR_GET,
|
||||||
|
NOOMV_INSTR_GETI,
|
||||||
|
NOOMV_INSTR_SET,
|
||||||
|
NOOMV_INSTR_SETI,
|
||||||
|
|
||||||
|
#ifdef NOOM_USE_NFT
|
||||||
|
NOOMV_INSTR_LOAD_NFT,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NOOMV_INSTR_NOP2 = 0xff,
|
||||||
} noomV_Opcode;
|
} noomV_Opcode;
|
||||||
|
|
||||||
typedef struct noomV_Inst {
|
typedef struct noomV_Inst {
|
||||||
noomV_Opcode op;
|
noomV_Opcode op;
|
||||||
unsigned char A;
|
unsigned char a;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
unsigned char B;
|
unsigned char b;
|
||||||
unsigned char C;
|
unsigned char c;
|
||||||
};
|
};
|
||||||
short sD;
|
short ss;
|
||||||
unsigned short uD;
|
unsigned short us;
|
||||||
};
|
};
|
||||||
} noomV_Inst;
|
} noomV_Inst;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user