jscript: Use bytecode for binary or implementation.

oldstable
Jacek Caban 2011-11-29 11:09:35 +01:00 committed by Alexandre Julliard
parent 7a20965bd2
commit 96b13314eb
4 changed files with 30 additions and 5 deletions

View File

@ -346,6 +346,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
case EXPR_BITNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
case EXPR_BOR:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or);
case EXPR_COMMA:
return compile_comma_expression(ctx, (binary_expression_t*)expr);
case EXPR_COND:

View File

@ -94,6 +94,15 @@ static inline HRESULT stack_push_number(exec_ctx_t *ctx, double number)
return stack_push(ctx, &v);
}
static inline HRESULT stack_push_int(exec_ctx_t *ctx, INT n)
{
VARIANT v;
V_VT(&v) = VT_I4;
V_I4(&v) = n;
return stack_push(ctx, &v);
}
static inline VARIANT *stack_top(exec_ctx_t *ctx)
{
assert(ctx->top);
@ -129,6 +138,11 @@ static HRESULT stack_pop_number(exec_ctx_t *ctx, VARIANT *r)
return hres;
}
static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r)
{
return to_int32(ctx->parser->script, stack_pop(ctx), &ctx->ei, r);
}
static void exprval_release(exprval_t *val)
{
switch(val->type) {
@ -2009,13 +2023,22 @@ static HRESULT bitor_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexc
}
/* ECMA-262 3rd Edition 11.10 */
HRESULT binary_or_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
static HRESULT interp_or(exec_ctx_t *ctx)
{
binary_expression_t *expr = (binary_expression_t*)_expr;
INT l, r;
HRESULT hres;
TRACE("\n");
return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
hres = stack_pop_int(ctx, &r);
if(FAILED(hres))
return hres;
hres = stack_pop_int(ctx, &l);
if(FAILED(hres))
return hres;
return stack_push_int(ctx, l|r);
}
/* ECMA-262 3rd Edition 11.10 */

View File

@ -63,6 +63,7 @@ typedef struct _func_stack {
X(neq2, 1, 0,0) \
X(new, 1, ARG_INT, 0) \
X(null, 1, 0,0) \
X(or, 1, 0,0) \
X(pop, 1, 0,0) \
X(regexp, 1, ARG_STR, ARG_INT) \
X(str, 1, ARG_STR, 0) \
@ -554,7 +555,6 @@ HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*
HRESULT array_literal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;

View File

@ -1308,7 +1308,7 @@ static const expression_eval_t expression_eval_table[] = {
compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
binary_or_expression_eval,
compiled_expression_eval,
binary_xor_expression_eval,
binary_and_expression_eval,
instanceof_expression_eval,