jscript: Use bytecode for unary '+' expression.

This commit is contained in:
Jacek Caban 2011-11-21 15:35:41 +01:00 committed by Alexandre Julliard
parent 2d83bdcfbe
commit 35b9c42f53
4 changed files with 10 additions and 20 deletions

View File

@ -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); return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_NOTEQEQ: case EXPR_NOTEQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2); 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: default:
assert(expr->eval != compiled_expression_eval); assert(expr->eval != compiled_expression_eval);
return compile_interp_fallback(ctx, expr); return compile_interp_fallback(ctx, expr);

View File

@ -2532,32 +2532,20 @@ HRESULT minus_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flag
} }
/* ECMA-262 3rd Edition 11.4.6 */ /* 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; VARIANT *v, num;
exprval_t exprval;
VARIANT val, num;
HRESULT hres; HRESULT hres;
TRACE("\n"); 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)) if(FAILED(hres))
return hres; return hres;
hres = exprval_to_value(ctx, &exprval, ei, &val); return stack_push(ctx, &num);
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;
} }
/* ECMA-262 3rd Edition 11.3.1 */ /* ECMA-262 3rd Edition 11.3.1 */

View File

@ -46,6 +46,7 @@ typedef struct _func_stack {
X(eq2, 1, 0) \ X(eq2, 1, 0) \
X(neg, 1, 0) \ X(neg, 1, 0) \
X(neq2, 1, 0) \ X(neq2, 1, 0) \
X(tonum, 1, 0) \
X(tree, 1, ARG_EXPR) \ X(tree, 1, ARG_EXPR) \
X(ret, 0, 0) 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 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 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 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_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 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_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;

View File

@ -1322,7 +1322,7 @@ static const expression_eval_t expression_eval_table[] = {
void_expression_eval, void_expression_eval,
typeof_expression_eval, typeof_expression_eval,
minus_expression_eval, minus_expression_eval,
plus_expression_eval, compiled_expression_eval,
post_increment_expression_eval, post_increment_expression_eval,
post_decrement_expression_eval, post_decrement_expression_eval,
pre_increment_expression_eval, pre_increment_expression_eval,