Add 'reg_var_decl' opcode
This commit is contained in:
@@ -460,8 +460,11 @@ OP_CODE_DECL_VOID (end_with)
|
||||
// Variable declaration
|
||||
OP_CODE_DECL (var_decl, T_IDX,
|
||||
variable_name)
|
||||
|
||||
OP_CODE_DECL (reg_var_decl, T_IDX_IDX,
|
||||
min,
|
||||
max)
|
||||
|
||||
// TODO New constructor
|
||||
|
||||
#endif /* OPCODE_STRUCTURES_H */
|
||||
|
||||
|
||||
@@ -371,7 +371,8 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
|
||||
op(logical_not) \
|
||||
op(b_not) \
|
||||
op(instanceof) \
|
||||
op(in)
|
||||
op(in) \
|
||||
op(reg_var_decl)
|
||||
|
||||
#define DEFINE_UNIMPLEMENTED_OP(op) \
|
||||
ecma_completion_value_t opfunc_ ## op(OPCODE opdata, struct __int_data *int_data) { \
|
||||
@@ -942,4 +943,5 @@ GETOP_IMPL_2 (delete, lhs, obj)
|
||||
GETOP_IMPL_2 (typeof, lhs, obj)
|
||||
GETOP_IMPL_1 (with, expr)
|
||||
GETOP_IMPL_0 (end_with)
|
||||
GETOP_IMPL_2 (reg_var_decl, min, max)
|
||||
|
||||
|
||||
@@ -138,7 +138,8 @@ typedef ecma_completion_value_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
OP_ARITHMETIC(op) \
|
||||
OP_UNCONDITIONAL_JUMPS(op) \
|
||||
OP_UNARY_OPS(op) \
|
||||
op(var_decl)
|
||||
op(var_decl) \
|
||||
op(reg_var_decl)
|
||||
|
||||
#include "opcode-structures.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
static token tok;
|
||||
static OPCODE opcode, opcodes_buffer[MAX_OPCODES];
|
||||
static uint8_t current_opcode_in_buffer = 0;
|
||||
static uint8_t opcode_counter = 0;
|
||||
static uint8_t opcode_counter = 0, sub_assignment_exprs = 0;
|
||||
|
||||
#ifdef __HOST
|
||||
_FILE *debug_file;
|
||||
@@ -1175,16 +1175,22 @@ parse_conditional_expression (bool *was_conditional)
|
||||
static T_IDX
|
||||
parse_assignment_expression (void)
|
||||
{
|
||||
T_IDX lhs, rhs;
|
||||
T_IDX lhs, rhs, reg_var_decl_loc;
|
||||
bool was_conditional = false;
|
||||
|
||||
reset_temp_name ();
|
||||
if (!sub_assignment_exprs)
|
||||
{
|
||||
reset_temp_name ();
|
||||
reg_var_decl_loc = opcode_counter;
|
||||
DUMP_OPCODE (reg_var_decl, min_temp_name, INVALID_VALUE);
|
||||
}
|
||||
|
||||
sub_assignment_exprs++;
|
||||
|
||||
lhs = parse_conditional_expression (&was_conditional);
|
||||
if (was_conditional)
|
||||
{
|
||||
dump_saved_opcodes ();
|
||||
return lhs;
|
||||
goto end;
|
||||
}
|
||||
|
||||
skip_newlines ();
|
||||
@@ -1254,7 +1260,14 @@ parse_assignment_expression (void)
|
||||
lexer_save_token (tok);
|
||||
}
|
||||
|
||||
dump_saved_opcodes ();
|
||||
end:
|
||||
|
||||
sub_assignment_exprs--;
|
||||
if (!sub_assignment_exprs)
|
||||
{
|
||||
REWRITE_OPCODE (reg_var_decl_loc, reg_var_decl, min_temp_name, (uint8_t) (temp_name - 1));
|
||||
dump_saved_opcodes ();
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user