Jacek Caban : jscript: Use bytecode for modulo expression implementation.

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


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

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

jscript: Use bytecode for modulo expression implementation.

---

 dlls/jscript/compile.c |    2 ++
 dlls/jscript/engine.c  |   15 ++++++++++++---
 dlls/jscript/engine.h  |    3 +--
 dlls/jscript/parser.y  |    2 +-
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 8608bbe..4793fa3 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -366,6 +366,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_MOD:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod);
     case EXPR_MUL:
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mul);
     case EXPR_NEW:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 97f19b5..1cdc4d0 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -2397,13 +2397,22 @@ static HRESULT mod_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcep
 }
 
 /* ECMA-262 3rd Edition    11.5.3 */
-HRESULT mod_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+static HRESULT interp_mod(exec_ctx_t *ctx)
 {
-    binary_expression_t *expr = (binary_expression_t*)_expr;
+    VARIANT l, r;
+    HRESULT hres;
 
     TRACE("\n");
 
-    return binary_expr_eval(ctx, expr, mod_eval, ei, ret);
+    hres = stack_pop_number(ctx, &r);
+    if(FAILED(hres))
+        return hres;
+
+    hres = stack_pop_number(ctx, &l);
+    if(FAILED(hres))
+        return hres;
+
+    return stack_push_number(ctx, fmod(num_val(&l), num_val(&r)));
 }
 
 /* ECMA-262 3rd Edition    11.4.2 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index f481a69..5ef2002 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -56,6 +56,7 @@ typedef struct _func_stack {
     X(jmp_nz,     0, ARG_ADDR,   0)        \
     X(jmp_z,      0, ARG_ADDR,   0)        \
     X(minus,      1, 0,0)                  \
+    X(mod,        1, 0,0)                  \
     X(mul,        1, 0,0)                  \
     X(neg,        1, 0,0)                  \
     X(neq,        1, 0,0)                  \
@@ -557,10 +558,8 @@ HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,
 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;
-HRESULT mod_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT delete_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT typeof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT minus_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 HRESULT post_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
 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;
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index 79ecb12..36f8f19 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1317,7 +1317,7 @@ static const expression_eval_t expression_eval_table[] = {
    compiled_expression_eval,
    compiled_expression_eval,
    compiled_expression_eval,
-   mod_expression_eval,
+   compiled_expression_eval,
    delete_expression_eval,
    compiled_expression_eval,
    typeof_expression_eval,




More information about the wine-cvs mailing list