Search in sources :

Example 1 with AgreeOverriddenConnection

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection in project AGREE by loonwerks.

the class AgreeASTPrettyprinter method connection.

// Note: this method (and the fact that I'm using instanceof)
// means that the AGREE Ast visitor is broken
private void connection(AgreeConnection conn) {
    if (conn instanceof AgreeAADLConnection) {
        AgreeAADLConnection aadl = (AgreeAADLConnection) conn;
        write("  ");
        write(aadl.type);
        write(aadl.delayed ? " delayed" : "");
        write(aadl.latched ? " latched" : "");
        write(" connection {");
        newline();
        write("    ");
        write(aadl.sourceNode == null ? "NULL NODE" : aadl.sourceNode.id);
        write("." + aadl.sourceVarName.id);
        write(" ->");
        write(aadl.destinationNode == null ? " NULL NODE" : " " + aadl.destinationNode.id);
        write("." + aadl.destinationVarName.id);
        newline();
        write("  }");
        newline();
    } else if (conn instanceof AgreeOverriddenConnection) {
        AgreeOverriddenConnection aadl = (AgreeOverriddenConnection) conn;
        write("  connection {");
        newline();
        write("    ");
        aadl.statement.accept(this);
        newline();
        write("    aadl: " + aadl.aadlConn.toString());
        newline();
        write("  }");
        newline();
    }
}
Also used : AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection)

Example 2 with AgreeOverriddenConnection

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection in project AGREE by loonwerks.

the class AgreeASTMapVisitor method visit.

@Override
public AgreeConnection visit(AgreeConnection e) {
    if (e instanceof AgreeAADLConnection) {
        AgreeAADLConnection aadlConn = (AgreeAADLConnection) e;
        AgreeNode sourceNode = null;
        if (aadlConn.sourceNode != null) {
            sourceNode = visitedNodes.get(aadlConn.sourceNode.compInst);
        }
        AgreeNode destinationNode = null;
        if (aadlConn.destinationNode != null) {
            destinationNode = visitedNodes.get(aadlConn.destinationNode.compInst);
        }
        AgreeVar sourVar = visit(aadlConn.sourceVarName);
        AgreeVar destVar = visit(aadlConn.destinationVarName);
        ConnectionType type = aadlConn.type;
        boolean latched = aadlConn.latched;
        boolean delayed = aadlConn.delayed;
        EObject reference = aadlConn.reference;
        return new AgreeAADLConnection(sourceNode, destinationNode, sourVar, destVar, type, latched, delayed, reference);
    } else if (e instanceof AgreeOverriddenConnection) {
        AgreeOverriddenConnection overriddenCon = (AgreeOverriddenConnection) e;
        AgreeStatement statement = visit(overriddenCon.statement);
        return new AgreeOverriddenConnection(statement, overriddenCon.aadlConn);
    }
    throw new AgreeException("Unhandled Agree connection type " + e.getClass());
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) EObject(org.eclipse.emf.ecore.EObject) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 3 with AgreeOverriddenConnection

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection in project AGREE by loonwerks.

the class LustreAstBuilder method addConnectionConstraints.

protected static void addConnectionConstraints(AgreeNode agreeNode, List<AgreeStatement> assertions) {
    for (AgreeConnection conn : agreeNode.connections) {
        if (conn instanceof AgreeAADLConnection) {
            AgreeAADLConnection aadlConn = (AgreeAADLConnection) conn;
            String destName = aadlConn.destinationNode == null ? "" : aadlConn.destinationNode.id + AgreeASTBuilder.dotChar;
            destName = destName + aadlConn.destinationVarName.id;
            String sourName = aadlConn.sourceNode == null ? "" : aadlConn.sourceNode.id + AgreeASTBuilder.dotChar;
            sourName = sourName + aadlConn.sourceVarName.id;
            Expr aadlConnExpr;
            if (!aadlConn.delayed) {
                aadlConnExpr = new BinaryExpr(new IdExpr(sourName), BinaryOp.EQUAL, new IdExpr(destName));
            } else {
                // we need to get the correct type for the aadlConnection
                // we can assume that the source and destination types are
                // the same at this point
                Expr initExpr = AgreeUtils.getInitValueFromType(aadlConn.sourceVarName.type);
                Expr preSource = new UnaryExpr(UnaryOp.PRE, new IdExpr(sourName));
                Expr sourExpr = new BinaryExpr(initExpr, BinaryOp.ARROW, preSource);
                aadlConnExpr = new BinaryExpr(sourExpr, BinaryOp.EQUAL, new IdExpr(destName));
            }
            assertions.add(new AgreeStatement("", aadlConnExpr, aadlConn.reference));
        } else {
            AgreeOverriddenConnection agreeConn = (AgreeOverriddenConnection) conn;
            assertions.add(agreeConn.statement);
        }
    }
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) IdExpr(jkind.lustre.IdExpr) AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) BinaryExpr(jkind.lustre.BinaryExpr) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) UnaryExpr(jkind.lustre.UnaryExpr)

Aggregations

AgreeAADLConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection)3 AgreeOverriddenConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection)3 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)2 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)1 ConnectionType (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType)1 AgreeConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection)1 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)1 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 Expr (jkind.lustre.Expr)1 IdExpr (jkind.lustre.IdExpr)1 IntExpr (jkind.lustre.IntExpr)1 NodeCallExpr (jkind.lustre.NodeCallExpr)1 UnaryExpr (jkind.lustre.UnaryExpr)1 EObject (org.eclipse.emf.ecore.EObject)1