From b1b0aadaab522d8ca97c31e3ac4483d65d167594 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 22 Nov 2011 16:31:44 +0100 Subject: [PATCH] jscript: Use bytecode for '+' expression implementation. --- dlls/jscript/compile.c | 2 ++ dlls/jscript/engine.c | 16 ++++++++++++---- dlls/jscript/engine.h | 2 +- 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 1bc887ca85d..1e496a86860 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -107,6 +107,8 @@ static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr) static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr) { switch(expr->type) { + case EXPR_ADD: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add); case EXPR_BITNEG: return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg); case EXPR_EQEQ: diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 1f5863a9a02..cbfde6dd184 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2213,13 +2213,21 @@ static HRESULT add_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcep } /* ECMA-262 3rd Edition 11.6.1 */ -HRESULT add_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +HRESULT interp_add(exec_ctx_t *ctx) { - binary_expression_t *expr = (binary_expression_t*)_expr; + VARIANT *l, *r, ret; + HRESULT hres; - TRACE("\n"); + r = stack_pop(ctx); + l = stack_pop(ctx); - return binary_expr_eval(ctx, expr, add_eval, ei, ret); + TRACE("%s + %s\n", debugstr_variant(l), debugstr_variant(r)); + + hres = add_eval(ctx->parser->script, l, r, &ctx->ei, &ret); + if(FAILED(hres)) + return hres; + + return stack_push(ctx, &ret); } /* ECMA-262 3rd Edition 11.6.2 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index c004af3097b..829274d5c63 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -42,6 +42,7 @@ typedef struct _func_stack { } func_stack_t; #define OP_LIST \ + X(add, 1, 0) \ X(bneg, 1, 0) \ X(eq2, 1, 0) \ X(neg, 1, 0) \ @@ -529,7 +530,6 @@ HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t* 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 in_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; -HRESULT add_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; HRESULT sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; HRESULT mul_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; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 92c79fcc2bd..98813b45527 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1313,7 +1313,7 @@ static const expression_eval_t expression_eval_table[] = { binary_and_expression_eval, instanceof_expression_eval, in_expression_eval, - add_expression_eval, + compiled_expression_eval, sub_expression_eval, mul_expression_eval, div_expression_eval,