flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschma...@apache.org
Subject svn commit: r1436565 - /flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
Date Mon, 21 Jan 2013 19:20:14 GMT
Author: mschmalle
Date: Mon Jan 21 19:20:14 2013
New Revision: 1436565

URL: http://svn.apache.org/viewvc?rev=1436565&view=rev
Log:
Flex:FalconJx
- Refactoring emitter not to depend on PackageNode, this is regarding MXML production eventually.
- The Goog emitter right now is the only one affected with not having a PackageNode, so I'm
not changing the ASEmitter right now.

Modified:
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java?rev=1436565&r1=1436564&r2=1436565&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
Mon Jan 21 19:20:14 2013
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.interna
 
 import java.io.FilterWriter;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +30,7 @@ import org.apache.flex.compiler.common.A
 import org.apache.flex.compiler.constants.IASKeywordConstants;
 import org.apache.flex.compiler.constants.IASLanguageConstants;
 import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IFunctionDefinition;
 import org.apache.flex.compiler.definitions.IPackageDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
@@ -41,6 +43,7 @@ import org.apache.flex.compiler.js.codeg
 import org.apache.flex.compiler.js.codegen.goog.IJSGoogEmitter;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.scopes.IASScope;
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IAccessorNode;
@@ -55,7 +58,6 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.IGetterNode;
 import org.apache.flex.compiler.tree.as.IIdentifierNode;
 import org.apache.flex.compiler.tree.as.IInterfaceNode;
-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.ISetterNode;
@@ -99,8 +101,8 @@ public class JSGoogEmitter extends JSEmi
     @Override
     public void emitPackageHeader(IPackageDefinition definition)
     {
-        IPackageNode node = definition.getNode();
-        ITypeNode type = findTypeNode(node);
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
         if (type == null)
             return;
 
@@ -116,17 +118,26 @@ public class JSGoogEmitter extends JSEmi
         writeNewline();
     }
 
+    private ITypeDefinition findType(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof ITypeDefinition)
+                return (ITypeDefinition) definition;
+        }
+        return null;
+    }
+
     @Override
     public void emitPackageHeaderContents(IPackageDefinition definition)
     {
-        IPackageNode node = definition.getNode();
-        ITypeNode type = findTypeNode(node);
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
         if (type == null)
             return;
 
-        IPackageDefinition parent = (IPackageDefinition) node.getDefinition();
         ArrayList<String> list = new ArrayList<String>();
-        parent.getContainedScope().getScopeNode().getAllImports(list);
+        definition.getContainedScope().getScopeNode().getAllImports(list);
         for (String imp : list)
         {
             if (imp.indexOf(AS3) != -1)
@@ -155,12 +166,14 @@ public class JSGoogEmitter extends JSEmi
     @Override
     public void emitPackageContents(IPackageDefinition definition)
     {
-        IPackageNode node = definition.getNode();
-        ITypeNode type = findTypeNode(node);
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
         if (type == null)
             return;
 
-        IClassNode cnode = (IClassNode) type;
+        IClassNode cnode = (IClassNode) type.getNode();
+        if (cnode == null)
+            return;
 
         emitClass(cnode);
     }



Mime
View raw message