From 58952a07d045cecacd12f222da0be49f8748528b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 25 Nov 2011 12:07:30 +0100 Subject: [PATCH] jscript: Use bytecode for '==' and '!=' expression. --- dlls/jscript/compile.c | 4 +++ dlls/jscript/engine.c | 60 ++++++++++++++++++++---------------------- dlls/jscript/engine.h | 4 +-- dlls/jscript/parser.y | 4 +-- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 17c949be18d..65d68610664 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 c4889f5ded7..9e26e934539 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2842,26 +2842,45 @@ 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); + 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; - hres = equal_values(ctx, &rval, &lval, ei, &b); - VariantClear(&lval); - VariantClear(&rval); + return stack_push_bool(ctx, b); +} + +/* ECMA-262 3rd Edition 11.9.2 */ +HRESULT interp_neq(exec_ctx_t *ctx) +{ + VARIANT *l, *r; + BOOL b; + HRESULT hres; + + r = stack_pop(ctx); + l = stack_pop(ctx); + + 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 return_bool(ret, b); + return stack_push_bool(ctx, !b); } /* ECMA-262 3rd Edition 11.9.4 */ @@ -2885,29 +2904,6 @@ static HRESULT interp_eq2(exec_ctx_t *ctx) 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) -{ - binary_expression_t *expr = (binary_expression_t*)_expr; - VARIANT rval, lval; - BOOL b; - HRESULT hres; - - TRACE("\n"); - - hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval); - if(FAILED(hres)) - return hres; - - hres = equal_values(ctx, &lval, &rval, ei, &b); - VariantClear(&lval); - VariantClear(&rval); - if(FAILED(hres)) - return hres; - - return return_bool(ret, !b); -} - /* ECMA-262 3rd Edition 11.9.5 */ static HRESULT interp_neq2(exec_ctx_t *ctx) { diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index dd319094d99..d74d57c426f 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 3e7f0fe2083..3c953ebe3a4 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,