This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new f19695e  handle static bindings in removecirculars
f19695e is described below

commit f19695e82189495fd89b798bf5b3cde70f0b4fb7
Author: Alex Harui <aha...@apache.org>
AuthorDate: Thu Feb 22 18:14:35 2018 -0800

    handle static bindings in removecirculars
---
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     | 34 +++++++++++++++++++++-
 .../compiler/internal/graph/GoogDepsWriter.java    | 15 +++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index 6d190e8..4226298 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -110,6 +110,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
     private IClassDefinition classDefinition;
     private IClassDefinition documentDefinition;
     private ArrayList<String> usedNames = new ArrayList<String>();
+    private ArrayList<String> staticUsedNames = new ArrayList<String>();
     private ArrayList<IMXMLMetadataNode> metadataNodes = new 
ArrayList<IMXMLMetadataNode>();
     
     private int eventCounter;
@@ -119,6 +120,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
     private boolean inMXMLContent;
     private boolean inStatesOverride;
     private boolean makingSimpleArray;
+    private boolean inStaticInitializer;
     
     private StringBuilder subDocuments = new StringBuilder();
     private ArrayList<String> subDocumentNames = new ArrayList<String>();
@@ -182,6 +184,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
        int endRequires = -1;
        boolean sawRequires = false;
        boolean stillSearching = true;
+        int provideIndex = -1;
         ArrayList<String> namesToAdd = new ArrayList<String>();
         ArrayList<String> foundRequires = new ArrayList<String>();
         int len = lines.length;
@@ -190,7 +193,14 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
             String line = lines[i];
                if (stillSearching)
                {
-                   int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+                int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+                if (c != -1)
+                {
+                    // if zero requires are found, require Language after the
+                    // call to goog.provide
+                    provideIndex = i + 1;
+                }
+                   c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
                    if (c > -1)
                    {
                        int c2 = line.indexOf(")");
@@ -400,6 +410,21 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                    }
             }
         }
+               if (staticUsedNames.size() > 0)
+               {
+                       StringBuilder sb = new StringBuilder();
+                       
sb.append(JSGoogEmitterTokens.ROYALE_STATIC_DEPENDENCY_LIST.getToken());
+                       boolean firstDependency = true;
+                       for (String staticName : staticUsedNames)
+                       {
+                               if (!firstDependency)
+                                       sb.append(",");
+                               firstDependency = false;
+                               sb.append(staticName);
+                       }
+                       sb.append("*/");
+                       finalLines.add(provideIndex, sb.toString());
+               }
 
        return Joiner.on("\n").join(finalLines);
     }
@@ -1167,7 +1192,9 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
         if (bd.getBindingInfo().isEmpty())
             return;
 
+        inStaticInitializer = true;
         outputBindingInfoAsData(cname, bd);
+        inStaticInitializer = false;
     }
 
     private void outputBindingInfoAsData(String cname, BindingDatabase 
bindingDataBase)
@@ -1233,6 +1260,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                        write(ASEmitterTokens.SQUARE_OPEN.getToken() + 
ASEmitterTokens.DOUBLE_QUOTE.getToken() +
                                bi.classDef.getQualifiedName() + 
ASEmitterTokens.DOUBLE_QUOTE.getToken());
                        usedNames.add(bi.classDef.getQualifiedName());
+                       staticUsedNames.add(bi.classDef.getQualifiedName());
                        int n = parts.length;
                        for (int i = 1; i < n; i++)
                        {
@@ -2792,6 +2820,10 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
        if (subDocumentNames.contains(name))
                return documentDefinition.getQualifiedName() + "." + name;
         if (NativeUtils.isJSNative(name)) return name;
+       if (inStaticInitializer)
+               if (!staticUsedNames.contains(name) && 
!NativeUtils.isJSNative(name))
+                       staticUsedNames.add(name);
+
                if (useName && !usedNames.contains(name) && !isExternal(name))
                        usedNames.add(name);
        return name;
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
index 016077e..b412817 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
@@ -131,10 +131,23 @@ public class GoogDepsWriter {
                        if (!isGoogClass(gd.className)) 
                        {
                                if (removeCirculars)
+                               {
+                                       ArrayList <String> deps = new 
ArrayList<String>();
+                                       if (gd.fileInfo.impls != null)
+                                               deps.addAll(gd.fileInfo.impls);
+                                       if (gd.fileInfo.staticDeps != null)
+                                       {
+                                               for (String dep : 
gd.fileInfo.staticDeps)
+                                               {
+                                                       if (!deps.contains(dep))
+                                                               deps.add(dep);
+                                               }
+                                       }
                                        
sb.append("goog.addDependency('").append(relativePath(gd.filePath)).append("', 
['")
                                                
.append(gd.className).append("'], [")
-                                               .append((gd.fileInfo.impls != 
null) ? getDependencies(gd.fileInfo.impls) : "")
+                                               .append(getDependencies(deps))
                                                .append("]);\n");
+                               }
                                else
                                        
sb.append("goog.addDependency('").append(relativePath(gd.filePath)).append("', 
['")
                                        .append(gd.className).append("'], [")

-- 
To stop receiving notification emails like this one, please contact
aha...@apache.org.

Reply via email to