Jacek Caban : jscript: Use bytecode for binary or implementation.

Alexandre Julliard julliard at winehq.org
Tue Nov 29 14:20:38 CST 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Nov 29 11:09:35 2011 +0100

jscript: Use bytecode for binary or implementation.

---

 dlls/jscript/compile.c |    2 ++
 dlls/jscript/engine.c  |   29 ++++++++++++++++++++++++++---
 dlls/jscript/engine.h  |    2 +-
 dlls/jscript/parser.y  |    2 +-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 4793fa3..7520756 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -346,6 +346,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
     case EXPR_BITNEG:
         return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
+    case EXPR_BOR:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or);
     case EXPR_COMMA:
         return compile_comma_expression(ctx, (binary_expression_t*)expr);
     case EXPR_COND:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 1cdc4d0..16a3a06 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -94,6 +94,15 @@ static inline HRESULT stack_push_number(exec_ctx_t *ctx, double number)
     return stack_push(ctx, &v);
 }
 
+static inline HRESULT stack_push_int(exec_ctx_t *ctx, INT n)
+{
+    VARIANT v;
+
+    V_VT(&v) = VT_I4;
+    V_I4(&v) = n;
+    return stack_push(ctx, &v);
+}
+
 static inline VARIANT *stack_top(exec_ctx_t *ctx)
 {
     assert(ctx->top);
@@ -129,6 +138,11 @@ static HRESULT stack_pop_number(exec_ctx_t *ctx, VARIANT *r)
     return hres;
 }
 
+static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r)
+{
+    return to_int32(ctx->parser->script, stack_pop(ctx), &ctx->ei, r);
+}
+
 static void exprval_release(exprval_t *val)
 {
     switch(val->type) {
@@ -2009,13 +2023,22 @@ static HRESULT bitor_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexc
 }
 
 /* ECMA-262 3rd Edition    11.10 */
-HRESULT binary_or_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+static HRESULT interp_or(exec_ctx_t *ctx)
 {
-    binary_expression_t *expr = (binary_expression_t*)_expr;
+    INT l, r;
+    HRESULT hres;
 
     TRACE("\n");
 
-    return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
+    hres = stack_pop_int(ctx, &r);
+    if(FAILED(hres))
+        return hres;
+
+    hres = stack_pop_int(ctx, &l);
+    if(FAILED(hres))
+        return hres;
+
+    return stack_push_int(ctx, l|r);
 }
 
 /* ECMA-262 3rd Edition    11.10 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 5ef2002..6ac6d23 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -63,6 +63,7 @@ typedef struct _func_stack {
     X(neq2,       1, 0,0)                  \
     X(new,        1, ARG_INT,    0)        \
     X(null,       1, 0,0)                  \
+    X(or,         1, 0,0)                  \
     X(pop,        1, 0,0)                  \
     X(regexp,     1, ARG_STR,    ARG_INT)  \
     X(str,        1, ARG_STR,    0)        \
@@ -554,7 +555,6 @@ HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*
 HRESULT array_literal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 
-HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT instanceof_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 36f8f19..fecde80 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1308,7 +1308,7 @@ static const expression_eval_t expression_eval_table[] = {
    compiled_expression_eval,
    compiled_expression_eval,
    compiled_expression_eval,
-   binary_or_expression_eval,
+   compiled_expression_eval,
    binary_xor_expression_eval,
    binary_and_expression_eval,
    instanceof_expression_eval,




More information about the wine-cvs mailing list