Adding 'func_expr_n' opcode; replacing arg1 and arg2 of 'func_decl_n' opcode with arg_list.

This commit is contained in:
Ruben Ayrapetyan
2014-08-26 15:58:57 +04:00
parent 7a80b7f4f1
commit 02f31fbcfb
4 changed files with 21 additions and 20 deletions
+1
View File
@@ -120,6 +120,7 @@ free_string_literal_copy (string_literal_copy *str_lit_descr_p) /**< string lite
op (call_n) \ op (call_n) \
op (native_call) \ op (native_call) \
op (func_decl_n) \ op (func_decl_n) \
op (func_expr_n) \
op (varg_list) \ op (varg_list) \
op (construct_n) \ op (construct_n) \
op (array_decl) \ op (array_decl) \
+3 -2
View File
@@ -62,13 +62,14 @@ typedef struct
#define OP_CALLS_AND_ARGS(p, a) \ #define OP_CALLS_AND_ARGS(p, a) \
p##_2 (a, call_0, lhs, name_lit_idx) \ p##_2 (a, call_0, lhs, name_lit_idx) \
p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \ p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \
p##_3 (a, call_n, lhs, name_lit_idx, arg1_lit_idx) \ p##_3 (a, call_n, lhs, name_lit_idx, arg_list) \
p##_3 (a, native_call, lhs, name, arg_list) \ p##_3 (a, native_call, lhs, name, arg_list) \
p##_3 (a, construct_n, lhs, name_lit_idx, arg_list) \ p##_3 (a, construct_n, lhs, name_lit_idx, arg_list) \
p##_1 (a, func_decl_0, name_lit_idx) \ p##_1 (a, func_decl_0, name_lit_idx) \
p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \ p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \
p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \
p##_3 (a, func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ p##_2 (a, func_decl_n, name_lit_idx, arg_list) \
p##_3 (a, func_expr_n, lhs, name_lit_idx, arg_list) \
p##_3 (a, varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx) \ p##_3 (a, varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx) \
p##_1 (a, exitval, status_code) \ p##_1 (a, exitval, status_code) \
p##_1 (a, retval, ret_value) \ p##_1 (a, retval, ret_value) \
+2 -1
View File
@@ -655,7 +655,8 @@ parse_argument_list (argument_list_type alt, idx_t obj)
{ {
case AL_FUNC_DECL: case AL_FUNC_DECL:
{ {
DUMP_OPCODE_3 (func_decl_n, obj, args[0], args[1]); TODO(Refine to match new opcodes)
// DUMP_OPCODE_3 (func_decl_n, obj, args[0], args[1]);
break; break;
} }
case AL_FUNC_EXPR: case AL_FUNC_EXPR:
+15 -17
View File
@@ -66,6 +66,14 @@ pp_nums (const ecma_number_t nums[], uint8_t size, uint8_t strings_num)
__printf ("\n"); __printf ("\n");
} }
static void
dump_arg_list (idx_t id)
{
FIXME (/* Dump arg list instead of args' number */);
__printf (" (%d args)", id);
}
static void static void
dump_variable (idx_t id) dump_variable (idx_t id)
{ {
@@ -181,15 +189,12 @@ dump_variable (idx_t id)
__printf (end ";"); \ __printf (end ";"); \
break; break;
#define CASE_VARG_N_NAME_LHS(op, lhs, equals, new, name, start, arg, end) \ #define CASE_VARG_N_NAME_LHS(op, lhs, equals, new, name, arg_list) \
case NAME_TO_ID (op): \ case NAME_TO_ID (op): \
dump_variable (opcode.data.op.lhs); \ dump_variable (opcode.data.op.lhs); \
__printf (" " equals " " new " "); \ __printf (" " equals " " new " "); \
dump_variable (opcode.data.op.name); \ dump_variable (opcode.data.op.name); \
__printf (start); \ dump_arg_list (opcode.data.op.arg_list); \
dump_variable (opcode.data.op.arg); \
__printf (" ..."); \
varg_end = end; \
break; break;
#define CASE_VARG_0_NAME(op, new, name, start, end) \ #define CASE_VARG_0_NAME(op, new, name, start, end) \
@@ -219,16 +224,11 @@ dump_variable (idx_t id)
__printf (end ";"); \ __printf (end ";"); \
break; break;
#define CASE_VARG_N_NAME(op, new, name, start, arg1, arg2, end) \ #define CASE_VARG_N_NAME(op, new, name, arg_list) \
case NAME_TO_ID (op): \ case NAME_TO_ID (op): \
__printf (new " "); \ __printf (new " "); \
dump_variable (opcode.data.op.name); \ dump_variable (opcode.data.op.name); \
__printf (start); \ dump_arg_list (opcode.data.op.arg_list); \
dump_variable (opcode.data.op.arg1); \
__printf (", "); \
dump_variable (opcode.data.op.arg2); \
__printf (" ..."); \
varg_end = end; \
break; break;
#define CASE_VARG_0_LHS(op, lhs, equals, start, end) \ #define CASE_VARG_0_LHS(op, lhs, equals, start, end) \
@@ -346,8 +346,6 @@ dump_variable (idx_t id)
__printf (";"); \ __printf (";"); \
break; break;
static char *varg_end;
void void
pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite) pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite)
{ {
@@ -414,12 +412,12 @@ pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite)
CASE_ASSIGNMENT (assignment, var_left, "=", value_right) CASE_ASSIGNMENT (assignment, var_left, "=", value_right)
CASE_VARG_0_NAME_LHS (call_0, lhs, "=", "", name_lit_idx, "(", ")") CASE_VARG_0_NAME_LHS (call_0, lhs, "=", "", name_lit_idx, "(", ")")
CASE_VARG_1_NAME_LHS (call_1, lhs, "=", "", name_lit_idx, "(", arg1_lit_idx, ")") CASE_VARG_1_NAME_LHS (call_1, lhs, "=", "", name_lit_idx, "(", arg1_lit_idx, ")")
CASE_VARG_N_NAME_LHS (call_n, lhs, "=", "", name_lit_idx, "(", arg1_lit_idx, ")") CASE_VARG_N_NAME_LHS (call_n, lhs, "=", "", name_lit_idx, arg_list)
CASE_VARG_N_NAME_LHS (construct_n, lhs, "=", "new", name_lit_idx, "(", arg_list, ")") CASE_VARG_N_NAME_LHS (construct_n, lhs, "=", "new", name_lit_idx, arg_list)
CASE_VARG_0_NAME (func_decl_0, "function", name_lit_idx, "(", ")") CASE_VARG_0_NAME (func_decl_0, "function", name_lit_idx, "(", ")")
CASE_VARG_1_NAME (func_decl_1, "function", name_lit_idx, "(", arg1_lit_idx, ")") CASE_VARG_1_NAME (func_decl_1, "function", name_lit_idx, "(", arg1_lit_idx, ")")
CASE_VARG_2_NAME (func_decl_2, "function", name_lit_idx, "(", arg1_lit_idx, arg2_lit_idx, ")") CASE_VARG_2_NAME (func_decl_2, "function", name_lit_idx, "(", arg1_lit_idx, arg2_lit_idx, ")")
CASE_VARG_N_NAME (func_decl_n, "function", name_lit_idx, "(", arg1_lit_idx, arg2_lit_idx, ")") CASE_VARG_N_NAME (func_decl_n, "function", name_lit_idx, arg_list)
CASE_VARG_3 (varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx); CASE_VARG_3 (varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx);
CASE_EXIT (exitval, "exit", status_code) CASE_EXIT (exitval, "exit", status_code)
CASE_SINGLE_ADDRESS (retval, "return", ret_value) CASE_SINGLE_ADDRESS (retval, "return", ret_value)