Search in sources :

Example 1 with NamedValue

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

the class AadlBaParserVisitor method visitValue_variable.

/**
 * {@inheritDoc}
 * <p/>
 * The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.
 */
@Override
public T visitValue_variable(@NotNull AadlBaParser.Value_variableContext ctx) {
    visitChildren(ctx);
    Reference tmp = ctx.reference().result;
    if (ctx.TICK() != null) {
        if (ctx.COUNT() != null) {
            NamedValue nv = _decl.createNamedValue();
            _dba.getDeclarativeBehaviorElements().add(nv);
            nv.setReference(tmp);
            nv.setCount(true);
            nv.setLocationReference(tmp.getLocationReference());
            ctx.result = nv;
        } else {
            NamedValue nv = _decl.createNamedValue();
            _dba.getDeclarativeBehaviorElements().add(nv);
            nv.setReference(tmp);
            nv.setFresh(true);
            nv.setLocationReference(tmp.getLocationReference());
            ctx.result = nv;
        }
    } else if (ctx.INTERROG() != null) {
        NamedValue nv = _decl.createNamedValue();
        _dba.getDeclarativeBehaviorElements().add(nv);
        nv.setReference(tmp);
        nv.setDequeue(true);
        nv.setLocationReference(tmp.getLocationReference());
        ctx.result = nv;
    } else {
        ctx.result = tmp;
    }
    return null;
}
Also used : PropertyReference(org.osate.ba.aadlba.PropertyReference) AadlBaLocationReference(org.osate.ba.utils.AadlBaLocationReference) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) PropertySetPropertyReference(org.osate.ba.aadlba.PropertySetPropertyReference) ClassifierFeaturePropertyReference(org.osate.ba.aadlba.ClassifierFeaturePropertyReference) ClassifierPropertyReference(org.osate.ba.aadlba.ClassifierPropertyReference) Reference(org.osate.ba.declarative.Reference) NamedValue(org.osate.ba.declarative.NamedValue)

Example 2 with NamedValue

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

the class AadlBaTypeChecker method valueVariableCheck.

// This method checks the given object and returns a value variable
// resolved from semantic ambiguities and its data representation. On error,
// reports error and returns null.
private ValueAndTypeHolder valueVariableCheck(ValueVariable v) {
    List<ElementHolder> ehl = null;
    ValueVariable tmpResult = null;
    ActualPortHolder port;
    TypeCheckRule stopRule;
    TypeCheckRule[] checkRules;
    if (v instanceof Reference) {
        port = null;
        stopRule = TypeCheckRule.VV_STOP_RULE;
        checkRules = new TypeCheckRule[] { TypeCheckRule.VV_COMPONENT_REFERENCE_FIRST_NAME, TypeCheckRule.DATA_COMPONENT_REFERENCE_OTHER_NAMES };
    } else // NamedValue case.
    {
        NamedValue nv = (NamedValue) v;
        v = nv.getReference();
        if (nv.isCount()) {
            port = _fact.createPortCountValue();
            stopRule = TypeCheckRule.PORT_COUNT_VALUE;
        } else if (nv.isDequeue()) {
            port = _fact.createPortDequeueValue();
            stopRule = TypeCheckRule.PORT_DEQUEUE_VALUE;
        } else {
            port = _fact.createPortFreshValue();
            stopRule = TypeCheckRule.PORT_FRESH_VALUE;
        }
        port.setLocationReference(v.getLocationReference());
        checkRules = new TypeCheckRule[] { stopRule };
    }
    ehl = refResolver((Reference) v, port, stopRule, checkRules);
    if (ehl != null) {
        tmpResult = referenceToValueVariable(ehl);
        if (tmpResult instanceof PortFreshValue) {
            PortFreshValue pfv = (PortFreshValue) tmpResult;
            AadlBaVisitors.putFreshPort(_ba, pfv.getPort());
        }
        return this.getValueAndTypeHolder(tmpResult, v);
    } else {
        return null;
    }
}
Also used : LocationReference(org.osate.aadl2.parsesupport.LocationReference) Reference(org.osate.ba.declarative.Reference) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) NamedValue(org.osate.ba.declarative.NamedValue)

Aggregations

DeclarativePropertyReference (org.osate.ba.declarative.DeclarativePropertyReference)2 NamedValue (org.osate.ba.declarative.NamedValue)2 Reference (org.osate.ba.declarative.Reference)2 LocationReference (org.osate.aadl2.parsesupport.LocationReference)1 ClassifierFeaturePropertyReference (org.osate.ba.aadlba.ClassifierFeaturePropertyReference)1 ClassifierPropertyReference (org.osate.ba.aadlba.ClassifierPropertyReference)1 PropertyReference (org.osate.ba.aadlba.PropertyReference)1 PropertySetPropertyReference (org.osate.ba.aadlba.PropertySetPropertyReference)1 AadlBaLocationReference (org.osate.ba.utils.AadlBaLocationReference)1