Module: wine Branch: master Commit: 6d541ecc5dff7cb6a07d8b1a0ab488a1b68a82d2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6d541ecc5dff7cb6a07d8b1a0a...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Sep 11 23:55:14 2008 +0200
jscript: Added '||' expression implementation.
---
dlls/jscript/engine.c | 45 +++++++++++++++++++++++++++++++++++++++++-- dlls/jscript/tests/lang.js | 6 +++++ 2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index a97d23a..cf1045b 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1225,10 +1225,49 @@ HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, return E_NOTIMPL; }
-HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +/* ECMA-262 3rd Edition 11.11 */ +HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) { - FIXME("\n"); - return E_NOTIMPL; + binary_expression_t *expr = (binary_expression_t*)_expr; + exprval_t exprval; + 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->parser->script, &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; + } + + 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->parser->script, &exprval, ei, &val); + exprval_release(&exprval); + if(FAILED(hres)) + return hres; + + ret->type = EXPRVAL_VARIANT; + ret->u.var = val; + return S_OK; }
HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index adbb9d2..b334d96 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -180,4 +180,10 @@ tmp = 1; ok((tmp += 1) === 2, "tmp += 1 !== 2"); ok(tmp === 2, "tmp !== 2");
+tmp = 3 || ok(false, "second or expression called"); +ok(tmp === 3, "3 || (...) is not 3"); + +tmp = false || 2; +ok(tmp === 2, "false || 2 is not 2"); + reportSuccess();