Esempio n. 1
0
        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
            });
        }
Esempio n. 3
0
        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
            });
        }
Esempio n. 5
0
        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;
                }
            }
        }
Esempio n. 6
0
        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;
                }
            }
        }