compacting
This commit is contained in:
+25
-25
@@ -16,12 +16,16 @@
|
|||||||
#ifndef OPCODES_H
|
#ifndef OPCODES_H
|
||||||
#define OPCODES_H
|
#define OPCODES_H
|
||||||
|
|
||||||
#include "stdio.h"
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
#define OPCODE struct __opcode
|
#define OPCODE struct __opcode
|
||||||
#define OP_DEF(name) struct __op_##name
|
#define OP_DEF(name) struct __op_##name
|
||||||
#define OP(name) struct __op_##name name
|
#define OP(name) struct __op_##name name
|
||||||
|
|
||||||
|
#define OP_TYPE_IDX uint8_t
|
||||||
|
|
||||||
OPCODE;
|
OPCODE;
|
||||||
|
|
||||||
typedef void (*opfunc)(OPCODE);
|
typedef void (*opfunc)(OPCODE);
|
||||||
@@ -30,7 +34,7 @@ OP_DEF (nop) { };
|
|||||||
|
|
||||||
OP_DEF (jmp)
|
OP_DEF (jmp)
|
||||||
{
|
{
|
||||||
int opcode_idx;
|
OP_TYPE_IDX opcode_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
OP_DEF (decl) { };
|
OP_DEF (decl) { };
|
||||||
@@ -46,23 +50,15 @@ OP_DEF (decl_var_local) { };
|
|||||||
/** Call with 1 argument */
|
/** Call with 1 argument */
|
||||||
OP_DEF (call_1)
|
OP_DEF (call_1)
|
||||||
{
|
{
|
||||||
int name_literal_idx;
|
OP_TYPE_IDX name_literal_idx;
|
||||||
int arg1_literal_idx;
|
OP_TYPE_IDX arg1_literal_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
OP_DEF (call_2)
|
OP_DEF (call_2)
|
||||||
{
|
{
|
||||||
int name_literal_idx;
|
OP_TYPE_IDX name_literal_idx;
|
||||||
int arg1_literal_idx;
|
OP_TYPE_IDX arg1_literal_idx;
|
||||||
int arg2_literal_idx;
|
OP_TYPE_IDX arg2_literal_idx;
|
||||||
};
|
|
||||||
|
|
||||||
OP_DEF (call_3)
|
|
||||||
{
|
|
||||||
int name_literal_idx;
|
|
||||||
int arg1_literal_idx;
|
|
||||||
int arg2_literal_idx;
|
|
||||||
int arg3_literal_idx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OP_DEF (call_n) { };
|
OP_DEF (call_n) { };
|
||||||
@@ -91,7 +87,7 @@ OP_DEF (with_end) { };
|
|||||||
|
|
||||||
OP_DEF (loop_inf)
|
OP_DEF (loop_inf)
|
||||||
{
|
{
|
||||||
int opcode_idx;
|
OP_TYPE_IDX opcode_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
OP_DEF (loop_cond_pre) { };
|
OP_DEF (loop_cond_pre) { };
|
||||||
@@ -100,18 +96,22 @@ OP_DEF (loop_cond_post) { };
|
|||||||
|
|
||||||
OP_DEF (swtch) { };
|
OP_DEF (swtch) { };
|
||||||
|
|
||||||
OPCODE{
|
/** OPCODES */
|
||||||
opfunc opfunc_ptr;
|
union __opdata
|
||||||
|
{
|
||||||
/** OPCODES */
|
|
||||||
union __opdata
|
|
||||||
{
|
|
||||||
OP (loop_inf);
|
OP (loop_inf);
|
||||||
OP (call_1);
|
OP (call_1);
|
||||||
|
OP (call_2);
|
||||||
|
OP (call_n);
|
||||||
|
|
||||||
OP (jmp);
|
OP (jmp);
|
||||||
} data;
|
OP (nop);
|
||||||
}
|
} data;
|
||||||
__packed;
|
|
||||||
|
OPCODE {
|
||||||
|
opfunc opfunc_ptr;
|
||||||
|
union __opdata data;
|
||||||
|
} __packed;
|
||||||
|
|
||||||
void save_op_jmp (FILE *, OPCODE, int);
|
void save_op_jmp (FILE *, OPCODE, int);
|
||||||
void save_op_call_1 (FILE *, OPCODE, int, int);
|
void save_op_call_1 (FILE *, OPCODE, int, int);
|
||||||
|
|||||||
Reference in New Issue
Block a user