use of org.osate.aadl2.BooleanLiteral in project AMASE by loonwerks.
the class AbstractSafetySemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Aadl2Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Aadl2Package.ARRAY_RANGE:
sequence_ArrayRange(context, (ArrayRange) semanticObject);
return;
case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
return;
case Aadl2Package.BOOLEAN_LITERAL:
sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case Aadl2Package.CLASSIFIER_VALUE:
sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
return;
case Aadl2Package.COMPUTED_VALUE:
sequence_ComputedTerm(context, (ComputedValue) semanticObject);
return;
case Aadl2Package.CONTAINED_NAMED_ELEMENT:
sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
return;
case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
return;
case Aadl2Package.INTEGER_LITERAL:
sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
return;
case Aadl2Package.LIST_VALUE:
sequence_ListTerm(context, (ListValue) semanticObject);
return;
case Aadl2Package.MODAL_PROPERTY_VALUE:
if (rule == grammarAccess.getModalPropertyValueRule()) {
sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyValueRule()) {
sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else
break;
case Aadl2Package.NAMED_VALUE:
if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
sequence_ConstantValue(context, (NamedValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
return;
} else
break;
case Aadl2Package.OPERATION:
sequence_SignedConstant(context, (Operation) semanticObject);
return;
case Aadl2Package.PROPERTY_ASSOCIATION:
if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyAssociationRule()) {
sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else
break;
case Aadl2Package.RANGE_VALUE:
sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
return;
case Aadl2Package.REAL_LITERAL:
sequence_RealTerm(context, (RealLiteral) semanticObject);
return;
case Aadl2Package.RECORD_VALUE:
if (rule == grammarAccess.getOldRecordTermRule()) {
sequence_OldRecordTerm(context, (RecordValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
sequence_RecordTerm(context, (RecordValue) semanticObject);
return;
} else
break;
case Aadl2Package.REFERENCE_VALUE:
sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
return;
case Aadl2Package.STRING_LITERAL:
sequence_StringTerm(context, (StringLiteral) semanticObject);
return;
}
else if (epackage == AgreePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case AgreePackage.AGREE_CONTRACT:
sequence_AgreeContract(context, (AgreeContract) semanticObject);
return;
case AgreePackage.AGREE_CONTRACT_LIBRARY:
sequence_AgreeLibrary(context, (AgreeContractLibrary) semanticObject);
return;
case AgreePackage.AGREE_CONTRACT_SUBCLAUSE:
sequence_AgreeSubclause(context, (AgreeContractSubclause) semanticObject);
return;
case AgreePackage.ALWAYS_STATEMENT:
sequence_PatternStatement(context, (AlwaysStatement) semanticObject);
return;
case AgreePackage.ARG:
sequence_Arg(context, (Arg) semanticObject);
return;
case AgreePackage.ARRAY_LITERAL_EXPR:
sequence_ArrayLiteralExpr(context, (ArrayLiteralExpr) semanticObject);
return;
case AgreePackage.ARRAY_SUB_EXPR:
sequence_ArraySubExpr(context, (ArraySubExpr) semanticObject);
return;
case AgreePackage.ARRAY_TYPE:
sequence_Type(context, (ArrayType) semanticObject);
return;
case AgreePackage.ARRAY_UPDATE_EXPR:
sequence_ArrayUpdateExpr(context, (ArrayUpdateExpr) semanticObject);
return;
case AgreePackage.ASSERT_STATEMENT:
sequence_NamedSpecStatement(context, (AssertStatement) semanticObject);
return;
case AgreePackage.ASSIGN_STATEMENT:
sequence_AssignStatement(context, (AssignStatement) semanticObject);
return;
case AgreePackage.ASSUME_STATEMENT:
sequence_NamedSpecStatement(context, (AssumeStatement) semanticObject);
return;
case AgreePackage.ASYNCH_STATEMENT:
sequence_SynchStatement(context, (AsynchStatement) semanticObject);
return;
case AgreePackage.BINARY_EXPR:
sequence_AddSubExpr_AndExpr_ArrowExpr_EquivExpr_ImpliesExpr_MultDivExpr_OrExpr_PowerExpr_RelateExpr(context, (BinaryExpr) semanticObject);
return;
case AgreePackage.BOOL_LIT_EXPR:
sequence_TermExpr(context, (BoolLitExpr) semanticObject);
return;
case AgreePackage.CALEN_STATEMENT:
sequence_SynchStatement(context, (CalenStatement) semanticObject);
return;
case AgreePackage.CALL_EXPR:
sequence_TermExpr(context, (CallExpr) semanticObject);
return;
case AgreePackage.CLOSED_TIME_INTERVAL:
sequence_TimeInterval(context, (ClosedTimeInterval) semanticObject);
return;
case AgreePackage.CONST_STATEMENT:
sequence_ConstStatement(context, (ConstStatement) semanticObject);
return;
case AgreePackage.DOUBLE_DOT_REF:
sequence_DoubleDotRef(context, (DoubleDotRef) semanticObject);
return;
case AgreePackage.ENUM_LIT_EXPR:
sequence_TermExpr(context, (EnumLitExpr) semanticObject);
return;
case AgreePackage.ENUM_STATEMENT:
sequence_EnumStatement(context, (EnumStatement) semanticObject);
return;
case AgreePackage.EQ_STATEMENT:
sequence_EqStatement(context, (EqStatement) semanticObject);
return;
case AgreePackage.EVENT_EXPR:
sequence_TermExpr(context, (EventExpr) semanticObject);
return;
case AgreePackage.EXISTS_EXPR:
sequence_ExistsExpr(context, (ExistsExpr) semanticObject);
return;
case AgreePackage.FLATMAP_EXPR:
sequence_FlatmapExpr(context, (FlatmapExpr) semanticObject);
return;
case AgreePackage.FLOOR_CAST:
sequence_TermExpr(context, (FloorCast) semanticObject);
return;
case AgreePackage.FN_DEF:
sequence_FnDef(context, (FnDef) semanticObject);
return;
case AgreePackage.FOLD_LEFT_EXPR:
sequence_FoldLeftExpr(context, (FoldLeftExpr) semanticObject);
return;
case AgreePackage.FOLD_RIGHT_EXPR:
sequence_FoldRightExpr(context, (FoldRightExpr) semanticObject);
return;
case AgreePackage.FORALL_EXPR:
sequence_ForallExpr(context, (ForallExpr) semanticObject);
return;
case AgreePackage.GET_PROPERTY_EXPR:
sequence_PreDefFnExpr(context, (GetPropertyExpr) semanticObject);
return;
case AgreePackage.GUARANTEE_STATEMENT:
sequence_NamedSpecStatement(context, (GuaranteeStatement) semanticObject);
return;
case AgreePackage.IF_THEN_ELSE_EXPR:
sequence_IfThenElseExpr(context, (IfThenElseExpr) semanticObject);
return;
case AgreePackage.INDICES_EXPR:
sequence_TermExpr(context, (IndicesExpr) semanticObject);
return;
case AgreePackage.INPUT_STATEMENT:
sequence_InputStatement(context, (InputStatement) semanticObject);
return;
case AgreePackage.INT_LIT_EXPR:
sequence_TermExpr(context, (IntLitExpr) semanticObject);
return;
case AgreePackage.LATCHED_EXPR:
sequence_TermExpr(context, (LatchedExpr) semanticObject);
return;
case AgreePackage.LATCHED_STATEMENT:
sequence_SynchStatement(context, (LatchedStatement) semanticObject);
return;
case AgreePackage.LEMMA_STATEMENT:
sequence_NamedSpecStatement(context, (LemmaStatement) semanticObject);
return;
case AgreePackage.LIBRARY_FN_DEF:
sequence_LibraryFnDef(context, (LibraryFnDef) semanticObject);
return;
case AgreePackage.LINEARIZATION_DEF:
sequence_LinearizationDef(context, (LinearizationDef) semanticObject);
return;
case AgreePackage.LINEARIZATION_INTERVAL:
sequence_LinearizationInterval(context, (LinearizationInterval) semanticObject);
return;
case AgreePackage.MN_SYNCH_STATEMENT:
sequence_SynchStatement(context, (MNSynchStatement) semanticObject);
return;
case AgreePackage.NAMED_ELM_EXPR:
sequence_TermExpr(context, (NamedElmExpr) semanticObject);
return;
case AgreePackage.NAMED_ID:
sequence_NamedID(context, (NamedID) semanticObject);
return;
case AgreePackage.NODE_BODY_EXPR:
sequence_NodeBodyExpr(context, (NodeBodyExpr) semanticObject);
return;
case AgreePackage.NODE_DEF:
sequence_NodeDef(context, (NodeDef) semanticObject);
return;
case AgreePackage.NODE_EQ:
sequence_NodeStmt(context, (NodeEq) semanticObject);
return;
case AgreePackage.NODE_LEMMA:
sequence_NodeStmt(context, (NodeLemma) semanticObject);
return;
case AgreePackage.OPEN_LEFT_TIME_INTERVAL:
sequence_TimeInterval(context, (OpenLeftTimeInterval) semanticObject);
return;
case AgreePackage.OPEN_RIGHT_TIME_INTERVAL:
sequence_TimeInterval(context, (OpenRightTimeInterval) semanticObject);
return;
case AgreePackage.OPEN_TIME_INTERVAL:
sequence_TimeInterval(context, (OpenTimeInterval) semanticObject);
return;
case AgreePackage.ORDER_STATEMENT:
sequence_OrderStatement(context, (OrderStatement) semanticObject);
return;
case AgreePackage.PERIODIC_STATEMENT:
sequence_RealTimeStatement(context, (PeriodicStatement) semanticObject);
return;
case AgreePackage.PRE_EXPR:
sequence_TermExpr(context, (PreExpr) semanticObject);
return;
case AgreePackage.PREV_EXPR:
sequence_PreDefFnExpr(context, (PrevExpr) semanticObject);
return;
case AgreePackage.PRIM_TYPE:
sequence_BaseType(context, (PrimType) semanticObject);
return;
case AgreePackage.PROPERTY_STATEMENT:
sequence_PropertyStatement(context, (PropertyStatement) semanticObject);
return;
case AgreePackage.REACHABLE_STATEMENT:
sequence_NamedSpecStatement(context, (ReachableStatement) semanticObject);
return;
case AgreePackage.REAL_CAST:
sequence_TermExpr(context, (RealCast) semanticObject);
return;
case AgreePackage.REAL_LIT_EXPR:
sequence_TermExpr(context, (RealLitExpr) semanticObject);
return;
case AgreePackage.RECORD_DEF:
sequence_RecordDef(context, (RecordDef) semanticObject);
return;
case AgreePackage.RECORD_LIT_EXPR:
sequence_TermExpr(context, (RecordLitExpr) semanticObject);
return;
case AgreePackage.RECORD_UPDATE_EXPR:
sequence_RecordUpdateExpr(context, (RecordUpdateExpr) semanticObject);
return;
case AgreePackage.SELECTION_EXPR:
sequence_SelectionExpr(context, (SelectionExpr) semanticObject);
return;
case AgreePackage.SPORADIC_STATEMENT:
sequence_RealTimeStatement(context, (SporadicStatement) semanticObject);
return;
case AgreePackage.SYNCH_STATEMENT:
sequence_SynchStatement(context, (SynchStatement) semanticObject);
return;
case AgreePackage.TAG_EXPR:
sequence_TagExpr(context, (TagExpr) semanticObject);
return;
case AgreePackage.THIS_REF:
sequence_ComponentRef(context, (ThisRef) semanticObject);
return;
case AgreePackage.TIME_EXPR:
sequence_TermExpr(context, (TimeExpr) semanticObject);
return;
case AgreePackage.TIME_FALL_EXPR:
sequence_TermExpr(context, (TimeFallExpr) semanticObject);
return;
case AgreePackage.TIME_OF_EXPR:
sequence_TermExpr(context, (TimeOfExpr) semanticObject);
return;
case AgreePackage.TIME_RISE_EXPR:
sequence_TermExpr(context, (TimeRiseExpr) semanticObject);
return;
case AgreePackage.UNARY_EXPR:
sequence_UnaryExpr(context, (UnaryExpr) semanticObject);
return;
case AgreePackage.UNINTERPRETED_FN_DEF:
sequence_UninterpretedFnDef(context, (UninterpretedFnDef) semanticObject);
return;
case AgreePackage.WHEN_HOLDS_STATEMENT:
sequence_WhenStatement(context, (WhenHoldsStatement) semanticObject);
return;
case AgreePackage.WHEN_OCCURS_STATMENT:
sequence_WhenStatement(context, (WhenOccursStatment) semanticObject);
return;
case AgreePackage.WHENEVER_BECOMES_TRUE_STATEMENT:
sequence_WheneverStatement(context, (WheneverBecomesTrueStatement) semanticObject);
return;
case AgreePackage.WHENEVER_HOLDS_STATEMENT:
sequence_WheneverStatement(context, (WheneverHoldsStatement) semanticObject);
return;
case AgreePackage.WHENEVER_IMPLIES_STATEMENT:
sequence_WheneverStatement(context, (WheneverImpliesStatement) semanticObject);
return;
case AgreePackage.WHENEVER_OCCURS_STATEMENT:
sequence_WheneverStatement(context, (WheneverOccursStatement) semanticObject);
return;
}
else if (epackage == SafetyPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case SafetyPackage.ACTIVATION_STATEMENT:
sequence_SpecStatement(context, (ActivationStatement) semanticObject);
return;
case SafetyPackage.ANALYSIS_STATEMENT:
sequence_SpecStatement(context, (AnalysisStatement) semanticObject);
return;
case SafetyPackage.CLOSED_SAFETY_INTERVAL:
sequence_SafetyInterval(context, (ClosedSafetyInterval) semanticObject);
return;
case SafetyPackage.DISABLE_STATEMENT:
sequence_FaultSubcomponent(context, (DisableStatement) semanticObject);
return;
case SafetyPackage.DURATION_STATEMENT:
if (rule == grammarAccess.getElementSafetyRule() || rule == grammarAccess.getFaultSubcomponentRule()) {
sequence_FaultSubcomponent(context, (DurationStatement) semanticObject);
return;
} else if (rule == grammarAccess.getHWFaultSubcomponentRule()) {
sequence_HWFaultSubcomponent(context, (DurationStatement) semanticObject);
return;
} else
break;
case SafetyPackage.ENABLER_CONDITION:
sequence_TriggerCondition(context, (EnablerCondition) semanticObject);
return;
case SafetyPackage.EQ_VALUE:
sequence_SafetyEqStatement(context, (EqValue) semanticObject);
return;
case SafetyPackage.FAULT_COUNT_BEHAVIOR:
sequence_AnalysisBehavior(context, (FaultCountBehavior) semanticObject);
return;
case SafetyPackage.FAULT_STATEMENT:
sequence_SpecStatement(context, (FaultStatement) semanticObject);
return;
case SafetyPackage.HW_FAULT_STATEMENT:
sequence_SpecStatement(context, (HWFaultStatement) semanticObject);
return;
case SafetyPackage.INPUT_STATEMENT:
sequence_FaultSubcomponent(context, (edu.umn.cs.crisys.safety.safety.InputStatement) semanticObject);
return;
case SafetyPackage.INTERVAL_EQ:
sequence_SafetyEqStatement(context, (IntervalEq) semanticObject);
return;
case SafetyPackage.OPEN_LEFT_SAFETY_INTERVAL:
sequence_SafetyInterval(context, (OpenLeftSafetyInterval) semanticObject);
return;
case SafetyPackage.OPEN_RIGHT_SAFETY_INTERVAL:
sequence_SafetyInterval(context, (OpenRightSafetyInterval) semanticObject);
return;
case SafetyPackage.OPEN_SAFETY_INTERVAL:
sequence_SafetyInterval(context, (OpenSafetyInterval) semanticObject);
return;
case SafetyPackage.OUTPUT_STATEMENT:
sequence_FaultSubcomponent(context, (OutputStatement) semanticObject);
return;
case SafetyPackage.PERMANENT_CONSTRAINT:
sequence_TemporalConstraint(context, (PermanentConstraint) semanticObject);
return;
case SafetyPackage.PROBABILITY_BEHAVIOR:
sequence_AnalysisBehavior(context, (ProbabilityBehavior) semanticObject);
return;
case SafetyPackage.PROBABILITY_STATEMENT:
if (rule == grammarAccess.getElementSafetyRule() || rule == grammarAccess.getFaultSubcomponentRule()) {
sequence_FaultSubcomponent(context, (ProbabilityStatement) semanticObject);
return;
} else if (rule == grammarAccess.getHWFaultSubcomponentRule()) {
sequence_HWFaultSubcomponent(context, (ProbabilityStatement) semanticObject);
return;
} else
break;
case SafetyPackage.PROPAGATE_STATEMENT:
sequence_SpecStatement(context, (PropagateStatement) semanticObject);
return;
case SafetyPackage.PROPAGATION_TYPE_STATEMENT:
if (rule == grammarAccess.getElementSafetyRule() || rule == grammarAccess.getFaultSubcomponentRule()) {
sequence_FaultSubcomponent(context, (PropagationTypeStatement) semanticObject);
return;
} else if (rule == grammarAccess.getHWFaultSubcomponentRule()) {
sequence_HWFaultSubcomponent(context, (PropagationTypeStatement) semanticObject);
return;
} else
break;
case SafetyPackage.RANGE_EQ:
sequence_SafetyEqStatement(context, (RangeEq) semanticObject);
return;
case SafetyPackage.SAFETY_CONTRACT:
sequence_SafetyContract(context, (SafetyContract) semanticObject);
return;
case SafetyPackage.SAFETY_CONTRACT_LIBRARY:
sequence_SafetyLibrary(context, (SafetyContractLibrary) semanticObject);
return;
case SafetyPackage.SAFETY_CONTRACT_SUBCLAUSE:
sequence_SafetySubclause(context, (SafetyContractSubclause) semanticObject);
return;
case SafetyPackage.SET_EQ:
sequence_SafetyEqStatement(context, (SetEq) semanticObject);
return;
case SafetyPackage.TRANSIENT_CONSTRAINT:
sequence_TemporalConstraint(context, (TransientConstraint) semanticObject);
return;
case SafetyPackage.TRIGGER_STATEMENT:
sequence_FaultSubcomponent(context, (TriggerStatement) semanticObject);
return;
case SafetyPackage.ASYMMETRIC:
sequence_PropagationTypeConstraint(context, (asymmetric) semanticObject);
return;
case SafetyPackage.SYMMETRIC:
sequence_PropagationTypeConstraint(context, (symmetric) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.osate.aadl2.BooleanLiteral in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method createVdmPort.
/**
* @author Vidhya Tekken Valapil
* Creates a new Vdm Port object and returns
* Populates "name", "mode" and "type"
* @param dataport
* @return vdm port
*/
private Port createVdmPort(DataPort dataPort, Model model, HashSet<String> dataTypeDecl) {
String modeString = "in";
if (dataPort.isIn()) {
modeString = "in";
} else if (dataPort.isOut()) {
modeString = "out";
}
// fetching data type information
DataSubcomponentType dSubCompType = dataPort.getDataFeatureClassifier();
verdict.vdm.vdm_data.DataType dtype = new verdict.vdm.vdm_data.DataType();
if (dSubCompType instanceof DataTypeImpl) {
org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) dSubCompType;
dtype = resolveAADLDataType(aadlDType, model, dataTypeDecl);
} else if (dSubCompType instanceof DataImplementationImpl) {
org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) dSubCompType;
dtype = resolveAADLDataImplementationType(aadlDImpl, model, dataTypeDecl);
} else {
System.out.println("Unresolved/unexpected Named Element.");
}
verdict.vdm.vdm_model.Port newPort = new verdict.vdm.vdm_model.Port();
newPort.setProbe(false);
if (dataPort.getOwnedPropertyAssociations().size() != 0) {
EList<PropertyAssociation> propertyAssocs = dataPort.getOwnedPropertyAssociations();
for (PropertyAssociation propertyAssoc : propertyAssocs) {
if (propertyAssoc.getProperty().getName().equalsIgnoreCase("probe")) {
EList<ModalPropertyValue> propVals = propertyAssoc.getOwnedValues();
if (propVals.size() == 0 || propVals.size() > 1) {
throw new RuntimeException("Unexpected number for values for probe property of port.");
}
if (propVals.get(0).getOwnedValue() instanceof BooleanLiteral) {
BooleanLiteral probeVal = (BooleanLiteral) propVals.get(0).getOwnedValue();
newPort.setProbe(probeVal.getValue());
} else {
throw new RuntimeException("Unexpected type of value for probe property of port.");
}
}
}
}
newPort.setId(dataPort.getQualifiedName());
newPort.setName(dataPort.getName());
newPort.setMode(convertToVdmPortMode(modeString));
newPort.setType(dtype);
return newPort;
}
use of org.osate.aadl2.BooleanLiteral in project osate2 by osate.
the class AlisaSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Aadl2Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Aadl2Package.AADL_BOOLEAN:
sequence_TypeRef(context, (AadlBoolean) semanticObject);
return;
case Aadl2Package.AADL_INTEGER:
sequence_TypeRef(context, (AadlInteger) semanticObject);
return;
case Aadl2Package.AADL_REAL:
sequence_TypeRef(context, (AadlReal) semanticObject);
return;
case Aadl2Package.AADL_STRING:
sequence_TypeRef(context, (AadlString) semanticObject);
return;
case Aadl2Package.BOOLEAN_LITERAL:
sequence_ABooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case Aadl2Package.INTEGER_LITERAL:
sequence_AIntegerTerm(context, (IntegerLiteral) semanticObject);
return;
case Aadl2Package.REAL_LITERAL:
sequence_ARealTerm(context, (RealLiteral) semanticObject);
return;
case Aadl2Package.STRING_LITERAL:
sequence_StringTerm(context, (StringLiteral) semanticObject);
return;
}
else if (epackage == AlisaPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case AlisaPackage.ASSURANCE_CASE:
sequence_AssuranceCase(context, (AssuranceCase) semanticObject);
return;
case AlisaPackage.ASSURANCE_PLAN:
sequence_AssurancePlan(context, (AssurancePlan) semanticObject);
return;
case AlisaPackage.ASSURANCE_TASK:
sequence_AssuranceTask(context, (AssuranceTask) semanticObject);
return;
}
else if (epackage == CommonPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case CommonPackage.ABINARY_OPERATION:
sequence_AAdditiveExpression_AAndExpression_AEqualityExpression_AMultiplicativeExpression_AOrExpression_ARelationalExpression(context, (ABinaryOperation) semanticObject);
return;
case CommonPackage.ACONDITIONAL:
sequence_AIfExpression(context, (AConditional) semanticObject);
return;
case CommonPackage.AFUNCTION_CALL:
sequence_AFunctionCall(context, (AFunctionCall) semanticObject);
return;
case CommonPackage.AMODEL_REFERENCE:
sequence_AModelReference(context, (AModelReference) semanticObject);
return;
case CommonPackage.APROPERTY_REFERENCE:
if (rule == grammarAccess.getAModelOrPropertyReferenceRule() || rule == grammarAccess.getAExpressionRule() || rule == grammarAccess.getAOrExpressionRule() || action == grammarAccess.getAOrExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAndExpressionRule() || action == grammarAccess.getAAndExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAEqualityExpressionRule() || action == grammarAccess.getAEqualityExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getARelationalExpressionRule() || action == grammarAccess.getARelationalExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAdditiveExpressionRule() || action == grammarAccess.getAAdditiveExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAMultiplicativeExpressionRule() || action == grammarAccess.getAMultiplicativeExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAUnaryOperationRule() || rule == grammarAccess.getAUnitExpressionRule() || action == grammarAccess.getAUnitExpressionAccess().getAUnitExpressionExpressionAction_1_0() || rule == grammarAccess.getAPrimaryExpressionRule() || rule == grammarAccess.getAParenthesizedExpressionRule()) {
sequence_AModelOrPropertyReference_APropertyReference(context, (APropertyReference) semanticObject);
return;
} else if (rule == grammarAccess.getAPropertyReferenceRule()) {
sequence_APropertyReference(context, (APropertyReference) semanticObject);
return;
} else
break;
case CommonPackage.ARANGE:
sequence_ARangeExpression(context, (ARange) semanticObject);
return;
case CommonPackage.AUNARY_OPERATION:
sequence_AUnaryOperation(context, (AUnaryOperation) semanticObject);
return;
case CommonPackage.AUNIT_EXPRESSION:
if (rule == grammarAccess.getAExpressionRule() || rule == grammarAccess.getAOrExpressionRule() || action == grammarAccess.getAOrExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAndExpressionRule() || action == grammarAccess.getAAndExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAEqualityExpressionRule() || action == grammarAccess.getAEqualityExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getARelationalExpressionRule() || action == grammarAccess.getARelationalExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAdditiveExpressionRule() || action == grammarAccess.getAAdditiveExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAMultiplicativeExpressionRule() || action == grammarAccess.getAMultiplicativeExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAUnaryOperationRule() || rule == grammarAccess.getAUnitExpressionRule() || action == grammarAccess.getAUnitExpressionAccess().getAUnitExpressionExpressionAction_1_0() || rule == grammarAccess.getAPrimaryExpressionRule() || rule == grammarAccess.getAParenthesizedExpressionRule()) {
sequence_AUnitExpression(context, (AUnitExpression) semanticObject);
return;
} else if (rule == grammarAccess.getShowValueRule()) {
sequence_ShowValue(context, (AUnitExpression) semanticObject);
return;
} else
break;
case CommonPackage.AVARIABLE_REFERENCE:
sequence_AVariableReference(context, (AVariableReference) semanticObject);
return;
case CommonPackage.COMPUTE_DECLARATION:
sequence_ComputeDeclaration(context, (ComputeDeclaration) semanticObject);
return;
case CommonPackage.DESCRIPTION:
sequence_Description(context, (Description) semanticObject);
return;
case CommonPackage.DESCRIPTION_ELEMENT:
sequence_DescriptionElement(context, (DescriptionElement) semanticObject);
return;
case CommonPackage.IMAGE_REFERENCE:
sequence_ImageReference(context, (ImageReference) semanticObject);
return;
case CommonPackage.MODEL_REF:
sequence_TypeRef(context, (ModelRef) semanticObject);
return;
case CommonPackage.PROPERTY_REF:
sequence_PropertyRef(context, (PropertyRef) semanticObject);
return;
case CommonPackage.RATIONALE:
sequence_Rationale(context, (Rationale) semanticObject);
return;
case CommonPackage.TYPE_REF:
sequence_TypeRef(context, (TypeRef) semanticObject);
return;
case CommonPackage.UNCERTAINTY:
sequence_Uncertainty(context, (Uncertainty) semanticObject);
return;
case CommonPackage.VAL_DECLARATION:
sequence_ValDeclaration(context, (ValDeclaration) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.osate.aadl2.BooleanLiteral in project osate2 by osate.
the class AadlBaUnparser method initSwitches.
/**
* Specific aadlba switch to unparse components
*/
protected void initSwitches() {
aadlbaSwitch = new AadlBaSwitch<String>() {
/**
* Top-level method to unparse "behavior_specification"
* annexsubclause
*/
// public String caseAnnexSubclause(AnnexSubclause object) {
// //FIXME : TODO : update location reference
//
// process((BehaviorAnnex) object);
//
// return DONE;
// }
/**
* Unparse behaviorannex
*/
@Override
public String caseBehaviorAnnex(BehaviorAnnex object) {
// DB: Improve code formatting
aadlbaText.addOutputNewline("");
// FIXME : TODO : update location reference
if (object.isSetVariables()) {
aadlbaText.addOutputNewline("variables");
aadlbaText.incrementIndent();
processEList(object.getVariables());
aadlbaText.decrementIndent();
}
if (object.isSetStates()) {
aadlbaText.addOutputNewline("states");
aadlbaText.incrementIndent();
processEList(object.getStates());
aadlbaText.decrementIndent();
}
if (object.isSetTransitions()) {
aadlbaText.addOutputNewline("transitions");
aadlbaText.incrementIndent();
processEList(object.getTransitions());
aadlbaText.decrementIndent();
}
return DONE;
}
/**
* Unparse behaviorvariable
*/
@Override
public String caseBehaviorVariable(BehaviorVariable object) {
// FIXME : TODO : update location reference
aadlbaText.addOutput(object.getName());
for (ArrayDimension ad : object.getArrayDimensions()) {
aadlbaText.addOutput("[");
if (ad instanceof DeclarativeArrayDimension) {
DeclarativeArrayDimension dad = (DeclarativeArrayDimension) ad;
process(dad.getDimension());
} else if (ad instanceof ArrayDimension) {
aadlbaText.addOutput(Long.toString(ad.getSize().getSize()));
}
aadlbaText.addOutput("]");
}
aadlbaText.addOutput(" : ");
if (object.getDataClassifier() instanceof QualifiedNamedElement) {
QualifiedNamedElement qn = (QualifiedNamedElement) object.getDataClassifier();
aadlbaText.addOutput(getNamespace(qn));
process(qn);
} else if (object.getDataClassifier() instanceof DataClassifier) {
aadlbaText.addOutput(object.getDataClassifier().getQualifiedName());
}
aadlbaText.addOutputNewline(";");
return DONE;
}
private String getNamespace(final QualifiedNamedElement qn) {
final Identifier baNameSpace = qn.getBaNamespace();
final StringBuilder nameSpace = new StringBuilder();
if (baNameSpace != null && !Strings.isNullOrEmpty(baNameSpace.getId())) {
nameSpace.append(baNameSpace.getId()).append("::");
}
return nameSpace.toString();
}
/**
* Unparse behaviorstate
*/
@Override
public String caseBehaviorState(BehaviorState object) {
// FIXME : TODO : update location reference
aadlbaText.addOutput(object.getName());
aadlbaText.addOutput(" : ");
if (object.isInitial()) {
aadlbaText.addOutput("initial ");
}
if (object.isComplete()) {
aadlbaText.addOutput("complete ");
}
if (object.isFinal()) {
aadlbaText.addOutput("final ");
}
aadlbaText.addOutputNewline("state;");
return DONE;
}
/**
* Unparse behaviortransition
*/
@Override
public String caseBehaviorTransition(BehaviorTransition object) {
// FIXME : TODO : update location reference
String tid = object.getName();
Long num = object.getPriority();
if (tid != null) {
aadlbaText.addOutput(tid);
if (num != AadlBaVisitors.DEFAULT_TRANSITION_PRIORITY) {
// numeral
aadlbaText.addOutput(" [");
aadlbaText.addOutput(String.valueOf(num));
aadlbaText.addOutput("]");
}
aadlbaText.addOutput(" : ");
}
if (object.getSourceState() != null) {
aadlbaText.addOutput(object.getSourceState().getName());
} else if (object instanceof DeclarativeBehaviorTransition) {
DeclarativeBehaviorTransition dbt = (DeclarativeBehaviorTransition) object;
for (Identifier id : dbt.getSrcStates()) {
aadlbaText.addOutput(id.getId());
if (dbt.getSrcStates().get(dbt.getSrcStates().size() - 1) != id) {
aadlbaText.addOutput(",");
}
}
}
aadlbaText.addOutput(" -[");
process(object.getCondition());
aadlbaText.addOutput("]-> ");
if (object.getDestinationState() != null) {
aadlbaText.addOutput(object.getDestinationState().getName());
} else if (object instanceof DeclarativeBehaviorTransition) {
DeclarativeBehaviorTransition dbt = (DeclarativeBehaviorTransition) object;
aadlbaText.addOutput(dbt.getDestState().getId());
}
if (object.getActionBlock() != null) {
aadlbaText.addOutput(" ");
process(object.getActionBlock());
}
aadlbaText.addOutputNewline(";");
return DONE;
}
@Override
public String caseExecutionTimeoutCatch(ExecutionTimeoutCatch object) {
aadlbaText.addOutput("timeout");
return DONE;
}
@Override
public String caseOtherwise(Otherwise object) {
aadlbaText.addOutput("otherwise");
return DONE;
}
/**
* Unparse dispatchcondition
*/
@Override
public String caseDispatchCondition(DispatchCondition object) {
// FIXME : TODO : update location reference
aadlbaText.addOutput("on dispatch");
if (object.getDispatchTriggerCondition() != null) {
aadlbaText.addOutput(" ");
process(object.getDispatchTriggerCondition());
}
if (object.isSetFrozenPorts()) {
aadlbaText.addOutput(" frozen ");
processEList(object.getFrozenPorts(), ", ");
}
return DONE;
}
@Override
public String caseDispatchTriggerConditionStop(DispatchTriggerConditionStop object) {
aadlbaText.addOutput("stop");
return DONE;
}
@Override
public String caseDispatchRelativeTimeout(DispatchRelativeTimeout object) {
aadlbaText.addOutput("timeout ");
return DONE;
}
@Override
public String caseCompletionRelativeTimeout(CompletionRelativeTimeout object) {
aadlbaText.addOutput("timeout ");
caseBehaviorTime(object);
return DONE;
}
@Override
public String caseDispatchTriggerLogicalExpression(DispatchTriggerLogicalExpression object) {
processEList(object.getDispatchConjunctions(), " or ");
return DONE;
}
@Override
public String caseDispatchConjunction(DispatchConjunction object) {
processEList(object.getDispatchTriggers(), " and ");
return DONE;
}
@Override
public String caseBehaviorActionBlock(BehaviorActionBlock object) {
aadlbaText.addOutputNewline("{");
aadlbaText.incrementIndent();
// aadlbaText.addOutput("{");
process(object.getContent());
aadlbaText.decrementIndent();
aadlbaText.addOutputNewline("");
aadlbaText.addOutput("}");
if (object.getTimeout() != null) {
aadlbaText.addOutput(" timeout ");
process(object.getTimeout());
}
return DONE;
}
@Override
public String caseBehaviorActionSequence(BehaviorActionSequence object) {
// DB: Indentation problem when using \n direcly
processEList(object.getActions(), ";", true);
// processEList(object.getActions(), ";\n");
return DONE;
}
@Override
public String caseBehaviorActionSet(BehaviorActionSet object) {
// DB: Indentation problem when using \n direcly
processEList(object.getActions(), " &", true);
// processEList(object.getActions(), " &\n");
return DONE;
}
/**
* Unparse ifstatement
*/
@Override
public String caseIfStatement(IfStatement object) {
// FIXME : TODO : update location reference
boolean hasToOutputTerminator = true;
if (object.isElif()) {
aadlbaText.addOutputNewline("");
aadlbaText.addOutput("elsif (");
hasToOutputTerminator = false;
} else {
aadlbaText.addOutput("if (");
hasToOutputTerminator = true;
}
process(object.getLogicalValueExpression());
aadlbaText.addOutputNewline(")");
aadlbaText.incrementIndent();
process(object.getBehaviorActions());
aadlbaText.decrementIndent();
if (object.getElseStatement() != null) {
process(object.getElseStatement());
}
if (hasToOutputTerminator) {
aadlbaText.addOutputNewline("");
aadlbaText.addOutput("end if");
}
return DONE;
}
@Override
public String caseElseStatement(ElseStatement object) {
aadlbaText.addOutputNewline("");
aadlbaText.addOutputNewline("else");
aadlbaText.incrementIndent();
process(object.getBehaviorActions());
aadlbaText.decrementIndent();
return DONE;
}
/**
* Unparse fororforallstatement
*/
@Override
public String caseForOrForAllStatement(ForOrForAllStatement object) {
// FIXME : TODO : update location reference
if (object.isForAll()) {
aadlbaText.addOutput("forall (");
} else {
aadlbaText.addOutput("for (");
}
process(object.getIterativeVariable());
aadlbaText.addOutput(" in ");
process(object.getIteratedValues());
aadlbaText.addOutputNewline(") {");
// aadlbaText.addOutputNewline("{");
aadlbaText.incrementIndent();
process(object.getBehaviorActions());
aadlbaText.decrementIndent();
aadlbaText.addOutputNewline("");
aadlbaText.addOutput("}");
return DONE;
}
@Override
public String caseIterativeVariable(IterativeVariable iv) {
aadlbaText.addOutput(iv.getName());
aadlbaText.addOutput(" : ");
// DB: Use qualified name when classifier is declared outside the package
final DataClassifier dataClass = iv.getDataClassifier();
final String dataClassName;
if (dataClass.getElementRoot() == iv.getElementRoot()) {
dataClassName = dataClass.getName();
} else {
dataClassName = dataClass.getQualifiedName();
}
aadlbaText.addOutput(dataClassName);
return DONE;
}
@Override
public String caseWhileOrDoUntilStatement(WhileOrDoUntilStatement object) {
if (object.isDoUntil()) {
return caseDoUntilStatement(object);
} else {
return caseWhileStatement(object);
}
}
/**
* Unparse whilestatement
*/
public String caseWhileStatement(WhileOrDoUntilStatement object) {
// FIXME : TODO : update location reference
aadlbaText.addOutput("while (");
process(object.getLogicalValueExpression());
aadlbaText.addOutputNewline(") {");
// aadlbaText.addOutputNewline("{");
aadlbaText.incrementIndent();
process(object.getBehaviorActions());
aadlbaText.decrementIndent();
aadlbaText.addOutputNewline("");
aadlbaText.addOutputNewline("}");
return DONE;
}
/**
* Unparse dountilstatement
*/
public String caseDoUntilStatement(WhileOrDoUntilStatement object) {
// FIXME : TODO : update location reference
aadlbaText.addOutputNewline("do");
process(object.getBehaviorActions());
aadlbaText.addOutputNewline("");
aadlbaText.addOutput("until (");
process(object.getLogicalValueExpression());
aadlbaText.addOutputNewline(")");
return DONE;
}
/**
* Unparse integerrange
*/
@Override
public String caseIntegerRange(IntegerRange object) {
// FIXME : TODO : update location reference
process(object.getLowerIntegerValue());
aadlbaText.addOutput(" .. ");
process(object.getUpperIntegerValue());
return DONE;
}
/**
* Unparse timedaction
*/
@Override
public String caseTimedAction(TimedAction object) {
aadlbaText.addOutput("computation (");
process(object.getLowerTime());
if (object.getUpperTime() != null) {
aadlbaText.addOutput(" .. ");
process(object.getUpperTime());
}
aadlbaText.addOutput(")");
if (object.isSetProcessorClassifier()) {
aadlbaText.addOutput(" in binding (");
processEList(object.getProcessorClassifier(), ", ", object, false);
aadlbaText.addOutput(")");
}
return DONE;
}
/**
* Unparse assignmentaction
*/
@Override
public String caseAssignmentAction(AssignmentAction object) {
// FIXME : TODO : update location reference
process(object.getTarget());
aadlbaText.addOutput(" := ");
process(object.getValueExpression());
return DONE;
}
@Override
public String caseAny(Any object) {
aadlbaText.addOutput("any");
return DONE;
}
@Override
public String caseElementHolder(ElementHolder el) {
if (el instanceof Reference) {
return processReference((Reference) el);
}
Element refContainer = Aadl2Visitors.getContainingPackageSection(el.getElement());
Element holderPackageOrPropertySet = Aadl2Visitors.getContainingPackageSection(el);
if (refContainer != null && holderPackageOrPropertySet != null && false == holderPackageOrPropertySet.equals(refContainer) && false == (el instanceof DataSubcomponentHolder)) {
StringBuilder sb = new StringBuilder(el.getElement().getQualifiedName());
String prefix = sb.substring(0, sb.lastIndexOf("::") + 2);
aadlbaText.addOutput(prefix);
}
if (el instanceof GroupableElement) {
GroupableElement ge = (GroupableElement) el;
if (ge.isSetGroupHolders()) {
processEList(ge.getGroupHolders(), ".");
aadlbaText.addOutput(".");
}
}
aadlbaText.addOutput(el.getElement().getName());
if (el instanceof IndexableElement) {
IndexableElement ie = (IndexableElement) el;
if (ie.isSetArrayIndexes()) {
caseArrayIndex(ie.getArrayIndexes());
}
}
return DONE;
}
private String processReference(Reference ref) {
for (ArrayableIdentifier id : ref.getIds()) {
aadlbaText.addOutput(id.getId());
caseArrayIndex(id.getArrayIndexes());
if (id != ref.getIds().get(ref.getIds().size() - 1)) {
aadlbaText.addOutput(".");
}
}
return DONE;
}
private String processCommAction(CommAction object) {
process(object.getReference());
if (object.isLock()) {
aadlbaText.addOutput("!<");
} else if (object.isUnlock()) {
aadlbaText.addOutput("!>");
} else if (object.isPortDequeue()) {
aadlbaText.addOutput(" ?");
} else {
aadlbaText.addOutput(" !");
}
if (object.isSetParameters() == true) {
aadlbaText.addOutput(" (");
processEList(object.getParameters(), ",");
aadlbaText.addOutput(")");
return DONE;
} else if (object.getTarget() != null) {
aadlbaText.addOutput(" (");
process(object.getTarget());
aadlbaText.addOutput(")");
return DONE;
}
return DONE;
}
/**
* Unparse arrayindex
*/
public String caseArrayIndex(EList<IntegerValue> object) {
// FIXME : TODO : update location reference
for (IntegerValue iv : object) {
aadlbaText.addOutput("[");
process(iv);
aadlbaText.addOutput("]");
}
return DONE;
}
/**
* Unparse datacomponentreference
*/
@Override
public String caseDataComponentReference(DataComponentReference object) {
// FIXME : TODO : update location reference
processEList(object.getData(), ".");
return DONE;
}
@Override
public String defaultCase(EObject object) {
if (object instanceof CommAction) {
return processCommAction((CommAction) object);
} else if (object instanceof Reference) {
return processReference((Reference) object);
} else if (object instanceof QualifiedNamedElement) {
QualifiedNamedElement qn = (QualifiedNamedElement) object;
aadlbaText.addOutput(qn.getBaName().getId());
} else if (object instanceof org.osate.ba.declarative.NamedValue) {
org.osate.ba.declarative.NamedValue nv = (org.osate.ba.declarative.NamedValue) object;
process(nv.getReference());
if (nv.isCount()) {
aadlbaText.addOutput("' count");
}
if (nv.isFresh()) {
aadlbaText.addOutput("' fresh");
}
if (nv.isDequeue()) {
aadlbaText.addOutput(" ?");
}
} else if (object instanceof DeclarativePropertyReference) {
DeclarativePropertyReference dpr = (DeclarativePropertyReference) object;
if (dpr.getQualifiedName().getBaName().getId().isEmpty()) {
aadlbaText.addOutput("#");
}
aadlbaText.addOutput(dpr.getQualifiedName().getBaNamespace().getId());
aadlbaText.addOutput("::");
if (false == dpr.getQualifiedName().getBaName().getId().isEmpty()) {
aadlbaText.addOutput(dpr.getQualifiedName().getBaName().getId());
aadlbaText.addOutput("#");
}
processEList(dpr.getPropertyNames(), ".");
} else if (object instanceof DeclarativePropertyName) {
DeclarativePropertyName dpn = (DeclarativePropertyName) object;
aadlbaText.addOutput(dpn.getPropertyName().getId());
// field
process(dpn.getField());
// indexes
caseArrayIndex(dpn.getIndexes());
}
return DONE;
}
@Override
public String caseSubprogramCallAction(SubprogramCallAction object) {
if (object.getProxy() != null) {
process(object.getProxy());
aadlbaText.addOutput(".");
}
process(object.getSubprogram());
aadlbaText.addOutput(" !");
if (object.isSetParameterLabels()) {
aadlbaText.addOutput(" (");
processEList(object.getParameterLabels(), ", ");
aadlbaText.addOutput(")");
}
return DONE;
}
@Override
public String casePortSendAction(PortSendAction object) {
process(object.getPort());
aadlbaText.addOutput(" !");
if (object.getValueExpression() != null) {
aadlbaText.addOutput(" (");
process(object.getValueExpression());
aadlbaText.addOutput(")");
}
return DONE;
}
@Override
public String casePortFreezeAction(PortFreezeAction object) {
return casePortActionOrValue(object, " >>");
}
@Override
public String casePortDequeueAction(PortDequeueAction object) {
process(object.getPort());
aadlbaText.addOutput(" ?");
if (object.getTarget() != null) {
aadlbaText.addOutput(" (");
process(object.getTarget());
aadlbaText.addOutput(")");
}
return DONE;
}
@Override
public String caseLockAction(LockAction object) {
return caseSharedDataAction(object, "!<");
}
@Override
public String caseUnlockAction(UnlockAction object) {
return caseSharedDataAction(object, "!>");
}
public String caseSharedDataAction(SharedDataAction object, String token) {
if (object.getDataAccess() != null) {
process(object.getDataAccess());
aadlbaText.addOutput(" ");
} else {
aadlbaText.addOutput("*");
}
aadlbaText.addOutput(token);
return DONE;
}
/**
* Unparse behaviortime
*/
@Override
public String caseBehaviorTime(BehaviorTime object) {
// FIXME : TODO : update location reference
process(object.getIntegerValue());
aadlbaText.addOutput(" ");
if (object.getUnit() != null) {
aadlbaText.addOutput(object.getUnit().getName());
} else {
if (object instanceof DeclarativeTime) {
DeclarativeTime dt = (DeclarativeTime) object;
aadlbaText.addOutput(dt.getUnitId().getId());
}
}
return DONE;
}
@Override
public String casePortDequeueValue(PortDequeueValue object) {
return casePortActionOrValue(object, " ?");
}
@Override
public String casePortCountValue(PortCountValue object) {
return casePortActionOrValue(object, "' count");
}
@Override
public String casePortFreshValue(PortFreshValue object) {
return casePortActionOrValue(object, "' fresh");
}
public String casePortActionOrValue(PortHolder object, String token) {
caseElementHolder(object);
aadlbaText.addOutput(token);
return DONE;
}
/**
* Unparse booleanliteral
*/
@Override
public String caseBehaviorBooleanLiteral(BehaviorBooleanLiteral object) {
// FIXME : TODO : update location reference
if (object.isValue()) {
aadlbaText.addOutput("true");
} else {
aadlbaText.addOutput("false");
}
return DONE;
}
/**
* Unparse stringliteral
*/
@Override
public String caseBehaviorStringLiteral(BehaviorStringLiteral object) {
// FIXME : TODO : update location reference
// DB: Manage adding double quotes
aadlbaText.addOutput(doubleQuoteString(object.getValue()));
return DONE;
}
@Override
public String caseBehaviorRealLiteral(BehaviorRealLiteral object) {
aadlbaText.addOutput(String.valueOf(object.getValue()));
return DONE;
}
@Override
public String caseBehaviorIntegerLiteral(BehaviorIntegerLiteral object) {
aadlbaText.addOutput(Long.toString(object.getValue()));
return DONE;
}
/**
* Unparse valueexpression
*/
@Override
public String caseValueExpression(ValueExpression object) {
// FIXME : TODO : update location reference
Iterator<Relation> itRel = object.getRelations().iterator();
process(itRel.next());
if (object.isSetLogicalOperators()) {
Iterator<LogicalOperator> itOp = object.getLogicalOperators().iterator();
while (itRel.hasNext()) {
LogicalOperator lo = itOp.next();
if (lo != LogicalOperator.NONE) {
aadlbaText.addOutput(" " + lo.getLiteral() + " ");
}
process(itRel.next());
}
}
return DONE;
}
/**
* Unparse relation
*/
@Override
public String caseRelation(Relation object) {
// FIXME : TODO : update location reference
process(object.getFirstExpression());
if (object.getSecondExpression() != null) {
if (object.getRelationalOperator() != RelationalOperator.NONE) {
aadlbaText.addOutput(" " + object.getRelationalOperator().getLiteral() + " ");
}
process(object.getSecondExpression());
}
return DONE;
}
/**
* Unparse simpleexpression
*/
@Override
public String caseSimpleExpression(SimpleExpression object) {
// FIXME : TODO : update location reference
if (object.isSetUnaryAddingOperator() && object.getUnaryAddingOperator() != UnaryAddingOperator.NONE) {
aadlbaText.addOutput(object.getUnaryAddingOperator().getLiteral());
}
Iterator<Term> itTerm = object.getTerms().iterator();
process(itTerm.next());
if (object.isSetBinaryAddingOperators()) {
Iterator<BinaryAddingOperator> itOp = object.getBinaryAddingOperators().iterator();
while (itTerm.hasNext()) {
BinaryAddingOperator bao = itOp.next();
if (bao != BinaryAddingOperator.NONE) {
aadlbaText.addOutput(" " + bao.getLiteral() + " ");
}
process(itTerm.next());
}
}
return DONE;
}
/**
* Unparse term
*/
@Override
public String caseTerm(Term object) {
// FIXME : TODO : update location reference
Iterator<Factor> itFact = object.getFactors().iterator();
process(itFact.next());
if (object.isSetMultiplyingOperators()) {
Iterator<MultiplyingOperator> itOp = object.getMultiplyingOperators().iterator();
while (itFact.hasNext()) {
MultiplyingOperator mo = itOp.next();
if (mo != MultiplyingOperator.NONE) {
aadlbaText.addOutput(" " + mo.getLiteral() + " ");
}
process(itFact.next());
}
}
return DONE;
}
/**
* Unparse factor
*/
@Override
public String caseFactor(Factor object) {
// FIXME : TODO : update location reference
if (object.isSetUnaryNumericOperator() || object.isSetUnaryBooleanOperator()) {
Enumerator e = null;
if (object.isSetUnaryNumericOperator()) {
e = object.getUnaryNumericOperator();
if (e != UnaryNumericOperator.NONE) {
aadlbaText.addOutput(e.getLiteral() + " ");
}
} else if (object.isSetUnaryBooleanOperator()) {
e = object.getUnaryBooleanOperator();
if (e != UnaryBooleanOperator.NONE) {
aadlbaText.addOutput(e.getLiteral() + " ");
}
}
}
if (object.getFirstValue() instanceof ValueExpression) {
aadlbaText.addOutput("(");
process(object.getFirstValue());
aadlbaText.addOutput(")");
} else {
process(object.getFirstValue());
}
if (object.isSetBinaryNumericOperator()) {
BinaryNumericOperator bno = object.getBinaryNumericOperator();
if (bno != BinaryNumericOperator.NONE) {
aadlbaText.addOutput(" " + bno.getLiteral() + " ");
}
if (object.getSecondValue() instanceof ValueExpression) {
aadlbaText.addOutput("(");
process(object.getSecondValue());
aadlbaText.addOutput(")");
} else {
process(object.getSecondValue());
}
}
return DONE;
}
@Override
public String caseBehaviorPropertyConstant(BehaviorPropertyConstant object) {
aadlbaText.addOutput("#");
if (object.getPropertySet() != null) {
aadlbaText.addOutput(object.getPropertySet().getQualifiedName());
aadlbaText.addOutput("::");
}
aadlbaText.addOutput(object.getProperty().getName());
return DONE;
}
@Override
public String casePropertySetPropertyReference(PropertySetPropertyReference object) {
aadlbaText.addOutput("#");
if (object.getPropertySet() != null) {
aadlbaText.addOutput(object.getPropertySet().getQualifiedName());
aadlbaText.addOutput("::");
}
processEList(object.getProperties(), ".");
return DONE;
}
@Override
public String caseClassifierPropertyReference(ClassifierPropertyReference object) {
org.osate.aadl2.Classifier c = object.getClassifier();
process(c, object);
aadlbaText.addOutput("#");
processEList(object.getProperties(), ".");
return DONE;
}
@Override
public String caseClassifierFeaturePropertyReference(ClassifierFeaturePropertyReference object) {
process(object.getComponent());
aadlbaText.addOutput("#");
processEList(object.getProperties(), ".");
return DONE;
}
@Override
public String casePropertyNameHolder(PropertyNameHolder pnh) {
PropertyElementHolder peh = pnh.getProperty();
Element el = peh.getElement();
if (el instanceof NamedElement) {
aadlbaText.addOutput(((NamedElement) el).getName());
} else if (el instanceof PropertyAssociation) {
aadlbaText.addOutput(((PropertyAssociation) el).getProperty().getName());
} else {
String tmp = unparse((PropertyExpression) el);
aadlbaText.addOutput(tmp);
}
if (pnh.getField() != null) {
aadlbaText.addOutput(".");
process(pnh.getField());
} else if (peh.isSetArrayIndexes()) {
caseArrayIndex(peh.getArrayIndexes());
}
return DONE;
}
@Override
public String caseUpperBound(UpperBound object) {
aadlbaText.addOutput("upper_bound");
return DONE;
}
@Override
public String caseLowerBound(LowerBound object) {
aadlbaText.addOutput("lower_bound");
return DONE;
}
};
}
use of org.osate.aadl2.BooleanLiteral in project osate2 by osate.
the class AadlBaParserVisitor method clonePropertyExpression.
private PropertyExpression clonePropertyExpression(PropertyExpression sourcePropertyExpression) {
PropertyExpression targetPropertyExpression = null;
if (sourcePropertyExpression instanceof ListValue) {
ListValue sourceLV = (ListValue) sourcePropertyExpression;
ListValue targetLV = _coreFact.createListValue();
for (PropertyExpression propInList : sourceLV.getOwnedListElements()) {
targetLV.getOwnedListElements().add(clonePropertyExpression(propInList));
}
targetPropertyExpression = targetLV;
} else if (sourcePropertyExpression instanceof StringLiteral) {
StringLiteral sourceSL = (StringLiteral) sourcePropertyExpression;
StringLiteral targetSL = _coreFact.createStringLiteral();
targetSL.setValue(sourceSL.getValue());
targetPropertyExpression = targetSL;
} else if (sourcePropertyExpression instanceof IntegerLiteral) {
IntegerLiteral sourceIL = (IntegerLiteral) sourcePropertyExpression;
IntegerLiteral targetIL = _coreFact.createIntegerLiteral();
targetIL.setValue(sourceIL.getValue());
targetIL.setUnit(sourceIL.getUnit());
targetPropertyExpression = targetIL;
} else if (sourcePropertyExpression instanceof RealLiteral) {
RealLiteral sourceRL = (RealLiteral) sourcePropertyExpression;
RealLiteral targetRL = _coreFact.createRealLiteral();
targetRL.setValue(sourceRL.getValue());
targetRL.setUnit(sourceRL.getUnit());
targetPropertyExpression = targetRL;
} else if (sourcePropertyExpression instanceof RecordValue) {
RecordValue sourceRV = (RecordValue) sourcePropertyExpression;
RecordValue targetRV = _coreFact.createRecordValue();
targetRV.getOwnedFieldValues().addAll(sourceRV.getOwnedFieldValues());
targetPropertyExpression = targetRV;
} else if (sourcePropertyExpression instanceof BooleanLiteral) {
BooleanLiteral sourceBL = (BooleanLiteral) sourcePropertyExpression;
BooleanLiteral targetBL = _coreFact.createBooleanLiteral();
targetBL.setValue(sourceBL.getValue());
targetPropertyExpression = targetBL;
} else if (sourcePropertyExpression instanceof RangeValue) {
RangeValue sourceRV = (RangeValue) sourcePropertyExpression;
RangeValue targetRV = _coreFact.createRangeValue();
targetRV.setMinimum(clonePropertyExpression(sourceRV.getMinimum()));
targetRV.setMaximum(clonePropertyExpression(sourceRV.getMaximum()));
targetPropertyExpression = targetRV;
} else if (sourcePropertyExpression instanceof DeclarativeReferenceValue) {
DeclarativeReferenceValue sourceDRV = (DeclarativeReferenceValue) sourcePropertyExpression;
ReferenceValue targetRV = _coreFact.createReferenceValue();
targetRV.setPath(sourceDRV.getRef());
targetPropertyExpression = targetRV;
} else if (sourcePropertyExpression instanceof DeclarativeClassifierValue) {
DeclarativeClassifierValue sourceDCV = (DeclarativeClassifierValue) sourcePropertyExpression;
ClassifierValue targetCV = _coreFact.createClassifierValue();
targetCV.setClassifier(sourceDCV.getClassifier());
targetPropertyExpression = targetCV;
}
return targetPropertyExpression;
}
Aggregations