Skip to content

Commit 15705a5

Browse files
committed
Issue #55 - Added control flow from tuple to structured node for call.
1 parent da3248a commit 15705a5

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed
295 Bytes
Binary file not shown.

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

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2017 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2018 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -59,45 +59,60 @@ public Action mapAction() throws MappingError {
5959

6060
public Action mapAction(boolean mayWrapAction) throws MappingError {
6161
Action action = this.mapTarget();
62-
62+
6363
InvocationExpression expression = this.getInvocationExpression();
64-
64+
6565
Tuple tuple = expression.getTuple();
6666
FumlMapping mapping = this.fumlMap(tuple);
67-
if (mapping instanceof TupleMapping) {
67+
if (!(mapping instanceof TupleMapping)) {
68+
this.throwError("Error mapping tuple:" + tuple);
69+
} else {
6870
TupleMapping tupleMapping = (TupleMapping)mapping;
6971
tupleMapping.setIsIndexFrom0(this.isIndexFrom0());
7072
tupleMapping.mapTo(action);
7173
this.graph.addAll(tupleMapping.getTupleGraph());
7274
this.lhsGraph = tupleMapping.getLhsGraph();
7375
this.assignedValueSourceMap = tupleMapping.getAssignedValueSourceMap();
74-
} else {
75-
this.throwError("Error mapping tuple:" + tuple);
76-
}
7776

78-
action = this.mapFeature(action);
79-
80-
// NOTE: mayWrapAction is only set to false for the mapping of the
81-
// equivalent invocation expression of a sequence access expression.
82-
if (mayWrapAction &&
83-
(action instanceof CallBehaviorAction ||
84-
action instanceof CallOperationAction) &&
85-
!((CallAction)action).getArgument().isEmpty() &&
86-
this.resultSource instanceof OutputPin) {
87-
action = this.adjustAction(
88-
this.graph, action, (OutputPin)this.resultSource);
89-
this.resultSource = ((StructuredActivityNode)action).
90-
getStructuredNodeOutput().get(0);
91-
92-
}
93-
94-
// NOTE: Adding left-hand side elements here prevents them from being
95-
// wrapped in the expansion region mapped from a sequence feature
96-
// invocation.
97-
this.graph.addAll(this.lhsGraph);
77+
action = this.mapFeature(action);
78+
79+
// NOTE: mayWrapAction is only set to false for the mapping of the
80+
// equivalent invocation expression of a sequence access expression.
81+
if (mayWrapAction &&
82+
(action instanceof CallBehaviorAction ||
83+
action instanceof CallOperationAction) &&
84+
!((CallAction)action).getArgument().isEmpty() &&
85+
this.resultSource instanceof OutputPin) {
86+
StructuredActivityNode node = this.adjustAction(
87+
this.graph, action, (OutputPin)this.resultSource);
88+
this.resultSource = node.getStructuredNodeOutput().get(0);
89+
90+
ActivityNode tupleNode = (ActivityNode)tupleMapping.getElement();
91+
if (tupleNode != null) {
92+
this.graph.addControlFlow(tupleNode, node);
93+
if (action instanceof CallOperationAction) {
94+
InputPin targetPin = ((CallOperationAction)action).getTarget();
95+
InputPin inputPin = graph.createInputPin(
96+
"Input(" + targetPin.getName() + ")",
97+
targetPin.getType(), 1, 1);
98+
ActivityEdge incomingEdge = targetPin.getIncoming().remove(0);
99+
incomingEdge.setTarget(inputPin);
100+
node.addStructuredNodeInput(inputPin);
101+
node.addEdge(this.graph.createObjectFlow(inputPin, targetPin));
102+
}
103+
}
104+
105+
action = node;
106+
}
107+
108+
// NOTE: Adding left-hand side elements here prevents them from being
109+
// wrapped in the expansion region mapped from a sequence feature
110+
// invocation.
111+
this.graph.addAll(this.lhsGraph);
112+
}
98113

99114
return action;
100-
}
115+
}
101116

102117
private StructuredActivityNode adjustAction(
103118
ActivityGraph graph, Action action, OutputPin resultPin) throws MappingError {

0 commit comments

Comments
 (0)