flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - special case toString() on *
Date Wed, 10 Aug 2016 22:28:51 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 23df02ae9 -> b10a1cd3d


special case toString() on *


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

Branch: refs/heads/develop
Commit: b10a1cd3d08df58228d459fcd0351489716877d5
Parents: 23df02a
Author: Alex Harui <aharui@apache.org>
Authored: Wed Aug 10 15:28:38 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Aug 10 15:28:38 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/jx/BinaryOperatorEmitter.java        | 16 ++++++++++++++++
 .../codegen/js/flexjs/TestFlexJSExpressions.java    | 10 ++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b10a1cd3/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
index 87e07c5..bb454fc 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
@@ -300,6 +300,9 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
             	{
 		        	if (rightDef == null ||
 		        			(!(rightDef.getQualifiedName().equals(IASLanguageConstants.String) ||
+		        			  (rightDef.getQualifiedName().equals(IASLanguageConstants.ANY_TYPE)
+		                    		&& rNode.getNodeID() == ASTNodeID.FunctionCallID &&
+		                    		isToString(rNode)) ||
 		        			  // if not an assignment we don't need to coerce numbers
 		        			  (!isAssignment && rightIsNumber) ||
 		        			   rightDef.getQualifiedName().equals(IASLanguageConstants.Null))))
@@ -381,6 +384,19 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
             */
         }
     }
+    
+    private boolean isToString(IASNode rNode)
+    {
+    	IExpressionNode fnNameNode = ((FunctionCallNode)rNode).getNameNode();
+    	if (fnNameNode.getNodeID() == ASTNodeID.MemberAccessExpressionID)
+    	{
+    		MemberAccessExpressionNode mae = (MemberAccessExpressionNode)fnNameNode;
+    		IExpressionNode rightNode = mae.getRightOperandNode();
+    		return rightNode.getNodeID() == ASTNodeID.IdentifierID && 
+    				((IdentifierNode)rightNode).getName().equals("toString");
+    	}
+    	return false;
+    }
 
     private void super_emitBinaryOperator(IBinaryOperatorNode node, String coercion)
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b10a1cd3/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 40ee688..2def937 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -624,6 +624,16 @@ public class TestFlexJSExpressions extends TestGoogExpressions
     }
 
     @Test
+    public void testVisitBinaryOperatorNode_StringAssignFromStarToString()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:String; public var c:*; public function d()
{ b = c.toString(); }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("this.b = this.c.toString()");
+    }
+
+    @Test
     public void testNamedFunctionAsArgument()
     {
         IFunctionNode node = (IFunctionNode) getNode(


Mime
View raw message