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] - emit 'x as int' as 'x as Number'
Date Tue, 17 May 2016 06:41:24 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop e8f263cfc -> c1d34ffd0


emit 'x as int' as 'x as Number'


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

Branch: refs/heads/develop
Commit: c1d34ffd0ced55b1c103ae9d53ffcc97b40e4930
Parents: e8f263c
Author: Alex Harui <aharui@apache.org>
Authored: Mon May 16 23:41:18 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon May 16 23:41:18 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 21 ++++++++++++++++++++
 .../internal/codegen/js/jx/AsIsEmitter.java     |  3 ++-
 .../js/flexjs/TestFlexJSExpressions.java        | 16 +++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1d34ffd/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 c954e2c..d34b224 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
@@ -23,6 +23,7 @@ import java.io.FilterWriter;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
 import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
 import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
 import org.apache.flex.compiler.constants.IASLanguageConstants;
@@ -439,6 +440,26 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         return name;
     }
     
+    public String convertASTypeToJS(String name)
+    {
+        String result = name;
+
+        if (name.equals(""))
+            result = IASLanguageConstants.Object;
+        else if (name.equals(IASLanguageConstants.Class))
+            result = IASLanguageConstants.Object;
+        else if (name.equals(IASLanguageConstants._int)
+                || name.equals(IASLanguageConstants.uint))
+            result = IASLanguageConstants.Number;
+
+        boolean isBuiltinFunction = name.matches("Vector\\.<.*>");
+        if (isBuiltinFunction)
+        {
+        	result = IASLanguageConstants.Array;
+        }
+        return result;
+    }
+    
     //--------------------------------------------------------------------------
     // Package Level
     //--------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1d34ffd/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
index ee8a5e6..c99d4d9 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
@@ -25,6 +25,7 @@ import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.projects.ICompilerProject;
@@ -167,7 +168,7 @@ public class AsIsEmitter extends JSSubEmitter
         if (dnode instanceof IClassDefinition)
         {
             startMapping(right);
-            write(getEmitter().formatQualifiedName(dnode.getQualifiedName()));
+            write(getEmitter().formatQualifiedName(((JSFlexJSEmitter)getEmitter()).convertASTypeToJS(dnode.getQualifiedName())));
             endMapping(right);
         }
         else

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1d34ffd/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 b5786f6..6f9b599 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
@@ -871,6 +871,22 @@ public class TestFlexJSExpressions extends TestGoogExpressions
     }
 
     @Test
+    public void testVisitAsInt()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a as int");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("org.apache.flex.utils.Language.as(a, Number)");
+    }
+
+    @Test
+    public void testVisitAsUint()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a as uint");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("org.apache.flex.utils.Language.as(a, Number)");
+    }
+
+    @Test
     public void testVisitAsMemberVariable()
     {
         IFunctionNode node = (IFunctionNode) getNode(


Mime
View raw message