Search in sources :

Example 56 with AgreeStatement

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();
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) VarDecl(jkind.lustre.VarDecl) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation) NodeBuilder(jkind.lustre.builders.NodeBuilder) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) Contract(jkind.lustre.Contract) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Aggregations

AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)56 IdExpr (jkind.lustre.IdExpr)50 Expr (jkind.lustre.Expr)49 BinaryExpr (jkind.lustre.BinaryExpr)47 NodeCallExpr (jkind.lustre.NodeCallExpr)45 BoolExpr (jkind.lustre.BoolExpr)44 UnaryExpr (jkind.lustre.UnaryExpr)40 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)39 IfThenElseExpr (jkind.lustre.IfThenElseExpr)28 ArrayList (java.util.ArrayList)25 IntExpr (jkind.lustre.IntExpr)23 RecordAccessExpr (jkind.lustre.RecordAccessExpr)19 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)15 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)13 RealExpr (jkind.lustre.RealExpr)13 VarDecl (jkind.lustre.VarDecl)13 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)12 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)11 Equation (jkind.lustre.Equation)11 TupleExpr (jkind.lustre.TupleExpr)11