Commit 2d83bdcf authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use bytecode for binary negation implementation.

parent 06d759ed
......@@ -107,6 +107,8 @@ static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr)
static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
{
switch(expr->type) {
case EXPR_BITNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
case EXPR_EQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
case EXPR_LOGNEG:
......
......@@ -3020,33 +3020,23 @@ HRESULT greatereq_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD
}
/* ECMA-262 3rd Edition 11.4.8 */
HRESULT binary_negation_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
HRESULT interp_bneg(exec_ctx_t *ctx)
{
unary_expression_t *expr = (unary_expression_t*)_expr;
exprval_t exprval;
VARIANT val;
VARIANT *v, r;
INT i;
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_int32(ctx, &val, ei, &i);
v = stack_pop(ctx);
hres = to_int32(ctx->parser->script, v, &ctx->ei, &i);
VariantClear(v);
if(FAILED(hres))
return hres;
ret->type = EXPRVAL_VARIANT;
V_VT(&ret->u.var) = VT_I4;
V_I4(&ret->u.var) = ~i;
return S_OK;
V_VT(&r) = VT_I4;
V_I4(&r) = ~i;
return stack_push(ctx, &r);
}
/* ECMA-262 3rd Edition 11.4.9 */
......
......@@ -42,6 +42,7 @@ typedef struct _func_stack {
} func_stack_t;
#define OP_LIST \
X(bneg, 1, 0) \
X(eq2, 1, 0) \
X(neg, 1, 0) \
X(neq2, 1, 0) \
......@@ -547,7 +548,6 @@ HRESULT less_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprv
HRESULT lesseq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
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 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;
......
......@@ -1335,7 +1335,7 @@ static const expression_eval_t expression_eval_table[] = {
lesseq_expression_eval,
greater_expression_eval,
greatereq_expression_eval,
binary_negation_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
left_shift_expression_eval,
right_shift_expression_eval,
......
......@@ -210,6 +210,11 @@ for(var iter in pureDisp)
tmp = new Object();
ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
ok(!("nonexistent" in tmp), "nonexistent is in tmp after '!' expression")
tmp = new Object();
ok((~tmp.nonexistent) === -1, "!tmp.nonexistent = " + ~tmp.nonexistent);
ok(!("nonexistent" in tmp), "nonexistent is in tmp after '~' expression")
tmp = 0;
if(true)
......
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