commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1391491 - /commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java
Date Fri, 28 Sep 2012 14:56:45 GMT
Author: luc
Date: Fri Sep 28 14:56:45 2012
New Revision: 1391491

URL: http://svn.apache.org/viewvc?rev=1391491&view=rev
Log:
Fixed merging.

Modified:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java?rev=1391491&r1=1391490&r2=1391491&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/algorithmic/forward/analysis/TrackingValue.java
Fri Sep 28 14:56:45 2012
@@ -40,7 +40,7 @@ public class TrackingValue implements Va
     /** Instructions that produce this value. */
     private Set<AbstractInsnNode> producers;
 
-    /** Values that are merged with this value. */
+    /** Values that are merged with this value (including the instance itself). */
     private Set<TrackingValue> merged;
 
     /** Build a new value without any link to instructions.
@@ -51,6 +51,7 @@ public class TrackingValue implements Va
         consumers  = new HashSet<AbstractInsnNode>();
         producers  = new HashSet<AbstractInsnNode>();
         merged     = new HashSet<TrackingValue>();
+        merged.add(this);
     }
 
     /** Get the wrapped {@link BasicValue}.
@@ -103,20 +104,22 @@ public class TrackingValue implements Va
     public static void merge(final TrackingValue value1,
                              final TrackingValue value2) {
 
+        if (value1.merged.contains(value2)) {
+            // the values have already been merged
+            return;
+        }
+
         // merge the sets
         value1.consumers.addAll(value2.consumers);
         value1.producers.addAll(value2.producers);
         value1.merged.addAll(value2.merged);
 
         // share the merged sets
-        for (TrackingValue value : value2.merged) {
+        for (final TrackingValue value : value2.merged) {
             value.consumers = value1.consumers;
             value.producers = value1.producers;
             value.merged    = value1.merged;
         }
-        value2.consumers = value1.consumers;
-        value2.producers = value1.producers;
-        value2.merged    = value1.merged;
 
     }
 



Mime
View raw message