13 #include <boost/regex.hpp>
77 #include <sys/resource.h>
85 std::vector<std::vector<SgGraphNode*> >
path;
88 std::vector<std::pair<SgGraphNode*, int> >
nodelst;
93 double timeDifference(
const struct timeval& end,
const struct timeval& begin)
95 return (end.tv_sec + end.tv_usec / 1.0e6) - (begin.tv_sec + begin.tv_usec / 1.0e6);
100 getrusage(RUSAGE_SELF, &ru);
115 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
127 std::vector<std::vector<SgGraphNode*> >
iLoops;
150 std::map<SgGraphNode*, std::vector<std::set<int> > >
lstordmap;
153 std::map<SgGraphNode*, std::set<SgGraphNode*> >
downed;
160 InheritedAttributeType inheritedValue, InheritedAttributeType
nullInherit,
161 SgGraphNode* endnode,
bool insep =
false,
bool pcHk =
false);
169 std::vector<InheritedAttributeType> inheritedValues) = 0;
172 InheritedAttributeType
in,
179 virtual void pathAnalyze(std::vector<SgGraphNode*>& pth,
bool loop=
false, std::set<std::vector<SgGraphNode*> >& incloops=NULL) = 0;
181 virtual void pathAnalyze(std::vector<SgGraphNode*>& pth,
bool loop, std::set<std::vector<SgGraphNode*> >& incloops) = 0;
191 std::map<SgGraphNode*, std::set<std::vector<SgGraphNode*> > >
lpbegins;
201 std::map<SgGraphNode*, InheritedAttributeType>
known;
216 std::map<SgGraphNode*, std::vector<std::vector<SgGraphNode*> > >
pathsAtMk;
218 std::map<SgGraphNode*, std::set<std::vector<SgGraphNode*> > >
mkloopmap;
219 std::map<SgGraphNode*, std::set<std::vector<SgGraphNode*> > >
subPathsAtMk;
227 bool disjoint(std::vector<SgGraphNode*>& path, std::vector<SgGraphNode*>& vec2)
const;
231 std::map<SgGraphNode*, InheritedAttributeType>
inhVals;
306 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
309 : synthesizedAttributes(new SynthesizedAttributesList())
315 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
319 ROSE_ASSERT(synthesizedAttributes != NULL);
320 delete synthesizedAttributes;
321 synthesizedAttributes = NULL;
327 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
333 ROSE_ASSERT(synthesizedAttributes != NULL);
334 delete synthesizedAttributes;
357 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
358 InheritedAttributeType
365 completedEdgesPath.clear();
380 completedEdges.clear();
381 completedEdgesOut.clear();
383 computedNodes.clear();
384 nullEdgesOrdered.clear();
385 nullEdgesOrderedOut.clear();
397 std::cout <<
"starting traversal" << std::endl;
401 synthesizedAttributes->resetStack();
402 ROSE_ASSERT(synthesizedAttributes->debugSize() == 0);
404 inhVals[n] = inheritedValue;
416 InheritedAttributeType inh;
417 struct timeval t1, t2, t3, t4, t5, t6, t7, t8;
424 solvePaths(g, n, endnode);
429 ROSE_ASSERT(inhVals.find(endnode) == inhVals.end());
431 std::cout <<
"solvePaths done" << std::endl;
439 computedNodes.insert(n);
441 computeOrder(g, n, endnode);
442 std::cout <<
"order computed" << std::endl;
444 computeInheritedOrdered(g, n);
445 std::cout <<
"inheritance computed" << std::endl;
446 ROSE_ASSERT(oVals.find(endnode) != oVals.end());
447 ROSE_ASSERT(inhVals.find(endnode) != inhVals.end());
449 InheritedAttributeType pthgraphinherit = inhVals[endnode];
452 std::cout <<
"evaluateGraph done" << std::endl;
457 evaluatePaths(g, n, endnode);
465 std::cout <<
"evaluatePaths done " << std::endl;
468 std::cout <<
"pathsolve took: " << diff << std::endl;
469 std::cout <<
"patheval took: " << diff2 << std::endl;
470 std::cout <<
"parpatheval took: " << diff2Par << std::endl;
471 std::cout <<
"grapheval took: " << diff3 << std::endl;
472 std::cout <<
"entire pathsolve took: " << diff+diff2+diff3+diff2Par << std::endl;
473 std::cout <<
"potential loops: " << nullEdgesOrdered.size() << std::endl;
474 std::cout <<
"nullNum: " << nullNum << std::endl;
477 std::cout <<
"mkloops: " << mkloops.size() << std::endl;
478 std::cout <<
"distime: " << distime << std::endl;
479 std::cout <<
"fllp: " << fllp << std::endl;
480 return pthgraphinherit;
497 bool is_disjoint(std::set<SgGraphNode*> set1, std::set<SgGraphNode*> set2) {
499 if (set1.empty() || set2.empty()) {
502 std::set<SgGraphNode*>::iterator it1 = set1.begin();
503 std::set<SgGraphNode*>::iterator it2 = set2.begin();
504 std::set<SgGraphNode*>::iterator it1End = set1.end();
505 std::set<SgGraphNode*>::iterator it2End = set2.end();
507 if (*it1 > *set2.rbegin() || *it2 > *set1.rbegin()) {
511 while (it1 != it1End && it2 != it2End) {
528 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
531 disjoint(std::vector<SgGraphNode*>& pthloops, std::vector<SgGraphNode*>& vec2)
const {
556 for (
int i = 0; i < pthloops.size(); i++) {
557 if (
find(vec2.begin(), vec2.end(), pthloops[i]) != vec2.end()) {
669 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
674 if (inhVals.find(n) != inhVals.end()) {
678 if (oed.size() == 0) {
681 for (std::set<SgDirectedGraphEdge*>::iterator i = oed.begin(); i != oed.end(); i++) {
682 if (inhVals.find((*i)->get_from()) == inhVals.end() && nullEdges.find(*i) == nullEdges.end()) {
691 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
695 std::vector<std::vector<SgGraphNode*> > path;
696 std::vector<SgGraphNode*> spath;
701 std::vector<SgGraphNode*> currpthorg;
703 std::map<SgGraphNode*, int> intPath;
704 intPath[n] = currint;
706 std::map<SgGraphNode*, int> currents;
709 bool midstep =
false;
713 std::vector<std::vector<SgGraphNode*> > pth = pathsAtMk[realstartnode];
714 std::vector<std::vector<SgGraphNode*> > cpth = pathsAtMk[realstartnode];
717 int disjointtrues = 0;
719 intPath[pth[0].front()] = currint;
720 std::set<SgGraphNode*> pthloopstmp;
722 pthloopstmp.insert(fakenode);
723 std::vector<std::set<SgGraphNode*> > pthloops;
724 pthloops.push_back(pthloopstmp);
729 std::vector<SgGraphNode*> rs;
730 rs.push_back(realstartnode);
735 std::vector<SgGraphNode*> sub;
738 std::set<std::vector<SgGraphNode*> > nullIncLoops;
739 std::vector<struct Bot*> todobotlst;
740 std::vector<struct Bot*> botlst;
741 struct Bot* rootBot =
new Bot;
748 botlst.push_back(rootBot);
751 std::vector<std::pair<std::vector<SgGraphNode*>, std::vector<std::set<SgGraphNode*> > > > collectedPaths;
754 if (todobotlst.size()+botlst.size() > maxlst) {
755 maxlst = todobotlst.size()+botlst.size();
756 std::cout <<
"maxlst: " << maxlst << std::endl;
757 std::cout <<
"todobotlst.size(): " << todobotlst.size() << std::endl;
758 std::cout <<
"botlst.size(): " << botlst.size() << std::endl;
762 int LOCALMAXBOTS = 10;
763 int LOCALMAXNODES = 0;
764 std::vector<struct Bot*> lstnullbot;
765 std::vector<std::vector<struct Bot*> > newbotlsts (MAXBOTS, lstnullbot);
769 ROSE_ASSERT(botlst.size() >= 0);
770 if (botlst.size() == 0) {
771 if (todobotlst.size() != 0) {
772 while (todobotlst.size() > 0 && botlst.size() < MAXBOTS) {
773 todobotlst.back()->on =
true;
774 botlst.push_back(todobotlst.back());
775 todobotlst.pop_back();
779 if (collectedPaths.size() > 0) {
780 for (
int i = 0; i < collectedPaths.size(); i++) {
781 std::set<std::vector<SgGraphNode*> > incloops;
782 std::vector<std::set<SgGraphNode*> > pthloops = collectedPaths[i].second;
783 for (
int q = 0; q < pthloops.size(); q++) {
784 for (std::set<SgGraphNode*>::iterator p = pthloops[q].begin(); p != pthloops[q].end(); p++) {
785 for (std::set<std::vector<SgGraphNode*> >::
iterator o = mkloopmap[*p].begin(); o != mkloopmap[*p].
end(); o++) {
792 pathAnalyze(collectedPaths[i].first,
false, incloops);
794 collectedPaths.clear();
799 if (botlst.size() > 0) {
800 std::pair<std::vector<SgGraphNode*>, std::vector<std::set<SgGraphNode*> > > nullpr;
801 std::vector<std::pair<std::vector<SgGraphNode*>, std::vector<std::set<SgGraphNode*> > > > newpathslst (MAXBOTS, nullpr);
802 #pragma omp parallel for
803 for (
int i = 0; i < botlst.size(); i++) {
805 std::vector<struct Bot*> localbotlst;
806 std::pair<std::vector<SgGraphNode*>, std::vector<std::set<SgGraphNode*> > > localnewpath;
807 struct Bot* currBot = botlst[i];
810 std::vector<std::vector<SgGraphNode*> > path = currBot->
path;
811 std::vector<std::set<SgGraphNode*> > pthloops = currBot->
pthloops;
813 if (currpth.back() == endnode) {
814 path.push_back(currpth);
815 std::vector<SgGraphNode*> flatpath;
816 std::set<std::vector<SgGraphNode*> > incloops;
817 struct timeval q1, q2;
818 ROSE_ASSERT(path.size() == pthloops.size() + 1);
820 for (
unsigned int q = 0; q < pthloops.size(); q++) {
821 for (
unsigned int r = 0; r < path[q].size(); r++) {
822 flatpath.push_back(path[q][r]);
838 for (
unsigned int pt2 = 0; pt2 < path[path.size()-1].size(); pt2++) {
839 flatpath.push_back(path[path.size()-1][pt2]);
843 flatpath.push_back(endnode);
851 std::pair<std::vector<SgGraphNode*> , std::vector<std::set<SgGraphNode*> > > newcol;
852 newcol.first = flatpath;
853 newcol.second = pthloops;
854 localnewpath = newcol;
857 int pts = pathsSize++;
863 bool starter =
false;
884 localbotlst.push_back(currBot);
891 struct timeval tdisb, tdise;
893 for (
int x = 0; x < pthloops.size(); x++) {
894 for (std::set<SgGraphNode*>::iterator j = pthloops[x].begin(); j != pthloops[x].end(); j++) {
895 if (
find(currpth.begin(), currpth.end(), *j) != currpth.end()) {
907 std::set<SgGraphNode*> pthloopstmp;
909 for (
int i = 0; i < currpth.size(); i++) {
911 if (mkloops.find(currpth[i]) != mkloops.end()) {
912 pthloopstmp.insert(currpth[i]);
915 pthloops.push_back(pthloopstmp);
916 path.push_back(currpth);
920 std::vector<SgGraphNode*> oldcurrpth = currpth;
925 ROSE_ASSERT(pathsAtMk.find(backnode) != pathsAtMk.end() || backnode == endnode);
926 ROSE_ASSERT(pathsAtMk.find(frontnode) != pathsAtMk.end());
927 std::vector<std::vector<SgGraphNode*> > tmppths = pathsAtMk[backnode];
929 currBot->
path = path;
932 for (
int tp = 1; tp < tmppths.size(); tp++) {
943 struct Bot* newBot =
new Bot;
948 localbotlst.push_back(newBot);
952 localbotlst.push_back(currBot);
975 localbotlst.push_back(currBot);
981 newpathslst[i] = localnewpath;
982 newbotlsts[i] = localbotlst;
988 for (
int i = 0; i < newbotlsts.size(); i++) {
989 if (newpathslst[i].first.size() > 0) {
990 collectedPaths.push_back(newpathslst[i]);
992 for (
int j = 0; j < newbotlsts[i].size(); j++) {
993 if (newbotlsts[i][j]->
remove ==
true) {
994 delete newbotlsts[i][j];
996 else if (num < MAXBOTS) {
997 newbotlsts[i][j]->on =
true;
998 botlst.push_back(newbotlsts[i][j]);
1002 newbotlsts[i][j]->on =
false;
1003 todobotlst.push_back(newbotlsts[i][j]);
1008 if (collectedPaths.size() > MINPATHS) {
1010 for (
int i = 0; i < collectedPaths.size(); i++) {
1011 std::vector<std::set<SgGraphNode*> >
pthloops;
1012 std::set<std::vector<SgGraphNode*> > incloops;
1013 pthloops = collectedPaths[i].second;
1014 for (
int q = 0; q < pthloops.size(); q++) {
1015 for (std::set<SgGraphNode*>::iterator p = pthloops[q].begin(); p != pthloops[q].end(); p++) {
1016 for (std::set<std::vector<SgGraphNode*> >::
iterator o = mkloopmap[*p].begin(); o != mkloopmap[*p].
end(); o++) {
1017 incloops.insert(*o);
1022 pathAnalyze(collectedPaths[i].first,
false, incloops);
1024 collectedPaths.clear();
1028 if (collectedPaths.size() > 0) {
1029 for (
int i = 0; i < collectedPaths.size(); i++) {
1030 std::set<std::vector<SgGraphNode*> > incloops;
1031 pthloops = collectedPaths[i].second;
1032 for (
int q = 0; q < pthloops.size(); q++) {
1033 for (std::set<SgGraphNode*>::iterator p = pthloops[q].begin(); p != pthloops[q].end(); p++) {
1034 for (std::set<std::vector<SgGraphNode*> >::
iterator o = mkloopmap[*p].begin(); o != mkloopmap[*p].
end(); o++) {
1035 incloops.insert(*o);
1040 pathAnalyze(collectedPaths[i].first,
false, incloops);
1043 collectedPaths.clear();
1048 std::cout <<
"successes: " << successes << std::endl;
1049 std::cout <<
"failures: " << failures << std::endl;
1050 std::cout <<
"maxlst: " << maxlst << std::endl;
1056 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1076 std::vector<std::vector<SgGraphNode*> >
path;
1077 std::vector<SgGraphNode*> spath;
1082 std::vector<SgGraphNode*>
currpth;
1084 std::map<SgGraphNode*, int> intPath;
1085 intPath[n] = currint;
1087 std::map<SgGraphNode*, int> currents;
1090 bool midstep =
false;
1094 std::vector<std::vector<SgGraphNode*> > pth = pathsAtMk[realstartnode];
1095 std::vector<std::vector<SgGraphNode*> > cpth = pathsAtMk[realstartnode];
1098 int disjointtrues = 0;
1100 intPath[pth[0].front()] = currint;
1101 std::set<SgGraphNode*> pthloopstmp;
1103 pthloopstmp.insert(fakenode);
1104 std::vector<std::set<SgGraphNode*> >
pthloops;
1105 pthloops.push_back(pthloopstmp);
1106 pthloopstmp.clear();
1110 std::vector<SgGraphNode*> rs;
1111 rs.push_back(realstartnode);
1118 std::vector<SgGraphNode*> sub;
1125 std::set<std::vector<SgGraphNode*> > nullIncLoops;
1167 while (step ==
false) {
1170 if (currpth.back() == endnode) {
1171 path.push_back(currpth);
1175 std::vector<SgGraphNode*> flatpath;
1177 std::set<std::vector<SgGraphNode*> > incloops;
1178 struct timeval q1, q2;
1181 ROSE_ASSERT(path.size() == pthloops.size() + 1);
1183 for (
unsigned int q = 0; q < pthloops.size(); q++) {
1186 for (
unsigned int r = 0; r < path[q].size(); r++) {
1187 flatpath.push_back(path[q][r]);
1189 for (std::set<SgGraphNode*>::iterator p = pthloops[q].begin(); p != pthloops[q].end(); p++) {
1190 for (std::set<std::vector<SgGraphNode*> >::
iterator o = mkloopmap[*p].begin(); o != mkloopmap[*p].
end(); o++) {
1191 incloops.insert(*o);
1195 for (
unsigned int pt2 = 0; pt2 < path[path.size()-1].size(); pt2++) {
1196 flatpath.push_back(path[path.size()-1][pt2]);
1201 flatpath.push_back(endnode);
1212 pathAnalyze(flatpath,
false, incloops);
1216 int pts = pathsSize++;
1222 bool starter =
false;
1230 ROSE_ASSERT(pathsAtMk.find((path.back()).back()) != pathsAtMk.end());
1231 if ((path.back()).front() == realstartnode) {
1234 if (currents[(path.back()).back()] < (pathsAtMk[(path.back()).back()].size()) ) {
1235 std::vector<std::vector<SgGraphNode*> > cpths = pathsAtMk[(path.back()).back()];
1236 currpth = cpths[currents[(path.back()).back()]];
1237 currents[(path.back()).back()]++;
1241 currents[(path.back()).back()] = 0;
1243 pthloops.pop_back();
1245 if (starter ==
true) {
1256 struct timeval tdisb, tdise;
1258 for (
int i = 0; i < pthloops.size(); i++) {
1259 for (std::set<SgGraphNode*>::iterator j = pthloops[i].begin(); j != pthloops[i].end(); j++) {
1260 if (
find(currpth.begin(), currpth.end(), *j) != currpth.end()) {
1286 std::set<SgGraphNode*> pthloopstmp;
1287 pthloopstmp.clear();
1288 for (
int i = 0; i < currpth.size(); i++) {
1290 if (mkloops.find(currpth[i]) != mkloops.end()) {
1291 pthloopstmp.insert(currpth[i]);
1294 pthloops.push_back(pthloopstmp);
1295 path.push_back(currpth);
1296 pthloopstmp.clear();
1299 std::vector<SgGraphNode*> oldcurrpth = currpth;
1301 if (currents.find((path.back()).back()) == currents.end()) {
1302 currents[(path.back()).back()] = 0;
1307 ROSE_ASSERT(pathsAtMk.find(backnode) != pathsAtMk.end() || backnode == endnode);
1308 ROSE_ASSERT(pathsAtMk.find(frontnode) != pathsAtMk.end());
1309 if (currents.find(backnode) == currents.end()) {
1310 currents[backnode] = 0;
1313 ROSE_ASSERT(currents[backnode] == 0);
1315 std::vector<std::vector<SgGraphNode*> > tmppths = pathsAtMk[backnode];
1317 currpth = tmppths[currents[backnode]];
1318 ROSE_ASSERT(currpth != oldcurrpth);
1319 currents[backnode]++;
1326 if (currents[(path.back()).back()] < pathsAtMk[(path.back()).back()].size() || path.back().back() == realstartnode) {
1329 currents[(path.back()).back()] = 0;
1331 pthloops.pop_back();
1333 if ((path.back()).back() != realstartnode) {
1334 currpth = (pathsAtMk[(path.back()).back()])[currents[(path.back()).back()]];
1335 currents[(path.back()).back()]++;
1343 std::cout <<
"successes: " << successes << std::endl;
1344 std::cout <<
"failures: " << failures << std::endl;
1355 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1359 printNodeForAnalysis(n, loopNum, pathVal, ss);
1361 for (std::set<SgDirectedGraphEdge*>::iterator i = outEdges.begin(); i != outEdges.end(); i++) {
1362 if (nullEdgesOrdered.find(*i) == nullEdgesOrdered.end()) {
1363 printEdgeForAnalysis(*i,
false, ss);
1366 printEdgeForAnalysis(*i,
true, ss);
1371 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1375 for (
unsigned int i = 0; i < n.size()-1; i++) {
1376 if (completedNodesPath.find(n[i]) == completedNodesPath.end()) {
1377 printNodeForAnalysis(n[i], loopNum, pathVal, ss);
1378 completedNodesPath.insert(n[i]);
1380 std::pair<SgGraphNode*, SgGraphNode*> prnod;
1381 prnod.first = n[i+1];
1382 prnod.second = n[i];
1383 if (completedEdgesPath.find(prnod) == completedEdgesPath.end()) {
1384 printEdgeForAnalysisPath(n[i+1], n[i], ss);
1385 completedEdgesPath.insert(prnod);
1388 if (completedNodesPath.find(n[n.size() - 1]) == completedNodesPath.end()) {
1389 printNodeForAnalysis(n[n.size()-1], loopNum, pathVal, ss);
1390 completedNodesPath.insert(n[n.size() - 1]);
1396 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1401 std::string nodeColor =
"black";
1403 ss <<
id <<
" [label=\"" <<
"LoopNumS" << loopNum <<
"\", color=\"" <<
"green" <<
"\", style=\"" <<
"solid" <<
"\"];\n";
1406 ss <<
id <<
" [label=\"" <<
"pathNumS" << pathNum <<
"\", color=\"" <<
"black" <<
"\", style=\"" <<
"dotted" <<
"\"];\n";
1410 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1421 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1425 ss << g2->
get_index() <<
" -> " << g1->
get_index() <<
" [label=\"" <<
"Edge" <<
"\", style=\"" <<
"solid" <<
"\"];\n";
1432 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
1438 bool tookone =
false;
1439 std::vector<SgGraphNode*> mkpath;
1440 std::vector<SgGraphNode*> marks;
1442 mkglobal.push_back(n);
1445 std::set<SgDirectedGraphEdge*> taken;
1446 std::vector<SgGraphNode*> toTake;
1447 std::vector<SgGraphNode*> path;
1449 mkpath.push_back(n);
1451 int bifurcations = 0;
1452 std::map<SgGraphNode*, bool> completed;
1453 while (done ==
false) {
1454 ROSE_ASSERT(currn != NULL);
1456 if (currn == endnode || completed.find(currn) != completed.end()) {
1457 if (pathsAtMk.find(marks.back()) == pathsAtMk.end()) {
1458 std::vector<std::vector<SgGraphNode*> > emptypath;
1459 pathsAtMk[marks.back()] = emptypath;
1462 pathsAtMk[marks.back()].push_back(mkpath);
1469 ROSE_ASSERT(mkpath.front() == marks.back());
1470 if (marks.size() == 0) {
1475 bool haventtaken =
false;
1479 while (found ==
false) {
1480 if (marks.size() == 0) {
1486 ROSE_ASSERT(oedg.size() > 1 || mark1 == n);
1487 for (std::set<SgDirectedGraphEdge*>::iterator j = oedg.begin(); j != oedg.end(); j++) {
1488 if (taken.find(*j) == taken.end() && haventtaken ==
false) {
1493 if (haventtaken ==
true) {
1494 if (marks.back() == n) {
1497 path.push_back(marks.back());
1498 if ( mkpath.empty() || (mkpath.back() != marks.back()) ) {
1499 ROSE_ASSERT(!marks.empty());
1500 mkpath.push_back(marks.back());
1502 taken.insert(tooked);
1507 completed[marks.back()] =
true;
1512 if (marks.size() == 0) {
1515 haventtaken =
false;
1523 if (oedg.size() > 1) {
1524 if (mkpath.back() != currn) {
1525 mkpath.push_back(currn);
1527 pathsAtMk[marks.back()].push_back(mkpath);
1529 mkpath.push_back(currn);
1530 marks.push_back(currn);
1531 if (
find(mkglobal.begin(), mkglobal.end(), currn) == mkglobal.end()) {
1532 mkglobal.push_back(currn);
1534 for (std::set<SgDirectedGraphEdge*>::iterator i = oedg.begin(); i != oedg.end(); i++) {
1535 if (taken.find(*i) == taken.end() && tookone ==
false) {
1538 took = (*i)->get_to();
1540 else if (taken.find(*i) == taken.end() && tookone ==
true) {
1547 took = (*(oedg.begin()))->get_to();
1552 if (
find(path.begin(), path.end(), took) == path.end()) {
1553 mkpath.push_back(took);
1554 path.push_back(took);
1558 mkloops.insert(took);
1559 std::vector<SgGraphNode*> lptemp;
1561 lptemp.push_back(took);
1562 while (path.back() != took) {
1566 lptemp.push_back(path.back());
1569 (mkloopmap[took]).insert(lptemp);
1581 path.push_back(took);
1582 currn = path.back();
1583 mkpath.push_back(took);
1592 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1593 SynthesizedAttributeType
1597 SynthesizedAttributeType s = SynthesizedAttributeType();
1604 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1608 std::map<SgGraphNode*, int> incomputables;
1609 std::set<SgGraphNode*> lpposs;
1615 if (orders % 10000 == 0) {
1616 std::cout <<
"orders: " << orders << std::endl;
1619 if (currn == endnode) {
1621 if (computable(g, currn) || currn == n) {
1623 if (oVals.find(currn) == oVals.end()) {
1624 oVals[currn] = currm++;
1625 iVals[currm++] = currn;
1628 if (currn == endnode) {
1632 std::pair<bool, SgGraphNode*> pbs = getNextChild(g, currn);
1633 computedNodes.insert(currn);
1634 ROSE_ASSERT(pbs.first ==
true);
1638 std::pair<bool, SgGraphNode*> pbp = getNextPar(g, currn);
1639 ROSE_ASSERT(pbp.first ==
true);
1645 std::cout <<
"required orders" << orders << std::endl;
1646 std::cout <<
"incomputables.size() " << incomputables.size() << std::endl;
1650 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1654 if (computedNodes.find(n) != computedNodes.end()) {
1659 for (std::set<SgDirectedGraphEdge*>::iterator i = ed.begin(); i != ed.end(); i++) {
1660 if (oVals.find((*i)->get_from()) == oVals.end() && nullEdgesOrdered.find(*i) == nullEdgesOrdered.end()) {
1670 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1678 for (std::map<int, SgGraphNode*>::iterator i = iVals.begin(); i != iVals.end(); i++) {
1680 ROSE_ASSERT(canEval(g, (*i).second));
1683 evalNodeOrdered(g, (*i).second);
1688 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1693 if (inhVals.find(n) == inhVals.end()) {
1695 for (std::set<SgDirectedGraphEdge*>::iterator i = ins.begin(); i != ins.end(); i++) {
1696 if (inhVals.find((*i)->get_from()) == inhVals.end() && nullEdgesOrdered.find(*i) == nullEdgesOrdered.end()) {
1706 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1710 if (inhVals.find(n) != inhVals.end()) {
1714 std::vector<InheritedAttributeType> inh;
1715 for (std::set<SgDirectedGraphEdge*>::iterator i = par.begin(); i != par.end(); i++) {
1716 if (inhVals.find((*i)->get_from()) != inhVals.end()) {
1717 inh.push_back(inhVals[(*i)->get_from()]);
1721 if (n != st || inh.size() > 0) {
1722 InheritedAttributeType inhX;
1723 inhX = evaluateInheritedAttribute(n, inh);
1732 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1736 if (pathValMap.find(currn) != pathValMap.end()) {
1740 int tmppathcount = 0;
1741 for (std::set<SgDirectedGraphEdge*>::iterator i = ined.begin(); i != ined.end(); i++) {
1742 ROSE_ASSERT(pathValMap.find((*i)->get_from()) != pathValMap.end() );
1746 int pv = pathValMap[(*i)->get_from()];
1751 pathValMap[currn] = tmppathcount;
1756 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1757 std::pair<bool, SgGraphNode*>
1760 bool nullPoss =
false;
1767 bool completed =
false;
1768 bool completeNull =
false;
1770 for (std::set<SgDirectedGraphEdge*>::iterator i = outs.begin(); i != outs.end(); i++) {
1772 if (outs.size() == 1) {
1773 nextNode = (*i)->get_to();
1774 if (nullEdgesOrdered.find(*i) != nullEdgesOrdered.end()) {
1780 else if (completed ==
false && computedNodes.find((*i)->get_to()) == computedNodes.end()) {
1782 nextNode = (*i)->get_to();
1783 if (nullEdgesOrdered.find(*i) != nullEdgesOrdered.end()) {
1786 completedEdgesOut.insert(*i);
1791 std::pair<bool, SgGraphNode*> pr;
1792 ROSE_ASSERT (completed ==
true || completeNull ==
true);
1793 if (completed ==
true) {
1794 pr.first = completed;
1795 pr.second = nextNode;
1800 pr.second = nullNode;
1807 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
1808 std::pair<bool, SgGraphNode*>
1814 bool completed =
false;
1815 bool completeNull =
false;
1816 for (std::set<SgDirectedGraphEdge*>::iterator i = ins.begin(); i != ins.end(); i++) {
1818 if (ins.size() == 1 ) {
1820 completedEdges.insert(*i);
1821 nextPar = (*i)->get_from();
1824 else if (completedEdges.find(*i) == completedEdges.end() && completed ==
false) {
1826 nextPar = (*i)->get_from();
1827 completedEdges.insert(*i);
1830 else if (completedEdges.find(*i) != completedEdges.end() && computedNodes.find((*i)->get_from()) == computedNodes.end() && completed ==
false ) {
1831 completeNull =
true;
1832 std::pair<SgGraphNode*, SgGraphNode*> lpp;
1834 nullEdgesOrdered.insert(*i);
1839 ROSE_ASSERT(completed ==
true || completeNull ==
true);
1840 std::pair<bool, SgGraphNode*> pr;
1841 pr.first = completed;
1842 pr.second = nextPar;
1844 if (completeNull ==
true && completed ==
false) {
1845 pr.first = completeNull;
1846 pr.second = nextPar;