use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method visit.
@Override
public ObligationSet visit(BinaryExpr e) {
if (e.op == BinaryOp.AND) {
ObligationSet lhs = e.left.accept(this);
ObligationSet rhs = e.right.accept(this);
lhs.extendContext(e.right);
rhs.extendContext(e.left);
lhs.addAll(rhs);
return lhs;
} else if (e.op == BinaryOp.OR) {
ObligationSet lhs = e.left.accept(this);
ObligationSet rhs = e.right.accept(this);
lhs.extendContext(notExpr(e.right));
rhs.extendContext(notExpr(e.left));
lhs.addAll(rhs);
return lhs;
} else if (e.op == BinaryOp.IMPLIES) {
Expr equivExpr = binExpr(notExpr(e.left), BinaryOp.OR, e.right);
return equivExpr.accept(this);
} else if (e.op == BinaryOp.ARROW) {
ObligationSet lhs = e.left.accept(this);
ObligationSet rhs = e.right.accept(this);
lhs.makeInitStepOnly();
rhs.makeAfter1Only();
lhs.addAll(rhs);
return lhs;
} else if (isBoolExpr(e.left)) {
if (e.op == BinaryOp.XOR || e.op == BinaryOp.NOTEQUAL) {
Expr equivExpr = notExpr(binExpr(e.left, BinaryOp.EQUAL, e.right));
return equivExpr.accept(this);
} else if (e.op == BinaryOp.EQUAL) {
Expr equivExpr = binExpr(binExpr(e.left, BinaryOp.AND, e.right), BinaryOp.OR, notExpr(binExpr(e.left, BinaryOp.OR, e.right)));
return equivExpr.accept(this);
} else {
// other relational operator over booleans (this may be dead code)
ObligationSet lhs = e.left.accept(this);
ObligationSet rhs = e.right.accept(this);
lhs.addAll(rhs);
return baseExpr(e, lhs);
}
} else {
// Other kind of operator (arithmetic?)
ObligationSet lhs = e.left.accept(this);
ObligationSet rhs = e.right.accept(this);
lhs.addAll(rhs);
return baseExpr(e, lhs);
}
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method visit.
@Override
public ObligationSet visit(ArrayUpdateExpr e) {
ObligationSet obs1 = e.array.accept(this);
ObligationSet obs2 = e.index.accept(this);
ObligationSet obs3 = e.value.accept(this);
obs1.addAll(obs2);
obs1.addAll(obs3);
return baseExpr(e, obs1);
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method visit.
@Override
public ObligationSet visit(Equation equation) {
ObligationSet result = new ObligationSet();
boolean isGuaranteeEq = equation.lhs.size() == 1 && equation.lhs.get(0).id.startsWith(GenerateUfcObligationsVisitor.GUARANTEE_PREFIX);
boolean isAssumptionEq = false;
/* how do we determine this? */
boolean isNormalEq = !isGuaranteeEq;
if (this.generateGuaranteeObligations && isGuaranteeEq) {
if (equation.lhs.size() == 1 && equation.lhs.get(0).id.startsWith(GenerateUfcObligationsVisitor.GUARANTEE_PREFIX)) {
result = expr(equation.expr);
}
} else if (this.generateAssumptionObligations && isAssumptionEq) {
result = expr(equation.expr);
} else if (this.generateEqObligations && isNormalEq) {
result = expr(equation.expr);
} else if (this.generatePropertyObligations) {
// Check if the equation is for a property in the current node
if (equation.lhs.size() == 1 && currentNode != null && currentNode.properties.contains(equation.lhs.get(0).id)) {
result = expr(equation.expr);
}
}
if (!equation.lhs.isEmpty()) {
result.setEqId(equation.lhs.get(0).id);
}
return result;
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method constructNewProgram.
public Program constructNewProgram() {
List<Node> nodes = new ArrayList<>();
for (Entry<Node, ObligationSet> nodeElem : obligations.entrySet()) {
nodes.add(constructNewNode(nodeElem.getKey(), nodeElem.getValue()));
}
Program newProgram = new Program(initialProgram.location, initialProgram.types, initialProgram.constants, Collections.emptyList(), nodes, initialProgram.main);
return newProgram;
}
Aggregations