jscript: Use bytecode for logical and expression.

This commit is contained in:
Jacek Caban 2011-11-28 12:04:33 +01:00 committed by Alexandre Julliard
parent 28375af386
commit 88dc54a7f7
4 changed files with 12 additions and 33 deletions

View File

@ -244,6 +244,8 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal)
static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
{
switch(expr->type) {
case EXPR_AND:
return compile_logical_expression(ctx, (binary_expression_t*)expr, OP_jmp_z);
case EXPR_ADD:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
case EXPR_BITNEG:

View File

@ -1957,47 +1957,24 @@ HRESULT interp_jmp_nz(exec_ctx_t *ctx)
}
/* ECMA-262 3rd Edition 11.11 */
HRESULT logical_and_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
HRESULT interp_jmp_z(exec_ctx_t *ctx)
{
binary_expression_t *expr = (binary_expression_t*)_expr;
exprval_t exprval;
const unsigned arg = ctx->parser->code->instrs[ctx->ip].arg1.uint;
VARIANT_BOOL b;
VARIANT val;
HRESULT hres;
TRACE("\n");
hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
hres = to_boolean(stack_top(ctx), &b);
if(FAILED(hres))
return hres;
hres = exprval_to_value(ctx, &exprval, ei, &val);
exprval_release(&exprval);
if(FAILED(hres))
return hres;
hres = to_boolean(&val, &b);
if(SUCCEEDED(hres) && !b) {
ret->type = EXPRVAL_VARIANT;
ret->u.var = val;
return S_OK;
if(b) {
stack_popn(ctx, 1);
ctx->ip++;
}else {
ctx->ip = arg;
}
VariantClear(&val);
if(FAILED(hres))
return hres;
hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
if(FAILED(hres))
return hres;
hres = exprval_to_value(ctx, &exprval, ei, &val);
exprval_release(&exprval);
if(FAILED(hres))
return hres;
ret->type = EXPRVAL_VARIANT;
ret->u.var = val;
return S_OK;
}

View File

@ -51,6 +51,7 @@ typedef struct _func_stack {
X(in, 1, 0,0) \
X(int, 1, ARG_INT, 0) \
X(jmp_nz, 0, ARG_ADDR, 0) \
X(jmp_z, 0, ARG_ADDR, 0) \
X(minus, 1, 0,0) \
X(neg, 1, 0,0) \
X(neq, 1, 0,0) \
@ -543,7 +544,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 logical_and_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;

View File

@ -1307,7 +1307,7 @@ static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *ide
static const expression_eval_t expression_eval_table[] = {
compiled_expression_eval,
compiled_expression_eval,
logical_and_expression_eval,
compiled_expression_eval,
binary_or_expression_eval,
binary_xor_expression_eval,
binary_and_expression_eval,