flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-falcon] [refs/heads/develop] - fix XML Literal handling in more places
Date Mon, 11 Apr 2016 04:47:37 GMT
fix XML Literal handling in more places


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

Branch: refs/heads/develop
Commit: 2135f681de50082ea6d626003b8321eaa9689187
Parents: 7a0a4c8
Author: Alex Harui <aharui@apache.org>
Authored: Sun Apr 10 21:38:57 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Sun Apr 10 21:38:57 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSGlobalClasses.java | 17 +++++++++++++++++
 .../internal/codegen/js/goog/JSGoogEmitter.java    |  7 -------
 .../internal/codegen/js/jx/LiteralEmitter.java     |  5 +++++
 3 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2135f681/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
index 32f28f5..864fc24 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
@@ -339,6 +339,23 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
     }
     
     @Test
+    public void testXMLLiteralAsParam()
+    {
+        IFunctionCallNode node = (IFunctionCallNode)getNode("var a:XML; a.appendChild(<top
attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>)",
+        		IFunctionCallNode.class);
+        asBlockWalker.visitFunctionCall(node);
+        assertOut("a.appendChild(new XML( \"<top attr1='cat'><child attr2='dog'><grandchild
attr3='fish'>text</grandchild></child></top>\") )");
+    }
+    
+    @Test
+    public void testXMLLiteralInReassign()
+    {
+    	IBinaryOperatorNode node = getBinaryNode("var a:XML = <foo />; a = <top attr1='cat'><child
attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>)");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("a = new XML( \"<top attr1='cat'><child attr2='dog'><grandchild
attr3='fish'>text</grandchild></child></top>\") ");
+    }
+    
+    @Test
     public void testXMLSingleDot()
     {
         IVariableNode node = getVariable("var a:XML = new XML(\"<top attr1='cat'><child
attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\");var
b:XMLList = a.child;");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2135f681/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
index 7fe1657..e08fb84 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
@@ -906,13 +906,6 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
                 getWalker().walk(((MemberAccessExpressionNode)node).getLeftOperandNode());
                 emitClosureEnd(((MemberAccessExpressionNode)node).getLeftOperandNode());
             }
-            else if (node.getNodeID() == ASTNodeID.XMLContentID)
-            {
-                write("new XML");
-                writeToken(ASEmitterTokens.PAREN_OPEN);
-                getWalker().walk(node);
-                writeToken(ASEmitterTokens.PAREN_CLOSE);
-            }
             else
                 getWalker().walk(node);
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2135f681/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
index a332f23..9b16bb8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
@@ -21,11 +21,13 @@ package org.apache.flex.compiler.internal.codegen.js.jx;
 
 import org.apache.flex.compiler.codegen.ISubEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
 import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
 import org.apache.flex.compiler.internal.tree.as.LiteralNode;
 import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
 import org.apache.flex.compiler.internal.tree.as.XMLLiteralNode;
+import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
@@ -49,6 +51,8 @@ public class LiteralEmitter extends JSSubEmitter implements
         {
             if (node.getLiteralType() == LiteralType.XML)
             {
+                write("new XML");
+                writeToken(ASEmitterTokens.PAREN_OPEN);
             	XMLLiteralNode xmlNode = (XMLLiteralNode)node;
             	if (xmlNode.getContentsNode().getChildCount() == 1)
             	{
@@ -83,6 +87,7 @@ public class LiteralEmitter extends JSSubEmitter implements
             			}
             		}
             	}
+                writeToken(ASEmitterTokens.PAREN_CLOSE);
             }
             s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
             s = s.replaceAll("\r", "__CR_PLACEHOLDER__");


Mime
View raw message