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

oldstable
Jacek Caban 2011-11-25 12:07:30 +01:00 committed by Alexandre Julliard
parent 413fe9a462
commit 58952a07d0
4 changed files with 36 additions and 36 deletions

View File

@ -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:

View File

@ -2842,26 +2842,45 @@ 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);
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;
hres = equal_values(ctx, &rval, &lval, ei, &b);
VariantClear(&lval);
VariantClear(&rval);
return stack_push_bool(ctx, b);
}
/* ECMA-262 3rd Edition 11.9.2 */
HRESULT interp_neq(exec_ctx_t *ctx)
{
VARIANT *l, *r;
BOOL b;
HRESULT hres;
r = stack_pop(ctx);
l = stack_pop(ctx);
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 return_bool(ret, b);
return stack_push_bool(ctx, !b);
}
/* ECMA-262 3rd Edition 11.9.4 */
@ -2885,29 +2904,6 @@ static HRESULT interp_eq2(exec_ctx_t *ctx)
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)
{
binary_expression_t *expr = (binary_expression_t*)_expr;
VARIANT rval, lval;
BOOL b;
HRESULT hres;
TRACE("\n");
hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
if(FAILED(hres))
return hres;
hres = equal_values(ctx, &lval, &rval, ei, &b);
VariantClear(&lval);
VariantClear(&rval);
if(FAILED(hres))
return hres;
return return_bool(ret, !b);
}
/* ECMA-262 3rd Edition 11.9.5 */
static HRESULT interp_neq2(exec_ctx_t *ctx)
{

View File

@ -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;

View File

@ -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,