Jacek Caban : jscript: Use bytecode for unary '+' expression.
Alexandre Julliard
julliard at winehq.org
Mon Nov 21 11:10:15 CST 2011
Module: wine
Branch: master
Commit: 35b9c42f530a9a338eaae928c96bd12c7a3514aa
URL: http://source.winehq.org/git/wine.git/?a=commit;h=35b9c42f530a9a338eaae928c96bd12c7a3514aa
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Nov 21 15:35:41 2011 +0100
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 8431b5c..1bc887c 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 17d8fa6..1f5863a 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);
- 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);
+ v = stack_pop(ctx);
+ hres = to_number(ctx->parser->script, v, &ctx->ei, &num);
+ VariantClear(v);
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 8692b0a..c004af3 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 d580ec0..92c79fc 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,
More information about the wine-cvs
mailing list