use of org.osate.ba.aadlba.BehaviorVariableHolder in project osate2 by osate.
the class AadlBaLegalityRulesChecker method D_6_L3_And_L4_Check.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Legality rule
* Section : D.6 Behavior Action Language
* Object : Check legality rules D.6.(L3), D.6.(L4)
* Keys : local variable port variable assigned action set
*/
public boolean D_6_L3_And_L4_Check(BehaviorActionBlock bab) {
BehaviorActions beActions = bab.getContent();
// Temporary list of targets passed between recursive calls of
// buildActionSetAssignedValuesLists method.
List<Target> lActionSetTar = new ArrayList<Target>();
// Set of duplicated targets between multiple action sets.
Set<Target> lDuplicates = new HashSet<Target>();
buildActionSetAssignedTargetLists(beActions, lActionSetTar, lDuplicates);
String localVariableErrorMsg = "The same local variable must not be " + "assigned to in different actions of an action set" + ": Behavior Annex D.6.(L3) legality rules failed";
String portErrorMsg = "The same port variable must not be assigned to " + "in different actions of an action set: " + "Behavior Annex D.6.(L4) legality rules failed";
String tmp;
for (Target tar : lDuplicates) {
// Local variable case.
if (tar instanceof BehaviorVariableHolder) {
tmp = localVariableErrorMsg;
} else // Port case.
{
tmp = portErrorMsg;
}
reportLegalityError(tar, tmp);
}
return lDuplicates.isEmpty();
}
use of org.osate.ba.aadlba.BehaviorVariableHolder in project osate2 by osate.
the class AadlBaParserVisitor method cloneHolder.
private ElementHolder cloneHolder(ElementHolder sourceElementHolder) {
ElementHolder targetElementHolder = null;
if (sourceElementHolder instanceof ClassifierFeatureHolder) {
ClassifierFeatureHolder sourceCfh = (ClassifierFeatureHolder) sourceElementHolder;
if (sourceElementHolder instanceof BehaviorVariableHolder) {
// BehaviorVariableHolder
targetElementHolder = _baFact.createBehaviorVariableHolder();
} else if (sourceElementHolder instanceof FeatureHolder) {
FeatureHolder sourceFeatureHolder = (FeatureHolder) sourceElementHolder;
// FeatureHolder
if (sourceFeatureHolder instanceof DataAccessHolder) {
// DataAccessHolder
targetElementHolder = _baFact.createDataAccessHolder();
} else if (sourceFeatureHolder instanceof ParameterHolder) {
// ParameterHolder
targetElementHolder = _baFact.createParameterHolder();
} else if (sourceFeatureHolder instanceof DataPortHolder) {
targetElementHolder = _baFact.createDataPortHolder();
} else if (sourceFeatureHolder instanceof EventDataPortHolder) {
targetElementHolder = _baFact.createEventDataPortHolder();
} else if (sourceFeatureHolder instanceof EventPortHolder) {
targetElementHolder = _baFact.createEventPortHolder();
} else if (sourceFeatureHolder instanceof SubprogramAccessHolder) {
targetElementHolder = _baFact.createSubprogramAccessHolder();
}
} else // PrototypeHolder
if (sourceElementHolder instanceof PrototypeHolder) {
// DataAccessPrototypeHolder
if (sourceElementHolder instanceof DataAccessPrototypeHolder) {
targetElementHolder = _baFact.createDataAccessPrototypeHolder();
} else if (sourceElementHolder instanceof FeaturePrototypeHolder) {
targetElementHolder = _baFact.createFeaturePrototypeHolder();
} else if (sourceElementHolder instanceof PortPrototypeHolder) {
targetElementHolder = _baFact.createPortPrototypeHolder();
} else if (sourceElementHolder instanceof SubprogramPrototypeHolder) {
targetElementHolder = _baFact.createSubprogramPrototypeHolder();
}
} else // SubcomponentHolder
if (sourceElementHolder instanceof SubcomponentHolder) {
// DataSubcomponentHolder
if (sourceElementHolder instanceof DataSubcomponentHolder) {
targetElementHolder = _baFact.createDataSubcomponentHolder();
} else if (sourceElementHolder instanceof SubprogramSubcomponentHolder) {
targetElementHolder = _baFact.createSubprogramSubcomponentHolder();
}
}
ClassifierFeatureHolder targetCfh = (ClassifierFeatureHolder) targetElementHolder;
targetCfh.setClassifierFeature(sourceCfh.getClassifierFeature());
}
if (targetElementHolder != null) {
targetElementHolder.setElement(sourceElementHolder.getElement());
}
return targetElementHolder;
}
Aggregations