You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/08/26 23:31:02 UTC
[06/15] git commit: [flex-falcon] [refs/heads/develop] - allow AST
hacking after AST node optimization
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 <ah...@apache.org>
Authored: Thu Aug 15 21:30:47 2013 -0700
Committer: Alex Harui <ah...@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);
}