public override bool Resolve (BlockContext ec)
{
bool ok = true;
Report.Debug (1, "START IF BLOCK", loc);
expr = expr.Resolve (ec);
if (expr == null) {
ok = false;
} else {
//
// Dead code elimination
//
if (expr is Constant) {
bool take = !((Constant) expr).IsDefaultValue;
if (take) {
if (!TrueStatement.Resolve (ec))
return false;
if ((FalseStatement != null) &&
!FalseStatement.ResolveUnreachable (ec, true))
return false;
FalseStatement = null;
} else {
if (!TrueStatement.ResolveUnreachable (ec, true))
return false;
TrueStatement = null;
if ((FalseStatement != null) &&
!FalseStatement.Resolve (ec))
return false;
}
return true;
}
}
ec.StartFlowBranching (FlowBranching.BranchingType.Conditional, loc);
ok &= TrueStatement.Resolve (ec);
is_true_ret = ec.CurrentBranching.CurrentUsageVector.IsUnreachable;
ec.CurrentBranching.CreateSibling ();
if (FalseStatement != null)
ok &= FalseStatement.Resolve (ec);
ec.EndFlowBranching ();
Report.Debug (1, "END IF BLOCK", loc);
return ok;
}