use of jkind.lustre.CondactExpr in project AGREE by loonwerks.
the class RemoveCondacts method clockNodeCalls.
private Node clockNodeCalls(Node node, final IdExpr clock) {
return (Node) node.accept(new AstMapVisitor() {
@Override
public Expr visit(NodeCallExpr e) {
List<Expr> args = new ArrayList<>();
args.add(clock);
args.addAll(visitExprs(e.args));
Node clocked = createClockedNode(e.node);
return new NodeCallExpr(clocked.id, args);
}
@Override
public Expr visit(CondactExpr e) {
NodeCallExpr call = (NodeCallExpr) super.visit(e.call);
List<Expr> args = new ArrayList<>();
args.add(new BinaryExpr(e.clock.accept(this), BinaryOp.AND, clock));
args.addAll(e.call.args);
args.addAll(visitExprs(e.args));
Node condact = createCondactNode(call.node);
return new NodeCallExpr(condact.id, args);
}
});
}
use of jkind.lustre.CondactExpr in project AGREE by loonwerks.
the class RemoveCondacts method removeCondacts.
private Node removeCondacts(Node node) {
return (Node) node.accept(new AstMapVisitor() {
@Override
public Expr visit(CondactExpr e) {
NodeCallExpr call = (NodeCallExpr) e.call.accept(this);
List<Expr> args = new ArrayList<>();
args.add(e.clock.accept(this));
args.addAll(e.call.args);
args.addAll(visitExprs(e.args));
Node condact = createCondactNode(call.node);
return new NodeCallExpr(condact.id, args);
}
});
}
use of jkind.lustre.CondactExpr in project AGREE by loonwerks.
the class AgreeCycleVisitor method visit.
@Override
public Set<String> visit(CondactExpr e) {
Set<String> argSet = new HashSet<>();
for (Expr argExpr : e.args) {
argSet.addAll(argExpr.accept(this));
}
argSet.addAll(e.call.accept(this));
return argSet;
}
use of jkind.lustre.CondactExpr in project AGREE by loonwerks.
the class LustreContractAstBuilder method addCondactCall.
protected static void addCondactCall(AgreeNode agreeNode, String nodePrefix, List<AgreeVar> inputs, List<AgreeStatement> assertions, AgreeNode subAgreeNode, String prefix, Expr clockExpr, Node lustreNode) {
List<Expr> inputIds = new ArrayList<>();
List<Expr> initOutputsVals = new ArrayList<>();
List<IdExpr> nodeOutputIds = new ArrayList<>();
for (VarDecl var : lustreNode.inputs) {
inputIds.add(new IdExpr(prefix + var.id));
}
for (VarDecl var : lustreNode.outputs) {
AgreeVar outputVar = (AgreeVar) var;
String dummyName = prefix + var.id + "__DUMMY";
AgreeVar dummyVar = new AgreeVar(dummyName, outputVar.type, outputVar.reference, outputVar.compInst, outputVar.featInst);
if (!inputs.contains(dummyVar)) {
inputs.add(dummyVar);
}
initOutputsVals.add(new IdExpr(dummyName));
nodeOutputIds.add(new IdExpr(prefix + var.id));
}
if (agreeNode.timing == TimingModel.LATCHED) {
throw new AgreeException("check how we do this in the generic lustre translation now" + " to make sure that it is correct");
}
Expr condactExpr = new CondactExpr(clockExpr, new NodeCallExpr(lustreNode.id, inputIds), initOutputsVals);
Expr condactOutput;
if (nodeOutputIds.size() > 1) {
condactOutput = new TupleExpr(nodeOutputIds);
} else {
condactOutput = nodeOutputIds.get(0);
}
Expr condactCall = new BinaryExpr(condactOutput, BinaryOp.EQUAL, condactExpr);
assertions.add(new AgreeStatement("", condactCall, null));
}
use of jkind.lustre.CondactExpr in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method visit.
// TODO: double check this for init expression args.
@Override
public ObligationSet visit(CondactExpr e) {
ObligationSet obs1 = e.clock.accept(this);
ObligationSet obs2 = e.call.accept(this);
ObligationSet obs3 = new ObligationSet();
for (Expr arg : e.args) {
obs3.addAll(arg.accept(this));
}
// inputs are only ``effecting'' when clock is true.
obs2.extendContext(e.clock);
// initial arguments are only effecting before the first clock, not just instants
// when the clock is low, but we would need a fresh variable to describe this
// situation, so we are being somewhat inaccurate.
obs3.extendContext(notExpr(e.clock));
obs1.addAll(obs2);
obs1.addAll(obs3);
return obs1;
}
Aggregations