From 35b9c42f530a9a338eaae928c96bd12c7a3514aa Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 21 Nov 2011 15:35:41 +0100 Subject: [PATCH] jscript: Use bytecode for unary '+' expression. --- dlls/jscript/compile.c | 2 ++ dlls/jscript/engine.c | 24 ++++++------------------ dlls/jscript/engine.h | 2 +- dlls/jscript/parser.y | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 8431b5cf7d5..1bc887ca85d 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -115,6 +115,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_NOTEQEQ: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2); + case EXPR_PLUS: + return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_tonum); default: assert(expr->eval != compiled_expression_eval); return compile_interp_fallback(ctx, expr); diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 17d8fa66bde..1f5863a9a02 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2532,32 +2532,20 @@ HRESULT minus_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flag } /* ECMA-262 3rd Edition 11.4.6 */ -HRESULT plus_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +HRESULT interp_tonum(exec_ctx_t *ctx) { - unary_expression_t *expr = (unary_expression_t*)_expr; - exprval_t exprval; - VARIANT val, num; + VARIANT *v, num; HRESULT hres; TRACE("\n"); - hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval); + v = stack_pop(ctx); + hres = to_number(ctx->parser->script, v, &ctx->ei, &num); + VariantClear(v); 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; - ret->u.var = num; - return S_OK; + return stack_push(ctx, &num); } /* ECMA-262 3rd Edition 11.3.1 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 8692b0ae567..c004af3097b 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -46,6 +46,7 @@ typedef struct _func_stack { X(eq2, 1, 0) \ X(neg, 1, 0) \ X(neq2, 1, 0) \ + X(tonum, 1, 0) \ X(tree, 1, ARG_EXPR) \ X(ret, 0, 0) @@ -537,7 +538,6 @@ HRESULT delete_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exp HRESULT void_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 plus_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 d580ec0f0ca..92c79fcc2bd 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1322,7 +1322,7 @@ static const expression_eval_t expression_eval_table[] = { void_expression_eval, typeof_expression_eval, minus_expression_eval, - plus_expression_eval, + compiled_expression_eval, post_increment_expression_eval, post_decrement_expression_eval, pre_increment_expression_eval,