Commit 2dcb8d41 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Always use bytecode for while statement.

parent c6932d80
......@@ -1015,11 +1015,9 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
static HRESULT compile_while_statement(compiler_ctx_t *ctx, while_statement_t *stat)
{
statement_ctx_t stat_ctx = {0, FALSE, FALSE};
unsigned off_backup, jmp_off;
unsigned jmp_off;
HRESULT hres;
off_backup = ctx->code_off;
stat_ctx.break_label = alloc_label(ctx);
if(stat_ctx.break_label == -1)
return E_OUTOFMEMORY;
......@@ -1050,11 +1048,6 @@ static HRESULT compile_while_statement(compiler_ctx_t *ctx, while_statement_t *s
}
hres = compile_statement(ctx, &stat_ctx, stat->statement);
if(hres == E_NOTIMPL) {
ctx->code_off = off_backup;
stat->stat.eval = while_statement_eval;
return compile_interp_fallback(ctx, &stat->stat);
}
if(FAILED(hres))
return hres;
......
......@@ -56,11 +56,6 @@ struct _except_frame_t {
except_frame_t *next;
};
static inline HRESULT stat_eval(script_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
return stat->eval(ctx, stat, rt, ret);
}
static HRESULT expr_eval(script_ctx_t*,expression_t*,jsexcept_t*,VARIANT*);
static HRESULT stack_push(exec_ctx_t *ctx, VARIANT *v)
......@@ -671,59 +666,6 @@ static HRESULT interp_var_set(exec_ctx_t *ctx)
return hres;
}
/* ECMA-262 3rd Edition 12.6.2 */
HRESULT while_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
{
while_statement_t *stat = (while_statement_t*)_stat;
VARIANT val, tmp;
VARIANT_BOOL b;
BOOL test_expr;
HRESULT hres;
TRACE("\n");
V_VT(&val) = VT_EMPTY;
test_expr = !stat->do_while;
while(1) {
if(test_expr) {
hres = expr_eval(ctx, stat->expr, &rt->ei, &tmp);
if(FAILED(hres))
break;
hres = to_boolean(&tmp, &b);
VariantClear(&tmp);
if(FAILED(hres) || !b)
break;
}else {
test_expr = TRUE;
}
hres = stat_eval(ctx, stat->statement, rt, &tmp);
if(FAILED(hres))
break;
VariantClear(&val);
val = tmp;
if(rt->type == RT_CONTINUE)
rt->type = RT_NORMAL;
if(rt->type != RT_NORMAL)
break;
}
if(FAILED(hres)) {
VariantClear(&val);
return hres;
}
if(rt->type == RT_BREAK)
rt->type = RT_NORMAL;
*ret = val;
return S_OK;
}
/* ECMA-262 3rd Edition 12.6.4 */
static HRESULT interp_forin(exec_ctx_t *ctx)
{
......@@ -2649,7 +2591,7 @@ static HRESULT interp_tree(exec_ctx_t *ctx)
TRACE("\n");
hres = stat_eval(ctx->parser->script, instr->arg1.stat, ctx->rt, &v);
hres = instr->arg1.stat->eval(ctx->parser->script, instr->arg1.stat, ctx->rt, &v);
if(FAILED(hres))
return hres;
......
......@@ -413,7 +413,6 @@ typedef struct {
} try_statement_t;
HRESULT compiled_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT while_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT continue_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment