flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [06/15] git commit: [flex-falcon] [refs/heads/develop] - allow AST hacking after AST node optimization
Date Mon, 26 Aug 2013 21:31:02 GMT
allow AST hacking after AST node optimization


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d3102814
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d3102814
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d3102814

Branch: refs/heads/develop
Commit: d31028140c6529a8e1cfa39f42a49df6aff09bb1
Parents: a867837
Author: Alex Harui <aharui@apache.org>
Authored: Thu Aug 15 21:30:47 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Aug 15 21:30:47 2013 -0700

----------------------------------------------------------------------
 .../flex/compiler/internal/tree/as/TreeNode.java    | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d3102814/compiler/src/org/apache/flex/compiler/internal/tree/as/TreeNode.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/as/TreeNode.java b/compiler/src/org/apache/flex/compiler/internal/tree/as/TreeNode.java
index 5fd2950..7a60fa5 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/as/TreeNode.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/as/TreeNode.java
@@ -20,7 +20,9 @@
 package org.apache.flex.compiler.internal.tree.as;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Comparator;
+import java.util.List;
 
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.utils.CheapArray;
@@ -144,8 +146,18 @@ public abstract class TreeNode extends NodeBase
 
     public void addChild(NodeBase child, int position)
     {
-        //TODO update offsets
-        CheapArray.replace(position, child, emptyNodeArray);
+        if (children instanceof List)
+        {
+            //TODO update offsets
+            CheapArray.replace(position, child, emptyNodeArray);
+        }
+        else
+        {
+            ArrayList<IASNode> newArray = new ArrayList<IASNode>();
+            Collections.addAll(newArray, (IASNode[])children);
+            newArray.add(position, child);
+            children = newArray.toArray();
+        }
         child.setParent(this);
     }
 


Mime
View raw message