コード例 #1
0
ファイル: Statement.cs プロジェクト: binarybird/Cascade
        public override Evaluation VisitFixedStatement(FixedStatementSyntax node)
        {
            node.Declaration?.Accept <Evaluation>(this);
            node.Statement?.Accept <Evaluation>(this);

            return(base.VisitFixedStatement(node));
        }
コード例 #2
0
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            base.VisitFixedStatement(node);
            StatementsAnalyzer statementsAnalyzer = this;

            statementsAnalyzer.counter = checked (statementsAnalyzer.counter + 1);
        }
コード例 #3
0
 protected override void VisitFixedStatementDeclarations(FixedStatementSyntax node)
 {
     foreach (var declarator in node.Declaration.Variables)
     {
         this.builder.Add(declarator);
     }
 }
コード例 #4
0
ファイル: SyntaxExtensions.cs プロジェクト: mikem8361/runtime
        private static FixedStatementSyntax AddStatementWithoutEmptyStatements(this FixedStatementSyntax fixedStatement, StatementSyntax childStatement)
        {
            if (fixedStatement.Statement.IsKind(SyntaxKind.EmptyStatement))
            {
                return(fixedStatement.WithStatement(childStatement));
            }

            BlockSyntax block;

            if (fixedStatement.Statement.IsKind(SyntaxKind.Block))
            {
                block = (BlockSyntax)fixedStatement.Statement;
                if (block.Statements.Count == 0)
                {
                    return(fixedStatement.WithStatement(childStatement));
                }
            }
            else
            {
                block = SyntaxFactory.Block(fixedStatement.Statement);
            }

            if (childStatement.IsKind(SyntaxKind.Block))
            {
                block = block.WithStatements(block.Statements.AddRange(((BlockSyntax)childStatement).Statements));
            }
            else
            {
                block = block.AddStatements(childStatement);
            }

            return(fixedStatement.WithStatement(block));
        }
コード例 #5
0
        public static Doc Print(FixedStatementSyntax node)
        {
            var groupId = Guid.NewGuid().ToString();

            return(Doc.Concat(
                       ExtraNewLines.Print(node),
                       Token.PrintLeadingTrivia(node.FixedKeyword),
                       Doc.Group(
                           Token.PrintWithoutLeadingTrivia(node.FixedKeyword),
                           " ",
                           Token.Print(node.OpenParenToken),
                           Doc.GroupWithId(
                               groupId,
                               Doc.Indent(Doc.SoftLine, Node.Print(node.Declaration)),
                               Doc.SoftLine
                               ),
                           Token.Print(node.CloseParenToken),
                           Doc.IfBreak(Doc.Null, Doc.SoftLine)
                           ),
                       node.Statement
                       is BlockSyntax blockSyntax
                    ? Block.PrintWithConditionalSpace(blockSyntax, groupId)
                    : Node.Print(node.Statement)
                       ));
        }
コード例 #6
0
            protected override void VisitFixedStatementDeclarations(FixedStatementSyntax node)
            {
                // Expecting N variable locals followed by N temporaries.
                var declarators = node.Declaration.Variables;
                int n           = declarators.Count;
                int startOffset = this.offset;

                for (int i = 0; i < n; i++)
                {
                    var declarator = declarators[i];
                    TryGetSlotIndex(declarator.Identifier.ValueText);
                    this.offset++;
                }

                int endOffset = this.offset;

                this.offset = startOffset;
                for (int i = 0; i < n; i++)
                {
                    var declarator = declarators[i];
                    if (!IsSlotIndex(TempKind.FixedString))
                    {
                        break;
                    }
                    AddLocal(TempKind.FixedString);
                    this.offset++;
                }

                Debug.Assert(this.offset <= endOffset);
                this.offset = endOffset;
            }
コード例 #7
0
ファイル: Statement.cs プロジェクト: binarybird/Cascade
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            node.Declaration?.Accept(this);
            node.Statement?.Accept(this);

            base.VisitFixedStatement(node);
        }
コード例 #8
0
        private void BuildFixedStatement(FixedStatementSyntax fixedStatement)
        {
            currentBlock = CreateBlock(currentBlock);
            BuildStatement(fixedStatement.Statement);

            currentBlock = CreateJumpBlock(fixedStatement, currentBlock);
            BuildVariableDeclaration(fixedStatement.Declaration);
        }
コード例 #9
0
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            var binder = new FixedStatementBinder(this.method, enclosing, node);

            AddToMap(node, binder);

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }
コード例 #10
0
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            using (Context.WithFlag("fixed"))
            {
                HandleVariableDeclaration(node.Declaration);
            }

            Visit(node.Statement);
        }
コード例 #11
0
ファイル: LocalScopeBinder.cs プロジェクト: SkightTeam/roslyn
            public override void VisitFixedStatement(FixedStatementSyntax node)
            {
                if (RootStmtOpt != node)
                {
                    return;
                }

                Visit(node.Declaration);
            }
コード例 #12
0
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            Debug.Assert((object)_method == _enclosing.ContainingMemberOrLambda);
            var binder = new FixedStatementBinder(_enclosing, node);

            AddToMap(node, binder);

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }
コード例 #13
0
 public override void VisitFixedStatement(FixedStatementSyntax node)
 {
     if (entryPoint.IsMethodLevel() && node.IsParent <AnonymousFunctionExpressionSyntax>())
     {
         return;
     }
     noscounter++;
     base.VisitFixedStatement(node);
 }
コード例 #14
0
        public static bool ContainsEmbeddedStatement(FixedStatementSyntax fixedStatement)
        {
            if (fixedStatement == null)
            {
                throw new ArgumentNullException(nameof(fixedStatement));
            }

            return(fixedStatement.Statement?.IsKind(SyntaxKind.Block) == false);
        }
                public override SyntaxNode VisitFixedStatement(FixedStatementSyntax node)
                {
                    if (node != this.ContainerOfStatementsOrFieldToReplace)
                    {
                        return(base.VisitFixedStatement(node));
                    }

                    return(node.WithDeclaration(VisitNode(node.Declaration))
                           .WithStatement(ReplaceStatementIfNeeded(node.Statement)));
                }
コード例 #16
0
ファイル: Core.cs プロジェクト: xdrie/SharpNative
        public static void WriteFixedStatement(OutputWriter writer, FixedStatementSyntax statement)
        {
//          writer.WriteIndent();
            writer.WriteLine("//fixed() Scope");
            writer.OpenBrace();
            Write(writer, statement.Declaration);
            Write(writer, statement.Statement);
            writer.CloseBrace();
//          writer.Write(";\r\n");
        }
コード例 #17
0
 private Doc PrintFixedStatementSyntax(FixedStatementSyntax node)
 {
     return(Concat(
                this.PrintSyntaxToken(node.FixedKeyword, " "),
                this.PrintSyntaxToken(node.OpenParenToken),
                this.Print(node.Declaration),
                this.PrintSyntaxToken(node.CloseParenToken),
                this.Print(node.Statement)
                ));
 }
コード例 #18
0
 public override void VisitFixedStatement(FixedStatementSyntax node)
 {
     if (entryPoint.IsMethodLevel() && node.IsParent <AnonymousFunctionExpressionSyntax>())
     {
         return;
     }
     IncreaseHeight();
     EmbeddednessConsideredToIncrease();
     base.VisitFixedStatement(node);
     currentNL--;
     EmbeddednessConsideredToDecrease();
 }
コード例 #19
0
ファイル: LLOC.cs プロジェクト: smartshark/OpenStaticAnalyzer
 public override void VisitFixedStatement(FixedStatementSyntax node)
 {
     if (entryNode is AnonymousFunctionExpressionSyntax && embeddedNode is AnonymousFunctionExpressionSyntax)
     {
         return;
     }
     if (_weComeFromMethod && _weInAnonymousMethod)
     {
         return;
     }
     InsertLLOCMap(node.GetLocation());
     base.VisitFixedStatement(node);
 }
コード例 #20
0
        public override LuaSyntaxNode VisitFixedStatement(FixedStatementSyntax node)
        {
            LuaStatementListSyntax statements = new LuaStatementListSyntax();

            statements.Statements.Add(new LuaShortCommentStatement(" " + node.FixedKeyword));
            LuaBlockStatementSyntax block = new LuaBlockStatementSyntax();
            var declaration = (LuaStatementSyntax)node.Declaration.Accept(this);

            block.Statements.Add(declaration);
            WriteStatementOrBlock(node.Statement, block);
            statements.Statements.Add(block);
            return(statements);
        }
コード例 #21
0
ファイル: StatementVisitor.cs プロジェクト: Yikez978/PT.PM
        public override UstNode VisitFixedStatement(FixedStatementSyntax node)
        {
            var statements = new List <Statement>();

            var varDec = (VariableDeclarationExpression)VisitVariableDeclaration(node.Declaration);

            statements.Add(new ExpressionStatement(varDec));
            statements.AddRange(GetChildStatements(node.Statement));

            var result = new BlockStatement(statements, node.GetTextSpan(), FileNode);

            return(result);
        }
コード例 #22
0
ファイル: Statement.cs プロジェクト: binarybird/Cascade
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            if (!PreVisit(node))
            {
                return;
            }

            node.Declaration?.Accept(this);
            node.Statement?.Accept(this);

            base.VisitFixedStatement(node);

            PostVisit(node);
        }
コード例 #23
0
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            var binder = new FixedStatementBinder(_enclosing, node);

            AddToMap(node, binder);

            if (node.Declaration != null)
            {
                Visit(node.Declaration, binder);
            }

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }
コード例 #24
0
ファイル: BlockStatements.cs プロジェクト: kobi2187/CsDisplay
 public override void VisitFixedStatement(FixedStatementSyntax node)
 {
     if (debug)
     {
         Console.WriteLine(node.ToFullString());
     }
     Todo("FixedStatement"); var nl = OurLine.NewLine(LineKind.Decl, "FixedStatement");
     nl.Source     = node.ToFullString();
     nl.ParentKind = node.Parent.RawKind;
     nl.RawKind    = node.RawKind;
     LogCommand(nl);
     StartBlock("FixedStatement");
     base.VisitFixedStatement(node);
     EndBlock("FixedStatement");
 }
コード例 #25
0
        async Task <Solution> AddAdressOfOperator(Document document, FixedStatementSyntax fixedStatement, CancellationToken cancellationToken)
        {
            var root = await document.GetSyntaxRootAsync().ConfigureAwait(false);

            var declaratorList = new SeparatedSyntaxList <VariableDeclaratorSyntax>();

            foreach (var variable in fixedStatement.Declaration.Variables)
            {
                var declarator = CreateDeclarator(variable);
                declaratorList = declaratorList.Add(declarator);
            }
            var fixedDeclaration = SyntaxFactory.VariableDeclaration(fixedStatement.Declaration.Type, declaratorList);

            root = root.ReplaceNode(fixedStatement.Declaration, fixedDeclaration);
            return(document.Project.Solution.WithDocumentSyntaxRoot(document.Id, root));
        }
コード例 #26
0
ファイル: SyntaxExtensions.cs プロジェクト: naricc/runtime
 private static FixedStatementSyntax AddStatementWithoutEmptyStatements(this FixedStatementSyntax fixedStatement, StatementSyntax childStatement)
 {
     if (fixedStatement.Statement.IsKind(SyntaxKind.EmptyStatement))
     {
         return(fixedStatement.WithStatement(childStatement));
     }
     if (fixedStatement.Statement.IsKind(SyntaxKind.Block))
     {
         var block = (BlockSyntax)fixedStatement.Statement;
         if (block.Statements.Count == 0)
         {
             return(fixedStatement.WithStatement(childStatement));
         }
         return(fixedStatement.WithStatement(block.AddStatements(childStatement)));
     }
     return(fixedStatement.WithStatement(SyntaxFactory.Block(fixedStatement.Statement, childStatement)));
 }
コード例 #27
0
ファイル: SA1503.cs プロジェクト: grokys/StyleCopMagic
        public override SyntaxNode VisitFixedStatement(FixedStatementSyntax node)
        {
            node = (FixedStatementSyntax)base.VisitFixedStatement(node);

            if (!node.CloseParenToken.IsMissing && node.Statement.Kind != SyntaxKind.Block)
            {
                return CodeAnnotations.Formatting.AddAnnotationTo(
                    Syntax.FixedStatement(
                        node.FixedKeyword,
                        node.OpenParenToken,
                        node.Declaration,
                        node.CloseParenToken,
                        WrapStatementWithBlock(node.Statement)));
            }
            else
            {
                return node;
            }
        }
コード例 #28
0
ファイル: LocalBinderFactory.cs プロジェクト: zuvys/roslyn
        public override void VisitFixedStatement(FixedStatementSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            var binder = new FixedStatementBinder(_enclosing, node);

            AddToMap(node, binder);

            if (node.Declaration != null)
            {
                VisitRankSpecifiers(node.Declaration.Type, binder);

                foreach (VariableDeclaratorSyntax declarator in node.Declaration.Variables)
                {
                    Visit(declarator, binder);
                }
            }

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }
コード例 #29
0
        public static bool IsCloseParenInStatement(this SyntaxToken token)
        {
            if (!(token.Parent is StatementSyntax statement))
            {
                return(false);
            }

            return(statement switch
            {
                IfStatementSyntax ifStatement => ifStatement.CloseParenToken.Equals(token),
                SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
                WhileStatementSyntax whileStatement => whileStatement.CloseParenToken.Equals(token),
                DoStatementSyntax doStatement => doStatement.CloseParenToken.Equals(token),
                ForStatementSyntax forStatement => forStatement.CloseParenToken.Equals(token),
                CommonForEachStatementSyntax foreachStatement => foreachStatement.CloseParenToken.Equals(token),
                LockStatementSyntax lockStatement => lockStatement.CloseParenToken.Equals(token),
                UsingStatementSyntax usingStatement => usingStatement.CloseParenToken.Equals(token),
                FixedStatementSyntax fixedStatement => fixedStatement.CloseParenToken.Equals(token),
                _ => false,
            });
コード例 #30
0
 public FixedStatementBinder(Binder enclosing, FixedStatementSyntax syntax)
     : base(enclosing)
 {
     Debug.Assert(syntax != null);
     _syntax = syntax;
 }
コード例 #31
0
        private Block BuildFixedStatement(FixedStatementSyntax fixedStatement, Block currentBlock)
        {
            var fixedStatementBlock = BuildStatement(fixedStatement.Statement, CreateBlock(currentBlock));

            return(BuildVariableDeclaration(fixedStatement.Declaration, CreateJumpBlock(fixedStatement, fixedStatementBlock)));
        }
コード例 #32
0
 public FixedBinder(FixedStatementSyntax syntax, MethodSymbol owner, Binder enclosing)
     : base(owner, enclosing)
 {
     this.syntax = syntax;
 }