Search in sources :

Example 21 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg in project AMASE by loonwerks.

the class SetEqImpl method basicSetLhs_set.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLhs_set(Arg newLhs_set, NotificationChain msgs) {
    Arg oldLhs_set = lhs_set;
    lhs_set = newLhs_set;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.SET_EQ__LHS_SET, oldLhs_set, newLhs_set);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Arg(com.rockwellcollins.atc.agree.agree.Arg)

Example 22 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg in project AMASE by loonwerks.

the class RangeEqImpl method basicSetLhs_range.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLhs_range(Arg newLhs_range, NotificationChain msgs) {
    Arg oldLhs_range = lhs_range;
    lhs_range = newLhs_range;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.RANGE_EQ__LHS_RANGE, oldLhs_range, newLhs_range);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Arg(com.rockwellcollins.atc.agree.agree.Arg)

Example 23 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg in project VERDICT by ge-high-assurance.

the class Agree2Vdm method addNodeDefToTypeDeclarations.

private void addNodeDefToTypeDeclarations(NodeDef nodeDef, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
    Node vdmNode = new Node();
    // String agreeNodeName = nodeDef.getName();
    String agreeNodeName = nodeDef.getQualifiedName();
    vdmNode.setName(agreeNodeName);
    // SETTING NODE INPUT PARAMETERS
    // get agree node's args and set them as input parameter
    EList<Arg> nodeInpArgs = nodeDef.getArgs();
    for (Arg arg : nodeInpArgs) {
        NodeParameter nodeParameter = new NodeParameter();
        nodeParameter.setName(arg.getName());
        // get types of each arg and define those types if needed -- will be done in getVdmTypeFromAgreeType()
        nodeParameter.setDataType(getVdmTypeFromAgreeType(arg.getType(), dataTypeDecl, model));
        vdmNode.getInputParameter().add(nodeParameter);
    }
    // SETTING NODE OUTPUT PARAMETERS
    EList<Arg> nodeReturnArgs = nodeDef.getRets();
    // get agree node's rets and set them as output parameter
    for (Arg arg : nodeReturnArgs) {
        NodeParameter nodeParameter = new NodeParameter();
        nodeParameter.setName(arg.getName());
        // get types of each arg and define those types if needed -- will be done in getVdmTypeFromAgreeType()
        nodeParameter.setDataType(getVdmTypeFromAgreeType(arg.getType(), dataTypeDecl, model));
        vdmNode.getOutputParameter().add(nodeParameter);
    }
    // SETTING NODE BODY
    NodeBody vdmNodeBody = new NodeBody();
    // get agree node's body
    NodeBodyExpr agreeNodeBody = nodeDef.getNodeBody();
    EList<NodeStmt> agreeNodeStmts = agreeNodeBody.getStmts();
    for (NodeStmt agreeNodeStmt : agreeNodeStmts) {
        if (agreeNodeStmt instanceof NodeEqImpl) {
            NodeEq agreeNodeEq = (NodeEq) agreeNodeStmt;
            // get all LHS identifiers in the statement and add it to the vdm node equation LHS
            NodeEquation vdmNodeEquation = new NodeEquation();
            EList<Arg> agreeLHSArgs = agreeNodeEq.getLhs();
            // this type is just a list of strings
            NodeEquationLHS vdmNodeEquationLHS = new NodeEquationLHS();
            for (Arg agreeLHSArg : agreeLHSArgs) {
                vdmNodeEquationLHS.getIdentifier().add(agreeLHSArg.getName());
            }
            vdmNodeEquation.setLhs(vdmNodeEquationLHS);
            // get the RHS i.e.expr of the agree NodeEq and set it as the vdm node equation's RHS
            vdmNodeEquation.setRhs(getVdmExpressionFromAgreeExpression(agreeNodeEq.getExpr(), dataTypeDecl, nodeDecl, model));
            vdmNodeBody.getEquation().add(vdmNodeEquation);
        } else {
            System.out.println("Node contains non-eq type statements");
        }
    }
    vdmNode.setBody(vdmNodeBody);
    vdmNode.setIsFunction(false);
    vdmNode.setIsImported(false);
    if (!nodeDecl.contains(agreeNodeName)) {
        nodeDecl.add(agreeNodeName);
        LustreProgram lustreProgram = model.getDataflowCode();
        lustreProgram.getNodeDeclaration().add(vdmNode);
        model.setDataflowCode(lustreProgram);
    }
}
Also used : NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) NodeBody(verdict.vdm.vdm_lustre.NodeBody) Node(verdict.vdm.vdm_lustre.Node) NodeEquationLHS(verdict.vdm.vdm_lustre.NodeEquationLHS) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) NodeEquation(verdict.vdm.vdm_lustre.NodeEquation) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) NodeParameter(verdict.vdm.vdm_lustre.NodeParameter) LustreProgram(verdict.vdm.vdm_lustre.LustreProgram) Arg(com.rockwellcollins.atc.agree.agree.Arg) NodeEqImpl(com.rockwellcollins.atc.agree.agree.impl.NodeEqImpl)

Example 24 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg in project AGREE by loonwerks.

the class AgreeASTBuilder method getEquationVars.

private List<AgreeVar> getEquationVars(EList<SpecStatement> specs, ComponentInstance compInst) {
    List<AgreeVar> agreeVars = new ArrayList<>();
    for (SpecStatement spec : specs) {
        if (spec instanceof EqStatement) {
            EList<Arg> args = ((EqStatement) spec).getLhs();
            List<VarDecl> vars = agreeVarsFromArgs(args, compInst);
            for (VarDecl var : vars) {
                agreeVars.add((AgreeVar) var);
            }
        } else if (spec instanceof PropertyStatement) {
            agreeVars.add(new AgreeVar(((PropertyStatement) spec).getName(), NamedType.BOOL, spec, compInst, null));
        }
    }
    return agreeVars;
}
Also used : VarDecl(jkind.lustre.VarDecl) Arg(com.rockwellcollins.atc.agree.agree.Arg) ArrayList(java.util.ArrayList) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement)

Example 25 with Arg

use of com.rockwellcollins.atc.agree.agree.Arg in project AGREE by loonwerks.

the class AgreeASTBuilder method getEquationStatements.

private GatheredVariablesAndConstraints getEquationStatements(EList<SpecStatement> specs, Map<String, jkind.lustre.Expr> rewriteMap) {
    GatheredVariablesAndConstraints result = new GatheredVariablesAndConstraints();
    for (SpecStatement spec : specs) {
        if (spec instanceof EqStatement) {
            EqStatement eq = (EqStatement) spec;
            EList<Arg> lhs = eq.getLhs();
            if (eq.getExpr() != null) {
                Expr expr = doSwitch(eq.getExpr()).accept(new SubstitutionVisitor(rewriteMap));
                if (lhs.size() != 1) {
                    List<Expr> ids = new ArrayList<>();
                    for (Arg arg : lhs) {
                        ids.add(new IdExpr(arg.getName()));
                    }
                    TupleExpr tuple = new TupleExpr(ids);
                    expr = new BinaryExpr(tuple, BinaryOp.EQUAL, expr);
                } else {
                    expr = new BinaryExpr(new IdExpr(lhs.get(0).getName()), BinaryOp.EQUAL, expr);
                }
                result.assertions.add(new AgreeStatement("", expr, spec));
            }
            result.obligations.addAll(getConstraintsFromArgs(lhs, eq));
        }
    }
    return result;
}
Also used : IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) TupleExpr(jkind.lustre.TupleExpr) SubstitutionVisitor(jkind.translation.SubstitutionVisitor) 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) Arg(com.rockwellcollins.atc.agree.agree.Arg) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement)

Aggregations

Arg (com.rockwellcollins.atc.agree.agree.Arg)31 ArrayList (java.util.ArrayList)11 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)10 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)7 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)7 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)7 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)7 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)7 NamedElement (org.osate.aadl2.NamedElement)7 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)6 PrimType (com.rockwellcollins.atc.agree.agree.PrimType)6 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)5 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)5 Check (org.eclipse.xtext.validation.Check)5 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)4 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)4 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)4 Expr (com.rockwellcollins.atc.agree.agree.Expr)4 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)4 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)4