flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [4/7] git commit: [flex-falcon] [refs/heads/develop] - don't generate code for 'as' and coercions or some imports that are only used for satisfying the AS compiler and not needed in JS
Date Mon, 10 Nov 2014 18:05:50 GMT
don't generate code for 'as' and coercions or some imports that are only used for satisfying
the AS compiler and not needed in JS


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

Branch: refs/heads/develop
Commit: f3713dde8881abb0de30be3f2f6810fcbc457a1a
Parents: 5d2765d
Author: Alex Harui <aharui@apache.org>
Authored: Thu Nov 6 13:40:15 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Nov 6 13:40:15 2014 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 57 +++++++++++++++-----
 .../js/flexjs/JSFlexJSEmitterTokens.java        |  1 +
 2 files changed, 45 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f3713dde/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 8ffd837..758bacd 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -59,6 +59,7 @@ import org.apache.flex.compiler.internal.scopes.PackageScope;
 import org.apache.flex.compiler.internal.scopes.TypeScope;
 import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
 import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.internal.tree.as.ClassNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.ParameterNode;
@@ -1297,11 +1298,39 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     {
         PackageScope containedScope = (PackageScope) definition
                 .getContainedScope();
+        
+        ArrayList<String> writtenRequires = new ArrayList<String>();
 
         ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
         if (type == null)
             return;
 
+        ITypeNode typeNode = type.getNode();
+        if (typeNode instanceof ClassNode)
+        {
+	        ClassNode classNode = (ClassNode) typeNode;
+	        if (classNode != null)
+	        {
+	            ASDocComment asDoc = (ASDocComment) classNode.getASDocComment();
+	            if (asDoc != null)
+	            {
+		            String asDocString = asDoc.commentNoEnd();
+		            String ignoreToken = JSFlexJSEmitterTokens.IGNORE_IMPORT.getToken();
+		            int ignoreIndex = asDocString.indexOf(ignoreToken);
+		            while (ignoreIndex != -1)
+		            {
+		            	String ignorable = asDocString.substring(ignoreIndex + ignoreToken.length());
+		            	int endIndex = ignorable.indexOf("\n");
+		            	ignorable = ignorable.substring(0, endIndex);
+		            	ignorable = ignorable.trim();
+		            	// pretend we've already written the goog.requires for this
+		            	writtenRequires.add(ignorable);
+		            	ignoreIndex = asDocString.indexOf(ignoreToken, ignoreIndex + ignoreToken.length());
+		            }
+	            }
+	        }
+        }
+        
         if (project == null)
             project = getWalker().getProject();
 
@@ -1313,8 +1342,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
 
         String cname = type.getQualifiedName();
-        ArrayList<String> writtenInstances = new ArrayList<String>();
-        writtenInstances.add(cname); // make sure we don't add ourselves
+        writtenRequires.add(cname); // make sure we don't add ourselves
 
         boolean emitsRequires = false;
         if (requiresList != null)
@@ -1330,7 +1358,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                 if (NativeUtils.isNative(imp))
                     continue;
 
-                if (writtenInstances.indexOf(imp) == -1)
+                if (writtenRequires.indexOf(imp) == -1)
                 {
 
                     /* goog.require('x');\n */
@@ -1342,7 +1370,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                     write(ASEmitterTokens.PAREN_CLOSE);
                     writeNewline(ASEmitterTokens.SEMICOLON);
                     
-                    writtenInstances.add(imp);
+                    writtenRequires.add(imp);
                     
                     emitsRequires = true;
                 }
@@ -1354,15 +1382,18 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         {
             for (String imp : interfacesList)
             {
-                write(JSGoogEmitterTokens.GOOG_REQUIRE);
-                write(ASEmitterTokens.PAREN_OPEN);
-                write(ASEmitterTokens.SINGLE_QUOTE);
-                write(imp);
-                write(ASEmitterTokens.SINGLE_QUOTE);
-                write(ASEmitterTokens.PAREN_CLOSE);
-                writeNewline(ASEmitterTokens.SEMICOLON);
-                
-                emitsInterfaces = true;
+                if (writtenRequires.indexOf(imp) == -1)
+                {
+	                write(JSGoogEmitterTokens.GOOG_REQUIRE);
+	                write(ASEmitterTokens.PAREN_OPEN);
+	                write(ASEmitterTokens.SINGLE_QUOTE);
+	                write(imp);
+	                write(ASEmitterTokens.SINGLE_QUOTE);
+	                write(ASEmitterTokens.PAREN_CLOSE);
+	                writeNewline(ASEmitterTokens.SEMICOLON);
+	                
+	                emitsInterfaces = true;
+                }
             }
         }
         

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f3713dde/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java
index 4a28e74..62a6919 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitterTokens.java
@@ -35,6 +35,7 @@ public enum JSFlexJSEmitterTokens implements IEmitterTokens
     QNAME("qName"),
     UNDERSCORE("_"),
     IGNORE_COERCION("@flexjsignorecoercion"),
+    IGNORE_IMPORT("@flexjsignoreimport"),
     ;
 
     private String token;


Mime
View raw message