Fix parsing of for-loops.

This commit is contained in:
Ilmir Usmanov
2014-07-23 20:47:31 +04:00
parent 2ff5d14b06
commit 764efa41b8
8 changed files with 35 additions and 98 deletions
-41
View File
@@ -371,47 +371,6 @@ OP_CODE_DECL_VOID (ret)
OP_CODE_DECL_VOID (nop)
// LOOPS
// Lately, all loops should be translated into different JMPs in an optimizer.
/** End of body of infinite loop should be ended with unconditional JMP
* to loop_root (ie. next op after loop condition) */
OP_CODE_DECL (loop_inf, T_IDX,
loop_root)
/** Numeric loop initialization.
* for (start,stop,step)
*/
OP_CODE_DECL (loop_init_num, T_IDX_IDX_IDX,
start,
stop,
step)
/** Check loop (condition).
* if (loop cond is true)
* { next_op }
* else
* { goto after_loop_op; }
*/
OP_CODE_DECL (loop_precond_begin_num, T_IDX_IDX,
condition,
after_loop_op)
/** i++;
* Increment iterator on step and JMP to PRECOND
*/
OP_CODE_DECL (loop_precond_end_num, T_IDX_IDX_IDX,
iterator,
step,
precond_begin)
/** do {...} while (cond);
* If condition is true, JMP to BODY_ROOT
*/
OP_CODE_DECL (loop_postcond, T_IDX_IDX,
condition,
body_root)
/** a = [] */
OP_CODE_DECL (array_0, T_IDX,
lhs)
-25
View File
@@ -318,10 +318,6 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
#define OP_UNIMPLEMENTED_LIST(op) \
op(is_true_jmp) \
op(is_false_jmp) \
op(loop_init_num) \
op(loop_precond_begin_num) \
op(loop_precond_end_num) \
op(loop_postcond) \
op(call_0) \
op(call_n) \
op(func_decl_1) \
@@ -388,22 +384,6 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
OP_UNIMPLEMENTED_LIST(DEFINE_UNIMPLEMENTED_OP)
#undef DEFINE_UNIMPLEMENTED_OP
ecma_completion_value_t
opfunc_loop_inf (OPCODE opdata, struct __int_data *int_data)
{
#ifdef __HOST
__printf ("%d::loop_inf:idx:%d\n",
int_data->pos,
opdata.data.loop_inf.loop_root);
#endif
int_data->pos = opdata.data.loop_inf.loop_root;
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value( ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
}
ecma_completion_value_t
opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
{
@@ -836,11 +816,6 @@ GETOP_IMPL_1 (exitval, status_code)
GETOP_IMPL_1 (retval, ret_value)
GETOP_IMPL_0 (ret)
GETOP_IMPL_0 (nop)
GETOP_IMPL_1 (loop_inf, loop_root)
GETOP_IMPL_3 (loop_init_num, start, stop, step)
GETOP_IMPL_2 (loop_precond_begin_num, condition, after_loop_op)
GETOP_IMPL_3 (loop_precond_end_num, iterator, step, precond_begin)
GETOP_IMPL_2 (loop_postcond, condition, body_root)
GETOP_IMPL_1 (var_decl, variable_name)
GETOP_IMPL_2 (b_not, dst, var_right)
GETOP_IMPL_2 (logical_not, dst, var_right)
-8
View File
@@ -35,13 +35,6 @@ struct __int_data;
OPCODE;
typedef ecma_completion_value_t (*opfunc)(OPCODE, struct __int_data *);
#define OP_LOOPS(op) \
op(loop_inf) \
op(loop_init_num) \
op(loop_precond_begin_num) \
op(loop_precond_end_num) \
op(loop_postcond)
#define OP_CALLS_AND_ARGS(op) \
op(call_0) \
op(call_1) \
@@ -134,7 +127,6 @@ typedef ecma_completion_value_t (*opfunc)(OPCODE, struct __int_data *);
op(is_false_jmp)
#define OP_LIST(op) \
OP_LOOPS(op) \
OP_CALLS_AND_ARGS(op) \
OP_INITS(op) \
OP_ASSIGNMENTS(op) \