From 7f878fd8a7ccf5f77a844dcc54e127bcfa76288e Mon Sep 17 00:00:00 2001 From: "e.gavrin" Date: Thu, 3 Jul 2014 18:37:57 +0400 Subject: [PATCH] add opcodes --- src/libcoreint/opcodes.c | 4 +- src/libcoreint/opcodes.h | 79 ++++++++++++++++++++++++++++++++++------ 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 78eae6979..dba9c4397 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -30,7 +30,7 @@ opfunc_op_call_1 (OPCODE opdata) { printf ("op_call_1:idx:%d:%d\n", opdata.data.call_1.name_literal_idx, - opdata.data.call_1.arg_literal_idx); + opdata.data.call_1.arg1_literal_idx); } void @@ -67,7 +67,7 @@ save_op_call_1 (FILE *file, OPCODE opdata, int arg1, int arg2) opdata.opfunc_ptr = opfunc_op_call_1; opdata.data.call_1.name_literal_idx = arg1; - opdata.data.call_1.arg_literal_idx = arg2; + opdata.data.call_1.arg1_literal_idx = arg2; fwrite (&opdata, sizeof (OPCODE), 1, file); } diff --git a/src/libcoreint/opcodes.h b/src/libcoreint/opcodes.h index 62f1e6ea0..9325ef2ec 100644 --- a/src/libcoreint/opcodes.h +++ b/src/libcoreint/opcodes.h @@ -26,23 +26,80 @@ OPCODE; typedef void (*opfunc)(OPCODE); -OP_DEF (loop_inf) -{ - int opcode_idx; -}; - -/** Call with 1 argument */ -OP_DEF (call_1) -{ - int name_literal_idx; - int arg_literal_idx; -}; +OP_DEF (nop) { }; OP_DEF (jmp) { int opcode_idx; }; +OP_DEF (decl) { }; + +OP_DEF (named_func_decl) { }; + +OP_DEF (anon_func_decl) { }; + +OP_DEF (decl_var_global) { }; + +OP_DEF (decl_var_local) { }; + +/** Call with 1 argument */ +OP_DEF (call_1) +{ + int name_literal_idx; + int arg1_literal_idx; +}; + +OP_DEF (call_2) +{ + int name_literal_idx; + int arg1_literal_idx; + int 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 (list_header) { }; + +OP_DEF (list_element) { }; + +OP_DEF (list_tail) { }; + +OP_DEF (try_begin) { }; + +OP_DEF (try_end) { }; + +OP_DEF (catch_begin) { }; + +OP_DEF (catch_end) { }; + +OP_DEF (finally_begin) { }; + +OP_DEF (finally_end) { }; + +OP_DEF (with_begin) { }; + +OP_DEF (with_end) { }; + +OP_DEF (loop_inf) +{ + int opcode_idx; +}; + +OP_DEF (loop_cond_pre) { }; + +OP_DEF (loop_cond_post) { }; + +OP_DEF (swtch) { }; + OPCODE{ opfunc opfunc_ptr;