Search in sources :

Example 1 with CondactExpr

use of jkind.lustre.CondactExpr 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);
        }
    });
}
Also used : AstMapVisitor(jkind.lustre.visitors.AstMapVisitor) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) CondactExpr(jkind.lustre.CondactExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Node(jkind.lustre.Node) BinaryExpr(jkind.lustre.BinaryExpr) ArrayList(java.util.ArrayList)

Example 2 with CondactExpr

use of jkind.lustre.CondactExpr 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);
        }
    });
}
Also used : AstMapVisitor(jkind.lustre.visitors.AstMapVisitor) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) CondactExpr(jkind.lustre.CondactExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList)

Example 3 with CondactExpr

use of jkind.lustre.CondactExpr in project AGREE by loonwerks.

the class AgreeCycleVisitor method visit.

@Override
public Set<String> visit(CondactExpr e) {
    Set<String> argSet = new HashSet<>();
    for (Expr argExpr : e.args) {
        argSet.addAll(argExpr.accept(this));
    }
    argSet.addAll(e.call.accept(this));
    return argSet;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) RecordUpdateExpr(jkind.lustre.RecordUpdateExpr) CondactExpr(jkind.lustre.CondactExpr) ArrayUpdateExpr(jkind.lustre.ArrayUpdateExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) ArrayExpr(jkind.lustre.ArrayExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) RecordExpr(jkind.lustre.RecordExpr) CastExpr(jkind.lustre.CastExpr) IntExpr(jkind.lustre.IntExpr) IdExpr(jkind.lustre.IdExpr) HashSet(java.util.HashSet)

Example 4 with CondactExpr

use of jkind.lustre.CondactExpr in project AGREE by loonwerks.

the class LustreContractAstBuilder method addCondactCall.

protected static void addCondactCall(AgreeNode agreeNode, String nodePrefix, List<AgreeVar> inputs, List<AgreeStatement> assertions, AgreeNode subAgreeNode, String prefix, Expr clockExpr, Node lustreNode) {
    List<Expr> inputIds = new ArrayList<>();
    List<Expr> initOutputsVals = new ArrayList<>();
    List<IdExpr> nodeOutputIds = new ArrayList<>();
    for (VarDecl var : lustreNode.inputs) {
        inputIds.add(new IdExpr(prefix + var.id));
    }
    for (VarDecl var : lustreNode.outputs) {
        AgreeVar outputVar = (AgreeVar) var;
        String dummyName = prefix + var.id + "__DUMMY";
        AgreeVar dummyVar = new AgreeVar(dummyName, outputVar.type, outputVar.reference, outputVar.compInst, outputVar.featInst);
        if (!inputs.contains(dummyVar)) {
            inputs.add(dummyVar);
        }
        initOutputsVals.add(new IdExpr(dummyName));
        nodeOutputIds.add(new IdExpr(prefix + var.id));
    }
    if (agreeNode.timing == TimingModel.LATCHED) {
        throw new AgreeException("check how we do this in the generic lustre translation now" + " to make sure that it is correct");
    }
    Expr condactExpr = new CondactExpr(clockExpr, new NodeCallExpr(lustreNode.id, inputIds), initOutputsVals);
    Expr condactOutput;
    if (nodeOutputIds.size() > 1) {
        condactOutput = new TupleExpr(nodeOutputIds);
    } else {
        condactOutput = nodeOutputIds.get(0);
    }
    Expr condactCall = new BinaryExpr(condactOutput, BinaryOp.EQUAL, condactExpr);
    assertions.add(new AgreeStatement("", condactCall, null));
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) IdExpr(jkind.lustre.IdExpr) CondactExpr(jkind.lustre.CondactExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayList(java.util.ArrayList) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) TupleExpr(jkind.lustre.TupleExpr) 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) NodeCallExpr(jkind.lustre.NodeCallExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 5 with CondactExpr

use of jkind.lustre.CondactExpr in project AGREE by loonwerks.

the class GenerateUfcObligationsVisitor method visit.

// TODO: double check this for init expression args.
@Override
public ObligationSet visit(CondactExpr e) {
    ObligationSet obs1 = e.clock.accept(this);
    ObligationSet obs2 = e.call.accept(this);
    ObligationSet obs3 = new ObligationSet();
    for (Expr arg : e.args) {
        obs3.addAll(arg.accept(this));
    }
    // inputs are only ``effecting'' when clock is true.
    obs2.extendContext(e.clock);
    // initial arguments are only effecting before the first clock, not just instants
    // when the clock is low, but we would need a fresh variable to describe this
    // situation, so we are being somewhat inaccurate.
    obs3.extendContext(notExpr(e.clock));
    obs1.addAll(obs2);
    obs1.addAll(obs3);
    return obs1;
}
Also used : ObligationSet(com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) RecordUpdateExpr(jkind.lustre.RecordUpdateExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) RecordExpr(jkind.lustre.RecordExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayExpr(jkind.lustre.ArrayExpr) IdExpr(jkind.lustre.IdExpr) ArrayUpdateExpr(jkind.lustre.ArrayUpdateExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr)

Aggregations

BinaryExpr (jkind.lustre.BinaryExpr)7 BoolExpr (jkind.lustre.BoolExpr)7 CondactExpr (jkind.lustre.CondactExpr)7 Expr (jkind.lustre.Expr)7 IdExpr (jkind.lustre.IdExpr)7 NodeCallExpr (jkind.lustre.NodeCallExpr)7 UnaryExpr (jkind.lustre.UnaryExpr)7 IfThenElseExpr (jkind.lustre.IfThenElseExpr)6 TupleExpr (jkind.lustre.TupleExpr)5 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)4 ArrayExpr (jkind.lustre.ArrayExpr)4 ArrayUpdateExpr (jkind.lustre.ArrayUpdateExpr)4 CastExpr (jkind.lustre.CastExpr)4 FunctionCallExpr (jkind.lustre.FunctionCallExpr)4 IntExpr (jkind.lustre.IntExpr)4 RealExpr (jkind.lustre.RealExpr)4 RecordAccessExpr (jkind.lustre.RecordAccessExpr)4 RecordExpr (jkind.lustre.RecordExpr)4 RecordUpdateExpr (jkind.lustre.RecordUpdateExpr)4 ArrayList (java.util.ArrayList)3