Jacek Caban : jscript: Properly handle return value evaluation in comma expression.
Alexandre Julliard
julliard at winehq.org
Fri Dec 14 14:09:59 CST 2012
Module: wine
Branch: master
Commit: 10c2a2bba456d5c8f70f4c98384196dfebf1d2e1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=10c2a2bba456d5c8f70f4c98384196dfebf1d2e1
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Dec 14 11:06:28 2012 +0100
jscript: Properly handle return value evaluation in comma expression.
---
dlls/jscript/compile.c | 12 ++++--------
dlls/jscript/tests/lang.js | 9 +++++++--
dlls/jscript/tests/run.c | 6 ++++--
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 4effda4..a3dab82 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -474,18 +474,15 @@ static HRESULT compile_increment_expression(compiler_ctx_t *ctx, unary_expressio
}
/* ECMA-262 3rd Edition 11.14 */
-static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t *expr)
+static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t *expr, BOOL emit_ret)
{
HRESULT hres;
- hres = compile_expression(ctx, expr->expression1, TRUE);
+ hres = compile_expression(ctx, expr->expression1, FALSE);
if(FAILED(hres))
return hres;
- if(!push_instr(ctx, OP_pop))
- return E_OUTOFMEMORY;
-
- return compile_expression(ctx, expr->expression2, TRUE);
+ return compile_expression(ctx, expr->expression2, emit_ret);
}
/* ECMA-262 3rd Edition 11.11 */
@@ -938,8 +935,7 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr, BOOL
case EXPR_CALL:
return compile_call_expression(ctx, (call_expression_t*)expr, emit_ret);
case EXPR_COMMA:
- hres = compile_comma_expression(ctx, (binary_expression_t*)expr);
- break;
+ return compile_comma_expression(ctx, (binary_expression_t*)expr, emit_ret);
case EXPR_COND:
hres = compile_conditional_expression(ctx, (conditional_expression_t*)expr);
break;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 640d171..23e12cc 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -189,14 +189,19 @@ tmp = eval("1;");
ok(tmp === 1, "tmp = " + tmp);
tmp = eval("1,2;");
ok(tmp === 2, "tmp = " + tmp);
+tmp = eval("testNoRes(),2;");
+ok(tmp === 2, "tmp = " + tmp);
tmp = eval("if(true) {3}");
ok(tmp === 3, "tmp = " + tmp);
-testNoRes();
eval("testRes(); testRes()");
tmp = eval("3; if(false) {4;} else {};;;")
ok(tmp === 3, "tmp = " + tmp);
-tmp = (function(){ return testRes();})();
+testNoRes();
+testRes() && testRes();
+testNoRes(), testNoRes();
+
+tmp = (function(){ return testNoRes(), testRes();})();
var obj1 = new Object();
ok(typeof(obj1) === "object", "typeof(obj1) is not object");
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 32b7c4c..55b1398 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -749,8 +749,10 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
case DISPID_GLOBAL_TESTRES:
ok(pvarRes != NULL, "pvarRes = NULL\n");
- if(pvarRes)
- V_VT(pvarRes) = VT_NULL;
+ if(pvarRes) {
+ V_VT(pvarRes) = VT_BOOL;
+ V_BOOL(pvarRes) = VARIANT_TRUE;
+ }
return S_OK;
case DISPID_GLOBAL_TESTNORES:
More information about the wine-cvs
mailing list