use of jkind.lustre.Equation in project AGREE by loonwerks.
the class PrettyPrintVisitor method visit.
@Override
public Void visit(Node node) {
write("node ");
write(node.id);
write("(");
newline();
varDecls(node.inputs);
newline();
write(") returns (");
newline();
varDecls(node.outputs);
newline();
write(");");
newline();
if (!node.locals.isEmpty()) {
write("var");
newline();
varDecls(node.locals);
write(";");
newline();
}
write("let");
newline();
if (node.id.equals(main)) {
write(" --%MAIN");
newline();
}
for (Equation equation : node.equations) {
write(" ");
equation.accept(this);
newline();
newline();
}
for (Expr assertion : node.assertions) {
assertion(assertion);
newline();
}
if (!node.properties.isEmpty()) {
for (String property : node.properties) {
property(property);
}
newline();
}
if (node.realizabilityInputs != null) {
write(" --%REALIZABLE ");
write(node.realizabilityInputs.stream().collect(joining(", ")));
write(";");
newline();
newline();
}
write("tel;");
return null;
}
use of jkind.lustre.Equation in project AMASE by loonwerks.
the class FaultASTBuilder method constructNodeCallExpr.
/**
* Construct the node call expression using the class list nodeArgs.
* Take into account any record types by accessing info collected previously in
* "dotField." If dotField is an empty string, there is no record field. If not,
* this holds the referenced field. For instance, if the total name is:
* sender.output
* then dotField = output
* If the total name is simply
* sender
* then dotField = ""
* The node call expression is added to the node builder at the end of this
* method.
*
* @param node NodeBuilder
* @param fault Fault
* @param dotField String
*/
private void constructNodeCallExpr(NodeBuilder node, Fault fault, String dotField) {
if (dotField.isEmpty()) {
NodeCallExpr nodeCall = new NodeCallExpr(fault.faultNode.id, nodeArgs);
node.addEquation(new Equation(new IdExpr(getFaultNodeOutputId(fault)), nodeCall));
} else {
List<Expr> newList = new ArrayList<>();
for (Expr ex : nodeArgs) {
if (ex instanceof IdExpr) {
IdExpr idEx = (IdExpr) ex;
if (idEx.id.equalsIgnoreCase("__fault__nominal__output")) {
IdExpr newId = new IdExpr(idEx.id + dotField);
newList.add(newId);
} else {
newList.add(ex);
}
} else {
newList.add(ex);
}
}
NodeCallExpr nodeCall = new NodeCallExpr(fault.faultNode.id, newList);
node.addEquation(new Equation(new IdExpr(getFaultNodeOutputId(fault)), nodeCall));
}
}
use of jkind.lustre.Equation in project AMASE by loonwerks.
the class AsymFaultASTBuilder method constructNodeCalls.
/**
* Construct the calls to the fault nodes with arguments in proper order.
* Add this to the comm node equations.
*
* @param newNode NodeBuilder for this comm node.
* @param fault Fault definition for fault node.
* @param dotField String that holds field if record type.
*/
private void constructNodeCalls(NodeBuilder newNode, String dotField) {
if (dotField.isEmpty()) {
for (Fault output : nodeArguments.keySet()) {
NodeCallExpr nodeCall = new NodeCallExpr(output.faultNode.id, nodeArguments.get(output));
newNode.addEquation(new Equation(new IdExpr(output.id + "__node__" + output.faultNode.outputs.get(0).id), nodeCall));
}
} else {
List<Expr> newList = new ArrayList<>();
for (Fault output : nodeArguments.keySet()) {
for (Expr ex : nodeArguments.get(output)) {
if (ex instanceof IdExpr) {
IdExpr idEx = (IdExpr) ex;
if (idEx.id.equalsIgnoreCase("__fault__nominal__output")) {
IdExpr newId = new IdExpr(idEx.id + dotField);
newList.add(newId);
} else {
newList.add(ex);
}
} else {
newList.add(ex);
}
}
NodeCallExpr nodeCall = new NodeCallExpr(output.faultNode.id, newList);
newNode.addEquation(new Equation(new IdExpr(output.id + "__node__" + output.faultNode.outputs.get(0).id), nodeCall));
}
}
}
use of jkind.lustre.Equation in project AMASE by loonwerks.
the class AddFaultDriverVisitor method visit.
@Override
public Node visit(Node node) {
List<VarDecl> inputs = Lists.newArrayList(node.inputs);
List<Equation> equations = Lists.newArrayList(node.equations);
if (node.id.equals(targetSubnodeName)) {
equations = visitEquations(node.equations);
inputs.add(new VarDecl(getFaultDriverId(targetVarName), NamedType.BOOL));
liftedTargetSubnodeInputs.add(getFaultDriverId(targetVarName));
}
return new Node(node.location, node.id, inputs, node.outputs, node.locals, equations, node.properties, node.assertions, node.realizabilityInputs, node.contract, node.ivc);
}
use of jkind.lustre.Equation in project AGREE by loonwerks.
the class AgreeASTBuilder method nodeEqToEq.
// helper method for above
private Equation nodeEqToEq(NodeEq nodeEq) {
Expr expr = doSwitch(nodeEq.getExpr());
List<IdExpr> ids = new ArrayList<>();
for (Arg arg : nodeEq.getLhs()) {
ids.add(new IdExpr(arg.getName()));
}
Equation eq = new Equation(ids, expr);
return eq;
}
Aggregations