Search in sources :

Example 1 with DLoop

use of edu.rice.cs.caper.bayou.core.dsl.DLoop in project bayou by capergroup.

the class DOMForStatement method handle.

@Override
public DSubTree handle() {
    DSubTree tree = new DSubTree();
    for (Object o : statement.initializers()) {
        DSubTree init = new DOMExpression((Expression) o, visitor).handle();
        tree.addNodes(init.getNodes());
    }
    DSubTree cond = new DOMExpression(statement.getExpression(), visitor).handle();
    DSubTree body = new DOMStatement(statement.getBody(), visitor).handle();
    for (Object o : statement.updaters()) {
        DSubTree update = new DOMExpression((Expression) o, visitor).handle();
        // updaters are part of body
        body.addNodes(update.getNodes());
    }
    boolean loop = cond.isValid();
    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;
}
Also used : DSubTree(edu.rice.cs.caper.bayou.core.dsl.DSubTree) Expression(org.eclipse.jdt.core.dom.Expression) DLoop(edu.rice.cs.caper.bayou.core.dsl.DLoop)

Example 2 with DLoop

use of edu.rice.cs.caper.bayou.core.dsl.DLoop 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;
}
Also used : DSubTree(edu.rice.cs.caper.bayou.core.dsl.DSubTree) DLoop(edu.rice.cs.caper.bayou.core.dsl.DLoop)

Example 3 with DLoop

use of edu.rice.cs.caper.bayou.core.dsl.DLoop in project bayou by capergroup.

the class DOMWhileStatement 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();
    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;
}
Also used : DSubTree(edu.rice.cs.caper.bayou.core.dsl.DSubTree) DLoop(edu.rice.cs.caper.bayou.core.dsl.DLoop)

Aggregations

DLoop (edu.rice.cs.caper.bayou.core.dsl.DLoop)3 DSubTree (edu.rice.cs.caper.bayou.core.dsl.DSubTree)3 Expression (org.eclipse.jdt.core.dom.Expression)1