/// <summary> /// Look for gotos without corresponding labels in the lowered body of a fixed statement. /// </summary> /// <remarks> /// Assumes continue, break, etc have already been rewritten to gotos. /// </remarks> private bool HasGotoOut(BoundNode node) { if (_lazyUnmatchedLabelCache == null) { _lazyUnmatchedLabelCache = new Dictionary <BoundNode, HashSet <LabelSymbol> >(); } HashSet <LabelSymbol> unmatched = UnmatchedGotoFinder.Find(node, _lazyUnmatchedLabelCache, RecursionDepth); _lazyUnmatchedLabelCache.Add(node, unmatched); return(unmatched != null && unmatched.Count > 0); }
public static HashSet <LabelSymbol> Find(BoundNode node, Dictionary <BoundNode, HashSet <LabelSymbol> > unmatchedLabelsCache, int recursionDepth) { UnmatchedGotoFinder finder = new UnmatchedGotoFinder(unmatchedLabelsCache, recursionDepth); finder.Visit(node); HashSet <LabelSymbol> gotos = finder._gotos; HashSet <LabelSymbol> targets = finder._targets; if (gotos != null && targets != null) { gotos.RemoveAll(targets); } return(gotos); }