Commit 1edd64ef authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added if statement implementation.

parent eedc6dc7
...@@ -566,10 +566,33 @@ HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_ty ...@@ -566,10 +566,33 @@ HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_ty
return S_OK; return S_OK;
} }
HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret) /* ECMA-262 3rd Edition 12.5 */
HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
{ {
FIXME("\n"); if_statement_t *stat = (if_statement_t*)_stat;
return E_NOTIMPL; exprval_t exprval;
VARIANT_BOOL b;
HRESULT hres;
TRACE("\n");
hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
if(FAILED(hres))
return hres;
hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
exprval_release(&exprval);
if(FAILED(hres))
return hres;
if(b)
hres = stat_eval(ctx, stat->if_stat, rt, ret);
else if(stat->else_stat)
hres = stat_eval(ctx, stat->else_stat, rt, ret);
else
V_VT(ret) = VT_EMPTY;
return hres;
} }
HRESULT dowhile_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret) HRESULT dowhile_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
var tmp;
ok(true, "true is not true?"); ok(true, "true is not true?");
ok(!false, "!false is not true"); ok(!false, "!false is not true");
ok(!undefined, "!undefined is not true"); ok(!undefined, "!undefined is not true");
...@@ -116,4 +118,26 @@ obj2.pvar = 3; ...@@ -116,4 +118,26 @@ obj2.pvar = 3;
testConstr1.prototype.pvar = 1; testConstr1.prototype.pvar = 1;
ok(obj2.pvar === 3, "obj2.pvar is not 3"); ok(obj2.pvar === 3, "obj2.pvar is not 3");
tmp = 0;
if(true)
tmp = 1;
else
ok(false, "else evaluated");
ok(tmp === 1, "tmp !== 1, if not evaluated?");
tmp = 0;
if(1 === 0)
ok(false, "if evaluated");
else
tmp = 1;
ok(tmp === 1, "tmp !== 1, if not evaluated?");
if(false)
ok(false, "if(false) evaluated");
tmp = 0;
if(true)
tmp = 1;
ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
reportSuccess(); reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment