use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.
the class InlineNodeCalls method createAssignmentEquations.
private void createAssignmentEquations(final String prefix, List<Equation> equations, Map<String, IdExpr> translation) {
SubstitutionVisitor substitution = new SubstitutionVisitor(translation) {
@Override
public Expr visit(NodeCallExpr e) {
return new NodeCallExpr(e.location, prefix + e.node, visitExprs(e.args));
}
};
for (Equation eq : equations) {
List<IdExpr> lhs = new ArrayList<>();
for (IdExpr idExpr : eq.lhs) {
lhs.add(translation.get(idExpr.id));
}
Expr expr = eq.expr.accept(substitution);
queue.add(new Equation(eq.location, lhs, expr));
}
}
use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.
the class InlineNodeCalls method visit.
@Override
public Expr visit(NodeCallExpr e) {
// Detect duplicate node calls to reduce code size
String key = getKey(e);
if (inlinedCalls.containsKey(key)) {
return inlinedCalls.get(key);
} else {
Expr result = TupleExpr.compress(visitNodeCallExpr(e));
inlinedCalls.put(key, result);
return result;
}
}
use of jkind.lustre.NodeCallExpr 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.NodeCallExpr 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.NodeCallExpr in project AGREE by loonwerks.
the class AgreeASTBuilder method getMNSynchConstraint.
private Expr getMNSynchConstraint(MNSynchStatement sync) {
Set<String> nodeNames = new HashSet<>();
Expr clockAssertion = new BoolExpr(true);
for (int i = 0; i < sync.getComp1().size(); i++) {
Subcomponent maxComp = (Subcomponent) sync.getComp1().get(i);
Subcomponent minComp = (Subcomponent) sync.getComp2().get(i);
Expr maxClock = new IdExpr(maxComp.getName() + clockIDSuffix);
Expr minClock = new IdExpr(minComp.getName() + clockIDSuffix);
int max = Integer.valueOf(sync.getMax().get(i));
int min = Integer.valueOf(sync.getMin().get(i));
MNSynchronyElement elem = new MNSynchronyElement(maxClock, minClock, max, min);
String nodeName = "__calendar_node_" + elem.max + "_" + elem.min;
nodeName = getObjectLocationPrefix(sync) + nodeName;
if (!nodeNames.contains(nodeName)) {
nodeNames.add(nodeName);
Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, elem.max, elem.min);
addToNodeList(calNode);
}
NodeCallExpr nodeCall = new NodeCallExpr(nodeName, elem.maxClock, elem.minClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
nodeCall = new NodeCallExpr(nodeName, elem.minClock, elem.maxClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
}
return clockAssertion;
}
Aggregations