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;
}
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;
}
}
Aggregations