flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gregd...@apache.org
Subject [5/6] git commit: [flex-falcon] [refs/heads/develop] - [FIX] Fix for static complex initializer from mxml script blocks, tuning to newlines in the output.
Date Tue, 11 Oct 2016 07:17:20 GMT
[FIX] Fix for static complex initializer from mxml script blocks, tuning to newlines in the
output.


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

Branch: refs/heads/develop
Commit: e1a6e636a0f9fdeb92e7dddffac20cdf8156cf14
Parents: a7d6952
Author: greg-dove <greg.dove@gmail.com>
Authored: Tue Oct 11 18:58:22 2016 +1300
Committer: greg-dove <greg.dove@gmail.com>
Committed: Tue Oct 11 18:58:22 2016 +1300

----------------------------------------------------------------------
 .../internal/codegen/js/jx/ClassEmitter.java    | 12 +++---
 .../internal/codegen/js/jx/FieldEmitter.java    |  7 +++-
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 42 ++++++++++++++++++--
 3 files changed, 51 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e1a6e636/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
index 3b28e5f..0a37cf4 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -149,20 +149,22 @@ public class ClassEmitter extends JSSubEmitter implements
         if (fjs.getFieldEmitter().hasComplexStaticInitializers)
         {
             writeNewline();
-            
+            boolean complexInitOutput = false;
 	        for (IDefinitionNode dnode : dnodes)
 	        {
 	            if (dnode.getNodeID() == ASTNodeID.VariableID)
 	            {
-	                writeNewline();
-	                fjs.getFieldEmitter().emitFieldInitializer((IVariableNode) dnode);
+                    complexInitOutput = fjs.getFieldEmitter().emitFieldInitializer((IVariableNode)
dnode) || complexInitOutput;
 	            }
 	            else if (dnode.getNodeID() == ASTNodeID.BindableVariableID)
 	            {
-	                writeNewline();
-	                fjs.getFieldEmitter().emitFieldInitializer((IVariableNode) dnode);
+                    complexInitOutput = fjs.getFieldEmitter().emitFieldInitializer((IVariableNode)
dnode) || complexInitOutput;
 	            }
 	        }
+	        if (complexInitOutput) {
+                writeNewline();
+                writeNewline();
+            }
         }
         
         fjs.getPackageFooterEmitter().emitClassInfo(node);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e1a6e636/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 b3b6bdb..8892220 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
@@ -26,6 +26,7 @@ import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.ModifiersSet;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
+import org.apache.flex.compiler.internal.codegen.Emitter;
 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.JSSessionModel.BindableVarInfo;
@@ -173,7 +174,7 @@ public class FieldEmitter extends JSSubEmitter implements
         }
     }
 
-    public void emitFieldInitializer(IVariableNode node)
+    public boolean emitFieldInitializer(IVariableNode node)
     {
         IDefinition definition = EmitterUtils.getClassDefinition(node);
 
@@ -199,6 +200,7 @@ public class FieldEmitter extends JSSubEmitter implements
             className = getEmitter().formatQualifiedName(definition.getQualifiedName());
         	if (ndef.isStatic() && EmitterUtils.needsStaticInitializer(vnodeString,
className) && !isPackageOrFileMember)
 	        {
+                writeNewline();
                 write(className
                         + ASEmitterTokens.MEMBER_ACCESS.getToken());
                 write(node.getName());
@@ -213,7 +215,10 @@ public class FieldEmitter extends JSSubEmitter implements
 	            writeToken(ASEmitterTokens.EQUAL);
 	            write(vnodeString);
 	            write(ASEmitterTokens.SEMICOLON);
+                return true;
 	        }
         }
+
+        return false;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e1a6e636/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index 3e8dfac..b128388 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -386,9 +386,9 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 
         fjs.getBindableEmitter().emit(cdef);
         fjs.getAccessorEmitter().emit(cdef);
-        
-        emitEvents(cname);
 
+        emitEvents(cname);
+        emitComplexStaticInitializers(node);
         emitPropertyGetterSetters(cname);
 
         emitMXMLDescriptorFuncs(cname);
@@ -2510,13 +2510,15 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     				{
     					IVariableNode varnode = (IVariableNode)schild;
     			        IExpressionNode vnode = varnode.getAssignedValueNode();
-    			        if (vnode != null && (!(varnode.isConst() || EmitterUtils.isScalar(vnode))))
+
+
+                        if (vnode != null && (!EmitterUtils.isScalar(vnode)))
     			        {
     	                    writeNewline();
     	                    write(ASEmitterTokens.THIS);
     	                    write(ASEmitterTokens.MEMBER_ACCESS);
     	                    write(varnode.getName());
-    	                    if (schildID == ASTNodeID.BindableVariableID)
+    	                    if (schildID == ASTNodeID.BindableVariableID && !varnode.isConst())
     	                    	write("_"); // use backing variable
     	                    write(ASEmitterTokens.SPACE);
     	                    writeToken(ASEmitterTokens.EQUAL);
@@ -2531,6 +2533,38 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
     		}
     	}
     }
+
+    public void emitComplexStaticInitializers(IASNode node){
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) ((IMXMLBlockWalker) getMXMLWalker())
+                .getASEmitter();
+
+        if (!fjs.getFieldEmitter().hasComplexStaticInitializers) return;
+        int n = node.getChildCount();
+        boolean sawOutput = false;
+        for (int i = 0; i < n; i++)
+        {
+            IASNode child = node.getChild(i);
+            if (child.getNodeID() == ASTNodeID.MXMLScriptID)
+            {
+                int m = child.getChildCount();
+                for (int j = 0; j < m; j++)
+                {
+                    IASNode schild = child.getChild(j);
+                    ASTNodeID schildID = schild.getNodeID();
+                    if (schildID == ASTNodeID.VariableID ||
+                            schildID == ASTNodeID.BindableVariableID)
+                    {
+                        sawOutput = fjs.getFieldEmitter().emitFieldInitializer((IVariableNode)
schild) || sawOutput;
+                    }
+                }
+            }
+        }
+
+        if (sawOutput) {
+            writeNewline();
+            writeNewline();
+        }
+    }
     
     @Override
     public void emitImplements(IMXMLImplementsNode node)


Mime
View raw message