Commit f904bc8e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Always use bytecode for for statement.

parent 2c0920f8
......@@ -1084,11 +1084,9 @@ static HRESULT compile_while_statement(compiler_ctx_t *ctx, while_statement_t *s
static HRESULT compile_for_statement(compiler_ctx_t *ctx, for_statement_t *stat)
{
statement_ctx_t stat_ctx = {0, FALSE, FALSE};
unsigned off_backup, expr_off;
unsigned expr_off;
HRESULT hres;
off_backup = ctx->code_off;
if(stat->variable_list) {
hres = compile_variable_list(ctx, stat->variable_list);
if(FAILED(hres))
......@@ -1131,11 +1129,6 @@ static HRESULT compile_for_statement(compiler_ctx_t *ctx, for_statement_t *stat)
return E_OUTOFMEMORY;
hres = compile_statement(ctx, &stat_ctx, stat->statement);
if(hres == E_NOTIMPL) {
ctx->code_off = off_backup;
stat->stat.eval = for_statement_eval;
return compile_interp_fallback(ctx, &stat->stat);
}
if(FAILED(hres))
return hres;
......
......@@ -657,31 +657,6 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, DWORD flags,
}
/* ECMA-262 3rd Edition 12.2 */
static HRESULT variable_list_eval(script_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
{
variable_declaration_t *iter;
HRESULT hres = S_OK;
for(iter = var_list; iter; iter = iter->next) {
VARIANT val;
if(!iter->expr)
continue;
hres = expr_eval(ctx, iter->expr, ei, &val);
if(FAILED(hres))
break;
hres = jsdisp_propput_name(ctx->exec_ctx->var_disp, iter->identifier, &val, ei, NULL/*FIXME*/);
VariantClear(&val);
if(FAILED(hres))
break;
}
return hres;
}
/* ECMA-262 3rd Edition 12.2 */
static HRESULT interp_var_set(exec_ctx_t *ctx)
{
const BSTR name = ctx->parser->code->instrs[ctx->ip].arg1.bstr;
......@@ -749,75 +724,6 @@ HRESULT while_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_
return S_OK;
}
/* ECMA-262 3rd Edition 12.6.3 */
HRESULT for_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
{
for_statement_t *stat = (for_statement_t*)_stat;
VARIANT val, tmp, retv;
VARIANT_BOOL b;
HRESULT hres;
TRACE("\n");
if(stat->variable_list) {
hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
if(FAILED(hres))
return hres;
}else if(stat->begin_expr) {
hres = expr_eval(ctx, stat->begin_expr, &rt->ei, &val);
if(FAILED(hres))
return hres;
VariantClear(&val);
}
V_VT(&retv) = VT_EMPTY;
while(1) {
if(stat->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;
}
hres = stat_eval(ctx, stat->statement, rt, &tmp);
if(FAILED(hres))
break;
VariantClear(&retv);
retv = tmp;
if(rt->type == RT_CONTINUE)
rt->type = RT_NORMAL;
else if(rt->type != RT_NORMAL)
break;
if(stat->end_expr) {
hres = expr_eval(ctx, stat->end_expr, &rt->ei, &val);
if(FAILED(hres))
break;
VariantClear(&val);
}
}
if(FAILED(hres)) {
VariantClear(&retv);
return hres;
}
if(rt->type == RT_BREAK)
rt->type = RT_NORMAL;
*ret = retv;
return S_OK;
}
/* ECMA-262 3rd Edition 12.6.4 */
static HRESULT interp_forin(exec_ctx_t *ctx)
{
......
......@@ -414,7 +414,6 @@ typedef struct {
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 for_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