Search in sources :

Example 1 with CalledSubprogramHolder

use of org.osate.ba.aadlba.CalledSubprogramHolder in project osate2 by osate.

the class SubprogramCallActionImpl method basicSetSubprogram.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetSubprogram(CalledSubprogramHolder newSubprogram, NotificationChain msgs) {
    CalledSubprogramHolder oldSubprogram = subprogram;
    subprogram = newSubprogram;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AadlBaPackage.SUBPROGRAM_CALL_ACTION__SUBPROGRAM, oldSubprogram, newSubprogram);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) CalledSubprogramHolder(org.osate.ba.aadlba.CalledSubprogramHolder)

Example 2 with CalledSubprogramHolder

use of org.osate.ba.aadlba.CalledSubprogramHolder in project osate-plugin by sireum.

the class BAVisitor method caseSubprogramCallAction.

@Override
public Boolean caseSubprogramCallAction(SubprogramCallAction object) {
    Name name = null;
    List<Feature> features = null;
    CalledSubprogramHolder csh = object.getSubprogram();
    assert csh.getArrayIndexes().isEmpty() : "has array indexes: " + csh.getArrayIndexes().size();
    if (csh instanceof SubprogramSubcomponentHolder) {
        SubprogramSubcomponentHolder ssh = (SubprogramSubcomponentHolder) csh;
        assert (ssh.getArrayIndexes().isEmpty());
        name = toName(ssh.getSubcomponent().getName());
        features = ssh.getSubcomponent().getAllFeatures();
    } else {
        throw new RuntimeException("Currently only supporting subcomponent subprograms");
    }
    assert features.size() == object.getParameterLabels().size() : "feature size not equal to param labels size: " + features.size() + " vs " + object.getParameterLabels().size();
    List<BTSFormalExpPair> params = new ArrayList<>();
    for (int index = 0; index < object.getParameterLabels().size(); index++) {
        Feature f = features.get(index);
        visit(object.getParameterLabels().get(index));
        BTSExp ne = pop();
        // TODO:
        Option<Name> paramName = toSome(toSimpleName(f.getName()));
        params.add(BTSFormalExpPair$.MODULE$.apply(paramName, toSome(ne), toNone()));
    }
    push(BTSSubprogramCallAction$.MODULE$.apply(name, VisitorUtil.toISZ(params)));
    return false;
}
Also used : SubprogramSubcomponentHolder(org.osate.ba.aadlba.SubprogramSubcomponentHolder) ArrayList(java.util.ArrayList) BTSExp(org.sireum.hamr.ir.BTSExp) Feature(org.osate.aadl2.Feature) BTSFormalExpPair(org.sireum.hamr.ir.BTSFormalExpPair) Name(org.sireum.hamr.ir.Name) CalledSubprogramHolder(org.osate.ba.aadlba.CalledSubprogramHolder)

Aggregations

CalledSubprogramHolder (org.osate.ba.aadlba.CalledSubprogramHolder)2 ArrayList (java.util.ArrayList)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Feature (org.osate.aadl2.Feature)1 SubprogramSubcomponentHolder (org.osate.ba.aadlba.SubprogramSubcomponentHolder)1 BTSExp (org.sireum.hamr.ir.BTSExp)1 BTSFormalExpPair (org.sireum.hamr.ir.BTSFormalExpPair)1 Name (org.sireum.hamr.ir.Name)1