diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index a529fe718dc..8608bbe5489 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -350,6 +350,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr) return compile_comma_expression(ctx, (binary_expression_t*)expr); case EXPR_COND: return compile_conditional_expression(ctx, (conditional_expression_t*)expr); + case EXPR_DIV: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_div); case EXPR_EQ: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq); case EXPR_EQEQ: diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 5e60381ed2f..97f19b5b386 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2360,13 +2360,22 @@ static HRESULT div_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcep } /* ECMA-262 3rd Edition 11.5.2 */ -HRESULT div_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +static HRESULT interp_div(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, div_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, num_val(&l)/num_val(&r)); } /* ECMA-262 3rd Edition 11.5.3 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 120bf42a230..f481a697a8f 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -45,6 +45,7 @@ typedef struct _func_stack { X(add, 1, 0,0) \ X(bool, 1, ARG_INT, 0) \ X(bneg, 1, 0,0) \ + X(div, 1, 0,0) \ X(double, 1, ARG_SBL, 0) \ X(eq, 1, 0,0) \ X(eq2, 1, 0,0) \ @@ -556,7 +557,6 @@ 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 div_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; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 9b72d7fda9f..79ecb125542 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1316,7 +1316,7 @@ static const expression_eval_t expression_eval_table[] = { compiled_expression_eval, compiled_expression_eval, compiled_expression_eval, - div_expression_eval, + compiled_expression_eval, mod_expression_eval, delete_expression_eval, compiled_expression_eval,