You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pi...@apache.org on 2017/03/31 05:09:28 UTC

[3/5] git commit: [flex-falcon] [refs/heads/feature/chart-work] - handle simple static initialization via function calls

handle simple static initialization via function calls


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

Branch: refs/heads/feature/chart-work
Commit: 5331a7703e0e16f69f1cf66c9746419c529e23be
Parents: 1de54cf
Author: Alex Harui <ah...@apache.org>
Authored: Thu Mar 30 11:57:56 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Mar 30 11:57:56 2017 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jx/FieldEmitter.java        | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5331a770/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
index 7029028..7fabff0 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
@@ -31,7 +31,10 @@ import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSSessionModel.BindableVarInfo;
 import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
 import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
@@ -110,6 +113,19 @@ public class FieldEmitter extends JSSubEmitter implements
         {
         	getModel().inStaticInitializer = ndef.isStatic();
             String vnodeString = getEmitter().stringifyNode(vnode);
+            if (ndef.isStatic() && vnode instanceof FunctionCallNode)
+            {
+            	FunctionCallNode fcn = (FunctionCallNode)vnode;
+            	if (fcn.getNameNode() instanceof IdentifierNode)
+            	{
+            		// assume this is a call to static method in the class
+            		// otherwise it would be a memberaccessexpression?
+            		FunctionDefinition fd = (FunctionDefinition)fcn.getNameNode().resolve(getProject());
+            		IASNode m = fd.getNode();
+            		// re-emit it to collect static initializer class references in usedNames
+            		getEmitter().stringifyNode(m);
+            	}
+            }
         	getModel().inStaticInitializer = false;
         	if ((ndef.isStatic() && !EmitterUtils.needsStaticInitializer(vnodeString, className)) || 
         			(!ndef.isStatic() && EmitterUtils.isScalar(vnode)) ||