Search in sources :

Example 26 with Equation

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;
}
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) ArrayExpr(jkind.lustre.ArrayExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) IntExpr(jkind.lustre.IntExpr) IdExpr(jkind.lustre.IdExpr) ArrayUpdateExpr(jkind.lustre.ArrayUpdateExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) RecordExpr(jkind.lustre.RecordExpr) Equation(jkind.lustre.Equation)

Example 27 with Equation

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));
    }
}
Also used : IdExpr(jkind.lustre.IdExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) Expr(jkind.lustre.Expr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation)

Example 28 with Equation

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));
        }
    }
}
Also used : IdExpr(jkind.lustre.IdExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation)

Example 29 with Equation

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);
}
Also used : VarDecl(jkind.lustre.VarDecl) Node(jkind.lustre.Node) Equation(jkind.lustre.Equation)

Example 30 with Equation

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;
}
Also used : 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) Arg(com.rockwellcollins.atc.agree.agree.Arg) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation)

Aggregations

Equation (jkind.lustre.Equation)52 IdExpr (jkind.lustre.IdExpr)48 Expr (jkind.lustre.Expr)43 BinaryExpr (jkind.lustre.BinaryExpr)40 NodeCallExpr (jkind.lustre.NodeCallExpr)35 UnaryExpr (jkind.lustre.UnaryExpr)35 VarDecl (jkind.lustre.VarDecl)34 BoolExpr (jkind.lustre.BoolExpr)33 NodeBuilder (jkind.lustre.builders.NodeBuilder)30 ArrayList (java.util.ArrayList)27 IfThenElseExpr (jkind.lustre.IfThenElseExpr)26 IntExpr (jkind.lustre.IntExpr)20 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)14 TupleExpr (jkind.lustre.TupleExpr)12 Node (jkind.lustre.Node)11 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)10 RealExpr (jkind.lustre.RealExpr)10 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)9 RecordAccessExpr (jkind.lustre.RecordAccessExpr)8 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)7