コード例 #1
0
ファイル: SwitchLabel.cs プロジェクト: xydoublez/cs2cpp
        internal bool Parse(SourceLabelSymbol sourceLabelSymbol)
        {
            if (sourceLabelSymbol == null)
            {
                throw new ArgumentNullException();
            }

            base.Parse(sourceLabelSymbol);
            Value = sourceLabelSymbol.SwitchCaseLabelConstant;
            return(Value != null);
        }
コード例 #2
0
        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
            });
        }
コード例 #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;
            }
        }
コード例 #4
0
        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
            });
        }
コード例 #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;
                }
            }
        }
コード例 #6
0
ファイル: LocalScopeBinder.cs プロジェクト: SkightTeam/roslyn
        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;
                }
            }
        }