You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/12/28 04:16:07 UTC

[royale-compiler] branch develop updated: output xmlliteral in tdf menubarexample correctly

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 39c4c1c  output xmlliteral in tdf menubarexample correctly
39c4c1c is described below

commit 39c4c1c3748ad514a8ae1a3affd5777276a687d7
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Dec 27 20:15:53 2018 -0800

    output xmlliteral in tdf menubarexample correctly
---
 .../codegen/js/jx/LiteralContainerEmitter.java     | 41 +++++++++++++++++-----
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
index 45fc4e8..5e07fa1 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
@@ -23,6 +23,8 @@ import org.apache.royale.compiler.codegen.ISubEmitter;
 import org.apache.royale.compiler.codegen.js.IJSEmitter;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.royale.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.royale.compiler.internal.tree.as.LiteralNode;
+import org.apache.royale.compiler.tree.ASTNodeID;
 import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IContainerNode;
 import org.apache.royale.compiler.tree.as.ILiteralContainerNode;
@@ -42,6 +44,7 @@ public class LiteralContainerEmitter extends JSSubEmitter implements
         final IContainerNode.ContainerType type = cnode.getContainerType();
         String preFix = null;
         String postFix = null;
+        boolean isXMLList = node.getNodeID() == ASTNodeID.XMLListContentID;
 
         if (type == IContainerNode.ContainerType.BRACES)
         {
@@ -70,22 +73,42 @@ public class LiteralContainerEmitter extends JSSubEmitter implements
             endMapping(node);
         }
 
+        if (isXMLList)
+        {
+        	write("new XMLList(\"");
+        }
         final int len = cnode.getChildCount();
         for (int i = 0; i < len; i++)
         {
             IASNode child = cnode.getChild(i);
-            getWalker().walk(child);
-            if (i < len - 1)
+            if (isXMLList)
             {
-                //we're mapping the comma to the literal container, but we fill
-                //the space between the current child and the next because we
-                //don't know exactly where the comma appears in ActionScript
-                startMapping(node, child);
-                writeToken(ASEmitterTokens.COMMA);
-                endMapping(node);
+            	if (child instanceof LiteralNode)
+            	{
+            		String value = ((LiteralNode)child).getValue(true);
+            		value = value.replace("\"", "\\\"");
+            		value = value.replace("\r", "");
+            		value = value.replace("\n", "\\n");
+            		write(value);
+            	}
+            }
+            else
+            {
+	            getWalker().walk(child);
+	            if (i < len - 1)
+	            {
+	                //we're mapping the comma to the literal container, but we fill
+	                //the space between the current child and the next because we
+	                //don't know exactly where the comma appears in ActionScript
+	                startMapping(node, child);
+	                writeToken(ASEmitterTokens.COMMA);
+	                endMapping(node);
+	            }
             }
         }
-
+        if (isXMLList)
+        	write("\")");
+        
         if (postFix != null)
         {
             startMapping(node, node.getEndLine(), node.getEndColumn() - postFix.length());