Search in sources :

Example 6 with IterativeVariable

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

the class AadlBaParserVisitor method visitFor_condition.

/**
 * {@inheritDoc}
 * <p/>
 * The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.
 */
@Override
public T visitFor_condition(@NotNull AadlBaParser.For_conditionContext ctx) {
    visitChildren(ctx);
    ctx.result = _baFact.createForOrForAllStatement();
    ctx.result.setForAll(false);
    setLocationReference(ctx.result, ctx.FOR());
    IterativeVariable itVar = _baFact.createIterativeVariable();
    itVar.setName(ctx.IDENT().getText());
    setLocationReference(itVar, ctx.IDENT());
    ctx.result.setIterativeVariable(itVar);
    _dba.getDeclarativeBehaviorElements().add(ctx.unique_component_classifier_reference().result);
    itVar.setDataClassifier(ctx.unique_component_classifier_reference().result);
    ctx.result.setIteratedValues(ctx.element_values().result);
    return null;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable)

Example 7 with IterativeVariable

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

the class AadlBaUtils method getBehaviorAnnexFeatureType.

/**
 * Analyze the given behavior annex feature and returns its type.
 *
 * @param el the given behavior annex feature
 * @return the given behavior annex feature's type
 * @exception UnsupportedOperationException for the unsupported types
 */
public static BehaviorFeatureType getBehaviorAnnexFeatureType(BehaviorElement el) {
    if (el instanceof org.osate.ba.aadlba.BehaviorVariable) {
        return BehaviorFeatureType.BEHAVIOR_VARIABLE;
    } else if (el instanceof IterativeVariable) {
        return BehaviorFeatureType.ITERATIVE_VARIABLE;
    }
    String errorMsg = "feature : " + el.getClass().getSimpleName() + " is not supported yet.";
    System.err.println(errorMsg);
    throw new UnsupportedOperationException(errorMsg);
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) AadlString(org.osate.aadl2.AadlString)

Example 8 with IterativeVariable

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

the class AadlBaNameResolver method refResolver.

// Resolves Reference objects (arrayable identifiers)
// within parent component's features ones and ba's variables ones and
// for/forall's iterative variable scope handler.
private boolean refResolver(Classifier parentContainer, Reference ref) {
    boolean result = true;
    boolean currentIdResult = false;
    ListIterator<ArrayableIdentifier> it = ref.getIds().listIterator();
    // Checks ArrayableIdentifier objects.
    while (it.hasNext()) {
        ArrayableIdentifier id = it.next();
        // Can't resolve within a null parent classifier.
        if (parentContainer == null) {
            result = false;
            reportNameError(id, id.getId());
            break;
        }
        if (parentContainer == _baParentContainer) {
            currentIdResult = identifierBaResolver(id, false);
        }
        if (!currentIdResult) {
            currentIdResult = identifierComponentResolver(id, parentContainer, true);
        }
        if (id.isSetArrayIndexes()) {
            // Checks array indexes names.
            for (IntegerValue index : id.getArrayIndexes()) {
                // Recursive call.
                result &= integerValueResolver(index);
            }
        }
        // If the current id is found, fetch the container for the next id.
        if (currentIdResult && it.hasNext()) {
            Element el = AadlBaTypeChecker.getBindedElement(id);
            // not been type checked already.
            if (el instanceof BehaviorVariable) {
                QualifiedNamedElement qne = (QualifiedNamedElement) ((BehaviorVariable) el).getDataClassifier();
                parentContainer = (Classifier) qne.getOsateRef();
            } else if (el instanceof IterativeVariable) {
                IterativeVariable itv = (IterativeVariable) el;
                QualifiedNamedElement qne = (QualifiedNamedElement) itv.getDataClassifier();
                parentContainer = (Classifier) qne.getOsateRef();
            } else {
                parentContainer = AadlBaUtils.getClassifier(el, parentContainer);
            }
        }
        // Add the current id result to the global result.
        result &= currentIdResult;
        // Reset.
        currentIdResult = false;
        // Don't continue if the current id is not found.
        if (result == false) {
            break;
        }
    }
    // Binds with the last id reference.
    ArrayableIdentifier lastId = ref.getIds().get((ref.getIds().size() - 1));
    ref.setOsateRef(lastId.getOsateRef());
    ref.setBaRef(lastId.getBaRef());
    return result;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) IntegerValue(org.osate.ba.aadlba.IntegerValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier)

Example 9 with IterativeVariable

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

the class ForOrForAllStatementImpl method basicSetIterativeVariable.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetIterativeVariable(IterativeVariable newIterativeVariable, NotificationChain msgs) {
    IterativeVariable oldIterativeVariable = iterativeVariable;
    iterativeVariable = newIterativeVariable;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AadlBaPackage.FOR_OR_FOR_ALL_STATEMENT__ITERATIVE_VARIABLE, oldIterativeVariable, newIterativeVariable);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

IterativeVariable (org.osate.ba.aadlba.IterativeVariable)9 DataClassifier (org.osate.aadl2.DataClassifier)4 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)4 AadlString (org.osate.aadl2.AadlString)3 Element (org.osate.aadl2.Element)3 NamedElement (org.osate.aadl2.NamedElement)3 BehaviorElement (org.osate.ba.aadlba.BehaviorElement)3 Classifier (org.osate.aadl2.Classifier)2 ComponentClassifier (org.osate.aadl2.ComponentClassifier)2 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)2 BehaviorActionBlock (org.osate.ba.aadlba.BehaviorActionBlock)2 ForOrForAllStatement (org.osate.ba.aadlba.ForOrForAllStatement)2 IntegerValue (org.osate.ba.aadlba.IntegerValue)2 StructUnionElement (org.osate.ba.aadlba.StructUnionElement)2 ArrayableIdentifier (org.osate.ba.declarative.ArrayableIdentifier)2 QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)2 Iterator (java.util.Iterator)1 AbstractEnumerator (org.eclipse.emf.common.util.AbstractEnumerator)1 EList (org.eclipse.emf.common.util.EList)1 Enumerator (org.eclipse.emf.common.util.Enumerator)1