internal void Control(LoopControlType controlType, string label)
{
AssertNotFinished();
bool controlled = false;
var statement = Statement;
while (statement != null) {
if (statement is LoopStatement) {
var loop = (LoopStatement) statement;
if (!String.IsNullOrEmpty(label) &&
String.Equals(label, loop.Label)) {
loop.Control(controlType);
controlled = true;
} else if (!controlled) {
loop.Control(controlType);
controlled = true;
}
}
statement = statement.Parent;
}
if (!controlled)
throw new StatementException(String.Format("Could not control {0} any loop.",
controlType.ToString().ToUpperInvariant()));
}