void DoIt() { graph = new LGSPGraph(new ProgramGraphsOriginalGraphModel()); actions = new ProgramGraphsOriginalActions(graph); procEnv = new LGSPGraphProcessingEnvironment(graph, actions); // use new exact 2.5 interface IClass cls = null; IMethodBody mb = null; bool success = actions.createProgramGraphPullUp.Apply(procEnv, ref cls, ref mb); IMatchesExact <Rule_pullUpMethod.IMatch_pullUpMethod> matchesExact = actions.pullUpMethod.Match(procEnv, 0, cls, mb); Console.WriteLine(matchesExact.Count + " matches found."); Console.WriteLine(matchesExact.FirstExact.node_m5.ToString()); graph.Clear(); // and again with old inexact interface IMatches matchesInexact; object[] returns; Action_createProgramGraphPullUp createProgramGraph = Action_createProgramGraphPullUp.Instance; matchesInexact = createProgramGraph.Match(procEnv, 0); returns = createProgramGraph.Modify(procEnv, matchesInexact.First); IGraphElement[] param = new LGSPNode[2]; param[0] = (Class)returns[0]; param[1] = (MethodBody)returns[1]; matchesInexact = actions.GetAction("pullUpMethod").Match(procEnv, 0, param); Console.WriteLine(matchesInexact.Count + " matches found."); Console.WriteLine(matchesInexact.First.getNodeAt((int)Rule_pullUpMethod.pullUpMethod_NodeNums.m5).ToString()); }
void DoIdpt() { graph = new LGSPGraph(new IndependentGraphModel()); actions = new IndependentActions(graph); procEnv = new LGSPGraphProcessingEnvironment(graph, actions); procEnv.ApplyGraphRewriteSequence("create"); Console.WriteLine(procEnv.PerformanceInfo.MatchesFound + " matches found."); Console.WriteLine(procEnv.PerformanceInfo.RewritesPerformed + " rewrites performed."); procEnv.PerformanceInfo.Reset(); IMatches matches = actions.GetAction("findIndependent").Match(procEnv, 0, null); Console.WriteLine(matches.Count + " matches found."); graph.Clear(); procEnv.ApplyGraphRewriteSequence("createIterated"); Console.WriteLine(procEnv.PerformanceInfo.MatchesFound + " matches found."); Console.WriteLine(procEnv.PerformanceInfo.RewritesPerformed + " rewrites performed."); procEnv.PerformanceInfo.Reset(); IAction_createIterated createIterated = actions.createIterated; IMatchesExact <Rule_createIterated.IMatch_createIterated> matchesCreateIterated = createIterated.Match(procEnv, 0); IintNode beg; INode end; createIterated.Modify(procEnv, matchesCreateIterated.FirstExact, out beg, out end); IMatchesExact <Rule_findChainPlusChainToIntIndependent.IMatch_findChainPlusChainToIntIndependent> matchesFindChain = actions.findChainPlusChainToIntIndependent.Match(procEnv, 0, beg, end); Console.WriteLine(matchesFindChain.Count + " matches found."); }