Jacek Caban : jscript: Use bytecode for '==' and '!=' expression.

Alexandre Julliard julliard at winehq.org
Fri Nov 25 10:27:32 CST 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Nov 25 12:07:30 2011 +0100

jscript: Use bytecode for '==' and '!=' expression.

---

 dlls/jscript/compile.c |    4 +++
 dlls/jscript/engine.c  |   52 ++++++++++++++++++++++-------------------------
 dlls/jscript/engine.h  |    4 +-
 dlls/jscript/parser.y  |    4 +-
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 17c949b..65d6861 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -228,6 +228,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
         return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
     case EXPR_COMMA:
         return compile_comma_expression(ctx, (binary_expression_t*)expr);
+    case EXPR_EQ:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq);
     case EXPR_EQEQ:
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
     case EXPR_IN:
@@ -238,6 +240,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
         return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
     case EXPR_MINUS:
         return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_minus);
+    case EXPR_NOTEQ:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq);
     case EXPR_NOTEQEQ:
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2);
     case EXPR_PLUS:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index c4889f5..9e26e93 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -2842,70 +2842,66 @@ static HRESULT equal_values(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jse
 }
 
 /* ECMA-262 3rd Edition    11.9.1 */
-HRESULT equal_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+HRESULT interp_eq(exec_ctx_t *ctx)
 {
-    binary_expression_t *expr = (binary_expression_t*)_expr;
-    VARIANT rval, lval;
+    VARIANT *l, *r;
     BOOL b;
     HRESULT hres;
 
-    TRACE("\n");
+    r = stack_pop(ctx);
+    l = stack_pop(ctx);
 
-    hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
-    if(FAILED(hres))
-        return hres;
+    TRACE("%s == %s\n", debugstr_variant(l), debugstr_variant(r));
 
-    hres = equal_values(ctx, &rval, &lval, ei, &b);
-    VariantClear(&lval);
-    VariantClear(&rval);
+    hres = equal_values(ctx->parser->script, l, r, &ctx->ei, &b);
+    VariantClear(l);
+    VariantClear(r);
     if(FAILED(hres))
         return hres;
 
-    return return_bool(ret, b);
+    return stack_push_bool(ctx, b);
 }
 
-/* ECMA-262 3rd Edition    11.9.4 */
-static HRESULT interp_eq2(exec_ctx_t *ctx)
+/* ECMA-262 3rd Edition    11.9.2 */
+HRESULT interp_neq(exec_ctx_t *ctx)
 {
     VARIANT *l, *r;
     BOOL b;
     HRESULT hres;
 
-    TRACE("\n");
-
     r = stack_pop(ctx);
     l = stack_pop(ctx);
 
-    hres = equal2_values(r, l, &b);
+    TRACE("%s != %s\n", debugstr_variant(l), debugstr_variant(r));
+
+    hres = equal_values(ctx->parser->script, l, r, &ctx->ei, &b);
     VariantClear(l);
     VariantClear(r);
     if(FAILED(hres))
         return hres;
 
-    return stack_push_bool(ctx, b);
+    return stack_push_bool(ctx, !b);
 }
 
-/* ECMA-262 3rd Edition    11.9.2 */
-HRESULT not_equal_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+/* ECMA-262 3rd Edition    11.9.4 */
+static HRESULT interp_eq2(exec_ctx_t *ctx)
 {
-    binary_expression_t *expr = (binary_expression_t*)_expr;
-    VARIANT rval, lval;
+    VARIANT *l, *r;
     BOOL b;
     HRESULT hres;
 
     TRACE("\n");
 
-    hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
-    if(FAILED(hres))
-        return hres;
+    r = stack_pop(ctx);
+    l = stack_pop(ctx);
 
-    hres = equal_values(ctx, &lval, &rval, ei, &b);
-    VariantClear(&lval);
-    VariantClear(&rval);
+    hres = equal2_values(r, l, &b);
+    VariantClear(l);
+    VariantClear(r);
     if(FAILED(hres))
         return hres;
 
-    return return_bool(ret, !b);
+    return stack_push_bool(ctx, b);
 }
 
 /* ECMA-262 3rd Edition    11.9.5 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index dd31909..d74d57c 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -46,11 +46,13 @@ typedef struct _func_stack {
     X(bool,       1, ARG_INT,    0)        \
     X(bneg,       1, 0,0)                  \
     X(double,     1, ARG_SBL,    0)        \
+    X(eq,         1, 0,0)                  \
     X(eq2,        1, 0,0)                  \
     X(in,         1, 0,0)                  \
     X(int,        1, ARG_INT,    0)        \
     X(minus,      1, 0,0)                  \
     X(neg,        1, 0,0)                  \
+    X(neq,        1, 0,0)                  \
     X(neq2,       1, 0,0)                  \
     X(null,       1, 0,0)                  \
     X(pop,        1, 0,0)                  \
@@ -553,8 +555,6 @@ HRESULT post_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcep
 HRESULT post_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT pre_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT pre_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT not_equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT less_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT lesseq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT greater_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index 3e7f0fe..3c953eb 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1327,9 +1327,9 @@ static const expression_eval_t expression_eval_table[] = {
    post_decrement_expression_eval,
    pre_increment_expression_eval,
    pre_decrement_expression_eval,
-   equal_expression_eval,
    compiled_expression_eval,
-   not_equal_expression_eval,
+   compiled_expression_eval,
+   compiled_expression_eval,
    compiled_expression_eval,
    less_expression_eval,
    lesseq_expression_eval,




More information about the wine-cvs mailing list