Skip to content

Commit 69e7f2e

Browse files
committed
Issue #31 (ALF11-14) - Updated to be consistent w/ proposed resolution.
1 parent 94505e2 commit 69e7f2e

File tree

10 files changed

+289
-216
lines changed

10 files changed

+289
-216
lines changed
277 Bytes
Binary file not shown.
277 Bytes
Binary file not shown.

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

Lines changed: 152 additions & 148 deletions
Large diffs are not rendered by default.

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

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -143,41 +143,47 @@ public static StructuredActivityNode wrapAction(
143143
* to feature references.
144144
*/
145145

146-
/**
147-
* BEHAVIOR INVOCATION MAPPING
148-
*
149-
* 1. A behavior invocation expression whose qualified name disambiguates to
150-
* a feature reference is mapped as if it were a feature invocation
151-
* expression. Otherwise, a behavior invocation expression is mapped as
152-
* either a behavior call or an association read.
153-
*
154-
* 2. A behavior invocation expression whose qualified name resolves to a
155-
* behavior maps to a call behavior action for the named behavior. If the
156-
* behavior invocation expression has a non-empty tuple, then the call
157-
* behavior action is the target of a control flow whose source is the
158-
* structured activity node mapped from the tuple. Each input pin of the
159-
* call behavior action corresponds to an in or inout parameter of the
160-
* called behavior. If there is an argument expression for that parameter in
161-
* the tuple, then the input pin is the target of an object flow whose
162-
* source is the result source element of the argument expression.
163-
* Similarly, each output pin of the call behavior action (other than the
164-
* output pin for a return parameter) corresponds to an out or inout
165-
* parameter. If there is an argument expression for that parameter in the
166-
* type, then the output pin is the source of an object flow whose target is
167-
* assigned value input for the argument expression. NOTE: Call behavior
168-
* action pins corresponding to unmatched parameters remain unconnected. If
169-
* the behavior has a return parameter, then the output pin of the call
170-
* behavior action corresponding to that parameter is the result source
171-
* element for the behavior invocation action. Otherwise it has no result
172-
* source element.
173-
*
174-
* 3. A behavior invocation expression whose qualified name resolves to an
175-
* association end maps to a read link action with end data for the ends of
176-
* the named association. Except for the end data for the target end, the
177-
* value input pins for each end are the target of an object flow from the
178-
* result source element of the mapping of the corresponding argument
179-
* expression. The result output pin of the read link action is the result
180-
* source element for the association selection.
146+
/**
147+
* BEHAVIOR INVOCATION MAPPING
148+
*
149+
* 1. A behavior invocation expression whose qualified name disambiguates to
150+
* a feature reference is mapped as if it were a feature invocation
151+
* expression. Otherwise, a behavior invocation expression is mapped as
152+
* either a behavior call or an association read.
153+
*
154+
* 2. A behavior invocation expression whose qualified name resolves to a
155+
* behavior maps to a call behavior action for the named behavior. If the
156+
* behavior invocation expression has a non-empty tuple, then the call
157+
* behavior action is the target of a control flow whose source is the
158+
* structured activity node mapped from the tuple. Each input pin of the
159+
* call behavior action corresponds to an in or inout parameter of the
160+
* called behavior. If there is an argument expression for that parameter in
161+
* the tuple, then the input pin is the target of an object flow whose
162+
* source is the result source element of the argument expression.
163+
* Similarly, each output pin of the call behavior action (other than the
164+
* output pin for a return parameter) corresponds to an out or inout
165+
* parameter. If there is an argument expression for that parameter in the
166+
* tuple, then the output pin is the source of an object flow whose target
167+
* is assigned value input for the argument expression. NOTE: Call behavior
168+
* action pins corresponding to unmatched parameters remain unconnected. If
169+
* the behavior does not have a return parameter, then the behavior
170+
* invocation expression has no result source element. Otherwise, the output
171+
* pin of the call behavior action corresponding to that parameter is the
172+
* result source element for the behavior invocation expression, unless
173+
* indexing from 0 applies to the behavior invocation expression and the
174+
* invocation is of a library function whose return value is affected by
175+
* this, in which case the output pin is connected by an object flow to an
176+
* invocation of the IntegerFunctions::- function whose second argument is
177+
* 1, and the result of that invocation provides the result source element
178+
* for the behavior invocation expression.
179+
*
180+
* 3. A behavior invocation expression whose qualified name resolves to an
181+
* association end maps to a read link action with end data for the ends of
182+
* the named association. Except for the end data for the target end, the
183+
* value input pins for each end are the target of an object flow from the
184+
* result source element of the mapping of the corresponding argument
185+
* expression. The result output pin of the read link action is the result
186+
* source element for the association selection.
181187
*/
182188

183189
/**

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public class LinkOperationExpressionMapping extends InvocationExpressionMapping
3535
* association end is ordered, then the insertAt input pin for that end is
3636
* the target of an object flow from the result source element of the
3737
* mapping of the corresponding index expression (which defaults to * if not
38-
* given explicitly).
38+
* given explicitly). If indexing from 0 applies to the link operation
39+
* expression, then the mapping of the index expression is adjusted as for
40+
* the index expression of a sequence access expression, except that the
41+
* value is first tested whether it is equal to * and then converted to an
42+
* integer and incremented only if it is not.
3943
*
4044
* 2. A link operation expression for the operation destroyLink maps to a
4145
* destroy link action for the named association. The value input pin of the
@@ -46,7 +50,11 @@ public class LinkOperationExpressionMapping extends InvocationExpressionMapping
4650
* isDestroyDuplicates=false and the insertAt input pin for that end is the
4751
* target of an object flow from the result source element of the mapping of
4852
* the corresponding index expression (which defaults to * if not given
49-
* explicitly).
53+
* explicitly). If indexing from 0 applies to the link operation
54+
* expression, then the mapping of the index expression is adjusted as for
55+
* the index expression of a sequence access expression, except that the
56+
* value is first tested whether it is equal to * and then converted to an
57+
* integer and incremented only if it is not.
5058
*
5159
* 3. A link operation expression for the link operation clearAssoc maps to
5260
* a clear association action for the named association. The object input

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

Lines changed: 12 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
@@ -23,15 +22,24 @@ public class SequenceAccessExpressionMapping extends BehaviorInvocationExpressio
2322
private InvocationExpression invocation = null;
2423
private ActivityNode indexSource = null;
2524

26-
/*
27-
* A sequence access expression is mapped to a call to the primitive
25+
/**
26+
* 1. A sequence access expression is mapped to a call to the primitive
2827
* behavior Alf::Library::PrimitiveBehaviors::SequenceFunctions::At. The
2928
* result source element of the primary expression of the sequence access
3029
* expression is connected by an object flow to the first argument input pin
3130
* of the call behavior action. The result source element of the index
3231
* expression is connected by an object flow to the second argument input
3332
* pin. The result output pin of the call behavior action is the result
3433
* source element for the sequence access expression.
34+
*
35+
* 2. If indexing from 0 applies to the sequence access expression, then the
36+
* mapping of its index expression is adjusted as follows. The result source
37+
* element of the index expression is connected by an object flow to the
38+
* first argument pin of a call to the primitive behavior
39+
* Alf::Library::PrimitiveBehaviors::IntegerFunctions::+, and the result of
40+
* a value specification action for the value 1 is connected to the second
41+
* argument pin. The result output pin of the call behavior action is then
42+
* used as the result source element for the index.
3543
*/
3644

3745
@Override

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*******************************************************************************
32
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
@@ -74,7 +73,11 @@ public abstract class TupleMapping extends SyntaxElementMapping {
7473
* connected by an object flow to an invocation of the
7574
* BitStringFunctions::toBitString function, and the result of that
7675
* invocation provides the source for setting the value of the associated
77-
* parameter.
76+
* parameter. If the tuple is in a behavior invocation expression or
77+
* sequence operation expression to which indexing from 0 applies, and the
78+
* parameter is an affected index parameter, then the mapping of the
79+
* argument expression is adjusted as for the index expression of a sequence
80+
* access expression.
7881
*
7982
* 3. For an argument for an out parameter, the argument expression is
8083
* mapped as a left hand side of an assignment: an argument that is a local

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/statements/StatementMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public Collection<Element> getModelElements() throws MappingError {
253253
}
254254

255255
public boolean isIndexFrom0() {
256-
return this.getStatement().getImpl().isIndexFrom0();
256+
return this.getStatement().getImpl().getIsIndexFrom0();
257257
}
258258

259259
public FumlMapping exprMap(Expression expression) {

org.modeldriven.alf/src/org/modeldriven/alf/syntax/statements/Statement.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*******************************************************************************
32
* Copyright 2011, 2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
@@ -98,6 +97,14 @@ public void setIsIsolated(Boolean isIsolated) {
9897
this.getImpl().setIsIsolated(isIsolated);
9998
}
10099

100+
public Boolean getIsIndexFrom0() {
101+
return this.getImpl().getIsIndexFrom0();
102+
}
103+
104+
public void setIsIndexFrom0(Boolean isIndexFrom0) {
105+
this.getImpl().setIsIndexFrom0(isIndexFrom0);
106+
}
107+
101108
/**
102109
* All the annotations of a statement must be allowed, as given by the
103110
* annotationAllowed operation for the statement.
@@ -120,6 +127,15 @@ public boolean statementIsIsolatedDerivation() {
120127
return this.getImpl().statementIsIsolatedDerivation();
121128
}
122129

130+
/**
131+
* A statement has indexing from 0 if it has an @indexFrom0 annotation, or
132+
* it is contained in a statement with indexing from 0 and it does not have
133+
* an @indexFrom1 annotation applied.
134+
*/
135+
public boolean statementIsIndexFrom0Derivation() {
136+
return this.getImpl().statementIsIndexFrom0Derivation();
137+
}
138+
123139
/**
124140
* Returns true if the given annotation is allowed for this kind of
125141
* statement. By default, only an @isolated annotation is allowed, with no
@@ -144,6 +160,7 @@ public void _deriveAll() {
144160
this.getAssignmentAfter();
145161
this.getEnclosingStatement();
146162
this.getIsIsolated();
163+
this.getIsIndexFrom0();
147164
super._deriveAll();
148165
Collection<Annotation> annotation = this.getAnnotation();
149166
if (annotation != null) {
@@ -163,10 +180,14 @@ public void checkConstraints(Collection<ConstraintViolation> violations) {
163180
violations.add(new ConstraintViolation(
164181
"statementUniqueAssignments", this));
165182
}
166-
if (!this.statementIsIsolatedDerivation()) {
167-
violations.add(new ConstraintViolation(
168-
"statementIsIsolatedDerivation", this));
169-
}
183+
if (!this.statementIsIsolatedDerivation()) {
184+
violations.add(new ConstraintViolation(
185+
"statementIsIsolatedDerivation", this));
186+
}
187+
if (!this.statementIsIndexFrom0Derivation()) {
188+
violations.add(new ConstraintViolation(
189+
"statementIsIndexFrom0Derivation", this));
190+
}
170191
Collection<Annotation> annotation = this.getAnnotation();
171192
if (annotation != null) {
172193
for (Object _annotation : annotation.toArray()) {
@@ -180,6 +201,8 @@ public String _toString(boolean includeDerived) {
180201
if (includeDerived) {
181202
s.append(" /isIsolated:");
182203
s.append(this.getIsIsolated());
204+
s.append(" /isIndexFrom0:");
205+
s.append(this.getIsIndexFrom0());
183206
}
184207
return s.toString();
185208
}

org.modeldriven.alf/src/org/modeldriven/alf/syntax/statements/impl/StatementImpl.java

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*******************************************************************************
32
* Copyright 2011, 2016 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
@@ -35,7 +34,8 @@ public abstract class StatementImpl extends DocumentedElementImpl {
3534
private Map<String, AssignedSource> assignmentBefore = null; // DERIVED
3635
private Map<String, AssignedSource> assignmentAfter = null; // DERIVED
3736
private Statement enclosingStatement = null; // DERIVED
38-
private Boolean isIsolated = null; // DERIVED
37+
private Boolean isIsolated = null; // DERIVED
38+
private Boolean isIndexFrom0 = null; // DERIVED
3939

4040
public StatementImpl(Statement self) {
4141
super(self);
@@ -161,6 +161,17 @@ public void setIsIsolated(Boolean isIsolated) {
161161
this.isIsolated = isIsolated;
162162
}
163163

164+
public Boolean getIsIndexFrom0() {
165+
if (this.isIndexFrom0 == null) {
166+
this.setIsIndexFrom0(this.deriveIsIndexFrom0());
167+
}
168+
return this.isIndexFrom0;
169+
}
170+
171+
public void setIsIndexFrom0(Boolean isIndexFrom0) {
172+
this.isIndexFrom0 = isIndexFrom0;
173+
}
174+
164175
/**
165176
* The assignments before are usually set externally.
166177
*/
@@ -189,15 +200,37 @@ protected Boolean deriveIsIsolated() {
189200
return this.hasAnnotation("isolated");
190201
}
191202

203+
/**
204+
* A statement has indexing from 0 if it has an @indexFrom0 annotation, or
205+
* it is contained in a statement with indexing from 0 and it does not have
206+
* an @indexFrom1 annotation applied.
207+
*/
208+
protected Boolean deriveIsIndexFrom0() {
209+
if (this.hasAnnotation("indexFrom0")) {
210+
return true;
211+
} else if (this.hasAnnotation("indexFrom1")) {
212+
return false;
213+
} else {
214+
Statement enclosingStatement = this.getSelf().getEnclosingStatement();
215+
return enclosingStatement != null &&
216+
enclosingStatement.getIsIndexFrom0();
217+
}
218+
}
219+
192220
/*
193221
* Derivations
194222
*/
195223

196-
public boolean statementIsIsolatedDerivation() {
197-
this.getSelf().getIsIsolated();
198-
return true;
199-
}
200-
224+
public boolean statementIsIsolatedDerivation() {
225+
this.getSelf().getIsIsolated();
226+
return true;
227+
}
228+
229+
public boolean statementIsIndexFrom0Derivation() {
230+
this.getSelf().getIsIsolated();
231+
return true;
232+
}
233+
201234
/*
202235
* Constraints
203236
*/
@@ -259,18 +292,6 @@ public boolean hasAnnotation(String name) {
259292
return false;
260293
}
261294

262-
public boolean isIndexFrom0() {
263-
if (this.hasAnnotation("indexFrom0")) {
264-
return true;
265-
} else if (this.hasAnnotation("indexFrom1")) {
266-
return false;
267-
} else {
268-
Statement enclosingStatement = this.getSelf().getEnclosingStatement();
269-
return enclosingStatement != null &&
270-
enclosingStatement.getImpl().isIndexFrom0();
271-
}
272-
}
273-
274295
private static boolean uniqueAssignments(Collection<AssignedSource> assignments) {
275296
return new HashSet<AssignedSource>(assignments).size() == assignments.size();
276297
}

0 commit comments

Comments
 (0)