internal bool Parse(SourceLabelSymbol sourceLabelSymbol) { if (sourceLabelSymbol == null) { throw new ArgumentNullException(); } base.Parse(sourceLabelSymbol); Value = sourceLabelSymbol.SwitchCaseLabelConstant; return(Value != null); }
public BoundSwitchSection SwitchSection(int value, params BoundStatement[] statements) { var label = new SourceLabelSymbol(CurrentMethod, ConstantValue.Create(value)); var switchLabel = new BoundSwitchLabel(Syntax, label) { WasCompilerGenerated = true }; return(new BoundSwitchSection(Syntax, ImmutableArray.Create <BoundSwitchLabel>(switchLabel), ImmutableArray.Create <BoundStatement>(statements)) { WasCompilerGenerated = true }); }
internal static void BuildLabels(MethodSymbol containingMethod, StatementSyntax statement, ref ArrayBuilder <LabelSymbol> labels) { while (statement.Kind() == SyntaxKind.LabeledStatement) { var labeledStatement = (LabeledStatementSyntax)statement; if (labels == null) { labels = ArrayBuilder <LabelSymbol> .GetInstance(); } var labelSymbol = new SourceLabelSymbol(containingMethod, labeledStatement.Identifier); labels.Add(labelSymbol); statement = labeledStatement.Statement; } }
public BoundSwitchSection SwitchSection(List <int> values, params BoundStatement[] statements) { var builder = ArrayBuilder <BoundSwitchLabel> .GetInstance(); foreach (var i in values) { var label = new SourceLabelSymbol(CurrentMethod, ConstantValue.Create(i)); builder.Add(new BoundSwitchLabel(Syntax, label) { WasCompilerGenerated = true }); } return(new BoundSwitchSection(Syntax, builder.ToImmutableAndFree(), ImmutableArray.Create <BoundStatement>(statements)) { WasCompilerGenerated = true }); }
protected void BuildLabels(SyntaxList <StatementSyntax> statements, ref ArrayBuilder <LabelSymbol> labels) { foreach (var statement in statements) { var stmt = statement; while (stmt.Kind == SyntaxKind.LabeledStatement) { var labeledStatement = (LabeledStatementSyntax)stmt; if (labels == null) { labels = ArrayBuilder <LabelSymbol> .GetInstance(); } var labelSymbol = new SourceLabelSymbol(this.Owner, labeledStatement.Identifier); labels.Add(labelSymbol); stmt = labeledStatement.Statement; } } }
protected void BuildLabels(SyntaxList <StatementSyntax> statements, ref ArrayBuilder <LabelSymbol> labels) { var containingMethod = (MethodSymbol)this.ContainingMemberOrLambda; foreach (var statement in statements) { var stmt = statement; while (stmt.Kind == SyntaxKind.LabeledStatement) { var labeledStatement = (LabeledStatementSyntax)stmt; if (labels == null) { labels = ArrayBuilder <LabelSymbol> .GetInstance(); } var labelSymbol = new SourceLabelSymbol(containingMethod, labeledStatement.Identifier); labels.Add(labelSymbol); stmt = labeledStatement.Statement; } } }