Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2018-08-26 10:37:51 +0000
committerEd Willink2018-09-04 12:21:06 +0000
commite4cb5abe15593331f529d623cb219da3e7b6261d (patch)
treed2bc47744d7bb540d5bedd26255db4ec521e3a08
parent8099661b85ce66893393b68342af9281d6933999 (diff)
downloadorg.eclipse.qvtd-e4cb5abe15593331f529d623cb219da3e7b6261d.tar.gz
org.eclipse.qvtd-e4cb5abe15593331f529d623cb219da3e7b6261d.tar.xz
org.eclipse.qvtd-e4cb5abe15593331f529d623cb219da3e7b6261d.zip
[529130] Eliminate superTracePropertyAnalyses
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/DatumCaches.java46
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/AbstractPartialRegionAnalysis.java36
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/PartialRegionAnalysis.java1
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/partitioner/CyclicPartitionsAnalysis.java10
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java16
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java4
6 files changed, 67 insertions, 46 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/DatumCaches.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/DatumCaches.java
index 844c3c7ac..28a05d0bd 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/DatumCaches.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/DatumCaches.java
@@ -375,22 +375,56 @@ public class DatumCaches
public @NonNull PropertyDatum getPropertyDatum(@NonNull ClassDatum classDatum, @NonNull Property property) {
assert property != oclContainerProperty; // Use getOclContainerPropertyDatums() to return multiple candidates
- Iterable<@NonNull PropertyDatum> allPropertyDatums = getAllPropertyDatums(classDatum);
- Map<@NonNull Property, @NonNull PropertyDatum> property2propertyDatum = classDatum2property2propertyDatum.get(classDatum);
- if (property2propertyDatum == null) {
- property2propertyDatum = new HashMap<>();
- classDatum2property2propertyDatum.put(classDatum, property2propertyDatum);
- }
+ Map<@NonNull Property, @NonNull PropertyDatum> property2propertyDatum = getProperty2propertyDatum(classDatum);
PropertyDatum cachedPropertyDatum = property2propertyDatum.get(property);
if (cachedPropertyDatum != null) {
return cachedPropertyDatum;
}
+ Iterable<@NonNull PropertyDatum> allPropertyDatums = getAllPropertyDatums(classDatum); // FIX why is this needed / not cached
for (PropertyDatum propertyDatum : allPropertyDatums) {
if ((propertyDatum.getReferredProperty() == property) && (propertyDatum.getOwningClassDatum() == classDatum)) {
return propertyDatum;
}
}
// If not found we create it
+ PropertyDatum propertyDatum = createPropertyDatum(classDatum, property, property2propertyDatum);
+ {
+ Property oppositeProperty = property.getOpposite();
+ if (oppositeProperty != null) {
+ // assert oppositeProperty != oclContainerProperty;
+ ClassDatum oppositeClassDatum = getClassDatum(QVTscheduleUtil.getReferredTypedModel(classDatum), PivotUtil.getOwningClass(oppositeProperty));
+ Map<@NonNull Property, @NonNull PropertyDatum> oppositeProperty2propertyDatum = getProperty2propertyDatum(oppositeClassDatum);
+ PropertyDatum oppositePropertyDatum = oppositeProperty2propertyDatum.get(oppositeProperty);
+ if (oppositePropertyDatum == null) {
+ Iterable<@NonNull PropertyDatum> allOppositePropertyDatums = getAllPropertyDatums(oppositeClassDatum); // FIX why is this needed / not cached
+ for (PropertyDatum aPropertyDatum : allOppositePropertyDatums) {
+ if ((aPropertyDatum.getReferredProperty() == oppositeProperty) && (aPropertyDatum.getOwningClassDatum() == oppositeClassDatum)) {
+ oppositePropertyDatum = aPropertyDatum;
+ break;
+ }
+ }
+ }
+ if (oppositePropertyDatum == null) {
+ // oppositePropertyDatum = createPropertyDatum(oppositeClassDatum, oppositeProperty, oppositeProperty2propertyDatum);
+ }
+ // propertyDatum.setOpposite(oppositePropertyDatum);
+ // oppositePropertyDatum.setOpposite(propertyDatum);
+ }
+ }
+ return propertyDatum;
+ }
+
+ private @NonNull Map<@NonNull Property, @NonNull PropertyDatum> getProperty2propertyDatum(@NonNull ClassDatum classDatum) {
+ Map<@NonNull Property, @NonNull PropertyDatum> property2propertyDatum = classDatum2property2propertyDatum.get(classDatum);
+ if (property2propertyDatum == null) {
+ property2propertyDatum = new HashMap<>();
+ classDatum2property2propertyDatum.put(classDatum, property2propertyDatum);
+ }
+ return property2propertyDatum;
+ }
+
+ private @NonNull PropertyDatum createPropertyDatum(@NonNull ClassDatum classDatum,@NonNull Property property,
+ @NonNull Map<@NonNull Property, @NonNull PropertyDatum> property2propertyDatum) {
TypedModel typedModel = QVTscheduleUtil.getReferredTypedModel(classDatum);
CompleteClass targetCompleteClass = classDatum.getCompleteClass();
org.eclipse.ocl.pivot.Class owningClass = QVTbaseUtil.getOwningClass(property);
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/AbstractPartialRegionAnalysis.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/AbstractPartialRegionAnalysis.java
index 79ccd0618..8f821a6c4 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/AbstractPartialRegionAnalysis.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/AbstractPartialRegionAnalysis.java
@@ -134,11 +134,6 @@ public abstract class AbstractPartialRegionAnalysis<@NonNull RA extends @NonNull
*/
private @Nullable Set<@NonNull TraceClassAnalysis<@NonNull RA>> superProducedTraceClassAnalyses = null;
- /**
- * The TracePropertyAnalysis instances and super instances that are produced by this MappingPartitioner.
- */
- private @Nullable Set<@NonNull TracePropertyAnalysis<@NonNull RA>> superProducedTracePropertyAnalyses = null;
-
protected AbstractPartialRegionAnalysis(@NonNull RegionsAnalysis<@NonNull RA> regionsAnalysis, @NonNull Region region) {
super(regionsAnalysis.getScheduleManager(), region);
this.regionsAnalysis = regionsAnalysis;
@@ -226,14 +221,24 @@ public abstract class AbstractPartialRegionAnalysis<@NonNull RA extends @NonNull
assert edge.isNew();
Property property = QVTscheduleUtil.getProperty(edge);
assert property != scheduleManager.getStandardLibraryHelper().getOclContainerProperty(); // oclContainer is not assignable
+ if (property.toString().contains("toA1") || property.toString().contains("ownsB")) {
+ property.toString();
+ }
PropertyDatum propertyDatum = scheduleManager.getPropertyDatum(edge);
- TracePropertyAnalysis<@NonNull RA> consumedTraceAnalysis = regionsAnalysis.addProducer(propertyDatum, getRA());
+ TracePropertyAnalysis<@NonNull RA> producedTraceAnalysis = regionsAnalysis.addProducer(propertyDatum, getRA());
List<@NonNull TracePropertyAnalysis<@NonNull RA>> producedTracePropertyAnalyses2 = producedTracePropertyAnalyses;
if (producedTracePropertyAnalyses2 == null) {
producedTracePropertyAnalyses = producedTracePropertyAnalyses2 = new ArrayList<>();
}
- if (!producedTracePropertyAnalyses2.contains(consumedTraceAnalysis)) {
- producedTracePropertyAnalyses2.add(consumedTraceAnalysis);
+ if (!producedTracePropertyAnalyses2.contains(producedTraceAnalysis)) {
+ producedTracePropertyAnalyses2.add(producedTraceAnalysis);
+ }
+ PropertyDatum oppositePropertyDatum = propertyDatum.getOpposite();
+ if (oppositePropertyDatum != null) {
+ TracePropertyAnalysis<@NonNull RA> oppositeProducedTraceAnalysis = regionsAnalysis.addProducer(oppositePropertyDatum, getRA());
+ if (!producedTracePropertyAnalyses2.contains(oppositeProducedTraceAnalysis)) {
+ producedTracePropertyAnalyses2.add(oppositeProducedTraceAnalysis);
+ }
}
}
@@ -631,21 +636,6 @@ public abstract class AbstractPartialRegionAnalysis<@NonNull RA extends @NonNull
}
@Override
- public @Nullable Iterable<@NonNull TracePropertyAnalysis<@NonNull RA>> getSuperProducedTracePropertyAnalyses() {
- List<@NonNull TracePropertyAnalysis<@NonNull RA>> producedTracePropertyAnalyses2 = producedTracePropertyAnalyses;
- if (producedTracePropertyAnalyses2 != null) {
- Set<@NonNull TracePropertyAnalysis<@NonNull RA>> superProducedTracePropertyAnalyses2 = superProducedTracePropertyAnalyses;
- if (superProducedTracePropertyAnalyses2 == null) {
- superProducedTracePropertyAnalyses2 = superProducedTracePropertyAnalyses = new HashSet<>();
- }
- for (@NonNull TracePropertyAnalysis<@NonNull RA> producedTracePropertyAnalysis : producedTracePropertyAnalyses2) {
- Iterables.addAll(superProducedTracePropertyAnalyses2, producedTracePropertyAnalysis.getSuperTracePropertyAnalyses());
- }
- }
- return superProducedTracePropertyAnalyses;
- }
-
- @Override
public @NonNull TraceClassAnalysis<@NonNull RA> getTraceClassAnalysis(@NonNull ClassDatum traceClassDatum) {
return regionsAnalysis.getTraceClassAnalysis(traceClassDatum);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/PartialRegionAnalysis.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/PartialRegionAnalysis.java
index e3b8d015b..236483261 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/PartialRegionAnalysis.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/PartialRegionAnalysis.java
@@ -32,7 +32,6 @@ public interface PartialRegionAnalysis<@NonNull RA extends PartialRegionAnalysis
@Deprecated /** @deprecated This accommodates the lack of a success trace variable for manual trace classes */
@Nullable Iterable<@NonNull RA> getSuccessors();
@Nullable Iterable<@NonNull TraceClassAnalysis<@NonNull RA>> getSuperProducedTraceClassAnalyses();
- @Nullable Iterable<@NonNull TracePropertyAnalysis<@NonNull RA>> getSuperProducedTracePropertyAnalyses();
@NonNull TraceClassAnalysis<@NonNull RA> getTraceClassAnalysis(@NonNull ClassDatum traceClassDatum);
@NonNull TracePropertyAnalysis<@NonNull RA> getTracePropertyAnalysis(@NonNull PropertyDatum propertyDatum);
@NonNull List<@NonNull Node> getTraceNodes();
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/partitioner/CyclicPartitionsAnalysis.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/partitioner/CyclicPartitionsAnalysis.java
index de88df97c..fa04343b0 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/partitioner/CyclicPartitionsAnalysis.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/partitioner/CyclicPartitionsAnalysis.java
@@ -220,19 +220,19 @@ public class CyclicPartitionsAnalysis
private @NonNull Set<@NonNull TracePropertyAnalysis<@NonNull Partition>> computeTracePropertyAnalysisDependencies(@NonNull Iterable<@NonNull Partition> nestedPartitions) {
Set<@NonNull TracePropertyAnalysis<@NonNull Partition>> consumedTracePropertyAnalyses = new HashSet<>();
- Set<@NonNull TracePropertyAnalysis<@NonNull Partition>> superProducedTracePropertyAnalyses = new HashSet<>();
+ Set<@NonNull TracePropertyAnalysis<@NonNull Partition>> producedTracePropertyAnalyses = new HashSet<>();
for (@NonNull Partition nestedPartition : nestedPartitions) {
Iterable<@NonNull TracePropertyAnalysis<@NonNull Partition>> consumedTracePropertyAnalyses2 = nestedPartition.getConsumedTracePropertyAnalyses();
if (consumedTracePropertyAnalyses2 != null) {
Iterables.addAll(consumedTracePropertyAnalyses, consumedTracePropertyAnalyses2);
}
- Iterable<@NonNull TracePropertyAnalysis<@NonNull Partition>> superProducedTracePropertyAnalyses2 = nestedPartition.getSuperProducedTracePropertyAnalyses();
- if (superProducedTracePropertyAnalyses2 != null) {
- Iterables.addAll(superProducedTracePropertyAnalyses, superProducedTracePropertyAnalyses2);
+ Iterable<@NonNull TracePropertyAnalysis<@NonNull Partition>> producedTracePropertyAnalyses2 = nestedPartition.getProducedTracePropertyAnalyses();
+ if (producedTracePropertyAnalyses2 != null) {
+ Iterables.addAll(producedTracePropertyAnalyses, producedTracePropertyAnalyses2);
}
}
Set<@NonNull TracePropertyAnalysis<@NonNull Partition>> cyclicTracePropertyAnalyses = new HashSet<>(consumedTracePropertyAnalyses);
- cyclicTracePropertyAnalyses.retainAll(superProducedTracePropertyAnalyses);
+ cyclicTracePropertyAnalyses.retainAll(producedTracePropertyAnalyses);
return cyclicTracePropertyAnalyses;
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
index 7ad71cde8..5ee1c43aa 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
@@ -378,16 +378,10 @@ public class CompilerUtil extends QVTscheduleUtil
Iterable<@NonNull TracePropertyAnalysis<@NonNull RA>> consumedTracePropertyAnalyses = consumer.getConsumedTracePropertyAnalyses();
if (consumedTracePropertyAnalyses != null) {
for (@NonNull TracePropertyAnalysis<@NonNull RA> consumedTracePropertyAnalysis : consumedTracePropertyAnalyses) {
- if (consumedTracePropertyAnalysis.toString().contains("oclContainer")) {
- consumer.toString();
- }
- for (@NonNull TracePropertyAnalysis<@NonNull RA> superConsumedTracePropertyAnalysis : consumedTracePropertyAnalysis.getSuperTracePropertyAnalyses()) {
- // @NonNull TracePropertyAnalysis<@NonNull RA> superConsumedTracePropertyAnalysis = consumedTracePropertyAnalysis;
- for (@NonNull RA producer : superConsumedTracePropertyAnalysis.getProducers()) {
- Set<@NonNull RA> producers = consumer2producers.get(consumer);
- assert producers != null;
- producers.add(producer);
- }
+ for (@NonNull RA producer : consumedTracePropertyAnalysis.getProducers()) {
+ Set<@NonNull RA> producers = consumer2producers.get(consumer);
+ assert producers != null;
+ producers.add(producer);
}
}
}
@@ -423,7 +417,7 @@ public class CompilerUtil extends QVTscheduleUtil
/**
* Return a map of the RAs that may execute after each RA.
*
- * This is an inconveient type-conformance exercise. Find the sources that are subtypes of the target. We therefore
+ * This is an inconvenient type-conformance exercise. Find the sources that are subtypes of the target. We therefore
* require the inverse computeTransitivePredecessors's result to be provided for inversion.
*/
public static <@NonNull RA extends PartialRegionAnalysis<@NonNull RA>> @NonNull Map<@NonNull RA, @NonNull Set<@NonNull RA>> computeTransitiveSuccessors(@NonNull Map<@NonNull RA, @NonNull Set<@NonNull RA>> partion2predecessors) {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java b/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
index bc3154d4f..6b52ac2ff 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
@@ -624,6 +624,10 @@ public class QVTscheduleUtil extends QVTscheduleConstants
}
}
+ public static @NonNull PropertyDatum getOpposite(@NonNull PropertyDatum propertyDatum) {
+ return ClassUtil.nonNullState(propertyDatum.getOpposite());
+ }
+
public static @NonNull NavigableEdge getOppositeEdge(@NonNull NavigableEdge navigableEdge) {
return ClassUtil.nonNullState(navigableEdge.getOppositeEdge());
}

Back to the top