Example #1
0
        private ReachingSet AnalyzeNode(TaggedEdge <CFGBlock, EdgeTag> edge)
        {
            if (ReachingSetDictionary[edge.Source] == null)
            {
                ReachingSetDictionary = ReachingSetDictionary.SetItem(edge.Source, new ReachingSet());
            }
            if (ReachingSetDictionary[edge.Target] == null)
            {
                ReachingSetDictionary = ReachingSetDictionary.SetItem(edge.Target, new ReachingSet());
            }

            var node = edge.Target;

            // IN:
            //    U   RD_OUT(l')
            // (l'~>l)
            ReachingSetDictionary = ReachingSetDictionary.SetItem(node,
                                                                  ReachingSetDictionary[node].AddInVarRange(ReachingSetDictionary[edge.Source].DefinedOutVars, true));

            // OUT:
            // (RD_IN(l) \ kill(l)) U gen(l)
            var Out = ReachingSetDictionary[node];

            Out = Out.AddOutVarRange(ReachingSetDictionary[node].DefinedInVars);
            XmlTraverser      xmlTraverser = new XmlTraverser();
            CFGASTNodeVisitor nodeVisitor  = new CFGASTNodeVisitor();

            xmlTraverser.AddVisitor(nodeVisitor);

            if (node.AstEntryNode != null)
            {
                var nodeToTraverse = Conditional.HasConditionNode(node.AstEntryNode) ? Conditional.GetCondNode(node.AstEntryNode)
                                                                                     : node.AstEntryNode;
                xmlTraverser.Traverse(nodeToTraverse);

                foreach (var currNode in nodeVisitor.NodesOfInterest)
                {
                    var varNode = AstNodeInfo.GetVarNameXmlNode(currNode);

                    ValueInfo varInfo = new ValueInfo()
                    {
                        Block = node
                    };
                    varInfo = VariableInfoComposer.AnalyzeBlock(varInfo);
                    var gs = new Variable(AstNodeInfo.GetVarNameXmlNode(currNode).Name, VariableScope.Unknown);
                    gs = gs.AddVarInfo(varInfo);

                    Out = Out.AddOutVar(varNode.InnerText, gs);
                }
            }
            ReachingSetDictionary = ReachingSetDictionary.SetItem(node, ReachingSetDictionary[node].AddOutVarRange(Out.DefinedOutVars));

            return(ReachingSetDictionary[node]);
        }