use of edu.rice.cs.caper.bayou.core.dsl.DSubTree in project bayou by capergroup.
the class DOMDoStatement method handle.
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
DSubTree cond = new DOMExpression(statement.getExpression(), visitor).handle();
DSubTree body = new DOMStatement(statement.getBody(), visitor).handle();
boolean loop = cond.isValid() && body.isValid();
tree.addNodes(body.getNodes());
if (loop)
tree.addNode(new DLoop(cond.getNodesAsCalls(), body.getNodes()));
else {
// only one of these will add nodes
tree.addNodes(cond.getNodes());
tree.addNodes(body.getNodes());
}
return tree;
}
use of edu.rice.cs.caper.bayou.core.dsl.DSubTree in project bayou by capergroup.
the class DOMInfixExpression method handle.
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
DSubTree Tleft = new DOMExpression(expr.getLeftOperand(), visitor).handle();
DSubTree Tright = new DOMExpression(expr.getRightOperand(), visitor).handle();
tree.addNodes(Tleft.getNodes());
tree.addNodes(Tright.getNodes());
return tree;
}
use of edu.rice.cs.caper.bayou.core.dsl.DSubTree in project bayou by capergroup.
the class DOMSwitchStatement method handle.
@Override
public DSubTree handle() {
DSubTree Sexpr = new DOMExpression(statement.getExpression(), visitor).handle();
boolean branch = Sexpr.isValid();
for (Object o : statement.statements()) {
int type = ((Statement) o).getNodeType();
nodeType.add(type);
DSubTree body = new DOMStatement((Statement) o, visitor).handle();
bodies.add(body.getNodes());
if (// excludes 'case' statement
type != 49)
branch |= body.isValid();
}
if (branch) {
DSubTree switchNode = BuildTree(Sexpr, 1);
tree.addNode(switchNode.getNodes().get(0));
} else {
// only one will add nodes, the rest will add nothing
tree.addNodes(Sexpr.getNodes());
for (Iterator<Object> iter = statement.statements().iterator(); iter.hasNext(); ) {
Object o = iter.next();
DSubTree body = new DOMStatement((Statement) o, visitor).handle();
tree.addNodes(body.getNodes());
}
}
return tree;
}
use of edu.rice.cs.caper.bayou.core.dsl.DSubTree 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;
}
use of edu.rice.cs.caper.bayou.core.dsl.DSubTree in project bayou by capergroup.
the class DOMVariableDeclarationStatement method handle.
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
for (Object o : statement.fragments()) {
VariableDeclarationFragment fragment = (VariableDeclarationFragment) o;
DSubTree t = new DOMVariableDeclarationFragment(fragment, visitor).handle();
tree.addNodes(t.getNodes());
}
return tree;
}
Aggregations