Commit 58952a07 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use bytecode for '==' and '!=' expression.

parent 413fe9a4
......@@ -228,6 +228,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
case EXPR_COMMA:
return compile_comma_expression(ctx, (binary_expression_t*)expr);
case EXPR_EQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq);
case EXPR_EQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
case EXPR_IN:
......@@ -238,6 +240,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_MINUS:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_minus);
case EXPR_NOTEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq);
case EXPR_NOTEQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2);
case EXPR_PLUS:
......
......@@ -2842,70 +2842,66 @@ static HRESULT equal_values(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jse
}
/* ECMA-262 3rd Edition 11.9.1 */
HRESULT equal_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
HRESULT interp_eq(exec_ctx_t *ctx)
{
binary_expression_t *expr = (binary_expression_t*)_expr;
VARIANT rval, lval;
VARIANT *l, *r;
BOOL b;
HRESULT hres;
TRACE("\n");
r = stack_pop(ctx);
l = stack_pop(ctx);
hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
if(FAILED(hres))
return hres;
TRACE("%s == %s\n", debugstr_variant(l), debugstr_variant(r));
hres = equal_values(ctx, &rval, &lval, ei, &b);
VariantClear(&lval);
VariantClear(&rval);
hres = equal_values(ctx->parser->script, l, r, &ctx->ei, &b);
VariantClear(l);
VariantClear(r);
if(FAILED(hres))
return hres;
return return_bool(ret, b);
return stack_push_bool(ctx, b);
}
/* ECMA-262 3rd Edition 11.9.4 */
static HRESULT interp_eq2(exec_ctx_t *ctx)
/* ECMA-262 3rd Edition 11.9.2 */
HRESULT interp_neq(exec_ctx_t *ctx)
{
VARIANT *l, *r;
BOOL b;
HRESULT hres;
TRACE("\n");
r = stack_pop(ctx);
l = stack_pop(ctx);
hres = equal2_values(r, l, &b);
TRACE("%s != %s\n", debugstr_variant(l), debugstr_variant(r));
hres = equal_values(ctx->parser->script, l, r, &ctx->ei, &b);
VariantClear(l);
VariantClear(r);
if(FAILED(hres))
return hres;
return stack_push_bool(ctx, b);
return stack_push_bool(ctx, !b);
}
/* ECMA-262 3rd Edition 11.9.2 */
HRESULT not_equal_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
/* ECMA-262 3rd Edition 11.9.4 */
static HRESULT interp_eq2(exec_ctx_t *ctx)
{
binary_expression_t *expr = (binary_expression_t*)_expr;
VARIANT rval, lval;
VARIANT *l, *r;
BOOL b;
HRESULT hres;
TRACE("\n");
hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
if(FAILED(hres))
return hres;
r = stack_pop(ctx);
l = stack_pop(ctx);
hres = equal_values(ctx, &lval, &rval, ei, &b);
VariantClear(&lval);
VariantClear(&rval);
hres = equal2_values(r, l, &b);
VariantClear(l);
VariantClear(r);
if(FAILED(hres))
return hres;
return return_bool(ret, !b);
return stack_push_bool(ctx, b);
}
/* ECMA-262 3rd Edition 11.9.5 */
......
......@@ -46,11 +46,13 @@ typedef struct _func_stack {
X(bool, 1, ARG_INT, 0) \
X(bneg, 1, 0,0) \
X(double, 1, ARG_SBL, 0) \
X(eq, 1, 0,0) \
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(neq, 1, 0,0) \
X(neq2, 1, 0,0) \
X(null, 1, 0,0) \
X(pop, 1, 0,0) \
......@@ -553,8 +555,6 @@ HRESULT post_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcep
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_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT not_equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT less_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
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;
......
......@@ -1327,9 +1327,9 @@ static const expression_eval_t expression_eval_table[] = {
post_decrement_expression_eval,
pre_increment_expression_eval,
pre_decrement_expression_eval,
equal_expression_eval,
compiled_expression_eval,
not_equal_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
less_expression_eval,
lesseq_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