예제 #1
0
 protected virtual void VisitBranchBlock(BranchBlock branchBlock, ExplodedGraphNode node)
 {
     var newProgramState = node.ProgramState;
     if (IsValueConsumingStatement(branchBlock.BranchingNode))
     {
         newProgramState = newProgramState.PopValue();
     }
     newProgramState = CleanStateAfterBlock(newProgramState, branchBlock);
     EnqueueAllSuccessors(branchBlock, newProgramState);
 }
예제 #2
0
        private BranchBlock CreateBranchBlock(Node expression, Block trueBlock, Block falseBlock, BranchBlockType type)
        {
            var block = new BranchBlock
            {
                Index      = NextBlockId(),
                Expression = expression,
                TrueBlock  = trueBlock,
                FalseBlock = falseBlock,
                Parents    = new List <Block>(), // { CurrentBlock }
                Type       = type
            };

            _blocks.Add(block);

            return(block);
        }
예제 #3
0
        private static SyntaxNode GetCondition(BranchBlock bbb)
        {
            // For an if or a while, bbb.BranchingNode represent the condition, not the statement that holds the condition
            // For a for, bbb.BranchingNode represents the for. Since for is a statement, not an expression, if we
            // see a for, we know it's at the top level of the expression tree, so it cannot be a for inside of a if condition
            switch (bbb.BranchingNode.Kind())
            {
            case SyntaxKind.ForStatement:
                var forStmt = bbb.BranchingNode as ForStatementSyntax;
                return(forStmt.Condition);

            case SyntaxKind.ForEachStatement:
                Debug.Assert(false, "Not ready to handle those");
                return(null);

            default:
                return(bbb.BranchingNode);
            }
        }