use of com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement in project AGREE by loonwerks.
the class LustreContractAstBuilder method getLustreNode.
protected static Node getLustreNode(AgreeNode agreeNode, String nodePrefix) {
List<VarDecl> inputs = new ArrayList<>();
List<VarDecl> outputs = new ArrayList<>();
List<VarDecl> locals = new ArrayList<>();
List<Equation> equations = new ArrayList<>();
List<Expr> assertions = new ArrayList<>();
List<Expr> requires = new ArrayList<>();
List<Expr> ensures = new ArrayList<>();
for (AgreeStatement statement : agreeNode.assumptions) {
requires.add(statement.expr);
}
for (AgreeStatement statement : agreeNode.lemmas) {
ensures.add(statement.expr);
}
for (AgreeStatement statement : agreeNode.guarantees) {
ensures.add(statement.expr);
}
for (AgreeStatement statement : agreeNode.assertions) {
assertions.add(statement.expr);
if (AgreeUtils.referenceIsInContract(statement.reference, agreeNode.compInst)) {
ensures.add(statement.expr);
}
}
// gather the remaining inputs
for (AgreeVar var : agreeNode.inputs) {
inputs.add(var);
}
for (AgreeVar var : agreeNode.outputs) {
outputs.add(var);
}
// Contract contract = new Contract(nodePrefix + agreeNode.id, requires, ensures);
Contract contract = new Contract(requires, ensures);
NodeBuilder builder = new NodeBuilder(nodePrefix + agreeNode.id);
builder.addInputs(inputs);
builder.addOutputs(outputs);
builder.addLocals(locals);
builder.addEquations(equations);
builder.addAssertions(assertions);
builder.setContract(contract);
return builder.build();
}
Aggregations