Jacek Caban : jscript: Use bytecode for logical and expression.
Alexandre Julliard
julliard at winehq.org
Mon Nov 28 14:00:07 CST 2011
Module: wine
Branch: master
Commit: 88dc54a7f7f9951b35a7f8c1218ccd9b2247cb61
URL: http://source.winehq.org/git/wine.git/?a=commit;h=88dc54a7f7f9951b35a7f8c1218ccd9b2247cb61
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Nov 28 12:04:33 2011 +0100
jscript: Use bytecode for logical and expression.
---
dlls/jscript/compile.c | 2 ++
dlls/jscript/engine.c | 39 ++++++++-------------------------------
dlls/jscript/engine.h | 2 +-
dlls/jscript/parser.y | 2 +-
4 files changed, 12 insertions(+), 33 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 36ecb6a..6abeec4 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -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:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 0cecd92..bf35d8a 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -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);
- if(FAILED(hres))
- return hres;
-
- hres = exprval_to_value(ctx, &exprval, ei, &val);
- exprval_release(&exprval);
+ hres = to_boolean(stack_top(ctx), &b);
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;
}
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 27083aa..5b67413 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -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;
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index 7e9febc..08e7b33 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -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,
More information about the wine-cvs
mailing list