Skip to content

Commit 81de79f

Browse files
committed
Made minor improvements to sequence expansion expression mappings.
- Avoided creating a structured activity node for a primary expression that does not map to any elements. - Correctly set the types of the expansion nodes for collect, iterate and isUnique expressions.
1 parent 6ee87e1 commit 81de79f

File tree

8 files changed

+114387
-114379
lines changed

8 files changed

+114387
-114379
lines changed

org.modeldriven.alf.eclipse/UML/Expressions_Sequence_Expansion_Reduction.uml

Lines changed: 5123 additions & 5127 deletions
Large diffs are not rendered by default.

org.modeldriven.alf.eclipse/UML/_RunTests.uml

Lines changed: 109219 additions & 109225 deletions
Large diffs are not rendered by default.
502 Bytes
Binary file not shown.

org.modeldriven.alf/src/org/modeldriven/alf/execution/AlfBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public abstract class AlfBase {
2626

27-
public static final String ALF_VERSION = "1.0.3";
27+
public static final String ALF_VERSION = "1.0.4/dev-01";
2828

2929
protected boolean isVerbose = false;
3030

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/CollectOrIterateExpressionMapping.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*******************************************************************************
3-
* Copyright 2011, 2013 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011, 2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
54
* are made available for use under the terms of the GNU General Public License
65
* (GPL) version 3 that accompanies this distribution and is available at
@@ -17,6 +16,7 @@
1716
import org.modeldriven.alf.syntax.expressions.CollectOrIterateExpression;
1817

1918
import org.modeldriven.alf.uml.ActivityNode;
19+
import org.modeldriven.alf.uml.Classifier;
2020

2121
public class CollectOrIterateExpressionMapping extends
2222
SequenceExpansionExpressionMapping {
@@ -42,11 +42,13 @@ protected ActivityNode mapNestedGraph(
4242
}
4343

4444
@Override
45-
public void map() throws MappingError {
46-
super.map();
45+
public Classifier map() throws MappingError {
46+
Classifier argumentType = super.map();
47+
this.region.getOutputElement().get(0).setType(argumentType);
4748
if ("iterate".equals(this.getCollectOrIterateExpression().getOperation())) {
4849
this.region.setMode("iterative");
4950
}
51+
return argumentType;
5052
}
5153

5254
public CollectOrIterateExpression getCollectOrIterateExpression() {

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/ForAllOrExistsOrOneExpressionMapping.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*******************************************************************************
3-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
54
* are made available for use under the terms of the GNU General Public License
65
* (GPL) version 3 that accompanies this distribution and is available at
@@ -20,6 +19,7 @@
2019
import org.modeldriven.alf.uml.TestIdentityAction;
2120
import org.modeldriven.alf.uml.ValueSpecificationAction;
2221
import org.modeldriven.alf.uml.ActivityNode;
22+
import org.modeldriven.alf.uml.Classifier;
2323

2424
public class ForAllOrExistsOrOneExpressionMapping extends
2525
SequenceExpansionExpressionMapping {
@@ -83,8 +83,8 @@ protected boolean isTerminated(String operation) {
8383
}
8484

8585
@Override
86-
public void map() throws MappingError {
87-
super.map();
86+
public Classifier map() throws MappingError {
87+
Classifier argumentType = super.map();
8888

8989
String operation = this.getForAllOrExistsOrOneExpression().getOperation();
9090

@@ -102,6 +102,8 @@ public void map() throws MappingError {
102102
this.graph.addObjectFlow(valueAction.getResult(), testAction.getSecond());
103103
this.resultSource = testAction.getResult();
104104
}
105+
106+
return argumentType;
105107
}
106108

107109
public ForAllOrExistsOrOneExpression getForAllOrExistsOrOneExpression() {

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/IsUniqueExpressionMapping.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*******************************************************************************
3-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
54
* are made available for use under the terms of the GNU General Public License
65
* (GPL) version 3 that accompanies this distribution and is available at
@@ -49,8 +48,9 @@ protected boolean isSelectLike(String operation) {
4948
}
5049

5150
@Override
52-
public void map() throws MappingError {
53-
super.map();
51+
public Classifier map() throws MappingError {
52+
Classifier argumentType = super.map();
53+
this.region.getOutputElement().get(0).setType(argumentType);
5454

5555
ActivityGraph nestedGraph = this.createActivityGraph();
5656
ActivityNode forkNode =
@@ -87,16 +87,20 @@ public void map() throws MappingError {
8787
// result in an input pin at the expansion region boundary.
8888
IsUniqueExpression expression = this.getIsUniqueExpression();
8989
ExpansionRegion region = this.graph.addExpansionRegion(
90-
"Uniqueness(" + expression.getClass().getSimpleName()+
90+
"Uniqueness(" + expression.getClass().getSimpleName() +
9191
"@" + expression.getId() + ")",
9292
"parallel",
9393
nestedGraph.getModelElements(),
94-
forkNode, variableSource, nestedResult);
94+
forkNode, variableSource, nestedResult);
95+
region.getInputElement().get(0).setType(argumentType);
96+
region.getOutputElement().get(0).setType(argumentType);
9597
this.graph.addControlFlow(forkStructureNode, region);
9698
this.resultSource = region.getOutputElement().get(0);
9799

98100
// Add the final check that there are no elements with a count != 1.
99-
this.addBehaviorCall(RootNamespace.getRootScope().getSequenceFunctionIsEmpty());
101+
this.addBehaviorCall(RootNamespace.getRootScope().getSequenceFunctionIsEmpty());
102+
103+
return argumentType;
100104
}
101105

102106
public IsUniqueExpression getIsUniqueExpression() {

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/SequenceExpansionExpressionMapping.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*******************************************************************************
3-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
54
* are made available for use under the terms of the GNU General Public License
65
* (GPL) version 3 that accompanies this distribution and is available at
@@ -115,9 +114,11 @@ protected void mapRegion(
115114
this.mapTo(this.region);
116115
}
117116

118-
public void map() throws MappingError {
117+
public Classifier map() throws MappingError {
119118
SequenceExpansionExpression expression =
120-
this.getSequenceExpansionExpression();
119+
this.getSequenceExpansionExpression();
120+
121+
Classifier argumentType = null;
121122

122123
ExtentOrExpression primary = expression.getPrimary();
123124
FumlMapping mapping = this.fumlMap(
@@ -127,10 +128,14 @@ public void map() throws MappingError {
127128
mapping.getErrorMessage());
128129
} else {
129130
ExpressionMapping primaryMapping = (ExpressionMapping)mapping;
130-
ActivityNode primaryNode = this.graph.addStructuredActivityNode(
131-
"Primary(" + expression.getClass().getSimpleName() +
132-
"@" + expression.getId() + ")",
133-
primaryMapping.getModelElements());
131+
Collection<Element> elements = primaryMapping.getModelElements();
132+
ActivityNode primaryNode = null;
133+
if (!elements.isEmpty()) {
134+
primaryNode = this.graph.addStructuredActivityNode(
135+
"Primary(" + expression.getClass().getSimpleName() +
136+
"@" + expression.getId() + ")",
137+
primaryMapping.getModelElements());
138+
}
134139
ActivityGraph nestedGraph = this.createActivityGraph();
135140
this.variableSource = nestedGraph.addForkNode(
136141
"Fork(" + expression.getVariable() + ")");
@@ -140,7 +145,8 @@ public void map() throws MappingError {
140145
this.throwError("Error mapping argument: " +
141146
mapping.getErrorMessage());
142147
} else {
143-
ExpressionMapping argumentMapping = (ExpressionMapping)mapping;
148+
ExpressionMapping argumentMapping = (ExpressionMapping)mapping;
149+
argumentType = argumentMapping.getType();
144150
nestedGraph.addAll(argumentMapping.getGraph());
145151

146152
this.mapRegion(
@@ -151,9 +157,13 @@ public void map() throws MappingError {
151157
this.variableSource);
152158
this.region.getInputElement().get(0).setType(primaryMapping.getType());
153159
this.region.getOutputElement().get(0).setType(primaryMapping.getType());
154-
this.graph.addControlFlow(primaryNode, this.region);
160+
if (primaryNode != null) {
161+
this.graph.addControlFlow(primaryNode, this.region);
162+
}
155163
}
156-
}
164+
}
165+
166+
return argumentType;
157167
}
158168

159169
//Used by subclasses

0 commit comments

Comments
 (0)