Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-27 14:27:49 +0000
committerEd Willink2016-10-27 14:27:49 +0000
commit38be5099f5c1415b4b7287a00aa094a5a1594edf (patch)
treeda0178a84bbcd55838145b6ee2a6461cbdcd6009
parentc46bad6dab2a579d9cb54a5cebfbbe5ba3fea52c (diff)
downloadorg.eclipse.qvtd-38be5099f5c1415b4b7287a00aa094a5a1594edf.tar.gz
org.eclipse.qvtd-38be5099f5c1415b4b7287a00aa094a5a1594edf.tar.xz
org.eclipse.qvtd-38be5099f5c1415b4b7287a00aa094a5a1594edf.zip
[506352] Ensure QVTi names are distinct
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/AbstractScheduledRegion2Mapping.java2
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java2
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/CyclicScheduledRegion2Mapping.java6
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/QVTs2QVTiVisitor.java20
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/RootRegion2Mapping.java3
5 files changed, 24 insertions, 9 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/AbstractScheduledRegion2Mapping.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/AbstractScheduledRegion2Mapping.java
index f7aaf387f..24eef481e 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/AbstractScheduledRegion2Mapping.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/AbstractScheduledRegion2Mapping.java
@@ -186,7 +186,7 @@ public abstract class AbstractScheduledRegion2Mapping extends AbstractRegion2Map
if (type instanceof CollectionType) {
Type elementType = ((CollectionType)type).getElementType();
assert elementType != null;
- LoopVariable loopVariable = helper.createLoopVariable("loop" + loopVariables.size(), elementType);//, true, sourceExpression);
+ LoopVariable loopVariable = helper.createLoopVariable(getSafeName("loop" + loopVariables.size()), elementType);//, true, sourceExpression);
loopVariables.put(loopVariable, sourceExpression);
// sourceExpression = PivotUtil.createVariableExp(loopVariable);
AbstractRegion2Mapping calledRegion2Mapping = visitor.getRegion2Mapping(targetNode.getRegion());
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
index c8a351ca2..3711678d1 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/BasicRegion2Mapping.java
@@ -873,7 +873,7 @@ public class BasicRegion2Mapping extends AbstractRegion2Mapping
}
Type elementType = ((CollectionType)type).getElementType();
assert elementType != null;
- LoopVariable loopVariable = helper.createLoopVariable("loop" + loopVariables.size(), elementType);//, true, sourceExpression);
+ LoopVariable loopVariable = helper.createLoopVariable(getSafeName("loop" + loopVariables.size()), elementType);//, true, sourceExpression);
loopVariables.put(loopVariable, sourceExpression);
// sourceExpression = PivotUtil.createVariableExp(loopVariable);
VariableDeclaration guardVariable = calledRegion2Mapping.getGuardVariable(targetNode);
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/CyclicScheduledRegion2Mapping.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/CyclicScheduledRegion2Mapping.java
index 6b8fbf0ca..61449639d 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/CyclicScheduledRegion2Mapping.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/CyclicScheduledRegion2Mapping.java
@@ -120,13 +120,13 @@ public class CyclicScheduledRegion2Mapping extends AbstractScheduledRegion2Mappi
// && !incoming2outgoing.values().contains(internallyPassedConnection)) { // Multiple should not occur, but line them up pair-wise
// incoming2outgoing.put(incomingConnection, internallyPassedConnection);
Type asType = getConnectionSourcesType(incomingConnection);
- String localName = "«local" + (index > 0 ? Integer.toString(index) : "") + "»";
+ String localName = getSafeName("«local" + (index > 0 ? Integer.toString(index) : "") + "»");
localVariable = helper.createBufferStatement(localName, asType, true, null);
mapping.getOwnedStatements().add(localVariable);
connection2variable.put(outgoingConnection, localVariable);
//
if ((asType instanceof CollectionType) && ((CollectionType)asType).isUnique()) {
- String newName = "«new" + (index > 0 ? Integer.toString(index) : "") + "»";
+ String newName = getSafeName("«new" + (index > 0 ? Integer.toString(index) : "") + "»");
BufferStatement newVariable2 = newVariable = helper.createBufferStatement(newName, asType, true, null);
mapping.getOwnedStatements().add(newVariable2);
connection2variable.put(outgoingConnection, newVariable2);
@@ -228,7 +228,7 @@ public class CyclicScheduledRegion2Mapping extends AbstractScheduledRegion2Mappi
if (connectionVariable == null) {
String name = intermediateConnection.getName();
assert name != null;
- connectionVariable = helper.createAppendParameter(name, getConnectionSourcesType(intermediateConnection), true);
+ connectionVariable = helper.createAppendParameter(getSafeName(name), getConnectionSourcesType(intermediateConnection), true);
connection2variable.put(intermediateConnection, connectionVariable);
mapping.getOwnedParameters().add(connectionVariable);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/QVTs2QVTiVisitor.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/QVTs2QVTiVisitor.java
index 8d5b1d427..a06791894 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/QVTs2QVTiVisitor.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/QVTs2QVTiVisitor.java
@@ -11,6 +11,7 @@
package org.eclipse.qvtd.compiler.internal.qvts2qvti;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -251,9 +252,19 @@ public class QVTs2QVTiVisitor extends QVTimperativeHelper implements Visitor<Ele
}
}
- // public @NonNull ChainNode getChain(@NonNull Region region) {
- // return chainGraph.getChain(region);
- // }
+ protected void gatherReservedPackageNames(@NonNull Set<@NonNull String> reservedNames, @NonNull Iterable<org.eclipse.ocl.pivot.Package> asPackages) {
+ for (org.eclipse.ocl.pivot.Package asPackage : asPackages) {
+ reservedNames.add(ClassUtil.nonNullState(asPackage.getName()));
+ gatherReservedClassNames(reservedNames, asPackage.getOwnedClasses());
+ gatherReservedPackageNames(reservedNames, asPackage.getOwnedPackages());
+ }
+ }
+
+ protected void gatherReservedClassNames(@NonNull Set<@NonNull String> reservedNames, @NonNull Iterable<org.eclipse.ocl.pivot.Class> asClasses) {
+ for (org.eclipse.ocl.pivot.Class asClass : asClasses) {
+ reservedNames.add(ClassUtil.nonNullState(asClass.getName()));
+ }
+ }
public @NonNull EnvironmentFactory getEnvironmentFactory() {
return environmentFactory;
@@ -304,9 +315,12 @@ public class QVTs2QVTiVisitor extends QVTimperativeHelper implements Visitor<Ele
Set<@NonNull String> reservedNames2 = reservedNames;
if (reservedNames2 == null) {
reservedNames = reservedNames2 = new HashSet<@NonNull String>();
+ org.eclipse.ocl.pivot.Package standardLibraryPackage = standardLibrary.getPackage();
+ gatherReservedPackageNames(reservedNames2, Collections.singletonList(standardLibraryPackage));
reservedNames2.add(ClassUtil.nonNull(qvtpTransformation.getName()));
for (TypedModel typedModel : qvtpTransformation.getModelParameter()) {
reservedNames2.add(ClassUtil.nonNullState(typedModel.getName()));
+ gatherReservedPackageNames(reservedNames2, typedModel.getUsedPackage());
}
for (Operation operation : qvtpTransformation.getOwnedOperations()) {
reservedNames2.add(ClassUtil.nonNull(operation.getName()));
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/RootRegion2Mapping.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/RootRegion2Mapping.java
index 8e6f35b8d..98335d0a6 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/RootRegion2Mapping.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvti/RootRegion2Mapping.java
@@ -118,7 +118,8 @@ public class RootRegion2Mapping extends AbstractScheduledRegion2Mapping
OCLExpression asSource = helper.createOperationCallExp(modelExp, "objectsOfKind", typeExp);
Type sourceType = asSource.getType();
assert sourceType != null;
- allInstancesVariable = helper.createDeclareStatement(resultNode.getName(), sourceType, true, asSource);
+ String safeName = getSafeName(resultNode);
+ allInstancesVariable = helper.createDeclareStatement(safeName, sourceType, true, asSource);
mapping.getOwnedStatements().add(allInstancesVariable);
classDatumAnalysis2variable.put(classDatumAnalysis, allInstancesVariable);
}

Back to the top