flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject [16/17] git commit: [flex-falcon] [refs/heads/develop] - Use 'superClass_.[method].call()' instead of '[Class].base()' when calling super method outside its subclass counterpart
Date Fri, 21 Nov 2014 12:10:36 GMT
Use 'superClass_.[method].call()' instead of '[Class].base()' when calling super method outside
its subclass counterpart

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: d27432aeac4b3f25e30385b416d54a6aa1e3fdef
Parents: 34725a7
Author: Erik de Bruin <erik@ixsoftware.nl>
Authored: Fri Nov 21 13:08:22 2014 +0100
Committer: Erik de Bruin <erik@ixsoftware.nl>
Committed: Fri Nov 21 13:08:22 2014 +0100

----------------------------------------------------------------------
 .../codegen/js/vf2js/JSVF2JSEmitter.java        | 58 +++++++++++++++++---
 1 file changed, 50 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d27432ae/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
index f6276d3..9a9a2c5 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
@@ -1025,11 +1025,39 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
         if (cnode == null)
             return;
         
-        write(cnode.getQualifiedName());
-        write(ASEmitterTokens.MEMBER_ACCESS);
-        write(JSGoogEmitterTokens.GOOG_BASE);
-        write(ASEmitterTokens.PAREN_OPEN);
-        write(ASEmitterTokens.THIS);
+        // (erikdebruin): Catch when a 'super' call does NOT match the enclosing
+        //                function call. The GCC only allows '.base()' calls
+        //                to matching super methods, so we need to use 
+        //                'goog.base' for these ...
+        boolean isCallToOtherSuperMethod = false;
+        try
+        {
+        	IExpressionNode d = fcnode.getNameNode();
+		    if (d != null && d instanceof IMemberAccessExpressionNode)
+		    {
+		    	IIdentifierNode b = (IIdentifierNode) ((IMemberAccessExpressionNode) d).getRightOperandNode();
+		    	
+		    	isCallToOtherSuperMethod = 
+		    			b != null && !b.getName().equals(fnode.getName());
+		    }
+        }
+		catch (Exception e) { /* Eat it! */ }
+        
+        if (isCallToOtherSuperMethod)
+        {
+        	write(ASEmitterTokens.THIS);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSGoogEmitterTokens.SUPERCLASS);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+        }
+        else
+        {
+            write(parseQualifiedName(cnode));
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSGoogEmitterTokens.GOOG_BASE);
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(ASEmitterTokens.THIS);
+        }
 
         if (fnode != null && fnode.isConstructor())
         {
@@ -1041,8 +1069,12 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
 
         if (fnode != null && !fnode.isConstructor())
         {
-            writeToken(ASEmitterTokens.COMMA);
-            write(ASEmitterTokens.SINGLE_QUOTE);
+            if (!isCallToOtherSuperMethod)
+            {
+            	writeToken(ASEmitterTokens.COMMA);
+            	write(ASEmitterTokens.SINGLE_QUOTE);
+            }
+            
             if (fnode.getNodeID() == ASTNodeID.GetterID
                     || fnode.getNodeID() == ASTNodeID.SetterID)
                 writeGetSetPrefix(fnode.getNodeID() == ASTNodeID.GetterID);
@@ -1052,7 +1084,17 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
             		(IMemberAccessExpressionNode) fcnode.getNameNode();
             write(((IIdentifierNode) aenode.getRightOperandNode()).getName());
             
-            write(ASEmitterTokens.SINGLE_QUOTE);
+            if (!isCallToOtherSuperMethod)
+            {
+            	write(ASEmitterTokens.SINGLE_QUOTE);
+            }
+            else
+            {
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSGoogEmitterTokens.GOOG_CALL);
+                write(ASEmitterTokens.PAREN_OPEN);
+                write(ASEmitterTokens.THIS);
+            }
         }
 
         IASNode[] anodes = null;


Mime
View raw message