public override bool Resolve (BlockContext ec)
{
if (ec.Switch == null){
ec.Report.Error (153, loc, "A goto case is only valid inside a switch statement");
return false;
}
ec.CurrentBranching.CurrentUsageVector.Goto ();
expr = expr.Resolve (ec);
if (expr == null)
return false;
Constant c = expr as Constant;
if (c == null) {
ec.Report.Error (150, expr.Location, "A constant value is expected");
return false;
}
TypeSpec type = ec.Switch.SwitchType;
Constant res = c.TryReduce (ec, type, c.Location);
if (res == null) {
c.Error_ValueCannotBeConverted (ec, loc, type, true);
return false;
}
if (!Convert.ImplicitStandardConversionExists (c, type))
ec.Report.Warning (469, 2, loc,
"The `goto case' value is not implicitly convertible to type `{0}'",
TypeManager.CSharpName (type));
object val = res.GetValue ();
if (val == null)
val = SwitchLabel.NullStringCase;
if (!ec.Switch.Elements.TryGetValue (val, out sl)) {
FlowBranchingBlock.Error_UnknownLabel (loc, "case " +
(c.GetValue () == null ? "null" : val.ToString ()), ec.Report);
return false;
}
return true;
}