BoundTree\LengthBasedStringSwitchData.cs (26)
87public readonly LabelSymbol? NullCaseLabel;
88public readonly ImmutableArray<(int value, LabelSymbol label)> LengthCaseLabels;
90public LengthJumpTable(LabelSymbol? nullCaseLabel, ImmutableArray<(int value, LabelSymbol label)> lengthCaseLabels)
101public readonly LabelSymbol Label;
103public readonly ImmutableArray<(char value, LabelSymbol label)> CharCaseLabels;
105internal CharJumpTable(LabelSymbol label, int selectedCharPosition, ImmutableArray<(char value, LabelSymbol label)> charCaseLabels)
117public readonly LabelSymbol Label;
118public readonly ImmutableArray<(string value, LabelSymbol label)> StringCaseLabels;
120internal StringJumpTable(LabelSymbol label, ImmutableArray<(string value, LabelSymbol label)> stringCaseLabels)
137internal static LengthBasedStringSwitchData Create(ImmutableArray<(ConstantValue value, LabelSymbol label)> inputCases)
141LabelSymbol? nullCaseLabel = null;
151var lengthCaseLabels = ArrayBuilder<(int value, LabelSymbol label)>.GetInstance();
157var labelForLength = CreateAndRegisterCharJumpTables(stringLength, group.SelectAsArray(c => (c.value.StringValue!, c.label)), charJumpTables, stringJumpTables);
165private static LabelSymbol CreateAndRegisterCharJumpTables(int stringLength, ImmutableArray<(string value, LabelSymbol label)> casesWithGivenLength,
186var charCaseLabels = ArrayBuilder<(char value, LabelSymbol label)>.GetInstance();
191LabelSymbol label = (stringLength == 1)
202static int selectBestCharacterIndex(int stringLength, ImmutableArray<(string value, LabelSymbol label)> caseLabels)
229static (int singleEntryCount, int largestBucket) positionScore(int position, ImmutableArray<(string value, LabelSymbol label)> caseLabels)
253private static LabelSymbol CreateAndRegisterStringJumpTable(ImmutableArray<(string value, LabelSymbol label)> cases, ArrayBuilder<StringJumpTable> stringJumpTables)
290void dump<T>(ImmutableArray<(T value, LabelSymbol label)> cases)
298string readable(LabelSymbol? label)
CodeGen\EmitStatement.cs (10)
1278LabelSymbol fallThroughLabel,
1369LabelSymbol fallThroughLabel,
1409void emitLengthDispatch(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1446void emitCharDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1487void emitFinalDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, TypeSymbol keyType, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1514LabelSymbol fallThroughLabel,
1967private Dictionary<LabelSymbol, GeneratedLabelSymbol> _labelClones;
2014var casesBuilder = ArrayBuilder<(ConstantValue, LabelSymbol)>.GetInstance();
2036private GeneratedLabelSymbol GetLabelClone(LabelSymbol label)
2041_labelClones = labelClones = new Dictionary<LabelSymbol, GeneratedLabelSymbol>();
FlowAnalysis\AbstractFlowPass.cs (12)
79private readonly PooledDictionary<LabelSymbol, TLocalState> _labels;
210_labels = PooledDictionary<LabelSymbol, TLocalState>.GetInstance();
238foreach (var key in _labels.Keys)
400public readonly LabelSymbol? Label;
403public PendingBranch(BoundNode branch, TLocalState state, LabelSymbol label, bool isConditionalState = false, TLocalState stateWhenTrue = default, TLocalState stateWhenFalse = default)
514protected virtual TLocalState LabelState(LabelSymbol label)
723private void ResolveBreaks(TLocalState breakState, LabelSymbol label)
732private void ResolveContinues(LabelSymbol continueLabel)
745private void JoinPendingBranches(ref TLocalState state, LabelSymbol label)
773private bool ResolveBranches(LabelSymbol label, BoundStatement? target)
792protected virtual void ResolveBranch(PendingBranch pending, LabelSymbol label, BoundStatement? target, ref bool labelStateChanged)
3423protected void VisitLabel(LabelSymbol label, BoundStatement node)
FlowAnalysis\NullableWalker_Patterns.cs (5)
374private PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> LearnFromDecisionDag(
417var labelStateMap = PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)>.GetInstance();
1087PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap,
1132PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap,
1144LocalState getStateForArm(BoundSwitchExpressionArm arm, PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap)
Generated\BoundNodes.xml.Generated.cs (108)
3756public BoundBreakStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
3765public BoundBreakStatement(SyntaxNode syntax, LabelSymbol label)
3774public LabelSymbol Label { get; }
3779public BoundBreakStatement Update(LabelSymbol label)
3793public BoundContinueStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
3802public BoundContinueStatement(SyntaxNode syntax, LabelSymbol label)
3811public LabelSymbol Label { get; }
3816public BoundContinueStatement Update(LabelSymbol label)
3830public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, ImmutableArray<LocalSymbol> innerLocals, ImmutableArray<MethodSymbol> innerLocalFunctions, ImmutableArray<BoundSwitchSection> switchSections, BoundDecisionDag reachabilityDecisionDag, BoundSwitchLabel? defaultLabel, LabelSymbol breakLabel, bool hasErrors = false)
3856public LabelSymbol BreakLabel { get; }
3861public BoundSwitchStatement Update(BoundExpression expression, ImmutableArray<LocalSymbol> innerLocals, ImmutableArray<MethodSymbol> innerLocalFunctions, ImmutableArray<BoundSwitchSection> switchSections, BoundDecisionDag reachabilityDecisionDag, BoundSwitchLabel? defaultLabel, LabelSymbol breakLabel)
3875public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false)
3890public ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases { get; }
3891public LabelSymbol DefaultLabel { get; }
3897public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt)
3944protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors)
3955protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, LabelSymbol breakLabel, LabelSymbol continueLabel)
3966public LabelSymbol BreakLabel { get; }
3967public LabelSymbol ContinueLabel { get; }
3972protected BoundConditionalLoopStatement(BoundKind kind, SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
3994public BoundDoStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4010public BoundDoStatement Update(ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4024public BoundWhileStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4040public BoundWhileStatement Update(ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4054public BoundForStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> outerLocals, BoundStatement? initializer, ImmutableArray<LocalSymbol> innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4082public BoundForStatement Update(ImmutableArray<LocalSymbol> outerLocals, BoundStatement? initializer, ImmutableArray<LocalSymbol> innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4096public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo? enumeratorInfoOpt, BoundValuePlaceholder? elementPlaceholder, BoundExpression? elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray<LocalSymbol> iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4131public BoundForEachStatement Update(ForEachEnumeratorInfo? enumeratorInfoOpt, BoundValuePlaceholder? elementPlaceholder, BoundExpression? elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray<LocalSymbol> iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4280public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler, bool hasErrors = false)
4297public LabelSymbol? FinallyLabelOpt { get; }
4303public BoundTryStatement Update(BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler)
4730public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
4739public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label)
4748public LabelSymbol Label { get; }
4753public BoundLabelStatement Update(LabelSymbol label)
4767public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt, bool hasErrors = false)
4778public LabelSymbol Label { get; }
4785public BoundGotoStatement Update(LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt)
4799public BoundLabeledStatement(SyntaxNode syntax, LabelSymbol label, BoundStatement body, bool hasErrors = false)
4810public LabelSymbol Label { get; }
4816public BoundLabeledStatement Update(LabelSymbol label, BoundStatement body)
4830public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type, bool hasErrors)
4839public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type)
4848public LabelSymbol Label { get; }
4853public BoundLabel Update(LabelSymbol label, TypeSymbol? type)
4904public BoundConditionalGoto(SyntaxNode syntax, BoundExpression condition, bool jumpIfTrue, LabelSymbol label, bool hasErrors = false)
4918public LabelSymbol Label { get; }
4923public BoundConditionalGoto Update(BoundExpression condition, bool jumpIfTrue, LabelSymbol label)
4937protected BoundSwitchExpression(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
4955public LabelSymbol? DefaultLabel { get; }
4961public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundPattern pattern, bool hasUnionMatching, BoundExpression? whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false)
4983public LabelSymbol Label { get; }
4988public BoundSwitchExpressionArm Update(ImmutableArray<LocalSymbol> locals, BoundPattern pattern, bool hasUnionMatching, BoundExpression? whenClause, BoundExpression value, LabelSymbol label)
5002public BoundUnconvertedSwitchExpression(SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
5016public BoundUnconvertedSwitchExpression Update(BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type)
5030public BoundConvertedSwitchExpression(SyntaxNode syntax, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol type, bool hasErrors = false)
5050public BoundConvertedSwitchExpression Update(TypeSymbol? naturalTypeOpt, bool wasTargetTyped, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol type)
5208public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
5217public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label)
5226public LabelSymbol Label { get; }
5231public BoundLeafDecisionDagNode Update(LabelSymbol label)
5778public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, bool hasUnionMatching, BoundExpression? whenClause, bool hasErrors = false)
5791public LabelSymbol Label { get; }
5799public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, bool hasUnionMatching, BoundExpression? whenClause)
8087public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, BoundPattern pattern, bool hasUnionMatching, bool isNegated, BoundDecisionDag reachabilityDecisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type, bool hasErrors = false)
8111public LabelSymbol WhenTrueLabel { get; }
8112public LabelSymbol WhenFalseLabel { get; }
8117public BoundIsPatternExpression Update(BoundExpression expression, BoundPattern pattern, bool hasUnionMatching, bool isNegated, BoundDecisionDag reachabilityDecisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type)
11713LabelSymbol label = this.VisitLabelSymbol(node.Label);
11718LabelSymbol label = this.VisitLabelSymbol(node.Label);
11725LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11734LabelSymbol defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11748LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11749LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11757LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11758LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11767LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11768LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11778LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11779LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11819LabelSymbol? finallyLabelOpt = this.VisitLabelSymbol(node.FinallyLabelOpt);
11892LabelSymbol label = this.VisitLabelSymbol(node.Label);
11897LabelSymbol label = this.VisitLabelSymbol(node.Label);
11904LabelSymbol label = this.VisitLabelSymbol(node.Label);
11910LabelSymbol label = this.VisitLabelSymbol(node.Label);
11921LabelSymbol label = this.VisitLabelSymbol(node.Label);
11928LabelSymbol label = this.VisitLabelSymbol(node.Label);
11936LabelSymbol? defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11945LabelSymbol? defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11980LabelSymbol label = this.VisitLabelSymbol(node.Label);
12085LabelSymbol label = this.VisitLabelSymbol(node.Label);
12509LabelSymbol whenTrueLabel = this.VisitLabelSymbol(node.WhenTrueLabel);
12510LabelSymbol whenFalseLabel = this.VisitLabelSymbol(node.WhenFalseLabel);
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (33)
43private readonly PooledDictionary<BoundDecisionDagNode, LabelSymbol> _dagNodeLabels = PooledDictionary<BoundDecisionDagNode, LabelSymbol>.GetInstance();
111protected virtual LabelSymbol GetDagNodeLabel(BoundDecisionDagNode dag)
113if (!_dagNodeLabels.TryGetValue(dag, out LabelSymbol label))
400if (_dagNodeLabels.TryGetValue(node, out LabelSymbol label))
566bool foundLabel = this._dagNodeLabels.TryGetValue(node, out LabelSymbol label);
572var label = GetDagNodeLabel(node);
589var cases = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
608var label = GetDagNodeLabel(node);
620ImmutableArray<(ConstantValue value, LabelSymbol label)> cases,
643(ImmutableArray<(ConstantValue value, LabelSymbol label)> whenTrueCases, ImmutableArray<(ConstantValue value, LabelSymbol label)> whenFalseCases)
644splitCases(ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, BinaryOperatorKind op, ConstantValue value)
646var whenTrueBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
647var whenFalseBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
681LabelSymbol trueLabel = whenTrue.Label;
687LabelSymbol falseLabel = whenFalse.Label;
693LabelSymbol falseLabel = _factory.GenerateLabel("relationalDispatch");
704private sealed class CasesComparer : IComparer<(ConstantValue value, LabelSymbol label)>
713int IComparer<(ConstantValue value, LabelSymbol label)>.Compare((ConstantValue value, LabelSymbol label) left, (ConstantValue value, LabelSymbol label) right)
744LabelSymbol defaultLabel = node.Otherwise;
787ImmutableArray<(ConstantValue value, LabelSymbol label)> cases;
1010var whenExpressionMap = PooledDictionary<BoundExpression, (LabelSymbol LabelToWhenExpression, ArrayBuilder<BoundWhenDecisionDagNode> WhenNodes)>.GetInstance();
1011var whenNodeMap = PooledDictionary<BoundWhenDecisionDagNode, (LabelSymbol LabelToWhenExpression, int WhenNodeIdentifier)>.GetInstance();
1019LabelSymbol labelToWhenExpression;
1070LabelSymbol labelToSectionScope = GetDagNodeLabel(whenNode);
1087void lowerWhenExpressionIfShared(BoundExpression whenExpression, LabelSymbol labelToWhenExpression, ArrayBuilder<BoundWhenDecisionDagNode> whenNodes)
1095var whenTrueLabel = GetDagNodeLabel(whenNodes[0].WhenTrue);
1131void addConditionalGoto(BoundExpression whenExpression, SyntaxNode whenClauseSyntax, LabelSymbol whenTrueLabel, ArrayBuilder<BoundStatement> sectionBuilder)
1161LabelSymbol labelToSectionScope = GetDagNodeLabel(whenClause);
1168var trueLabel = GetDagNodeLabel(whenTrue);