flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [03/50] git commit: [flex-falcon] [refs/heads/dual] - handle xml.@['someProp']
Date Thu, 13 Apr 2017 17:43:34 GMT
handle xml.@['someProp']


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

Branch: refs/heads/dual
Commit: 6e14d68351e6b530179e5fbaf9a6416775a42bd4
Parents: 85a1701
Author: Alex Harui <aharui@apache.org>
Authored: Wed Mar 8 00:02:21 2017 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Mar 8 00:02:21 2017 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java        | 18 +++++++++++++++---
 .../codegen/js/jx/DynamicAccessEmitter.java       |  3 +++
 .../codegen/js/jx/MemberAccessEmitter.java        |  5 ++++-
 .../js/flexjs/TestFlexJSGlobalClasses.java        | 10 ++++++++++
 4 files changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6e14d683/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 4bcc3cf..abb9d3b 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -1060,9 +1060,21 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         }
         else if (node.getNodeID() == ASTNodeID.Op_AtID)
         {
-        	write("attribute('");
-            getWalker().walk(node.getOperandNode());
-        	write("')");
+        	IASNode op = node.getOperandNode();
+        	if (op != null)
+        	{
+            	write("attribute('");
+        		getWalker().walk(node.getOperandNode());
+            	write("')");
+        	}
+        	else if (node.getParent().getNodeID() == ASTNodeID.ArrayIndexExpressionID)
+        	{
+        		DynamicAccessNode parentNode = (DynamicAccessNode)node.getParent();
+            	write("attribute(");
+        		getWalker().walk(parentNode.getRightOperandNode());        		
+            	write(")");
+        	}
+        		
         	return;
         }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6e14d683/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/DynamicAccessEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/DynamicAccessEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/DynamicAccessEmitter.java
index f02d298..39321b7 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/DynamicAccessEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/DynamicAccessEmitter.java
@@ -23,6 +23,7 @@ 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.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IDynamicAccessNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
 
@@ -39,6 +40,8 @@ public class DynamicAccessEmitter extends JSSubEmitter implements
     {
         IExpressionNode leftOperandNode = node.getLeftOperandNode();
         getWalker().walk(leftOperandNode);
+        if (leftOperandNode.getNodeID() == ASTNodeID.Op_AtID)
+        	return;
 
         startMapping(node, leftOperandNode);
         write(ASEmitterTokens.SQUARE_OPEN);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6e14d683/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
index 2f5f278..6060c5e 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
@@ -32,6 +32,7 @@ import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.jx.BinaryOperatorEmitter.DatePropertiesGetters;
 import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
 import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
+import org.apache.flex.compiler.internal.tree.as.DynamicAccessNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.GetterNode;
 import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
@@ -85,7 +86,9 @@ public class MemberAccessEmitter extends JSSubEmitter implements
         		boolean descendant = (node.getOperator() == OperatorType.DESCENDANT_ACCESS);
         		boolean child = (node.getOperator() == OperatorType.MEMBER_ACCESS) && 
         							(!(parentNode instanceof FunctionCallNode)) &&
-        							rightNode.getNodeID() != ASTNodeID.Op_AtID;
+        							rightNode.getNodeID() != ASTNodeID.Op_AtID &&
+        							!((rightNode.getNodeID() == ASTNodeID.ArrayIndexExpressionID) && 
+        									(((DynamicAccessNode)rightNode).getLeftOperandNode().getNodeID() == ASTNodeID.Op_AtID));
         		if (descendant || child)
 	        	{
 	        		writeLeftSide(node, leftNode, rightNode);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6e14d683/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
index 8eb01bd..74b9d1e 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
@@ -625,6 +625,16 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
     }
     
     @Test
+    public void testXMLAttributeBracket()
+    {
+        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.@[\"attr1\"];");
+        IASNode parentNode = node.getParent();
+        node = (IVariableNode) parentNode.getChild(1);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XMLList} */ b = a.attribute(\"attr1\")");
+    }
+    
+    @Test
     public void testXMLAttributeToString()
     {
         IVariableNode node = getVariable("var a:XML = new XML(\"<top attr1='cat'><child
attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\");var
b:String = a.@attr1;");


Mime
View raw message