flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject [11/11] git commit: [flex-falcon] [refs/heads/develop] - This is where all the magic happens ; -)
Date Tue, 05 Nov 2013 12:45:37 GMT
This is where all the magic happens ;-)

- updated emission of 'as', 'instanceof' and 'is' operators
- added emission of 'interfaces classes' with 'goog.require'
- added 'storage' for implemented/extended interfaces as a property of the class

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/7020dcfa
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/7020dcfa
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/7020dcfa

Branch: refs/heads/develop
Commit: 7020dcfaccf04007aa29a9e60dbf92fe0294f21b
Parents: 3905b3e
Author: Erik de Bruin <erik@ixsoftware.nl>
Authored: Tue Nov 5 13:44:15 2013 +0100
Committer: Erik de Bruin <erik@ixsoftware.nl>
Committed: Tue Nov 5 13:44:15 2013 +0100

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 65 +++++++++++++++-----
 1 file changed, 49 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7020dcfa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 944185e..932c3c3 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -684,9 +684,28 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             write(ASEmitterTokens.PAREN_OPEN);
             getWalker().walk(node.getLeftOperandNode());
             writeToken(ASEmitterTokens.COMMA);
-            getWalker().walk(node.getRightOperandNode());
+
+            IDefinition dnode = (node.getRightOperandNode()).resolve(project);
+            if (dnode != null)
+                write(dnode.getQualifiedName());
+            else
+                getWalker().walk(node.getRightOperandNode());
+            
             write(ASEmitterTokens.PAREN_CLOSE);
         }
+        else if (id == ASTNodeID.Op_InstanceOfID)
+        {
+            getWalker().walk(node.getLeftOperandNode());
+
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.INSTANCEOF);
+            
+            IDefinition dnode = (node.getRightOperandNode()).resolve(project);
+            if (dnode != null)
+                write(dnode.getQualifiedName());
+            else
+                getWalker().walk(node.getRightOperandNode());
+        }
         else
         {
             IExpressionNode leftSide = node.getLeftOperandNode();
@@ -829,15 +848,16 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         ASProjectScope projectScope = (ASProjectScope) flexProject.getScope();
         ICompilationUnit cu = projectScope
                 .getCompilationUnitForDefinition(type);
-        ArrayList<String> list = flexProject.getRequires(cu);
+        ArrayList<String> requiresList = flexProject.getRequires(cu);
+        ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
 
         String cname = type.getQualifiedName();
         ArrayList<String> writtenInstances = new ArrayList<String>();
         writtenInstances.add(cname); // make sure we don't add ourselves
 
-        if (list != null)
+        if (requiresList != null)
         {
-            for (String imp : list)
+            for (String imp : requiresList)
             {
                 if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
                     continue;
@@ -863,17 +883,34 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                 }
             }
 
-            // (erikdebruin) only write 'closing' line break when there are 
-            //               actually imports...
-            if (list.size() > 1
-                    || (list.size() == 1 && list.get(0).indexOf(
+            if (requiresList.size() > 1
+                    || (requiresList.size() == 1 && requiresList.get(0).indexOf(
                             JSGoogEmitterTokens.AS3.getToken()) == -1))
             {
                 writeNewline();
             }
         }
         
-        // erikdebruin: Add missing language feature support, like the 'is' and 
+        if (interfacesList != null)
+        {
+            for (String imp : interfacesList)
+            {
+                write(JSGoogEmitterTokens.GOOG_REQUIRE);
+                write(ASEmitterTokens.PAREN_OPEN);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                write(imp);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                write(ASEmitterTokens.PAREN_CLOSE);
+                writeNewline(ASEmitterTokens.SEMICOLON);
+            }
+            
+            if (interfacesList.size() > 0)
+            {
+                writeNewline();
+            }
+        }
+        
+        // erikdebruin: Add missing language feature support, with e.g. 'is' and 
         //              'as' operators. We don't need to worry about requiring
         //              this in every project: ADVANCED_OPTIMISATIONS will NOT
         //              include any of the code if it is not used in the project.
@@ -918,13 +955,9 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     
                 write(type.getQualifiedName());
                 write(ASEmitterTokens.MEMBER_ACCESS);
-                if (tnode instanceof IClassNode)
-                {
-                    write(JSEmitterTokens.PROTOTYPE);
-                    write(ASEmitterTokens.MEMBER_ACCESS);
-                }
-                write("AFJS_INTERFACES");
-                write(ASEmitterTokens.SPACE);
+                write(JSEmitterTokens.PROTOTYPE);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                writeToken(JSFlexJSEmitterTokens.AFJS_INTERFACES);
                 writeToken(ASEmitterTokens.EQUAL);
                 write(ASEmitterTokens.SQUARE_OPEN);
                 int i = 0;


Mime
View raw message