You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/04/16 18:31:37 UTC

git commit: [flex-falcon] - add more tests, fix a bug found by those tests

Updated Branches:
  refs/heads/develop 0e923fbf3 -> a5c10c63d


add more tests, fix a bug found by those tests


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

Branch: refs/heads/develop
Commit: a5c10c63dfcbc13003c7ac0fc99286b83f3d76ef
Parents: 0e923fb
Author: Alex Harui <ah...@apache.org>
Authored: Mon Apr 15 16:15:32 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Apr 16 09:31:25 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSClass.java         |   27 +
 .../codegen/js/flexjs/TestFlexJSExpressions.java   |  390 ++++++++++++++-
 .../codegen/js/flexjs/TestFlexJSStatements.java    |    9 +
 .../codegen/js/flexjs/JSFlexJSEmitter.java         |    6 +-
 4 files changed, 426 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a5c10c63/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index c30f9b9..6df8dfe 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -23,6 +23,7 @@ import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogClass;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
 import org.apache.flex.compiler.tree.as.IClassNode;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -86,6 +87,32 @@ public class TestFlexJSClass extends TestGoogClass
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\n * @expose\n * @return {Object}\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n\tvar self = this;\n\treturn goog.base(this, 'foo1b');\n};\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo6 = function(value) {\n};\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.fl
 ex.A.foo7 = function(value) {\n};\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};");
     }
 
+    @Test
+    public void testMethodsWithLocalFunctions()
+    {
+        IClassNode node = getClassNode("public class B {"
+                + "public function foo1():Object{function bar1():Object {return null;}; return bar1()}"
+                + "public function foo2():Object{function bar2(param1:Object):Object {return null;}; return bar2('foo');}"
+                + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n\tvar self = this;\n\tfunction bar1() {\n\t\treturn null;\n\t};\n\treturn bar1();\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n\tvar self = this;\n\tfunction bar2(param1) {\n\t\treturn null;\n\t};\n\treturn bar2('foo');\n};");
+    }
+
+    @Ignore
+    @Test
+    public void testClassWithoutConstructor()
+    {
+        /* AJH couldn't find a way to reproduce the code paths
+         * in a simple test case.  May require multiple compilation
+         * units in the same package.
+         */
+        IClassNode node = getClassNode("public class B {"
+                + "public function clone():B { return new B() }"
+                + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.clone() = function {\n\treturn new B();\n}");
+    }
+
     protected IBackend createBackend()
     {
         return new FlexJSBackend();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a5c10c63/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 6f850a2..8136a0f 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
@@ -24,6 +24,7 @@ import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogExpressions;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
 import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
 import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
 import org.junit.Test;
 
@@ -64,7 +65,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         asBlockWalker.visitMemberAccessExpression(node);
         assertOut("a");
     }
-    
+
     @Override
     @Test
     public void testVisitLanguageIdentifierNode_SuperMethod_1()
@@ -109,6 +110,389 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         assertOut("a = a || b");
     }
 
+    @Test
+    public void testVisitBinaryOperatorNode_functionCallOnLeft()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function b(s:String):Boolean {return s.toLowerCase() == 'foo'; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("s.toLowerCase() == 'foo'");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_functionCallOnLeftContained()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function b(s:String):Boolean {return (s.toLowerCase() == 'foo'); }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("(s.toLowerCase() == 'foo')");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c() { b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignmentWithThis()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c() { this.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c(other:B) { other.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_nestedSetterAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function get d():B {}; public function c(other:B) { d.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.get_d().get_d().set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_nestedSetterAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function get d():B {}; public function c(other:B) { other.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.get_d().set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignmentFromGetter()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c() { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(self.get_b() + 1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignmentFromGetterMaskedByLocal()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c() { var b:int; b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_setterAssignmentFromGetterMaskedByParam()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public function set b(value:int):void {}; public function c(b:int) { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c() { b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignmentWithThis()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c() { this.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c(other:B) { other.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableSetterAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; [Bindable] public var d:B; public function c(other:B) { d.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.get_d().get_d().set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableSetterAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; [Bindable] public var d:B; public function c(other:B) { other.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.get_d().set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignmentFromGetter()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c() { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.set_b(self.get_b() + 1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignmentFromGetterMaskedByLocal()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c() { var b:int; b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_bindableAssignmentFromGetterMaskedByParam()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public function c(b:int) { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c() { b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.b = 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignmentWithThis()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c() { this.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.b = 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c(other:B) { other.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.b = 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varSetterAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public var d:B; public function c(other:B) { d.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.d.d.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varVarAssignment()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public var d:B; public function c(other:B) { d.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.d.d.b = 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varSetterAssignmentOtherInstance()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {[Bindable] public var b:int; public var d:B; public function c(other:B) { other.d.b = 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("other.d.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignmentFromVar()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c() { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("self.b = self.b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignmentFromVarMaskedByLocal()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c() { var b:int; b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_varAssignmentFromVarMaskedByParam()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:int; public function c(b:int) { b = b + 1; }}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignment()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c() { b = 1; }; public static function set b(value:int):void {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("foo.bar.B.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignmentWithPath()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c() { foo.bar.B.b = 1; }; public static function set b(value:int):void {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("foo.bar.B.set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignmentOtherInstance()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c() { d.b = 1; }; public function set b(value:int):void {}; public static function get d():B {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("foo.bar.B.get_d().set_b(1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignmentFromGetter()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c() { b = b + 1; }; public static function set b(value:int):void {}; public static function get b():int {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("foo.bar.B.set_b(foo.bar.B.get_b() + 1)");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignmentFromGetterMaskedByLocal()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c() { var b:int; b = b + 1; }; public static function set b(value:int):void {}; public static function get b():int {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testVisitBinaryOperatorNode_staticSetterAssignmentFromGetterMaskedByParam()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function c(b:int) { b = b + 1; }; public static function set b(value:int):void {}; public static function get b():int {}}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                node, IBinaryOperatorNode.class);
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("b = b + 1");
+    }
+
+    @Test
+    public void testNamedFunctionAsArgument()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function b() { function c(f:Function):void {}; function d():void {}; c(d); }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitFunction(node);
+        assertOut("B.prototype.b = function() {\n\tvar self = this;\n\tfunction c(f) {\n\t};\n\tfunction d() {\n\t};\n\tc(d);\n}");
+    }
+
+    @Test
+    public void testMethodAsArgument()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function b() { function c(f:Function):void {}; c(b); }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitFunction(node);
+        assertOut("B.prototype.b = function() {\n\tvar self = this;\n\tfunction c(f) {\n\t};\n\tc(goog.bind(self.b, self));\n}");
+    }
+
+    @Test
+    public void testStaticMethodAsArgument()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {static public function b() { function c(f:Function):void {}; c(b); }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+        asBlockWalker.visitFunction(node);
+        assertOut("foo.bar.B.b = function() {\n\tfunction c(f) {\n\t};\n\tc(foo.bar.B.b);\n}");
+    }
+
+    @Test
+    public void testNativeGetter()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "public class B {public function b():int { var s:String; return s.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 {string} */ s;\n\treturn s.length;\n}");
+    }
+
     //----------------------------------
     // Other
     //----------------------------------
@@ -120,7 +504,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         asBlockWalker.visitFunction(node);
         assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tb/** Cast to A */.text = '';\n}");
     }
-    
+
     @Test
     public void testFunctionCall()
     {
@@ -128,7 +512,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         asBlockWalker.visitFunction(node);
         assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tbar(b).text = '';\n}");
     }
-    
+
     @Override
     @Test
     public void testVisitAs()

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a5c10c63/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
index 7c1e5c3..6b6a2d3 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSStatements.java
@@ -62,6 +62,15 @@ public class TestFlexJSStatements extends TestGoogStatements
         assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n\tbreak;}\n");
     }
 
+    @Test
+    public void testVisitForEach_HoistedVar()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "var i:int; for each(i in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var foreachiter0 in obj) \n{\ni = obj[foreachiter0];\n\n\tbreak;}\n");
+    }
+
     @Override
     @Test
     public void testVisitLabel_1()

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a5c10c63/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 fd2d328..5f4ee52 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
@@ -269,7 +269,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             {
                 if ((type != null && type.getQualifiedName().equalsIgnoreCase(
                         IASLanguageConstants.Function))
-                        || (def != null && def.getQualifiedName()
+                        || (def != null && (!def.isInternal()) && def.getQualifiedName()
                                 .equalsIgnoreCase(mnode.getQualifiedName())))
                 {
                     if (!(pnode instanceof FunctionNode)
@@ -293,9 +293,9 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                         // we are in a member access expression and it isn't a static
                         // and we are the left node, or the left node is 'this'
                         String tname = type.getQualifiedName();
-                        writeSelf = !tname.equalsIgnoreCase(cnode
+                        writeSelf = true; /*!tname.equalsIgnoreCase(cnode
                                 .getQualifiedName())
-                                && !tname.equals(IASLanguageConstants.Function);
+                                && !tname.equals(IASLanguageConstants.Function);*/
                         break;
                     }
                 }