flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/6] git commit: [flex-falcon] - Handle Vector.length
Date Sat, 20 Apr 2013 00:18:13 GMT
Handle Vector.length


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

Branch: refs/heads/develop
Commit: c30116a26fd990be8785d1f112ddc15a3ffd05a9
Parents: 2e0b423
Author: Alex Harui <aharui@apache.org>
Authored: Fri Apr 19 09:43:50 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Apr 19 09:46:05 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSExpressions.java   |   19 +++++++++++++++
 .../apache/flex/compiler/utils/NativeUtils.java    |    2 +
 2 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c30116a2/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index da344c0..56d0aef 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -504,6 +504,17 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function()
{\n\tvar /** @type {string} */ s;\n\treturn s.length;\n}");
     }
 
+    @Test
+    public void testNativeVectorGetter()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function b():int { var a:Vector.<String>; return
a.length; }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        asBlockWalker.visitFunction(node);
+        // String.length is a getter but is a property in JS, so don't generate set_length()
call.
+        assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function()
{\n\tvar self = this;\n\tvar /** @type {Vector.<string>} */ a;\n\treturn a.length;\n}");
+    }
+
     //----------------------------------
     // Other
     //----------------------------------
@@ -524,6 +535,14 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         assertOut("FalconTest_A.prototype.foo = function() {\n\tbar(b).text = '';\n}");
     }
 
+    @Test
+    public void testComplexBooleanExpression()
+    {
+        IFunctionNode node = getMethod("function foo(b:Boolean):Boolean {var c:String; var
d:String; if (!(b ? c : d)) { return b;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {boolean} b\n * @return {boolean}\n */\nFalconTest_A.prototype.foo
= function(b) {\n\tvar self = this;\n\tvar /** @type {string} */ c;\n\tvar /** @type {string}
*/ d;\n\tif (!(b ? c : d)) {\n\t\treturn b;\n\t}\n}");
+    }
+
     @Override
     @Test
     public void testVisitAs()

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c30116a2/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
index 554a231..c56812e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
@@ -90,6 +90,8 @@ public class NativeUtils
             if (test.getValue().equals(type))
                 return true;
         }
+        if (type.startsWith("Vector.<"))
+            return true;
         return false;
     }
 }


Mime
View raw message