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)
1251LabelSymbol fallThroughLabel,
1342LabelSymbol fallThroughLabel,
1382void emitLengthDispatch(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1419void emitCharDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1460void emitFinalDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, TypeSymbol keyType, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1487LabelSymbol fallThroughLabel,
1940private Dictionary<LabelSymbol, GeneratedLabelSymbol> _labelClones;
1987var casesBuilder = ArrayBuilder<(ConstantValue, LabelSymbol)>.GetInstance();
2009private GeneratedLabelSymbol GetLabelClone(LabelSymbol label)
2014_labelClones = labelClones = new Dictionary<LabelSymbol, GeneratedLabelSymbol>();
FlowAnalysis\AbstractFlowPass.cs (11)
79private readonly PooledDictionary<LabelSymbol, TLocalState> _labels;
210_labels = PooledDictionary<LabelSymbol, TLocalState>.GetInstance();
399public readonly LabelSymbol? Label;
402public PendingBranch(BoundNode branch, TLocalState state, LabelSymbol label, bool isConditionalState = false, TLocalState stateWhenTrue = default, TLocalState stateWhenFalse = default)
513protected virtual TLocalState LabelState(LabelSymbol label)
722private void ResolveBreaks(TLocalState breakState, LabelSymbol label)
731private void ResolveContinues(LabelSymbol continueLabel)
744private void JoinPendingBranches(ref TLocalState state, LabelSymbol label)
772private bool ResolveBranches(LabelSymbol label, BoundStatement? target)
791protected virtual void ResolveBranch(PendingBranch pending, LabelSymbol label, BoundStatement? target, ref bool labelStateChanged)
3373protected void VisitLabel(LabelSymbol label, BoundStatement node)
FlowAnalysis\NullableWalker_Patterns.cs (5)
374private PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> LearnFromDecisionDag(
416var labelStateMap = PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)>.GetInstance();
987PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap,
1032PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap,
1044LocalState getStateForArm(BoundSwitchExpressionArm arm, PooledDictionary<LabelSymbol, (LocalState state, bool believedReachable)> labelStateMap)
Generated\BoundNodes.xml.Generated.cs (108)
3688public BoundBreakStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
3697public BoundBreakStatement(SyntaxNode syntax, LabelSymbol label)
3706public LabelSymbol Label { get; }
3711public BoundBreakStatement Update(LabelSymbol label)
3725public BoundContinueStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
3734public BoundContinueStatement(SyntaxNode syntax, LabelSymbol label)
3743public LabelSymbol Label { get; }
3748public BoundContinueStatement Update(LabelSymbol label)
3762public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, ImmutableArray<LocalSymbol> innerLocals, ImmutableArray<MethodSymbol> innerLocalFunctions, ImmutableArray<BoundSwitchSection> switchSections, BoundDecisionDag reachabilityDecisionDag, BoundSwitchLabel? defaultLabel, LabelSymbol breakLabel, bool hasErrors = false)
3788public LabelSymbol BreakLabel { get; }
3793public BoundSwitchStatement Update(BoundExpression expression, ImmutableArray<LocalSymbol> innerLocals, ImmutableArray<MethodSymbol> innerLocalFunctions, ImmutableArray<BoundSwitchSection> switchSections, BoundDecisionDag reachabilityDecisionDag, BoundSwitchLabel? defaultLabel, LabelSymbol breakLabel)
3807public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false)
3822public ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases { get; }
3823public LabelSymbol DefaultLabel { get; }
3829public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt)
3876protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors)
3887protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, LabelSymbol breakLabel, LabelSymbol continueLabel)
3898public LabelSymbol BreakLabel { get; }
3899public LabelSymbol ContinueLabel { get; }
3904protected BoundConditionalLoopStatement(BoundKind kind, SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
3926public BoundDoStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
3942public BoundDoStatement Update(ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
3956public BoundWhileStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
3972public BoundWhileStatement Update(ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
3986public BoundForStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> outerLocals, BoundStatement? initializer, ImmutableArray<LocalSymbol> innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4014public BoundForStatement Update(ImmutableArray<LocalSymbol> outerLocals, BoundStatement? initializer, ImmutableArray<LocalSymbol> innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4028public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo? enumeratorInfoOpt, BoundValuePlaceholder? elementPlaceholder, BoundExpression? elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray<LocalSymbol> iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, BoundAwaitableInfo? awaitOpt, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel, bool hasErrors = false)
4065public BoundForEachStatement Update(ForEachEnumeratorInfo? enumeratorInfoOpt, BoundValuePlaceholder? elementPlaceholder, BoundExpression? elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray<LocalSymbol> iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, BoundAwaitableInfo? awaitOpt, BoundStatement body, LabelSymbol breakLabel, LabelSymbol continueLabel)
4214public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler, bool hasErrors = false)
4231public LabelSymbol? FinallyLabelOpt { get; }
4237public BoundTryStatement Update(BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler)
4664public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
4673public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label)
4682public LabelSymbol Label { get; }
4687public BoundLabelStatement Update(LabelSymbol label)
4701public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt, bool hasErrors = false)
4712public LabelSymbol Label { get; }
4719public BoundGotoStatement Update(LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt)
4733public BoundLabeledStatement(SyntaxNode syntax, LabelSymbol label, BoundStatement body, bool hasErrors = false)
4744public LabelSymbol Label { get; }
4750public BoundLabeledStatement Update(LabelSymbol label, BoundStatement body)
4764public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type, bool hasErrors)
4773public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type)
4782public LabelSymbol Label { get; }
4787public BoundLabel Update(LabelSymbol label, TypeSymbol? type)
4838public BoundConditionalGoto(SyntaxNode syntax, BoundExpression condition, bool jumpIfTrue, LabelSymbol label, bool hasErrors = false)
4852public LabelSymbol Label { get; }
4857public BoundConditionalGoto Update(BoundExpression condition, bool jumpIfTrue, LabelSymbol label)
4871protected BoundSwitchExpression(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
4889public LabelSymbol? DefaultLabel { get; }
4895public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false)
4915public LabelSymbol Label { get; }
4920public BoundSwitchExpressionArm Update(ImmutableArray<LocalSymbol> locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label)
4934public BoundUnconvertedSwitchExpression(SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
4948public BoundUnconvertedSwitchExpression Update(BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type)
4962public BoundConvertedSwitchExpression(SyntaxNode syntax, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol type, bool hasErrors = false)
4982public BoundConvertedSwitchExpression Update(TypeSymbol? naturalTypeOpt, bool wasTargetTyped, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol type)
5138public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
5147public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label)
5156public LabelSymbol Label { get; }
5161public BoundLeafDecisionDagNode Update(LabelSymbol label)
5682public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause, bool hasErrors = false)
5694public LabelSymbol Label { get; }
5701public BoundSwitchLabel Update(LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause)
7939public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, BoundPattern pattern, bool isNegated, BoundDecisionDag reachabilityDecisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type, bool hasErrors = false)
7961public LabelSymbol WhenTrueLabel { get; }
7962public LabelSymbol WhenFalseLabel { get; }
7967public BoundIsPatternExpression Update(BoundExpression expression, BoundPattern pattern, bool isNegated, BoundDecisionDag reachabilityDecisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type)
11421LabelSymbol label = this.VisitLabelSymbol(node.Label);
11426LabelSymbol label = this.VisitLabelSymbol(node.Label);
11433LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11442LabelSymbol defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11456LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11457LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11465LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11466LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11475LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11476LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11486LabelSymbol breakLabel = this.VisitLabelSymbol(node.BreakLabel);
11487LabelSymbol continueLabel = this.VisitLabelSymbol(node.ContinueLabel);
11528LabelSymbol? finallyLabelOpt = this.VisitLabelSymbol(node.FinallyLabelOpt);
11601LabelSymbol label = this.VisitLabelSymbol(node.Label);
11606LabelSymbol label = this.VisitLabelSymbol(node.Label);
11613LabelSymbol label = this.VisitLabelSymbol(node.Label);
11619LabelSymbol label = this.VisitLabelSymbol(node.Label);
11630LabelSymbol label = this.VisitLabelSymbol(node.Label);
11637LabelSymbol label = this.VisitLabelSymbol(node.Label);
11645LabelSymbol? defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11654LabelSymbol? defaultLabel = this.VisitLabelSymbol(node.DefaultLabel);
11689LabelSymbol label = this.VisitLabelSymbol(node.Label);
11789LabelSymbol label = this.VisitLabelSymbol(node.Label);
12208LabelSymbol whenTrueLabel = this.VisitLabelSymbol(node.WhenTrueLabel);
12209LabelSymbol 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;
1002var whenExpressionMap = PooledDictionary<BoundExpression, (LabelSymbol LabelToWhenExpression, ArrayBuilder<BoundWhenDecisionDagNode> WhenNodes)>.GetInstance();
1003var whenNodeMap = PooledDictionary<BoundWhenDecisionDagNode, (LabelSymbol LabelToWhenExpression, int WhenNodeIdentifier)>.GetInstance();
1011LabelSymbol labelToWhenExpression;
1062LabelSymbol labelToSectionScope = GetDagNodeLabel(whenNode);
1079void lowerWhenExpressionIfShared(BoundExpression whenExpression, LabelSymbol labelToWhenExpression, ArrayBuilder<BoundWhenDecisionDagNode> whenNodes)
1087var whenTrueLabel = GetDagNodeLabel(whenNodes[0].WhenTrue);
1123void addConditionalGoto(BoundExpression whenExpression, SyntaxNode whenClauseSyntax, LabelSymbol whenTrueLabel, ArrayBuilder<BoundStatement> sectionBuilder)
1153LabelSymbol labelToSectionScope = GetDagNodeLabel(whenClause);
1160var trueLabel = GetDagNodeLabel(whenTrue);