Commit 35b9c42f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use bytecode for unary '+' expression.

parent 2d83bdcf
......@@ -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);
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment