use of org.osate.ba.declarative.Identifier in project osate2 by osate.
the class AadlBaTypeChecker method behaviorTimeCheck.
private boolean behaviorTimeCheck(DeclarativeTime dbt, BehaviorTime result) {
IntegerValue tmp = integerValueCheck(dbt.getIntegerValue());
// method. So replace if needed.
if (tmp != null) {
result.setIntegerValue(tmp);
Identifier unitId = dbt.getUnitId();
result.setUnit((UnitLiteral) unitId.getOsateRef());
result.setLocationReference(dbt.getLocationReference());
}
return tmp != null;
}
use of org.osate.ba.declarative.Identifier in project osate2 by osate.
the class AadlBaNameResolver method propertySetpropertyReferenceResolver.
private boolean propertySetpropertyReferenceResolver(DeclarativePropertyReference ref) {
Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
String packageName = null;
if (ref.getQualifiedName() != null) {
packageName = ref.getQualifiedName().getBaNamespace().getId();
}
NamedElement ne = null;
// Now check the type in each current package's sections.
for (PackageSection context : _contextsTab) {
ne = Aadl2Visitors.findElementInPropertySet(propertyNameId.getId(), packageName, context);
if (ne != null) {
propertyNameId.setOsateRef(ne);
ref.getPropertyNames().get(0).setOsateRef(ne);
if (packageName != null) {
ref.getQualifiedName().getBaNamespace().setOsateRef(ne.getNamespace());
ref.getQualifiedName().setOsateRef(ne.getNamespace());
}
if (ne instanceof Property) {
Property p = (Property) ne;
// First search within the default values.
if (p.getDefaultValue() != null) {
PropertyExpression pe = p.getDefaultValue();
propertyNameId.setOsateRef(pe);
ref.getPropertyNames().get(0).setOsateRef(pe);
}
return propertyNameResolver(ref.getPropertyNames());
} else if (ne instanceof PropertyType) {
if (ne instanceof EnumerationType) {
return propertyNameResolver(ref.getPropertyNames());
} else {
// It doesn't make any sense
// for the other types.
String msg = "reference to property type (other than enumeration" + " type) is not supported";
_errManager.error(ref.getPropertyNames().get(1).getPropertyName(), msg);
return false;
}
} else // Property constant case.
{
if (ref.getPropertyNames().size() > 1) {
// Property constants haven't any sub property.
String msg = "property names are not supported for property constant";
_errManager.error(ref.getPropertyNames().get(1).getPropertyName(), msg);
return false;
} else {
DeclarativePropertyName firstDpn = ref.getPropertyNames().get(0);
if (null != firstDpn.getField() || firstDpn.isSetIndexes()) {
// Property constants haven't any property field.
String msg = "property fields are not supported for property constant";
BehaviorElement bel = (null != firstDpn.getField()) ? firstDpn.getField() : firstDpn.getIndexes().get(0);
_errManager.error(bel, msg);
return false;
} else {
return true;
}
}
}
}
}
reportNameError(propertyNameId, propertyNameId.getId());
return false;
}
use of org.osate.ba.declarative.Identifier in project osate2 by osate.
the class AadlBaNameResolver method communicationActionResolver.
private boolean communicationActionResolver(CommAction act) {
boolean result = true;
if (act.getTarget() != null) {
result &= targetResolver(act.getTarget());
}
if (act.getQualifiedName() != null) {
result &= qualifiedNamedElementResolver(act.getQualifiedName(), true);
}
if (act.getReference() != null) {
// Ambiguous cases :
// _ unqualified unique component classifier reference
// without implementation information provided, are parsed as reference
// (single name) without array index.
// _ unqualified unique component classifier reference with
// implementation information provided and a reference (two names)
// without array index.
Reference ref = act.getReference();
EList<ArrayableIdentifier> ids = ref.getIds();
boolean hasArrayIndex = false;
// names.
if (ids.size() > 2) {
result &= refResolver(ref);
} else {
for (ArrayableIdentifier id : ids) {
if (id.isSetArrayIndexes()) {
hasArrayIndex = true;
}
}
// unique component classifier reference can't have array index.
if (hasArrayIndex) {
result &= refResolver(ref);
} else {
// Resolves ambiguous case between unqualified unique component
// classifier reference and a reference with only one name.
ArrayableIdentifier idComponent = ids.get(0);
StringBuilder subprogramName = new StringBuilder();
subprogramName.append(idComponent.getId());
if (ids.size() == 2) {
ArrayableIdentifier idImplementation = ids.get(1);
subprogramName.append('.');
subprogramName.append(idImplementation.getId());
}
QualifiedNamedElement qne = DeclarativeFactory.eINSTANCE.createQualifiedNamedElement();
// Clone the identifier as object reference in the most of the AADLBA
// Front End emf meta model classes are unique (the containment
// attribute set to true).
Identifier idClone = DeclarativeFactory.eINSTANCE.createIdentifier();
idClone.setLocationReference(idComponent.getLocationReference());
idClone.setId(subprogramName.toString());
qne.setBaName(idClone);
qne.setBaNamespace(null);
qne.setLocationReference(idComponent.getLocationReference());
if (qualifiedNamedElementResolver(qne, false)) {
act.setReference(null);
act.setQualifiedName(qne);
act.setLocationReference(qne.getLocationReference());
result &= true;
} else {
result &= refResolver(ref);
}
}
}
}
if (act.isSetParameters()) {
result &= subprogramParameterListResolver(act.getParameters());
}
return result;
}
use of org.osate.ba.declarative.Identifier in project osate2 by osate.
the class AadlBaSemanticRulesChecker method D_3_18_Checker.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Semantic rule
* Section : D.3 Behavior Specification
* Object : Check semantic rule D.3.(18)
* Keys : execute condition state pure initial
*/
public boolean D_3_18_Checker(DeclarativeBehaviorTransition bt) {
BehaviorState bs;
boolean result = true;
List<Identifier> sourceStateList = bt.getSrcStates();
for (Identifier srcState : sourceStateList) {
bs = (BehaviorState) srcState.getBaRef();
// initial state may have execute condition.
if (bs.isComplete() || bs.isFinal()) {
this.reportSemanticError(srcState, "Only transition out of " + "execution states or states that are intial only may have " + "execute condition: Behavior Annex D.3.(18) semantic rule " + "failed");
result = false;
}
}
return result;
}
use of org.osate.ba.declarative.Identifier in project osate2 by osate.
the class AadlBaSemanticRulesChecker method D_4_6_Check.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Semantic rule
* Section : D.4 Thread Dispatch Behavior Specification
* Object : Check semantic rule D.4.(5)
* Keys : dispatch relative timeout condition catch timed thread complete
* state period property
*/
// => D.4.(5) is implemented along D.4.(L1) .
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Semantic rule
* Section : D.4 Thread Dispatch Behavior Specification
* Object : Check semantic rule D.4.(6)
* Keys : stop dispatch initiation finalization complete final execute states
*/
public boolean D_4_6_Check(DispatchTriggerConditionStop stopStatement, DeclarativeBehaviorTransition btOwner, EList<BehaviorTransition> allTransitions) {
boolean result = true;
List<Identifier> sourceStateList = btOwner.getSrcStates();
// Check the source states : they must be complete states.
BehaviorState tmpState;
for (Identifier srcState : sourceStateList) {
tmpState = (BehaviorState) srcState.getBaRef();
if (!tmpState.isComplete()) {
this.reportSemanticError(stopStatement, "The stop dispatch trigger " + "statement must be declared in an outgoing transition of a " + "complete state: Behavior Annex D.4.(6) semantic rule failed");
result = false;
break;
}
}
// Create a transitions array because the array will be modified.
// See transitionEndToFinalStateDriver.
DeclarativeBehaviorTransition[] transArray = new DeclarativeBehaviorTransition[allTransitions.size()];
allTransitions.toArray(transArray);
int btOwnerIndex = allTransitions.indexOf(btOwner);
if (!transitionEndToFinalStateCheck(btOwner, btOwnerIndex, transArray)) {
reportSemanticError(stopStatement, "The stop dispatch trigger " + "statement must be declared in a transition that ends to final" + " state possibly via one or more execution states: " + "Behavior Annex D.4.(6) semantic rule failed");
result = false;
}
return result;
}
Aggregations