Jacek Caban : jscript: Added conditional expression implementation.
Alexandre Julliard
julliard at winehq.org
Thu Sep 11 08:00:56 CDT 2008
Module: wine
Branch: master
Commit: 23ccc9a293c6261e035a29f211970bf7c4a37fc5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=23ccc9a293c6261e035a29f211970bf7c4a37fc5
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 10 21:11:15 2008 +0200
jscript: Added conditional expression implementation.
---
dlls/jscript/engine.c | 22 +++++++++++++++++++---
dlls/jscript/tests/lang.js | 3 +++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index e19a0bb..ba3f9b0 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -781,10 +781,26 @@ HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD fla
return S_OK;
}
-HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+/* ECMA-262 3rd Edition 11.12 */
+HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
- FIXME("\n");
- return E_NOTIMPL;
+ conditional_expression_t *expr = (conditional_expression_t*)_expr;
+ exprval_t exprval;
+ VARIANT_BOOL b;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
+ if(FAILED(hres))
+ return hres;
+
+ hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
+ exprval_release(&exprval);
+ if(FAILED(hres))
+ return hres;
+
+ return expr_eval(ctx, b ? expr->true_expression : expr->false_expression, flags, ei, ret);
}
/* ECMA-262 3rd Edition 11.2.1 */
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 76cacee..7096401 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -150,4 +150,7 @@ ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
}
ok(blockVar === 2, "blockVar !== 2");
+ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
+ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
+
reportSuccess();
More information about the wine-cvs
mailing list