Search in sources :

Example 1 with BTSNameExp

use of org.sireum.hamr.ir.BTSNameExp in project osate-plugin by sireum.

the class BAVisitor method caseClassifierPropertyReference.

@Override
public Boolean caseClassifierPropertyReference(ClassifierPropertyReference object) {
    if (object.getProperties().size() == 2) {
        Element firstElem = object.getProperties().get(0).getProperty().getElement();
        if (firstElem instanceof PropertyAssociation) {
            PropertyAssociation pa = (PropertyAssociation) firstElem;
            if (pa.getProperty().getName().equals("Enumerators")) {
                Element secondElem = object.getProperties().get(1).getProperty().getElement();
                if (secondElem instanceof StringLiteral) {
                    // TODO can we trust BA that this a valid enum value
                    StringLiteral sl = ((StringLiteral) secondElem);
                    BTSNameExp ne = BTSNameExp$.MODULE$.apply(toSimpleName(object.getClassifier().getQualifiedName()), toNone());
                    push(BTSAccessExp$.MODULE$.apply(ne, sl.getValue(), toNone()));
                } else {
                    throw new RuntimeException("Looks like an enum ref but second element isn't a string lit");
                }
            }
        } else {
            throw new RuntimeException("What is this " + object);
        }
    } else {
        throw new RuntimeException("Need to handle this case " + object);
    }
    return false;
}
Also used : BTSNameExp(org.sireum.hamr.ir.BTSNameExp) BehaviorStringLiteral(org.osate.ba.aadlba.BehaviorStringLiteral) StringLiteral(org.osate.aadl2.StringLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) NamedElement(org.osate.aadl2.NamedElement) Element(org.osate.aadl2.Element)

Example 2 with BTSNameExp

use of org.sireum.hamr.ir.BTSNameExp in project osate-plugin by sireum.

the class BAVisitor method caseDataComponentReference.

@Override
public Boolean caseDataComponentReference(DataComponentReference object) {
    // name exp followed by access ??
    assert (object.getData().size() >= 2);
    visit(object.getData().get(0));
    BTSNameExp exp = pop();
    visit(object.getData().get(1));
    String attributeName = pop();
    BTSAccessExp bts = BTSAccessExp$.MODULE$.apply(exp, attributeName, toNone());
    for (int i = 2; i < object.getData().size(); i++) {
        visit(object.getData().get(i));
        attributeName = pop();
        bts = BTSAccessExp$.MODULE$.apply(bts, attributeName, toNone());
    }
    push(bts);
    return false;
}
Also used : BTSNameExp(org.sireum.hamr.ir.BTSNameExp) BTSAccessExp(org.sireum.hamr.ir.BTSAccessExp)

Aggregations

BTSNameExp (org.sireum.hamr.ir.BTSNameExp)2 Element (org.osate.aadl2.Element)1 NamedElement (org.osate.aadl2.NamedElement)1 PropertyAssociation (org.osate.aadl2.PropertyAssociation)1 StringLiteral (org.osate.aadl2.StringLiteral)1 BehaviorStringLiteral (org.osate.ba.aadlba.BehaviorStringLiteral)1 BTSAccessExp (org.sireum.hamr.ir.BTSAccessExp)1