public Worklist Make(CallGraph c1, CallGraph c2, Config cfg) { var c1Roots = SimpleGraph.FindRoots((IEnumerable <ISimpleGraphNode>)c1.GetNodes()).Cast <CallGraphNode>(); var c2Roots = SimpleGraph.FindRoots((IEnumerable <ISimpleGraphNode>)c2.GetNodes()).Cast <CallGraphNode>(); if (c1Roots.Count() != c2Roots.Count()) { Log.Out(Log.Urgent, "Unequal number of nodes at root level in worklist construction"); } //for(int i = 0; i < c1Roots.Count; i++) // c1Roots[i].Name return(null); }
/// <summary> /// The entry point of the RVT decomposition method /// </summary> /// <param name="cg1"></param> /// <param name="cg2"></param> /// <param name="cgP"></param> /// <param name="cfgP"></param> /// <param name="mergedProgramP"></param> /// <param name="fnMap"></param> public static void RVTMain(SDiff.CallGraph cg1, SDiff.CallGraph cg2, SDiff.CallGraph cgP, Config cfgP, Program mergedProgramP, Dictionary <string, string> fnMap) { cg = cgP; mergedProgram = mergedProgramP; cfg = cfgP; funs = new Dictionary <string, string>(fnMap); eqProcsCreated = new Dictionary <string, Duple <Duple <Procedure, Implementation>, List <Variable> > >(); //compute the cg sizes int cg1size, cg2size; var cg1Nodes = cg1.GetNodes(); var cg2Nodes = cg2.GetNodes(); cg1size = cg1Nodes.Count(); cg2size = cg2Nodes.Count(); //create the mapping from fn --> index fnNameToIndex1 = new Dictionary <string, int>(); fnIndexToName1 = new Dictionary <int, string>(); fnNameToIndex2 = new Dictionary <string, int>(); fnIndexToName2 = new Dictionary <int, string>(); int count = 0; string[] s1 = new string[cg1Nodes.Count()], s2 = new string[cg1Nodes.Count + cg2Nodes.Count()]; foreach (var cgNode in cg1Nodes) { var fnName = cgNode.Proc.Name; fnNameToIndex1.Add(fnName, count); fnIndexToName1.Add(count, fnName); s1[count] = RemoveVersionPrefix(fnName); count++; } //We want the indices to be distinct foreach (var cgNode in cg2Nodes) { var fnName = cgNode.Proc.Name; fnNameToIndex2.Add(fnName, count); fnIndexToName2.Add(count, fnName); s2[count] = RemoveVersionPrefix(fnName); count++; } //create the edge list List <Tuple <int, int> > edgeList1, edgeList2; edgeList1 = new List <Tuple <int, int> >(); edgeList2 = new List <Tuple <int, int> >(); foreach (var cgNode in cg1Nodes) { var src = cgNode.Proc.Name; var srcIdx = fnNameToIndex1[src]; var callees = cgNode.Callees; foreach (var callee in callees) { var dest = callee.Proc.Name; var destIdx = fnNameToIndex1[dest]; var edge = new Tuple <int, int>(srcIdx, destIdx); edgeList1.Add(edge); } } foreach (var cgNode in cg2Nodes) { var src = cgNode.Proc.Name; var srcIdx = fnNameToIndex2[src]; var callees = cgNode.Callees; foreach (var callee in callees) { var dest = callee.Proc.Name; var destIdx = fnNameToIndex2[dest]; var edge = new Tuple <int, int>(srcIdx, destIdx); edgeList2.Add(edge); } } //call the Decomposer List <int> synEq = new List <int>(); List <Tuple <int, int> > fnMapIndex = new List <Tuple <int, int> >(); fnMapIndexDict = new Dictionary <int, int>(); List <int> empty1 = new List <int>(), empty2 = new List <int>(); foreach (var fnPair in fnMap) { var left = fnNameToIndex1[fnPair.Key]; var right = fnNameToIndex2[fnPair.Value]; var lr = new Tuple <int, int>(left, right); //Add the same uninterpreted function by default Procedure leftP = cg.NodeOfName(fnPair.Key).Proc; Procedure rightP = cg.NodeOfName(fnPair.Value).Proc; InjectUIFsOnBothProcs(leftP, rightP); if (RVTCreateEQProcs(left, ref synEq, ref empty1, ref empty2)) { //add the mapping if the eq generation succeeded //HACK!!! should be filtered from the list given to RVT fnMapIndex.Add(lr); fnMapIndexDict.Add(left, right); } } // marking functions that were originated from loops (these will be marked differently in the dotty graphs) List <int> loop_functions_1, loop_functions_2; loop_functions_1 = new List <int>(); loop_functions_2 = new List <int>(); foreach (var cgNode in cg1Nodes) { string src = cgNode.Proc.Name; if (src.Contains(Options.LoopStringIdentifier)) { loop_functions_1.Add(fnNameToIndex1[src]); } } foreach (var cgNode in cg2Nodes) { string src = cgNode.Proc.Name; if (src.Contains(Options.LoopStringIdentifier)) { loop_functions_2.Add(fnNameToIndex2[src]); } } //RunRVTDecomposer(cg1size, cg2size, edgeList1, edgeList2, fnMapIndex, synEq); DECOMPOSE_CS.RVT_Decompose.Decompose_main(cg1size, cg1size + cg2size, edgeList1, edgeList2, loop_functions_1, loop_functions_2, fnMapIndex, synEq, empty1, empty2, s1, s2); }