jscript: Use bytecode for unary '-' expression.
This commit is contained in:
parent
b13c6a27c3
commit
413fe9a462
|
@ -236,6 +236,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
|
|||
return compile_literal(ctx, ((literal_expression_t*)expr)->literal);
|
||||
case EXPR_LOGNEG:
|
||||
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
|
||||
case EXPR_MINUS:
|
||||
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_minus);
|
||||
case EXPR_NOTEQEQ:
|
||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2);
|
||||
case EXPR_PLUS:
|
||||
|
|
|
@ -2574,32 +2574,18 @@ HRESULT typeof_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla
|
|||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 11.4.7 */
|
||||
HRESULT minus_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
|
||||
HRESULT interp_minus(exec_ctx_t *ctx)
|
||||
{
|
||||
unary_expression_t *expr = (unary_expression_t*)_expr;
|
||||
exprval_t exprval;
|
||||
VARIANT val, num;
|
||||
VARIANT n;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
|
||||
hres = stack_pop_number(ctx, &n);
|
||||
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;
|
||||
num_set_val(&ret->u.var, -num_val(&num));
|
||||
return S_OK;
|
||||
return stack_push_number(ctx, -num_val(&n));
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 11.4.6 */
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct _func_stack {
|
|||
X(eq2, 1, 0,0) \
|
||||
X(in, 1, 0,0) \
|
||||
X(int, 1, ARG_INT, 0) \
|
||||
X(minus, 1, 0,0) \
|
||||
X(neg, 1, 0,0) \
|
||||
X(neq2, 1, 0,0) \
|
||||
X(null, 1, 0,0) \
|
||||
|
|
|
@ -1321,7 +1321,7 @@ static const expression_eval_t expression_eval_table[] = {
|
|||
delete_expression_eval,
|
||||
compiled_expression_eval,
|
||||
typeof_expression_eval,
|
||||
minus_expression_eval,
|
||||
compiled_expression_eval,
|
||||
compiled_expression_eval,
|
||||
post_increment_expression_eval,
|
||||
post_decrement_expression_eval,
|
||||
|
|
Loading…
Reference in New Issue