use of edu.rice.cs.caper.bayou.core.dsl.DBranch in project bayou by capergroup.
the class DOMConditionalExpression method handle.
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
DSubTree Tcond = new DOMExpression(expression.getExpression(), visitor).handle();
DSubTree Tthen = new DOMExpression(expression.getThenExpression(), visitor).handle();
DSubTree Telse = new DOMExpression(expression.getElseExpression(), visitor).handle();
boolean branch = (Tcond.isValid() && Tthen.isValid()) || (Tcond.isValid() && Telse.isValid()) || (Tthen.isValid() && Telse.isValid());
if (branch)
tree.addNode(new DBranch(Tcond.getNodesAsCalls(), Tthen.getNodes(), Telse.getNodes()));
else {
// only one of these will add nodes, the rest will add nothing
tree.addNodes(Tcond.getNodes());
tree.addNodes(Tthen.getNodes());
tree.addNodes(Telse.getNodes());
}
return tree;
}
use of edu.rice.cs.caper.bayou.core.dsl.DBranch in project bayou by capergroup.
the class DOMIfStatement method handle.
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
DSubTree Tcond = new DOMExpression(statement.getExpression(), visitor).handle();
DSubTree Tthen = new DOMStatement(statement.getThenStatement(), visitor).handle();
DSubTree Telse = new DOMStatement(statement.getElseStatement(), visitor).handle();
boolean branch = (Tcond.isValid() && Tthen.isValid()) || (Tcond.isValid() && Telse.isValid()) || (Tthen.isValid() && Telse.isValid());
if (branch)
tree.addNode(new DBranch(Tcond.getNodesAsCalls(), Tthen.getNodes(), Telse.getNodes()));
else {
// only one of these will add nodes, the rest will add nothing
tree.addNodes(Tcond.getNodes());
tree.addNodes(Tthen.getNodes());
tree.addNodes(Telse.getNodes());
}
return tree;
}
use of edu.rice.cs.caper.bayou.core.dsl.DBranch in project bayou by capergroup.
the class DOMSwitchStatement method BuildTree.
private DSubTree BuildTree(DSubTree Sexpr, int itPos) {
DSubTree bodyPrev = new DSubTree();
DSubTree caseNodes = new DSubTree();
DSubTree bodyNext;
for (int it1 = itPos; it1 < bodies.size(); it1++) {
int typePrev = nodeType.get(it1);
if (typePrev == 49) {
// checks for 'case' statement
bodyNext = BuildTree(Sexpr, it1 + 1);
DASTNode caseNode = new DBranch(Sexpr.getNodesAsCalls(), bodyPrev.getNodes(), bodyNext.getNodes());
caseNodes.addNode(caseNode);
return caseNodes;
} else {
bodyPrev.addNodes(bodies.get(it1));
}
}
return bodyPrev;
}