Search in sources :

Example 1 with BTSFormalExpPair

use of org.sireum.hamr.ir.BTSFormalExpPair 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

ArrayList (java.util.ArrayList)1 Feature (org.osate.aadl2.Feature)1 CalledSubprogramHolder (org.osate.ba.aadlba.CalledSubprogramHolder)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