Search in sources :

Example 1 with QualifiedNamedElement

use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.

the class AadlBaNameResolver method resolveProperty.

private Property resolveProperty(QualifiedNamedElement qne) {
    String packageName = "";
    boolean hasNamespace = qne.getBaNamespace() != null;
    if (hasNamespace) {
        packageName = qne.getBaNamespace().getId();
    }
    NamedElement propNE = Aadl2Visitors.findElementInPropertySet(qne.getBaName().getId(), packageName, Aadl2Visitors.getContainingPackageSection(_ba));
    return (Property) propNE;
}
Also used : QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Example 2 with QualifiedNamedElement

use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.

the class AadlBaNameResolver method qualifiedNamedElementResolver.

private boolean qualifiedNamedElementResolver(QualifiedNamedElement qne, boolean hasToReport) {
    String packageName = null;
    EObject ne;
    boolean hasNamespace = qne.getBaNamespace() != null;
    if (hasNamespace) {
        packageName = qne.getBaNamespace().getId();
    }
    // Now check the type in each current package's sections.
    for (PackageSection context : _contextsTab) {
        NamedElement parent = (NamedElement) _ba.eContainer().eContainer();
        ne = Aadl2Visitors.findSubcomponentInComponent((Classifier) parent, qne.getBaName().getId());
        if (ne == null) {
            ne = Aadl2Visitors.findFeatureInComponent((Classifier) parent, qne.getBaName().getId());
        }
        if (ne == null) {
            ne = Aadl2Visitors.findElementInPackage(qne.getBaName().getId(), packageName, context);
        }
        if (ne == null) {
            ne = Aadl2Visitors.findElementInPropertySet(qne.getBaName().getId(), packageName, context);
        }
        // An element is found.
        if (ne != null && ne instanceof NamedElement) {
            // Links unique component classifier reference with named element found.
            qne.setOsateRef((Element) ne);
            qne.getBaName().setOsateRef((Element) ne);
            if (hasNamespace) {
                qne.getBaNamespace().setOsateRef(((NamedElement) ne).getNamespace());
            }
            return true;
        }
    }
    // The element is not found.
    if (hasToReport) {
        StringBuilder qualifiedName = new StringBuilder();
        if (hasNamespace) {
            qualifiedName.append(qne.getBaNamespace().getId());
            qualifiedName.append("::");
        }
        qualifiedName.append(qne.getBaName().getId());
        reportNameError(qne, qualifiedName.toString());
    }
    return false;
}
Also used : PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 3 with QualifiedNamedElement

use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.

the class AadlBaNameResolver method behaviorActionResolver.

private boolean behaviorActionResolver(BehaviorAction act) {
    boolean result = true;
    // Case of basic action.
    if (act instanceof BasicAction) {
        result = basicActionResolver((BasicAction) act);
    } else {
        if (act instanceof BehaviorActionBlock) {
            result = behaviorActionBlockResolver((BehaviorActionBlock) act);
        } else {
            // Case of IF statement.
            if (act instanceof IfStatement) {
                result = ifStatementResolver((IfStatement) act);
            } else {
                // Case if WHILE and DO UNTIL statement.
                if (act instanceof WhileOrDoUntilStatement) {
                    WhileOrDoUntilStatement stat = (WhileOrDoUntilStatement) act;
                    result = valueExpressionResolver(stat.getLogicalValueExpression());
                    result &= behaviorActionsResolver(stat.getBehaviorActions());
                } else // Case of FOR and FOR ALL statement.
                {
                    ForOrForAllStatement stat = (ForOrForAllStatement) act;
                    IterativeVariable itVar = stat.getIterativeVariable();
                    // Resolves unique component classifier reference.
                    QualifiedNamedElement uccr = (QualifiedNamedElement) itVar.getDataClassifier();
                    result = qualifiedNamedElementResolver(uccr, true);
                    // Checks the for/forall's iterative variable.
                    result &= iterativeVariableUniquenessCheck(itVar);
                    // Add the for/forall statment's iterative variable to
                    // the scope handler.
                    _itvScope.add(itVar);
                    // Check element values.
                    result &= elementValuesResolver(stat.getIteratedValues());
                    // Check behavior actions.
                    result &= behaviorActionsResolver(stat.getBehaviorActions());
                    // remove the for/forall statment's iterative variable from
                    // the scope handler (after checking for/forall's behavior
                    // actions.
                    _itvScope.remove(itVar);
                }
            }
        // End of third else.
        }
    // End of second else.
    }
    return result;
}
Also used : IfStatement(org.osate.ba.aadlba.IfStatement) IterativeVariable(org.osate.ba.aadlba.IterativeVariable) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) BasicAction(org.osate.ba.aadlba.BasicAction) WhileOrDoUntilStatement(org.osate.ba.aadlba.WhileOrDoUntilStatement) BehaviorActionBlock(org.osate.ba.aadlba.BehaviorActionBlock) ForOrForAllStatement(org.osate.ba.aadlba.ForOrForAllStatement)

Example 4 with QualifiedNamedElement

use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.

the class AadlBaTypeChecker method behaviorVariableCheck.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Semantic rule
 * Section : D.3 Behavior Specification
 * Object : Check semantic rule D.3.(28)
 * Keys : local variables explicitly typed valid data component classifier
 */
private boolean behaviorVariableCheck() {
    boolean result = true;
    IntegerValueConstant ivc = null;
    QualifiedNamedElement uccr;
    for (BehaviorVariable bv : _ba.getVariables()) {
        uccr = (QualifiedNamedElement) bv.getDataClassifier();
        DataClassifier dc = (DataClassifier) uniqueNamedElementReferenceResolver(uccr, TypeCheckRule.DATA_UCCR);
        _hl.addToHyperlinking(uccr.getAadlBaLocationReference(), dc);
        result &= dc != null;
        bv.setDataClassifier(dc);
        for (PropertyAssociation pa : bv.getOwnedPropertyAssociations()) {
            Property p = (Property) uniqueNamedElementReferenceResolver((QualifiedNamedElement) pa.getProperty(), TypeCheckRule.PROPERTY);
            pa.setProperty(p);
        }
        ListIterator<ArrayDimension> it = bv.getArrayDimensions().listIterator();
        while (it.hasNext()) {
            ArrayDimension tmp = it.next();
            DeclarativeArrayDimension dad = (DeclarativeArrayDimension) tmp;
            ivc = dad.getDimension();
            ivc = integerValueConstantCheck(ivc);
            result &= ivc != null;
            // integervalueConstantCheck method. So replace if needed.
            if (ivc != null) {
                it.set(integerValueConstantToArrayDimension(ivc));
            }
        }
    }
    return result;
}
Also used : QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeArrayDimension(org.osate.ba.declarative.DeclarativeArrayDimension) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DataClassifier(org.osate.aadl2.DataClassifier) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) ArrayDimension(org.osate.aadl2.ArrayDimension) DeclarativeArrayDimension(org.osate.ba.declarative.DeclarativeArrayDimension)

Example 5 with QualifiedNamedElement

use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.

the class AadlBaTypeChecker method portDequeueActionResolver.

private PortDequeueAction portDequeueActionResolver(CommAction comAct) {
    // if already resolved, check port ref is event or event data port
    QualifiedNamedElement qne = comAct.getQualifiedName();
    if (qne != null) {
        boolean isOfExpectedType = qne.getOsateRef() instanceof EventPort || qne.getOsateRef() instanceof EventDataPort;
        if (!isOfExpectedType) {
            String name = "referenced object";
            if (qne.getOsateRef() instanceof NamedElement) {
                NamedElement ne = (NamedElement) qne.getOsateRef();
                name = ne.getName();
            } else if (qne.getBaRef() instanceof BehaviorNamedElement) {
                BehaviorNamedElement bne = (BehaviorNamedElement) qne.getBaRef();
                name = bne.getName();
            } else if (qne.getBaName().getId() != null) {
                name = qne.getBaName().getId();
            } else if (qne.getName() != null) {
                name = qne.getName();
            }
            reportError(comAct, "incorrect port dequeue action, " + name + " is not an event [data] port");
            return null;
        }
    } else if (comAct.getReference() == null) {
        return null;
    }
    Target tarTmp = null;
    boolean tarCheckResult = true;
    TypeCheckRule stopOnThisRule = TypeCheckRule.IN_PORT;
    TypeCheckRule checkRule = TypeCheckRule.PORT_DEQUEUE_VALUE;
    List<ElementHolder> resolvedRef = refResolver(comAct.getReference(), null, stopOnThisRule, checkRule);
    if (resolvedRef != null) {
        PortHolder portHolder = (PortHolder) resolvedRef.get(0);
        return portDequeueActionResolver(portHolder, comAct);
    } else {
        return null;
    }
}
Also used : QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) EventPort(org.osate.aadl2.EventPort) EventDataPort(org.osate.aadl2.EventDataPort) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)21 DataClassifier (org.osate.aadl2.DataClassifier)8 NamedElement (org.osate.aadl2.NamedElement)6 BasicProperty (org.osate.aadl2.BasicProperty)5 Classifier (org.osate.aadl2.Classifier)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)5 Identifier (org.osate.ba.declarative.Identifier)5 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)4 Property (org.osate.aadl2.Property)4 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)4 ArrayableIdentifier (org.osate.ba.declarative.ArrayableIdentifier)4 DeclarativePropertyReference (org.osate.ba.declarative.DeclarativePropertyReference)4 ArrayList (java.util.ArrayList)3 ArrayDimension (org.osate.aadl2.ArrayDimension)3 IterativeVariable (org.osate.ba.aadlba.IterativeVariable)3 Reference (org.osate.ba.declarative.Reference)3 EObject (org.eclipse.emf.ecore.EObject)2 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2