internal void Define(LabelScopeInfo block)
{
// Prevent the label from being shadowed, which enforces cleaner
// trees. Also we depend on this for simplicity (keeping only one
// active IL Label per LabelInfo)
for (LabelScopeInfo j = block; j != null; j = j.Parent)
{
if (j.ContainsTarget(_node))
{
throw Error.LabelTargetAlreadyDefined(_node.Name);
}
}
_definitions.Add(block);
block.AddLabelInfo(_node, this);
// Once defined, validate all jumps
if (_definitions.Count == 1)
{
foreach (LabelScopeInfo r in _references)
{
ValidateJump(r);
}
}
else
{
// Was just redefined, if we had any across block jumps, they're
// now invalid
if (_acrossBlockJump)
{
throw Error.AmbiguousJump(_node.Name);
}
// For local jumps, we need a new IL label
// This is okay because:
// 1. no across block jumps have been made or will be made
// 2. we don't allow the label to be shadowed
_labelDefined = false;
}
}