flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [1/5] git commit: [flex-falcon] [refs/heads/develop] - EmitterUtils: moved findFunction(), findFunctionNode(), findVariable(), and findVariableNode() from ASEmitter so that they can be accessed in more places (there seems to be duplicates of findType() a
Date Mon, 11 Jan 2016 19:54:53 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop f3f082fa3 -> 4550efc11


EmitterUtils: moved findFunction(), findFunctionNode(), findVariable(), and findVariableNode()
from ASEmitter so that they can be accessed in more places (there seems to be duplicates of
findType() and findTypeNode() in both classes, which should probably be cleaned up)


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

Branch: refs/heads/develop
Commit: 2450d143a6f58ac3063222c9d11444f4d0c3414b
Parents: 0c69c38
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Mon Jan 11 11:51:04 2016 -0800
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Mon Jan 11 11:51:04 2016 -0800

----------------------------------------------------------------------
 .../compiler/internal/codegen/as/ASEmitter.java | 47 +-------------
 .../internal/codegen/js/utils/EmitterUtils.java | 64 ++++++++++++++++++--
 2 files changed, 61 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2450d143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index 9118e95..b142984 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -37,6 +37,7 @@ import org.apache.flex.compiler.definitions.IFunctionDefinition;
 import org.apache.flex.compiler.definitions.IPackageDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.ContainerNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
@@ -324,7 +325,7 @@ public class ASEmitter implements IASEmitter, IEmitter
     public void emitPackageContents(IPackageDefinition definition)
     {
         IPackageNode node = definition.getNode();
-        ITypeNode tnode = findTypeNode(node);
+        ITypeNode tnode = EmitterUtils.findTypeNode(node);
         if (tnode != null)
         {
             indentPush();
@@ -1145,30 +1146,6 @@ public class ASEmitter implements IASEmitter, IEmitter
         }
         return null;
     }
-    
-    protected IFunctionNode findFunctionNode(IPackageNode node)
-    {
-        IScopedNode scope = node.getScopedNode();
-        for (int i = 0; i < scope.getChildCount(); i++)
-        {
-            IASNode child = scope.getChild(i);
-            if (child instanceof IFunctionNode)
-                return (IFunctionNode) child;
-        }
-        return null;
-    }
-
-    protected IVariableNode findVariableNode(IPackageNode node)
-    {
-        IScopedNode scope = node.getScopedNode();
-        for (int i = 0; i < scope.getChildCount(); i++)
-        {
-            IASNode child = scope.getChild(i);
-            if (child instanceof IVariableNode)
-                return (IVariableNode) child;
-        }
-        return null;
-    }
 
     protected ITypeDefinition findType(Collection<IDefinition> definitions)
     {
@@ -1180,26 +1157,6 @@ public class ASEmitter implements IASEmitter, IEmitter
         return null;
     }
 
-    protected IFunctionDefinition findFunction(Collection<IDefinition> definitions)
-    {
-        for (IDefinition definition : definitions)
-        {
-            if (definition instanceof IFunctionDefinition)
-                return (IFunctionDefinition) definition;
-        }
-        return null;
-    }
-
-    protected IVariableDefinition findVariable(Collection<IDefinition> definitions)
-    {
-        for (IDefinition definition : definitions)
-        {
-            if (definition instanceof IVariableDefinition)
-                return (IVariableDefinition) definition;
-        }
-        return null;
-    }
-
     public void walkArguments(IExpressionNode[] nodes)
     {
         int len = nodes.length;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2450d143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
index 75e6e24..9afeb77 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
@@ -35,6 +35,7 @@ import org.apache.flex.compiler.definitions.IFunctionDefinition;
 import org.apache.flex.compiler.definitions.IFunctionDefinition.FunctionClassification;
 import org.apache.flex.compiler.definitions.INamespaceDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.definitions.IVariableDefinition;
 import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
 import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
 import org.apache.flex.compiler.internal.definitions.ClassDefinition;
@@ -56,6 +57,7 @@ import org.apache.flex.compiler.tree.as.IPackageNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
 import org.apache.flex.compiler.tree.as.IScopedNode;
 import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
 import org.apache.flex.compiler.utils.NativeUtils;
 
 /**
@@ -85,10 +87,58 @@ public class EmitterUtils
         return null;
     }
 
+    public static IFunctionDefinition findFunction(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof IFunctionDefinition)
+                return (IFunctionDefinition) definition;
+        }
+        return null;
+    }
+
+    public static IFunctionNode findFunctionNode(IPackageNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        for (int i = 0; i < scope.getChildCount(); i++)
+        {
+            IASNode child = scope.getChild(i);
+            if (child instanceof IFunctionNode)
+                return (IFunctionNode) child;
+        }
+        return null;
+    }
+
+    public static IVariableNode findVariableNode(IPackageNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        for (int i = 0; i < scope.getChildCount(); i++)
+        {
+            IASNode child = scope.getChild(i);
+            if (child instanceof IVariableNode)
+                return (IVariableNode) child;
+        }
+        return null;
+    }
+
+    public static IVariableDefinition findVariable(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof IVariableDefinition)
+                return (IVariableDefinition) definition;
+        }
+        return null;
+    }
+
     public static ITypeDefinition getTypeDefinition(IDefinitionNode node)
     {
         ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
-        return (ITypeDefinition) tnode.getDefinition();
+        if (tnode != null)
+        {
+            return (ITypeDefinition) tnode.getDefinition();
+        }
+        return null;
     }
 
     public static boolean isSameClass(IDefinition pdef, IDefinition thisClass,
@@ -144,10 +194,14 @@ public class EmitterUtils
     public static IClassDefinition getSuperClassDefinition(
             IDefinitionNode node, ICompilerProject project)
     {
-        IClassDefinition parent = (IClassDefinition) node.getDefinition()
-                .getParent();
-        IClassDefinition superClass = parent.resolveBaseClass(project);
-        return superClass;
+        IDefinition parent = node.getDefinition().getParent();
+        if (parent instanceof IClassDefinition)
+        {
+            IClassDefinition parentClassDef = (IClassDefinition) parent;
+            IClassDefinition superClass = parentClassDef.resolveBaseClass(project);
+            return superClass;
+        }
+        return null;
     }
 
     public static List<String> resolveImports(ITypeDefinition type)


Mime
View raw message