Refine opcodes OP_LIST macro. Removed ambiguous lists of opcodes in several files. The only list is in opcodes.h

This commit is contained in:
e.gavrin 2014-08-23 00:13:42 +04:00
parent d4a9d9430e
commit d80cb10361
6 changed files with 130 additions and 308 deletions

View File

@ -23,12 +23,12 @@
#include "interpreter.h" #include "interpreter.h"
#include "jerry-libc.h" #include "jerry-libc.h"
#define INIT_OP_FUNC(name) [ __op__idx_##name ] = opfunc_##name, #define __INIT_OP_FUNC(name, arg1, arg2, arg3) [ __op__idx_##name ] = opfunc_##name,
static const opfunc __opfuncs[LAST_OP] = static const opfunc __opfuncs[LAST_OP] =
{ {
OP_LIST (INIT_OP_FUNC) OP_LIST (INIT_OP_FUNC)
}; };
#undef INIT_OP_FUNC #undef __INIT_OP_FUNC
JERRY_STATIC_ASSERT (sizeof (OPCODE) <= 4); JERRY_STATIC_ASSERT (sizeof (OPCODE) <= 4);

View File

@ -15,7 +15,7 @@
#include "opcodes-support.h" #include "opcodes-support.h"
#define GETOP_DEF_0(name) \ #define GETOP_DEF_0(a, name) \
__opcode getop_##name (void) \ __opcode getop_##name (void) \
{ \ { \
__opcode opdata; \ __opcode opdata; \
@ -23,7 +23,7 @@
return opdata; \ return opdata; \
} }
#define GETOP_DEF_1(name, field1) \ #define GETOP_DEF_1(a, name, field1) \
__opcode getop_##name (T_IDX arg1) \ __opcode getop_##name (T_IDX arg1) \
{ \ { \
__opcode opdata; \ __opcode opdata; \
@ -32,7 +32,7 @@
return opdata; \ return opdata; \
} }
#define GETOP_DEF_2(name, field1, field2) \ #define GETOP_DEF_2(a, name, field1, field2) \
__opcode getop_##name (T_IDX arg1, T_IDX arg2) \ __opcode getop_##name (T_IDX arg1, T_IDX arg2) \
{ \ { \
__opcode opdata; \ __opcode opdata; \
@ -42,7 +42,7 @@
return opdata; \ return opdata; \
} }
#define GETOP_DEF_3(name, field1, field2, field3) \ #define GETOP_DEF_3(a, name, field1, field2, field3) \
__opcode getop_##name (T_IDX arg1, T_IDX arg2, T_IDX arg3) \ __opcode getop_##name (T_IDX arg1, T_IDX arg2, T_IDX arg3) \
{ \ { \
__opcode opdata; \ __opcode opdata; \
@ -53,67 +53,4 @@
return opdata; \ return opdata; \
} }
GETOP_DEF_3 (construct_decl, lhs, name_lit_idx, arg_list) OP_ARGS_LIST (GETOP_DEF)
GETOP_DEF_1 (func_decl_0, name_lit_idx)
GETOP_DEF_2 (array_decl, lhs, list)
GETOP_DEF_3 (prop, lhs, name, value)
GETOP_DEF_3 (prop_getter, lhs, obj, prop)
GETOP_DEF_3 (prop_setter, obj, prop, rhs)
GETOP_DEF_2 (prop_get_decl, lhs, prop)
GETOP_DEF_3 (prop_set_decl, lhs, prop, arg)
GETOP_DEF_2 (obj_decl, lhs, list)
GETOP_DEF_1 (this, lhs)
GETOP_DEF_2 (delete, lhs, obj)
GETOP_DEF_2 (typeof, lhs, obj)
GETOP_DEF_1 (with, expr)
GETOP_DEF_0 (end_with)
GETOP_DEF_1 (var_decl, variable_name)
GETOP_DEF_2 (reg_var_decl, min, max)
GETOP_DEF_3 (meta, type, data_1, data_2)
GETOP_DEF_2 (is_true_jmp, value, opcode)
GETOP_DEF_2 (is_false_jmp, value, opcode)
GETOP_DEF_1 (jmp, opcode_idx)
GETOP_DEF_1 (jmp_up, opcode_count)
GETOP_DEF_1 (jmp_down, opcode_count)
GETOP_DEF_3 (addition, dst, var_left, var_right)
GETOP_DEF_2 (post_incr, dst, var_right)
GETOP_DEF_2 (post_decr, dst, var_right)
GETOP_DEF_2 (pre_incr, dst, var_right)
GETOP_DEF_2 (pre_decr, dst, var_right)
GETOP_DEF_3 (substraction, dst, var_left, var_right)
GETOP_DEF_3 (division, dst, var_left, var_right)
GETOP_DEF_3 (multiplication, dst, var_left, var_right)
GETOP_DEF_3 (remainder, dst, var_left, var_right)
GETOP_DEF_3 (b_shift_left, dst, var_left, var_right)
GETOP_DEF_3 (b_shift_right, dst, var_left, var_right)
GETOP_DEF_3 (b_shift_uright, dst, var_left, var_right)
GETOP_DEF_3 (b_and, dst, var_left, var_right)
GETOP_DEF_3 (b_or, dst, var_left, var_right)
GETOP_DEF_3 (b_xor, dst, var_left, var_right)
GETOP_DEF_3 (logical_and, dst, var_left, var_right)
GETOP_DEF_3 (logical_or, dst, var_left, var_right)
GETOP_DEF_3 (equal_value, dst, var_left, var_right)
GETOP_DEF_3 (not_equal_value, dst, var_left, var_right)
GETOP_DEF_3 (equal_value_type, dst, var_left, var_right)
GETOP_DEF_3 (not_equal_value_type, dst, var_left, var_right)
GETOP_DEF_3 (less_than, dst, var_left, var_right)
GETOP_DEF_3 (greater_than, dst, var_left, var_right)
GETOP_DEF_3 (less_or_equal_than, dst, var_left, var_right)
GETOP_DEF_3 (greater_or_equal_than, dst, var_left, var_right)
GETOP_DEF_3 (assignment, var_left, type_value_right, value_right)
GETOP_DEF_2 (call_0, lhs, name_lit_idx)
GETOP_DEF_3 (call_1, lhs, name_lit_idx, arg1_lit_idx)
GETOP_DEF_3 (call_n, lhs, name_lit_idx, arg1_lit_idx)
GETOP_DEF_3 (native_call, lhs, name, arg_list)
GETOP_DEF_2 (func_decl_1, name_lit_idx, arg1_lit_idx)
GETOP_DEF_3 (func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
GETOP_DEF_3 (func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
GETOP_DEF_3 (varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx)
GETOP_DEF_1 (exitval, status_code)
GETOP_DEF_1 (retval, ret_value)
GETOP_DEF_0 (ret)
GETOP_DEF_0 (nop)
GETOP_DEF_2 (b_not, dst, var_right)
GETOP_DEF_2 (logical_not, dst, var_right)
GETOP_DEF_3 (instanceof, dst, var_left, var_right)
GETOP_DEF_3 (in, dst, var_left, var_right)

View File

@ -18,82 +18,20 @@
#include "opcodes.h" #include "opcodes.h"
#define GETOP_DECL_0(name) \ #define GETOP_DECL_0(a, name) \
__opcode getop_##name (void); __opcode getop_##name (void);
#define GETOP_DECL_1(name, field1) \ #define GETOP_DECL_1(a, name, arg1) \
__opcode getop_##name (T_IDX); __opcode getop_##name (T_IDX);
#define GETOP_DECL_2(name, field1, field2) \ #define GETOP_DECL_2(a, name, arg1, arg2) \
__opcode getop_##name (T_IDX, T_IDX); __opcode getop_##name (T_IDX, T_IDX);
#define GETOP_DECL_3(name, field1, field2, field3) \ #define GETOP_DECL_3(a, name, arg1, arg2, arg3) \
__opcode getop_##name (T_IDX, T_IDX, T_IDX); __opcode getop_##name (T_IDX, T_IDX, T_IDX);
GETOP_DECL_3 (construct_decl, lhs, name_lit_idx, arg_list)
GETOP_DECL_1 (func_decl_0, name_lit_idx) OP_ARGS_LIST (GETOP_DECL)
GETOP_DECL_2 (array_decl, lhs, list)
GETOP_DECL_3 (prop, lhs, name, value)
GETOP_DECL_3 (prop_getter, lhs, obj, prop)
GETOP_DECL_3 (prop_setter, obj, prop, rhs)
GETOP_DECL_2 (prop_get_decl, lhs, prop)
GETOP_DECL_3 (prop_set_decl, lhs, prop, arg)
GETOP_DECL_2 (obj_decl, lhs, list)
GETOP_DECL_1 (this, lhs)
GETOP_DECL_2 (delete, lhs, obj)
GETOP_DECL_2 (typeof, lhs, obj)
GETOP_DECL_1 (with, expr)
GETOP_DECL_0 (end_with)
GETOP_DECL_1 (var_decl, variable_name)
GETOP_DECL_2 (reg_var_decl, min, max)
GETOP_DECL_3 (meta, type, data_1, data_2)
GETOP_DECL_2 (is_true_jmp, value, opcode)
GETOP_DECL_2 (is_false_jmp, value, opcode)
GETOP_DECL_1 (jmp, opcode_idx)
GETOP_DECL_1 (jmp_up, opcode_count)
GETOP_DECL_1 (jmp_down, opcode_count)
GETOP_DECL_3 (addition, dst, var_left, var_right)
GETOP_DECL_2 (post_incr, dst, var_right)
GETOP_DECL_2 (post_decr, dst, var_right)
GETOP_DECL_2 (pre_incr, dst, var_right)
GETOP_DECL_2 (pre_decr, dst, var_right)
GETOP_DECL_3 (substraction, dst, var_left, var_right)
GETOP_DECL_3 (division, dst, var_left, var_right)
GETOP_DECL_3 (multiplication, dst, var_left, var_right)
GETOP_DECL_3 (remainder, dst, var_left, var_right)
GETOP_DECL_3 (b_shift_left, dst, var_left, var_right)
GETOP_DECL_3 (b_shift_right, dst, var_left, var_right)
GETOP_DECL_3 (b_shift_uright, dst, var_left, var_right)
GETOP_DECL_3 (b_and, dst, var_left, var_right)
GETOP_DECL_3 (b_or, dst, var_left, var_right)
GETOP_DECL_3 (b_xor, dst, var_left, var_right)
GETOP_DECL_3 (logical_and, dst, var_left, var_right)
GETOP_DECL_3 (logical_or, dst, var_left, var_right)
GETOP_DECL_3 (equal_value, dst, var_left, var_right)
GETOP_DECL_3 (not_equal_value, dst, var_left, var_right)
GETOP_DECL_3 (equal_value_type, dst, var_left, var_right)
GETOP_DECL_3 (not_equal_value_type, dst, var_left, var_right)
GETOP_DECL_3 (less_than, dst, var_left, var_right)
GETOP_DECL_3 (greater_than, dst, var_left, var_right)
GETOP_DECL_3 (less_or_equal_than, dst, var_left, var_right)
GETOP_DECL_3 (greater_or_equal_than, dst, var_left, var_right)
GETOP_DECL_3 (assignment, var_left, type_value_right, value_right)
GETOP_DECL_2 (call_0, lhs, name_lit_idx)
GETOP_DECL_3 (call_1, lhs, name_lit_idx, arg1_lit_idx)
GETOP_DECL_3 (call_n, lhs, name_lit_idx, arg1_lit_idx)
GETOP_DECL_3 (native_call, lhs, name, arg_list)
GETOP_DECL_2 (func_decl_1, name_lit_idx, arg1_lit_idx)
GETOP_DECL_3 (func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
GETOP_DECL_3 (func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
GETOP_DECL_3 (varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx)
GETOP_DECL_1 (exitval, status_code)
GETOP_DECL_1 (retval, ret_value)
GETOP_DECL_0 (ret)
GETOP_DECL_0 (nop)
GETOP_DECL_2 (b_not, dst, var_right)
GETOP_DECL_2 (logical_not, dst, var_right)
GETOP_DECL_3 (instanceof, dst, var_left, var_right)
GETOP_DECL_3 (in, dst, var_left, var_right)
#endif /* OPCODES_SUPPORT_H */ #endif /* OPCODES_SUPPORT_H */

View File

@ -22,9 +22,21 @@
#define T_IDX uint8_t /** index values */ #define T_IDX uint8_t /** index values */
#define OPCODE __opcode #define OPCODE __opcode
#define OP_STRUCT_FIELD(name) __op_##name name; #define OP_0(action, name) \
#define OP_ENUM_FIELD(name) __op__idx_##name , __##action (name, void, void, void)
#define OP_FUNC_DECL(name) ecma_completion_value_t opfunc_##name (__opcode, __int_data*);
#define OP_1(action, name, field1) \
__##action (name, field1, void, void)
#define OP_2(action, name, field1, field2) \
__##action (name, field1, field2, void)
#define OP_3(action, name, field1, field2, field3) \
__##action (name, field1, field2, field3)
#define __OP_STRUCT_FIELD(name, arg1, arg2, arg3) __op_##name name;
#define __OP_ENUM_FIELD(name, arg1, arg2, arg3) __op__idx_##name ,
#define __OP_FUNC_DECL(name, arg1, arg2, arg3) ecma_completion_value_t opfunc_##name (__opcode, __int_data*);
typedef uint16_t opcode_counter_t; typedef uint16_t opcode_counter_t;
@ -40,198 +52,133 @@ typedef struct
ecma_value_t *regs_p; /**< register variables */ ecma_value_t *regs_p; /**< register variables */
} __int_data; } __int_data;
#define OP_CALLS_AND_ARGS(op) \ #define OP_CALLS_AND_ARGS(p, a) \
op (call_0) \ p##_2 (a, call_0, lhs, name_lit_idx) \
op (call_1) \ p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \
op (call_n) \ p##_3 (a, call_n, lhs, name_lit_idx, arg1_lit_idx) \
op (native_call) \ p##_3 (a, native_call, lhs, name, arg_list) \
op (construct_decl) \ p##_3 (a, construct_decl, lhs, name_lit_idx, arg_list) \
op (func_decl_0) \ p##_1 (a, func_decl_0, name_lit_idx) \
op (func_decl_1) \ p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \
op (func_decl_2) \ p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \
op (func_decl_n) \ p##_3 (a, func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \
op (varg_list) \ p##_3 (a, varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx) \
op (exitval) \ p##_1 (a, exitval, status_code) \
op (retval) \ p##_1 (a, retval, ret_value) \
op (ret) p##_0 (a, ret)
#define OP_INITS(op) \ #define OP_INITS(p, a) \
op (array_decl) \ p##_2 (a, array_decl, lhs, list) \
op (prop) \ p##_3 (a, prop, lhs, name, value) \
op (prop_getter) \ p##_3 (a, prop_getter, lhs, obj, prop) \
op (prop_setter) \ p##_3 (a, prop_setter, obj, prop, rhs) \
op (prop_get_decl) \ p##_2 (a, prop_get_decl, lhs, prop) \
op (prop_set_decl) \ p##_3 (a, prop_set_decl, lhs, prop, arg) \
op (obj_decl) \ p##_2 (a, obj_decl, lhs, list) \
op (this) \ p##_1 (a, this, lhs) \
op (delete) \ p##_2 (a, delete, lhs, obj) \
op (typeof) \ p##_2 (a, typeof, lhs, obj) \
op (with) \ p##_1 (a, with, expr) \
op (end_with) p##_0 (a, end_with)
#define OP_ASSIGNMENTS(op) \ #define OP_ASSIGNMENTS(p, a) \
op (assignment) p##_3 (a, assignment, var_left, type_value_right, value_right)
#define OP_B_SHIFTS(op) \ #define OP_B_SHIFTS(p, a) \
op (b_shift_left) \ p##_3 (a, b_shift_left, dst, var_left, var_right) \
op (b_shift_right) \ p##_3 (a, b_shift_right, dst, var_left, var_right) \
op (b_shift_uright) p##_3 (a, b_shift_uright, dst, var_left, var_right)
#define OP_B_BITWISE(op) \ #define OP_B_BITWISE(p, a) \
op (b_and) \ p##_3 (a, b_and, dst, var_left, var_right) \
op (b_or) \ p##_3 (a, b_or, dst, var_left, var_right) \
op (b_xor) \ p##_3 (a, b_xor, dst, var_left, var_right) \
op (b_not) p##_2 (a, b_not, dst, var_right)
#define OP_B_LOGICAL(op) \ #define OP_B_LOGICAL(p, a) \
op (logical_and) \ p##_3 (a, logical_and, dst, var_left, var_right) \
op (logical_or) \ p##_3 (a, logical_or, dst, var_left, var_right) \
op (logical_not) p##_2 (a, logical_not, dst, var_right)
#define OP_EQUALITY(op) \ #define OP_EQUALITY(p, a) \
op (equal_value) \ p##_3 (a, equal_value, dst, var_left, var_right) \
op (not_equal_value) \ p##_3 (a, not_equal_value, dst, var_left, var_right) \
op (equal_value_type) \ p##_3 (a, equal_value_type, dst, var_left, var_right) \
op (not_equal_value_type) p##_3 (a, not_equal_value_type, dst, var_left, var_right)
#define OP_RELATIONAL(op) \ #define OP_RELATIONAL(p, a) \
op (less_than) \ p##_3 (a, less_than, dst, var_left, var_right) \
op (greater_than) \ p##_3 (a, greater_than, dst, var_left, var_right) \
op (less_or_equal_than) \ p##_3 (a, less_or_equal_than, dst, var_left, var_right) \
op (greater_or_equal_than) \ p##_3 (a, greater_or_equal_than, dst, var_left, var_right) \
op (instanceof) \ p##_3 (a, instanceof, dst, var_left, var_right) \
op (in) p##_3 (a, in, dst, var_left, var_right)
#define OP_ARITHMETIC(op) \ #define OP_ARITHMETIC(p, a) \
op (post_incr) \ p##_2 (a, post_incr, dst, var_right) \
op (post_decr) \ p##_2 (a, post_decr, dst, var_right) \
op (pre_incr) \ p##_2 (a, pre_incr, dst, var_right) \
op (pre_decr) \ p##_2 (a, pre_decr, dst, var_right) \
op (addition) \ p##_3 (a, addition, dst, var_left, var_right) \
op (substraction) \ p##_3 (a, substraction, dst, var_left, var_right) \
op (division) \ p##_3 (a, division, dst, var_left, var_right) \
op (multiplication) \ p##_3 (a, multiplication, dst, var_left, var_right) \
op (remainder) p##_3 (a, remainder, dst, var_left, var_right)
#define OP_UNCONDITIONAL_JUMPS(op) \ #define OP_JUMPS(p, a) \
op (jmp) \ p##_1 (a, jmp, opcode_idx) \
op (jmp_up) \ p##_1 (a, jmp_up, opcode_count) \
op (jmp_down) \ p##_1 (a, jmp_down, opcode_count) \
op (nop) p##_0 (a, nop) \
p##_2 (a, is_true_jmp, value, opcode) \
p##_2 (a, is_false_jmp, value, opcode)
#define OP_UNARY_OPS(op) \ #define OP_LIST_FULL(p, a) \
op (is_true_jmp) \ OP_CALLS_AND_ARGS (p, a) \
op (is_false_jmp) OP_INITS (p, a) \
OP_ASSIGNMENTS (p, a) \
OP_B_LOGICAL (p, a) \
OP_B_BITWISE (p, a) \
OP_B_SHIFTS (p, a) \
OP_EQUALITY (p, a) \
OP_RELATIONAL (p, a) \
OP_ARITHMETIC (p, a) \
OP_JUMPS (p, a) \
p##_1 (a, var_decl, variable_name) \
p##_2 (a, reg_var_decl, min, max) \
p##_3 (a, meta, type, data_1, data_2)
#define OP_LIST(op) \ #define OP_LIST(a) OP_LIST_FULL (OP, a)
OP_CALLS_AND_ARGS (op) \ #define OP_ARGS_LIST(a) OP_LIST_FULL (a, void)
OP_INITS (op) \
OP_ASSIGNMENTS (op) \
OP_B_LOGICAL (op) \
OP_B_BITWISE (op) \
OP_B_SHIFTS (op) \
OP_EQUALITY (op) \
OP_RELATIONAL (op) \
OP_ARITHMETIC (op) \
OP_UNCONDITIONAL_JUMPS (op) \
OP_UNARY_OPS (op) \
op (var_decl) \
op (reg_var_decl)\
op (meta)
#define OP_DATA (name, list) typedef struct { list ; } __op_##name; #define OP_DATA_0(action, name) \
#define OP_DATA_0(name) \
typedef struct \ typedef struct \
{ \ { \
T_IDX __do_not_use; \ T_IDX __do_not_use; \
} __op_##name } __op_##name;
#define OP_DATA_1(name, arg1) \ #define OP_DATA_1(action, name, arg1) \
typedef struct \ typedef struct \
{ \ { \
T_IDX arg1; \ T_IDX arg1; \
} __op_##name } __op_##name;
#define OP_DATA_2(name, arg1, arg2) \ #define OP_DATA_2(action, name, arg1, arg2) \
typedef struct \ typedef struct \
{ \ { \
T_IDX arg1; \ T_IDX arg1; \
T_IDX arg2; \ T_IDX arg2; \
} __op_##name } __op_##name;
#define OP_DATA_3(name, arg1, arg2, arg3) \ #define OP_DATA_3(action, name, arg1, arg2, arg3) \
typedef struct \ typedef struct \
{ \ { \
T_IDX arg1; \ T_IDX arg1; \
T_IDX arg2; \ T_IDX arg2; \
T_IDX arg3; \ T_IDX arg3; \
} __op_##name } __op_##name;
OP_DATA_2 (is_true_jmp, value, opcode); OP_ARGS_LIST (OP_DATA)
OP_DATA_2 (is_false_jmp, value, opcode);
OP_DATA_1 (jmp, opcode_idx);
OP_DATA_1 (jmp_up, opcode_count);
OP_DATA_1 (jmp_down, opcode_count);
OP_DATA_3 (addition, dst, var_left, var_right);
OP_DATA_2 (post_incr, dst, var_right);
OP_DATA_2 (post_decr, dst, var_right);
OP_DATA_2 (pre_incr, dst, var_right);
OP_DATA_2 (pre_decr, dst, var_right);
OP_DATA_3 (substraction, dst, var_left, var_right);
OP_DATA_3 (division, dst, var_left, var_right);
OP_DATA_3 (multiplication, dst, var_left, var_right);
OP_DATA_3 (remainder, dst, var_left, var_right);
OP_DATA_3 (b_shift_left, dst, var_left, var_right);
OP_DATA_3 (b_shift_right, dst, var_left, var_right);
OP_DATA_3 (b_shift_uright, dst, var_left, var_right);
OP_DATA_3 (b_and, dst, var_left, var_right);
OP_DATA_3 (b_or, dst, var_left, var_right);
OP_DATA_3 (b_xor, dst, var_left, var_right);
OP_DATA_3 (logical_and, dst, var_left, var_right);
OP_DATA_3 (logical_or, dst, var_left, var_right);
OP_DATA_3 (equal_value, dst, var_left, var_right);
OP_DATA_3 (not_equal_value, dst, var_left, var_right);
OP_DATA_3 (equal_value_type, dst, var_left, var_right);
OP_DATA_3 (not_equal_value_type, dst, var_left, var_right);
OP_DATA_3 (less_than, dst, var_left, var_right);
OP_DATA_3 (greater_than, dst, var_left, var_right);
OP_DATA_3 (less_or_equal_than, dst, var_left, var_right);
OP_DATA_3 (greater_or_equal_than, dst, var_left, var_right);
OP_DATA_3 (assignment, var_left, type_value_right, value_right);
OP_DATA_2 (call_0, lhs, name_lit_idx);
OP_DATA_3 (call_1, lhs, name_lit_idx, arg1_lit_idx);
OP_DATA_3 (call_n, lhs, name_lit_idx, arg1_lit_idx);
OP_DATA_3 (native_call, lhs, name, arg_list);
OP_DATA_2 (func_decl_1, name_lit_idx, arg1_lit_idx);
OP_DATA_3 (func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx);
OP_DATA_3 (func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx);
OP_DATA_3 (varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx);
OP_DATA_1 (exitval, status_code);
OP_DATA_1 (retval, ret_value);
OP_DATA_0 (ret);
OP_DATA_0 (nop);
OP_DATA_1 (var_decl, variable_name);
OP_DATA_2 (b_not, dst, var_right);
OP_DATA_2 (logical_not, dst, var_right);
OP_DATA_3 (instanceof, dst, var_left, var_right);
OP_DATA_3 (in, dst, var_left, var_right);
OP_DATA_3 (construct_decl, lhs, name_lit_idx, arg_list);
OP_DATA_1 (func_decl_0, name_lit_idx);
OP_DATA_2 (array_decl, lhs, list);
OP_DATA_3 (prop, lhs, name, value);
OP_DATA_3 (prop_getter, lhs, obj, prop);
OP_DATA_3 (prop_setter, obj, prop, rhs);
OP_DATA_2 (prop_get_decl, lhs, prop);
OP_DATA_3 (prop_set_decl, lhs, prop, arg);
OP_DATA_2 (obj_decl, lhs, list);
OP_DATA_1 (this, lhs);
OP_DATA_2 (delete, lhs, obj);
OP_DATA_2 (typeof, lhs, obj);
OP_DATA_1 (with, expr);
OP_DATA_0 (end_with);
OP_DATA_2 (reg_var_decl, min, max);
OP_DATA_3 (meta, type, data_1, data_2);
typedef struct typedef struct
{ {

View File

@ -21,11 +21,11 @@
#define FIELD(op, field) (opcode.data.op.field) #define FIELD(op, field) (opcode.data.op.field)
#define OPCODE_STR(op) \ #define __OPCODE_STR(name, arg1, arg2, arg3) \
#op, #name,
#define OPCODE_SIZE(op) \ #define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##op) + 1, sizeof (__op_##name) + 1,
static char* opcode_names[] = static char* opcode_names[] =
{ {

View File

@ -18,8 +18,8 @@
#define NAME_TO_ID(op) (__op__idx_##op) #define NAME_TO_ID(op) (__op__idx_##op)
#define OPCODE_SIZE(op) \ #define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##op) + 1, sizeof (__op_##name) + 1,
static uint8_t opcode_sizes[] = { static uint8_t opcode_sizes[] = {
OP_LIST (OPCODE_SIZE) OP_LIST (OPCODE_SIZE)