Search in sources :

Example 1 with DBranch

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

Example 2 with DBranch

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

Example 3 with DBranch

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

Aggregations

DBranch (edu.rice.cs.caper.bayou.core.dsl.DBranch)3 DSubTree (edu.rice.cs.caper.bayou.core.dsl.DSubTree)3 DASTNode (edu.rice.cs.caper.bayou.core.dsl.DASTNode)1