Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracuccuru2013-04-15 09:41:42 +0000
committeracuccuru2013-04-15 09:41:42 +0000
commit4d119c3a2e4c6667369a6a6d22f7cd3a17225c90 (patch)
tree0f82d52161ce6d4e6f143687e61b4de7759c8ada /sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus
parent2d3b3760063be2fd7a8ec2b5f95f215169af4029 (diff)
downloadorg.eclipse.papyrus-4d119c3a2e4c6667369a6a6d22f7cd3a17225c90.tar.gz
org.eclipse.papyrus-4d119c3a2e4c6667369a6a6d22f7cd3a17225c90.tar.xz
org.eclipse.papyrus-4d119c3a2e4c6667369a6a6d22f7cd3a17225c90.zip
405391: [Moka] Moka shall provide an implementation of the fUML Execution Model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405391
Diffstat (limited to 'sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus')
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/ActionActivation.java376
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallActionActivation.java107
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallBehaviorActionActivation.java43
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallOperationActionActivation.java36
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InputPinActivation.java39
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InvocationActionActivation.java17
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/OutputPinActivation.java91
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/PinActivation.java78
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/SendSignalActionActivation.java50
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionActivation.java150
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionEventAccepter.java38
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadExtentActionActivation.java45
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadIsClassifiedObjectActionActivation.java72
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReclassifyObjectActionActivation.java95
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReduceActionActivation.java97
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartClassifierBehaviorActionActivation.java41
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartObjectBehaviorActionActivation.java75
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/AddStructuralFeatureValueActionActivation.java123
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearAssociationActionActivation.java41
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearStructuralFeatureActionActivation.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateLinkActionActivation.java85
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateObjectActionActivation.java32
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyLinkActionActivation.java97
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyObjectActionActivation.java101
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/LinkActionActivation.java70
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadLinkActionActivation.java81
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadSelfActionActivation.java35
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadStructuralFeatureActionActivation.java56
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/RemoveStructuralFeatureValueActionActivation.java119
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/StructuralFeatureActionActivation.java78
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/TestIdentityActionActivation.java34
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ValueSpecificationActionActivation.java29
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteLinkActionActivation.java17
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteStructuralFeatureActionActivation.java37
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ClauseActivation.java129
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ConditionalNodeActivation.java176
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/LoopNodeActivation.java256
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/StructuredActivityNodeActivation.java211
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/Values.java24
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionActivationGroup.java122
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionNodeActivation.java60
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionRegionActivation.java326
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/TokenSet.java27
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityEdgeInstance.java202
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityExecution.java89
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityFinalNodeActivation.java44
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivation.java353
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivationGroup.java313
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityParameterNodeActivation.java74
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlNodeActivation.java36
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlToken.java40
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/DecisionNodeActivation.java313
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/FlowFinalNodeActivation.java37
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkNodeActivation.java60
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkedToken.java72
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/InitialNodeActivation.java36
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/JoinNodeActivation.java28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/MergeNodeActivation.java17
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectNodeActivation.java130
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectToken.java48
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Offer.java84
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Token.java58
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/BooleanValue.java65
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/CompoundValue.java150
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DataValue.java49
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DispatchStrategy.java36
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/EnumerationValue.java80
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Evaluation.java33
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/ExtensionalValue.java43
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/FeatureValue.java105
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/InstanceValueEvaluation.java110
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/IntegerValue.java98
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Link.java141
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralBooleanEvaluation.java28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralEvaluation.java29
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralIntegerEvaluation.java28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralNullEvaluation.java23
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralRealEvaluation.java28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralStringEvaluation.java28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralUnlimitedNaturalEvaluation.java29
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Object_.java130
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/PrimitiveValue.java39
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RealValue.java93
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RedefinitionBasedDispatchStrategy.java66
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Reference.java99
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StringValue.java58
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StructuredValue.java95
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/UnlimitedNaturalValue.java69
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Value.java92
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/Execution.java114
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/OpaqueBehaviorExecution.java47
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/ParameterValue.java44
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ArrivalSignal.java17
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ClassifierBehaviorExecution.java86
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/EventAccepter.java21
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/FIFOGetNextEventStrategy.java25
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/GetNextEventStrategy.java26
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ObjectActivation.java187
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/SignalInstance.java47
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ChoiceStrategy.java24
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactory.java179
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactoryL1.java55
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Executor.java74
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/FirstChoiceStrategy.java22
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Locus.java153
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticStrategy.java19
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticVisitor.java27
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL2/ExecutionFactoryL2.java139
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL3/ExecutionFactoryL3.java85
109 files changed, 9142 insertions, 0 deletions
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/ActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/ActionActivation.java
new file mode 100644
index 00000000000..644aa86368d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/ActionActivation.java
@@ -0,0 +1,376 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityEdgeInstance;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ControlToken;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ForkNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ObjectToken;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.BooleanValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ConditionalNode;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.LiteralBoolean;
+import org.eclipse.uml2.uml.LoopNode;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Pin;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public abstract class ActionActivation extends ActivityNodeActivation {
+
+ /*
+ * The activations of the pins owned by the action of this action
+ * activation.
+ */
+ public List<PinActivation> pinActivations = new ArrayList<PinActivation>();
+
+ /*
+ * Whether this action activation is already firing. This attribute is only
+ * used if the action for this action activation has isLocallyReentrant =
+ * false (the default). If isLocallyReentrant=true, then firing always just
+ * remains false.
+ */
+ public Boolean firing;
+
+ public void run() {
+ // Run this action activation and any outoging fork node attached to it.
+ super.run();
+ if(this.outgoingEdges.size() > 0) {
+ this.outgoingEdges.get(0).target.run();
+ }
+ this.firing = false;
+ }
+
+ public List<Token> takeOfferedTokens() {
+ // If the action is not locally reentrant, then mark this activation as
+ // firing.
+ // Take any incoming offers of control tokens, then concurrently fire
+ // all input pin activations.
+ // Note: This is included here to happen in the same isolation scope as
+ // the isReady test.
+ this.firing = !((Action)this.node).isLocallyReentrant();
+ List<Token> offeredTokens = new ArrayList<Token>();
+ List<ActivityEdgeInstance> incomingEdges = this.incomingEdges;
+ for(int i = 0; i < incomingEdges.size(); i++) {
+ ActivityEdgeInstance incomingEdge = incomingEdges.get(i);
+ List<Token> tokens = incomingEdge.takeOfferedTokens();
+ for(int j = 0; j < tokens.size(); j++) {
+ Token token = tokens.get(j);
+ token.withdraw();
+ offeredTokens.add(token);
+ }
+ }
+ Action action = (Action)(this.node);
+ // *** Fire all input pins concurrently. ***
+ List<InputPin> inputPins = getInputs(action); // CHANGED from: action.getInputs();
+ for(Iterator<InputPin> i = inputPins.iterator(); i.hasNext();) {
+ InputPin pin = i.next();
+ PinActivation pinActivation = this.getPinActivation(pin);
+ List<Token> tokens = pinActivation.takeOfferedTokens();
+ pinActivation.fire(tokens);
+ for(int j = 0; j < tokens.size(); j++) {
+ Token token = tokens.get(j);
+ offeredTokens.add(token);
+ }
+ }
+ return offeredTokens;
+ }
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Do the main action behavior then concurrently fire all output pin
+ // activations
+ // and offer a single control token. Then activate the action again,
+ // if it is still ready to fire and has at least one token actually
+ // being
+ // offered to it.
+ do {
+ Debug.println("[fire] Action " + this.node.getName() + "...");
+ Debug.println("[event] Fire activity=" + this.getActivityExecution().getBehavior().getName() + " action=" + this.node.getName());
+ this.doAction();
+ incomingTokens = this.completeAction();
+ } while(incomingTokens.size() > 0);
+ }
+
+ public void terminate() {
+ // Terminate this action activation and any outgoing fork node attached
+ // to it.
+ super.terminate();
+ if(this.outgoingEdges.size() > 0) {
+ this.outgoingEdges.get(0).target.terminate();
+ }
+ }
+
+ public List<Token> completeAction() {
+ // Concurrently fire all output pin activations and offer a single
+ // control token. Then check if the action should fire again
+ // and, if so, return additional incoming tokens for this.
+ this.sendOffers();
+ Debug.println("[fire] Checking if " + this.node.getName() + " should fire again...");
+ _beginIsolation();
+ List<Token> incomingTokens = new ArrayList<Token>();
+ this.firing = false;
+ if(this.isReady()) {
+ incomingTokens = this.takeOfferedTokens();
+ this.firing = this.isFiring() & incomingTokens.size() > 0;
+ }
+ _endIsolation();
+ return incomingTokens;
+ }
+
+ public Boolean isReady() {
+ // In addition to the default condition, check that, if the action has
+ // isLocallyReentrant=false, then the activation is not currently
+ // firing,
+ // and that the sources of all incoming edges (control flows) have
+ // offers and all input pin activations are ready.
+ // [This assumes that all edges directly incoming to the action are
+ // control flows.]
+ boolean ready = super.isReady() & (((Action)this.node).isLocallyReentrant() | !this.isFiring());
+ int i = 1;
+ while(ready & i <= this.incomingEdges.size()) {
+ ready = this.incomingEdges.get(i - 1).hasOffer();
+ i = i + 1;
+ }
+ List<InputPin> inputPins = getInputs((Action)this.node); // CHANGED from: ((Action)(this.node)).getInputs();
+ int j = 1;
+ while(ready & j <= inputPins.size()) {
+ ready = this.getPinActivation(inputPins.get(j - 1)).isReady();
+ j = j + 1;
+ }
+ return ready;
+ }
+
+ public Boolean isFiring() {
+ // Indicate whether this action activation is currently firing or not.
+ return this.firing == null? false: this.firing; // ADDED check for null
+ }
+
+ public abstract void doAction();
+
+ public void sendOffers() {
+ // Fire all output pins and send offers on all outgoing control flows.
+ Action action = (Action)(this.node);
+ // *** Send offers from all output pins concurrently. ***
+ List<OutputPin> outputPins = getOutputs(action); // CHANGED from: action.getOutputs();
+ for(Iterator<OutputPin> i = outputPins.iterator(); i.hasNext();) {
+ OutputPin outputPin = i.next();
+ PinActivation pinActivation = this.getPinActivation(outputPin);
+ pinActivation.sendUnofferedTokens();
+ }
+ // Send offers on all outgoing control flows.
+ if(this.outgoingEdges.size() > 0) {
+ List<Token> tokens = new ArrayList<Token>();
+ tokens.add(new ControlToken());
+ this.addTokens(tokens);
+ this.outgoingEdges.get(0).sendOffer(tokens);
+ }
+ }
+
+ public void createNodeActivations() {
+ // Create node activations for the input and output pins of the action
+ // for this activation.
+ // [Note: Pins are owned by their actions, not by the enclosing activity
+ // (or group), so they must be activated through the action activation.]
+ Action action = (Action)(this.node);
+ List<ActivityNode> inputPinNodes = new ArrayList<ActivityNode>();
+ List<InputPin> inputPins = getInputs(action); // CHANGED from: action.getInputs();
+ for(int i = 0; i < inputPins.size(); i++) {
+ InputPin inputPin = inputPins.get(i);
+ inputPinNodes.add(inputPin);
+ }
+ this.group.createNodeActivations(inputPinNodes);
+ for(int i = 0; i < inputPinNodes.size(); i++) {
+ ActivityNode node = inputPinNodes.get(i);
+ this.addPinActivation((PinActivation)(this.group.getNodeActivation(node)));
+ }
+ List<ActivityNode> outputPinNodes = new ArrayList<ActivityNode>();
+ List<OutputPin> outputPins = getOutputs(action); // CHANGED from: action.getOutputs();
+ for(int i = 0; i < outputPins.size(); i++) {
+ OutputPin outputPin = outputPins.get(i);
+ outputPinNodes.add(outputPin);
+ }
+ this.group.createNodeActivations(outputPinNodes);
+ for(int i = 0; i < outputPinNodes.size(); i++) {
+ ActivityNode node = outputPinNodes.get(i);
+ this.addPinActivation((PinActivation)(this.group.getNodeActivation(node)));
+ }
+ }
+
+ public void addOutgoingEdge(ActivityEdgeInstance edge) {
+ // If there are no outgoing activity edge instances, create a single
+ // activity edge instance with a fork node execution at the other end.
+ // Add the give edge to the fork node execution that is the target of
+ // the activity edge instance out of this action execution.
+ // [This assumes that all edges directly outgoing from the action are
+ // control flows, with an implicit fork for offers out of the action.]
+ ActivityNodeActivation forkNodeActivation;
+ if(this.outgoingEdges.size() == 0) {
+ forkNodeActivation = new ForkNodeActivation();
+ forkNodeActivation.running = false; // ADDED
+ ActivityEdgeInstance newEdge = new ActivityEdgeInstance();
+ super.addOutgoingEdge(newEdge);
+ forkNodeActivation.addIncomingEdge(newEdge);
+ } else {
+ forkNodeActivation = this.outgoingEdges.get(0).target;
+ }
+ forkNodeActivation.addOutgoingEdge(edge);
+ }
+
+ public void addPinActivation(PinActivation pinActivation) {
+ // Add a pin activation to this action activation.
+ this.pinActivations.add(pinActivation);
+ pinActivation.actionActivation = this;
+ }
+
+ public PinActivation getPinActivation(Pin pin) {
+ // Precondition: The given pin is owned by the action of the action
+ // activation.
+ // Return the pin activation corresponding to the given pin.
+ PinActivation pinActivation = null;
+ int i = 1;
+ while(pinActivation == null & i <= this.pinActivations.size()) {
+ PinActivation thisPinActivation = this.pinActivations.get(i - 1);
+ if(thisPinActivation.node == pin) {
+ pinActivation = thisPinActivation;
+ }
+ i = i + 1;
+ }
+ return pinActivation;
+ }
+
+ public void putToken(OutputPin pin, Value value) {
+ // Precondition: The action execution has fired and the given pin is
+ // owned by the action of the action execution.
+ // Place a token for the given value on the pin activation corresponding
+ // to the given output pin.
+ Debug.println("[putToken] node = " + this.node.getName());
+ ObjectToken token = new ObjectToken();
+ token.value = value;
+ PinActivation pinActivation = this.getPinActivation(pin);
+ pinActivation.addToken(token);
+ }
+
+ public void putTokens(OutputPin pin, List<Value> values) {
+ // Precondition: The action execution has fired and the given pin is
+ // owned by the action of the action execution.
+ // Place tokens for the given values on the pin activation corresponding
+ // to the given output pin.
+ // Debug.println("[putTokens] node = " + this.node.getName());
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ this.putToken(pin, value);
+ }
+ }
+
+ public List<Value> getTokens(InputPin pin) {
+ // Precondition: The action execution has fired and the given pin is
+ // owned by the action of the action execution.
+ // Get any tokens held by the pin activation corresponding to the given
+ // input pin and return them
+ // (but leave the tokens on the pin).
+ Debug.println("[getTokens] node = " + this.node.getName() + ", pin = " + pin.getName());
+ PinActivation pinActivation = this.getPinActivation(pin);
+ List<Token> tokens = pinActivation.getUnofferedTokens();
+ List<Value> values = new ArrayList<Value>();
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ Value value = ((ObjectToken)token).value;
+ if(value != null) {
+ values.add(value);
+ }
+ }
+ return values;
+ }
+
+ public List<Value> takeTokens(InputPin pin) {
+ // Precondition: The action execution has fired and the given pin is
+ // owned by the action of the action execution.
+ // Take any tokens held by the pin activation corresponding to the given
+ // input pin and return them.
+ Debug.println("[takeTokens] node = " + this.node.getName() + ", pin = " + pin.getName());
+ PinActivation pinActivation = this.getPinActivation(pin);
+ List<Token> tokens = pinActivation.takeUnofferedTokens();
+ List<Value> values = new ArrayList<Value>();
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ Value value = ((ObjectToken)token).value;
+ if(value != null) {
+ values.add(value);
+ }
+ }
+ return values;
+ }
+
+ public Boolean isSourceFor(ActivityEdgeInstance edgeInstance) {
+ // If this action has an outgoing fork node, check that the fork node is
+ // the source of the given edge instance.
+ boolean isSource = false;
+ if(this.outgoingEdges.size() > 0) {
+ isSource = this.outgoingEdges.get(0).target.isSourceFor(edgeInstance);
+ }
+ return isSource;
+ }
+
+ public Boolean valueParticipatesInLink(Value value, Link link) {
+ // Test if the given value participates in the given link.
+ List<FeatureValue> linkFeatureValues = link.getFeatureValues();
+ boolean participates = false;
+ int i = 1;
+ while(!participates & i <= linkFeatureValues.size()) {
+ participates = linkFeatureValues.get(i - 1).values.get(0).equals(value);
+ i = i + 1;
+ }
+ return participates;
+ }
+
+ public BooleanValue makeBooleanValue(Boolean value) {
+ // Make a Boolean value using the built-in Boolean primitive type.
+ // [This ensures that Boolean values created internally are the same as
+ // the default used for evaluating Boolean literals.]
+ LiteralBoolean booleanLiteral = UMLFactory.eINSTANCE.createLiteralBoolean();
+ booleanLiteral.setValue(value);
+ return (BooleanValue)(this.getExecutionLocus().executor.evaluate(booleanLiteral));
+ }
+
+ // ADDED:
+ protected static List<InputPin> getInputs(Action action) {
+ return action instanceof LoopNode? ((LoopNode)action).getLoopVariableInputs():
+ action.getInputs();
+ }
+
+ protected static List<OutputPin> getOutputs(Action action) {
+ return action instanceof LoopNode? ((LoopNode)action).getResults():
+ action instanceof ConditionalNode? ((ConditionalNode)action).getResults():
+ action.getOutputs();
+ }
+ //
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallActionActivation.java
new file mode 100644
index 00000000000..46742380c67
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallActionActivation.java
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.CallAction;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+
+public abstract class CallActionActivation extends InvocationActionActivation {
+
+ /*
+ * The set of execution object for currently ongoing calls made through this
+ * call action activation.
+ */
+ public List<Execution> callExecutions = new ArrayList<Execution>();
+
+ public void doAction() {
+ // Get the call execution object, set its input parameters from the
+ // argument pins and execute it.
+ // Once execution completes, copy the values of the output parameters of
+ // the call execution to the result pins of the call action execution,
+ // then destroy the execution.
+ Execution callExecution = this.getCallExecution();
+ if(callExecution != null) {
+ this.callExecutions.add(callExecution);
+ CallAction callAction = (CallAction)(this.node);
+ List<InputPin> argumentPins = callAction.getArguments();
+ List<OutputPin> resultPins = callAction.getResults();
+ List<Parameter> parameters = callExecution.getBehavior().getOwnedParameters();
+ int pinNumber = 1;
+ int i = 1;
+ while(i <= parameters.size()) {
+ Parameter parameter = parameters.get(i - 1);
+ if(parameter.getDirection() == ParameterDirectionKind.IN_LITERAL | parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ ParameterValue parameterValue = new ParameterValue();
+ parameterValue.parameter = parameter;
+ parameterValue.values = this.takeTokens(argumentPins.get(pinNumber - 1));
+ callExecution.setParameterValue(parameterValue);
+ pinNumber = pinNumber + 1;
+ }
+ i = i + 1;
+ }
+ callExecution.execute();
+ List<ParameterValue> outputParameterValues = callExecution.getOutputParameterValues();
+ pinNumber = 1;
+ i = 1;
+ while(i <= parameters.size()) {
+ Parameter parameter = parameters.get(i - 1);
+ if((parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL)) {
+ for(int j = 0; j < outputParameterValues.size(); j++) {
+ ParameterValue outputParameterValue = outputParameterValues.get(j);
+ if(outputParameterValue.parameter == parameter) {
+ OutputPin resultPin = resultPins.get(pinNumber - 1);
+ this.putTokens(resultPin, outputParameterValue.values);
+ }
+ }
+ pinNumber = pinNumber + 1;
+ }
+ i = i + 1;
+ }
+ callExecution.destroy();
+ this.removeCallExecution(callExecution);
+ }
+ }
+
+ public abstract Execution getCallExecution();
+
+ public void terminate() {
+ // Terminate all call executions (if any), then terminate the call
+ // action activation (self).
+ for(int i = 0; i < this.callExecutions.size(); i++) {
+ Execution execution = this.callExecutions.get(i);
+ execution.terminate();
+ }
+ super.terminate();
+ }
+
+ public void removeCallExecution(Execution execution) {
+ // Remove the given execution from the current list of call executions.
+ boolean notFound = true;
+ int i = 1;
+ while(notFound & i <= this.callExecutions.size()) {
+ if(this.callExecutions.get(i - 1) == execution) {
+ this.callExecutions.remove(i - 1);
+ notFound = false;
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallBehaviorActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallBehaviorActionActivation.java
new file mode 100644
index 00000000000..0b171b3b92f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallBehaviorActionActivation.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+
+public class CallBehaviorActionActivation extends CallActionActivation {
+
+ public Execution getCallExecution() {
+ // Create and execution for the given behavior at the current locus and
+ // return the resulting execution object.
+ // If the given behavior is in the context of a classifier, then pass
+ // the current context object as the context for the call.
+ // Otherwise, use a null context.
+ // [Note that this requires the behavior context to be compatible with
+ // the type of the current contect object.]
+ Behavior behavior = ((CallBehaviorAction)(this.node)).getBehavior();
+ Object_ context;
+ if(behavior.getContext() == null) {
+ context = null;
+ } else {
+ // Debug.println("[getCallExecution] behavior context = " +
+ // behavior.context.name);
+ context = this.getExecutionContext();
+ }
+ // Debug.println("[getCallExecution] context = " + context);
+ return this.getExecutionLocus().factory.createExecution(behavior, context);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallOperationActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallOperationActionActivation.java
new file mode 100644
index 00000000000..7140f7bab29
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/CallOperationActionActivation.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.uml2.uml.CallOperationAction;
+
+public class CallOperationActionActivation extends CallActionActivation {
+
+ public Execution getCallExecution() {
+ // If the value on the target input pin is a reference, dispatch the
+ // operation to it and return the resulting execution object.
+ CallOperationAction action = (CallOperationAction)(this.node);
+ Value target = this.takeTokens(action.getTarget()).get(0);
+ Execution execution;
+ if(target instanceof Reference) {
+ execution = ((Reference)target).dispatch(action.getOperation());
+ } else {
+ execution = null;
+ }
+ return execution;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InputPinActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InputPinActivation.java
new file mode 100644
index 00000000000..f639623f43a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InputPinActivation.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import org.eclipse.uml2.uml.Pin;
+
+public class InputPinActivation extends PinActivation {
+
+ public void receiveOffer() {
+ // Forward the offer to the action activation. [When all input pins are
+ // ready, the action will fire them.]
+ this.actionActivation.receiveOffer();
+ }
+
+ public Boolean isReady() {
+ // Return true if the total number of values already being offered by
+ // this pin plus those being offered
+ // by the sources of incoming edges is at least equal to the minimum
+ // multiplicity of the pin.
+ boolean ready = super.isReady();
+ if(ready) {
+ int totalValueCount = this.countUnofferedTokens() + this.countOfferedValues();
+ int minimum = ((Pin)this.node).getLower();
+ ready = totalValueCount >= minimum;
+ }
+ return ready;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InvocationActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InvocationActionActivation.java
new file mode 100644
index 00000000000..7d0c7af4940
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/InvocationActionActivation.java
@@ -0,0 +1,17 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+public abstract class InvocationActionActivation extends ActionActivation {
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/OutputPinActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/OutputPinActivation.java
new file mode 100644
index 00000000000..42df9fb586a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/OutputPinActivation.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+import org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils;
+import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils;
+import org.eclipse.uml2.uml.ActivityNode;
+
+public class OutputPinActivation extends PinActivation {
+
+ /**
+ * Overriding introduced to connect with the debug API
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ObjectNodeActivation#sendOffers(java.util.List)
+ */
+ @Override
+ public void sendOffers(List<Token> tokens) {
+ // Connection with the debug api
+ Locus locus = this.getActivityExecution().locus ;
+ if (locus.isInDebugMode) {
+ this.incomingTokens_DEBUG = tokens ;
+ if (locus.engine.isTerminated())
+ return ;
+ boolean animationMarkerNeedsToBeRemoved = false ;
+ long date = 0 ;
+ if (MokaConstants.MOKA_AUTOMATIC_ANIMATION) {
+ date = System.currentTimeMillis() ;
+ AnimationUtils.getInstance().addAnimationMarker(node) ;
+ animationMarkerNeedsToBeRemoved = true ;
+ }
+ MokaStackFrame stackFrame = FUMLPresentationUtils.getMokaStackFrame(this) ;
+ stackFrame.setThread(locus.mainThread) ;
+ StackFrameManager.getInstance().setStackFrame(this.getActivityExecution(), stackFrame) ;
+ //locus.stackFrames = new MokaStackFrame[]{stackFrame} ;
+ int reasonForSuspending = FUMLExecutionEngine.controlDelegate.shallSuspend(this.getActivityExecution(), this) ;
+ if (reasonForSuspending != -1) {
+ locus.mainThread.setSuspended(true) ;
+ locus.mainThread.setStackFrames(null) ;
+ locus.stackFrames = StackFrameManager.getInstance().getStackFrames() ;
+ Suspend_Event breakpointEvent = new Suspend_Event(locus.mainThread, reasonForSuspending, new MokaThread[]{locus.mainThread}) ;
+ locus.engine.sendEvent(breakpointEvent) ;
+ try {
+ FUMLExecutionEngine.controlDelegate.suspend(this.getActivityExecution()) ;
+ } catch (InterruptedException e) {
+ Activator.log.error(e);
+ }
+ locus.mainThread.setSuspended(false) ;
+ }
+ if (animationMarkerNeedsToBeRemoved) {
+ try {
+ long ellapsed = System.currentTimeMillis() - date ;
+ long delay = Math.max(1,MokaConstants.MOKA_ANIMATION_DELAY - ellapsed) ;
+ Thread.sleep(delay) ;
+ } catch (InterruptedException e1) {
+ Activator.log.error(e1);
+ }
+ AnimationUtils.getInstance().removeAnimationMarker(node) ;
+ }
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // End: Connection with the debug api
+ super.sendOffers(tokens);
+ }
+
+
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/PinActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/PinActivation.java
new file mode 100644
index 00000000000..d7843599b65
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/PinActivation.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityEdgeInstance;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ObjectNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.uml2.uml.Pin;
+
+public abstract class PinActivation extends ObjectNodeActivation {
+
+ /*
+ * The activation of the action that owns the pin for this pin activation.
+ */
+ public ActionActivation actionActivation;
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Add all incoming tokens to the pin.
+ Debug.println("[fire] Pin " + (this.node == null ? "" : this.node.getName() + "..."));
+ this.addTokens(incomingTokens);
+ }
+
+ public List<Token> takeOfferedTokens() {
+ // Take only a number of tokens only up to the limit allowed by
+ // the multiplicity upper bound of the pin for this activation.
+ int count = this.countUnofferedTokens();
+ int upper = -1;
+ // Note: A pin activation used in an expansion activation group
+ // will have this.node == null.
+ if(this.node != null) {
+ upper = ((Pin)(this.node)).getUpper();
+ }
+ List<Token> tokens = new ArrayList<Token>();
+ // Note: upper < 0 indicates an unbounded upper multiplicity.
+ if(upper < 0 | count < upper) {
+ List<ActivityEdgeInstance> incomingEdges = this.incomingEdges;
+ for(int i = 0; i < incomingEdges.size(); i++) {
+ ActivityEdgeInstance edge = incomingEdges.get(i);
+ int incomingCount = edge.countOfferedValues();
+ List<Token> incomingTokens = new ArrayList<Token>();
+ if(upper < 0 | incomingCount < upper - count) {
+ incomingTokens = edge.takeOfferedTokens();
+ count = count + incomingCount;
+ } else if(count < upper) {
+ incomingTokens = edge.takeOfferedTokens(upper - count);
+ count = upper;
+ }
+ for(int j = 0; j < incomingTokens.size(); j++) {
+ Token token = incomingTokens.get(j);
+ tokens.add(token);
+ }
+ }
+ }
+ return tokens;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/SendSignalActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/SendSignalActionActivation.java
new file mode 100644
index 00000000000..335b0dec9b9
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/BasicActions/SendSignalActionActivation.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.SignalInstance;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.SendSignalAction;
+import org.eclipse.uml2.uml.Signal;
+
+public class SendSignalActionActivation extends InvocationActionActivation {
+
+ public void doAction() {
+ // Get the value from the target pin. If the value is not a reference,
+ // then do nothing.
+ // Otherwise, construct a signal using the values from the argument pins
+ // and send it to the referent object.
+ SendSignalAction action = (SendSignalAction)(this.node);
+ Value target = this.takeTokens(action.getTarget()).get(0);
+ if(target instanceof Reference) {
+ Signal signal = action.getSignal();
+ SignalInstance signalInstance = new SignalInstance();
+ signalInstance.type = signal;
+ List<Property> attributes = signal.getOwnedAttributes();
+ List<InputPin> argumentPins = action.getArguments();
+ for(int i = 0; i < attributes.size(); i++) {
+ Property attribute = attributes.get(i);
+ InputPin argumentPin = argumentPins.get(i);
+ List<Value> values = this.takeTokens(argumentPin);
+ signalInstance.setFeatureValue(attribute, values, 0);
+ }
+ ((Reference)target).send(signalInstance);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionActivation.java
new file mode 100644
index 00000000000..d119f42db48
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionActivation.java
@@ -0,0 +1,150 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.SignalInstance;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.SignalEvent;
+import org.eclipse.uml2.uml.Trigger;
+
+public class AcceptEventActionActivation extends ActionActivation {
+
+ /*
+ * If the accept event action activation is waiting for an event, then this
+ * is the accepter it has registered for the event.
+ */
+ public AcceptEventActionEventAccepter eventAccepter;
+
+ public Boolean waiting;
+
+ public void run() {
+ // Create an event accepter and initialize waiting to false.
+ super.run();
+ this.eventAccepter = new AcceptEventActionEventAccepter();
+ this.eventAccepter.actionActivation = this;
+ this.waiting = false;
+ }
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Register the event accepter for this accept event action activation
+ // with the context object of the enclosing activity execution
+ // and wait for an event to be accepted.
+ Debug.println("[fire] Action " + this.node.getName() + "...");
+ this.getExecutionContext().register(this.eventAccepter);
+ this.waiting = true;
+ this.firing = false;
+ this.suspend();
+ }
+
+ public Boolean isReady() {
+ // An accept event action activiation is ready to fire only if it is not
+ // already waiting for an event.
+ boolean ready;
+ if(this.isWaiting()) { // CHANGED "this.waiting" to "this.isWaiting()".
+ ready = false;
+ } else {
+ ready = super.isReady();
+ }
+ return ready;
+ }
+
+ // ADDED:
+ public Boolean isWaiting() {
+ return this.waiting == null? false: this.waiting;
+ }
+ //
+
+ public void doAction() {
+ // Do nothing. [This will never be called.]
+ return;
+ }
+
+ public void accept(SignalInstance signalInstance) {
+ // Accept a signal occurance for the given signal instance.
+ // If the action does not unmarshall, then place the signal instance on
+ // the result pin, if any.
+ // If the action does unmarshall, then get the feature values of the
+ // signal instance, and place the values for each feature on the
+ // corresponding output pin.
+ // Concurrently fire all output pins while offering a single control
+ // token.
+ // If there are no incoming edges, then re-register this accept event
+ // action execution with the context object.
+ AcceptEventAction action = (AcceptEventAction)(this.node);
+ List<OutputPin> resultPins = action.getResults();
+ Debug.println("[accept] action = " + action.getName() + ", signalinstance = " + signalInstance);
+ if(this.running) {
+ if(!action.isUnmarshall()) {
+ List<Value> result = new ArrayList<Value>();
+ result.add(signalInstance);
+ if(resultPins.size() > 0) {
+ this.putTokens(resultPins.get(0), result);
+ }
+ } else {
+ List<FeatureValue> featureValues = signalInstance.getFeatureValues();
+ for(int i = 0; i < featureValues.size(); i++) {
+ FeatureValue featureValue = featureValues.get(i);
+ OutputPin resultPin = resultPins.get(i);
+ this.putTokens(resultPin, featureValue.values);
+ }
+ }
+ this.sendOffers();
+ this.waiting = false;
+ Debug.println("[fire] Checking if " + this.node.getName() + " should fire again...");
+ this.receiveOffer();
+ this.resume();
+ }
+ }
+
+ public Boolean match(SignalInstance signalInstance) {
+ // Return true if the given signal instance matches a trigger of the
+ // accept action of this activation.
+ AcceptEventAction action = (AcceptEventAction)(this.node);
+ List<Trigger> triggers = action.getTriggers();
+ Signal signal = signalInstance.type;
+ boolean matches = false;
+ int i = 1;
+ while(!matches & i <= triggers.size()) {
+ matches = ((SignalEvent)(triggers.get(i - 1).getEvent())).getSignal() == signal;
+ i = i + 1;
+ }
+ return matches;
+ }
+
+ public void terminate() {
+ // Terminate this action and unregister its event accepter.
+ super.terminate();
+ if(this.isWaiting()) { // CHANGED "this.waiting" to "this.isWaiting()".
+ this.getExecutionContext().unregister(this.eventAccepter);
+ this.waiting = false;
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionEventAccepter.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionEventAccepter.java
new file mode 100644
index 00000000000..36897d0a945
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/AcceptEventActionEventAccepter.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.EventAccepter;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.SignalInstance;
+
+public class AcceptEventActionEventAccepter extends EventAccepter {
+
+ /*
+ * The accept event action activation on behalf of which this event accepter
+ * is waiting.
+ */
+ public AcceptEventActionActivation actionActivation;
+
+ public void accept(SignalInstance signalInstance) {
+ // Accept a signal occurance for the given signal instance.
+ // Forward the signal occuranceto the action activation.
+ this.actionActivation.accept(signalInstance);
+ }
+
+ public Boolean match(SignalInstance signalInstance) {
+ // Return true if the given signal instance matches a trigger of the
+ // accept action of the action activation.
+ return this.actionActivation.match(signalInstance);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadExtentActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadExtentActionActivation.java
new file mode 100644
index 00000000000..81816936535
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadExtentActionActivation.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.ReadExtentAction;
+
+public class ReadExtentActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the extent, at the current execution locus, of the classifier
+ // (which must be a class) identified in the action.
+ // Place references to the resulting set of objects on the result pin.
+ ReadExtentAction action = (ReadExtentAction)(this.node);
+ List<ExtensionalValue> objects = this.getExecutionLocus().getExtent(action.getClassifier());
+ // Debug.println("[doAction] " + action.classifier.name + " has " +
+ // objects.size() + " instance(s).");
+ List<Value> references = new ArrayList<Value>();
+ for(int i = 0; i < objects.size(); i++) {
+ Value object = objects.get(i);
+ Reference reference = new Reference();
+ reference.referent = (Object_)object;
+ references.add(reference);
+ }
+ this.putTokens(action.getResult(), references);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadIsClassifiedObjectActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadIsClassifiedObjectActionActivation.java
new file mode 100644
index 00000000000..f52b719844f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReadIsClassifiedObjectActionActivation.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.ReadIsClassifiedObjectAction;
+
+public class ReadIsClassifiedObjectActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the value on the object input pin and determine if it is
+ // classified by the classifier specified in the action.
+ // If the isDirect attribute of the action is false, then place true on
+ // the result output pin if the input object has the specified
+ // classifier or of one its (direct or indirect) descendants as a type.
+ // If the isDirect attribute of the action is true, then place true on
+ // the result output pin if the input object has the specified
+ // classifier as a type.
+ // Otherwise place false on the result output pin.
+ ReadIsClassifiedObjectAction action = (ReadIsClassifiedObjectAction)(this.node);
+ Value input = this.takeTokens(action.getObject()).get(0);
+ List<Classifier> types = input.getTypes();
+ boolean result = false;
+ int i = 1;
+ while(!result & i <= types.size()) {
+ Classifier type = types.get(i - 1);
+ if(type == action.getClassifier()) {
+ result = true;
+ } else if(!action.isDirect()) {
+ result = this.checkAllParents(type, action.getClassifier());
+ }
+ i = i + 1;
+ }
+ List<Value> values = new ArrayList<Value>();
+ values.add(this.makeBooleanValue(result));
+ this.putTokens(action.getResult(), values);
+ }
+
+ public Boolean checkAllParents(Classifier type, Classifier classifier) {
+ // Check if the given classifier matches any of the direct or indirect
+ // ancestors of a given type.
+ List<Classifier> directParents = type.getGenerals();
+ boolean matched = false;
+ int i = 1;
+ while(!matched & i <= directParents.size()) {
+ Classifier directParent = directParents.get(i - 1);
+ if(directParent == classifier) {
+ matched = true;
+ } else {
+ matched = this.checkAllParents(directParent, classifier);
+ }
+ i = i + 1;
+ }
+ return matched;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReclassifyObjectActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReclassifyObjectActionActivation.java
new file mode 100644
index 00000000000..23c1a30498b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReclassifyObjectActionActivation.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.ReclassifyObjectAction;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class ReclassifyObjectActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the value of the object input pin. If it is not a reference, then
+ // do nothing. Otherwise, do the following.
+ // Remove all types from the referent object that are in the set of old
+ // classifiers but not the set of new classifiers (or just all types
+ // that are not new classifiers, if isReplaceAll is true).
+ // Remove the feature values from the referent object for all
+ // classifiers that are removed.
+ // Add all new classifiers as types of the referent object that are not
+ // already types.
+ // Add (empty) feature values to the referent object for the structural
+ // features of all added classifiers.
+ ReclassifyObjectAction action = (ReclassifyObjectAction)(this.node);
+ List<Classifier> newClassifiers = action.getNewClassifiers();
+ List<Classifier> oldClassifiers = action.getOldClassifiers();
+ Value input = this.takeTokens(action.getObject()).get(0);
+ if(input instanceof Reference) {
+ Object_ object = ((Reference)input).referent;
+ int i = 1;
+ while(i <= object.types.size()) {
+ Class type = object.types.get(i - 1);
+ boolean toBeRemoved = true;
+ int j = 1;
+ while(toBeRemoved & j <= newClassifiers.size()) {
+ toBeRemoved = (type != newClassifiers.get(j - 1));
+ j = j + 1;
+ }
+ if(toBeRemoved & !action.isReplaceAll()) {
+ boolean notInOld = true;
+ int k = 1;
+ while(notInOld & k <= oldClassifiers.size()) {
+ notInOld = (type != oldClassifiers.get(k - 1));
+ k = k + 1;
+ }
+ toBeRemoved = !notInOld;
+ }
+ if(toBeRemoved) {
+ object.types.remove(i - 1);
+ object.removeFeatureValues(type);
+ } else {
+ i = i + 1;
+ }
+ }
+ for(int n = 0; n < newClassifiers.size(); n++) {
+ Classifier classifier = newClassifiers.get(n);
+ boolean toBeAdded = true;
+ int j = 1;
+ while(toBeAdded & j <= object.types.size()) {
+ toBeAdded = (classifier != object.types.get(j - 1));
+ j = j + 1;
+ }
+ if(toBeAdded) {
+ object.types.add((Class)classifier);
+ List<NamedElement> members = classifier.getMembers();
+ for(int k = 0; k < members.size(); k++) {
+ NamedElement member = members.get(k);
+ if(member instanceof StructuralFeature) {
+ object.setFeatureValue((StructuralFeature)member, new ArrayList<Value>(), 0);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReduceActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReduceActionActivation.java
new file mode 100644
index 00000000000..b1e5f26b486
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/ReduceActionActivation.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.ReduceAction;
+
+public class ReduceActionActivation extends ActionActivation {
+
+ /*
+ * The current execution of the reducer behavior.
+ */
+ public Execution currentExecution;
+
+ public void doAction() {
+ // Get the values of the collection input pin.
+ // If the input pin has no values, then do nothing. Otherwise, do the
+ // following.
+ // Repeatedly invoke the reducer behavior on successive pairs to reduce
+ // the collection to a single value, and place that value on the result
+ // pin.
+ // To invoke the reducer behavior, compile it to create an execution,
+ // make the execution the current execution, place the appropriate
+ // values on its input parameters, and execute it.
+ ReduceAction action = (ReduceAction)(this.node);
+ List<Value> values = this.takeTokens(action.getCollection());
+ if(values.size() > 0) {
+ List<Parameter> parameters = action.getReducer().getOwnedParameters();
+ Parameter input1 = null;
+ Parameter input2 = null;
+ Parameter output = null;
+ int i = 1;
+ while(i <= parameters.size()) {
+ Parameter parameter = parameters.get(i - 1);
+ if(parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ if(input1 == null) {
+ input1 = parameter;
+ } else {
+ input2 = parameter;
+ }
+ } else if(parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL | parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
+ output = parameter;
+ }
+ i = i + 1;
+ }
+ ParameterValue parameterValue1 = new ParameterValue();
+ parameterValue1.parameter = input1;
+ parameterValue1.values = new ArrayList<Value>();
+ parameterValue1.values.add(values.get(0));
+ int j = 2;
+ while(j <= values.size()) {
+ this.currentExecution = this.getExecutionLocus().factory.createExecution(action.getReducer(), this.getExecutionContext());
+ this.currentExecution.setParameterValue(parameterValue1);
+ ParameterValue parameterValue2 = new ParameterValue();
+ parameterValue2.parameter = input2;
+ parameterValue2.values = new ArrayList<Value>();
+ parameterValue2.values.add(values.get(j - 1));
+ this.currentExecution.setParameterValue(parameterValue2);
+ this.currentExecution.execute();
+ parameterValue1.values = this.currentExecution.getParameterValue(output).values;
+ j = j + 1;
+ if(parameterValue1.values.isEmpty() & j <= values.size()) {
+ parameterValue1.values.add(values.get(j - 1));
+ j = j + 1;
+ }
+ }
+ this.putTokens(action.getResult(), parameterValue1.values);
+ }
+ }
+
+ public void terminate() {
+ // If there is a current execution, terminate it. Then terminate self.
+ if(this.currentExecution != null) {
+ this.currentExecution.terminate();
+ }
+ super.terminate();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartClassifierBehaviorActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartClassifierBehaviorActionActivation.java
new file mode 100644
index 00000000000..6b362fb11cc
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartClassifierBehaviorActionActivation.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.StartClassifierBehaviorAction;
+
+public class StartClassifierBehaviorActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the value on the object input pin. If it is not a reference, then
+ // do nothing.
+ // Start the classifier behavior of the referent object for the
+ // classifier given as the type of the object input pin.
+ // If the object input pin has no type, then start the classifier
+ // behaviors of all types of the referent object. [The required behavior
+ // in this case is not clear from the spec.]
+ StartClassifierBehaviorAction action = (StartClassifierBehaviorAction)(this.node);
+ Value object = this.takeTokens(action.getObject()).get(0);
+ if(object instanceof Reference) {
+ ((Reference)object).startBehavior((Class)(action.getObject().getType()), new ArrayList<ParameterValue>());
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartObjectBehaviorActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartObjectBehaviorActionActivation.java
new file mode 100644
index 00000000000..750d241e74a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/CompleteActions/StartObjectBehaviorActionActivation.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.InvocationActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
+
+public class StartObjectBehaviorActionActivation extends InvocationActionActivation {
+
+ public void doAction() {
+ // Get the value on the object input pin. If it is not a reference, then
+ // do nothing.
+ // Start the behavior of the referent object for the classifier given as
+ // the type of the object input pin, with parameter values taken from
+ // the argument input pins.
+ // If the object input pin has no type, then start the classifier
+ // behaviors of all types of the referent object.
+ StartObjectBehaviorAction action = (StartObjectBehaviorAction)(this.node);
+ Value object = this.takeTokens(action.getObject()).get(0);
+ if(object instanceof Reference) {
+ Class type = (Class)(action.getObject().getType());
+ List<InputPin> argumentPins = action.getArguments();
+ List<ParameterValue> inputs = new ArrayList<ParameterValue>();
+ if(type != null) {
+ Behavior behavior;
+ if(type instanceof Behavior) {
+ behavior = (Behavior)type;
+ } else {
+ behavior = type.getClassifierBehavior();
+ }
+ if(behavior != null) {
+ List<Parameter> parameters = behavior.getOwnedParameters();
+ int pinNumber = 1;
+ int i = 1;
+ while(i <= parameters.size()) {
+ Parameter parameter = parameters.get(i - 1);
+ int j = pinNumber;
+ if(parameter.getDirection() == ParameterDirectionKind.IN_LITERAL | parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ ParameterValue parameterValue = new ParameterValue();
+ parameterValue.parameter = parameter;
+ parameterValue.values = this.takeTokens(argumentPins.get(j - 1));
+ inputs.add(parameterValue);
+ j = j + 1;
+ }
+ pinNumber = j;
+ i = i + 1;
+ }
+ }
+ }
+ ((Reference)object).startBehavior(type, inputs);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/AddStructuralFeatureValueActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/AddStructuralFeatureValueActionActivation.java
new file mode 100644
index 00000000000..c0a7580df04
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/AddStructuralFeatureValueActionActivation.java
@@ -0,0 +1,123 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StructuredValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.UnlimitedNaturalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.uml2.uml.AddStructuralFeatureValueAction;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class AddStructuralFeatureValueActionActivation extends WriteStructuralFeatureActionActivation {
+
+ public void doAction() {
+ // Get the values of the object and value input pins.
+ // If the given feature is an association end, then create a link
+ // between the object and value inputs.
+ // Otherwise, if the object input is a structural value, then add a
+ // value to the values for the feature.
+ // If isReplaceAll is true, first remove all current matching links or
+ // feature values.
+ // If isReplaceAll is false and there is an insertAt pin, insert the
+ // value at the appropriate position.
+ AddStructuralFeatureValueAction action = (AddStructuralFeatureValueAction)(this.node);
+ StructuralFeature feature = action.getStructuralFeature();
+ Association association = this.getAssociation(feature);
+ Value value = this.takeTokens(action.getObject()).get(0);
+ List<Value> inputValues = this.takeTokens(action.getValue());
+ // NOTE: Multiplicity of the value input pin is required to be 1..1.
+ Value inputValue = inputValues.get(0);
+ int insertAt = 0;
+ if(action.getInsertAt() != null) {
+ insertAt = ((UnlimitedNaturalValue)this.takeTokens(action.getInsertAt()).get(0)).value;
+ }
+ if(association != null) {
+ List<Link> links = this.getMatchingLinks(association, feature, value);
+ Property oppositeEnd = this.getOppositeEnd(association, feature);
+ int position = 0;
+ if(oppositeEnd.isOrdered()) {
+ position = this.getMatchingLinks(association, oppositeEnd, inputValue).size() + 1;
+ }
+ if(action.isReplaceAll()) {
+ for(int i = 0; i < links.size(); i++) {
+ Link link = links.get(i);
+ link.destroy();
+ }
+ } else if(feature.isUnique()) {
+ int i = 1;
+ boolean destroyed = false;
+ while(!destroyed & i <= links.size()) {
+ Link link = links.get(i - 1);
+ FeatureValue featureValue = link.getFeatureValue(feature);
+ if(featureValue.values.get(0).equals(inputValue)) {
+ position = link.getFeatureValue(oppositeEnd).position;
+ link.destroy();
+ destroyed = true;
+ }
+ i = i + 1;
+ }
+ }
+ Link newLink = new Link();
+ newLink.type = association;
+ newLink.setFeatureValue(feature, inputValues, insertAt);
+ List<Value> oppositeValues = new ArrayList<Value>();
+ oppositeValues.add(value);
+ newLink.setFeatureValue(oppositeEnd, oppositeValues, position);
+ newLink.addTo(this.getExecutionLocus());
+ } else if(value instanceof StructuredValue) {
+ // If the value is a data value, then it must be copied before
+ // any change is made.
+ if(!(value instanceof Reference)) {
+ value = value.copy();
+ }
+ StructuredValue structuredValue = (StructuredValue)value;
+ if(action.isReplaceAll()) {
+ structuredValue.setFeatureValue(feature, inputValues, 0);
+ } else {
+ FeatureValue featureValue = structuredValue.getFeatureValue(feature);
+ if(featureValue.values.size() > 0 & insertAt == 0) {
+ // *** If there is no insertAt pin, then the structural
+ // feature must be unordered, and the insertion position is
+ // immaterial. ***
+ insertAt = ((ChoiceStrategy)this.getExecutionLocus().factory.getStrategy("choice")).choose(featureValue.values.size());
+ }
+ if(feature.isUnique()) {
+ // Remove any existing value that duplicates the input value
+ int j = position(inputValue, featureValue.values, 1);
+ if(j > 0) {
+ featureValue.values.remove(j - 1);
+ }
+ }
+ if(insertAt <= 0) { // Note: insertAt = -1 indicates an
+ // unlimited value of "*"
+ featureValue.values.add(inputValue);
+ } else {
+ featureValue.values.add(insertAt - 1, inputValue);
+ }
+ }
+ }
+ if(action.getResult() != null) {
+ this.putToken(action.getResult(), value);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearAssociationActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearAssociationActionActivation.java
new file mode 100644
index 00000000000..f5e9a3dbff4
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearAssociationActionActivation.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.ClearAssociationAction;
+
+public class ClearAssociationActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the extent, at the current execution locus, of the given
+ // association.
+ // Read the object input pin. Destroy all links in which the object
+ // participates.
+ ClearAssociationAction action = (ClearAssociationAction)(this.node);
+ List<ExtensionalValue> extent = this.getExecutionLocus().getExtent(action.getAssociation());
+ Value objectValue = this.takeTokens(action.getObject()).get(0);
+ for(int i = 0; i < extent.size(); i++) {
+ Link link = (Link)(extent.get(i));
+ if(this.valueParticipatesInLink(objectValue, link)) {
+ link.destroy();
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearStructuralFeatureActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearStructuralFeatureActionActivation.java
new file mode 100644
index 00000000000..cc5d4495fdb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ClearStructuralFeatureActionActivation.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StructuredValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.ClearStructuralFeatureAction;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class ClearStructuralFeatureActionActivation extends StructuralFeatureActionActivation {
+
+ public void doAction() {
+ // Get the value of the object input pin.
+ // If the given feature is an association end, then
+ // destroy all links that have the object input on the opposite end.
+ // Otherwise, if the object input is a structured value, then
+ // set the appropriate feature of the input value to be empty.
+ ClearStructuralFeatureAction action = (ClearStructuralFeatureAction)(this.node);
+ StructuralFeature feature = action.getStructuralFeature();
+ Association association = this.getAssociation(feature);
+ Value value = this.takeTokens(action.getObject()).get(0);
+ if(association != null) {
+ List<Link> links = this.getMatchingLinks(association, feature, value);
+ for(int i = 0; i < links.size(); i++) {
+ Link link = links.get(i);
+ link.destroy();
+ }
+ } else if(value instanceof StructuredValue) {
+ // If the value is a data value, then it must be copied before
+ // any change is made.
+ if(!(value instanceof Reference)) {
+ value = value.copy();
+ }
+ ((StructuredValue)value).setFeatureValue(action.getStructuralFeature(), new ArrayList<Value>(), 0);
+ }
+ if(action.getResult() != null) {
+ this.putToken(action.getResult(), value);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateLinkActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateLinkActionActivation.java
new file mode 100644
index 00000000000..87ccf1d0ebc
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateLinkActionActivation.java
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.UnlimitedNaturalValue;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.CreateLinkAction;
+import org.eclipse.uml2.uml.LinkEndCreationData;
+import org.eclipse.uml2.uml.LinkEndData;
+
+public class CreateLinkActionActivation extends WriteLinkActionActivation {
+
+ public void doAction() {
+ // If the association has any unique ends, then destroy an existing link
+ // that matches all ends of the link being created.
+ // Get the extent at the current execution locus of the association for
+ // which a link is being created.
+ // Destroy all links that have a value for any end for which
+ // isReplaceAll is true.
+ // Create a new link for the association, at the current locus, with the
+ // given end data values,
+ // inserted at the given insertAt position (for ordered ends).
+ CreateLinkAction action = (CreateLinkAction)(this.node);
+ List<LinkEndCreationData> endDataList = new ArrayList<LinkEndCreationData>();
+ for(LinkEndData data : action.getEndData()) {
+ endDataList.add((LinkEndCreationData)data);
+ }
+ Association linkAssociation = this.getAssociation();
+ List<ExtensionalValue> extent = this.getExecutionLocus().getExtent(linkAssociation);
+ boolean unique = false;
+ for(int i = 0; i < endDataList.size(); i++) {
+ if(endDataList.get(i).getEnd().isUnique()) {
+ unique = true;
+ }
+ }
+ for(int i = 0; i < extent.size(); i++) {
+ ExtensionalValue value = extent.get(i);
+ Link link = (Link)value;
+ boolean match = true;
+ boolean destroy = false;
+ int j = 1;
+ while(j <= endDataList.size()) {
+ LinkEndCreationData endData = endDataList.get(j - 1);
+ if(this.endMatchesEndData(link, endData)) {
+ if(endData.isReplaceAll()) {
+ destroy = true;
+ }
+ } else {
+ match = false;
+ }
+ j = j + 1;
+ }
+ if(destroy | unique & match) {
+ link.destroy();
+ }
+ }
+ Link newLink = new Link();
+ newLink.type = linkAssociation;
+ for(int i = 0; i < endDataList.size(); i++) {
+ LinkEndCreationData endData = endDataList.get(i);
+ int insertAt = 0;
+ if(endData.getInsertAt() != null) {
+ insertAt = ((UnlimitedNaturalValue)(this.takeTokens(endData.getInsertAt()).get(0))).value;
+ }
+ newLink.setFeatureValue(endData.getEnd(), this.takeTokens(endData.getValue()), insertAt);
+ }
+ newLink.addTo(this.getExecutionLocus());
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateObjectActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateObjectActionActivation.java
new file mode 100644
index 00000000000..1ae6eb53f76
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/CreateObjectActionActivation.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.CreateObjectAction;
+
+public class CreateObjectActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Create an object with the given classifier (which must be a class) as
+ // its type, at the same locus as the action activation.
+ // Place a reference to the object on the result pin of the action.
+ CreateObjectAction action = (CreateObjectAction)(this.node);
+ Reference reference = new Reference();
+ reference.referent = this.getExecutionLocus().instantiate((Class)(action.getClassifier()));
+ this.putToken(action.getResult(), reference);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyLinkActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyLinkActionActivation.java
new file mode 100644
index 00000000000..74ea5406bf0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyLinkActionActivation.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.uml2.uml.DestroyLinkAction;
+import org.eclipse.uml2.uml.LinkEndData;
+import org.eclipse.uml2.uml.LinkEndDestructionData;
+import org.eclipse.uml2.uml.Property;
+
+public class DestroyLinkActionActivation extends WriteLinkActionActivation {
+
+ public void doAction() {
+ // Get the extent, at the current execution locus, of the association
+ // for which links are being destroyed.
+ // Destroy all links that match the given link end destruction data.
+ // For unique ends, or non-unique ends for which isDestroyDuplicates is
+ // true, match links with a matching value for that end.
+ // For non-unique, ordered ends for which isDestroyDuplicates is false,
+ // match links with an end value at the given destroyAt position. [Must
+ // a value be given, too, in this case?]
+ // For non-unique, non-ordered ends for which isDestroyDuplicates is
+ // false, pick one matching link (if any) non-deterministically. [The
+ // semantics of this case is not clear from the current spec.]
+ Debug.println("[doAction] DestroyLinkAction...");
+ DestroyLinkAction action = (DestroyLinkAction)(this.node);
+ List<LinkEndDestructionData> destructionDataList = new ArrayList<LinkEndDestructionData>();
+ for(LinkEndData data : action.getEndData()) {
+ destructionDataList.add((LinkEndDestructionData)data);
+ }
+ Debug.println("[doAction] end data size = " + destructionDataList.size());
+ boolean destroyOnlyOne = false;
+ int j = 1;
+ while(!destroyOnlyOne & j <= destructionDataList.size()) {
+ LinkEndDestructionData endData = destructionDataList.get(j - 1);
+ destroyOnlyOne = !endData.getEnd().isUnique() & !endData.getEnd().isOrdered() & !endData.isDestroyDuplicates();
+ j = j + 1;
+ }
+ List<LinkEndData> endDataList = new ArrayList<LinkEndData>();
+ for(int i = 0; i < destructionDataList.size(); i++) {
+ LinkEndDestructionData endData = destructionDataList.get(i);
+ Debug.println("[doAction] Matching end = " + endData.getEnd().getName());
+ endDataList.add(endData);
+ }
+ List<ExtensionalValue> extent = this.getExecutionLocus().getExtent(this.getAssociation());
+ List<ExtensionalValue> matchingLinks = new ArrayList<ExtensionalValue>();
+ for(int i = 0; i < extent.size(); i++) {
+ ExtensionalValue value = extent.get(i);
+ Link link = (Link)value;
+ if(this.linkMatchesEndData(link, endDataList)) {
+ matchingLinks.add(link);
+ }
+ }
+ // Now that matching is done, ensure that all tokens on end data input
+ // pins
+ // are consumed.
+ for(int i = 0; i < destructionDataList.size(); i++) {
+ LinkEndDestructionData endData = destructionDataList.get(i);
+ Property end = endData.getEnd();
+ if(!endData.isDestroyDuplicates() & !end.isUnique() & end.isOrdered()) {
+ this.takeTokens(endData.getDestroyAt());
+ }
+ Debug.println("[doAction] Consuming tokens for end " + end.getName());
+ this.takeTokens(endData.getValue());
+ }
+ if(destroyOnlyOne) {
+ // *** If there is more than one matching link,
+ // non-deterministically choose one. ***
+ if(matchingLinks.size() > 0) {
+ int i = ((ChoiceStrategy)this.getExecutionLocus().factory.getStrategy("choice")).choose(matchingLinks.size());
+ matchingLinks.get(i - 1).destroy();
+ }
+ } else {
+ for(int i = 0; i < matchingLinks.size(); i++) {
+ ExtensionalValue matchingLink = matchingLinks.get(i);
+ matchingLink.destroy();
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyObjectActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyObjectActionActivation.java
new file mode 100644
index 00000000000..447ab45d7ea
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/DestroyObjectActionActivation.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.DestroyObjectAction;
+import org.eclipse.uml2.uml.Property;
+
+public class DestroyObjectActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the value on the target input pin.
+ // If the value is not a reference, then the action has no effect.
+ // Otherwise, do the following.
+ // If isDestroyLinks is true, destroy all links in which the referent
+ // participates.
+ // If isDestroyOwnedObjects is true, destroy all objects owned by the
+ // referent via composition links.
+ // Destroy the referent object.
+ DestroyObjectAction action = (DestroyObjectAction)(this.node);
+ Value value = this.takeTokens(action.getTarget()).get(0);
+ this.destroyObject(value, action.isDestroyLinks(), action.isDestroyOwnedObjects());
+ }
+
+ public void destroyObject(Value value, Boolean isDestroyLinks, Boolean isDestroyOwnedObjects) {
+ // If the given value is a reference, then destroy the referenced
+ // object, per the given destroy action attribute values.
+ // Debug.println("[destroyObject] object = " + value.objectId());
+ if(value instanceof Reference) {
+ Reference reference = (Reference)value;
+ if(isDestroyLinks | isDestroyOwnedObjects) {
+ Debug.println("[destroyObject] Destroying links...");
+ List<ExtensionalValue> extensionalValues = this.getExecutionLocus().extensionalValues;
+ for(int i = 0; i < extensionalValues.size(); i++) {
+ ExtensionalValue extensionalValue = extensionalValues.get(i);
+ if(extensionalValue instanceof Link) {
+ Link link = (Link)extensionalValue;
+ if(this.valueParticipatesInLink(reference, link)) {
+ if(isDestroyLinks | this.objectIsComposite(reference, link)) {
+ // Debug.println("[destroyObject] Destroying link "
+ // + link.objectId());
+ link.destroy();
+ }
+ }
+ }
+ }
+ }
+ if(isDestroyOwnedObjects) {
+ Debug.println("[destroyObject] Destroying owned objects...");
+ List<FeatureValue> objectFeatureValues = reference.getFeatureValues();
+ for(int i = 0; i < objectFeatureValues.size(); i++) {
+ FeatureValue featureValue = objectFeatureValues.get(i);
+ if(((Property)featureValue.feature).getAggregation() == AggregationKind.COMPOSITE_LITERAL) {
+ List<Value> values = featureValue.values;
+ for(int j = 0; j < values.size(); j++) {
+ Value ownedValue = values.get(j);
+ this.destroyObject(ownedValue, isDestroyLinks, isDestroyOwnedObjects);
+ }
+ }
+ }
+ }
+ reference.destroy();
+ }
+ }
+
+ public Boolean objectIsComposite(Reference reference, Link link) {
+ // Test whether the given reference participates in the given link as a
+ // composite.
+ List<FeatureValue> linkFeatureValues = link.getFeatureValues();
+ boolean isComposite = false;
+ int i = 1;
+ while(!isComposite & i <= linkFeatureValues.size()) {
+ FeatureValue featureValue = linkFeatureValues.get(i - 1);
+ if(!featureValue.values.get(0).equals(reference) & ((Property)featureValue.feature).getAggregation() == AggregationKind.COMPOSITE_LITERAL) {
+ isComposite = true;
+ }
+ i = i + 1;
+ }
+ return isComposite;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/LinkActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/LinkActionActivation.java
new file mode 100644
index 00000000000..76c21d9b291
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/LinkActionActivation.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.UnlimitedNaturalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.LinkAction;
+import org.eclipse.uml2.uml.LinkEndData;
+import org.eclipse.uml2.uml.LinkEndDestructionData;
+import org.eclipse.uml2.uml.Property;
+
+public abstract class LinkActionActivation extends ActionActivation {
+
+ public Boolean linkMatchesEndData(Link link, List<LinkEndData> endDataList) {
+ // Test whether the given link matches the given end data.
+ boolean matches = true;
+ int i = 1;
+ while(matches & i <= endDataList.size()) {
+ matches = this.endMatchesEndData(link, endDataList.get(i - 1));
+ i = i + 1;
+ }
+ return matches;
+ }
+
+ public Boolean endMatchesEndData(Link link, LinkEndData endData) {
+ // Test whether the appropriate end of the given link matches the given
+ // end data.
+ boolean matches = false;
+ if(endData.getValue() == null) {
+ matches = true;
+ } else {
+ Property end = endData.getEnd();
+ FeatureValue linkFeatureValue = link.getFeatureValue(end);
+ Value endValue = this.getTokens(endData.getValue()).get(0);
+ if(endData instanceof LinkEndDestructionData) {
+ if(!((LinkEndDestructionData)endData).isDestroyDuplicates() & !end.isUnique() & end.isOrdered()) {
+ int destroyAt = ((UnlimitedNaturalValue)(this.getTokens(((LinkEndDestructionData)endData).getDestroyAt()).get(0))).value;
+ matches = linkFeatureValue.values.get(0).equals(endValue) && linkFeatureValue.position == destroyAt;
+ } else {
+ matches = linkFeatureValue.values.get(0).equals(endValue);
+ }
+ } else {
+ matches = linkFeatureValue.values.get(0).equals(endValue);
+ }
+ }
+ return matches;
+ }
+
+ public Association getAssociation() {
+ // Get the association for the link action of this activation.
+ return (Association)(((LinkAction)(this.node)).getEndData().get(0).getEnd().getAssociation());
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadLinkActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadLinkActionActivation.java
new file mode 100644
index 00000000000..ec446580068
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadLinkActionActivation.java
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.uml2.uml.LinkEndData;
+import org.eclipse.uml2.uml.ReadLinkAction;
+
+public class ReadLinkActionActivation extends LinkActionActivation {
+
+ public void doAction() {
+ // Get the extent, at the current execution locus, of the association to
+ // which the action applies.
+ // For all links that match the link end data, place the value of the
+ // remaining "open" end on the result pin.
+ ReadLinkAction action = (ReadLinkAction)(this.node);
+ List<LinkEndData> endDataList = action.getEndData();
+ LinkEndData openEnd = null;
+ int i = 1;
+ while((openEnd == null) & i <= endDataList.size()) {
+ if(endDataList.get(i - 1).getValue() == null) {
+ openEnd = endDataList.get(i - 1);
+ }
+ i = i + 1;
+ }
+ List<ExtensionalValue> extent = this.getExecutionLocus().getExtent(this.getAssociation());
+ List<FeatureValue> featureValues = new ArrayList<FeatureValue>();
+ for(int j = 0; j < extent.size(); j++) {
+ ExtensionalValue value = extent.get(j);
+ Link link = (Link)value;
+ if(this.linkMatchesEndData(link, endDataList)) {
+ FeatureValue featureValue = link.getFeatureValue(openEnd.getEnd());
+ if(!openEnd.getEnd().isOrdered() | featureValues.size() == 0) {
+ featureValues.add(featureValue);
+ } else {
+ int n = featureValue.position;
+ boolean continueSearching = true;
+ int k = 0;
+ while(continueSearching & k < featureValues.size()) {
+ k = k + 1;
+ continueSearching = featureValues.get(k - 1).position < n;
+ }
+ if(continueSearching) {
+ featureValues.add(featureValue);
+ } else {
+ featureValues.add(k - 1, featureValue);
+ }
+ }
+ }
+ }
+ for(int j = 0; j < featureValues.size(); j++) {
+ FeatureValue featureValue = featureValues.get(j);
+ this.putToken(action.getResult(), featureValue.values.get(0));
+ }
+ // Now that matching is done, ensure that all tokens on end data input
+ // pins
+ // are consumed.
+ for(int k = 0; k < endDataList.size(); k++) {
+ LinkEndData endData = endDataList.get(k);
+ if(endData.getValue() != null) {
+ this.takeTokens(endData.getValue());
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadSelfActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadSelfActionActivation.java
new file mode 100644
index 00000000000..6d1ca769e17
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadSelfActionActivation.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.ReadSelfAction;
+
+public class ReadSelfActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the context object of the activity execution containing this
+ // action activation and place a reference to it on the result output
+ // pin.
+ // Debug.println("[ReadSelfActionActivation] Start...");
+ Reference context = new Reference();
+ context.referent = this.getExecutionContext();
+ // Debug.println("[ReadSelfActionActivation] context object = " +
+ // context.referent);
+ OutputPin resultPin = ((ReadSelfAction)(this.node)).getResult();
+ this.putToken(resultPin, context);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadStructuralFeatureActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadStructuralFeatureActionActivation.java
new file mode 100644
index 00000000000..0fe5c25a91b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ReadStructuralFeatureActionActivation.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StructuredValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class ReadStructuralFeatureActionActivation extends StructuralFeatureActionActivation {
+
+ public void doAction() {
+ // Get the value of the object input pin.
+ // If the given feature is an association end, then get all values of
+ // the that end.
+ // for which the opposite end has the object input value and place them
+ // on the result pin.
+ // Otherwise, if the object input value is a structural value, then get
+ // the values
+ // of the appropriate feature of the input value and place them on the
+ // result output pin.
+ ReadStructuralFeatureAction action = (ReadStructuralFeatureAction)(this.node);
+ StructuralFeature feature = action.getStructuralFeature();
+ Association association = this.getAssociation(feature);
+ Value value = this.takeTokens(action.getObject()).get(0);
+ List<Value> resultValues = new ArrayList<Value>();
+ if(association != null) {
+ List<Link> links = this.getMatchingLinks(association, feature, value);
+ for(int i = 0; i < links.size(); i++) {
+ Link link = links.get(i);
+ resultValues.add(link.getFeatureValue(feature).values.get(0));
+ }
+ } else if(value instanceof StructuredValue) {
+ // Debug.println("[ReadStructuralFeatureActionActivation] value = "
+ // + value +", structural feature = " + feature.name);
+ resultValues = ((StructuredValue)value).getFeatureValue(feature).values;
+ }
+ this.putTokens(action.getResult(), resultValues);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/RemoveStructuralFeatureValueActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/RemoveStructuralFeatureValueActionActivation.java
new file mode 100644
index 00000000000..96dbc0c031e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/RemoveStructuralFeatureValueActionActivation.java
@@ -0,0 +1,119 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.FeatureValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StructuredValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.UnlimitedNaturalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.RemoveStructuralFeatureValueAction;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class RemoveStructuralFeatureValueActionActivation extends WriteStructuralFeatureActionActivation {
+
+ public void doAction() {
+ // Get the values of the object and value input pins.
+ // If the given feature is an association end, then destroy any matching
+ // links.
+ // Otherwise, if the object input is a structural value, remove values
+ // from the given feature.
+ // If isRemoveDuplicates is true, then destroy all current matching
+ // links or remove all values equal to the input value.
+ // If isRemoveDuplicates is false and there is no removeAt input pin,
+ // remove any one feature value equal to the input value (if there are
+ // any that are equal).
+ // If isRemoveDuplicates is false, and there is a removeAt input pin
+ // remove the feature value at that position.
+ RemoveStructuralFeatureValueAction action = (RemoveStructuralFeatureValueAction)(this.node);
+ StructuralFeature feature = action.getStructuralFeature();
+ Association association = this.getAssociation(feature);
+ Value value = this.takeTokens(action.getObject()).get(0);
+ Value inputValue = null;
+ if(action.getValue() != null) {
+ // NOTE: Multiplicity of the value input pin is required to be 1..1.
+ inputValue = this.takeTokens(action.getValue()).get(0);
+ }
+ int removeAt = 0;
+ if(action.getRemoveAt() != null) {
+ removeAt = ((UnlimitedNaturalValue)this.takeTokens(action.getRemoveAt()).get(0)).value;
+ }
+ if(association != null) {
+ List<Link> links = this.getMatchingLinks(association, feature, value);
+ if(action.isRemoveDuplicates()) {
+ for(int i = 0; i < links.size(); i++) {
+ Link link = links.get(i);
+ link.destroy();
+ }
+ } else if(action.getRemoveAt() == null) {
+ // *** If there is more than one matching link,
+ // non-deterministically choose one. ***
+ if(links.size() > 0) {
+ int i = ((ChoiceStrategy)this.getExecutionLocus().factory.getStrategy("choice")).choose(links.size());
+ links.get(i - 1).destroy();
+ }
+ } else {
+ boolean notFound = true;
+ int i = 1;
+ while(notFound & i < links.size()) {
+ Link link = links.get(i - 1);
+ if(link.getFeatureValue(feature).position == removeAt) {
+ notFound = false;
+ link.destroy();
+ }
+ }
+ }
+ } else if(value instanceof StructuredValue) {
+ // If the value is a data value, then it must be copied before
+ // any change is made.
+ if(!(value instanceof Reference)) {
+ value = value.copy();
+ }
+ FeatureValue featureValue = ((StructuredValue)value).getFeatureValue(action.getStructuralFeature());
+ if(action.isRemoveDuplicates()) {
+ int j = this.position(inputValue, featureValue.values, 1);
+ while(j > 0) {
+ featureValue.values.remove(j - 1);
+ j = this.position(inputValue, featureValue.values, j);
+ }
+ } else if(action.getRemoveAt() == null) {
+ List<Integer> positions = new ArrayList<Integer>();
+ int j = this.position(inputValue, featureValue.values, 1);
+ while(j > 0) {
+ positions.add(j);
+ j = this.position(inputValue, featureValue.values, j);
+ }
+ if(positions.size() > 0) {
+ // *** Nondeterministically choose which value to remove.
+ // ***
+ int k = ((ChoiceStrategy)this.getExecutionLocus().factory.getStrategy("choice")).choose(positions.size());
+ featureValue.values.remove(positions.get(k - 1) - 1);
+ }
+ } else {
+ if(featureValue.values.size() >= removeAt) {
+ featureValue.values.remove(removeAt - 1);
+ }
+ }
+ }
+ if(action.getResult() != null) {
+ this.putToken(action.getResult(), value);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/StructuralFeatureActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/StructuralFeatureActionActivation.java
new file mode 100644
index 00000000000..9922b44c7a6
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/StructuralFeatureActionActivation.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Link;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public abstract class StructuralFeatureActionActivation extends ActionActivation {
+
+ public Association getAssociation(StructuralFeature feature) {
+ // If the structural feature for the action of this activation is an
+ // association end,
+ // then get the associated association.
+ Association association = null;
+ if(feature instanceof Property) {
+ association = ((Property)feature).getAssociation();
+ }
+ return association;
+ }
+
+ public List<Link> getMatchingLinks(Association association, StructuralFeature end, Value oppositeValue) {
+ // Get the links of the given binary association whose end opposite
+ // to the given end has the given value
+ Property oppositeEnd = this.getOppositeEnd(association, end);
+ List<ExtensionalValue> extent = this.getExecutionLocus().getExtent(association);
+ List<Link> links = new ArrayList<Link>();
+ for(int i = 0; i < extent.size(); i++) {
+ ExtensionalValue link = extent.get(i);
+ if(link.getFeatureValue(oppositeEnd).values.get(0).equals(oppositeValue)) {
+ if(!end.isOrdered() | links.size() == 0) {
+ links.add((Link)link);
+ } else {
+ int n = link.getFeatureValue(end).position;
+ boolean continueSearching = true;
+ int j = 0;
+ while(continueSearching & j < links.size()) {
+ j = j + 1;
+ continueSearching = links.get(j - 1).getFeatureValue(end).position < n;
+ }
+ if(continueSearching) {
+ links.add((Link)link);
+ } else {
+ links.add(j - 1, (Link)link);
+ }
+ }
+ }
+ }
+ return links;
+ }
+
+ public Property getOppositeEnd(Association association, StructuralFeature end) {
+ // Get the end of a binary association opposite to the given end.
+ Property oppositeEnd = association.getMemberEnds().get(0);
+ if(oppositeEnd == end) {
+ oppositeEnd = association.getMemberEnds().get(1);
+ }
+ return oppositeEnd;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/TestIdentityActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/TestIdentityActionActivation.java
new file mode 100644
index 00000000000..6f4588b6317
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/TestIdentityActionActivation.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.TestIdentityAction;
+
+public class TestIdentityActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Get the values from the first and second input pins and test if they
+ // are equal. (Note the equality of references is defined to be that
+ // they have identical referents.)
+ // If they are equal, place true on the pin execution for the result
+ // output pin, otherwise place false.
+ TestIdentityAction action = (TestIdentityAction)(this.node);
+ Value firstValue = this.takeTokens(action.getFirst()).get(0);
+ Value secondValue = this.takeTokens(action.getSecond()).get(0);
+ Value testResult = this.makeBooleanValue(firstValue.equals(secondValue));
+ this.putToken(action.getResult(), testResult);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ValueSpecificationActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ValueSpecificationActionActivation.java
new file mode 100644
index 00000000000..5d736529b21
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/ValueSpecificationActionActivation.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.ValueSpecificationAction;
+
+public class ValueSpecificationActionActivation extends ActionActivation {
+
+ public void doAction() {
+ // Evaluate the value specification for the action and place the result
+ // on the result pin of the action.
+ ValueSpecificationAction action = (ValueSpecificationAction)(this.node);
+ Value value = this.getExecutionLocus().executor.evaluate(action.getValue());
+ this.putToken(action.getResult(), value);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteLinkActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteLinkActionActivation.java
new file mode 100644
index 00000000000..88db8285f54
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteLinkActionActivation.java
@@ -0,0 +1,17 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+public abstract class WriteLinkActionActivation extends LinkActionActivation {
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteStructuralFeatureActionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteStructuralFeatureActionActivation.java
new file mode 100644
index 00000000000..e367e1c9755
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Actions/IntermediateActions/WriteStructuralFeatureActionActivation.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public abstract class WriteStructuralFeatureActionActivation extends StructuralFeatureActionActivation {
+
+ public Integer position(Value value, List<Value> list, Integer startAt) {
+ // Return the position (counting from 1) of the first occurance of the
+ // given value in the given list at or after the starting index, or 0 if
+ // it is not found.
+ boolean found = false;
+ int i = startAt;
+ while(!found & i <= list.size()) {
+ found = list.get(i - 1).equals(value);
+ i = i + 1;
+ }
+ if(!found) {
+ i = 1;
+ }
+ return i - 1;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ClauseActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ClauseActivation.java
new file mode 100644
index 00000000000..66f072092d0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ClauseActivation.java
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.BooleanValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Clause;
+
+public class ClauseActivation {
+
+ /*
+ * The activation of the conditional node that contains the clause for this
+ * clause activation.
+ */
+ public ConditionalNodeActivation conditionalNodeActivation;
+
+ public Clause clause;
+
+ public void receiveControl() {
+ // If all predecessors to the clause for this activation have run their
+ // tests and failed, then run the test for this clause.
+ // If the test succeeds, then terminate any other clauses that may be
+ // running and run the body of this clause.
+ // If the test fails, then pass control to successor clauses.
+ Debug.println("[receiveControl] clauseActivation = " + this);
+ if(this.isReady()) {
+ Debug.println("[receiveControl] Running test...");
+ this.runTest();
+ BooleanValue decision = this.getDecision();
+ // Note that the decision may be null if the test was terminated
+ // before completion.
+ if(decision != null) {
+ if(decision.value == true) {
+ Debug.println("[receiveControl] Test succeeded.");
+ this.selectBody();
+ } else {
+ Debug.println("[receiveControl] Test failed.");
+ List<ClauseActivation> successors = this.getSuccessors();
+ // *** Give control to all successors concurrently. ***
+ for(Iterator<ClauseActivation> i = successors.iterator(); i.hasNext();) {
+ ClauseActivation successor = i.next();
+ successor.receiveControl();
+ }
+ }
+ }
+ }
+ }
+
+ public Boolean isReady() {
+ // Test if all predecessors to this clause activation have failed.
+ List<ClauseActivation> predecessors = this.getPredecessors();
+ boolean ready = true;
+ int i = 1;
+ while(ready & i <= predecessors.size()) {
+ ClauseActivation predecessor = predecessors.get(i - 1);
+ BooleanValue decisionValue = predecessor.getDecision();
+ // Note that the decision will be null if the predecessor clause has
+ // not run yet.
+ if(decisionValue == null) {
+ ready = false;
+ } else {
+ ready = !decisionValue.value;
+ }
+ i = i + 1;
+ }
+ return ready;
+ }
+
+ public void runTest() {
+ // Run the test of the clause for this clause activation.
+ this.conditionalNodeActivation.runTest(this.clause);
+ }
+
+ public void selectBody() {
+ // Select the body of the clause for this clause activation.
+ this.conditionalNodeActivation.selectBody(this.clause);
+ }
+
+ public BooleanValue getDecision() {
+ // Get the value (if any) on the decider pin of the clause for this
+ // clause activation.
+ List<Value> deciderValues = this.conditionalNodeActivation.getPinValues(this.clause.getDecider());
+ BooleanValue deciderValue = null;
+ if(deciderValues.size() > 0) {
+ deciderValue = (BooleanValue)(deciderValues.get(0));
+ }
+ return deciderValue;
+ }
+
+ public List<ClauseActivation> getPredecessors() {
+ // Return the clause activations for the predecessors of the clause for
+ // this clause activation.
+ List<ClauseActivation> predecessors = new ArrayList<ClauseActivation>();
+ List<Clause> predecessorClauses = this.clause.getPredecessorClauses();
+ for(int i = 0; i < predecessorClauses.size(); i++) {
+ Clause predecessorClause = predecessorClauses.get(i);
+ predecessors.add(this.conditionalNodeActivation.getClauseActivation(predecessorClause));
+ }
+ return predecessors;
+ }
+
+ public List<ClauseActivation> getSuccessors() {
+ // Return the clause activations for the successors of the clause for
+ // this clause activation.
+ List<ClauseActivation> successors = new ArrayList<ClauseActivation>();
+ List<Clause> successorClauses = this.clause.getSuccessorClauses();
+ for(int i = 0; i < successorClauses.size(); i++) {
+ Clause successorClause = successorClauses.get(i);
+ successors.add(this.conditionalNodeActivation.getClauseActivation(successorClause));
+ }
+ return successors;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ConditionalNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ConditionalNodeActivation.java
new file mode 100644
index 00000000000..f02a3905f10
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/ConditionalNodeActivation.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.uml2.uml.Clause;
+import org.eclipse.uml2.uml.ConditionalNode;
+import org.eclipse.uml2.uml.ExecutableNode;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Pin;
+
+public class ConditionalNodeActivation extends StructuredActivityNodeActivation {
+
+ /*
+ * The activations for each clause in the conditional node for this node
+ * activation.
+ */
+ public List<ClauseActivation> clauseActivations = new ArrayList<ClauseActivation>();
+
+ /*
+ * The set of clauses which meet the conditions to have their bodies
+ * activated.
+ */
+ public List<Clause> selectedClauses = new ArrayList<Clause>();
+
+ /*
+ * The clause chosen from the set of selectedClauses to actually be
+ * executed.
+ */
+ public Clause selectedClause;
+
+ public void doStructuredActivity() {
+ // Run all the non-executable, non-pin nodes in the conditional node.
+ // Activate all clauses in the conditional node and pass control to
+ // those that are ready (i.e., have no predecessors).
+ // If one or more clauses have succeeded in being selected, choose one
+ // non-deterministically and run its body, then copy the outputs of that
+ // clause to the output pins of the node.
+ ConditionalNode node = (ConditionalNode)(this.node);
+ List<ActivityNodeActivation> nodeActivations = this.activationGroup.nodeActivations;
+ List<ActivityNodeActivation> nonExecutableNodeActivations = new ArrayList<ActivityNodeActivation>();
+ for(int i = 0; i < nodeActivations.size(); i++) {
+ ActivityNodeActivation nodeActivation = nodeActivations.get(i);
+ if(!(nodeActivation.node instanceof ExecutableNode | nodeActivation.node instanceof Pin)) {
+ nonExecutableNodeActivations.add(nodeActivation);
+ }
+ }
+ this.activationGroup.run(nonExecutableNodeActivations);
+ this.clauseActivations.clear();
+ List<Clause> clauses = node.getClauses();
+ for(int i = 0; i < clauses.size(); i++) {
+ Clause clause = clauses.get(i);
+ ClauseActivation clauseActivation = new ClauseActivation();
+ clauseActivation.clause = clause;
+ clauseActivation.conditionalNodeActivation = this;
+ this.clauseActivations.add(clauseActivation);
+ }
+ this.selectedClauses.clear();
+ List<ClauseActivation> readyClauseActivations = new ArrayList<ClauseActivation>();
+ for(int i = 0; i < this.clauseActivations.size(); i++) {
+ ClauseActivation clauseActivation = this.clauseActivations.get(i);
+ Debug.println("[doStructuredActivity] clauseActivations[" + i + "] = " + clauseActivation);
+ if(clauseActivation.isReady()) {
+ Debug.println("[doStructuredActivity] Clause activation is ready.");
+ readyClauseActivations.add(clauseActivation);
+ }
+ }
+ // *** Give control to all ready clauses concurrently. ***
+ for(Iterator<ClauseActivation> i = readyClauseActivations.iterator(); i.hasNext();) {
+ ClauseActivation clauseActivation = (ClauseActivation)i.next();
+ Debug.println("[doStructuredActivity] Giving control to " + clauseActivation + "...");
+ clauseActivation.receiveControl();
+ }
+ this.selectedClause = null;
+ if(this.selectedClauses.size() > 0 & this.isRunning()) {
+ Debug.println("[doStructuredActivity] " + this.selectedClauses.size() + " clause(s) selected.");
+ // *** If multiple clauses are selected, choose one
+ // non-deterministically. ***
+ int i = ((ChoiceStrategy)this.getExecutionLocus().factory.getStrategy("choice")).choose(this.selectedClauses.size());
+ this.selectedClause = this.selectedClauses.get(i - 1);
+ Debug.println("[doStructuredActivity] Running selectedClauses[" + i + "] = " + this.selectedClause);
+ for(int j = 0; j < clauses.size(); j++) {
+ Clause clause = clauses.get(j);
+ if(clause != selectedClause) {
+ List<ExecutableNode> testNodes = clause.getTests();
+ for(int k = 0; k < testNodes.size(); k++) {
+ ExecutableNode testNode = testNodes.get(k);
+ this.activationGroup.getNodeActivation(testNode).terminate();
+ }
+ }
+ }
+ this.activationGroup.runNodes(this.makeActivityNodeList(this.selectedClause.getBodies()));
+ }
+ }
+
+ public void completeBody() {
+ // Complete the activation of the body of a conditional note by
+ // copying the outputs of the selected clause (if any) to the output
+ // pins of the node and terminating the activation of all nested nodes.
+ if(this.selectedClause != null) {
+ ConditionalNode node = (ConditionalNode)(this.node);
+ List<OutputPin> resultPins = node.getResults();
+ List<OutputPin> bodyOutputPins = this.selectedClause.getBodyOutputs();
+ for(int k = 0; k < resultPins.size(); k++) {
+ OutputPin resultPin = resultPins.get(k);
+ OutputPin bodyOutputPin = bodyOutputPins.get(k);
+ this.putTokens(resultPin, this.getPinValues(bodyOutputPin));
+ }
+ }
+ this.activationGroup.terminateAll();
+ }
+
+ public List<Token> completeAction() {
+ // Only complete the conditional node if it is not suspended.
+ if(!this.isSuspended()) {
+ completeBody();
+ }
+ return super.completeAction();
+ }
+
+ public ClauseActivation getClauseActivation(Clause clause) {
+ // Get the clause activation corresponding to the given clause.
+ // Debug.println("[getClauseActivation] clause = " + clause);
+ ClauseActivation selectedClauseActivation = null;
+ int i = 1;
+ while((selectedClauseActivation == null) & i <= this.clauseActivations.size()) {
+ ClauseActivation clauseActivation = this.clauseActivations.get(i - 1);
+ // Debug.println("[getClauseActivations] clauseActivations[" + i +
+ // "].clause = " + clauseActivation.clause);
+ if(clauseActivation.clause == clause) {
+ selectedClauseActivation = clauseActivation;
+ }
+ i = i + 1;
+ }
+ return selectedClauseActivation;
+ }
+
+ public void runTest(Clause clause) {
+ // Run the test for the given clause.
+ if(this.isRunning()) {
+ this.activationGroup.runNodes(this.makeActivityNodeList(clause.getTests()));
+ }
+ }
+
+ public void selectBody(Clause clause) {
+ // Add the clause to the list of selected clauses.
+ this.selectedClauses.add(clause);
+ }
+
+ public void resume() {
+ // When this conditional node is resumed after being suspended, complete
+ // its body and then resume it as a structured activity node.
+ // [Note that this presumes that accept event actions are not allowed
+ // in the test part of a clause of a conditional node.]
+ completeBody();
+ super.resume();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/LoopNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/LoopNodeActivation.java
new file mode 100644
index 00000000000..00f1a2f0a68
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/LoopNodeActivation.java
@@ -0,0 +1,256 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.OutputPinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.BooleanValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ExecutableNode;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.LoopNode;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Pin;
+
+public class LoopNodeActivation extends StructuredActivityNodeActivation {
+
+ public List<Values> bodyOutputLists = new ArrayList<Values>();
+ public Boolean isTerminateAll;
+
+ public void doStructuredActivity() {
+ // Set the initial values for the body outputs to the values of the loop
+ // variable input pins.
+ // If isTestedFirst is true, then repeatedly run the test part and the
+ // body part of the loop, copying values from the body outputs to the
+ // loop variables.
+ // If isTestedFirst is false, then repeatedly run the body part and the
+ // test part of the loop, copying values from the body outputs to the
+ // loop variables.
+ // When the test fails, copy the values of the body outputs to the loop
+ // outputs.
+ // [Note: The body outputs are used for the loop outputs, rather than
+ // the loop variables, since values on the loop variables may be
+ // consumed when running the test for the last time.]
+ LoopNode loopNode = (LoopNode)(this.node);
+ List<InputPin> loopVariableInputs = loopNode.getLoopVariableInputs();
+
+ this.bodyOutputLists.clear(); // Added
+
+ for(int i = 0; i < loopVariableInputs.size(); i++) {
+ InputPin loopVariableInput = loopVariableInputs.get(i);
+ Values bodyOutputList = new Values();
+ bodyOutputList.values = this.takeTokens(loopVariableInput);
+ this.bodyOutputLists.add(bodyOutputList);
+ }
+ this.isTerminateAll = false;
+ this.doLoop(true);
+ }
+
+ public void doLoop(Boolean continuing) {
+ // If isTestedFirst is true, then repeatedly run the test part and the
+ // body part of the loop, copying values from the body outputs to the
+ // loop variables.
+ // If isTestedFirst is false, then repeatedly run the body part and the
+ // test part of the loop, copying values from the body outputs to the
+ // loop variables.
+ LoopNode loopNode = (LoopNode)(this.node);
+ List<OutputPin> loopVariables = loopNode.getLoopVariables();
+ List<OutputPin> resultPins = this.getResults(); // CHANGED from: loopNode.getResults();
+ while(continuing) {
+ // Set loop variable values
+ this.runLoopVariables();
+ for(int i = 0; i < loopVariables.size(); i++) {
+ OutputPin loopVariable = loopVariables.get(i);
+ Values bodyOutputList = bodyOutputLists.get(i);
+ List<Value> values = bodyOutputList.values;
+ this.putPinValues(loopVariable, values);
+ ((OutputPinActivation)this.activationGroup.getNodeActivation(loopVariable)).sendUnofferedTokens();
+ }
+ // Run all the non-executable, non-pin nodes in the conditional
+ // node.
+ List<ActivityNodeActivation> nodeActivations = this.activationGroup.nodeActivations;
+ List<ActivityNodeActivation> nonExecutableNodeActivations = new ArrayList<ActivityNodeActivation>();
+ for(int i = 0; i < nodeActivations.size(); i++) {
+ ActivityNodeActivation nodeActivation = nodeActivations.get(i);
+ if(!(nodeActivation.node instanceof ExecutableNode | nodeActivation.node instanceof Pin)) {
+ nonExecutableNodeActivations.add(nodeActivation);
+ }
+ }
+ this.activationGroup.run(nonExecutableNodeActivations);
+ // Run the loop
+ if(loopNode.isTestedFirst()) {
+ continuing = this.runTest();
+ if(continuing) {
+ this.runBody();
+ }
+ } else {
+ this.runBody();
+ if(this.isRunning() & !this.isSuspended()) {
+ continuing = this.runTest();
+ }
+ }
+ if(!this.isTerminateAll & this.isRunning() & !this.isSuspended()) {
+ this.activationGroup.terminateAll();
+ } else {
+ continuing = false;
+ }
+ Debug.println("[doStructuredActivity] " + (continuing ? "Continuing." : this.isSuspended() ? "Suspended" : "Done."));
+ }
+ if(!this.isTerminateAll & this.isRunning() & !this.isSuspended()) {
+ for(int i = 0; i < bodyOutputLists.size(); i++) {
+ Values bodyOutputList = bodyOutputLists.get(i);
+ OutputPin resultPin = resultPins.get(i);
+ this.putTokens(resultPin, bodyOutputList.values);
+ }
+ }
+ }
+
+ public Boolean runTest() {
+ // Run the test part of the loop node for this node activation.
+ // Return the value on the decider pin.
+ Debug.println("[runTest] Running test...");
+ LoopNode loopNode = (LoopNode)(this.node);
+ this.activationGroup.runNodes(this.makeActivityNodeList(loopNode.getTests()));
+ List<Value> values = this.getPinValues(loopNode.getDecider());
+ // If there is no decider value, treat it as false.
+ boolean decision = false;
+ if(values.size() > 0) {
+ decision = ((BooleanValue)(values.get(0))).value;
+ }
+ Debug.println("[runTest] " + (decision ? "Test succeeded." : "Test failed."));
+ return decision;
+ }
+
+ public void runBody() {
+ // Run the body part of the loop node for this node activation and save
+ // the body outputs.
+ Debug.println("[runBody] Running body...");
+ LoopNode loopNode = (LoopNode)this.node;
+ this.activationGroup.runNodes(this.makeActivityNodeList(loopNode.getBodyParts()));
+ if(!this.isTerminateAll && !this.isSuspended()) {
+ this.saveBodyOutputs();
+ }
+ }
+
+ public void saveBodyOutputs() {
+ // Save the body outputs for use in the next iteration.
+ LoopNode loopNode = (LoopNode)this.node;
+ List<OutputPin> bodyOutputs = loopNode.getBodyOutputs();
+ List<Values> bodyOutputLists = this.bodyOutputLists;
+ for(int i = 0; i < bodyOutputs.size(); i++) {
+ OutputPin bodyOutput = bodyOutputs.get(i);
+ Values bodyOutputList = bodyOutputLists.get(i);
+ bodyOutputList.values = this.getPinValues(bodyOutput);
+ }
+ }
+
+ public void runLoopVariables() {
+ // Run the loop variable pins of the loop node for this node activation.
+ this.activationGroup.runNodes(this.makeLoopVariableList());
+ }
+
+ public void createNodeActivations() {
+ // In addition to creating activations for contained nodes, create
+ // activations for any loop variables.
+
+ super.createNodeActivations();
+ this.activationGroup.createNodeActivations(this.makeLoopVariableList());
+ }
+
+ public List<ActivityNode> makeLoopVariableList() {
+ // Return an activity node list containing the loop variable pins for
+ // the loop node of this activation.
+ LoopNode loopNode = (LoopNode)(this.node);
+ List<ActivityNode> nodes = new ArrayList<ActivityNode>();
+ List<OutputPin> loopVariables = loopNode.getLoopVariables();
+ for(int i = 0; i < loopVariables.size(); i++) {
+ OutputPin loopVariable = loopVariables.get(i);
+ nodes.add(loopVariable);
+ }
+ return nodes;
+ }
+
+ public void terminateAll() {
+ // Copy the values of the body outputs to the loop outputs, and then
+ // terminate all activations in the loop.
+ this.isTerminateAll = true;
+ LoopNode loopNode = (LoopNode) this.node;
+ List<OutputPin> bodyOutputs = loopNode.getBodyOutputs();
+ List<OutputPin> resultPins = this.getResults();
+ for (int i = 0; i < bodyOutputs.size(); i++) {
+ OutputPin bodyOutput = bodyOutputs.get(i);
+ OutputPin resultPin = resultPins.get(i);
+ this.putTokens(resultPin, this.getPinValues(bodyOutput));
+ }
+ super.terminateAll();
+ }
+
+ public void resume() {
+ // When this loop node is resumed after being suspended, continue with
+ // its next iteration (if any). Once the loop has completed execution
+ // without being suspended again, complete the action.
+ LoopNode loopNode = (LoopNode)(this.node);
+ this.saveBodyOutputs();
+ if (!this.isTerminateAll) {
+ if(loopNode.isMustIsolate()) {
+ _beginIsolation();
+ this.continueLoop();
+ _endIsolation();
+ } else {
+ this.continueLoop();
+ }
+ }
+ if(this.isSuspended()) {
+ // NOTE: If the subsequent iteration of the loop suspends it again,
+ // then it is necessary to remove the previous suspension from the
+ // containing activity node activation group.
+ this.group.resume(this);
+ } else {
+ super.resume();
+ }
+ }
+
+ public void continueLoop() {
+ // Continue the loop node when it is resumed after being suspended. If
+ // isTestedFirst is true, then continue executing the loop. If
+ // isTestedFirst is false, then run the test to determine whether
+ // the loop should be continued or completed.
+ // [Note that this presumes that an accept event action is not allowed
+ // in the test part of a loop node.]
+ LoopNode loopNode = (LoopNode)(this.node);
+ boolean continuing = true;
+ if(!loopNode.isTestedFirst()) {
+ continuing = this.runTest();
+ }
+ if(this.isRunning()) {
+ this.activationGroup.terminateAll();
+ this.doLoop(continuing);
+ }
+ }
+
+ // ADDED:
+ private List<OutputPin> getResults() {
+ LoopNode node = (LoopNode)this.node;
+ List<OutputPin> results = new ArrayList<OutputPin>(node.getResults());
+ List<OutputPin> loopVariables = node.getLoopVariables();
+ results.removeAll(loopVariables);
+ return results;
+ }
+ //
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/StructuredActivityNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/StructuredActivityNodeActivation.java
new file mode 100644
index 00000000000..dcc779150ab
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/StructuredActivityNodeActivation.java
@@ -0,0 +1,211 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.PinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityEdgeInstance;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivationGroup;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ObjectToken;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ExecutableNode;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+
+public class StructuredActivityNodeActivation extends ActionActivation {
+
+ /*
+ * The group of activations of the activity nodes contained in the
+ * structured activity node.
+ */
+ public ActivityNodeActivationGroup activationGroup;
+
+ public void doAction() {
+ // If the structured activity node has mustIsolate=true, then carry out
+ // its behavior with isolation.
+ // Otherwise just activate it normally.
+ if(((StructuredActivityNode)(this.node)).isMustIsolate()) {
+ _beginIsolation();
+ this.doStructuredActivity();
+ _endIsolation();
+ } else {
+ this.doStructuredActivity();
+ }
+ }
+
+ public void doStructuredActivity() {
+ // Run all activations of contained nodes. When this is complete,
+ // return.
+ // (This is the default behavior for a structured activity node used
+ // simply as a group. It is overridden for the execution of conditional
+ // and loop nodes.)
+ Action action = (Action)(this.node);
+ // *** Concurrently send offers from all input pins. ***
+ List<InputPin> inputPins = getInputs(action); // CHANGED from: action.getInputs();
+ for(Iterator<InputPin> i = inputPins.iterator(); i.hasNext();) {
+ InputPin inputPin = i.next();
+ PinActivation pinActivation = this.getPinActivation(inputPin);
+ pinActivation.sendUnofferedTokens();
+ }
+ this.activationGroup.run(this.activationGroup.nodeActivations);
+ }
+
+ public void terminate() {
+ // Terminate the execution of all contained node activations (which
+ // completes the performance of the structured activity node
+ // activation), and then terminate this node itself.
+ this.terminateAll();
+ super.terminate();
+ }
+
+ public ActivityNodeActivation getNodeActivation(ActivityNode node) {
+ // If this structured activity node activation is not for the given
+ // node, then check if there is an activation for the node in the
+ // activation group.
+ ActivityNodeActivation thisActivation = super.getNodeActivation(node);
+ ActivityNodeActivation activation = null;
+ if(thisActivation != null) {
+ activation = thisActivation;
+ } else if(this.activationGroup != null) {
+ activation = this.activationGroup.getNodeActivation(node);
+ }
+ return activation;
+ }
+
+ public List<ActivityNode> makeActivityNodeList(List<ExecutableNode> nodes) {
+ // Return an activity node list containing the given list of executable
+ // nodes
+ // and any pins that they own.
+ List<ActivityNode> activityNodes = new ArrayList<ActivityNode>();
+ for(int i = 0; i < nodes.size(); i++) {
+ ActivityNode node = nodes.get(i);
+ activityNodes.add(node);
+ if(node instanceof Action) {
+ Action action = (Action)node;
+ List<InputPin> inputPins = getInputs(action); // CHANGED from: action.getInputs();
+ for(int j = 0; j < inputPins.size(); j++) {
+ InputPin inputPin = inputPins.get(j);
+ activityNodes.add(inputPin);
+ }
+ List<OutputPin> outputPins = getOutputs(action); // CHANGED from: action.getOutputs();
+ for(int j = 0; j < outputPins.size(); j++) {
+ OutputPin outputPin = outputPins.get(j);
+ activityNodes.add(outputPin);
+ }
+ }
+ }
+ return activityNodes;
+ }
+
+ public List<Value> getPinValues(OutputPin pin) {
+ // Return the values of the tokens on the pin activation corresponding
+ // to the given pin in the internal activation group for this node
+ // activation.
+ PinActivation pinActivation = (PinActivation)(this.activationGroup.getNodeActivation(pin));
+ List<Token> tokens = pinActivation.getTokens();
+ List<Value> values = new ArrayList<Value>();
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ Value value = ((ObjectToken)token).value;
+ if(value != null) {
+ values.add(value);
+ }
+ }
+ return values;
+ }
+
+ public void putPinValues(OutputPin pin, List<Value> values) {
+ // Place tokens for the given values on the pin activation corresponding
+ // to the given output pin on the internal activation group for this
+ // node activation.
+ PinActivation pinActivation = (PinActivation)(this.activationGroup.getNodeActivation(pin));
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ ObjectToken token = new ObjectToken();
+ token.value = value;
+ pinActivation.addToken(token);
+ }
+ }
+
+ public void createNodeActivations() {
+ // Create an activation group and create node activations for all the
+ // nodes within the structured activity node.
+ super.createNodeActivations();
+
+ this.activationGroup = new ActivityNodeActivationGroup();
+ this.activationGroup.containingNodeActivation = this;
+ this.activationGroup.createNodeActivations(((StructuredActivityNode)(this.node)).getNodes());
+ }
+
+ public void createEdgeInstances() {
+ // Create instances for all edges owned by this node.
+ this.activationGroup.createEdgeInstances(((StructuredActivityNode)(this.node)).getEdges());
+ }
+
+ public Boolean isSourceFor(ActivityEdgeInstance edgeInstance) {
+ // Returns true if this node is either the source for the given
+ // edgeInstance itself or if it contains the source in its
+ // activation group.
+ boolean isSource = super.isSourceFor(edgeInstance);
+ if(!isSource) {
+ isSource = this.activationGroup.hasSourceFor(edgeInstance);
+ }
+ return isSource;
+ }
+
+ public void terminateAll() {
+ // Terminate the execution of all contained node activations (which
+ // completes the performance of the structured activity node
+ // activation).
+ this.activationGroup.terminateAll();
+ }
+
+ public Boolean isSuspended() {
+ // Check if the activation group for this node is suspended.
+ return this.activationGroup.isSuspended();
+ }
+
+ public List<Token> completeAction() {
+ // Only actually complete this structured activity node if it is not
+ // suspended.
+ List<Token> incomingTokens = new ArrayList<Token>();
+ if(!this.isSuspended()) {
+ incomingTokens = super.completeAction();
+ }
+ return incomingTokens;
+ }
+
+ public void resume() {
+ // When this structured activity node is resumed after being suspended,
+ // then complete its prior firing and, if there are more incoming
+ // tokens, fire it again. If, after that, the node is not suspended,
+ // then finish its resumption.
+ List<Token> incomingTokens = super.completeAction();
+ if(incomingTokens.size() > 0) {
+ this.fire(incomingTokens);
+ }
+ if(!this.isSuspended()) {
+ super.resume();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/Values.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/Values.java
new file mode 100644
index 00000000000..1b1a50373c3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/CompleteStructuredActivities/Values.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public class Values {
+
+ public List<Value> values = new ArrayList<Value>();
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionActivationGroup.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionActivationGroup.java
new file mode 100644
index 00000000000..d66654af7dc
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionActivationGroup.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.OutputPinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivationGroup;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ExpansionRegion;
+
+public class ExpansionActivationGroup extends ActivityNodeActivationGroup {
+
+ /*
+ * Output pin activations corresponding, in order, to the input pins of the
+ * expansion region of this activation group.
+ */
+ public List<OutputPinActivation> regionInputs = new ArrayList<OutputPinActivation>();
+
+ /*
+ * Output pin activations corresponding, in order, to the input expansion
+ * nodes of the expansion region of this activation group.
+ */
+ public List<OutputPinActivation> groupInputs = new ArrayList<OutputPinActivation>();
+
+ /*
+ * The expansion region activation this activation group is for.
+ */
+ public ExpansionRegionActivation regionActivation;
+
+ /*
+ * Output pin activations corresponding, in order, to the output expansion
+ * nodes of the expansion region of this activation group.
+ */
+ public List<OutputPinActivation> groupOutputs = new ArrayList<OutputPinActivation>();
+
+ /*
+ * The index (starting at 1) of this activation group in the list held by
+ * the expansion region activation.
+ */
+ public Integer index;
+
+ public ActivityNodeActivation getNodeActivation(ActivityNode node) {
+ // If the given node is an input pin of the expansion region, then
+ // return the corresponding region-input output-pin activation.
+ // If the given node is an input expansion node of the expansion region,
+ // then return the corresponding group-input output-pin activation.
+ // If the given node is an output expansion node of the expansion
+ // region, then return the corresponding group-output output-pin
+ // activation.
+ // Otherwise return the node activation from the activation group, as
+ // usual.
+ ExpansionRegion region = (ExpansionRegion)(this.regionActivation.node);
+ // List<InputPin> inputs = region.getInputs();
+ ActivityNodeActivation activation = null;
+ int i = 1;
+ while(activation == null & i <= region.getInputs().size()) {
+ if(node == region.getInputs().get(i - 1)) {
+ activation = this.regionInputs.get(i - 1);
+ }
+ i = i + 1;
+ }
+ int j = 1;
+ while(activation == null & j <= region.getInputElements().size()) {
+ if(node == region.getInputElements().get(j - 1)) {
+ activation = this.groupInputs.get(j - 1);
+ }
+ j = j + 1;
+ }
+ int k = 1;
+ while(activation == null & k <= region.getOutputElements().size()) {
+ if(node == region.getOutputElements().get(k - 1)) {
+ activation = this.groupOutputs.get(k - 1);
+ }
+ k = k + 1;
+ }
+ if(activation == null) {
+ activation = super.getNodeActivation(node);
+ }
+ return activation;
+ }
+
+ public ActivityExecution getActivityExecution() {
+ // Get the activity execution that contains the expansion region
+ // activation for this activation group.
+ return this.regionActivation.getActivityExecution();
+ }
+
+ public void suspend(ActivityNodeActivation activation) {
+ // Suspend the given activation in this activation group. If this is
+ // the only suspended activation, then suspend the associated region
+ // activation.
+ if(!this.isSuspended()) {
+ this.regionActivation.suspend();
+ }
+ super.suspend(activation);
+ }
+
+ public void resume(ActivityNodeActivation activation) {
+ // Resume the given activation in this activation group. If this is the
+ // last suspended activation, then resume the associated region
+ // activation.
+ super.resume(activation);
+ if(!this.isSuspended()) {
+ this.regionActivation.resume(this);
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionNodeActivation.java
new file mode 100644
index 00000000000..4c99267ae0b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionNodeActivation.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ObjectNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.uml2.uml.ExpansionNode;
+import org.eclipse.uml2.uml.ExpansionRegion;
+
+public class ExpansionNodeActivation extends ObjectNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Take tokens from all incoming edges.
+ Debug.println("[fire] Expansion node " + this.node.getName() + "...");
+ this.addTokens(incomingTokens);
+ }
+
+ public void receiveOffer() {
+ // Forward the offer on to the expansion region.
+ this.getExpansionRegionActivation().receiveOffer();
+ }
+
+ public Boolean isReady() {
+ // An expansion node is always fired by its expansion region.
+ return false;
+ }
+
+ public ExpansionRegionActivation getExpansionRegionActivation() {
+ // Return the expansion region activation corresponding to this
+ // expansion node, in the context of the activity node activation group
+ // this expansion node activation is in.
+ ExpansionNode node = (ExpansionNode)(this.node);
+ ExpansionRegion region = node.getRegionAsInput();
+ if(region == null) {
+ region = node.getRegionAsOutput();
+ }
+ return (ExpansionRegionActivation)(this.group.getNodeActivation(region));
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionRegionActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionRegionActivation.java
new file mode 100644
index 00000000000..ac64fe6a74a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/ExpansionRegionActivation.java
@@ -0,0 +1,326 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.OutputPinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivationGroup;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+import org.eclipse.uml2.uml.ExpansionKind;
+import org.eclipse.uml2.uml.ExpansionNode;
+import org.eclipse.uml2.uml.ExpansionRegion;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+
+public class ExpansionRegionActivation extends ActionActivation {
+
+ /*
+ * The set of expansion activation groups for this expansion region
+ * activation. One activation group is created corresponding to each token
+ * held by the first input expansion node activation for the expansion
+ * region.
+ */
+ public List<ExpansionActivationGroup> activationGroups = new ArrayList<ExpansionActivationGroup>();
+
+ /*
+ * The tokens taken from each of the input pin activations for this
+ * expansion region activation. These are preserved for initializing the
+ * region inputs of each of the activation groups.
+ */
+ public List<TokenSet> inputTokens = new ArrayList<TokenSet>();
+
+ /*
+ * The tokens taken from each of the input expansion node activations for
+ * this expansion region activation. These are preserved for initializing
+ * the group input of each of the activation groups.
+ */
+ public List<TokenSet> inputExpansionTokens = new ArrayList<TokenSet>();
+
+ public Integer next;
+
+ public List<Token> takeOfferedTokens() {
+ // Take the tokens from the input pin and input expansion node
+ // activations and save them.
+ super.takeOfferedTokens();
+ ExpansionRegion region = (ExpansionRegion)(this.node);
+ List<InputPin> inputPins = region.getInputs();
+ List<ExpansionNode> inputElements = region.getInputElements();
+ this.inputTokens.clear();
+ this.inputExpansionTokens.clear();
+ for(int i = 0; i < inputPins.size(); i++) {
+ InputPin inputPin = inputPins.get(i);
+ TokenSet tokenSet = new TokenSet();
+ tokenSet.tokens = this.getPinActivation(inputPin).takeTokens();
+ this.inputTokens.add(tokenSet);
+ }
+ int n = this.numberOfValues();
+ for(int i = 0; i < inputElements.size(); i++) {
+ ExpansionNode inputElement = inputElements.get(i);
+ ExpansionNodeActivation expansionNodeActivation = this.getExpansionNodeActivation(inputElement);
+ expansionNodeActivation.fire(expansionNodeActivation.takeOfferedTokens());
+ List<Token> tokens = expansionNodeActivation.takeTokens();
+ TokenSet tokenSet = new TokenSet();
+ int j = 1;
+ while(j <= n) {
+ tokenSet.tokens.add(tokens.get(j - 1));
+ j = j + 1;
+ }
+ this.inputExpansionTokens.add(tokenSet);
+ }
+ return new ArrayList<Token>();
+ }
+
+ public void doAction() {
+ // If the expansion region has mustIsolate=true, then carry out its
+ // behavior with isolation.
+ // Otherwise just activate it normally.
+ if(((StructuredActivityNode)(this.node)).isMustIsolate()) {
+ _beginIsolation();
+ this.doStructuredActivity();
+ _endIsolation();
+ } else {
+ this.doStructuredActivity();
+ }
+ }
+
+ public void doStructuredActivity() {
+ // Create a number of expansion region activation groups equal to the
+ // number of values expanded in the region,
+ // setting the region inputs and group inputs for each group.
+ // Run the body of the region in each group, either iteratively or in
+ // parallel.
+ // Add the outputs of each activation group to the corresonding output
+ // expansion node activations.
+ ExpansionRegion region = (ExpansionRegion)this.node;
+ List<InputPin> inputPins = region.getInputs();
+ List<ExpansionNode> inputElements = region.getInputElements();
+ List<ExpansionNode> outputElements = region.getOutputElements();
+ this.activationGroups.clear();
+ int n = this.inputExpansionTokens.get(0).tokens.size();
+ int k = 1;
+ while(k <= n) {
+ ExpansionActivationGroup activationGroup = new ExpansionActivationGroup();
+ activationGroup.regionActivation = this;
+ activationGroup.index = k;
+ int j = 1;
+ while(j <= inputPins.size()) {
+ OutputPinActivation regionInput = new OutputPinActivation();
+ regionInput.run();
+ activationGroup.regionInputs.add(regionInput);
+ j = j + 1;
+ }
+ j = 1;
+ while(j <= inputElements.size()) {
+ OutputPinActivation groupInput = new OutputPinActivation();
+ groupInput.run();
+ activationGroup.groupInputs.add(groupInput);
+ j = j + 1;
+ }
+ j = 1;
+ while(j <= outputElements.size()) {
+ OutputPinActivation groupOutput = new OutputPinActivation();
+ groupOutput.run();
+ activationGroup.groupOutputs.add(groupOutput); // CHANGED "new OutputPinActivation()" to "groupOutput"
+ j = j + 1;
+ }
+ activationGroup.createNodeActivations(region.getNodes());
+ activationGroup.createEdgeInstances(region.getEdges());
+ this.activationGroups.add(activationGroup);
+ k = k + 1;
+ }
+ // List<ExpansionActivationGroup> activationGroups =
+ // this.activationGroups;
+ if(region.getMode() == ExpansionKind.ITERATIVE_LITERAL) {
+ Debug.println("[doStructuredActivity] Expansion mode = iterative");
+ this.next = 1;
+ this.runIterative();
+ } else if(region.getMode() == ExpansionKind.PARALLEL_LITERAL) {
+ Debug.println("[doStructuredActivity] Expansion mode = parallel");
+ this.runParallel();
+ }
+ this.doOutput();
+ }
+
+ public void runIterative() {
+ // Run the body of the region iteratively, either until all activation
+ // groups have run or until the region is suspended.
+ List<ExpansionActivationGroup> activationGroups = this.activationGroups;
+ while(this.next <= activationGroups.size() & !this.isSuspended()) {
+ ExpansionActivationGroup activationGroup = activationGroups.get(this.next - 1);
+ this.runGroup(activationGroup);
+ this.next = this.next + 1;
+ }
+ }
+
+ public void runParallel() {
+ // Run the body of the region concurrently.
+ List<ExpansionActivationGroup> activationGroups = this.activationGroups;
+ // *** Activate all groups concurrently. ***
+ for(Iterator<ExpansionActivationGroup> i = activationGroups.iterator(); i.hasNext();) {
+ ExpansionActivationGroup activationGroup = i.next();
+ this.runGroup(activationGroup);
+ }
+ }
+
+ public void doOutput() {
+ // Place tokens on the output expansion nodes.
+ ExpansionRegion region = (ExpansionRegion)this.node;
+ List<ExpansionNode> outputElements = region.getOutputElements();
+ Debug.println("[doOutput] Expansion region " + region.getName() + " is " + (this.isSuspended() ? "suspended." : "completed."));
+ if(!this.isSuspended()) {
+ for(int i = 0; i < activationGroups.size(); i++) {
+ ExpansionActivationGroup activationGroup = activationGroups.get(i);
+ List<OutputPinActivation> groupOutputs = activationGroup.groupOutputs;
+ for(int j = 0; j < groupOutputs.size(); j++) {
+ OutputPinActivation groupOutput = groupOutputs.get(j);
+ ExpansionNode outputElement = outputElements.get(j);
+ this.getExpansionNodeActivation(outputElement).addTokens(groupOutput.takeTokens());
+ }
+ }
+ }
+ }
+
+ public void terminate() {
+ // Terminate the execution of all contained node activations (which
+ // completes the performance of the expansion region activation).
+ List<ExpansionActivationGroup> activationGroups = this.activationGroups;
+ for(int i = 0; i < activationGroups.size(); i++) {
+ ExpansionActivationGroup activationGroup = this.activationGroups.get(i);
+ List<OutputPinActivation> groupOutputs = activationGroup.groupOutputs;
+ _beginIsolation();
+ for(int j = 0; j < groupOutputs.size(); j++) {
+ OutputPinActivation groupOutput = groupOutputs.get(j);
+ groupOutput.fire(groupOutput.takeOfferedTokens());
+ }
+ activationGroup.terminateAll();
+ _endIsolation();
+ }
+ super.terminate();
+ }
+
+ public void sendOffers() {
+ // Fire all output expansion nodes and send offers on all outgoing
+ // control flows.
+ ExpansionRegion region = (ExpansionRegion)(this.node);
+ // *** Send offers from all output expansion nodes concurrently. ***
+ List<ExpansionNode> outputElements = region.getOutputElements();
+ for(Iterator<ExpansionNode> i = outputElements.iterator(); i.hasNext();) {
+ ExpansionNode outputElement = i.next();
+ this.getExpansionNodeActivation(outputElement).sendUnofferedTokens();
+ }
+ // Send offers on all outgoing control flows.
+ super.sendOffers();
+ }
+
+ public void runGroup(ExpansionActivationGroup activationGroup) {
+ // Set up the inputs for the group with the given index, run the group
+ // and then fire the group outputs.
+ if(this.isRunning()) {
+ Debug.println("[runGroup] groupInput[0] = " + this.inputExpansionTokens.get(0).tokens.get(activationGroup.index - 1).getValue());
+ List<TokenSet> inputTokens = this.inputTokens;
+ for(int j = 0; j < inputTokens.size(); j++) {
+ TokenSet tokenSet = inputTokens.get(j);
+ OutputPinActivation regionInput = activationGroup.regionInputs.get(j);
+ regionInput.clearTokens();
+ regionInput.addTokens(tokenSet.tokens);
+ regionInput.sendUnofferedTokens();
+ }
+ List<TokenSet> inputExpansionTokens = this.inputExpansionTokens;
+ for(int j = 0; j < inputExpansionTokens.size(); j++) {
+ TokenSet tokenSet = inputExpansionTokens.get(j);
+ OutputPinActivation groupInput = activationGroup.groupInputs.get(j);
+ groupInput.clearTokens();
+ if(tokenSet.tokens.size() >= activationGroup.index) {
+ groupInput.addToken(tokenSet.tokens.get(activationGroup.index - 1));
+ }
+ groupInput.sendUnofferedTokens();
+ }
+ activationGroup.run(activationGroup.nodeActivations);
+ this.terminateGroup(activationGroup);
+ }
+ }
+
+ public void terminateGroup(ExpansionActivationGroup activationGroup) {
+ // Terminate the given activation group, after preserving any group
+ // outputs.
+ if(this.isRunning() & !this.isSuspended()) {
+ List<OutputPinActivation> groupOutputs = activationGroup.groupOutputs;
+ for(int i = 0; i < groupOutputs.size(); i++) {
+ OutputPinActivation groupOutput = groupOutputs.get(i);
+ groupOutput.fire(groupOutput.takeOfferedTokens());
+ }
+ activationGroup.terminateAll();
+ }
+ }
+
+ public ExpansionNodeActivation getExpansionNodeActivation(ExpansionNode node) {
+ // Return the expansion node activation corresponding to the given
+ // expansion node, in the context of the activity node activation group
+ // this expansion region activation is in.
+ // [Note: Expansion regions do not own their expansion nodes. Instead,
+ // they are own as object nodes by the enclosing activity or group.
+ // Therefore, they will already be activated along with their expansion
+ // region.]
+ return (ExpansionNodeActivation)(this.group.getNodeActivation(node));
+ }
+
+ public Integer numberOfValues() {
+ // Return the number of values to be acted on by the expansion region of
+ // this activation, which is the minimum of the number of values offered
+ // to each of the input expansion nodes of the activation.
+ ExpansionRegion region = (ExpansionRegion)(this.node);
+ List<ExpansionNode> inputElements = region.getInputElements();
+ int n = this.getExpansionNodeActivation(inputElements.get(0)).countOfferedValues();
+ int i = 2;
+ while(i <= inputElements.size()) {
+ int count = this.getExpansionNodeActivation(inputElements.get(i - 1)).countOfferedValues();
+ if(count < n) {
+ n = count;
+ }
+ i = i + 1;
+ }
+ return n;
+ }
+
+ public Boolean isSuspended() {
+ // Check if the activation group for this node is suspended.
+ boolean suspended = false;
+ int i = 1;
+ while(i <= this.activationGroups.size() & !suspended) {
+ ActivityNodeActivationGroup group = this.activationGroups.get(i - 1);
+ suspended = group.isSuspended();
+ i = i + 1;
+ }
+ return suspended;
+ }
+
+ public void resume(ExpansionActivationGroup activationGroup) {
+ // Resume an expansion region after the suspension of the given
+ // activation group. If the region is iterative, then continue with the
+ // iteration. If the region is parallel, and there are no more suspended
+ // activation groups, then generate the expansion node output.
+ ExpansionRegion region = (ExpansionRegion)this.node;
+ this.resume();
+ this.terminateGroup(activationGroup);
+ if(region.getMode() == ExpansionKind.ITERATIVE_LITERAL) {
+ this.runIterative();
+ }
+ this.doOutput();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/TokenSet.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/TokenSet.java
new file mode 100644
index 00000000000..c1974e1f452
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/ExtraStructuredActivities/TokenSet.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.Token;
+
+public class TokenSet {
+
+ /*
+ * The set of tokens in this input set.
+ */
+ public List<Token> tokens = new ArrayList<Token>();
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityEdgeInstance.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityEdgeInstance.java
new file mode 100644
index 00000000000..56c3ee900df
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityEdgeInstance.java
@@ -0,0 +1,202 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+import org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils;
+import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils;
+import org.eclipse.uml2.uml.ActivityEdge;
+
+public class ActivityEdgeInstance {
+
+ /*
+ * The activity edge of which this is an instance. [This is optional to
+ * allow for an implicit fork node execution to be connected to its action
+ * execution by an edge instance which does not have a corresponding node in
+ * the model.]
+ */
+ public ActivityEdge edge;
+
+ /*
+ * The activity group that contains this activity edge instance.
+ */
+ public ActivityNodeActivationGroup group;
+
+ /*
+ * The source of this activity edge instance. The node of the source must be
+ * the same as the source of the edge of this edge instance.
+ */
+ public ActivityNodeActivation source;
+
+ /*
+ * The target of this activity edge instance. The node of the target must be
+ * the same as the target of the edge of this edge instance.
+ */
+ public ActivityNodeActivation target;
+
+ public List<Offer> offers = new ArrayList<Offer>();
+
+ public void sendOffer(List<Token> tokens) {
+ // Send an offer from the source to the target.
+ // Keep the offered tokens until taken by the target.
+ // (Note that any one edge should only be handling either all object
+ // tokens or all control tokens.)
+ Offer offer = new Offer();
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ // Debug.println("[sendOffer] token value = " + token.get());
+ offer.offeredTokens.add(token);
+ }
+ this.offers.add(offer);
+
+ // Connection with the debug api
+ if (this.group != null) { // TODO : Understand why group may be null
+ Locus locus = this.group.getActivityExecution().locus ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ boolean animationMarkerNeedsToBeRemoved = false ;
+ long date = 0 ;
+ if (MokaConstants.MOKA_AUTOMATIC_ANIMATION) {
+ date = System.currentTimeMillis() ;
+ AnimationUtils.getInstance().addAnimationMarker(edge) ;
+ animationMarkerNeedsToBeRemoved = true ;
+ }
+ MokaStackFrame stackFrame = FUMLPresentationUtils.getMokaStackFrame(this) ;
+ //stackFrame.setModelElement(this.edge) ;
+ stackFrame.setThread(locus.mainThread) ;
+ stackFrame.setName(this.edge.getName()) ;
+ StackFrameManager.getInstance().setStackFrame(this.group.getActivityExecution(), stackFrame) ;
+ int reasonForSuspending = FUMLExecutionEngine.controlDelegate.shallSuspend(this.group.getActivityExecution(), this) ;
+ if (reasonForSuspending != -1) {
+ locus.mainThread.setSuspended(true) ;
+ locus.mainThread.setStackFrames(null) ;
+ //locus.stackFrames = new MokaStackFrame[]{stackFrame} ;
+ locus.stackFrames = StackFrameManager.getInstance().getStackFrames() ;
+ Suspend_Event breakpointEvent = new Suspend_Event(locus.mainThread, reasonForSuspending, new MokaThread[]{locus.mainThread}) ;
+ locus.engine.sendEvent(breakpointEvent) ;
+ try {
+ FUMLExecutionEngine.controlDelegate.suspend(this.group.getActivityExecution()) ;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ locus.mainThread.setSuspended(false) ;
+ }
+ if (animationMarkerNeedsToBeRemoved) {
+ try {
+ long ellapsed = System.currentTimeMillis() - date ;
+ long delay = Math.max(1,MokaConstants.MOKA_ANIMATION_DELAY - ellapsed) ;
+ Thread.sleep(delay) ;
+ } catch (InterruptedException e1) {
+ Activator.log.error(e1);
+ }
+ AnimationUtils.getInstance().removeAnimationMarker(edge) ;
+ }
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ }
+
+ // End: Connection with the debug api
+
+ this.target.receiveOffer();
+ }
+
+ public Integer countOfferedValues() {
+ // Return the number of values being offered in object tokens.
+ int count = 0;
+ List<Offer> offers = this.offers;
+ for(int i = 0; i < offers.size(); i++) {
+ count = count + offers.get(i).countOfferedValues();
+ }
+ return count;
+ }
+
+ public List<Token> takeOfferedTokens() {
+ // Take all the offered tokens and return them.
+ List<Token> tokens = new ArrayList<Token>();
+ while(this.offers.size() > 0) {
+ List<Token> offeredTokens = this.offers.get(0).getOfferedTokens();
+ for(int i = 0; i < offeredTokens.size(); i++) {
+ tokens.add(offeredTokens.get(i));
+ }
+ this.offers.remove(0);
+ }
+ return tokens;
+ }
+
+ public List<Token> takeOfferedTokens(Integer maxCount) {
+ // Take all the offered tokens, up to the given maximum count of
+ // non-null object tokens, and return them.
+ List<Token> tokens = new ArrayList<Token>();
+ int remainingCount = maxCount;
+ while(this.offers.size() > 0 & remainingCount > 0) {
+ Offer offer = this.offers.get(0);
+ List<Token> offeredTokens = offer.getOfferedTokens();
+ int count = offer.countOfferedValues();
+ if(count <= remainingCount) {
+ for(int i = 0; i < offeredTokens.size(); i++) {
+ tokens.add(offeredTokens.get(i));
+ }
+ remainingCount = remainingCount - count;
+ this.offers.remove(0);
+ } else {
+ for(int i = 0; i < remainingCount; i++) {
+ Token token = offeredTokens.get(i);
+ if(token.getValue() != null) {
+ tokens.add(token);
+ }
+ }
+ offer.removeOfferedValues(remainingCount);
+ remainingCount = 0;
+ }
+ }
+ return tokens;
+ }
+
+ public List<Token> getOfferedTokens() {
+ // Get the offered tokens (after which the tokens will still be
+ // offered).
+ List<Token> tokens = new ArrayList<Token>();
+ List<Offer> offers = this.offers;
+ for(int i = 0; i < offers.size(); i++) {
+ List<Token> offeredTokens = offers.get(i).getOfferedTokens();
+ for(int j = 0; j < offeredTokens.size(); j++) {
+ tokens.add(offeredTokens.get(j));
+ }
+ }
+ return tokens;
+ }
+
+ public Boolean hasOffer() {
+ // Return true if there are any pending offers.
+ boolean hasTokens = false;
+ int i = 1;
+ while(!hasTokens & i <= this.offers.size()) {
+ hasTokens = this.offers.get(i - 1).hasTokens();
+ i = i + 1;
+ }
+ return hasTokens;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityExecution.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityExecution.java
new file mode 100644
index 00000000000..5d4ec8b35a8
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityExecution.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityParameterNode;
+
+public class ActivityExecution extends Execution {
+
+ /*
+ * The group of activations of the activity nodes of the activity.
+ */
+ public ActivityNodeActivationGroup activationGroup;
+
+ public void execute() {
+ // Execute the activity for this execution by creating an activity node
+ // activation group and activating all the activity nodes in the
+ // activity.
+ // When this is complete, copy the values on the tokens offered by
+ // output parameter nodes to the corresponding output parameters.
+ Activity activity = (Activity)(this.getTypes().get(0));
+ Debug.println("[execute] Activity " + activity.getName() + "...");
+ // Debug.println("[execute] context = " + this.context.objectId());
+ Debug.println("[event] Execute activity=" + activity.getName());
+ this.activationGroup = new ActivityNodeActivationGroup();
+ this.activationGroup.activityExecution = this;
+ this.activationGroup.activate(activity.getNodes(), activity.getEdges());
+ // Debug.println("[execute] Getting output parameter node activations...");
+ List<ActivityParameterNodeActivation> outputActivations = this.activationGroup.getOutputParameterNodeActivations();
+ // Debug.println("[execute] There are " + outputActivations.size() +
+ // " output parameter node activations.");
+ for(int i = 0; i < outputActivations.size(); i++) {
+ ActivityParameterNodeActivation outputActivation = outputActivations.get(i);
+ ParameterValue parameterValue = new ParameterValue();
+ parameterValue.parameter = ((ActivityParameterNode)(outputActivation.node)).getParameter();
+ List<Token> tokens = outputActivation.getTokens();
+ for(int j = 0; j < tokens.size(); j++) {
+ Token token = tokens.get(j);
+ Value value = ((ObjectToken)token).value;
+ if(value != null) {
+ parameterValue.values.add(value);
+ Debug.println("[event] Output activity=" + activity.getName() + " parameter=" + parameterValue.parameter.getName() + " value=" + value);
+ }
+ }
+ this.setParameterValue(parameterValue);
+ }
+ // Statement added for connection with the DebugAPI
+ StackFrameManager.getInstance().popActivityExecution() ;
+ Debug.println("[execute] Activity " + activity.getName() + " completed.");
+ }
+
+ public Value copy() {
+ // Create a new activity execution that is a copy of this execution.
+ // [Note: This currently just returns a non-executing execution for the
+ // same activity as this execution.]
+ return super.copy();
+ }
+
+ public Value new_() {
+ // Create a new activity execution with empty properties.
+ return new ActivityExecution();
+ }
+
+ public void terminate() {
+ // Terminate all node activations (which will ultimately result in the
+ // activity execution completing).
+ if (this.activationGroup != null) {
+ this.activationGroup.terminateAll();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityFinalNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityFinalNodeActivation.java
new file mode 100644
index 00000000000..f007a76e0aa
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityFinalNodeActivation.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities.ExpansionActivationGroup;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+
+public class ActivityFinalNodeActivation extends ControlNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Terminate the activity execution or structured node activation
+ // containing this activation.
+ Debug.println("[fire] Activity final node " + this.node.getName() + "...");
+ if(incomingTokens.size() > 0 | this.incomingEdges.size() == 0) {
+ if(this.group.activityExecution != null) {
+ this.group.activityExecution.terminate();
+ } else if(this.group.containingNodeActivation != null) {
+ this.group.containingNodeActivation.terminateAll();
+ } else if(this.group instanceof ExpansionActivationGroup) {
+ ((ExpansionActivationGroup)this.group).regionActivation.terminate();
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivation.java
new file mode 100644
index 00000000000..d1bf5f9a1cf
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivation.java
@@ -0,0 +1,353 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+import org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticVisitor;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils;
+import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils;
+import org.eclipse.uml2.uml.ActivityNode;
+
+public abstract class ActivityNodeActivation extends SemanticVisitor {
+
+ /*
+ * The group that contains this activity node activation.
+ */
+ public ActivityNodeActivationGroup group;
+
+ /*
+ * The activity node being activated by this activity node activation. The
+ * node must be owned by the activity (type) of the activity execution of
+ * this node activation. [This is optional, to allow for fork node edge
+ * queues and implicit fork and join node activations for actions to not
+ * have nodes in the model.]
+ */
+ public ActivityNode node;
+
+ /*
+ * The set of activity edge instances for the incoming edges of the node.
+ */
+ public List<ActivityEdgeInstance> incomingEdges = new ArrayList<ActivityEdgeInstance>();
+
+ /*
+ * The set of activity edge instances for the outgoing edges of the node.
+ */
+ public List<ActivityEdgeInstance> outgoingEdges = new ArrayList<ActivityEdgeInstance>();
+
+ /*
+ * If true, this node activation is enabled for execution once all its other
+ * prerequesites are satisfied.
+ */
+ public Boolean running;
+
+ public List<Token> heldTokens = new ArrayList<Token>();
+
+ public void run() {
+ // Run the activation of this node.
+ if(this.node != null) {
+ Debug.println("[run] node = " + this.node.getName());
+ } else {
+ Debug.println("[run] Anonymous activation of type " + this.getClass().getName());
+ }
+ this.running = true;
+ }
+
+ public void receiveOffer() {
+ // Receive an offer from an incoming edge.
+ // Check if all prerequisites have been satisfied. If so, fire.
+ Debug.println("[receiveOffer] " + (this.node == null ? "..." : "node = " + this.node.getName()));
+ _beginIsolation();
+ boolean ready = this.isReady();
+ List<Token> tokens = new ArrayList<Token>();
+ if(ready) {
+ Debug.println("[receiveOffer] Firing.");
+ tokens = this.takeOfferedTokens();
+ }
+ _endIsolation();
+ if(ready) {
+ this.fire(tokens);
+ }
+ }
+
+ public List<Token> takeOfferedTokens() {
+ // Get tokens from all incoming edges.
+ List<Token> allTokens = new ArrayList<Token>();
+ List<ActivityEdgeInstance> incomingEdges = this.incomingEdges;
+ for(int i = 0; i < incomingEdges.size(); i++) {
+ ActivityEdgeInstance incomingEdge = incomingEdges.get(i);
+ List<Token> tokens = incomingEdge.takeOfferedTokens();
+ for(int j = 0; j < tokens.size(); j++) {
+ Token token = tokens.get(j);
+ allTokens.add(token);
+ }
+ }
+ return allTokens;
+ }
+
+ // public abstract void fire(List<Token> incomingTokens);
+
+ // This property is introduced for connection to the debug API
+ public List<Token> incomingTokens_DEBUG ;
+
+ public void fire(List<Token> incomingTokens) {
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ this.incomingTokens_DEBUG = incomingTokens ;
+ if (locus.engine.isTerminated())
+ return ;
+ boolean animationMarkerNeedsToBeRemoved = false ;
+ long date = 0 ;
+ if (MokaConstants.MOKA_AUTOMATIC_ANIMATION) {
+ date = System.currentTimeMillis() ;
+ AnimationUtils.getInstance().addAnimationMarker(node) ;
+ animationMarkerNeedsToBeRemoved = true ;
+ }
+ MokaStackFrame stackFrame = FUMLPresentationUtils.getMokaStackFrame(this) ;
+ stackFrame.setThread(locus.mainThread) ;
+ stackFrame.setName(this.node.getName()) ;
+ StackFrameManager.getInstance().setStackFrame(this.getActivityExecution(), stackFrame) ;
+ int reasonForSuspending = FUMLExecutionEngine.controlDelegate.shallSuspend(this.getActivityExecution(), this) ;
+ if (reasonForSuspending != -1) {
+ locus.mainThread.setSuspended(true) ;
+ locus.mainThread.setStackFrames(null) ;
+ //locus.stackFrames = new MokaStackFrame[]{stackFrame} ;
+ locus.stackFrames = StackFrameManager.getInstance().getStackFrames() ;
+ Suspend_Event breakpointEvent = new Suspend_Event(locus.mainThread, reasonForSuspending, new MokaThread[]{locus.mainThread}) ;
+ locus.engine.sendEvent(breakpointEvent) ;
+ try {
+ FUMLExecutionEngine.controlDelegate.suspend(this.getActivityExecution()) ;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ locus.mainThread.setSuspended(false) ;
+ }
+ if (animationMarkerNeedsToBeRemoved) {
+ try {
+ long ellapsed = System.currentTimeMillis() - date ;
+ long delay = Math.max(1,MokaConstants.MOKA_ANIMATION_DELAY - ellapsed) ;
+ Thread.sleep(delay) ;
+ } catch (InterruptedException e1) {
+ Activator.log.error(e1);
+ }
+ AnimationUtils.getInstance().removeAnimationMarker(node) ;
+ }
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ }
+ //
+
+ public void sendOffers(List<Token> tokens) {
+ // Send offers for the given set of tokens over all outgoing edges (if
+ // there are any tokens actually being offered).
+ if(tokens.size() > 0) {
+ // *** Send all outgoing offers concurrently. ***
+ List<ActivityEdgeInstance> outgoingEdges = this.outgoingEdges;
+ for(Iterator<ActivityEdgeInstance> i = outgoingEdges.iterator(); i.hasNext();) {
+ ActivityEdgeInstance outgoingEdge = i.next();
+ // Debug.println("[sendOffers] Sending offer to " +
+ // outgoingEdge.target.node.getName() + ".");
+ outgoingEdge.sendOffer(tokens);
+ }
+ }
+ }
+
+ public void terminate() {
+ // Terminate the activation of this node.
+ if(this.running) {
+ if(this.node != null) {
+ Debug.println("[terminate] node = " + this.node.getName());
+ } else {
+ Debug.println("[terminate] Anonymous activation of type " + this.getClass().getName());
+ }
+ }
+ this.running = false;
+ }
+
+ public Boolean isReady() {
+ // Check if all the prerequisites for this node have been satisfied.
+ // By default, check that this node is running.
+ return this.isRunning();
+ }
+
+ public Boolean isRunning() {
+ // Test whether this node activation is running.
+ return this.running;
+ }
+
+ public void addOutgoingEdge(ActivityEdgeInstance edge) {
+ // Add an activity edge instance as an outgoing edge of this activity
+ // node activation.
+ edge.source = this;
+ this.outgoingEdges.add(edge);
+ }
+
+ public void addIncomingEdge(ActivityEdgeInstance edge) {
+ // Add an activity edge instance as an incoming edge of this activity
+ // node activation.
+ edge.target = this;
+ this.incomingEdges.add(edge);
+ }
+
+ public void createNodeActivations() {
+ // Create node activations for any subnodes of the node for this
+ // activation.
+ // For most kinds of nodes, this does nothing.
+ return;
+ }
+
+ public void createEdgeInstances() {
+ // Create edge instances for any edge instances owned by the node for
+ // this activation.
+ // For most kinds of nodes, this does nothing.
+ return;
+ }
+
+ public Boolean isSourceFor(ActivityEdgeInstance edgeInstance) {
+ // Check if this node activation is the effective source for the given
+ // edge instance.
+ return edgeInstance.source == this;
+ }
+
+ public ActivityExecution getActivityExecution() {
+ // Return the activity execution that contains this activity node
+ // activation, directly or indirectly.
+ return this.group.getActivityExecution();
+ }
+
+ public Object_ getExecutionContext() {
+ // Get the context object for the containing activity execution.
+ return this.getActivityExecution().context;
+ }
+
+ public Locus getExecutionLocus() {
+ // Get the locus of the containing activity execution.
+ return this.getActivityExecution().locus;
+ }
+
+ public ActivityNodeActivation getNodeActivation(ActivityNode node) {
+ // Get the activity node activation corresponding to the given activity
+ // node, in the context of this activity node activation.
+ // By default, return this activity node activation, if it is for the
+ // given node, otherwise return nothing.
+ ActivityNodeActivation activation = null;
+ if(node == this.node) {
+ activation = this;
+ }
+ return activation;
+ }
+
+ public void addToken(Token token) {
+ // Transfer the given token to be held by this node.
+ if(this.node == null) {
+ Debug.println("[addToken] ...");
+ } else {
+ Debug.println("[addToken] node = " + this.node.getName());
+ }
+ Token transferredToken = token.transfer(this);
+ // Debug.println("[addToken] Adding token with value = " +
+ // transferredToken.get());
+ this.heldTokens.add(transferredToken);
+ }
+
+ public Integer removeToken(Token token) {
+ // Remove the given token, if it is held by this node activation.
+ // Return the position (counting from 1) of the removed token (0 if
+ // there is none removed).
+ boolean notFound = true;
+ int i = 1;
+ while(notFound & i <= this.heldTokens.size()) {
+ if(this.heldTokens.get(i - 1) == token) {
+ if(this.node == null) {
+ Debug.println("[removeToken] ...");
+ } else {
+ Debug.println("[removeToken] node = " + this.node.getName());
+ }
+ this.heldTokens.remove(i - 1);
+ notFound = false;
+ }
+ i = i + 1;
+ }
+ if(notFound) {
+ i = 0;
+ } else {
+ i = i - 1;
+ }
+ return i;
+ }
+
+ public void addTokens(List<Token> tokens) {
+ // Transfer the given tokens to be the held tokens for this node.
+ // if (this.node == null) {
+ // Debug.println("[addTokens] ...");
+ // } else {
+ // Debug.println("[addTokens] node = " + this.node.getName());
+ // }
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ this.addToken(token);
+ }
+ }
+
+ public List<Token> takeTokens() {
+ // Take the tokens held by this node activation.
+ List<Token> tokens = this.getTokens();
+ this.clearTokens();
+ return tokens;
+ }
+
+ public void clearTokens() {
+ // Remove all held tokens.
+ while(this.heldTokens.size() > 0) {
+ this.heldTokens.get(0).withdraw();
+ }
+ }
+
+ public List<Token> getTokens() {
+ // Get the tokens held by this node activation.
+ // Debug.println("[getTokens] node = " + this.node.getName());
+ List<Token> tokens = new ArrayList<Token>();
+ List<Token> heldTokens = this.heldTokens;
+ for(int i = 0; i < heldTokens.size(); i++) {
+ Token heldToken = heldTokens.get(i);
+ // Debug.println("[getTokens] token value = " +
+ // heldTokens.get());
+ tokens.add(heldToken);
+ }
+ return tokens;
+ }
+
+ public void suspend() {
+ // Suspend this activation within the activation group that contains it.
+ this.group.suspend(this);
+ }
+
+ public void resume() {
+ // Resume this activation within the activation group that contains it.
+ this.group.resume(this);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivationGroup.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivationGroup.java
new file mode 100644
index 00000000000..c054cf22d01
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityNodeActivationGroup.java
@@ -0,0 +1,313 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.ActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities.StructuredActivityNodeActivation;
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.Pin;
+
+public class ActivityNodeActivationGroup {
+
+ /*
+ * The set of activity edge instances for this group.
+ */
+ public List<ActivityEdgeInstance> edgeInstances = new ArrayList<ActivityEdgeInstance>();
+
+ /*
+ * The set of activity node executions for this group.
+ */
+ public List<ActivityNodeActivation> nodeActivations = new ArrayList<ActivityNodeActivation>();
+
+ /*
+ * The activity execution to which this group belongs. (This will be empty
+ * if the group is for a structured activity node activation.)
+ */
+ public ActivityExecution activityExecution;
+
+ /*
+ * The structured activity node activation to which this group belongs.
+ * (This will be empty if the group is for an activity execution.)
+ */
+ public StructuredActivityNodeActivation containingNodeActivation;
+
+ /*
+ * Activity node activations in this activation group that are suspended
+ * waiting for an event occurrence. If an activation group has a containing
+ * node activation and any suspended activations, then the containing node
+ * activation will also be suspended.
+ */
+ public List<ActivityNodeActivation> suspendedActivations = new ArrayList<ActivityNodeActivation>();
+
+ public void run(List<ActivityNodeActivation> activations) {
+ // Run the given node activations and then (concurrently) send an offer
+ // to all activations for nodes with no incoming edges within the given
+ // set.
+ for(int i = 0; i < activations.size(); i++) {
+ ActivityNodeActivation activation = activations.get(i);
+ activation.run();
+ }
+ Debug.println("[run] Checking for enabled nodes...");
+ List<ActivityNodeActivation> enabledActivations = new ArrayList<ActivityNodeActivation>();
+ for(int i = 0; i < activations.size(); i++) {
+ ActivityNodeActivation activation = activations.get(i);
+ Debug.println("[run] Checking node " + activation.node.getName() + "...");
+ if(activation instanceof ActionActivation | activation instanceof ControlNodeActivation | activation instanceof ActivityParameterNodeActivation) {
+ boolean isEnabled = this.checkIncomingEdges(activation.incomingEdges, activations);
+ // For an action activation, also consider incoming edges to
+ // input pins
+ if(isEnabled & activation instanceof ActionActivation) {
+ List<InputPin> inputPins = ((Action)activation.node).getInputs();
+ int j = 1;
+ while(j <= inputPins.size() & isEnabled) {
+ InputPin inputPin = inputPins.get(j - 1);
+ List<ActivityEdgeInstance> inputEdges = ((ActionActivation)activation).getPinActivation(inputPin).incomingEdges;
+ isEnabled = this.checkIncomingEdges(inputEdges, activations);
+ j = j + 1;
+ }
+ }
+ if(isEnabled) {
+ Debug.println("[run] Node " + activation.node.getName() + " is enabled.");
+ enabledActivations.add(activation);
+ }
+ }
+ }
+ // Debug.println("[run] " + enabledActivations.size() +
+ // " node(s) are enabled.");
+ // *** Send offers to all enabled nodes concurrently. ***
+ for(Iterator<ActivityNodeActivation> i = enabledActivations.iterator(); i.hasNext();) {
+ ActivityNodeActivation activation = i.next();
+ Debug.println("[run] Sending offer to node " + activation.node.getName() + ".");
+ activation.receiveOffer();
+ }
+ }
+
+ public Boolean checkIncomingEdges(List<ActivityEdgeInstance> incomingEdges, List<ActivityNodeActivation> activations) {
+ // Check if any incoming edges have a source in a given set of
+ // activations.
+ int j = 1;
+ boolean notFound = true;
+ while(j <= incomingEdges.size() & notFound) {
+ int k = 1;
+ while(k <= activations.size() & notFound) {
+ if(activations.get(k - 1).isSourceFor(incomingEdges.get(j - 1))) {
+ notFound = false;
+ }
+ k = k + 1;
+ }
+ j = j + 1;
+ }
+ return notFound;
+ }
+
+ public void runNodes(List<ActivityNode> nodes) {
+ // Run the node activations associated with the given nodes in this
+ // activation group.
+ List<ActivityNodeActivation> nodeActivations = new ArrayList<ActivityNodeActivation>();
+ for(int i = 0; i < nodes.size(); i++) {
+ ActivityNode node = nodes.get(i);
+ ActivityNodeActivation nodeActivation = this.getNodeActivation(node);
+ if(nodeActivation != null) {
+ nodeActivations.add(nodeActivation);
+ }
+ }
+ this.run(nodeActivations);
+ }
+
+ public void activate(List<ActivityNode> nodes, List<ActivityEdge> edges) {
+ // Activate and run the given set of nodes with the given set of edges,
+ // within this activation group.
+ this.createNodeActivations(nodes);
+ this.createEdgeInstances(edges);
+ this.run(this.nodeActivations);
+ // Debug.println("[activate] Exiting.");
+ }
+
+ public void terminateAll() {
+ // Terminate all node activations in the group.
+ Debug.println("[terminateAll] Terminating activation group for " + (this.activityExecution != null ? "activity " + this.activityExecution.getTypes().get(0).getName() : this.containingNodeActivation != null ? "node " + this.containingNodeActivation.node.getName() : "expansion region") + ".");
+ List<ActivityNodeActivation> nodeActivations = this.nodeActivations;
+ for(int i = 0; i < nodeActivations.size(); i++) {
+ ActivityNodeActivation nodeActivation = nodeActivations.get(i);
+ nodeActivation.terminate();
+ }
+ this.suspendedActivations.clear();
+ }
+
+ public void createNodeActivations(List<ActivityNode> nodes) {
+ // Add activity node activations for the given set of nodes to this
+ // group and create edge instances between them.
+ for(int i = 0; i < nodes.size(); i++) {
+ ActivityNode node = nodes.get(i);
+ Debug.println("[createNodeActivations] Creating a node activation for " + node.getName() + "...");
+ this.createNodeActivation(node);
+ }
+ }
+
+ public ActivityNodeActivation createNodeActivation(ActivityNode node) {
+ // Create an activity node activation for a given activity node in this
+ // activity node activation group.
+ ActivityNodeActivation activation = (ActivityNodeActivation)(this.getActivityExecution().locus.factory.instantiateVisitor(node));
+ activation.node = node;
+ activation.running = false;
+ this.addNodeActivation(activation);
+ activation.createNodeActivations();
+ return activation;
+ }
+
+ public void addNodeActivation(ActivityNodeActivation activation) {
+ // Add the given node activation to this group.
+ activation.group = this;
+ this.nodeActivations.add(activation);
+ }
+
+ public ActivityNodeActivation getNodeActivation(ActivityNode node) {
+ // Return the node activation (if any) in this group,
+ // or any nested group, corresponding to the given activity node.
+ // If this is a group for a structured activity node activation,
+ // also include the pin activations for that node activation.
+ ActivityNodeActivation activation = null;
+ if(this.containingNodeActivation != null && node instanceof Pin) {
+ activation = this.containingNodeActivation.getPinActivation((Pin)node);
+ }
+ if(activation == null) {
+ int i = 1;
+ while(activation == null & i <= this.nodeActivations.size()) {
+ activation = this.nodeActivations.get(i - 1).getNodeActivation(node);
+ i = i + 1;
+ }
+ }
+ return activation;
+ }
+
+ public void createEdgeInstances(List<ActivityEdge> edges) {
+ // Create instance edges for the given activity edges, as well as for
+ // edge instances within any nodes activated in this group.
+ for(int i = 0; i < edges.size(); i++) {
+ ActivityEdge edge = edges.get(i);
+ Debug.println("[createEdgeInstances] Creating an edge instance from " + edge.getSource().getName() + " to " + edge.getTarget().getName() + ".");
+ ActivityEdgeInstance edgeInstance = new ActivityEdgeInstance();
+ edgeInstance.edge = edge;
+ this.addEdgeInstance(edgeInstance);
+ this.getNodeActivation(edge.getSource()).addOutgoingEdge(edgeInstance);
+ this.getNodeActivation(edge.getTarget()).addIncomingEdge(edgeInstance);
+ // Debug.println("[createEdgeInstances] Edge instance created...");
+ }
+ List<ActivityNodeActivation> nodeActivations = this.nodeActivations;
+ for(int i = 0; i < nodeActivations.size(); i++) {
+ ActivityNodeActivation nodeActivation = nodeActivations.get(i);
+ nodeActivation.createEdgeInstances();
+ }
+ // Debug.println("[createEdgeInstances] Done creating edge instances.");
+ }
+
+ public void addEdgeInstance(ActivityEdgeInstance instance) {
+ // Add the given edge instance to this group.
+ instance.group = this;
+ this.edgeInstances.add(instance);
+ }
+
+ public ActivityExecution getActivityExecution() {
+ // Return the activity execution to which this group belongs, directly
+ // or indirectly.
+ ActivityExecution activityExecution = this.activityExecution;
+ if(activityExecution == null) {
+ activityExecution = this.containingNodeActivation.group.getActivityExecution();
+ }
+ // Debug.println("[getActivityExecution] activityExecution = " +
+ // activityExecution);
+ return activityExecution;
+ }
+
+ public List<ActivityParameterNodeActivation> getOutputParameterNodeActivations() {
+ // Return the set of all activations in this group of activity parameter
+ // nodes for output (inout, out and return) parameters.
+ List<ActivityParameterNodeActivation> parameterNodeActivations = new ArrayList<ActivityParameterNodeActivation>();
+ List<ActivityNodeActivation> nodeActivations = this.nodeActivations;
+ for(int i = 0; i < nodeActivations.size(); i++) {
+ ActivityNodeActivation activation = nodeActivations.get(i);
+ if(activation instanceof ActivityParameterNodeActivation) {
+ if(activation.incomingEdges.size() > 0) {
+ parameterNodeActivations.add((ActivityParameterNodeActivation)activation);
+ }
+ }
+ }
+ return parameterNodeActivations;
+ }
+
+ public Boolean hasSourceFor(ActivityEdgeInstance edgeInstance) {
+ // Returns true if this activation group has a node activation
+ // corresponding to the source of the given edge instance.
+ boolean hasSource = false;
+ List<ActivityNodeActivation> activations = this.nodeActivations;
+ int i = 1;
+ while(!hasSource & i <= activations.size()) {
+ hasSource = activations.get(i - 1).isSourceFor(edgeInstance);
+ i = i + 1;
+ }
+ return hasSource;
+ }
+
+ public Boolean isSuspended() {
+ // Check if this activitation group has any suspended activations and
+ // is,
+ // therefore, itself suspended.
+ return this.suspendedActivations.size() > 0;
+ }
+
+ public void suspend(ActivityNodeActivation activation) {
+ // Suspend the given activation in this activation group. If this is
+ // the only suspended activation, and the activation group has a
+ // containing node activation, then suspend that containing activation.
+ Debug.println("[suspend] node=" + (activation.node == null ? "null" : activation.node.getName()));
+ if(!this.isSuspended()) {
+ StructuredActivityNodeActivation containingNodeActivation = this.containingNodeActivation;
+ if(containingNodeActivation != null) {
+ containingNodeActivation.suspend();
+ }
+ }
+ this.suspendedActivations.add(activation);
+ }
+
+ public void resume(ActivityNodeActivation activation) {
+ // Resume the given activation by removing it from the suspended
+ // activation list for this activation group. If this is the last
+ // suspended activation, and the activation group has a containing
+ // node activation, then resume that containing activation.
+ Debug.println("[resume] node=" + (activation.node == null ? "null" : activation.node.getName()));
+ boolean found = false;
+ int i = 1;
+ while(!found & i <= this.suspendedActivations.size()) {
+ if(this.suspendedActivations.get(i - 1) == activation) {
+ this.suspendedActivations.remove(i - 1);
+ found = true;
+ }
+ i = i + 1;
+ }
+ if(!this.isSuspended()) {
+ StructuredActivityNodeActivation containingNodeActivation = this.containingNodeActivation;
+ if(containingNodeActivation != null) {
+ containingNodeActivation.resume();
+ }
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityParameterNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityParameterNodeActivation.java
new file mode 100644
index 00000000000..0f9c7d372bb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ActivityParameterNodeActivation.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.uml2.uml.ActivityParameterNode;
+import org.eclipse.uml2.uml.Parameter;
+
+public class ActivityParameterNodeActivation extends ObjectNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // If there are no incoming edges, this is an activation of an input
+ // activity parameter node.
+ // Get the values from the input parameter indicated by the activity
+ // parameter node and offer those values as object tokens.
+ if(this.node.getIncomings().size() == 0) {
+ Debug.println("[fire] Input activity parameter node " + this.node.getName() + "...");
+ Parameter parameter = ((ActivityParameterNode)(this.node)).getParameter();
+ ParameterValue parameterValue = this.getActivityExecution().getParameterValue(parameter);
+ // Debug.println("[fire] parameter = " + parameter.name);
+ if(parameterValue != null) {
+ Debug.println("[fire] Parameter has " + parameterValue.values.size() + " value(s).");
+ // List<Token> tokens = new ArrayList<Token>();
+ List<Value> values = parameterValue.values;
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ ObjectToken token = new ObjectToken();
+ token.value = value;
+ this.addToken(token);
+ }
+ this.sendUnofferedTokens();
+ }
+ }
+ // If there are one or more incoming edges, this is an activation of an
+ // output activity parameter node.
+ // Take the tokens offered on incoming edges and add them to the set of
+ // tokens being offered.
+ // [Note that an output activity parameter node may fire multiple times,
+ // accumulating tokens offered to it.]
+ else {
+ Debug.println("[fire] Output activity parameter node " + this.node.getName() + "...");
+ this.addTokens(incomingTokens);
+ }
+ }
+
+ public void clearTokens() {
+ // Clear all held tokens only if this is an input parameter node.
+ if(this.node.getIncomings().size() == 0) {
+ super.clearTokens();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlNodeActivation.java
new file mode 100644
index 00000000000..aca82d2b7f1
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlNodeActivation.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+
+public abstract class ControlNodeActivation extends ActivityNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // By default, offer all tokens on all outgoing edges.
+ if(this.node != null) {
+ Debug.println("[fire] Control node " + this.node.getName() + "...");
+ }
+ this.sendOffers(incomingTokens);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlToken.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlToken.java
new file mode 100644
index 00000000000..956eec05cfe
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ControlToken.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public class ControlToken extends Token {
+
+ public Boolean equals(Token other) {
+ // Return true if the other token is a control token, because control
+ // tokens are interchangable.
+ return other instanceof ControlToken;
+ }
+
+ public Token copy() {
+ // Return a new control token.
+ return new ControlToken();
+ }
+
+ public Boolean isControl() {
+ // Return true for a control token.
+ return true;
+ }
+
+ public Value getValue() {
+ // Control tokens do not have values.
+ return null;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/DecisionNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/DecisionNodeActivation.java
new file mode 100644
index 00000000000..5f54b89788a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/DecisionNodeActivation.java
@@ -0,0 +1,313 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+import org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.DecisionNode;
+import org.eclipse.uml2.uml.ObjectFlow;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class DecisionNodeActivation extends ControlNodeActivation {
+
+ /*
+ * The current execution of the decision input behavior (if any).
+ */
+ public Execution decisionInputExecution;
+
+ public void fire(List<Token> incomingTokens) {
+ // Inserted for connection with the debug api
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ boolean animationMarkerNeedsToBeRemoved = false ;
+ long date = 0 ;
+ this.incomingTokens_DEBUG = incomingTokens ;
+ if (locus.engine.isTerminated())
+ return ;
+ if (MokaConstants.MOKA_AUTOMATIC_ANIMATION) {
+ date = System.currentTimeMillis() ;
+ AnimationUtils.getInstance().addAnimationMarker(node) ;
+ animationMarkerNeedsToBeRemoved = true ;
+ }
+ MokaStackFrame stackFrame = FUMLPresentationUtils.getMokaStackFrame(this) ;
+ stackFrame.setThread(locus.mainThread) ;
+ stackFrame.setName(this.node.getName()) ;
+ StackFrameManager.getInstance().setStackFrame(this.getActivityExecution(), stackFrame) ;
+ int reasonForSuspending = FUMLExecutionEngine.controlDelegate.shallSuspend(this.getActivityExecution(), this) ;
+ if (reasonForSuspending != -1) {
+ locus.mainThread.setSuspended(true) ;
+ locus.mainThread.setStackFrames(null) ;
+ //locus.stackFrames = new MokaStackFrame[]{stackFrame} ;
+ locus.stackFrames = StackFrameManager.getInstance().getStackFrames() ;
+ Suspend_Event breakpointEvent = new Suspend_Event(locus.mainThread, reasonForSuspending, new MokaThread[]{locus.mainThread}) ;
+ locus.engine.sendEvent(breakpointEvent) ;
+ try {
+ FUMLExecutionEngine.controlDelegate.suspend(this.getActivityExecution()) ;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ locus.mainThread.setSuspended(false) ;
+ }
+ if (animationMarkerNeedsToBeRemoved) {
+ try {
+ long ellapsed = System.currentTimeMillis() - date ;
+ long delay = Math.max(1,MokaConstants.MOKA_ANIMATION_DELAY - ellapsed) ;
+ Thread.sleep(delay) ;
+ } catch (InterruptedException e1) {
+ Activator.log.error(e1);
+ }
+ AnimationUtils.getInstance().removeAnimationMarker(node) ;
+ }
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Get the decision values and test them on each guard.
+ // Forward the offer over the edges for which the test succeeds.
+ Debug.println("[fire] Decision node " + this.node.getName() + "...");
+ // List<Token> incomingTokens = this.takeOfferedTokens();
+ List<Token> removedControlTokens = this.removeJoinedControlTokens(incomingTokens);
+ List<Value> decisionValues = this.getDecisionValues(incomingTokens);
+ List<ActivityEdgeInstance> outgoingEdges = this.outgoingEdges;
+ for(int i = 0; i < outgoingEdges.size(); i++) {
+ ActivityEdgeInstance edgeInstance = outgoingEdges.get(i);
+ ValueSpecification guard = edgeInstance.edge.getGuard();
+ List<Token> offeredTokens = new ArrayList<Token>();
+ for(int j = 0; j < incomingTokens.size(); j++) {
+ Token incomingToken = incomingTokens.get(j);
+ Value decisionValue = decisionValues.get(j);
+ if(this.test(guard, decisionValue)) {
+ offeredTokens.add(incomingToken);
+ }
+ }
+ if(offeredTokens.size() > 0) {
+ for(int j = 0; j < removedControlTokens.size(); j++) {
+ Token removedControlToken = removedControlTokens.get(j);
+ offeredTokens.add(removedControlToken);
+ }
+ edgeInstance.sendOffer(offeredTokens);
+ }
+ }
+ }
+
+ public List<Value> getDecisionValues(List<Token> incomingTokens) {
+ // If there is neither a decision input flow nor a decision input
+ // behavior, then return the set of values from the incoming tokens.
+ // [In this case, the single incoming edge must be an object flow.]
+ // If there is a decision input flow, but no decision input behavior,
+ // then return a list of the decision input values equal in size to the
+ // number of incoming tokens.
+ // If there is both a decision input flow and a decision input behavior,
+ // then execute the decision input behavior once for each incoming token
+ // and return the set of resulting values.
+ // If the primary incoming edge is an object flow, then the value on
+ // each object token is passed to the decision input behavior, along
+ // with the decision input flow value, if any.
+ // If the primary incoming edge is a control flow, then the decision
+ // input behavior only receives the decision input flow, if any.
+ Value decisionInputValue = this.getDecisionInputFlowValue();
+ List<Value> decisionValues = new ArrayList<Value>();
+ for(int i = 0; i < incomingTokens.size(); i++) {
+ Token incomingToken = incomingTokens.get(i);
+ Value value = this.executeDecisionInputBehavior(incomingToken.getValue(), decisionInputValue);
+ decisionValues.add(value);
+ }
+ // Debug.println("[getDecisionValues] " + decisionValues.size() +
+ // " decision value(s):");
+ for(int i = 0; i < decisionValues.size(); i++) {
+ Value decisionValue = decisionValues.get(i);
+ Debug.println("[getDecisionValues] decisionValues[" + i + "] = " + decisionValue);
+ }
+ return decisionValues;
+ }
+
+ public Value executeDecisionInputBehavior(Value inputValue, Value decisionInputValue) {
+ // Create the decision input execution from the decision input behavior.
+ // If the behavior has input parameter(s), set the input parameter(s) of
+ // the execution to the given value(s).
+ // Execute the decision input execution and then remove it.
+ // Return the value of the output parameter of the execution.
+ // If there is no decision input behavior, the decision input value is
+ // returned, if one is given, otherwise the input value is used as the
+ // decision value.
+ Debug.println("[executeDecisionBehavior] inputValue = " + inputValue);
+ Behavior decisionInputBehavior = ((DecisionNode)(this.node)).getDecisionInput();
+ Value decisionInputResult = null;
+ if(decisionInputBehavior == null) {
+ if(decisionInputValue != null) {
+ decisionInputResult = decisionInputValue;
+ } else {
+ decisionInputResult = inputValue;
+ }
+ } else {
+ this.decisionInputExecution = this.getExecutionLocus().factory.createExecution(decisionInputBehavior, this.getExecutionContext());
+ int i = 1;
+ int j = 0;
+ while((j == 0 | (j == 1 & decisionInputValue != null)) & i <= decisionInputBehavior.getOwnedParameters().size()) {
+ Parameter parameter = decisionInputBehavior.getOwnedParameters().get(i - 1);
+ if(parameter.getDirection().equals(ParameterDirectionKind.IN_LITERAL) | parameter.getDirection().equals(ParameterDirectionKind.INOUT_LITERAL)) {
+ ParameterValue inputParameterValue = new ParameterValue();
+ inputParameterValue.parameter = parameter;
+ j = j + 1;
+ if(j == 1 && inputValue != null) {
+ inputParameterValue.values.add(inputValue);
+ } else {
+ inputParameterValue.values.add(decisionInputValue);
+ }
+ this.decisionInputExecution.setParameterValue(inputParameterValue);
+ }
+ i = i + 1;
+ }
+ this.decisionInputExecution.execute();
+ List<ParameterValue> outputParameterValues = this.decisionInputExecution.getOutputParameterValues();
+ decisionInputExecution.destroy();
+ decisionInputResult = outputParameterValues.get(0).values.get(0);
+ }
+ return decisionInputResult;
+ }
+
+ public void terminate() {
+ // Terminate the decision input execution, if any, and then terminate
+ // this activation.
+ if(this.decisionInputExecution != null) {
+ this.decisionInputExecution.terminate();
+ }
+ super.terminate();
+ }
+
+ public Boolean isReady() {
+ // Check that all incoming edges have sources that are offering tokens.
+ // [This should be at most two incoming edges, if there is a decision
+ // input flow.]
+ int i = 1;
+ boolean ready = true;
+ while(ready & i <= this.incomingEdges.size()) {
+ ready = this.incomingEdges.get(i - 1).hasOffer();
+ i = i + 1;
+ }
+ return ready;
+ }
+
+ public List<Token> takeOfferedTokens() {
+ // Get tokens from the incoming edge that is not the decision input
+ // flow.
+ ObjectFlow decisionInputFlow = ((DecisionNode)(this.node)).getDecisionInputFlow();
+ List<Token> allTokens = new ArrayList<Token>();
+ List<ActivityEdgeInstance> incomingEdges = this.incomingEdges;
+ for(int i = 0; i < incomingEdges.size(); i++) {
+ ActivityEdgeInstance edgeInstance = incomingEdges.get(i);
+ if(edgeInstance.edge != decisionInputFlow) {
+ List<Token> tokens = edgeInstance.takeOfferedTokens();
+ for(int j = 0; j < tokens.size(); j++) {
+ allTokens.add(tokens.get(j));
+ }
+ }
+ }
+ return allTokens;
+ }
+
+ public Value getDecisionInputFlowValue() {
+ // Take the next token available on the decision input flow, if any, and
+ // return its value.
+ ActivityEdgeInstance decisionInputFlowInstance = this.getDecisionInputFlowInstance();
+ Value value = null;
+ if(decisionInputFlowInstance != null) {
+ List<Token> tokens = decisionInputFlowInstance.takeOfferedTokens();
+ if(tokens.size() > 0) {
+ value = tokens.get(0).getValue();
+ }
+ }
+ return value;
+ }
+
+ public ActivityEdgeInstance getDecisionInputFlowInstance() {
+ // Get the activity edge instance for the decision input flow, if any.
+ ActivityEdge decisionInputFlow = ((DecisionNode)(this.node)).getDecisionInputFlow();
+ ActivityEdgeInstance edgeInstance = null;
+ if(decisionInputFlow != null) {
+ int i = 1;
+ while(edgeInstance == null & i <= this.incomingEdges.size()) {
+ ActivityEdgeInstance incomingEdge = this.incomingEdges.get(i - 1);
+ if(incomingEdge.edge == decisionInputFlow) {
+ edgeInstance = incomingEdge;
+ }
+ i = i + 1;
+ }
+ }
+ return edgeInstance;
+ }
+
+ public Boolean test(ValueSpecification guard, Value value) {
+ // Test if the given value matches the guard. If there is no guard,
+ // return true.
+ boolean guardResult = true;
+ if(guard != null) {
+ Value guardValue = this.getExecutionLocus().executor.evaluate(guard);
+ guardResult = guardValue.equals(value);
+ }
+ return guardResult;
+ }
+
+ public List<Token> removeJoinedControlTokens(List<Token> incomingTokens) {
+ // If the primary incoming edge is an object flow, then remove any
+ // control tokens from the incoming tokens and return them.
+ // [Control tokens may effectively be offered on an object flow outgoing
+ // from a join node that has both control and object flows incoming.]
+ List<Token> removedControlTokens = new ArrayList<Token>();
+ if(this.hasObjectFlowInput()) {
+ int i = 1;
+ while(i <= incomingTokens.size()) {
+ Token token = incomingTokens.get(i - 1);
+ if(token.isControl()) {
+ removedControlTokens.add(token);
+ incomingTokens.remove(i - 1);
+ i = i - 1;
+ }
+ i = i + 1;
+ }
+ }
+ return removedControlTokens;
+ }
+
+ public Boolean hasObjectFlowInput() {
+ // Check that the primary incoming edge is an object flow.
+ ActivityEdge decisionInputFlow = ((DecisionNode)(this.node)).getDecisionInputFlow();
+ boolean isObjectFlow = false;
+ int i = 1;
+ while(!isObjectFlow & i <= this.incomingEdges.size()) {
+ ActivityEdge edge = this.incomingEdges.get(i - 1).edge;
+ isObjectFlow = edge != decisionInputFlow & edge instanceof ObjectFlow;
+ i = i + 1;
+ }
+ return isObjectFlow;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/FlowFinalNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/FlowFinalNodeActivation.java
new file mode 100644
index 00000000000..f08df12bb25
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/FlowFinalNodeActivation.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+
+public class FlowFinalNodeActivation extends ControlNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Consume all incoming tokens.
+ Debug.println("[fire] Flow final node " + this.node.getName() + "...");
+ for(int i = 0; i < incomingTokens.size(); i++) {
+ Token token = incomingTokens.get(i);
+ token.withdraw();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkNodeActivation.java
new file mode 100644
index 00000000000..6f1f2852d32
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkNodeActivation.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+
+public class ForkNodeActivation extends ControlNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ if (this.group != null) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ }
+ // Create forked tokens for all incoming tokens and offer them on all
+ // outgoing edges.
+ if(this.node == null) {
+ Debug.println("[fire] Anonymous fork node.");
+ } else {
+ Debug.println("[fire] Fork node " + this.node.getName() + "...");
+ }
+ List<ActivityEdgeInstance> outgoingEdges = this.outgoingEdges;
+ int outgoingEdgeCount = outgoingEdges.size();
+ List<Token> forkedTokens = new ArrayList<Token>();
+ for(int i = 0; i < incomingTokens.size(); i++) {
+ Token token = incomingTokens.get(i);
+ ForkedToken forkedToken = new ForkedToken();
+ forkedToken.baseToken = token;
+ forkedToken.remainingOffersCount = outgoingEdgeCount;
+ forkedToken.baseTokenIsWithdrawn = false;
+ forkedTokens.add(forkedToken);
+ }
+ this.addTokens(forkedTokens);
+ this.sendOffers(forkedTokens);
+ }
+
+ public void terminate() {
+ // Remove any offered tokens and terminate.
+ this.clearTokens();
+ super.terminate();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkedToken.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkedToken.java
new file mode 100644
index 00000000000..4a34e88eef6
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ForkedToken.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public class ForkedToken extends Token {
+
+ public Token baseToken;
+
+ /*
+ * The remaining number of outstanding offers for this token on outgoing
+ * edges of the fork node.
+ */
+ public Integer remainingOffersCount;
+
+ /*
+ * Indicates whether withdraw() has been called on the base token.
+ */
+ public Boolean baseTokenIsWithdrawn;
+
+ public Boolean isControl() {
+ // Test if the base token is a control token.
+ return this.baseToken.isControl();
+ }
+
+ public void withdraw() {
+ // If the base token is not withdrawn, then withdraw it.
+ // Decrement the remaining offers count.
+ // When the remaining number of offers is zero, then remove this token
+ // from its holder.
+ if(!this.baseTokenIsWithdrawn & !this.baseToken.isWithdrawn()) {
+ this.baseToken.withdraw();
+ // NOTE: This keeps a base token that is a forked token from being
+ // withdrawn more than once, since withdrawing a forked token may
+ // not actually remove it from its fork node holder.
+ this.baseTokenIsWithdrawn = true;
+ }
+ if(this.remainingOffersCount > 0) {
+ this.remainingOffersCount = this.remainingOffersCount - 1;
+ }
+ if(this.remainingOffersCount == 0) {
+ super.withdraw();
+ }
+ }
+
+ public Token copy() {
+ // Return a copy of the base token.
+ return this.baseToken.copy();
+ }
+
+ public Boolean equals(Token otherToken) {
+ // Test if this token is equal to another token.
+ return this == otherToken;
+ }
+
+ public Value getValue() {
+ // Return the value of the base token.
+ return this.baseToken.getValue();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/InitialNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/InitialNodeActivation.java
new file mode 100644
index 00000000000..51c40f7ac07
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/InitialNodeActivation.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+
+public class InitialNodeActivation extends ControlNodeActivation {
+
+ public void fire(List<Token> incomingTokens) {
+ super.fire(incomingTokens) ;
+ Locus locus = this.getExecutionLocus() ;
+ if (locus.isInDebugMode) {
+ if (locus.engine.isTerminated())
+ return ;
+ }
+ // Create a single token and send offers for it.
+ List<Token> tokens = new ArrayList<Token>();
+ tokens.add(new ControlToken());
+ this.addTokens(tokens);
+ this.sendOffers(tokens);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/JoinNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/JoinNodeActivation.java
new file mode 100644
index 00000000000..c2e6058fc64
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/JoinNodeActivation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+public class JoinNodeActivation extends ControlNodeActivation {
+
+ public Boolean isReady() {
+ // Check that all incoming edges have sources that are offering tokens.
+ boolean ready = true;
+ int i = 1;
+ while(ready & i <= this.incomingEdges.size()) {
+ ready = this.incomingEdges.get(i - 1).hasOffer();
+ i = i + 1;
+ }
+ return ready;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/MergeNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/MergeNodeActivation.java
new file mode 100644
index 00000000000..283956b1db0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/MergeNodeActivation.java
@@ -0,0 +1,17 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+public class MergeNodeActivation extends ControlNodeActivation {
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectNodeActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectNodeActivation.java
new file mode 100644
index 00000000000..99d2b602241
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectNodeActivation.java
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ObjectNodeActivation extends ActivityNodeActivation {
+
+ /*
+ * The number of held tokens that have already been offered.
+ */
+ public Integer offeredTokenCount;
+
+ public void run() {
+ // Initialize the offered token count to zero.
+ super.run();
+ this.offeredTokenCount = 0;
+ }
+
+ public void sendOffers(List<Token> tokens) {
+ // If the set of tokens to be sent is empty, then offer a null token
+ // instead.
+ // Otherwise, offer the given tokens as usual.
+ if(tokens.size() == 0) {
+ ObjectToken token = new ObjectToken();
+ token.holder = this;
+ tokens.add(token);
+ }
+ super.sendOffers(tokens);
+ }
+
+ public void terminate() {
+ // Remove any offered tokens and terminate.
+ this.clearTokens();
+ super.terminate();
+ }
+
+ public void addToken(Token token) {
+ // Transfer the given token to be held by this node only if it is a
+ // non-null object token.
+ // If it is a control token or a null token, consume it without holding
+ // it.
+ if(token.getValue() == null) {
+ token.withdraw();
+ } else {
+ super.addToken(token);
+ }
+ }
+
+ public Integer removeToken(Token token) {
+ // Remove the given token, if it is held by this node activation.
+ int i = super.removeToken(token);
+ if(i > 0 & i <= this.offeredTokenCount) {
+ this.offeredTokenCount = this.offeredTokenCount - 1;
+ }
+ return i;
+ }
+
+ public void clearTokens() {
+ // Remove all held tokens.
+ super.clearTokens();
+ this.offeredTokenCount = 0;
+ }
+
+ public Integer countOfferedValues() {
+ // Count the total number of non-null object tokens being offered to
+ // this node activation.
+ int totalValueCount = 0;
+ int i = 1;
+ while(i <= this.incomingEdges.size()) {
+ totalValueCount = totalValueCount + this.incomingEdges.get(i - 1).countOfferedValues();
+ i = i + 1;
+ }
+ return totalValueCount;
+ }
+
+ public void sendUnofferedTokens() {
+ // Send offers over all outgoing edges, if there are any tokens to be
+ // offered.
+ List<Token> tokens = this.getUnofferedTokens();
+ this.offeredTokenCount = this.offeredTokenCount + tokens.size();
+ this.sendOffers(tokens);
+ }
+
+ public Integer countUnofferedTokens() {
+ // Return the number of unoffered tokens that are to be offered next.
+ // (By default, this is all unoffered tokens.)
+ if(this.heldTokens.size() == 0) {
+ this.offeredTokenCount = 0;
+ }
+ return this.heldTokens.size() - this.offeredTokenCount;
+ }
+
+ public List<Token> getUnofferedTokens() {
+ // Get the next set of unoffered tokens to be offered and return it.
+ // [Note: This effectively treats all object flows as if they have
+ // weight=*, rather than the weight=1 default in the current
+ // superstructure semantics.]
+ List<Token> tokens = new ArrayList<Token>();
+ int i = 1;
+ while(i <= this.countUnofferedTokens()) {
+ tokens.add(this.heldTokens.get(this.offeredTokenCount + i - 1));
+ i = i + 1;
+ }
+ return tokens;
+ }
+
+ public List<Token> takeUnofferedTokens() {
+ // Take the next set of unoffered tokens to be offered from this node
+ // activation and return them.
+ List<Token> tokens = this.getUnofferedTokens();
+ for(int i = 0; i < tokens.size(); i++) {
+ Token token = tokens.get(i);
+ token.withdraw();
+ }
+ return tokens;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectToken.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectToken.java
new file mode 100644
index 00000000000..ddee2aa78a8
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/ObjectToken.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public class ObjectToken extends Token {
+
+ /*
+ * The value carried by this token. A token may have no value, in which case
+ * it is a "null token".
+ */
+ public Value value;
+
+ public Boolean equals(Token other) {
+ // Test if this object token is the same as the other token.
+ return this == other;
+ }
+
+ public Token copy() {
+ // Return a new object token with the same value as this token.
+ // [Note: the holder of the copy is not set.]
+ ObjectToken copy = new ObjectToken();
+ copy.value = this.value;
+ return copy;
+ }
+
+ public Boolean isControl() {
+ // Return false for an object token.
+ return false;
+ }
+
+ public Value getValue() {
+ // Return the value of this object token.
+ return this.value;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Offer.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Offer.java
new file mode 100644
index 00000000000..4b9c1af6e6d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Offer.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Offer {
+
+ public List<Token> offeredTokens = new ArrayList<Token>();
+
+ public Integer countOfferedValues() {
+ // Return the number of values being offered on object tokens.
+ // Remove any tokens that have already been withdrawn and don't include
+ // them in the count.
+ this.removeWithdrawnTokens();
+ int count = 0;
+ for(int i = 0; i < this.offeredTokens.size(); i++) {
+ if(this.offeredTokens.get(i).getValue() != null) {
+ count = count + 1;
+ }
+ }
+ return count;
+ }
+
+ public List<Token> getOfferedTokens() {
+ // Get the offered tokens, removing any that have been withdrawn.
+ this.removeWithdrawnTokens();
+ List<Token> tokens = new ArrayList<Token>();
+ List<Token> offeredTokens = this.offeredTokens;
+ for(int i = 0; i < this.offeredTokens.size(); i++) {
+ Token offeredToken = offeredTokens.get(i);
+ // Debug.println("[getOfferedTokens] token value = " +
+ // offeredToken.getValue());
+ tokens.add(offeredToken);
+ }
+ return tokens;
+ }
+
+ public void removeOfferedValues(Integer count) {
+ // Remove the given number of non-null object tokens from those in this
+ // offer.
+ int n = count;
+ int i = 1;
+ while(n > 0) {
+ if(this.offeredTokens.get(i - 1).getValue() != null) {
+ this.offeredTokens.remove(i - 1);
+ } else {
+ i = i + 1;
+ }
+ n = n - 1;
+ }
+ }
+
+ public void removeWithdrawnTokens() {
+ // Remove any tokens that have already been consumed.
+ // List<Token> offeredTokens = this.offeredTokens;
+ int i = 1;
+ while(i <= this.offeredTokens.size()) {
+ if(this.offeredTokens.get(i - 1).isWithdrawn()) {
+ this.offeredTokens.remove(i - 1);
+ i = i - 1;
+ }
+ i = i + 1;
+ }
+ }
+
+ public Boolean hasTokens() {
+ // Check whether this offer has any tokens that have not been withdrawn.
+ this.removeWithdrawnTokens();
+ return this.offeredTokens.size() > 0;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Token.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Token.java
new file mode 100644
index 00000000000..7a9887aced3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Activities/IntermediateActivities/Token.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+
+public abstract class Token {
+
+ public ActivityNodeActivation holder;
+
+ public Token transfer(ActivityNodeActivation holder) {
+ // if this token does not have any holder, make the given holder its
+ // holder.
+ // Otherwise, remove this token from its holder and return a copy of it
+ // transfered to a new holder.
+ Token token = this;
+ if(this.holder != null) {
+ this.withdraw();
+ token = this.copy();
+ }
+ token.holder = holder;
+ return token;
+ }
+
+ public void withdraw() {
+ // Remove this token from its holder, withdrawing any offers for it.
+ if(!this.isWithdrawn()) {
+ // Debug.println("[withdraw] Taking token with value = " +
+ // this.getValue());
+ this.holder.removeToken(this);
+ this.holder = null;
+ }
+ }
+
+ public abstract Boolean equals(Token other);
+
+ public abstract Token copy();
+
+ public Boolean isWithdrawn() {
+ // Test if this token has been withdrawn.
+ return this.holder == null;
+ }
+
+ public abstract Boolean isControl();
+
+ public abstract Value getValue();
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/BooleanValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/BooleanValue.java
new file mode 100644
index 00000000000..ee4eb384df6
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/BooleanValue.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralBoolean;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class BooleanValue extends PrimitiveValue {
+
+ /*
+ * The actual Boolean value.
+ */
+ public Boolean value;
+
+ public ValueSpecification specify() {
+ // Return a literal boolean with the value of this boolean value.
+ LiteralBoolean literal = UMLFactory.eINSTANCE.createLiteralBoolean();
+ literal.setType(this.type);
+ literal.setValue(this.value);
+ return literal;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this boolean value is equal to the otherValue.
+ // To be equal, the otherValue must have the same value as this boolean
+ // value.
+ boolean isEqual = false;
+ if(otherValue instanceof BooleanValue) {
+ isEqual = ((BooleanValue)otherValue).value.equals(this.value); // CHANGED == to equals;
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new boolean value with the same value as this boolean value.
+ BooleanValue newValue = (BooleanValue)(super.copy());
+ newValue.value = this.value;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Return a new boolean value with no value.
+ return new BooleanValue();
+ }
+
+ public String toString() {
+ String stringValue = "false";
+ if(this.value) {
+ stringValue = "true";
+ }
+ return stringValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/CompoundValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/CompoundValue.java
new file mode 100644
index 00000000000..926636b5ef3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/CompoundValue.java
@@ -0,0 +1,150 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public abstract class CompoundValue extends StructuredValue {
+
+ public List<FeatureValue> featureValues = new ArrayList<FeatureValue>();
+
+ public Boolean equals(Value otherValue) {
+ // Test if this data value is equal to the otherValue.
+ // To be equal, the otherValue must also be a compund value with the
+ // same types and equal values for each feature.
+ // Debug.println("[equals] othervalue instanceof CompoundValue = " +
+ // (otherValue instanceof CompoundValue));
+ // Debug.println("[equals] super.equals(otherValue) = " +
+ // super.equals(otherValue));
+ boolean isEqual = otherValue instanceof CompoundValue;
+ if(isEqual) {
+ CompoundValue otherCompoundValue = (CompoundValue)otherValue;
+ // Debug.println("[equals] " + this.featureValues.size() +
+ // " feature(s).");
+ isEqual = super.equals(otherValue) & otherCompoundValue.featureValues.size() == this.featureValues.size();
+ int i = 1;
+ while(isEqual & i <= this.featureValues.size()) {
+ FeatureValue thisFeatureValue = this.featureValues.get(i - 1);
+ boolean matched = false;
+ int j = 1;
+ while(!matched & j <= otherCompoundValue.featureValues.size()) {
+ FeatureValue otherFeatureValue = otherCompoundValue.featureValues.get(j - 1);
+ if(thisFeatureValue.feature == otherFeatureValue.feature) {
+ matched = thisFeatureValue.hasEqualValues(otherFeatureValue);
+ }
+ j = j + 1;
+ }
+ isEqual = matched;
+ i = i + 1;
+ }
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new data value with the same featureValues as this data
+ // value.
+ CompoundValue newValue = (CompoundValue)(super.copy());
+ List<FeatureValue> featureValues = this.featureValues;
+ for(int i = 0; i < featureValues.size(); i++) {
+ FeatureValue featureValue = featureValues.get(i);
+ newValue.featureValues.add(featureValue.copy());
+ }
+ return newValue;
+ }
+
+ public FeatureValue getFeatureValue(StructuralFeature feature) {
+ // Get the value(s) of the member of featureValues for the given
+ // feature.
+ FeatureValue featureValue = null;
+ int i = 1;
+ while(featureValue == null & i <= this.featureValues.size()) {
+ if(this.featureValues.get(i - 1).feature == feature) {
+ featureValue = this.featureValues.get(i - 1);
+ }
+ i = i + 1;
+ }
+ return featureValue;
+ }
+
+ public void setFeatureValue(StructuralFeature feature, List<Value> values, Integer position) {
+ // Set the value(s) of the member of featureValues for the given
+ // feature.
+ FeatureValue featureValue = this.getFeatureValue(feature);
+ if(featureValue == null) {
+ featureValue = new FeatureValue();
+ this.featureValues.add(featureValue);
+ }
+ featureValue.feature = feature;
+ featureValue.values = values;
+ featureValue.position = position;
+ }
+
+ public List<FeatureValue> getFeatureValues() {
+ // Return the feature values for this compound value.
+ return this.featureValues;
+ }
+
+ public void removeFeatureValues(Classifier classifier) {
+ // Remove all feature values for features whose type is the given
+ // classifier.
+ int i = 1;
+ while(i <= this.featureValues.size()) {
+ if(this.featureValues.get(i - 1).feature.getType() == classifier) {
+ this.featureValues.remove(i - 1);
+ } else {
+ i = i + 1;
+ }
+ }
+ }
+
+ public String toString() {
+ String buffer = "(" + this.objectId() + ":";
+ List<Classifier> types = this.getTypes();
+ int i = 1;
+ while(i <= types.size()) {
+ buffer = buffer + " " + types.get(i - 1).getName();
+ i = i + 1;
+ }
+ int k = 1;
+ while(k <= this.featureValues.size()) {
+ FeatureValue featureValue = this.featureValues.get(k - 1);
+ buffer = buffer + "\n\t\t" + featureValue.feature.getName() + "[" + featureValue.position + "] =";
+ int j = 1;
+ while(j <= featureValue.values.size()) {
+ Value value = featureValue.values.get(j - 1);
+ if (value instanceof Reference) {
+ Object_ object = ((Reference)value).referent;
+ buffer = buffer + " Reference to (" + object.objectId() + ":";
+ types = object.getTypes();
+ int n = 1;
+ while (n <= types.size()) {
+ buffer = buffer + " " + types.get(n - 1).getName();
+ n = n + 1;
+ }
+ buffer = buffer + ")";
+ } else {
+ buffer = buffer + " " + value.toString();
+ }
+ j = j + 1;
+ }
+ k = k + 1;
+ }
+ return buffer + ")";
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DataValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DataValue.java
new file mode 100644
index 00000000000..2585ed45dbe
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DataValue.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.DataType;
+
+public class DataValue extends CompoundValue {
+
+ /*
+ * The type of this data value. This must not be a primitive or an
+ * enumeration.
+ */
+ public DataType type;
+
+ public List<Classifier> getTypes() {
+ // Return the single type of this data value.
+ List<Classifier> types = new ArrayList<Classifier>();
+ types.add(this.type);
+ return types;
+ }
+
+ public Value copy() {
+ // Create a new data value with the same type and feature values as this
+ // data value.
+ DataValue newValue = (DataValue)(super.copy());
+ newValue.type = this.type;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new data value with no type or feature values.
+ return new DataValue();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DispatchStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DispatchStrategy.java
new file mode 100644
index 00000000000..a8c5801858f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/DispatchStrategy.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticStrategy;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Operation;
+
+public abstract class DispatchStrategy extends SemanticStrategy {
+
+ public String getName() {
+ // Dispatch strategies are always named "dispatch".
+ return "dispatch";
+ }
+
+ public Execution dispatch(Object_ object, Operation operation) {
+ // Get the behavior for the given operation as determined by the type(s)
+ // of the given object, compile the behavior at the locus of the object,
+ // and return the resulting execution object.
+ return object.locus.factory.createExecution(this.getMethod(object, operation), object);
+ }
+
+ public abstract Behavior getMethod(Object_ object, Operation operation);
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/EnumerationValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/EnumerationValue.java
new file mode 100644
index 00000000000..07be5e8dac1
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/EnumerationValue.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class EnumerationValue extends Value {
+
+ /*
+ * The literal value of this enumeration value.
+ */
+ public EnumerationLiteral literal;
+
+ public Enumeration type;
+
+ public ValueSpecification specify() {
+ // Return an instance value with literal as the instance.
+ InstanceValue instanceValue = UMLFactory.eINSTANCE.createInstanceValue();
+ // InstanceSpecification instance =
+ // UMLFactory.eINSTANCE.createInstanceSpecification();
+ instanceValue.setType(this.type);
+ instanceValue.setInstance(this.literal);
+ return instanceValue;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this enumeration value is equal to the otherValue.
+ // To be equal, the otherValue must also be an enumeration value with
+ // the same literal as this enumeration value.
+ boolean isEqual = false;
+ if(otherValue instanceof EnumerationValue) {
+ isEqual = ((EnumerationValue)otherValue).literal == this.literal;
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new enumeration value with the same literal as this
+ // enumeration value.
+ EnumerationValue newValue = (EnumerationValue)(super.copy());
+ newValue.type = this.type;
+ newValue.literal = this.literal;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new enumeration value with no literal.
+ return new EnumerationValue();
+ }
+
+ public List<Classifier> getTypes() {
+ // Return the single type of this enumeration value.
+ List<Classifier> types = new ArrayList<Classifier>();
+ types.add(this.type);
+ return types;
+ }
+
+ public String toString() {
+ return literal.getName();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Evaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Evaluation.java
new file mode 100644
index 00000000000..4f4f3d14f84
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Evaluation.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticVisitor;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public abstract class Evaluation extends SemanticVisitor {
+
+ /*
+ * The value specification to be evaluated.
+ */
+ public ValueSpecification specification;
+
+ /*
+ * The locus at which this evaluation is taking place.
+ */
+ public Locus locus;
+
+ public abstract Value evaluate();
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/ExtensionalValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/ExtensionalValue.java
new file mode 100644
index 00000000000..bef54d38e84
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/ExtensionalValue.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+
+public abstract class ExtensionalValue extends CompoundValue {
+
+ /*
+ * The locus of the extent of which this value is a member. (If the value
+ * has been destroyed, it has no locus.)
+ */
+ public Locus locus;
+
+ public void destroy() {
+ // Remove this value from its locus (if it has not already been
+ // destroyed).
+ if(this.locus != null) {
+ this.locus.remove(this);
+ }
+ }
+
+ public Value copy() {
+ // Create a new extensional value with the same feature values at the
+ // same locus as this one.
+ ExtensionalValue newValue = (ExtensionalValue)(super.copy());
+ if(this.locus != null) {
+ this.locus.add(newValue);
+ }
+ return newValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/FeatureValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/FeatureValue.java
new file mode 100644
index 00000000000..0c6579be295
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/FeatureValue.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class FeatureValue {
+
+ /*
+ * The structural feature being given value(s).
+ */
+ public StructuralFeature feature;
+
+ /*
+ * The values of for the feature. Zero or more values are possible, as
+ * constrained by the multiplicity of the feature.
+ */
+ public List<Value> values = new ArrayList<Value>();
+
+ /*
+ * The position of this feature value in a set of ordered values for a
+ * feature of an association. [This is only relevant if the feature value is
+ * for a link and the feature is ordered.]
+ */
+ public Integer position;
+
+ public Boolean hasEqualValues(FeatureValue other) {
+ // Determine if this feature value has an equal set of values as another
+ // feature value.
+ // If the feature is ordered, then the values also have to be in the
+ // same order.
+ boolean equal = true;
+ if(this.values.size() != other.values.size()) {
+ equal = false;
+ } else {
+ // Debug.println("[hasEqualValues] feature = " + this.feature.name +
+ // ", " + this.values.size() + " value(s).");
+ if(this.feature.isOrdered()) {
+ int i = 1;
+ while(equal & i <= this.values.size()) {
+ equal = this.values.get(i - 1).equals(other.values.get(i - 1));
+ i = i + 1;
+ }
+ } else {
+ // Note: otherFeatureValues is used here solely as a holder for
+ // a copy of the list of other values,
+ // since the Java to UML mapping conventions do not allow
+ // "remove" on a local list variable.
+ FeatureValue otherFeatureValues = new FeatureValue();
+ List<Value> values = other.values;
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ otherFeatureValues.values.add(value);
+ }
+ int i = 1;
+ while(equal & i <= this.values.size()) {
+ // Debug.println("[hasEqualValues] This value [" + (i-1) +
+ // "] = " + this.values.get(i-1));
+ boolean matched = false;
+ int j = 1;
+ while(!matched & j <= otherFeatureValues.values.size()) {
+ if(this.values.get(i - 1).equals(otherFeatureValues.values.get(j - 1))) {
+ // Debug.println("[hasEqualValues] Other value [" +
+ // (j-1) + "] = " +
+ // otherFeatureValues.values.get(j-1));
+ matched = true;
+ otherFeatureValues.values.remove(j - 1);
+ }
+ j = j + 1;
+ }
+ equal = matched;
+ i = i + 1;
+ }
+ }
+ }
+ return equal;
+ }
+
+ public FeatureValue copy() {
+ // Create a copy of this feature value.
+ FeatureValue newValue = new FeatureValue();
+ newValue.feature = this.feature;
+ newValue.position = this.position;
+ List<Value> values = this.values;
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ newValue.values.add(value.copy());
+ }
+ return newValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/InstanceValueEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/InstanceValueEvaluation.java
new file mode 100644
index 00000000000..18db33d1d8a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/InstanceValueEvaluation.java
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.Slot;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class InstanceValueEvaluation extends Evaluation {
+
+ public Value evaluate() {
+ // If the instance specification is for an enumeration, then return the
+ // identified enumeration literal.
+ // If the instance specification is for a data type (but not a primitive
+ // value or an enumeration), then create a data value of the given data
+ // type.
+ // If the instance specification is for an object, then create an object
+ // at the current locus with the specified types.
+ // Set each feature of the created value to the result of evaluating the
+ // value specifications for the specified slot for the feature.
+ // Debug.println("[evaluate] InstanceValueEvaluation...");
+ InstanceSpecification instance = ((InstanceValue)this.specification).getInstance();
+ // List<Classifier> types = instance.getClassifiers();
+ // Classifier myType = types.get(0);
+ // Debug.println("[evaluate] type = " + myType.getName());
+ Value value;
+ if(instance instanceof EnumerationLiteral) {
+ // Debug.println("[evaluate] Type is an enumeration.");
+ EnumerationValue enumerationValue = new EnumerationValue();
+ // enumerationValue.type = (Enumeration)myType;
+ enumerationValue.type = ((EnumerationLiteral)instance).getEnumeration(); // ADDED
+ enumerationValue.literal = (EnumerationLiteral)instance;
+ value = enumerationValue;
+ Debug.println("[evaluate] type = " + enumerationValue.type.getName()); // ADDED
+ } else {
+ // ADDED:
+ List<Classifier> types = instance.getClassifiers();
+ Classifier myType = types.get(0);
+ Debug.println("[evaluate] type = " + myType.getName());
+ //
+ StructuredValue structuredValue = null;
+ if(myType instanceof DataType) {
+ // Debug.println("[evaluate] Type is a data type.");
+ DataValue dataValue = new DataValue();
+ dataValue.type = (DataType)myType;
+ structuredValue = dataValue;
+ } else {
+ Object_ object = null;
+ if(myType instanceof Behavior) {
+ // Debug.println("[evaluate] Type is a behavior.");
+ object = this.locus.factory.createExecution((Behavior)myType, null);
+ } else {
+ // Debug.println("[evaluate] Type is a class.");
+ object = new Object_();
+ for(int i = 0; i < types.size(); i++) {
+ Classifier type = types.get(i);
+ object.types.add((Class)type);
+ }
+ }
+ this.locus.add(object);
+ Reference reference = new Reference();
+ reference.referent = object;
+ structuredValue = reference;
+ }
+ structuredValue.createFeatureValues();
+ // Debug.println("[evaluate] " + instance.slot.size() +
+ // " slot(s).");
+ List<Slot> instanceSlots = instance.getSlots();
+ for(int i = 0; i < instanceSlots.size(); i++) {
+ Slot slot = instanceSlots.get(i);
+ List<Value> values = new ArrayList<Value>();
+ // Debug.println("[evaluate] feature = " +
+ // slot.definingFeature.getName() + ", " + slot.value.size() +
+ // " value(s).");
+ List<ValueSpecification> slotValues = slot.getValues();
+ for(int j = 0; j < slotValues.size(); j++) {
+ ValueSpecification slotValue = slotValues.get(j);
+ // Debug.println("[evaluate] Value = " +
+ // slotValue.getClass().getName());
+ values.add(this.locus.executor.evaluate(slotValue));
+ }
+ structuredValue.setFeatureValue(slot.getDefiningFeature(), values, 0);
+ }
+ value = structuredValue;
+ }
+ return value;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/IntegerValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/IntegerValue.java
new file mode 100644
index 00000000000..6e351061b2b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/IntegerValue.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralInteger;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class IntegerValue extends PrimitiveValue {
+
+ /*
+ * The actual Integer value.
+ */
+ public Integer value;
+
+ public ValueSpecification specify() {
+ // Return a literal integer with the value of this integer value.
+ LiteralInteger literal = UMLFactory.eINSTANCE.createLiteralInteger();
+ literal.setType(this.type);
+ literal.setValue(this.value);
+ return literal;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this integer value is equal to the otherValue.
+ // To be equal, the otherValue must have the same value as this integer
+ // value.
+ boolean isEqual = false;
+ if(otherValue instanceof IntegerValue) {
+ isEqual = ((IntegerValue)otherValue).value.equals(this.value); // CHANGED == to equals
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new integer value with the same value as this integer value.
+ IntegerValue newValue = (IntegerValue)(super.copy());
+ newValue.value = this.value;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new integer value with no value.
+ return new IntegerValue();
+ }
+
+ public String toString() {
+ String stringValue = "";
+ if(this.value == 0) {
+ stringValue = "0";
+ } else {
+ int positiveValue = this.value;
+ if(positiveValue < 0) {
+ positiveValue = -positiveValue;
+ }
+ do {
+ int digit = positiveValue % 10;
+ if(digit == 0) {
+ stringValue = "0" + stringValue;
+ } else if(digit == 1) {
+ stringValue = "1" + stringValue;
+ } else if(digit == 2) {
+ stringValue = "2" + stringValue;
+ } else if(digit == 3) {
+ stringValue = "3" + stringValue;
+ } else if(digit == 4) {
+ stringValue = "4" + stringValue;
+ } else if(digit == 5) {
+ stringValue = "5" + stringValue;
+ } else if(digit == 6) {
+ stringValue = "6" + stringValue;
+ } else if(digit == 7) {
+ stringValue = "7" + stringValue;
+ } else if(digit == 8) {
+ stringValue = "8" + stringValue;
+ } else if(digit == 9) {
+ stringValue = "9" + stringValue;
+ }
+ positiveValue = positiveValue / 10;
+ } while(positiveValue > 0);
+ if(this.value < 0) {
+ stringValue = "-" + stringValue;
+ }
+ }
+ return stringValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Link.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Link.java
new file mode 100644
index 00000000000..417d03a896f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Link.java
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Property;
+
+public class Link extends ExtensionalValue {
+
+ /*
+ * The type of this link.
+ */
+ public Association type;
+
+ public void destroy() {
+ // Remove the type of this link and destroy it.
+ // Shift the positions of the feature values of any remaining links in
+ // the extent of the same association, for ends that are ordered.
+ Debug.println("[destroy] link = " + this.objectId());
+ List<Property> ends = this.type.getMemberEnds();
+ List<ExtensionalValue> extent = this.locus.getExtent(this.type);
+ for(int i = 0; i < extent.size(); i++) {
+ ExtensionalValue otherLink = extent.get(i);
+ for(int j = 0; j < ends.size(); j++) {
+ Property end = ends.get(j);
+ if(end.isOrdered()) {
+ FeatureValue featureValue = otherLink.getFeatureValue(end);
+ if(this.getFeatureValue(end).position < featureValue.position) {
+ featureValue.position = featureValue.position - 1;
+ }
+ }
+ }
+ }
+ this.type = null;
+ super.destroy();
+ }
+
+ public Value copy() {
+ // Create a new link with the same type, locus and feature values as
+ // this link.
+ Link newValue = (Link)(super.copy());
+ newValue.type = this.type;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new link with no type or properies.
+ return new Link();
+ }
+
+ public List<Classifier> getTypes() {
+ // Return the single type of this link (if any).
+ List<Classifier> types = null;
+ if(this.type == null) {
+ types = new ArrayList<Classifier>();
+ } else {
+ types = new ArrayList<Classifier>();
+ types.add(this.type);
+ }
+ return types;
+ }
+
+ public Boolean isMatchingLink(ExtensionalValue link, Property end) {
+ // Test whether the given link matches the values of this link on all
+ // ends other than the given end.
+ List<Property> ends = this.type.getMemberEnds();
+ boolean matches = true;
+ int i = 1;
+ while(matches & i <= ends.size()) {
+ Property otherEnd = ends.get(i - 1);
+ if(otherEnd != end & !this.getFeatureValue(otherEnd).values.get(0).equals(link.getFeatureValue(otherEnd).values.get(0))) {
+ matches = false;
+ }
+ i = i + 1;
+ }
+ return matches;
+ }
+
+ public List<FeatureValue> getOtherFeatureValues(List<ExtensionalValue> extent, Property end) {
+ // Return all feature values for the given end of links in the given
+ // extent whose other ends match this link.
+ List<FeatureValue> featureValues = new ArrayList<FeatureValue>();
+ for(int i = 0; i < extent.size(); i++) {
+ ExtensionalValue link = extent.get(i);
+ if(link != this) {
+ if(isMatchingLink(link, end)) {
+ featureValues.add(link.getFeatureValue(end));
+ }
+ }
+ }
+ return featureValues;
+ }
+
+ public void addTo(Locus locus) {
+ // Add this link to the extent of its association at the given locus.
+ // Shift the positions of ends of other links, as appropriate, for ends
+ // that are ordered.
+ Debug.println("[addTo] link = " + this.objectId());
+ List<Property> ends = this.type.getMemberEnds();
+ List<ExtensionalValue> extent = locus.getExtent(this.type);
+ for(int i = 0; i < ends.size(); i++) {
+ Property end = ends.get(i);
+ if(end.isOrdered()) {
+ FeatureValue featureValue = this.getFeatureValue(end);
+ List<FeatureValue> otherFeatureValues = this.getOtherFeatureValues(extent, end);
+ int n = otherFeatureValues.size();
+ if(featureValue.position < 0 | featureValue.position > n) {
+ featureValue.position = n + 1;
+ } else {
+ if(featureValue.position == 0) {
+ featureValue.position = 1;
+ }
+ for(int j = 0; j < otherFeatureValues.size(); j++) {
+ FeatureValue otherFeatureValue = otherFeatureValues.get(j);
+ if(featureValue.position <= otherFeatureValue.position) {
+ otherFeatureValue.position = otherFeatureValue.position + 1;
+ }
+ }
+ }
+ }
+ }
+ locus.add(this);
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralBooleanEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralBooleanEvaluation.java
new file mode 100644
index 00000000000..8b379bfd28f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralBooleanEvaluation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralBoolean;
+
+public class LiteralBooleanEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a literal boolean, producing a boolean value.
+ LiteralBoolean literal = (LiteralBoolean)specification;
+ BooleanValue booleanValue = new BooleanValue();
+ booleanValue.type = this.getType("Boolean");
+ booleanValue.value = literal.booleanValue();
+ return booleanValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralEvaluation.java
new file mode 100644
index 00000000000..3c5caa299a3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralEvaluation.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.PrimitiveType;
+
+public abstract class LiteralEvaluation extends Evaluation {
+
+ public PrimitiveType getType(String builtInTypeName) {
+ // Get the type of the specification. If that is null, then use the
+ // built-in type of the given name.
+ PrimitiveType type = (PrimitiveType)(this.specification.getType());
+ if(type == null) {
+ type = this.locus.factory.getBuiltInType(builtInTypeName);
+ }
+ return type;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralIntegerEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralIntegerEvaluation.java
new file mode 100644
index 00000000000..cf86d556cc3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralIntegerEvaluation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralInteger;
+
+public class LiteralIntegerEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a literal integer, producing an integer value.
+ LiteralInteger literal = (LiteralInteger)specification;
+ IntegerValue integerValue = new IntegerValue();
+ integerValue.type = this.getType("Integer");
+ integerValue.value = literal.integerValue();
+ return integerValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralNullEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralNullEvaluation.java
new file mode 100644
index 00000000000..e6d502c1322
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralNullEvaluation.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+public class LiteralNullEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a literal null, returning nothing (since a null represents
+ // an "absence of any value").
+ return null;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralRealEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralRealEvaluation.java
new file mode 100644
index 00000000000..bd84f6167f7
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralRealEvaluation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralReal;
+
+public class LiteralRealEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a real integer, producing a real value.
+ LiteralReal literal = (LiteralReal)specification;
+ RealValue realValue = new RealValue();
+ realValue.type = this.getType("Real");
+ realValue.value = literal.getValue();
+ return realValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralStringEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralStringEvaluation.java
new file mode 100644
index 00000000000..8b843030350
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralStringEvaluation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralString;
+
+public class LiteralStringEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a literal string, producing a string value.
+ LiteralString literal = (LiteralString)specification;
+ StringValue stringValue = new StringValue();
+ stringValue.type = this.getType("String");
+ stringValue.value = literal.getValue();
+ return stringValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralUnlimitedNaturalEvaluation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralUnlimitedNaturalEvaluation.java
new file mode 100644
index 00000000000..9106d2fa525
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/LiteralUnlimitedNaturalEvaluation.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
+
+public class LiteralUnlimitedNaturalEvaluation extends LiteralEvaluation {
+
+ public Value evaluate() {
+ // Evaluate a literal unlimited natural producing an unlimited natural
+ // value.
+ LiteralUnlimitedNatural literal = (LiteralUnlimitedNatural)specification;
+ UnlimitedNaturalValue unlimitedNaturalValue = new UnlimitedNaturalValue();
+ unlimitedNaturalValue.type = this.getType("UnlimitedNatural");
+ unlimitedNaturalValue.value = literal.getValue();
+ return unlimitedNaturalValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Object_.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Object_.java
new file mode 100644
index 00000000000..73cab0a4cbe
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Object_.java
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.EventAccepter;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.ObjectActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.SignalInstance;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Operation;
+
+public class Object_ extends ExtensionalValue {
+
+ /*
+ * The classes under which this object is currently classified. (A destroyed
+ * object has no types.)
+ */
+ public List<Class> types = new ArrayList<Class>();
+
+ /*
+ * The object activation handling the active behavior of this object.
+ */
+ public ObjectActivation objectActivation;
+
+ public void startBehavior(Class classifier, List<ParameterValue> inputs) {
+ // Create an object activation for this object (if one does not already
+ // exist) and start its behavior(s).
+ // Debug.println("[startBehavior] On object...");
+ if(this.objectActivation == null) {
+ this.objectActivation = new ObjectActivation();
+ this.objectActivation.object = this;
+ }
+ // Debug.println("[startBehavior] objectActivation = " +
+ // objectActivation);
+ this.objectActivation.startBehavior(classifier, inputs);
+ }
+
+ public Execution dispatch(Operation operation) {
+ // Dispatch the given operation to a method execution, using a dispatch
+ // strategy.
+ return ((DispatchStrategy)this.locus.factory.getStrategy("dispatch")).dispatch(this, operation);
+ }
+
+ public void send(SignalInstance signalInstance) {
+ // If the object is active, add the given signal instance to the event
+ // pool and signal that a new signal instance has arrived.
+ if(this.objectActivation != null) {
+ this.objectActivation.send(signalInstance);
+ }
+ }
+
+ public void destroy() {
+ // Stop the object activation (if any), clear all types and destroy the
+ // object as an extensional value.
+ Debug.println("[destroy] object = " + this.objectId());
+ if(this.objectActivation != null) {
+ this.objectActivation.stop();
+ this.objectActivation = null;
+ }
+ this.types.clear();
+ super.destroy();
+ }
+
+ public void register(EventAccepter accepter) {
+ // Register the given accept event accepter to wait for a dispatched
+ // signal event.
+ if(this.objectActivation != null) {
+ this.objectActivation.register(accepter);
+ }
+ }
+
+ public void unregister(EventAccepter accepter) {
+ // Remove the given event accepter for the list of waiting event
+ // accepters.
+ if(this.objectActivation != null) {
+ this.objectActivation.unregister(accepter);
+ }
+ }
+
+ public Value copy() {
+ // Create a new object that is a copy of this object at the same locus
+ // as this object.
+ // However, the new object will NOT have any object activation (i.e, its
+ // classifier behaviors will not be started).
+ Object_ newObject = (Object_)(super.copy());
+ List<Class> types = this.types;
+ for(int i = 0; i < types.size(); i++) {
+ Class type = types.get(i);
+ newObject.types.add(type);
+ }
+ return newObject;
+ }
+
+ public Value new_() {
+ // Create a new object with no type, feature values or locus.
+ return new Object_();
+ }
+
+ public List<Classifier> getTypes() {
+ // Return the types of this object.
+ List<Classifier> types = new ArrayList<Classifier>();
+ List<Class> myTypes = this.types;
+ for(int i = 0; i < myTypes.size(); i++) {
+ Class type = myTypes.get(i);
+ types.add(type);
+ }
+ return types;
+ }
+
+ public String toString() {
+ return this.objectId() ;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/PrimitiveValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/PrimitiveValue.java
new file mode 100644
index 00000000000..92b1a3e785c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/PrimitiveValue.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.PrimitiveType;
+
+public abstract class PrimitiveValue extends Value {
+
+ public PrimitiveType type;
+
+ public Value copy() {
+ // Create a new value that is equal to this primitive value.
+ PrimitiveValue newValue = (PrimitiveValue)(super.copy());
+ newValue.type = this.type;
+ return newValue;
+ }
+
+ public List<Classifier> getTypes() {
+ // Return the single primitive type of this value.
+ List<Classifier> types = new ArrayList<Classifier>();
+ types.add(this.type);
+ return types;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RealValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RealValue.java
new file mode 100644
index 00000000000..77a0555c5a2
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RealValue.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralReal;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class RealValue extends PrimitiveValue {
+
+ /*
+ * The actual Real value.
+ */
+ public double value;
+
+ public ValueSpecification specify() {
+ // Return a literal real with the value of this real value.
+ LiteralReal literal = UMLFactory.eINSTANCE.createLiteralReal();
+ literal.setType(this.type);
+ literal.setValue(this.value);
+ return literal;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this real value is equal to the otherValue.
+ // To be equal, the otherValue must have the same value as this real
+ // value.
+ boolean isEqual = false;
+ if(otherValue instanceof RealValue) {
+ isEqual = ((RealValue)otherValue).value == this.value;
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new real value with the same value as this real value.
+ RealValue newValue = (RealValue)(super.copy());
+ newValue.value = this.value;
+ return newValue;
+ }
+
+ public Value new_() {
+ return new RealValue();
+ }
+
+ public String toString() {
+ String stringValue = "";
+ if(this.value == 0) {
+ stringValue = "0";
+ } else {
+ double positiveValue = this.value;
+ if(positiveValue < 0) {
+ positiveValue = -positiveValue;
+ }
+ int exponent = 0;
+ if(positiveValue < .1) {
+ while(positiveValue < .1) {
+ positiveValue = positiveValue * 10;
+ exponent = exponent - 1;
+ }
+ } else if(positiveValue > 1) {
+ while(positiveValue > 1) {
+ positiveValue = positiveValue / 10;
+ exponent = exponent + 1;
+ }
+ }
+ // This gives 9 significant digits in the mantissa.
+ for(int i = 0; i < 9; i++) {
+ positiveValue = positiveValue * 10;
+ }
+ IntegerValue integerValue = new IntegerValue();
+ integerValue.value = (int)positiveValue;
+ stringValue = "0." + integerValue.toString();
+ integerValue.value = exponent;
+ stringValue = stringValue + "E" + integerValue.toString();
+ if(this.value < 0) {
+ stringValue = "-" + stringValue;
+ }
+ }
+ return stringValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RedefinitionBasedDispatchStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RedefinitionBasedDispatchStrategy.java
new file mode 100644
index 00000000000..25d2ea58991
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/RedefinitionBasedDispatchStrategy.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.List;
+
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+
+public class RedefinitionBasedDispatchStrategy extends DispatchStrategy {
+
+ public Behavior getMethod(Object_ object, Operation operation) {
+ // Get the method that corresponds to the given operation for the given
+ // object.
+ // [If there is more than one type with a method for the operation, then
+ // the first one is arbitrarily chosen.]
+ Behavior method = null;
+ int i = 1;
+ while(method == null & i <= object.types.size()) {
+ Class type = object.types.get(i - 1);
+ List<NamedElement> members = type.getMembers();
+ int j = 1;
+ while(method == null & j <= members.size()) {
+ NamedElement member = members.get(j - 1);
+ if(member instanceof Operation) {
+ Operation memberOperation = (Operation)member;
+ if(this.operationsMatch(memberOperation, operation)) {
+ method = memberOperation.getMethods().get(0);
+ }
+ }
+ j = j + 1;
+ }
+ i = i + 1;
+ }
+ return method;
+ }
+
+ public Boolean operationsMatch(Operation ownedOperation, Operation baseOperation) {
+ // Check if the owned operation is equal to or a redefinition (directly
+ // or indirectly) of the base operation.
+ boolean matches = false;
+ if(ownedOperation == baseOperation) {
+ matches = true;
+ } else {
+ int i = 1;
+ while(!matches & i <= ownedOperation.getRedefinedOperations().size()) {
+ matches = this.operationsMatch(ownedOperation.getRedefinedOperations().get(i - 1), baseOperation);
+ i = i + 1;
+ }
+ }
+ return matches;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Reference.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Reference.java
new file mode 100644
index 00000000000..5b150d00d81
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Reference.java
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.SignalInstance;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.StructuralFeature;
+
+public class Reference extends StructuredValue {
+
+ public Object_ referent;
+
+ public void startBehavior(Class classifier, List<ParameterValue> inputs) {
+ // Asynchronously start the behavior of the given classifier for the
+ // referent object.
+ this.referent.startBehavior(classifier, inputs);
+ }
+
+ public Execution dispatch(Operation operation) {
+ // Dispatch the given operation to the referent object.
+ return this.referent.dispatch(operation);
+ }
+
+ public void send(SignalInstance signalInstance) {
+ // Send the given signal instance to the referent object.
+ this.referent.send(signalInstance);
+ }
+
+ public void destroy() {
+ // Destroy the referent.
+ this.referent.destroy();
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this reference is equal to the otherValue.
+ // To be equal, the otherValue must also be a reference, with the same
+ // referent as this reference.
+ boolean isEqual = false;
+ if(otherValue instanceof Reference) {
+ isEqual = (((Reference)otherValue).referent == this.referent);
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new reference with the same referent as this reference.
+ Reference newValue = (Reference)(super.copy());
+ newValue.referent = this.referent;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new reference with no referent.
+ return new Reference();
+ }
+
+ public List<Classifier> getTypes() {
+ // Get the types of the referent object.
+ return this.referent.getTypes();
+ }
+
+ public FeatureValue getFeatureValue(StructuralFeature feature) {
+ // Get the feature value associated with the given feature in the
+ // referent object.
+ return this.referent.getFeatureValue(feature);
+ }
+
+ public void setFeatureValue(StructuralFeature feature, List<Value> values, Integer position) {
+ // Set the values associated with the given feature in the referent
+ // object.
+ this.referent.setFeatureValue(feature, values, position);
+ }
+
+ public List<FeatureValue> getFeatureValues() {
+ // Return the feature values of the referent.
+ return this.referent.getFeatureValues();
+ }
+
+ public String toString() {
+ return "Reference to " + this.referent.toString();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StringValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StringValue.java
new file mode 100644
index 00000000000..76ad22e56f4
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StringValue.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralString;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class StringValue extends PrimitiveValue {
+
+ public String value;
+
+ public ValueSpecification specify() {
+ // Return a literal string with the value of this string value.
+ LiteralString literal = UMLFactory.eINSTANCE.createLiteralString();
+ literal.setType(this.type);
+ literal.setValue(this.value);
+ return literal;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this string value is equal to the otherValue.
+ // To be equal, the otherValue must have the same value as this string
+ // value.
+ boolean isEqual = false;
+ if(otherValue instanceof StringValue) {
+ isEqual = ((StringValue)otherValue).value.equals(this.value);
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new string value with the same value as this string value.
+ StringValue newValue = (StringValue)(super.copy());
+ newValue.value = this.value;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new string value with no value.
+ return new StringValue();
+ }
+
+ public String toString() {
+ return value;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StructuredValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StructuredValue.java
new file mode 100644
index 00000000000..3aafdb67095
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/StructuredValue.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Slot;
+import org.eclipse.uml2.uml.StructuralFeature;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public abstract class StructuredValue extends Value {
+
+ public ValueSpecification specify() {
+ // Return an instance value that specifies this structured value.
+ // Debug.println("[specify] StructuredValue...");
+ InstanceValue instanceValue = UMLFactory.eINSTANCE.createInstanceValue();
+ InstanceSpecification instance = UMLFactory.eINSTANCE.createInstanceSpecification();
+ instanceValue.setType(null);
+ instanceValue.setInstance(instance);
+ instance.getClassifiers().addAll(this.getTypes());
+ List<FeatureValue> featureValues = this.getFeatureValues();
+ // Debug.println("[specify] " + featureValues.size() + " feature(s).");
+ for(int i = 0; i < featureValues.size(); i++) {
+ FeatureValue featureValue = featureValues.get(i);
+ Slot slot = UMLFactory.eINSTANCE.createSlot();
+ slot.setDefiningFeature(featureValue.feature);
+ // Debug.println("[specify] feature = " + featureValue.feature.name
+ // + ", " + featureValue.values.size() + " value(s).");
+ List<Value> values = featureValue.values;
+ for(int j = 0; j < values.size(); j++) {
+ Value value = values.get(j);
+ // Debug.println("[specify] value = " + value);
+ slot.getValues().add(value.specify());
+ }
+ instance.getSlots().add(slot);
+ }
+ return instanceValue;
+ }
+
+ public abstract FeatureValue getFeatureValue(StructuralFeature feature);
+
+ public abstract void setFeatureValue(StructuralFeature feature, List<Value> values, Integer position);
+
+ public abstract List<FeatureValue> getFeatureValues();
+
+ public void createFeatureValues() {
+ // Create empty feature values for all structural features, direct and
+ // inherited, of the types of this structured value.
+ List<Classifier> types = this.getTypes();
+ for(int i = 0; i < types.size(); i++) {
+ Classifier type = types.get(i);
+ this.createFeatureValuesFromType(type); // REPLACED body of loop
+ }
+ }
+
+ // ADDED
+ public void createFeatureValuesFromType(Classifier type) {
+ // Create empty feature values for all structural features from the
+ // given type and all its direct and indirect parents.
+ // [Note that this is necessary in order to set the feature values for
+ // private structural features of parent classifiers, since these are
+ // not actually inherited.]
+ List<NamedElement> ownedMembers = type.getOwnedMembers();
+ for(int i = 0; i < ownedMembers.size(); i++) {
+ NamedElement member = ownedMembers.get(i);
+ if(member instanceof StructuralFeature) {
+ this.setFeatureValue((StructuralFeature)member, new ArrayList<Value>(), 0);
+ }
+ }
+
+ List<Classifier> generals = type.getGenerals();
+ for (int i = 0; i < generals.size(); i++) {
+ Classifier general = generals.get(i);
+ this.createFeatureValuesFromType(general);
+ }
+ }
+ //
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/UnlimitedNaturalValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/UnlimitedNaturalValue.java
new file mode 100644
index 00000000000..4c375644aff
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/UnlimitedNaturalValue.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class UnlimitedNaturalValue extends PrimitiveValue {
+
+ /*
+ * The actual unlimited natural value.
+ */
+ public Integer value;
+
+ public ValueSpecification specify() {
+ // Return a literal unlimited natural with the value of this unlimited
+ // natural value.
+ LiteralUnlimitedNatural literal = UMLFactory.eINSTANCE.createLiteralUnlimitedNatural();
+ literal.setType(this.type);
+ literal.setValue(this.value);
+ return literal;
+ }
+
+ public Boolean equals(Value otherValue) {
+ // Test if this unlimited natural value is equal to the otherValue.
+ // To be equal, the otherValue must have the same value as this
+ // unlimited natural value.
+ boolean isEqual = false;
+ if(otherValue instanceof UnlimitedNaturalValue) {
+ isEqual = ((UnlimitedNaturalValue)otherValue).value.equals(this.value); // CHANGED == to equals
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new unlimited natural value with the same value as this
+ // value.
+ UnlimitedNaturalValue newValue = (UnlimitedNaturalValue)(super.copy());
+ newValue.value = this.value;
+ return newValue;
+ }
+
+ public Value new_() {
+ // Create a new unlimited natural value with no value.
+ return new UnlimitedNaturalValue();
+ }
+
+ public String toString() {
+ String stringValue = "*";
+ if(this.value >= 0) {
+ IntegerValue integerValue = new IntegerValue();
+ integerValue.value = this.value;
+ stringValue = integerValue.toString();
+ }
+ return stringValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Value.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Value.java
new file mode 100644
index 00000000000..6603dc3216c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Classes/Kernel/Value.java
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticVisitor;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public abstract class Value extends SemanticVisitor {
+
+ public abstract ValueSpecification specify();
+
+ public Boolean equals(Value otherValue) {
+ // Test if this value is equal to otherValue. To be equal, this value
+ // must have the same type as otherValue.
+ // This operation must be overridden in Value subclasses to check for
+ // equality of properties defined in those subclasses.
+ List<Classifier> myTypes = this.getTypes();
+ List<Classifier> otherTypes = otherValue.getTypes();
+ boolean isEqual = true;
+ // Debug.println("[equals] Value...");
+ // Debug.println("[equals] this has " + myTypes.size() +
+ // "types, other has " + otherTypes.size() + ".");
+ if(myTypes.size() != otherTypes.size()) {
+ isEqual = false;
+ } else {
+ // Debug.println("[equals] " + myTypes.size() + " type(s).");
+ int i = 1;
+ while(isEqual & i <= myTypes.size()) {
+ // Debug.println("[equals] this type = " +
+ // myTypes.get(i-1).name);
+ boolean matched = false;
+ int j = 1;
+ while(!matched & j <= otherTypes.size()) {
+ // Debug.println("[equals] other type = " +
+ // otherTypes.get(j-1).name);
+ matched = (otherTypes.get(j - 1) == myTypes.get(i - 1));
+ j = j + 1;
+ }
+ isEqual = matched;
+ i = i + 1;
+ }
+ }
+ return isEqual;
+ }
+
+ public Value copy() {
+ // Create a new value that is equal to this value.
+ // By default, this operation simply creates a new value with empty
+ // properties.
+ // It must be overridden in each Value subclass to do the superclass
+ // copy and then appropriately set properties defined in the subclass.
+ return this.new_();
+ }
+
+ public abstract Value new_();
+
+ public abstract List<Classifier> getTypes();
+
+ public Boolean hasType(Classifier type) {
+ // Check if this object has the given classifier as a type.
+ List<Classifier> types = this.getTypes();
+ boolean found = false;
+ int i = 1;
+ while(!found & i <= types.size()) {
+ found = (types.get(i - 1) == type);
+ i = i + 1;
+ }
+ return found;
+ }
+
+ public abstract String toString();
+
+ public String objectId() {
+ // Return an identifier for this object.
+ // [Non-normative.]
+ return super.toString();
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/Execution.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/Execution.java
new file mode 100644
index 00000000000..8495fe44af0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/Execution.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+
+public abstract class Execution extends Object_ {
+
+ /*
+ * The object that provides the context for this execution. The type of the
+ * context of the execution must be the context of the type (behavior) of
+ * the execution.
+ */
+ public Object_ context;
+
+ /*
+ * The parameterValues for this execution. All parameterValues must have a
+ * parameter that is a parameter of the type of this execution. The values
+ * of all input (in and in-out) parameters must be set before the execution
+ * is executed.
+ */
+ public List<ParameterValue> parameterValues = new ArrayList<ParameterValue>();
+
+ public abstract void execute();
+
+ public void terminate() {
+ // Terminate an ongoing execution. By default, do nothing.
+ return;
+ }
+
+ public Value copy() {
+ // Create a new execution that has the same behavior and parameterValues
+ // as this execution.
+ // Debug.println("[Copy] execution = " + this);
+ Execution newValue = (Execution)(super.copy());
+ newValue.context = this.context;
+ List<ParameterValue> parameterValues = this.parameterValues;
+ for(int i = 0; i < parameterValues.size(); i++) {
+ ParameterValue parameterValue = parameterValues.get(i);
+ newValue.parameterValues.add(parameterValue.copy());
+ }
+ // Debug.println("[Copy] Done.");
+ return newValue;
+ }
+
+ public abstract Value new_();
+
+ public void setParameterValue(ParameterValue parameterValue) {
+ // Set the given parameter value for this execution.
+ // If a parameter value already existed for the parameter of the given
+ // parameter value, then replace its value.
+ // Debug.println("[setParameterValue] parameter = " +
+ // parameterValue.parameter.name + " with " +
+ // parameterValue.values.size() + " values");
+ ParameterValue existingParameterValue = this.getParameterValue(parameterValue.parameter);
+ if(existingParameterValue == null) {
+ this.parameterValues.add(parameterValue);
+ } else {
+ existingParameterValue.values = parameterValue.values;
+ }
+ }
+
+ public ParameterValue getParameterValue(Parameter parameter) {
+ // Get the parameter value of this execution corresponding to the given
+ // parameter (if any).
+ ParameterValue parameterValue = null;
+ int i = 1;
+ while(parameterValue == null & i <= this.parameterValues.size()) {
+ if(this.parameterValues.get(i - 1).parameter == parameter) {
+ parameterValue = this.parameterValues.get(i - 1);
+ }
+ i = i + 1;
+ }
+ return parameterValue;
+ }
+
+ public List<ParameterValue> getOutputParameterValues() {
+ // Return the parameter values for output (in-out, out and return)
+ // parameters.
+ List<ParameterValue> outputs = new ArrayList<ParameterValue>();
+ List<ParameterValue> parameterValues = this.parameterValues;
+ for(int i = 0; i < parameterValues.size(); i++) {
+ ParameterValue parameterValue = parameterValues.get(i);
+ Parameter parameter = parameterValue.parameter;
+ if((parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL)) {
+ outputs.add(parameterValue);
+ }
+ }
+ return outputs;
+ }
+
+ public Behavior getBehavior() {
+ // Get the behavior that is the type of this execution.
+ return (Behavior)(this.getTypes().get(0));
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/OpaqueBehaviorExecution.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/OpaqueBehaviorExecution.java
new file mode 100644
index 00000000000..62097cb60cb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/OpaqueBehaviorExecution.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+
+public abstract class OpaqueBehaviorExecution extends Execution {
+
+ public void execute() {
+ // Execute the body of the opaque behavior.
+ Debug.println("[execute] Opaque behavior " + this.getBehavior().getName() + "...");
+ List<Parameter> parameters = this.getBehavior().getOwnedParameters();
+ List<ParameterValue> inputs = new ArrayList<ParameterValue>();
+ List<ParameterValue> outputs = new ArrayList<ParameterValue>();
+ for(int i = 0; i < parameters.size(); i++) {
+ Parameter parameter = parameters.get(i);
+ if((parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL)) {
+ inputs.add(this.getParameterValue(parameter));
+ }
+ if((parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) | (parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL)) {
+ ParameterValue parameterValue = new ParameterValue();
+ parameterValue.parameter = parameter;
+ this.setParameterValue(parameterValue);
+ outputs.add(parameterValue);
+ }
+ }
+ this.doBody(inputs, outputs);
+ }
+
+ public abstract void doBody(List<ParameterValue> inputParameters, List<ParameterValue> outputParameters);
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/ParameterValue.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/ParameterValue.java
new file mode 100644
index 00000000000..a05b5c23a51
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/BasicBehaviors/ParameterValue.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Parameter;
+
+public class ParameterValue {
+
+ public Parameter parameter;
+
+ /*
+ * The values of for the parameter. Zero or more values are possible, as
+ * constrained by the multiplicity of the parameter.
+ */
+ public List<Value> values = new ArrayList<Value>();
+
+ public ParameterValue copy() {
+ // Create a new parameter value for the same parameter as this parameter
+ // value, but with copies of the values of this parameter value.
+ ParameterValue newValue = new ParameterValue();
+ newValue.parameter = this.parameter;
+ List<Value> values = this.values;
+ for(int i = 0; i < values.size(); i++) {
+ Value value = values.get(i);
+ newValue.values.add(value.copy());
+ }
+ return newValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ArrivalSignal.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ArrivalSignal.java
new file mode 100644
index 00000000000..98b8e27113b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ArrivalSignal.java
@@ -0,0 +1,17 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+public class ArrivalSignal {
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ClassifierBehaviorExecution.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ClassifierBehaviorExecution.java
new file mode 100644
index 00000000000..da4e71474a0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ClassifierBehaviorExecution.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+
+public class ClassifierBehaviorExecution {
+
+ /*
+ * The execution of the associated classifier behavior for a certain object.
+ */
+ public Execution execution;
+
+ /*
+ * The classifier whose behavior is being executed. (This must be an active
+ * class.)
+ */
+ public Class classifier;
+
+ /*
+ * The object activation that owns this classifier behavior execution.
+ */
+ public ObjectActivation objectActivation;
+
+ public void execute(Class classifier, List<ParameterValue> inputs) {
+ // Set the classifier for this classifier behavior execution to the
+ // given class.
+ // If the given class is a behavior, set the execution to be the object
+ // of the object activation of the classifier behavior execution.
+ // Otherwise the class must be an active class, so get an execution
+ // object for the classifier behavior for the class.
+ // Set the input parameters for the execution to the given values.
+ // Then start the active behavior of this ClassifierBehaviorExecution
+ // object, which will execute the execution object on a separate thread
+ // of control.
+ // Debug.println("[execute] Executing behavior for " + classifier.name +
+ // "...");
+ this.classifier = classifier;
+ Object_ object = this.objectActivation.object;
+ if(classifier instanceof Behavior) {
+ this.execution = (Execution)object;
+ } else {
+ this.execution = object.locus.factory.createExecution(classifier.getClassifierBehavior(), object);
+ }
+ if(inputs != null) {
+ for(int i = 0; i < inputs.size(); i++) {
+ ParameterValue input = inputs.get(i);
+ this.execution.setParameterValue(input);
+ }
+ }
+ _startObjectBehavior();
+ }
+
+ public void _startObjectBehavior() {
+ this.execution.execute();
+ }
+
+ public void terminate() {
+ // Terminate the associated execution.
+ // If the execution is not itself the object of the object activation,
+ // then destroy it.
+ // Debug.println("[terminate] Terminating behavior for " +
+ // classifier.name + "...");
+ this.execution.terminate();
+ if(this.execution != this.objectActivation.object) {
+ this.execution.destroy();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/EventAccepter.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/EventAccepter.java
new file mode 100644
index 00000000000..7b8d9979e82
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/EventAccepter.java
@@ -0,0 +1,21 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+public abstract class EventAccepter {
+
+ public abstract void accept(SignalInstance signalInstance);
+
+ public abstract Boolean match(SignalInstance signalInstance);
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/FIFOGetNextEventStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/FIFOGetNextEventStrategy.java
new file mode 100644
index 00000000000..b7df045e6c6
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/FIFOGetNextEventStrategy.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+public class FIFOGetNextEventStrategy extends GetNextEventStrategy {
+
+ public SignalInstance getNextEvent(ObjectActivation objectActivation) {
+ // Get the first event from the given event pool. The event is removed
+ // from the pool.
+ SignalInstance signalInstance = objectActivation.eventPool.get(0);
+ objectActivation.eventPool.remove(0);
+ return signalInstance;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/GetNextEventStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/GetNextEventStrategy.java
new file mode 100644
index 00000000000..938c02d901e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/GetNextEventStrategy.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticStrategy;
+
+public abstract class GetNextEventStrategy extends SemanticStrategy {
+
+ public String getName() {
+ // Get next event strategies are always named "getNextEvent".
+ return "getNextEvent";
+ }
+
+ public abstract SignalInstance getNextEvent(ObjectActivation objectActivation);
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ObjectActivation.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ObjectActivation.java
new file mode 100644
index 00000000000..a6154c1ba00
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/ObjectActivation.java
@@ -0,0 +1,187 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+
+public class ObjectActivation {
+
+ /*
+ * The executing classifier behaviors for this object activation.
+ */
+ public List<ClassifierBehaviorExecution> classifierBehaviorExecutions = new ArrayList<ClassifierBehaviorExecution>();
+
+ /*
+ * The set of event accepters waiting for signals to be received by the
+ * object of this object activation.
+ */
+ public List<EventAccepter> waitingEventAccepters = new ArrayList<EventAccepter>();
+
+ /*
+ * The pool of signals sent to the object of this object activation, pending
+ * dispatching as events. (All the data values in the pool must be signal
+ * instances -- that is, they must have a single type that is a signal.)
+ */
+ public List<SignalInstance> eventPool = new ArrayList<SignalInstance>();
+
+ /*
+ * The object whose active behavior is being handled by this active object.
+ */
+ public Object_ object;
+
+ public void stop() {
+ // Stop this object activation by terminating all classifier behavior
+ // executions.
+ List<ClassifierBehaviorExecution> classifierBehaviorExecutions = this.classifierBehaviorExecutions;
+ for(int i = 0; i < classifierBehaviorExecutions.size(); i++) {
+ ClassifierBehaviorExecution classifierBehaviorExecution = classifierBehaviorExecutions.get(i);
+ classifierBehaviorExecution.terminate();
+ }
+ }
+
+ public void register(EventAccepter accepter) {
+ // Register the given event accepter to wait for a dispatched signal
+ // event.
+ Debug.println("[register] object = " + this.object);
+ Debug.println("[register] accepter = " + accepter);
+ this.waitingEventAccepters.add(accepter);
+ }
+
+ public void unregister(EventAccepter accepter) {
+ // Remove the given event accepter for the list of waiting event
+ // accepters.
+ Debug.println("[unregister] object = " + this.object);
+ Debug.println("[unregister] accepter = " + accepter);
+ boolean notFound = true;
+ int i = 1;
+ while(notFound & i <= this.waitingEventAccepters.size()) {
+ if(this.waitingEventAccepters.get(i - 1) == accepter) {
+ this.waitingEventAccepters.remove(i - 1);
+ notFound = false;
+ }
+ i = i + 1;
+ }
+ }
+
+ public void dispatchNextEvent() {
+ // Get the next signal instance out of the event pool.
+ // If there is one or more waiting event accepters with triggers that
+ // match the signal instance, then dispatch it to exactly one of those
+ // waiting accepters.
+ if(this.eventPool.size() > 0) {
+ SignalInstance signalInstance = this.getNextEvent();
+ Debug.println("[dispatchNextEvent] signalInstance = " + signalInstance);
+ List<Integer> matchingEventAccepterIndexes = new ArrayList<Integer>();
+ List<EventAccepter> waitingEventAccepters = this.waitingEventAccepters;
+ for(int i = 0; i < waitingEventAccepters.size(); i++) {
+ EventAccepter eventAccepter = waitingEventAccepters.get(i);
+ if(eventAccepter.match(signalInstance)) {
+ matchingEventAccepterIndexes.add(i);
+ }
+ }
+ if(matchingEventAccepterIndexes.size() > 0) {
+ // *** Choose one matching event accepter non-deterministically.
+ // ***
+ int j = ((ChoiceStrategy)this.object.locus.factory.getStrategy("choice")).choose(matchingEventAccepterIndexes.size());
+ EventAccepter selectedEventAccepter = this.waitingEventAccepters.get(matchingEventAccepterIndexes.get(j - 1));
+ this.waitingEventAccepters.remove(j - 1);
+ selectedEventAccepter.accept(signalInstance);
+ }
+ }
+ }
+
+ public SignalInstance getNextEvent() {
+ // Get the next event from the event pool, using a get next event
+ // strategy.
+ return ((GetNextEventStrategy)this.object.locus.factory.getStrategy("getNextEvent")).getNextEvent(this);
+ }
+
+ public void send(SignalInstance signalInstance) {
+ // Add the given signal instance to the event pool and signal that a new
+ // signal instance has arrived.
+ this.eventPool.add((SignalInstance)(signalInstance.copy()));
+ _send(new ArrivalSignal());
+ }
+
+ public void startBehavior(Class classifier, List<ParameterValue> inputs) {
+ // Start the event dispatch loop for this object activation (if it has
+ // not already been started).
+ // If a classifier is given that is a type of the object of this object
+ // activation and there is not already a classifier behavior execution
+ // for it,
+ // then create a classifier behavior execution for it.
+ // Otherwise, create a classifier behavior execution for each of the
+ // types of the object of this object activation which has a classifier
+ // behavior or which is a behavior itself
+ // and for which there is not currently a classifier behavior execution.
+ // Start EventDispatchLoop
+ _startObjectBehavior();
+ if(classifier == null) {
+ Debug.println("[startBehavior] Starting behavior for all classifiers...");
+ // *** Start all classifier behaviors concurrently. ***
+ List<Class> types = this.object.types;
+ for(Iterator<Class> i = types.iterator(); i.hasNext();) {
+ Class type = i.next();
+ if(type instanceof Behavior | type.getClassifierBehavior() != null) {
+ this.startBehavior(type, new ArrayList<ParameterValue>());
+ }
+ }
+ } else {
+ Debug.println("[startBehavior] Starting behavior for " + classifier.getName() + "...");
+ boolean notYetStarted = true;
+ int i = 1;
+ while(notYetStarted & i <= this.classifierBehaviorExecutions.size()) {
+ notYetStarted = (this.classifierBehaviorExecutions.get(i - 1).classifier != classifier);
+ i = i + 1;
+ }
+ if(notYetStarted) {
+ ClassifierBehaviorExecution newExecution = new ClassifierBehaviorExecution();
+ newExecution.objectActivation = this;
+ this.classifierBehaviorExecutions.add(newExecution);
+ newExecution.execute(classifier, inputs);
+ }
+ }
+ }
+
+
+ int signalCount = 0;
+ public void _startObjectBehavior() {
+ // *** This should start the EventDispatchLoop ***
+
+ while (this.signalCount > 0) {
+ this.dispatchNextEvent();
+ signalCount = signalCount - 1;
+ }
+ } // _startObjectBehavior
+
+ public void _send(ArrivalSignal signal) {
+ // Signal the arrival of a new signal instance in the event pool.
+ // *** This should send an ArrivalSignal to the EventDispatchLoop. ***
+
+ this.signalCount = this.signalCount + 1;
+ if (this.signalCount == 1) {
+ this._startObjectBehavior();
+ }
+ } // _send
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/SignalInstance.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/SignalInstance.java
new file mode 100644
index 00000000000..81adfbc7587
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/CommonBehaviors/Communications/SignalInstance.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.CompoundValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Signal;
+
+public class SignalInstance extends CompoundValue {
+
+ public Signal type;
+
+ public List<Classifier> getTypes() {
+ // Return the single type of this signal instance.
+ List<Classifier> types = new ArrayList<Classifier>();
+ types.add(this.type);
+ return types;
+ }
+
+ public Value new_() {
+ // Create a new signal instance with no type or feature values.
+ return new SignalInstance();
+ }
+
+ public Value copy() {
+ // Create a new signal instance with the same type and feature values as
+ // this signal instance.
+ SignalInstance newValue = (SignalInstance)(super.copy());
+ newValue.type = this.type;
+ return newValue;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ChoiceStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ChoiceStrategy.java
new file mode 100644
index 00000000000..80354508f7a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ChoiceStrategy.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+public abstract class ChoiceStrategy extends SemanticStrategy {
+
+ public String getName() {
+ // The name of a choice strategy is always "choice".
+ return "choice";
+ }
+
+ public abstract Integer choose(Integer size);
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactory.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactory.java
new file mode 100644
index 00000000000..8d5599010cd
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactory.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.debug.StackFrameManager;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Evaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.OpaqueBehaviorExecution;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public abstract class ExecutionFactory {
+
+ /*
+ * The locus at which this factory resides.
+ */
+ public Locus locus;
+
+ /*
+ * The set of opaque behavior executions to be used to execute the primitive
+ * behaviors known to the factory.
+ */
+ public List<OpaqueBehaviorExecution> primitiveBehaviorPrototypes = new ArrayList<OpaqueBehaviorExecution>();
+
+ /*
+ * The set of primitive types that have corresponding literal value
+ * specifications. Must include Integer, Boolean, String and
+ * UnlimitedNatural.
+ */
+ public List<PrimitiveType> builtInTypes = new ArrayList<PrimitiveType>();
+
+ /*
+ * The set of semantic strategies currently registered with this execution
+ * factory.
+ */
+ public List<SemanticStrategy> strategies = new ArrayList<SemanticStrategy>();
+
+ public Execution createExecution(Behavior behavior, Object_ context) {
+ // Create an execution object for a given behavior.
+ // The execution will take place at the locus of the factory in the
+ // given context.
+ // If the context is empty, the execution is assumed to provide its own
+ // context.
+ Execution execution;
+ if(behavior instanceof OpaqueBehavior) {
+ execution = this.instantiateOpaqueBehaviorExecution((OpaqueBehavior)behavior);
+ } else {
+ execution = (Execution)this.instantiateVisitor(behavior);
+ execution.types.add(behavior);
+ execution.createFeatureValues();
+ }
+ this.locus.add(execution);
+ if(context == null) {
+ execution.context = execution;
+ } else {
+ execution.context = context;
+ }
+ // Statement added for connection with the DebugAPI
+ if (execution instanceof ActivityExecution)
+ StackFrameManager.getInstance().pushActivityExecution((ActivityExecution)execution) ;
+ return execution;
+ }
+
+ public Evaluation createEvaluation(ValueSpecification specification) {
+ // Create an evaluation object for a given value specification.
+ // The evaluation will take place at the locus of the factory.
+ Evaluation evaluation = (Evaluation)this.instantiateVisitor(specification);
+ evaluation.specification = specification;
+ evaluation.locus = this.locus;
+ return evaluation;
+ }
+
+ public abstract SemanticVisitor instantiateVisitor(Element element);
+
+ public OpaqueBehaviorExecution instantiateOpaqueBehaviorExecution(OpaqueBehavior behavior) {
+ // Return a copy of the prototype for the primitive behavior execution
+ // of the given opaque behavior.
+ OpaqueBehaviorExecution execution = null;
+ int i = 1;
+ while(execution == null & i <= this.primitiveBehaviorPrototypes.size()) {
+ // Debug.println("[instantiateOpaqueExecution] Checking " +
+ // this.primitiveBehaviorPrototypes.get(i).objectId() + "...");
+ OpaqueBehaviorExecution prototype = this.primitiveBehaviorPrototypes.get(i - 1);
+ if (prototype.getBehavior() == behavior) {
+ execution = (OpaqueBehaviorExecution)(prototype.copy());
+ }
+ i = i + 1;
+ }
+ if(execution == null) {
+ Debug.println("[instantiateOpaqueExecution] No prototype execution found for " + behavior.getName() + ".");
+ }
+ return execution;
+ }
+
+ public void addPrimitiveBehaviorPrototype(OpaqueBehaviorExecution execution) {
+ // Add an opaque behavior execution to use as a prototype for
+ // instantiating the corresponding primitive opaque behavior.
+ // Precondition: No primitive behavior prototype for the type of the
+ // given execution should already exist.
+ this.primitiveBehaviorPrototypes.add(execution);
+ }
+
+ public void addBuiltInType(PrimitiveType type) {
+ // Add the given primitive type as a built-in type.
+ // Precondition: No built-in type with the same name should already
+ // exist.
+ this.builtInTypes.add(type);
+ }
+
+ public PrimitiveType getBuiltInType(String name) {
+ // Return the built-in type with the given name.
+ PrimitiveType type = null;
+ int i = 1;
+ while(type == null & i <= this.builtInTypes.size()) {
+ PrimitiveType primitiveType = this.builtInTypes.get(i - 1);
+ if(primitiveType.getName().equals(name)) {
+ type = primitiveType;
+ }
+ i = i + 1;
+ }
+ return type;
+ }
+
+ public void setStrategy(SemanticStrategy strategy) {
+ // Set the strategy for a semantic variation point. Any existing
+ // strategy for the same SVP is replaced.
+ int i = this.getStrategyIndex(strategy.getName());
+ if(i <= this.strategies.size()) {
+ this.strategies.remove(i - 1);
+ }
+ this.strategies.add(strategy);
+ }
+
+ public SemanticStrategy getStrategy(String name) {
+ // Get the strategy with the given name.
+ int i = this.getStrategyIndex(name);
+ SemanticStrategy strategy = null;
+ if(i <= this.strategies.size()) {
+ strategy = this.strategies.get(i - 1);
+ }
+ return strategy;
+ }
+
+ public Integer getStrategyIndex(String name) {
+ // Get the index of the strategy with the given name.
+ // If there is no such strategy, return the size of the strategies list.
+ List<SemanticStrategy> strategies = this.strategies;
+ int i = 1;
+ boolean unmatched = true;
+ while(unmatched & (i <= strategies.size())) {
+ if(strategies.get(i - 1).getName().equals(name)) {
+ unmatched = false;
+ } else {
+ i = i + 1;
+ }
+ }
+ return i;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactoryL1.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactoryL1.java
new file mode 100644
index 00000000000..1959cc1c648
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/ExecutionFactoryL1.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.InstanceValueEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralBooleanEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralIntegerEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralNullEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralRealEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralStringEvaluation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.LiteralUnlimitedNaturalEvaluation;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.LiteralBoolean;
+import org.eclipse.uml2.uml.LiteralInteger;
+import org.eclipse.uml2.uml.LiteralNull;
+import org.eclipse.uml2.uml.LiteralReal;
+import org.eclipse.uml2.uml.LiteralString;
+import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
+
+public class ExecutionFactoryL1 extends ExecutionFactory {
+
+ public SemanticVisitor instantiateVisitor(Element element) {
+ // Instantiate a visitor object for the given element (at Conformance
+ // Level 1)
+ SemanticVisitor visitor = null;
+ if(element instanceof LiteralBoolean) {
+ visitor = new LiteralBooleanEvaluation();
+ } else if(element instanceof LiteralString) {
+ visitor = new LiteralStringEvaluation();
+ } else if(element instanceof LiteralNull) {
+ visitor = new LiteralNullEvaluation();
+ } else if(element instanceof InstanceValue) {
+ visitor = new InstanceValueEvaluation();
+ } else if(element instanceof LiteralUnlimitedNatural) {
+ visitor = new LiteralUnlimitedNaturalEvaluation();
+ } else if(element instanceof LiteralInteger) {
+ visitor = new LiteralIntegerEvaluation();
+ } else if(element instanceof LiteralReal) {
+ visitor = new LiteralRealEvaluation();
+ }
+ return visitor;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Executor.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Executor.java
new file mode 100644
index 00000000000..348a8f66f8a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Executor.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Reference;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+public class Executor {
+
+ /*
+ * The locus at which this executor resides.
+ */
+ public Locus locus;
+
+ public List<ParameterValue> execute(Behavior behavior, Object_ context, List<ParameterValue> inputs) {
+ // Execute the given behavior with the given input values in the given
+ // context, producing the given output values.
+ // There must be one input parameter value for each input (in or in-out)
+ // parameter of the behavior.
+ // The returned values include one parameter value for each output
+ // (in-out, out or return) parameter of the behavior.
+ // The execution instance is destroyed at completion.
+ Execution execution = this.locus.factory.createExecution(behavior, context);
+ for(int i = 0; i < inputs.size(); i++) {
+ execution.setParameterValue(inputs.get(i));
+ }
+ execution.execute();
+ List<ParameterValue> outputValues = execution.getOutputParameterValues();
+ execution.destroy();
+ return outputValues;
+ }
+
+ public Value evaluate(ValueSpecification specification) {
+ // Evaluate the given value specification, returning the specified
+ // value.
+ // Debug.println("[evaluate] Start...");
+ return this.locus.factory.createEvaluation(specification).evaluate();
+ }
+
+ public Reference start(Class type, List<ParameterValue> inputs) {
+ // Instantiate the given class and start any behavior of the resulting
+ // object.
+ // (The behavior of an object includes any classifier behaviors for an
+ // active object or the class of the object itself, if that is a
+ // behavior.)
+ Debug.println("[start] Starting " + type.getName() + "...");
+ Object_ object = this.locus.instantiate(type);
+ Debug.println("[start] Object = " + object);
+ object.startBehavior(type, inputs);
+ Reference reference = new Reference();
+ reference.referent = object;
+ return reference;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/FirstChoiceStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/FirstChoiceStrategy.java
new file mode 100644
index 00000000000..e692ecd2552
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/FirstChoiceStrategy.java
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+public class FirstChoiceStrategy extends ChoiceStrategy {
+
+ public Integer choose(Integer size) {
+ // Always choose one.
+ return 1;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Locus.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Locus.java
new file mode 100644
index 00000000000..4926e675fac
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/Locus.java
@@ -0,0 +1,153 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.papyrus.moka.debug.MokaDebugTarget;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.ExtensionalValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.debug.FumlThread;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+
+public class Locus {
+
+ public boolean isInDebugMode = false ;
+
+ public FUMLExecutionEngine engine ;
+
+ public FumlThread mainThread ;
+
+ public MokaStackFrame[] stackFrames ;
+
+ public void initDebugInformation(String debugMode, FUMLExecutionEngine engine) {
+ this.engine = engine ;
+ Locus.debugTarget = engine.getDebugTarget() ;
+ if (debugMode.equals(ILaunchManager.DEBUG_MODE)) {
+ this.isInDebugMode = true ;
+ this.mainThread = new FumlThread(engine.getDebugTarget()) ;
+ this.mainThread.setName("Main thread") ;
+ }
+ }
+
+ protected static MokaDebugTarget debugTarget ;
+
+ public static MokaDebugTarget getDebugTarget() {
+ return Locus.debugTarget ;
+ }
+
+ /*
+ * The executor to be used at this locus.
+ */
+ public Executor executor;
+
+ /*
+ * The factory to be used at this locus.
+ */
+ public ExecutionFactory factory;
+
+ /*
+ * The set of values that are members of classifier extents at this locus.
+ */
+ public List<ExtensionalValue> extensionalValues = new ArrayList<ExtensionalValue>();
+
+ public void setExecutor(Executor executor) {
+ // Set the executor for this locus.
+ this.executor = executor;
+ this.executor.locus = this;
+ }
+
+ public void setFactory(ExecutionFactory factory) {
+ // Set the factory for this locus.
+ this.factory = factory;
+ this.factory.locus = this;
+ }
+
+ public List<ExtensionalValue> getExtent(Classifier classifier) {
+ // Return the set of extensional values at this locus which have the
+ // given classifier as a type.
+ List<ExtensionalValue> extent = new ArrayList<ExtensionalValue>();
+ List<ExtensionalValue> extensionalValues = this.extensionalValues;
+ for(int i = 0; i < extensionalValues.size(); i++) {
+ ExtensionalValue value = extensionalValues.get(i);
+ List<Classifier> types = value.getTypes();
+ boolean conforms = false;
+ int j = 1;
+ while(!conforms & j <= types.size()) {
+ conforms = this.conforms(types.get(j - 1), classifier);
+ j = j + 1;
+ }
+ if(conforms) {
+ extent.add(value);
+ }
+ }
+ return extent;
+ }
+
+ public void add(ExtensionalValue value) {
+ // Add the given extensional value to this locus
+ value.locus = this;
+ this.extensionalValues.add(value);
+ }
+
+ public void remove(ExtensionalValue value) {
+ // Remove the given extensional value from this locus.
+ value.locus = null;
+ boolean notFound = true;
+ int i = 1;
+ while(notFound & i <= this.extensionalValues.size()) {
+ if(this.extensionalValues.get(i - 1) == value) {
+ this.extensionalValues.remove(i - 1);
+ notFound = false;
+ }
+ i = i + 1;
+ }
+ }
+
+ public Object_ instantiate(Class type) {
+ // Instantiate the given class at this locus.
+ Object_ object = null;
+ if(type instanceof Behavior) {
+ object = this.factory.createExecution((Behavior)type, null);
+ } else {
+ object = new Object_();
+ object.types.add(type);
+ object.createFeatureValues();
+ this.add(object);
+ }
+ return object;
+ }
+
+ public Boolean conforms(Classifier type, Classifier classifier) {
+ // Test if a type conforms to a given classifier, that is, the type is
+ // equal to or a descendant of the classifier.
+ boolean doesConform = false;
+ if(type == classifier) {
+ doesConform = true;
+ } else {
+ int i = 1;
+ while(!doesConform & i <= type.getGenerals().size()) {
+ doesConform = this.conforms(type.getGenerals().get(i - 1), classifier);
+ i = i + 1;
+ }
+ }
+ return doesConform;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticStrategy.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticStrategy.java
new file mode 100644
index 00000000000..eebf042c79f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticStrategy.java
@@ -0,0 +1,19 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+public abstract class SemanticStrategy {
+
+ public abstract String getName();
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticVisitor.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticVisitor.java
new file mode 100644
index 00000000000..2a530c94b98
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL1/SemanticVisitor.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1;
+
+import org.eclipse.papyrus.moka.fuml.debug.Debug;
+
+public abstract class SemanticVisitor {
+
+ public void _endIsolation() {
+ Debug.println("[_endIsolation] End isolation.");
+ }
+
+ public void _beginIsolation() {
+ Debug.println("[_beginIsolation] Begin isolation.");
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL2/ExecutionFactoryL2.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL2/ExecutionFactoryL2.java
new file mode 100644
index 00000000000..f46bf001559
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL2/ExecutionFactoryL2.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL2;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.CallBehaviorActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.CallOperationActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.InputPinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.OutputPinActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions.SendSignalActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.AddStructuralFeatureValueActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ClearAssociationActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ClearStructuralFeatureActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.CreateLinkActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.CreateObjectActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.DestroyLinkActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.DestroyObjectActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ReadLinkActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ReadSelfActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ReadStructuralFeatureActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.RemoveStructuralFeatureValueActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.TestIdentityActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.IntermediateActions.ValueSpecificationActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityFinalNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityParameterNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.DecisionNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.FlowFinalNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ForkNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.InitialNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.JoinNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.MergeNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ExecutionFactoryL1;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticVisitor;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityFinalNode;
+import org.eclipse.uml2.uml.ActivityParameterNode;
+import org.eclipse.uml2.uml.AddStructuralFeatureValueAction;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+import org.eclipse.uml2.uml.CallOperationAction;
+import org.eclipse.uml2.uml.ClearAssociationAction;
+import org.eclipse.uml2.uml.ClearStructuralFeatureAction;
+import org.eclipse.uml2.uml.CreateLinkAction;
+import org.eclipse.uml2.uml.CreateObjectAction;
+import org.eclipse.uml2.uml.DecisionNode;
+import org.eclipse.uml2.uml.DestroyLinkAction;
+import org.eclipse.uml2.uml.DestroyObjectAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.FlowFinalNode;
+import org.eclipse.uml2.uml.ForkNode;
+import org.eclipse.uml2.uml.InitialNode;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.JoinNode;
+import org.eclipse.uml2.uml.MergeNode;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.ReadLinkAction;
+import org.eclipse.uml2.uml.ReadSelfAction;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.RemoveStructuralFeatureValueAction;
+import org.eclipse.uml2.uml.SendSignalAction;
+import org.eclipse.uml2.uml.TestIdentityAction;
+import org.eclipse.uml2.uml.ValueSpecificationAction;
+
+public class ExecutionFactoryL2 extends ExecutionFactoryL1 {
+
+ public SemanticVisitor instantiateVisitor(Element element) {
+ // Instantiate a visitor object for the given element (at Conformance
+ // Level 2)
+ SemanticVisitor visitor = null;
+ if(element instanceof Activity) {
+ visitor = new ActivityExecution();
+ } else if(element instanceof ActivityParameterNode) {
+ visitor = new ActivityParameterNodeActivation();
+ } else if(element instanceof InitialNode) {
+ visitor = new InitialNodeActivation();
+ } else if(element instanceof ActivityFinalNode) {
+ visitor = new ActivityFinalNodeActivation();
+ } else if(element instanceof FlowFinalNode) {
+ visitor = new FlowFinalNodeActivation();
+ } else if(element instanceof JoinNode) {
+ visitor = new JoinNodeActivation();
+ } else if(element instanceof MergeNode) {
+ visitor = new MergeNodeActivation();
+ } else if(element instanceof ForkNode) {
+ visitor = new ForkNodeActivation();
+ } else if(element instanceof DecisionNode) {
+ visitor = new DecisionNodeActivation();
+ } else if(element instanceof InputPin) {
+ visitor = new InputPinActivation();
+ } else if(element instanceof OutputPin) {
+ visitor = new OutputPinActivation();
+ } else if(element instanceof CallBehaviorAction) {
+ visitor = new CallBehaviorActionActivation();
+ } else if(element instanceof CallOperationAction) {
+ visitor = new CallOperationActionActivation();
+ } else if(element instanceof SendSignalAction) {
+ visitor = new SendSignalActionActivation();
+ } else if(element instanceof ReadSelfAction) {
+ visitor = new ReadSelfActionActivation();
+ } else if(element instanceof TestIdentityAction) {
+ visitor = new TestIdentityActionActivation();
+ } else if(element instanceof ValueSpecificationAction) {
+ visitor = new ValueSpecificationActionActivation();
+ } else if(element instanceof CreateObjectAction) {
+ visitor = new CreateObjectActionActivation();
+ } else if(element instanceof DestroyObjectAction) {
+ visitor = new DestroyObjectActionActivation();
+ } else if(element instanceof ReadStructuralFeatureAction) {
+ visitor = new ReadStructuralFeatureActionActivation();
+ } else if(element instanceof ClearStructuralFeatureAction) {
+ visitor = new ClearStructuralFeatureActionActivation();
+ } else if(element instanceof AddStructuralFeatureValueAction) {
+ visitor = new AddStructuralFeatureValueActionActivation();
+ } else if(element instanceof RemoveStructuralFeatureValueAction) {
+ visitor = new RemoveStructuralFeatureValueActionActivation();
+ } else if(element instanceof ReadLinkAction) {
+ visitor = new ReadLinkActionActivation();
+ } else if(element instanceof ClearAssociationAction) {
+ visitor = new ClearAssociationActionActivation();
+ } else if(element instanceof CreateLinkAction) {
+ visitor = new CreateLinkActionActivation();
+ } else if(element instanceof DestroyLinkAction) {
+ visitor = new DestroyLinkActionActivation();
+ } else {
+ visitor = super.instantiateVisitor(element);
+ }
+ return visitor;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL3/ExecutionFactoryL3.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL3/ExecutionFactoryL3.java
new file mode 100644
index 00000000000..b637d89c99e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/Loci/LociL3/ExecutionFactoryL3.java
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL3;
+
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.AcceptEventActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.ReadExtentActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.ReadIsClassifiedObjectActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.ReclassifyObjectActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.ReduceActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.StartClassifierBehaviorActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Actions.CompleteActions.StartObjectBehaviorActionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities.ConditionalNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities.LoopNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.CompleteStructuredActivities.StructuredActivityNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities.ExpansionNodeActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Activities.ExtraStructuredActivities.ExpansionRegionActivation;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.SemanticVisitor;
+import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL2.ExecutionFactoryL2;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.ConditionalNode;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ExpansionNode;
+import org.eclipse.uml2.uml.ExpansionRegion;
+import org.eclipse.uml2.uml.LoopNode;
+import org.eclipse.uml2.uml.ReadExtentAction;
+import org.eclipse.uml2.uml.ReadIsClassifiedObjectAction;
+import org.eclipse.uml2.uml.ReclassifyObjectAction;
+import org.eclipse.uml2.uml.ReduceAction;
+import org.eclipse.uml2.uml.StartClassifierBehaviorAction;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+
+public class ExecutionFactoryL3 extends ExecutionFactoryL2 {
+
+ public SemanticVisitor instantiateVisitor(Element element) {
+ // Instantiate a visitor object for the given element (at Conformance
+ // Level 3)
+ SemanticVisitor visitor = null;
+ if(element instanceof ConditionalNode) {
+ visitor = new ConditionalNodeActivation();
+ } else if(element instanceof LoopNode) {
+ visitor = new LoopNodeActivation();
+ } else if(element instanceof ExpansionRegion) {
+ visitor = new ExpansionRegionActivation();
+ }
+ // Note: Since ConditionalNode, LoopNode and ExpansionRegion are
+ // subclasses of
+ // StructuredActivityNode, element must be tested against the three
+ // subclasses before
+ // the superclass
+ else if(element instanceof StructuredActivityNode) {
+ visitor = new StructuredActivityNodeActivation();
+ } else if(element instanceof ExpansionNode) {
+ visitor = new ExpansionNodeActivation();
+ } else if(element instanceof ReadExtentAction) {
+ visitor = new ReadExtentActionActivation();
+ } else if(element instanceof ReadIsClassifiedObjectAction) {
+ visitor = new ReadIsClassifiedObjectActionActivation();
+ } else if(element instanceof ReclassifyObjectAction) {
+ visitor = new ReclassifyObjectActionActivation();
+ } else if(element instanceof StartObjectBehaviorAction) {
+ visitor = new StartObjectBehaviorActionActivation();
+ } else if(element instanceof StartClassifierBehaviorAction) {
+ visitor = new StartClassifierBehaviorActionActivation();
+ } else if(element instanceof AcceptEventAction) {
+ visitor = new AcceptEventActionActivation();
+ } else if(element instanceof ReduceAction) {
+ visitor = new ReduceActionActivation();
+ } else {
+ visitor = super.instantiateVisitor(element);
+ }
+ return visitor;
+ }
+}

Back to the top