From 413fe9a46200f9477d1b6bf2ba7a55b4f76b0760 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 25 Nov 2011 12:06:30 +0100 Subject: [PATCH] jscript: Use bytecode for unary '-' expression. --- dlls/jscript/compile.c | 2 ++ dlls/jscript/engine.c | 22 ++++------------------ dlls/jscript/engine.h | 1 + dlls/jscript/parser.y | 2 +- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 12dd04f20cf..17c949be18d 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -236,6 +236,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr) return compile_literal(ctx, ((literal_expression_t*)expr)->literal); case EXPR_LOGNEG: 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_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 a0043265756..c4889f5ded7 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2574,32 +2574,18 @@ HRESULT typeof_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla } /* ECMA-262 3rd Edition 11.4.7 */ -HRESULT minus_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +HRESULT interp_minus(exec_ctx_t *ctx) { - unary_expression_t *expr = (unary_expression_t*)_expr; - exprval_t exprval; - VARIANT val, num; + VARIANT n; HRESULT hres; TRACE("\n"); - hres = expr_eval(ctx, expr->expression, 0, ei, &exprval); + hres = stack_pop_number(ctx, &n); if(FAILED(hres)) return hres; - hres = exprval_to_value(ctx, &exprval, ei, &val); - exprval_release(&exprval); - if(FAILED(hres)) - return hres; - - hres = to_number(ctx, &val, ei, &num); - VariantClear(&val); - if(FAILED(hres)) - return hres; - - ret->type = EXPRVAL_VARIANT; - num_set_val(&ret->u.var, -num_val(&num)); - return S_OK; + return stack_push_number(ctx, -num_val(&n)); } /* ECMA-262 3rd Edition 11.4.6 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 736fe5ac058..dd319094d99 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -49,6 +49,7 @@ typedef struct _func_stack { 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(neq2, 1, 0,0) \ X(null, 1, 0,0) \ diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 2e8c0d8759c..3e7f0fe2083 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1321,7 +1321,7 @@ static const expression_eval_t expression_eval_table[] = { delete_expression_eval, compiled_expression_eval, typeof_expression_eval, - minus_expression_eval, + compiled_expression_eval, compiled_expression_eval, post_increment_expression_eval, post_decrement_expression_eval,