jscript: Use bytecode interpreter for logical negation expression.
This commit is contained in:
parent
32602170a5
commit
418af7eda9
|
@ -81,6 +81,17 @@ static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_
|
|||
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t *expr, jsop_t op)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
hres = compile_expression(ctx, expr->expression);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr)
|
||||
{
|
||||
unsigned instr;
|
||||
|
@ -98,6 +109,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
|
|||
switch(expr->type) {
|
||||
case EXPR_EQEQ:
|
||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
|
||||
case EXPR_LOGNEG:
|
||||
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);
|
||||
default:
|
||||
|
|
|
@ -3050,25 +3050,21 @@ HRESULT binary_negation_expression_eval(script_ctx_t *ctx, expression_t *_expr,
|
|||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 11.4.9 */
|
||||
HRESULT logical_negation_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
|
||||
HRESULT interp_neg(exec_ctx_t *ctx)
|
||||
{
|
||||
unary_expression_t *expr = (unary_expression_t*)_expr;
|
||||
exprval_t exprval;
|
||||
VARIANT *v;
|
||||
VARIANT_BOOL b;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
|
||||
v = stack_pop(ctx);
|
||||
hres = to_boolean(v, &b);
|
||||
VariantClear(v);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = exprval_to_boolean(ctx, &exprval, ei, &b);
|
||||
exprval_release(&exprval);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
return return_bool(ret, !b);
|
||||
return stack_push_bool(ctx, !b);
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 11.7.1 */
|
||||
|
|
|
@ -43,6 +43,7 @@ typedef struct _func_stack {
|
|||
|
||||
#define OP_LIST \
|
||||
X(eq2, 1, 0) \
|
||||
X(neg, 1, 0) \
|
||||
X(neq2, 1, 0) \
|
||||
X(tree, 1, ARG_EXPR) \
|
||||
X(ret, 0, 0)
|
||||
|
@ -547,7 +548,6 @@ HRESULT lesseq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exp
|
|||
HRESULT greater_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT greatereq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT binary_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT logical_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT left_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT right_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT right2_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -1336,7 +1336,7 @@ static const expression_eval_t expression_eval_table[] = {
|
|||
greater_expression_eval,
|
||||
greatereq_expression_eval,
|
||||
binary_negation_expression_eval,
|
||||
logical_negation_expression_eval,
|
||||
compiled_expression_eval,
|
||||
left_shift_expression_eval,
|
||||
right_shift_expression_eval,
|
||||
right2_shift_expression_eval,
|
||||
|
|
|
@ -208,6 +208,9 @@ for(var iter in false)
|
|||
for(var iter in pureDisp)
|
||||
ok(false, "unexpected forin call in pureDisp object");
|
||||
|
||||
tmp = new Object();
|
||||
ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
|
||||
|
||||
tmp = 0;
|
||||
if(true)
|
||||
tmp = 1;
|
||||
|
|
Loading…
Reference in New Issue