Exemplo n.º 1
0
        //HashSet<CFGBlock> CnodesVisited = new HashSet<CFGBlock>();
        private CTLLTLNode MakeCNode(CFGBlock block)
        {
            var v = Stopwatch.StartNew();
            if (nodeList.Exists (x => x.block == block))
                return null;
            v.Stop();

            var cNode = new CTLLTLNode ();
            cNode.block = block;
            GetBlockName (cNode);
            cNode.nodeName = nodeList.Count + 1 + "";
            nodeList.Add (cNode);
            //CnodesVisited.Add(cNode.block);
            if (cNode.block.AstEntryNode != null && (nodeList.Count % 1000) == 0)
                Console.WriteLine("Added node: " + cNode.block.AstEntryNode.LocalName + " total in list: " + nodeList.Count + " Loop took: " + v.Elapsed);
            return cNode;
        }
Exemplo n.º 2
0
        private void GetBlockName(CTLLTLNode block)
        {
            string nodeName = (nodeList.Count + 1).ToString ();
            if (block.block.IsSpecialBlock || block.block.AstEntryNode == null) {

            } else {
                switch (block.block.AstEntryNode.LocalName) {
                case (AstConstants.Nodes.Expr_FuncCall):
                case (AstConstants.Nodes.Expr_MethodCall):
                    string methodName = "";
                    try{methodName = block.block.AstEntryNode.GetSubNode (AstConstants.Subnode + ":" + AstConstants.Subnodes.Name).FirstChild.GetSubNode (AstConstants.Subnode + ":" + AstConstants.Subnodes.Parts).InnerText;} catch (Exception e){};
                    if (methodName == "add_filter") {
                        var filterName = block.block.AstEntryNode.GetSubNode (AstConstants.Subnode + ":" + AstConstants.Subnodes.Args)
                            .FirstChild.FirstChild
                            .GetSubNode (AstConstants.Subnode + ":" + AstConstants.Subnodes.Value).FirstChild.LastChild.InnerText;
                        block.methodName = methodName;
                        block.filterName = filterName;
                        filterList.Add (filterName);
                    } else
                        block.methodName = methodName;
                    nodeName = nodeName + "Call_" + block.methodName;
                    break;
                default:
                    nodeName = nodeName + block.block.AstEntryNode.LocalName.ToLower ();
                    break;
                }
                //Handle the harder cases!
            }
            block.nodeName = nodeName;
        }