Skip to content

Commit 7b6eae1

Browse files
Merge pull request #3 from HammerMaximilian/development
development --> master 2.0.0
2 parents 62c10a8 + 8c88470 commit 7b6eae1

File tree

366 files changed

+100074
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+100074
-33
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ For detailed information, please see the [User Guide](fUML-CSharp_User_Guide.pdf
3838
* NOTE: it is suggested to store user-defined source code projects in common directory `"<fUML-C#-rootdir>\fUML-CSharp\usersrc"`
3939
* The *usersrc* directory may contain arbitrary nested subdirectories
4040
* Add required assemblies for uml, fuml and pscs to your project's references
41-
* Create a `<model-name>Environment` class by deriving from class `fuml.environment.Environment`
41+
* Create a `<model-name>Environment` class by deriving from class `fuml.environment.Environment` (or `pscs.environment.Environment` for PSCS-compatibility)
4242
* Create a `<model-name>Model` class by deriving from class `uml.environment.InMemoryModel` (this class will contain all of your model elements)
4343
* Create a class containing a main method and call `<model-name>Environment.Instance().Execute("<behavior-name>");` for each behavior you want to execute in subsequent order
4444
* Build project and run executable
@@ -55,4 +55,5 @@ For detailed information, please see the [User Guide](fUML-CSharp_User_Guide.pdf
5555
* Choose your model file
5656
* Choose a target directory for the generated source code (`"<fUML-C#-rootdir>\fUML-CSharp\usersrc\<model-name>"` is suggested)
5757
* Open newly generated C# project in Visual Studio and build executable(s)
58+
* **NOTE**: Depending on the target directory path it might be necessary to adapt the project's dependencies to the *uml*, *fuml* and *pscs* assemblies since they are referenced by relative paths. This only applies if you choose a target directory structure that differes from the one suggested above.
5859
* Run executable from command line using `<executable-name> <behavior-name> [<behavior-name> <behavior-name> <behavior-name> <...>]`
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using fuml.semantics.structuredclassifiers;
2+
using uml.classification;
3+
using uml.commonstructure;
4+
5+
namespace fuml.extensions.structuredclassifiers
6+
{
7+
public class UMLConformingDispatchStrategy : RedefinitionBasedDispatchStrategy
8+
{
9+
public override bool OperationsMatch(
10+
Operation ownedOperation,
11+
Operation baseOperation)
12+
{
13+
// Check if the owned operation is equal to or overrides the base operation.
14+
// In this context, an owned operation overrides a base operation if:
15+
// - base operation is directly or indirectly redefined by owned operation
16+
// - the class that owns base operation is equal to or a base class of the class that owns owned operation
17+
// - they have the same number of owned parameters and for each parameter the following holds:
18+
// - direction, ordering and uniqueness are the same
19+
// - the corresponding types are covariant, contravariant or invariant
20+
// - the multiplicities are compatible depending on the parameter direction
21+
22+
bool matches = base.OperationsMatch(ownedOperation, baseOperation);
23+
if (matches)
24+
{
25+
matches = IsConsistentWith(ownedOperation, baseOperation);
26+
}
27+
28+
return matches;
29+
} // operationsMatch
30+
31+
public bool IsConsistentWith(
32+
Operation ownedOperation,
33+
Operation baseOperation)
34+
{
35+
bool isConsistentWith;
36+
37+
isConsistentWith = ConformsTo(ownedOperation.class_!, baseOperation.class_!);
38+
39+
List<Parameter> ownedOperationParameters = ownedOperation.ownedParameter;
40+
List<Parameter> baseOperationParameters = baseOperation.ownedParameter;
41+
42+
isConsistentWith = isConsistentWith && (baseOperationParameters.Count == ownedOperationParameters.Count);
43+
44+
for (int i = 0; isConsistentWith == true && i < ownedOperationParameters.Count; i++)
45+
{
46+
Parameter redefiningParameter = ownedOperationParameters.ElementAt(i);
47+
Parameter redefinedParameter = baseOperationParameters.ElementAt(i);
48+
49+
isConsistentWith = isConsistentWith && (redefiningParameter.multiplicityElement.isUnique == redefinedParameter.multiplicityElement.isUnique);
50+
isConsistentWith = isConsistentWith && (redefiningParameter.multiplicityElement.isOrdered == redefinedParameter.multiplicityElement.isOrdered);
51+
isConsistentWith = isConsistentWith && (redefiningParameter.direction == redefinedParameter.direction);
52+
53+
Classifier redefiningParameterType = (Classifier)redefiningParameter.type!;
54+
Classifier redefinedParameterType = (Classifier)redefinedParameter.type!;
55+
isConsistentWith = isConsistentWith && (ConformsTo(redefiningParameterType, redefinedParameterType) || ConformsTo(redefinedParameterType, redefiningParameterType));
56+
57+
if (redefinedParameter.direction == ParameterDirectionKind.inout)
58+
{
59+
isConsistentWith = isConsistentWith &&
60+
(
61+
CompatibleWith(redefiningParameter.multiplicityElement, redefinedParameter.multiplicityElement) &&
62+
CompatibleWith(redefinedParameter.multiplicityElement, redefiningParameter.multiplicityElement)
63+
);
64+
}
65+
else if (redefinedParameter.direction == ParameterDirectionKind.in_)
66+
{
67+
isConsistentWith = isConsistentWith && CompatibleWith(redefinedParameter.multiplicityElement, redefiningParameter.multiplicityElement);
68+
}
69+
else // i.e. if((redefinedParameter.direction == ParameterDirectionKind.out_) || (redefinedParameter.direction == ParameterDirectionKind.return_))
70+
{
71+
isConsistentWith = isConsistentWith && CompatibleWith(redefiningParameter.multiplicityElement, redefinedParameter.multiplicityElement);
72+
}
73+
}
74+
75+
return isConsistentWith;
76+
}
77+
78+
public bool ConformsTo(Classifier type, Classifier otherType)
79+
{
80+
bool conformsTo = false;
81+
82+
if (type == otherType)
83+
{
84+
conformsTo = true;
85+
}
86+
else
87+
{
88+
int i = 1;
89+
while (conformsTo is false && i <= type.general.Count)
90+
{
91+
Classifier general = type.general.ElementAt(i);
92+
conformsTo = ConformsTo(general, otherType);
93+
}
94+
}
95+
96+
return conformsTo;
97+
}
98+
99+
public bool CompatibleWith(MultiplicityElement self, MultiplicityElement other)
100+
{
101+
bool compatibleWith = (other.lower <= self.lower) && ((other.upper.naturalValue == -1) || (self.upper.naturalValue <= other.upper.naturalValue));
102+
103+
return compatibleWith;
104+
}
105+
} // UMLConformingDispatchStrategy
106+
}

fUML-CSharp/fuml/src/fuml/semantics/actions/ActionActivation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public override bool IsReady()
147147

148148
List<InputPin> inputPins = ((uml.actions.Action)node!).input;
149149
int j = 1;
150-
while (ready & j <= inputPins.Count)
150+
while (ready && j <= inputPins.Count)
151151
{
152152
ready = GetPinActivation(inputPins.ElementAt(j - 1)).IsReady();
153153
j++;

fUML-CSharp/fuml/src/fuml/semantics/actions/DestroyObjectActionActivation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void DestroyObject(Value value,
4141
{
4242
List<ExtensionalValue> extensionalValues =
4343
GetExecutionLocus().extensionalValues;
44-
foreach (ExtensionalValue extensionalValue in extensionalValues)
44+
foreach (ExtensionalValue extensionalValue in extensionalValues.ToList())
4545
{
4646
if (extensionalValue is Link link)
4747
{

fUML-CSharp/fuml/src/fuml/semantics/commonbehavior/ObjectActivation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void StartBehavior(
141141
// Start EventDispatchLoop
142142
_startObjectBehavior();
143143

144-
if (classifier is not null)
144+
if (classifier is null)
145145
{
146146
Debug.Println("[startBehavior] Starting behavior for all classifiers...");
147147
// *** Start all classifier behaviors concurrently. ***

fUML-CSharp/fuml/src/fuml/semantics/structuredclassifiers/ReferenceExtension.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ public virtual Execution Dispatch(
1111
bool isExplicitBaseClassCall = false)
1212
{
1313
// Extends Reference.Dispatch(Operation) by flag "isExplicitBaseClassCall"
14-
// Propagate "isExplicitBaseClassCall" to Object_.GetMethod
14+
// If "isExplicitBaseClassCall" is true, delegate to Object_.Dispatch(Operation, bool).
15+
// Else, call standard method Dispatch(Operation) to maintain possible method overriding.
1516

16-
return (referent is not null) ? referent.Dispatch(operation, isExplicitBaseClassCall) : null!;
17+
if(isExplicitBaseClassCall)
18+
{
19+
return (referent is not null) ? referent.Dispatch(operation, isExplicitBaseClassCall) : null!;
20+
}
21+
else
22+
{
23+
return Dispatch(operation);
24+
}
25+
1726
} // Dispatch
1827
} // Reference
1928
}

0 commit comments

Comments
 (0)