public static HashSet<LabelSymbol> Find(BoundNode node, Dictionary<BoundNode, HashSet<LabelSymbol>> unmatchedLabelsCache) { UnmatchedGotoFinder finder = new UnmatchedGotoFinder(unmatchedLabelsCache); finder.Visit(node); HashSet<LabelSymbol> gotos = finder._gotos; HashSet<LabelSymbol> targets = finder._targets; if (gotos != null && targets != null) { gotos.RemoveAll(targets); } return gotos; }
public static HashSet<LabelSymbol> Find(BoundNode node, Dictionary<BoundNode, HashSet<LabelSymbol>> unmatchedLabelsCache) { UnmatchedGotoFinder finder = new UnmatchedGotoFinder(unmatchedLabelsCache); finder.Visit(node); HashSet<LabelSymbol> gotos = finder.gotos; HashSet<LabelSymbol> targets = finder.targets; if (gotos != null && targets != null) { gotos.RemoveAll(targets); } return gotos; }
/// <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); lazyUnmatchedLabelCache.Add(node, unmatched); return(unmatched != null && unmatched.Count > 0); }