Search in sources :

Example 1 with NodeCallExpr

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

the class InlineNodeCalls method createAssignmentEquations.

private void createAssignmentEquations(final String prefix, List<Equation> equations, Map<String, IdExpr> translation) {
    SubstitutionVisitor substitution = new SubstitutionVisitor(translation) {

        @Override
        public Expr visit(NodeCallExpr e) {
            return new NodeCallExpr(e.location, prefix + e.node, visitExprs(e.args));
        }
    };
    for (Equation eq : equations) {
        List<IdExpr> lhs = new ArrayList<>();
        for (IdExpr idExpr : eq.lhs) {
            lhs.add(translation.get(idExpr.id));
        }
        Expr expr = eq.expr.accept(substitution);
        queue.add(new Equation(eq.location, lhs, expr));
    }
}
Also used : SubstitutionVisitor(jkind.translation.SubstitutionVisitor) IdExpr(jkind.lustre.IdExpr) TupleExpr(jkind.lustre.TupleExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation)

Example 2 with NodeCallExpr

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

the class InlineNodeCalls method visit.

@Override
public Expr visit(NodeCallExpr e) {
    // Detect duplicate node calls to reduce code size
    String key = getKey(e);
    if (inlinedCalls.containsKey(key)) {
        return inlinedCalls.get(key);
    } else {
        Expr result = TupleExpr.compress(visitNodeCallExpr(e));
        inlinedCalls.put(key, result);
        return result;
    }
}
Also used : TupleExpr(jkind.lustre.TupleExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr)

Example 3 with NodeCallExpr

use of jkind.lustre.NodeCallExpr 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 4 with NodeCallExpr

use of jkind.lustre.NodeCallExpr 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 5 with NodeCallExpr

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

the class AgreeASTBuilder method getMNSynchConstraint.

private Expr getMNSynchConstraint(MNSynchStatement sync) {
    Set<String> nodeNames = new HashSet<>();
    Expr clockAssertion = new BoolExpr(true);
    for (int i = 0; i < sync.getComp1().size(); i++) {
        Subcomponent maxComp = (Subcomponent) sync.getComp1().get(i);
        Subcomponent minComp = (Subcomponent) sync.getComp2().get(i);
        Expr maxClock = new IdExpr(maxComp.getName() + clockIDSuffix);
        Expr minClock = new IdExpr(minComp.getName() + clockIDSuffix);
        int max = Integer.valueOf(sync.getMax().get(i));
        int min = Integer.valueOf(sync.getMin().get(i));
        MNSynchronyElement elem = new MNSynchronyElement(maxClock, minClock, max, min);
        String nodeName = "__calendar_node_" + elem.max + "_" + elem.min;
        nodeName = getObjectLocationPrefix(sync) + nodeName;
        if (!nodeNames.contains(nodeName)) {
            nodeNames.add(nodeName);
            Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, elem.max, elem.min);
            addToNodeList(calNode);
        }
        NodeCallExpr nodeCall = new NodeCallExpr(nodeName, elem.maxClock, elem.minClock);
        clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
        nodeCall = new NodeCallExpr(nodeName, elem.minClock, elem.maxClock);
        clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
    }
    return clockAssertion;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Subcomponent(org.osate.aadl2.Subcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Node(jkind.lustre.Node) HashSet(java.util.HashSet) MNSynchronyElement(com.rockwellcollins.atc.agree.analysis.MNSynchronyElement)

Aggregations

NodeCallExpr (jkind.lustre.NodeCallExpr)21 Expr (jkind.lustre.Expr)20 IdExpr (jkind.lustre.IdExpr)20 BinaryExpr (jkind.lustre.BinaryExpr)17 BoolExpr (jkind.lustre.BoolExpr)16 UnaryExpr (jkind.lustre.UnaryExpr)15 ArrayList (java.util.ArrayList)13 IfThenElseExpr (jkind.lustre.IfThenElseExpr)13 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)9 IntExpr (jkind.lustre.IntExpr)7 RecordAccessExpr (jkind.lustre.RecordAccessExpr)7 TupleExpr (jkind.lustre.TupleExpr)7 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)6 Node (jkind.lustre.Node)6 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)5 RealExpr (jkind.lustre.RealExpr)5 CondactExpr (jkind.lustre.CondactExpr)4 VarDecl (jkind.lustre.VarDecl)4 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)3 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)3