Jacek Caban : jscript: Use bytecode interpreter for logical negation expression.
Alexandre Julliard
julliard at winehq.org
Fri Nov 18 10:19:07 CST 2011
Module: wine
Branch: master
Commit: 418af7eda90715b6bb75adb9325c9be963ffcf3b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=418af7eda90715b6bb75adb9325c9be963ffcf3b
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Nov 18 14:10:40 2011 +0100
jscript: Use bytecode interpreter for logical negation expression.
---
dlls/jscript/compile.c | 13 +++++++++++++
dlls/jscript/engine.c | 16 ++++++----------
dlls/jscript/engine.h | 2 +-
dlls/jscript/parser.y | 2 +-
dlls/jscript/tests/lang.js | 3 +++
5 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index b93ab52..b51f68f 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -81,6 +81,17 @@ static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
}
+static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t *expr, jsop_t op)
+{
+ HRESULT hres;
+
+ hres = compile_expression(ctx, expr->expression);
+ if(FAILED(hres))
+ return hres;
+
+ return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
+}
+
static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr)
{
unsigned instr;
@@ -98,6 +109,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
switch(expr->type) {
case EXPR_EQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
+ case EXPR_LOGNEG:
+ return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_NOTEQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_neq2);
default:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 6353d12..29fb64b 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -3050,25 +3050,21 @@ HRESULT binary_negation_expression_eval(script_ctx_t *ctx, expression_t *_expr,
}
/* ECMA-262 3rd Edition 11.4.9 */
-HRESULT logical_negation_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+HRESULT interp_neg(exec_ctx_t *ctx)
{
- unary_expression_t *expr = (unary_expression_t*)_expr;
- exprval_t exprval;
+ VARIANT *v;
VARIANT_BOOL b;
HRESULT hres;
TRACE("\n");
- hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
- if(FAILED(hres))
- return hres;
-
- hres = exprval_to_boolean(ctx, &exprval, ei, &b);
- exprval_release(&exprval);
+ v = stack_pop(ctx);
+ hres = to_boolean(v, &b);
+ VariantClear(v);
if(FAILED(hres))
return hres;
- return return_bool(ret, !b);
+ return stack_push_bool(ctx, !b);
}
/* ECMA-262 3rd Edition 11.7.1 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 5c46e39..55c29e8 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -43,6 +43,7 @@ typedef struct _func_stack {
#define OP_LIST \
X(eq2, 1, 0) \
+ X(neg, 1, 0) \
X(neq2, 1, 0) \
X(tree, 1, ARG_EXPR) \
X(ret, 0, 0)
@@ -547,7 +548,6 @@ HRESULT lesseq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exp
HRESULT greater_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT greatereq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT logical_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT left_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT right_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT right2_shift_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 310ff2a..fd294bd 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1336,7 +1336,7 @@ static const expression_eval_t expression_eval_table[] = {
greater_expression_eval,
greatereq_expression_eval,
binary_negation_expression_eval,
- logical_negation_expression_eval,
+ compiled_expression_eval,
left_shift_expression_eval,
right_shift_expression_eval,
right2_shift_expression_eval,
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index b54eef2..92eb642 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -208,6 +208,9 @@ for(var iter in false)
for(var iter in pureDisp)
ok(false, "unexpected forin call in pureDisp object");
+tmp = new Object();
+ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
+
tmp = 0;
if(true)
tmp = 1;
More information about the wine-cvs
mailing list