Jacek Caban : jscript: Always use bytecode for while statement.

Alexandre Julliard julliard at winehq.org
Thu Dec 29 12:15:45 CST 2011


Module: wine
Branch: master
Commit: 2dcb8d412f41283d9f7b83a8d1bb55868bda31da
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2dcb8d412f41283d9f7b83a8d1bb55868bda31da

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Dec 29 11:07:49 2011 +0100

jscript: Always use bytecode for while statement.

---

 dlls/jscript/compile.c |    9 +------
 dlls/jscript/engine.c  |   60 +-----------------------------------------------
 dlls/jscript/engine.h  |    1 -
 3 files changed, 2 insertions(+), 68 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 636cdff..127d967 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -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;
 
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 62fdf23..781814a 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -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;
 
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 424000e..4ac5e6a 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -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;




More information about the wine-cvs mailing list