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

joshtynjala 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 fd9e237  FieldEmitter: in addition to analyzing function calls for 
static dependencies, also analyzes constructors that are called
fd9e237 is described below

commit fd9e23730b4b6db512dc781b9dbbf644dc123e79
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Aug 6 12:02:48 2019 -0700

    FieldEmitter: in addition to analyzing function calls for static 
dependencies, also analyzes constructors that are called
---
 .../internal/codegen/js/jx/FieldEmitter.java       | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
index 85a9c06..784c9c5 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
@@ -25,7 +25,9 @@ import 
org.apache.royale.compiler.codegen.js.goog.IJSGoogDocEmitter;
 import org.apache.royale.compiler.common.ASModifier;
 import org.apache.royale.compiler.common.ModifiersSet;
 import org.apache.royale.compiler.constants.IASKeywordConstants;
+import org.apache.royale.compiler.definitions.IClassDefinition;
 import org.apache.royale.compiler.definitions.IDefinition;
+import org.apache.royale.compiler.definitions.IFunctionDefinition;
 import org.apache.royale.compiler.definitions.IVariableDefinition;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.royale.compiler.internal.codegen.js.JSEmitterTokens;
@@ -126,12 +128,12 @@ public class FieldEmitter extends JSSubEmitter implements
             String vnodeString = getEmitter().stringifyNode(vnode);
             if (ndef.isStatic() && vnode instanceof FunctionCallNode)
             {
-               FunctionCallNode fcn = (FunctionCallNode)vnode;
+                FunctionCallNode fcn = (FunctionCallNode)vnode;
                if (fcn.getNameNode() instanceof IdentifierNode)
                {
+                       IDefinition d = fcn.getNameNode().resolve(getProject());
                        // assume this is a call to static method in the class
                        // otherwise it would be a memberaccessexpression?
-                       IDefinition d = 
(IDefinition)fcn.getNameNode().resolve(getProject());
                        if (d instanceof FunctionDefinition)
                        {
                                FunctionDefinition fd = (FunctionDefinition)d;
@@ -141,7 +143,22 @@ public class FieldEmitter extends JSSubEmitter implements
                                // re-emit it to collect static initializer 
class references in usedNames
                                getEmitter().stringifyNode(m);
                                }
-                       }
+                    }
+                    //it could also be a constructor
+                    else if (d instanceof IClassDefinition)
+                    {
+                        IClassDefinition classDef = (IClassDefinition) d;
+                        IFunctionDefinition constructorDef = 
classDef.getConstructor();
+                        if (constructorDef != null)
+                        {
+                            IASNode m = constructorDef.getNode();
+                            if (m != null)
+                            {
+                                // re-emit it to collect static initializer 
class references in usedNames
+                                getEmitter().stringifyNode(m);
+                            }
+                        }
+                    }
                }
             }
                getModel().inStaticInitializer = false;

Reply via email to