flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/9] git commit: [flex-falcon] [refs/heads/develop] - changes to generate the set of requires based on actual usage instead of the dependencies requires by AS. AS dependencies may also include types of variables which don't really matter to JS. Doing
Date Mon, 11 Jan 2016 18:04:44 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 0c69c38ad -> f3f082fa3


changes to generate the set of requires based on actual usage instead of the dependencies
requires by AS.  AS dependencies may also include types of variables which don't really matter
to JS.  Doing this eliminates the need for circular dependency checking in our code.  But
it also seems to have caused new warnings to show up which will require more investigation
and a future commit


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

Branch: refs/heads/develop
Commit: 15b170f8d133dc03580a47ac95c4624b81bcb28a
Parents: 9d605f2
Author: Alex Harui <aharui@apache.org>
Authored: Thu Jan 7 10:28:25 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Jan 7 10:28:25 2016 -0800

----------------------------------------------------------------------
 .../flex/compiler/codegen/as/IASEmitter.java    |  2 +
 .../compiler/codegen/mxml/IMXMLEmitter.java     |  2 +
 .../compiler/internal/codegen/as/ASEmitter.java |  6 +++
 .../compiler/internal/codegen/js/JSWriter.java  |  2 +-
 .../codegen/js/flexjs/JSFlexJSDocEmitter.java   |  2 +-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 46 +++++++++++++++++++-
 .../codegen/js/jx/IdentifierEmitter.java        |  5 ++-
 .../codegen/js/jx/PackageFooterEmitter.java     |  4 +-
 .../internal/codegen/mxml/MXMLEmitter.java      |  6 +++
 .../internal/codegen/mxml/MXMLWriter.java       |  2 +-
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 35 +++++++++++++++
 .../compiler/internal/graph/GoogDepsWriter.java |  4 +-
 12 files changed, 109 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
index df9bbcc..1a666f1 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
@@ -85,6 +85,8 @@ public interface IASEmitter extends IEmitter
 
     void setDocEmitter(IDocEmitter value);
 
+    String postProcess(String output);
+    
     void emitImport(IImportNode node);
 
     void emitPackageHeader(IPackageDefinition definition);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/codegen/mxml/IMXMLEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/mxml/IMXMLEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/mxml/IMXMLEmitter.java
index 53461b4..a8dc6dc 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/mxml/IMXMLEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/mxml/IMXMLEmitter.java
@@ -60,6 +60,8 @@ public interface IMXMLEmitter extends IEmitter
 
     IBlockWalker getMXMLWalker();
 
+    String postProcess(String output);
+    
     void setMXMLWalker(IBlockWalker mxmlBlockWalker);
 
     //--------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/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 8223ee9..ca21571 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
@@ -190,6 +190,12 @@ public class ASEmitter implements IASEmitter, IEmitter
     }
 
     @Override
+    public String postProcess(String output)
+    {
+    	return output;
+    }
+    
+    @Override
     public void write(IEmitterTokens value)
     {
         write(value.getToken());

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSWriter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSWriter.java
index 9d2c5c1..16a4d4d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSWriter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSWriter.java
@@ -77,7 +77,7 @@ public class JSWriter implements IJSWriter
 
         try
         {
-            out.write(writer.toString().getBytes());
+            out.write(emitter.postProcess(writer.toString()).getBytes());
         }
         catch (IOException e)
         {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
index 85a9aca..11a6518 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
@@ -88,7 +88,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
     @Override
     protected String formatQualifiedName(String name)
     {
-    	return ((JSFlexJSEmitter)emitter).formatQualifiedName(name);
+    	return ((JSFlexJSEmitter)emitter).formatQualifiedName(name, true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/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 a101a4c..d439da9 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
@@ -20,6 +20,7 @@
 package org.apache.flex.compiler.internal.codegen.js.flexjs;
 
 import java.io.FilterWriter;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
@@ -87,6 +88,8 @@ import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
 import org.apache.flex.compiler.utils.ASNodeUtils;
 
+import com.google.common.base.Joiner;
+
 /**
  * Concrete implementation of the 'FlexJS' JavaScript production.
  * 
@@ -124,6 +127,36 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     private ObjectDefinePropertyEmitter objectDefinePropertyEmitter;
     private DefinePropertyFunctionEmitter definePropertyFunctionEmitter;
 
+    public ArrayList<String> usedNames = new ArrayList<String>();
+    
+    @Override
+    public String postProcess(String output)
+    {
+    	String[] lines = output.split("\n");
+    	ArrayList<String> finalLines = new ArrayList<String>();
+    	boolean sawRequires = false;
+    	boolean stillSearching = true;
+    	for (String line : lines)
+    	{
+    		if (stillSearching)
+    		{
+	            int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+	            if (c > -1)
+	            {
+	                int c2 = line.indexOf(")");
+	                String s = line.substring(c + 14, c2 - 1);
+	    			sawRequires = true;
+	    			if (!usedNames.contains(s))
+	    				continue;
+	    		}
+	    		else if (sawRequires)
+	    			stillSearching = false;
+    		}
+    		finalLines.add(line);
+    	}
+    	return Joiner.on("\n").join(finalLines);
+    }
+    
     public BindableEmitter getBindableEmitter()
     {
         return bindableEmitter;
@@ -291,6 +324,11 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     @Override
     public String formatQualifiedName(String name)
     {
+        return formatQualifiedName(name, false);
+    }
+
+    public String formatQualifiedName(String name, boolean isDoc)
+    {
         /*
         if (name.contains("goog.") || name.startsWith("Vector."))
             return name;
@@ -300,9 +338,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     		return getModel().getInternalClasses().get(name);
     	if (name.startsWith("window."))
     		name = name.substring(7);
+    	else if (!isDoc)
+    	{
+    		if (!usedNames.contains(name))
+    			usedNames.add(name);
+    	}
         return name;
     }
-
+    
     //--------------------------------------------------------------------------
     // Package Level
     //--------------------------------------------------------------------------
@@ -351,6 +394,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     public void emitPackageHeaderContents(IPackageDefinition definition)
     {
         packageHeaderEmitter.emitContents(definition);
+        usedNames.clear();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
index a21cd63..4ed97e7 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
@@ -29,6 +29,7 @@ import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
 import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
+import org.apache.flex.compiler.internal.definitions.TypeDefinitionBase;
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IFunctionObjectNode;
@@ -128,8 +129,10 @@ public class IdentifierEmitter extends JSSubEmitter implements
             	String qname = nodeDef.getQualifiedName();
             	if (parentNodeId == ASTNodeID.MemberAccessExpressionID)
             		write(node.getName());
-            	else
+            	else if (nodeDef instanceof TypeDefinitionBase)
             		write(getEmitter().formatQualifiedName(qname));
+            	else 
+            		write(qname);
             }
             else
                 write(node.getName());

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
index 1110448..daffb46 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
@@ -19,6 +19,8 @@
 
 package org.apache.flex.compiler.internal.codegen.js.jx;
 
+import java.util.ArrayList;
+
 import org.apache.flex.compiler.codegen.ISubEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.definitions.IDefinition;
@@ -28,6 +30,7 @@ import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.scopes.IASScope;
@@ -135,6 +138,5 @@ public class PackageFooterEmitter extends JSSubEmitter implements
 	    write(ASEmitterTokens.SPACE);
 	    write(ASEmitterTokens.BLOCK_CLOSE);
 	    writeNewline(ASEmitterTokens.SEMICOLON);
-
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLEmitter.java
index 56d0fb2..bba7f23 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLEmitter.java
@@ -64,6 +64,12 @@ import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
 public class MXMLEmitter extends Emitter implements IMXMLEmitter
 {
 
+    @Override
+    public String postProcess(String output)
+    {
+        return output;
+    }
+
     //--------------------------------------------------------------------------
     //    walkers
     //--------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLWriter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLWriter.java
index 1d97ea5..81ce78c 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLWriter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/MXMLWriter.java
@@ -67,7 +67,7 @@ public class MXMLWriter extends JSWriter
 
         try
         {
-            out.write(writer.toString().getBytes());
+            out.write(mxmlEmitter.postProcess(writer.toString()).getBytes());
         }
         catch (IOException e)
         {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index 950f66e..f9f05a4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -86,6 +86,8 @@ import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.utils.NativeUtils;
 import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
 
+import com.google.common.base.Joiner;
+
 /**
  * @author Erik de Bruin
  */
@@ -107,6 +109,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     private ArrayList<MXMLScriptSpecifier> scripts;
     //private ArrayList<MXMLStyleSpecifier> styles;
     private IClassDefinition classDefinition;
+    private ArrayList<String> usedNames = new ArrayList<String>();
     
     private int eventCounter;
     private int idCounter;
@@ -137,6 +140,37 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     }
 
     @Override
+    public String postProcess(String output)
+    {
+        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker()).getASEmitter();
+        usedNames.addAll(((JSFlexJSEmitter)asEmitter).usedNames);
+        
+    	String[] lines = output.split("\n");
+    	ArrayList<String> finalLines = new ArrayList<String>();
+    	boolean sawRequires = false;
+    	boolean stillSearching = true;
+    	for (String line : lines)
+    	{
+    		if (stillSearching)
+    		{
+	            int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+	            if (c > -1)
+	            {
+	                int c2 = line.indexOf(")");
+	                String s = line.substring(c + 14, c2 - 1);
+	    			sawRequires = true;
+	    			if (!usedNames.contains(s))
+	    				continue;
+	    		}
+	    		else if (sawRequires)
+	    			stillSearching = false;
+    		}
+    		finalLines.add(line);
+    	}
+    	return Joiner.on("\n").join(finalLines);
+    }
+    
+    @Override
     protected String getIndent(int numIndent)
     {
         final StringBuilder sb = new StringBuilder();
@@ -1972,6 +2006,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     		return name;
     	name = name.replaceAll("\\.", "_");
     	*/
+    	usedNames.add(name);
     	return name;
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15b170f8/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
index 21ec7b6..13108ff 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -147,7 +147,7 @@ public class GoogDepsWriter {
 		visited.put(current.className, current);
 		
 		filePathsInOrder.add(current.filePath);
-		removeCirculars(current);
+		//removeCirculars(current);
         System.out.println("Dependencies calculated for '" + current.filePath + "'");
 
 		ArrayList<String> deps = current.deps;
@@ -240,12 +240,14 @@ public class GoogDepsWriter {
 	                        	// don't add the require if some class needs it at static initialization
 	                        	// time and that class is not this class
 	                        	suppressCount++;
+	                        	System.out.println(gd.filePath + " removing circular (static):
" + s);
 	                        	continue;
 	                        }
 	                        else if (!gd.deps.contains(s))
 	                        {
 	                        	// someone require'd this class
 	                        	suppressCount++;
+	                        	System.out.println(gd.filePath + " removing circular: " + s);
 	                        	continue;
 	                        }
                         }


Mime
View raw message