You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/06/05 06:37:24 UTC

[royale-compiler] branch release_practice updated: try sorting another set to get consistency

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch release_practice
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/release_practice by this push:
     new 34edd6c  try sorting another set to get consistency
34edd6c is described below

commit 34edd6ca4f4977863a5b65f325a1ed9e7914b950
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Jun 4 23:37:13 2019 -0700

    try sorting another set to get consistency
---
 .../org/apache/royale/abc/semantics/Block.java     |  6 ++++++
 .../royale/abc/semantics/ControlFlowGraph.java     | 25 +++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/compiler/src/main/java/org/apache/royale/abc/semantics/Block.java b/compiler/src/main/java/org/apache/royale/abc/semantics/Block.java
index d404ae0..1d89d30 100644
--- a/compiler/src/main/java/org/apache/royale/abc/semantics/Block.java
+++ b/compiler/src/main/java/org/apache/royale/abc/semantics/Block.java
@@ -59,6 +59,12 @@ public class Block implements IBasicBlock
     }
 
     /**
+     * block number assigned by ControlFlowGraph.  So far,
+     * only used to try to guarantee order in lists/collections
+     */
+    public int blocknum;
+    
+    /**
      * Add a successor to this block.
      * 
      * @param succ - the successor block.
diff --git a/compiler/src/main/java/org/apache/royale/abc/semantics/ControlFlowGraph.java b/compiler/src/main/java/org/apache/royale/abc/semantics/ControlFlowGraph.java
index 9dbd05f..14c9c00 100644
--- a/compiler/src/main/java/org/apache/royale/abc/semantics/ControlFlowGraph.java
+++ b/compiler/src/main/java/org/apache/royale/abc/semantics/ControlFlowGraph.java
@@ -23,10 +23,13 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.royale.abc.ABCConstants;
 import org.apache.royale.abc.graph.IBasicBlock;
@@ -34,6 +37,8 @@ import org.apache.royale.abc.graph.IFlowgraph;
 import org.apache.royale.abc.graph.algorithms.DepthFirstPreorderIterator;
 import org.apache.royale.abc.graph.algorithms.DominatorTree;
 import org.apache.royale.abc.visitors.IFlowGraphVisitor;
+import org.apache.royale.compiler.css.ICSSDocument;
+import org.apache.royale.compiler.internal.projects.LibraryPathManager;
 
 /**
  * A ControlFlowGraph represents the flow of control through a sequence of
@@ -190,7 +195,24 @@ public class ControlFlowGraph implements IFlowgraph
 
         // We've seen all the instructions now, so we can compute the blocks that
         // each label corresponds to, and fill in the rest of the graph
-        for (Map.Entry<Block, Collection<Label>> entry : successor_labels.entrySet())
+        Set<Entry<Block, Collection<Label>>> entries = successor_labels.entrySet();
+        ArrayList<Entry<Block, Collection<Label>>> listOfEntries = new ArrayList<Entry<Block, Collection<Label>>>();
+        for (Map.Entry<Block, Collection<Label>> entry : entries)
+        	listOfEntries.add(entry);
+        Collections.sort(listOfEntries, new Comparator<Entry<Block, Collection<Label>>>()
+        {
+            /**
+             * Sort by blocknum.
+             */
+            @Override
+            public int compare(Entry<Block, Collection<Label>> o1, Entry<Block, Collection<Label>> o2)
+            {
+            	int block1 = o1.getKey().blocknum;
+            	int block2 = o2.getKey().blocknum;
+                return block1 - block2;
+            }
+        });
+        for (Map.Entry<Block, Collection<Label>> entry : listOfEntries)
             for (Label target_label : entry.getValue())
             {
                 IBasicBlock target_block = getBlock(target_label);
@@ -259,6 +281,7 @@ public class ControlFlowGraph implements IFlowgraph
     private Block newBlock()
     {
         Block result = new Block();
+        result.blocknum = blocks.size();
         blocks.add(result);
         return result;
     }