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

gregdove 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 7dc35f1  More thorough checking of assigned value for static 
initializers. Adds checking for function call return type and function call 
params into the 'isExternalReference' checking.
7dc35f1 is described below

commit 7dc35f11ad08c1dc326b754684b1fe4bdb5abbc7
Author: greg-dove <[email protected]>
AuthorDate: Sat Jan 2 10:05:29 2021 +1300

    More thorough checking of assigned value for static initializers. Adds 
checking for function call return type and function call params into the 
'isExternalReference' checking.
---
 .../internal/codegen/js/jx/FieldEmitter.java       | 37 ++++++++++++++++------
 1 file changed, 28 insertions(+), 9 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 6a056bb..91195a8 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
@@ -36,16 +36,10 @@ import 
org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitterToke
 import org.apache.royale.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.royale.compiler.internal.definitions.FunctionDefinition;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
-import org.apache.royale.compiler.internal.tree.as.ChainedVariableNode;
-import org.apache.royale.compiler.internal.tree.as.FunctionCallNode;
-import org.apache.royale.compiler.internal.tree.as.IdentifierNode;
-import org.apache.royale.compiler.internal.tree.as.VariableNode;
+import org.apache.royale.compiler.internal.tree.as.*;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
-import org.apache.royale.compiler.tree.as.IASNode;
-import org.apache.royale.compiler.tree.as.IExpressionNode;
-import org.apache.royale.compiler.tree.as.INamespaceDecorationNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
+import org.apache.royale.compiler.tree.as.*;
 import org.apache.royale.compiler.tree.metadata.IMetaTagNode;
 import org.apache.royale.compiler.tree.metadata.IMetaTagsNode;
 import org.apache.royale.compiler.utils.NativeUtils;
@@ -84,6 +78,12 @@ public class FieldEmitter extends JSSubEmitter implements
                if (def == null)  // saw this for a package reference (org in 
org.apache)
                        return false;
                String qname = def.getQualifiedName();
+               if (def instanceof IFunctionDefinition) {
+                if (vnode.getAncestorOfType(FunctionCallNode.class) != null){
+                    def = ((IFunctionDefinition) 
def).resolveReturnType(getProject());
+                    qname = def.getQualifiedName();
+                }
+            }
                if (NativeUtils.isJSNative(qname))
                        return false;
                if (def instanceof IClassDefinition)
@@ -103,10 +103,29 @@ public class FieldEmitter extends JSSubEmitter implements
                {
                        if (isExternalReference((IExpressionNode)childNode, 
cdef))
                                return true;
-               }
+               } else if (childNode instanceof IContainerNode) {
+                   if (checkContainer((IContainerNode)childNode,cdef ))
+                       return true;
+            }
        }
        return false;
     }
+
+    private boolean checkContainer(IContainerNode containerNode, 
IClassDefinition cdef){
+        int n = containerNode.getChildCount();
+        for (int i = 0; i < n; i++)
+        {
+            IASNode childNode = containerNode.getChild(i);
+            if (childNode instanceof IExpressionNode) {
+                if (isExternalReference((IExpressionNode)childNode, cdef))
+                    return true;
+            } else if (childNode instanceof IContainerNode) {
+                if (checkContainer((IContainerNode) childNode,cdef ))
+                    return true;
+            }
+        }
+        return false;
+    }
     
     @Override
     public void emit(IVariableNode node)

Reply via email to