flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [02/50] git commit: [flex-falcon] [refs/heads/dual] - handle a few more cases with super
Date Thu, 13 Apr 2017 17:43:33 GMT
handle a few more cases with super


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

Branch: refs/heads/dual
Commit: 85a170101d19dcfe51a177fdb21e34bc9bc43c94
Parents: fde0386
Author: Alex Harui <aharui@apache.org>
Authored: Tue Mar 7 22:34:21 2017 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Mar 7 22:34:21 2017 -0800

----------------------------------------------------------------------
 .../internal/codegen/js/goog/JSGoogEmitter.java |  3 +-
 .../codegen/js/jx/MemberAccessEmitter.java      | 16 ++++++-
 .../js/flexjs/TestFlexJSExpressions.java        | 45 ++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/85a17010/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
index 8486ab0..98a4015 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
@@ -909,7 +909,8 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
             if (definition instanceof FunctionDefinition &&
                     !((FunctionDefinition)definition).isStatic() &&
                     (!(definition instanceof AccessorDefinition)) &&
-                    node instanceof MemberAccessExpressionNode)
+                    node instanceof MemberAccessExpressionNode &&
+                    ((MemberAccessExpressionNode)node).getLeftOperandNode().getNodeID() !=
ASTNodeID.SuperID)
             {
                 emitClosureStart();
                 getWalker().walk(node);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/85a17010/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 0c37490..2f5f278 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
@@ -269,7 +269,10 @@ public class MemberAccessEmitter extends JSSubEmitter implements
         {
         	write(ASEmitterTokens.COMMA);
         	write(ASEmitterTokens.SPACE);
-        	writeLeftSide(node, leftNode, rightNode);
+        	if (leftNode.getNodeID() == ASTNodeID.SuperID)
+        		write(ASEmitterTokens.THIS);
+        	else
+        		writeLeftSide(node, leftNode, rightNode);
         	getEmitter().emitClosureEnd(node, def);
         }
         
@@ -311,6 +314,17 @@ public class MemberAccessEmitter extends JSSubEmitter implements
                 write(ASEmitterTokens.PAREN_CLOSE);
                 return false;
             }
+            else if (leftNode.getNodeID() == ASTNodeID.SuperID
+                    && (rightDef != null && rightDef instanceof FunctionDefinition))
+            {
+                write(getEmitter().formatQualifiedName(
+                        getEmitter().getModel().getCurrentClass().getQualifiedName()));
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSGoogEmitterTokens.SUPERCLASS);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(rightDef.getBaseName());
+                return false;
+            }
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/85a17010/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 3331fc6..17c9940 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
@@ -102,6 +102,51 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         assertOut("/**\n */\nFalconTest_A.prototype[\"http://www.adobe.com/2006/actionscript/flash/proxy::foo\"]
= function() {\n  if (a)\n    FalconTest_A.superClass_['http://www.adobe.com/2006/actionscript/flash/proxy::setProperty'].apply(this,
[ a, b] );\n}");
     }
 
+    @Test
+    public void testVisitLanguageIdentifierNode_SuperMethodAsFunctionReference()
+    {
+        IFileNode node = (IFileNode)getNode("package { public class FalconTest_A extends
Base { override public function foo() {var f:Function = super.foo;} } }\n" +
+        		"class Base { public function foo(){} }", IFileNode.class, 0, false);
+        IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
+                node, IFunctionNode.class);
+        IClassNode classnode = (IClassNode) findFirstDescendantOfType(
+                node, IClassNode.class);
+        IClassDefinition def = classnode.getDefinition();
+        ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
+        asBlockWalker.visitFunction(fnode);
+        assertOut("/**\n * @export\n * @override\n */\nFalconTest_A.prototype.foo = function()
{\n  var /** @type {Function} */ f = org.apache.flex.utils.Language.closure(FalconTest_A.superClass_.foo,
this, 'foo');\n}");
+    }
+    
+    @Test
+    public void testVisitLanguageIdentifierNode_SuperMethodAsVarFunctionReference()
+    {
+    	IFileNode node = (IFileNode)getNode("package { public class FalconTest_A extends Base
{ override public function foo() {var f:Function; f = super.foo;} } }\n" +
+        		"class Base { public function foo(){} }", IFileNode.class, 0, false);
+        IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
+                node, IFunctionNode.class);
+        IClassNode classnode = (IClassNode) findFirstDescendantOfType(
+                node, IClassNode.class);
+        IClassDefinition def = classnode.getDefinition();
+        ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
+        asBlockWalker.visitFunction(fnode);
+        assertOut("/**\n * @export\n * @override\n */\nFalconTest_A.prototype.foo = function()
{\n  var /** @type {Function} */ f;\n  f = org.apache.flex.utils.Language.closure(FalconTest_A.superClass_.foo,
this, 'foo');\n}");
+    }
+    
+    @Test
+    public void testVisitLanguageIdentifierNode_SuperMethodInApply()
+    {
+    	IFileNode node = (IFileNode)getNode("package { public class FalconTest_A extends Base
{ override public function foo() {super.foo.apply(this, [a, b, c]);} } }\n" +
+        		"class Base { public function foo(){} }", IFileNode.class, 0, false);
+        IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
+                node, IFunctionNode.class);
+        IClassNode classnode = (IClassNode) findFirstDescendantOfType(
+                node, IClassNode.class);
+        IClassDefinition def = classnode.getDefinition();
+        ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
+        asBlockWalker.visitFunction(fnode);
+        assertOut("/**\n * @export\n * @override\n */\nFalconTest_A.prototype.foo = function()
{\n  FalconTest_A.superClass_.foo.apply(this, [a, b, c]);\n}");
+    }
+    
     //----------------------------------
     // Primary expression keywords
     //----------------------------------


Mime
View raw message