use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder in project AGREE by loonwerks.
the class AgreeInlineLatchedConnections method visit.
@Override
public AgreeNode visit(AgreeNode node) {
AgreeNodeBuilder builder = new AgreeNodeBuilder(node);
builder.clearSubNodes();
for (AgreeNode subNode : node.subNodes) {
AgreeNode newSubNode = (AgreeNode) subNode.accept(this);
builder.addSubNode(newSubNode);
}
if (node.timing == AgreeNode.TimingModel.LATCHED) {
for (AgreeNode subNode : builder.build().subNodes) {
addLatchedInputEqs(builder, subNode);
}
}
AgreeNode finalNode = builder.build();
nodes.add(finalNode);
return finalNode;
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder in project AGREE by loonwerks.
the class LustreAstBuilder method flattenAgreeNode.
protected static AgreeNode flattenAgreeNode(AgreeProgram agreeProgram, AgreeNode agreeNode, String nodePrefix) {
List<AgreeVar> inputs = new ArrayList<>();
List<AgreeVar> outputs = new ArrayList<>();
List<AgreeVar> locals = new ArrayList<>();
List<AgreeStatement> patternProps = new ArrayList<>();
List<AgreeEquation> equations = new ArrayList<>();
List<AgreeStatement> assertions = new ArrayList<>();
Set<AgreeVar> timeEvents = new HashSet<>(agreeNode.eventTimes);
Expr someoneTicks = null;
for (AgreeNode subAgreeNode : agreeNode.subNodes) {
String prefix = subAgreeNode.id + AgreeASTBuilder.dotChar;
Expr clockExpr = getClockExpr(agreeNode, subAgreeNode);
if (someoneTicks == null) {
someoneTicks = clockExpr;
} else {
someoneTicks = new BinaryExpr(someoneTicks, BinaryOp.OR, clockExpr);
}
AgreeNode flatNode = flattenAgreeNode(agreeProgram, subAgreeNode, nodePrefix + subAgreeNode.id + AgreeASTBuilder.dotChar);
Node lustreNode = addSubNodeLustre(agreeProgram, agreeNode, nodePrefix, flatNode);
addInputsAndOutputs(agreeNode, inputs, outputs, patternProps, flatNode, lustreNode, prefix);
addTimeEvents(timeEvents, flatNode, prefix, assertions);
addNodeCall(agreeNode, assertions, prefix, clockExpr, lustreNode);
addHistoricalAssumptionConstraint(agreeNode, prefix, clockExpr, assertions, lustreNode);
}
if (agreeNode.timing == TimingModel.ASYNC) {
if (someoneTicks == null) {
throw new AgreeException("Somehow we generated a clock constraint without any clocks." + " Perhaps none of your subcomponents have an agree annex?");
}
assertions.add(new AgreeStatement("someone ticks", someoneTicks, null));
}
addConnectionConstraints(agreeNode, assertions);
// add any clock constraints
assertions.addAll(agreeNode.assertions);
assertions.add(new AgreeStatement("", agreeNode.clockConstraint, null));
inputs.addAll(agreeNode.inputs);
outputs.addAll(agreeNode.outputs);
locals.addAll(agreeNode.locals);
equations.addAll(agreeNode.localEquations);
patternProps.addAll(agreeNode.patternProps);
AgreeNodeBuilder builder = new AgreeNodeBuilder(agreeNode.id);
builder.addInput(inputs);
builder.addOutput(outputs);
builder.addLocal(locals);
builder.addLocalEquation(equations);
builder.addIvcElements(agreeNode.getivcElements());
builder.addSubNode(agreeNode.subNodes);
builder.addAssertion(assertions);
builder.addAssumption(agreeNode.assumptions);
builder.addGuarantee(agreeNode.guarantees);
builder.addLemma(agreeNode.lemmas);
builder.addPatternProp(patternProps);
builder.setClockConstraint(new BoolExpr(true));
builder.setInitialConstraint(agreeNode.initialConstraint);
builder.setClockVar(agreeNode.clockVar);
builder.setReference(agreeNode.reference);
builder.setTiming(null);
builder.addEventTime(timeEvents);
builder.setCompInst(agreeNode.compInst);
builder.setFaultTreeFlag(agreeNode.faultTreeFlag);
return builder.build();
}
Aggregations