jscript: Added if statement implementation.
This commit is contained in:
parent
eedc6dc715
commit
1edd64ef8b
|
@ -566,10 +566,33 @@ HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_ty
|
|||
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");
|
||||
return E_NOTIMPL;
|
||||
if_statement_t *stat = (if_statement_t*)_stat;
|
||||
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)
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
var tmp;
|
||||
|
||||
ok(true, "true is not true?");
|
||||
ok(!false, "!false is not true");
|
||||
ok(!undefined, "!undefined is not true");
|
||||
|
@ -116,4 +118,26 @@ obj2.pvar = 3;
|
|||
testConstr1.prototype.pvar = 1;
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue