flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1438502 [1/2] - in /flex/falcon/trunk: compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx.tests/test-files/ compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx/src/org/apache/fle...
Date Fri, 25 Jan 2013 13:30:37 GMT
Author: erikdebruin
Date: Fri Jan 25 13:30:37 2013
New Revision: 1438502

URL: http://svn.apache.org/viewvc?rev=1438502&view=rev
Log:
Major addition: 'self' references added to output

- IJSGoogDocEmitter: removed APIs for unused annotations
- IJSGoogDocEmitter: changed signature of some APIs to match the needs of the implementation
- JSGoogDocEmitter: added annotation using fully qualified names for return values and function parameters
- JSGoogEmitter: added support for 'goog' JSs hunger for 'self' references for all class members etc.
- changed tests to reflect the need for 'self'
- added a large test file that is a mirror of the AS file used in the POC, to facilitate output verification and assure integrity of POC

Added:
    flex/falcon/trunk/compiler.jx.tests/test-files/poc.as   (with props)
    flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js   (with props)
Modified:
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
    flex/falcon/trunk/compiler.jx.tests/test-files/call-super_result.js
    flex/falcon/trunk/compiler.jx.tests/test-files/get-set_result.js
    flex/falcon/trunk/compiler.jx.tests/test-files/output.js
    flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object.as
    flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object_result.js
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/js/codegen/goog/IJSGoogDocEmitter.java

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java Fri Jan 25 13:30:37 2013
@@ -51,7 +51,7 @@ public class TestGoogAccessorMembers ext
         IGetterNode node = (IGetterNode) getAccessor("function get foo():int{return -1;}");
         visitor.visitGetter(node);
         assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', "
-                + "\n\t{get:function() {\n\t\treturn -1;\n\t}, configurable:true}\n)");
+                + "\n\t{get:function() {\n\t\tvar self = this;\n\t\treturn -1;\n\t}, configurable:true}\n)");
     }
 
     @Override
@@ -61,7 +61,7 @@ public class TestGoogAccessorMembers ext
         IGetterNode node = (IGetterNode) getAccessor("public function get foo():int{return -1;}");
         visitor.visitGetter(node);
         assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', "
-                + "\n\t{get:function() {\n\t\treturn -1;\n\t}, configurable:true}\n)");
+                + "\n\t{get:function() {\n\t\tvar self = this;\n\t\treturn -1;\n\t}, configurable:true}\n)");
     }
 
     @Override
@@ -69,20 +69,20 @@ public class TestGoogAccessorMembers ext
     public void testGetAccessor_withNamespaceOverride()
     {
         // TODO (erikdebruin) need to figure out how to handle calls to 
-    	//                    'super' since the JS getter is actually an 
-    	//                    anonymous function...
-    	IGetterNode node = (IGetterNode) getAccessor("public override function get foo():int{super.foo(); return -1;}");
+        //                    'super' since the JS getter is actually an 
+        //                    anonymous function...
+        IGetterNode node = (IGetterNode) getAccessor("public override function get foo():int{super.foo(); return -1;}");
         visitor.visitGetter(node);
-        assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', \n\t{get:function() {\n\t\tgoog.base(this, 'foo');\n\t\treturn -1;\n\t}, configurable:true}\n)");
+        assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', \n\t{get:function() {\n\t\tvar self = this;\n\t\tgoog.base(this, 'foo');\n\t\treturn -1;\n\t}, configurable:true}\n)");
     }
 
     @Override
     @Test
     public void testGetAccessor_withStatic()
     {
-    	IGetterNode node = (IGetterNode) getAccessor("public static function get foo():int{return -1;}");
+        IGetterNode node = (IGetterNode) getAccessor("public static function get foo():int{return -1;}");
         visitor.visitGetter(node);
-        assertOut("Object.defineProperty(\n\tA, \n\t'foo', \n\t{get:function() {\n\t\treturn -1;\n\t}, configurable:true}\n)");
+        assertOut("Object.defineProperty(\n\tA, \n\t'foo', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn -1;\n\t}, configurable:true}\n)");
     }
 
     @Override
@@ -101,7 +101,7 @@ public class TestGoogAccessorMembers ext
         ISetterNode node = (ISetterNode) getAccessor("function set foo(value:int):void{trace('haai');}");
         visitor.visitSetter(node);
         assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', "
-                + "\n\t{set:function(value) {\n\t\ttrace('haai');\n\t}, configurable:true}\n)");
+                + "\n\t{set:function(value) {\n\t\tvar self = this;\n\t\ttrace('haai');\n\t}, configurable:true}\n)");
     }
 
     @Override
@@ -119,16 +119,16 @@ public class TestGoogAccessorMembers ext
     public void testSetAccessor_withNamespaceOverride()
     {
         // TODO (erikdebruin) see: testGetAccessor_withNamespaceOverride
-    	ISetterNode node = (ISetterNode) getAccessor("public override function set foo(value:int):void{super.foo();}");
+        ISetterNode node = (ISetterNode) getAccessor("public override function set foo(value:int):void{super.foo();}");
         visitor.visitSetter(node);
-        assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', \n\t{set:function(value) {\n\t\tgoog.base(this, 'foo');\n\t}, configurable:true}\n)");
+        assertOut("Object.defineProperty(\n\tA.prototype, \n\t'foo', \n\t{set:function(value) {\n\t\tvar self = this;\n\t\tgoog.base(this, 'foo');\n\t}, configurable:true}\n)");
     }
 
     @Override
     @Test
     public void testSetAccessor_withStatic()
     {
-    	ISetterNode node = (ISetterNode) getAccessor("public static function set foo(value:int):void{}");
+        ISetterNode node = (ISetterNode) getAccessor("public static function set foo(value:int):void{}");
         visitor.visitSetter(node);
         assertOut("Object.defineProperty(\n\tA, \n\t'foo', \n\t{set:function(value) {\n\t}, configurable:true}\n)");
     }

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java Fri Jan 25 13:30:37 2013
@@ -34,8 +34,8 @@ import org.junit.Test;
  */
 public class TestGoogClass extends TestClass
 {
-	@Override
-	@Test
+    @Override
+    @Test
     public void testSimple()
     {
         IClassNode node = getClassNode("public class A{}");
@@ -43,48 +43,48 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleInternal()
     {
-		// (erikdebruin) the AS compiler will enforce 'internal' namespace, 
-		//               in JS we ignore it
+        // (erikdebruin) the AS compiler will enforce 'internal' namespace, 
+        //               in JS we ignore it
         IClassNode node = getClassNode("internal class A{}");
         visitor.visitClass(node);
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleFinal()
     {
-		// (erikdebruin) the AS compiler will enforce the 'final' keyword, 
-		//               in JS we ignore it
+        // (erikdebruin) the AS compiler will enforce the 'final' keyword, 
+        //               in JS we ignore it
         IClassNode node = getClassNode("public final class A{}");
         visitor.visitClass(node);
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleDynamic()
     {
-		// (erikdebruin) all JS objects are 'dynamic' by design
+        // (erikdebruin) all JS objects are 'dynamic' by design
         IClassNode node = getClassNode("public dynamic class A{}");
         visitor.visitClass(node);
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleExtends()
     {
-       IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
+        IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
         visitor.visitClass(node);
         assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleImplements()
     {
@@ -93,7 +93,7 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleImplementsMultiple()
     {
@@ -102,7 +102,7 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n};");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleExtendsImplements()
     {
@@ -111,7 +111,7 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleExtendsImplementsMultiple()
     {
@@ -120,7 +120,7 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
     }
 
-	@Override
+    @Override
     @Test
     public void testSimpleFinalExtendsImplementsMultiple()
     {
@@ -129,7 +129,7 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
     }
 
-	@Override
+    @Override
     @Test
     public void testQualifiedExtendsImplementsMultiple()
     {
@@ -138,16 +138,16 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
     }
 
-	@Override
+    @Override
     @Test
     public void testConstructor()
     {
         IClassNode node = getClassNode("public class A {public function A() {super('foo', 42);}}");
         visitor.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n\tgoog.base(this, 'foo', 42);\n};");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n\tvar self = this;\n\tgoog.base(this, 'foo', 42);\n};");
     }
-    
-	@Override
+
+    @Override
     @Test
     public void testFields()
     {
@@ -157,20 +157,20 @@ public class TestGoogClass extends TestC
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
     }
 
-	@Override
+    @Override
     @Test
     public void testConstants()
     {
-        IClassNode node = getClassNode("public class A {" +
-        		"public static const A:int = 42;" +
-        		"protected static const B:Number = 42;" +
-                "private static const C:Number = 42;" +
-                "foo_bar static const C:String = 'me' + 'you';");
+        IClassNode node = getClassNode("public class A {"
+                + "public static const A:int = 42;"
+                + "protected static const B:Number = 42;"
+                + "private static const C:Number = 42;"
+                + "foo_bar static const C:String = 'me' + 'you';");
         visitor.visitClass(node);
         assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
     }
-    
-	@Override
+
+    @Override
     @Test
     public void testAccessors()
     {
@@ -186,10 +186,10 @@ public class TestGoogClass extends TestC
                 + "foo_bar function get foo6():Object{return null;}"
                 + "foo_bar function set foo6(value:Object):void{}" + "}");
         visitor.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo1;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo1', \n\t{get:function() {\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo1', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @protected\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo2;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo2', \n\t{get:function() {\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo2', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo3;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo3', \n\t{get:function() {\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.d
 efineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo3', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo5;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo5', \n\t{get:function() {\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo5', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo6;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo6', \n\t{get:function() {\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo6', \n\t{set:function(value) {\n\t}, configurable:true}\n);");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo1;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo1', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo1', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @protected\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo2;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo2', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo2', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo3;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo3', \n\t{get:function() {\n\t\tvar self 
 = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo3', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo5;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo5', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo5', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.foo6;\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo6', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.flex.A.prototype, \n\t'foo6', \n\t{set:function(value) {\n\t}, configurable:true}\n);");
     }
 
-	@Override
+    @Override
     @Test
     public void testMethods()
     {
@@ -204,18 +204,20 @@ public class TestGoogClass extends TestC
                 + "public static function foo7(value:Object):void{}"
                 + "foo_bar static function foo7(value:Object):void{}" + "}");
         visitor.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n\treturn null;\n};\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n\treturn null;\n};\n\n/**\n * @return {Object}\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n\treturn goog.base(this, 'foo1b');\n};\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n/**\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 * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\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 * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n/**\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 * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};\n\n/**\n * @param {Object} value\n
  */\norg.apache.flex.A.foo7 = function(value) {\n};");
     }
 
-	@Override
+    @Override
     protected IClassNode getClassNode(String code)
     {
-        String source = "package org.apache.flex {import flash.events.IEventDispatcher;import mx.logging.ILogger;import spark.components.Button;" + code + "}";
+        String source = "package org.apache.flex {import flash.events.IEventDispatcher;import mx.logging.ILogger;import spark.components.Button;"
+                + code + "}";
         IFileNode node = getFileNode(source);
-        IClassNode child = (IClassNode) findFirstDescendantOfType(node, IClassNode.class);
+        IClassNode child = (IClassNode) findFirstDescendantOfType(node,
+                IClassNode.class);
         return child;
     }
-    
+
     protected IBackend createBackend()
     {
         return new GoogBackend();

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java Fri Jan 25 13:30:37 2013
@@ -49,7 +49,7 @@ public class TestGoogEmiter extends Test
                 + "return \"Don't \" + _privateVar + value; }";
         IFileNode node = getFileNode(code);
         visitor.visitFile(node);
-        assertOut("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tgoog.base(this);\n\tif (this.foo() != 42) {\n\t\tthis.bar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\treturn \"Don't \" + _privateVar + value;\n};");
+        assertOut("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tvar self = this;\n\tgoog.base(this);\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};");
     }
 
     @Test
@@ -66,7 +66,7 @@ public class TestGoogEmiter extends Test
         IFunctionNode node = getMethodWithPackage("function method1(bar:int):int{\n}");
         visitor.visitFunction(node);
         assertOut("/**\n * @param {number} bar\n * @return {number}\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(bar) {\n}");
+                + "foo.bar.A.prototype.method1 = function(bar) {\n}");
     }
 
     @Test
@@ -74,8 +74,8 @@ public class TestGoogEmiter extends Test
     {
         IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {A} goo\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
+        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {foo.bar.A} goo\n */\n"
+                + "foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
     }
 
     @Test
@@ -83,8 +83,8 @@ public class TestGoogEmiter extends Test
     {
         IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {A} goo\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
+        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {foo.bar.A} goo\n */\n"
+                + "foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
     }
 
     @Test
@@ -93,22 +93,24 @@ public class TestGoogEmiter extends Test
         IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
         visitor.visitFunction(node);
         assertOut("/**\n * @param {number} p1\n * @param {number} p2\n * @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+                + "foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+                + "\tvar self = this;\n"
                 + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
                 + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
                 + "\treturn p1 + p2 + p3 + p4;\n}");
     }
-    
+
     @Test
     public void testDefaultParameter_Body()
     {
         IFunctionNode node = getMethodWithPackage("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
         visitor.visitFunction(node);
         assertOut("/**\n * @param {number=} bar\n * @param {number=} bax\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(bar, bax) {\n"
-        		+ "\tbar = typeof bar !== 'undefined' ? bar : 42;\n"
+                + "foo.bar.A.prototype.method1 = function(bar, bax) {\n"
+                + "\tvar self = this;\n"
+                + "\tbar = typeof bar !== 'undefined' ? bar : 42;\n"
                 + "\tbax = typeof bax !== 'undefined' ? bax : 4;\n"
-                + "\tif (a)\n\t\tthis.foo();\n}");
+                + "\tif (a)\n\t\tfoo();\n}");
     }
 
     @Test
@@ -117,7 +119,7 @@ public class TestGoogEmiter extends Test
         IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
         visitor.visitFunction(node);
         assertOut("/**\n * @param {number} p1\n * @param {number} p2\n * @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
-        		+ "foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+                + "foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
                 + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
                 + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
     }

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java Fri Jan 25 13:30:37 2013
@@ -35,13 +35,13 @@ import org.junit.Test;
  */
 public class TestGoogExpressions extends TestExpressions
 {
-	@Override
+    @Override
     @Test
     public void testVisitLanguageIdentifierNode_SuperMethod_1()
     {
         IFunctionNode node = getMethod("function foo(){if (a) super.foo();}");
         visitor.visitFunction(node);
-        assertOut("A.prototype.foo = function() {\n\tif (a)\n\t\tgoog.base(this, 'foo');\n}");
+        assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tgoog.base(this, 'foo');\n}");
     }
 
     @Override
@@ -50,9 +50,9 @@ public class TestGoogExpressions extends
     {
         IFunctionNode node = getMethod("function foo(){if (a) super.foo(a, b, c);}");
         visitor.visitFunction(node);
-        assertOut("A.prototype.foo = function() {\n\tif (a)\n\t\tgoog.base(this, 'foo', a, b, c);\n}");
+        assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tgoog.base(this, 'foo', a, b, c);\n}");
     }
-	
+
     //----------------------------------
     // Primary expression keywords
     //----------------------------------
@@ -62,7 +62,7 @@ public class TestGoogExpressions extends
     //----------------------------------
 
     @Override
-	@Test
+    @Test
     public void testVisitBinaryOperatorNode_LogicalAndAssignment()
     {
         IBinaryOperatorNode node = getBinaryNode("a &&= b");
@@ -101,7 +101,7 @@ public class TestGoogExpressions extends
                 "var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};",
                 IVariableNode.class);
         visitor.visitVariable(node);
-        assertOut("var /** @type {Object} */ a = function(foo, bar) {\n\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\treturn -1;\n}");
+        assertOut("var /** @type {Object} */ a = function(foo, bar) {\n\tvar self = this;\n\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\treturn -1;\n}");
     }
 
     @Override
@@ -113,14 +113,14 @@ public class TestGoogExpressions extends
                 "if (a) {addListener('foo', function(event:Object):void{doit();});}",
                 IIfNode.class);
         visitor.visitIf(node);
-        assertOut("if (a) {\n\tthis.addListener('foo', function(event) {\n\t\tthis.doit();\n\t});\n}");
+        assertOut("if (a) {\n\taddListener('foo', function(event) {\n\t\tvar self = this;\n\t\tdoit();\n\t});\n}");
     }
 
     @Override
     @Test
     public void testVisitAs()
     {
-    	// TODO (erikdebruin) the assert is a placeholder for the eventual workaround
+        // TODO (erikdebruin) the assert is a placeholder for the eventual workaround
         IBinaryOperatorNode node = getBinaryNode("a as b");
         visitor.visitBinaryOperator(node);
         assertOut("as(a, b)");
@@ -130,7 +130,7 @@ public class TestGoogExpressions extends
     @Test
     public void testVisitBinaryOperator_Instancof()
     {
-    	// TODO (erikdebruin) check if the AS and JS implementations match
+        // TODO (erikdebruin) check if the AS and JS implementations match
         IBinaryOperatorNode node = getBinaryNode("a instanceof b");
         visitor.visitBinaryOperator(node);
         assertOut("a instanceof b");
@@ -140,7 +140,7 @@ public class TestGoogExpressions extends
     @Test
     public void testVisitBinaryOperator_Is()
     {
-    	// TODO (erikdebruin) the assert is a placeholder for the eventual workaround
+        // TODO (erikdebruin) the assert is a placeholder for the eventual workaround
         IBinaryOperatorNode node = getBinaryNode("a is b");
         visitor.visitBinaryOperator(node);
         assertOut("is(a, b)");
@@ -151,8 +151,8 @@ public class TestGoogExpressions extends
     public void testVisitBinaryOperator_NamespaceAccess_1()
     {
         // TODO (mschmalle) this needs INamespaceAccessExpressionNode interface
-    	// TODO (erikdebruin) we need a 'goog.require("a")' in the header
-    	NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
+        // TODO (erikdebruin) we need a 'goog.require("a")' in the header
+        NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
                 "a::b", NamespaceAccessExpressionNode.class);
         visitor.visitNamespaceAccessExpression(node);
         assertOut("a.b");
@@ -163,7 +163,7 @@ public class TestGoogExpressions extends
     public void testVisitBinaryOperator_NamespaceAccess_2()
     {
         // TODO (mschmalle) this needs INamespaceAccessExpressionNode interface
-    	// TODO (erikdebruin) we need a 'goog.require("a.b")' in the header
+        // TODO (erikdebruin) we need a 'goog.require("a.b")' in the header
         NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
                 "a::b::c", NamespaceAccessExpressionNode.class);
         visitor.visitNamespaceAccessExpression(node);

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java Fri Jan 25 13:30:37 2013
@@ -27,7 +27,8 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 /**
- * This class tests the production of valid 'goog' JS code from an external file.
+ * This class tests the production of valid 'goog' JS code from an external
+ * file.
  * 
  * @author Erik de Bruin
  */
@@ -41,7 +42,6 @@ public class TestGoogFile extends TestWa
         assertOut(getCodeFromFile("output", true));
     }
 
-    @Ignore
     @Test
     public void testFile_getset()
     {
@@ -54,13 +54,12 @@ public class TestGoogFile extends TestWa
     @Test
     public void testFile_callsuper()
     {
-    	// TODO (erikdebruin) handle various constructor super call edge cases first
+        // TODO (erikdebruin) handle various constructor super call edge cases first
         IFileNode node = getFileNode("call-super", true);
         visitor.visitFile(node);
         assertOut(getCodeFromFile("call-super_result", true));
     }
 
-    @Ignore
     @Test
     public void testFile_qualifynewobject()
     {
@@ -69,6 +68,14 @@ public class TestGoogFile extends TestWa
         assertOut(getCodeFromFile("qualify-new-object_result", true));
     }
 
+    @Test
+    public void testFile_poc()
+    {
+        IFileNode node = getFileNode("poc", true);
+        visitor.visitFile(node);
+        assertOut(getCodeFromFile("poc_result", true));
+    }
+
     @Override
     protected IBackend createBackend()
     {

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java Fri Jan 25 13:30:37 2013
@@ -33,7 +33,8 @@ import org.junit.Test;
 public class TestGoogGlobalClasses extends TestGlobalClasses
 {
     @Override
-    @Test    public void testArgumentError()
+    @Test
+    public void testArgumentError()
     {
         IVariableNode node = getVariable("var a:ArgumentError = new ArgumentError();");
         visitor.visitVariable(node);
@@ -46,7 +47,7 @@ public class TestGoogGlobalClasses exten
     {
         IFunctionNode node = getMethod("function a():void {\ttrace(arguments);}");
         visitor.visitFunction(node);
-        assertOut("A.prototype.a = function() {\n\ttrace(arguments);\n}");
+        assertOut("A.prototype.a = function() {\n\tvar self = this;\n\ttrace(arguments);\n}");
     }
 
     @Override
@@ -125,11 +126,11 @@ public class TestGoogGlobalClasses exten
     @Test
     public void testInt()
     {
-    	IVariableNode node = getVariable("var a:int = new int(1.8);");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {number} */ a = new int(1.8)");
+        IVariableNode node = getVariable("var a:int = new int(1.8);");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {number} */ a = new int(1.8)");
     }
-    
+
     @Override
     @Test
     public void testJSON()
@@ -197,23 +198,23 @@ public class TestGoogGlobalClasses exten
     @Test
     public void testReferenceError()
     {
-    	IVariableNode node = getVariable("var a:ReferenceError = new ReferenceError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {ReferenceError} */ a = new ReferenceError()");
+        IVariableNode node = getVariable("var a:ReferenceError = new ReferenceError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {ReferenceError} */ a = new ReferenceError()");
     }
-    
+
     @Ignore
     @Override
     @Test
     public void testRegExp()
     {
-    	// TODO (erikdebruin) how to handle the escaping of backslashes in
-    	//                    strings in the tests?
+        // TODO (erikdebruin) how to handle the escaping of backslashes in
+        //                    strings in the tests?
         IVariableNode node = getVariable("var a:RegExp = new RegExp('test-\\d', 'i');");
         visitor.visitVariable(node);
         assertOut("var a:RegExp = new RegExp('test-\\\\d', 'i')");
     }
-    
+
     @Override
     @Test
     public void testRegExp_Literal()
@@ -222,95 +223,95 @@ public class TestGoogGlobalClasses exten
         visitor.visitVariable(node);
         assertOut("var /** @type {RegExp} */ a = /test-\\d/i");
     }
-    
+
     @Override
     @Test
     public void testSecurityError()
     {
-    	IVariableNode node = getVariable("var a:SecurityError = new SecurityError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {SecurityError} */ a = new SecurityError()");
+        IVariableNode node = getVariable("var a:SecurityError = new SecurityError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {SecurityError} */ a = new SecurityError()");
     }
-    
+
     @Override
     @Test
     public void testString()
     {
-    	IVariableNode node = getVariable("var a:String = new String(\"100\");");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {string} */ a = new String(\"100\")");
+        IVariableNode node = getVariable("var a:String = new String(\"100\");");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {string} */ a = new String(\"100\")");
     }
 
     @Override
     @Test
     public void testSyntaxError()
     {
-    	IVariableNode node = getVariable("var a:SyntaxError = new SyntaxError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {SyntaxError} */ a = new SyntaxError()");
+        IVariableNode node = getVariable("var a:SyntaxError = new SyntaxError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {SyntaxError} */ a = new SyntaxError()");
     }
-    
+
     @Override
     @Test
     public void testTypeError()
     {
-    	IVariableNode node = getVariable("var a:TypeError = new TypeError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {TypeError} */ a = new TypeError()");
+        IVariableNode node = getVariable("var a:TypeError = new TypeError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {TypeError} */ a = new TypeError()");
     }
-    
+
     @Override
     @Test
     public void testUint()
     {
-    	IVariableNode node = getVariable("var a:uint = new uint(-100);");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {number} */ a = new uint(-100)");
+        IVariableNode node = getVariable("var a:uint = new uint(-100);");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {number} */ a = new uint(-100)");
     }
 
     @Override
     @Test
     public void testURIError()
     {
-    	IVariableNode node = getVariable("var a:URIError = new URIError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {URIError} */ a = new URIError()");
+        IVariableNode node = getVariable("var a:URIError = new URIError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {URIError} */ a = new URIError()");
     }
-    
+
     @Override
     @Test
     public void testVector()
     {
-    	IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {Vector.<string>} */ a = new Vector(['Hello','World'])");
+        IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {Vector.<string>} */ a = new Vector(['Hello','World'])");
     }
 
     @Override
     @Test
     public void testVerifyError()
     {
-    	IVariableNode node = getVariable("var a:VerifyError = new VerifyError();");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {VerifyError} */ a = new VerifyError()");
+        IVariableNode node = getVariable("var a:VerifyError = new VerifyError();");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {VerifyError} */ a = new VerifyError()");
     }
-    
+
     @Override
     @Test
     public void testXML()
     {
-    	IVariableNode node = getVariable("var a:XML = new XML('@');");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {XML} */ a = new XML('@')");
+        IVariableNode node = getVariable("var a:XML = new XML('@');");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {XML} */ a = new XML('@')");
     }
-    
+
     @Override
     @Test
     public void testXMLList()
     {
-    	IVariableNode node = getVariable("var a:XMLList = new XMLList('<!-- comment -->');");
-    	visitor.visitVariable(node);
-    	assertOut("var /** @type {XMLList} */ a = new XMLList('<!-- comment -->')");
+        IVariableNode node = getVariable("var a:XMLList = new XMLList('<!-- comment -->');");
+        visitor.visitVariable(node);
+        assertOut("var /** @type {XMLList} */ a = new XMLList('<!-- comment -->')");
     }
 
     @Override

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java Fri Jan 25 13:30:37 2013
@@ -26,7 +26,8 @@ import org.apache.flex.compiler.tree.as.
 import org.junit.Test;
 
 /**
- * This class tests the production of 'goog'-ified JS code for Class Method members.
+ * This class tests the production of 'goog'-ified JS code for Class Method
+ * members.
  * 
  * @author Michael Schmalle
  * @author Erik de Bruin
@@ -48,7 +49,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo():int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @return {number}\n */\nA.prototype.foo = function() {\n\treturn -1;\n}");
+        assertOut("/**\n * @return {number}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\treturn -1;\n}");
     }
 
     @Override
@@ -57,7 +58,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n}");
+        assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
     }
 
     @Override
@@ -66,7 +67,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
     }
 
     @Override
@@ -75,7 +76,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String = \"baz\"):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n}");
     }
 
     @Override
@@ -84,7 +85,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String, baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -93,7 +94,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String, ...rest):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nA.prototype.foo = function(bar, rest) {\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nA.prototype.foo = function(bar, rest) {\n\tvar self = this;\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n}");
     }
 
     @Override
@@ -103,7 +104,7 @@ public class TestGoogMethodMembers exten
         IFunctionNode node = getMethod("public function foo(bar:String, baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
         // we ignore the 'public' namespace completely
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -112,10 +113,10 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("mx_internal function foo(bar:String, baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
-    	// TODO (erikdebruin) can we safely ignore custom namespaces?
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        // TODO (erikdebruin) can we safely ignore custom namespaces?
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
-    
+
     @Override
     @Test
     public void testMethod_withNamespaceModifiers()
@@ -125,7 +126,7 @@ public class TestGoogMethodMembers exten
         // (erikdebruin) here we actually DO want to declare the method
         //               directly on the 'class' constructor instead of the
         //               prototype!
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -134,7 +135,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("public override function foo(bar:String, baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -143,38 +144,38 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("override public function foo(bar:String, baz:int = null):int{return -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     //--------------------------------------------------------------------------
     // Doc Specific Tests 
     //--------------------------------------------------------------------------
-    
+
     @Test
     public void testConstructor_withThisInBody()
     {
         IFunctionNode node = getMethod("public function A(){this.foo;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @constructor\n */\nA = function() {\n\tthis.foo;\n}");
+        assertOut("/**\n * @constructor\n */\nA = function() {\n\tvar self = this;\n\tthis.foo;\n}");
     }
-    
+
     @Test
     public void testMethod_withThisInBody()
     {
         IFunctionNode node = getMethod("function foo(){this.foo;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tthis.foo;\n}");
+        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\tthis.foo;\n}");
     }
-    
+
     @Test
     public void testMethod_withThisInBodyComplex()
     {
         IFunctionNode node = getMethod("function foo(){if(true){while(i){this.bar(42);}}}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tif (true) " +
-        		"{\n\t\twhile (i) {\n\t\t\tthis.bar(42);\n\t\t}\n\t}\n}");
+        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\tif (true) "
+                + "{\n\t\twhile (i) {\n\t\t\tthis.bar(42);\n\t\t}\n\t}\n}");
     }
-    
+
     @Override
     protected IBackend createBackend()
     {

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java Fri Jan 25 13:30:37 2013
@@ -59,11 +59,11 @@ public class TestGoogPackage extends Tes
         // All class nodes in AST get either an implicit or explicit constructor
         // this is an implicit and the way I have the before/after handler working
         // with block disallows implicit blocks from getting { }
-    	
-    	// (erikdebruin) the constuctor IS the class definition, in 'goog' JS,
-    	//               therefor we need to write out implicit constructors 
-    	//               (if I understand the term correctly)
-    	
+
+        // (erikdebruin) the constuctor IS the class definition, in 'goog' JS,
+        //               therefor we need to write out implicit constructors 
+        //               (if I understand the term correctly)
+
         IFileNode node = getFileNode("package {public class A{}}");
         visitor.visitFile(node);
         assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};");
@@ -93,7 +93,7 @@ public class TestGoogPackage extends Tes
     {
         IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){if (a){for (var i:Object in obj){doit();}}}}}");
         visitor.visitFile(node);
-        assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tthis.doit();\n\t\t}\n\t}\n};");
+        assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tvar self = this;\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tdoit();\n\t\t}\n\t}\n};");
     }
 
     @Override

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java (original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java Fri Jan 25 13:30:37 2013
@@ -43,7 +43,8 @@ public class TestGoogStatements extends 
     @Test
     public void testVarDeclaration()
     {
-        IVariableNode node = (IVariableNode) getNode("var a;", IVariableNode.class);
+        IVariableNode node = (IVariableNode) getNode("var a;",
+                IVariableNode.class);
         visitor.visitVariable(node);
         assertOut("var /** @type {*} */ a");
     }
@@ -52,7 +53,8 @@ public class TestGoogStatements extends 
     @Test
     public void testVarDeclaration_withType()
     {
-        IVariableNode node = (IVariableNode) getNode("var a:int;", IVariableNode.class);
+        IVariableNode node = (IVariableNode) getNode("var a:int;",
+                IVariableNode.class);
         visitor.visitVariable(node);
         assertOut("var /** @type {number} */ a");
     }
@@ -170,7 +172,7 @@ public class TestGoogStatements extends 
     @Test
     public void testVisitForEach_1()
     {
-    	// TODO (erikdebruin) the assert is a placeholder for the eventual workaround
+        // TODO (erikdebruin) the assert is a placeholder for the eventual workaround
         IForLoopNode node = (IForLoopNode) getNode(
                 "for each(var i:int in obj) { break; }", IForLoopNode.class);
         visitor.visitForLoop(node);
@@ -181,7 +183,7 @@ public class TestGoogStatements extends 
     @Test
     public void testVisitForEach_1a()
     {
-    	// TODO (erikdebruin) the assert is a placeholder for the eventual workaround
+        // TODO (erikdebruin) the assert is a placeholder for the eventual workaround
         IForLoopNode node = (IForLoopNode) getNode(
                 "for each(var i:int in obj)  break; ", IForLoopNode.class);
         visitor.visitForLoop(node);
@@ -269,7 +271,7 @@ public class TestGoogStatements extends 
     @Test
     public void testVisit()
     {
-    	// TODO (erikdebruin) check if resulting 'goog' JS is valid
+        // TODO (erikdebruin) check if resulting 'goog' JS is valid
         IFileNode node = (IFileNode) getNode(
                 "try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally {  }"
                         + "if (d) for (var i:int = 0; i < len; i++) break;"
@@ -283,10 +285,9 @@ public class TestGoogStatements extends 
                         + "foo: for each(var i:int in obj) break foo;",
                 IFileNode.class);
         visitor.visitFile(node);
-        assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};\n\nA.prototype.a = function() {\n\ttry {\n\t\ta;\n\t} catch (e) {\n\t\tif (a) {\n\t\t\tif (b) {\n\t\t\t\tif (c)\n\t\t\t\t\tb;\n\t\t\t\telse if (f)\n\t\t\t\t\ta;\n\t\t\t\telse\n\t\t\t\t\te;\n\t\t\t}\n\t\t}\n\t} finally {\n\t}\n\tif (d)\n\t\tfor (var /** @type {number} */ i = 0; i < len; i++)\n\t\t\tbreak;\n\tif (a) {\n\t\twith (ab) {\n\t\t\tthis.c();\n\t\t}\n\t\tdo {\n\t\t\ta++;\n\t\t\tdo\n\t\t\t\ta++;\n\t\t\twhile (a > b);\n\t\t} while (c > d);\n\t}\n\tif (b) {\n\t\ttry {\n\t\t\ta;\n\t\t\tthrow new Error('foo');\n\t\t} catch (e) {\n\t\t\tswitch (i) {\n\t\t\t\tcase 1:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (f) {\n\t\t\tc;\n\t\t\teee.dd;\n\t\t} finally {\n\t\t\td;\n\t\t\tvar /** @type {Object} */ a = function(foo, bar) {\n\t\t\t\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\t\t\t\treturn -1;\n\t\t\t};\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t\teee.dd;\n
 \t\t\teee.dd;\n\t\t}\n\t}\n\tfoo : for-each (var /** @type {number} */ i in obj)\n\t\tbreak foo;;\n};");
+        assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};\n\nA.prototype.a = function() {\n\tvar self = this;\n\ttry {\n\t\ta;\n\t} catch (e) {\n\t\tif (a) {\n\t\t\tif (b) {\n\t\t\t\tif (c)\n\t\t\t\t\tb;\n\t\t\t\telse if (f)\n\t\t\t\t\ta;\n\t\t\t\telse\n\t\t\t\t\te;\n\t\t\t}\n\t\t}\n\t} finally {\n\t}\n\tif (d)\n\t\tfor (var /** @type {number} */ i = 0; i < len; i++)\n\t\t\tbreak;\n\tif (a) {\n\t\twith (ab) {\n\t\t\tc();\n\t\t}\n\t\tdo {\n\t\t\ta++;\n\t\t\tdo\n\t\t\t\ta++;\n\t\t\twhile (a > b);\n\t\t} while (c > d);\n\t}\n\tif (b) {\n\t\ttry {\n\t\t\ta;\n\t\t\tthrow new Error('foo');\n\t\t} catch (e) {\n\t\t\tswitch (i) {\n\t\t\t\tcase 1:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (f) {\n\t\t\tc;\n\t\t\teee.dd;\n\t\t} finally {\n\t\t\td;\n\t\t\tvar /** @type {Object} */ a = function(foo, bar) {\n\t\t\t\tvar self = this;\n\t\t\t\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\t\t\t\treturn -1;\n\t\t\t};\n\t\t
 \teee.dd;\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t}\n\t}\n\tfoo : for-each (var /** @type {number} */ i in obj)\n\t\tbreak foo;;\n};");
     }
 
-
     protected IBackend createBackend()
     {
         return new GoogBackend();

Modified: flex/falcon/trunk/compiler.jx.tests/test-files/call-super_result.js
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/call-super_result.js?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/call-super_result.js (original)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/call-super_result.js Fri Jan 25 13:30:37 2013
@@ -10,6 +10,7 @@ goog.require('spark.components.Button');
  * @param {string} z
  */
 org.apache.flex.A = function(z) {
+	var self = this;
 	goog.base(this, z);
 }
 goog.inherits(org.apache.flex.A, spark.components.Button);
@@ -20,6 +21,7 @@ goog.inherits(org.apache.flex.A, spark.c
  * @return {string}
  */
 org.apache.flex.A.prototype.hasSuperCall = function(a, b) {
+	var self = this;
 	goog.base(this, 'hasSuperCall', a, b, 100);
 	var /** @type {string} */ result = myRegularFunctionCall(-1);
 	return result;

Modified: flex/falcon/trunk/compiler.jx.tests/test-files/get-set_result.js
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/get-set_result.js?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/get-set_result.js (original)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/get-set_result.js Fri Jan 25 13:30:37 2013
@@ -21,6 +21,7 @@ Object.defineProperty(
 	org.apache.flex.A.prototype, 
 	'a', 
 	{get:function() {
+		var self = this;
 		return -1;
 	}, configurable:true}
 );
@@ -29,6 +30,7 @@ Object.defineProperty(
 	org.apache.flex.A.prototype, 
 	'a', 
 	{set:function(value) {
-		_a = value;
+		var self = this;
+		self._a = value;
 	}, configurable:true}
 );
\ No newline at end of file

Modified: flex/falcon/trunk/compiler.jx.tests/test-files/output.js
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/output.js?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/output.js (original)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/output.js Fri Jan 25 13:30:37 2013
@@ -9,8 +9,9 @@ goog.require('spark.components.Button');
  * @implements {flash.events.IEventDispatcher}
  */
 org.apache.flex.A = function() {
+	var self = this;
 	goog.base(this);
-	trace(typeof("a"));
+	self.trace(typeof("a"));
 }
 goog.inherits(org.apache.flex.A, spark.components.Button);
 

Added: flex/falcon/trunk/compiler.jx.tests/test-files/poc.as
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/poc.as?rev=1438502&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/poc.as (added)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/poc.as Fri Jan 25 13:30:37 2013
@@ -0,0 +1,88 @@
+package  
+{
+
+import flash.events.MouseEvent;
+
+import spark.components.Button;
+import spark.components.Group;
+import spark.components.Label;
+
+public class Example extends Group
+{
+	private static const BYEBYE:String = "Bye Bye";
+	private static const HELLOWORLD:String = "Hello World";
+	
+	private static var counter:int = 100;
+
+	public function Example() 
+	{
+		init();
+	}
+	
+	private var _btn1:Button;
+	private var _btn2:Button;
+	private var _btn3:Button;
+	private var _lbl1:Label;
+	private var _lbl2:Label;
+	
+	public function init():void
+	{
+		_lbl1 = new Label();
+		_lbl1.x = 100;
+		_lbl1.y = 25;
+		_lbl1.text = Example.HELLOWORLD;
+		
+		addElement(_lbl1);
+		
+		_lbl2 = new Label();
+		_lbl2.x = 200;
+		_lbl2.y = 25;
+		_lbl2.text = Example.counter + "";
+		
+		addElement(_lbl2);
+		
+		_btn1 = new Button();
+		_btn1.x = 100;
+		_btn1.y = 50;
+		_btn1.label = "Click me";
+		_btn1.addEventListener(MouseEvent.CLICK, btn1clickHandler);
+		
+		addElement(_btn1);
+
+		_btn2 = new Button();
+		_btn2.x = 200;
+		_btn2.y = 50;
+		_btn2.label = "Add it";
+		_btn2.addEventListener(MouseEvent.CLICK, btn2clickHandler);
+		
+		addElement(_btn2);
+		
+		_btn3 = new Button();
+		_btn3.x = 300;
+		_btn3.y = 50;
+		_btn3.label = "Move it";
+		_btn3.addEventListener(MouseEvent.CLICK, btn3clickHandler);
+		
+		addElement(_btn3);
+	}
+	
+	protected function btn1clickHandler(event:MouseEvent):void
+	{
+		if (_lbl1.text == Example.HELLOWORLD)
+			_lbl1.text = Example.BYEBYE;
+		else
+			_lbl1.text = Example.HELLOWORLD;
+	}
+	
+	protected function btn2clickHandler(event:MouseEvent):void
+	{
+		_lbl2.text = --Example.counter + "";
+	}
+	
+	protected function btn3clickHandler(event:MouseEvent):void
+	{
+		_btn3.x += 10;
+	}
+	
+}
+}
\ No newline at end of file

Propchange: flex/falcon/trunk/compiler.jx.tests/test-files/poc.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js?rev=1438502&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js (added)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js Fri Jan 25 13:30:37 2013
@@ -0,0 +1,126 @@
+goog.provide('Example');
+
+goog.require('flash.events.MouseEvent');
+goog.require('spark.components.Button');
+goog.require('spark.components.Group');
+goog.require('spark.components.Label');
+
+/**
+ * @constructor
+ * @extends {spark.components.Group}
+ */
+Example = function() {
+	var self = this;
+	goog.base(this);
+	self.init();
+}
+goog.inherits(Example, spark.components.Group);
+
+/**
+ * @private
+ * @const
+ * @type {string}
+ */
+Example.BYEBYE = "Bye Bye";
+
+/**
+ * @private
+ * @const
+ * @type {string}
+ */
+Example.HELLOWORLD = "Hello World";
+
+/**
+ * @private
+ * @type {number}
+ */
+Example.counter = 100;
+
+/**
+ * @private
+ * @type {spark.components.Button}
+ */
+Example.prototype._btn1;
+
+/**
+ * @private
+ * @type {spark.components.Button}
+ */
+Example.prototype._btn2;
+
+/**
+ * @private
+ * @type {spark.components.Button}
+ */
+Example.prototype._btn3;
+
+/**
+ * @private
+ * @type {spark.components.Label}
+ */
+Example.prototype._lbl1;
+
+/**
+ * @private
+ * @type {spark.components.Label}
+ */
+Example.prototype._lbl2;
+
+Example.prototype.init = function() {
+	var self = this;
+	self._lbl1 = new spark.components.Label();
+	self._lbl1.x = 100;
+	self._lbl1.y = 25;
+	self._lbl1.text = Example.HELLOWORLD;
+	self.addElement(self._lbl1);
+	self._lbl2 = new spark.components.Label();
+	self._lbl2.x = 200;
+	self._lbl2.y = 25;
+	self._lbl2.text = Example.counter + "";
+	self.addElement(self._lbl2);
+	self._btn1 = new spark.components.Button();
+	self._btn1.x = 100;
+	self._btn1.y = 50;
+	self._btn1.label = "Click me";
+	self._btn1.addEventListener(flash.events.MouseEvent.CLICK, self.btn1clickHandler);
+	self.addElement(self._btn1);
+	self._btn2 = new spark.components.Button();
+	self._btn2.x = 200;
+	self._btn2.y = 50;
+	self._btn2.label = "Add it";
+	self._btn2.addEventListener(flash.events.MouseEvent.CLICK, self.btn2clickHandler);
+	self.addElement(self._btn2);
+	self._btn3 = new spark.components.Button();
+	self._btn3.x = 300;
+	self._btn3.y = 50;
+	self._btn3.label = "Move it";
+	self._btn3.addEventListener(flash.events.MouseEvent.CLICK, self.btn3clickHandler);
+	self.addElement(self._btn3);
+};
+
+/**
+ * @param {flash.events.MouseEvent} event
+ */
+Example.prototype.btn1clickHandler = function(event) {
+	var self = this;
+	if (self._lbl1.text == Example.HELLOWORLD)
+		self._lbl1.text = Example.BYEBYE;
+	else
+		self._lbl1.text = Example.HELLOWORLD;
+};
+
+/**
+ * @param {flash.events.MouseEvent} event
+ */
+Example.prototype.btn2clickHandler = function(event) {
+	var self = this;
+	self._lbl2.text = --Example.counter + "";
+};
+
+/**
+ * @param {flash.events.MouseEvent} event
+ */
+Example.prototype.btn3clickHandler = function(event) {
+	var self = this;
+	self._btn3.x += 10;
+};
\ No newline at end of file

Propchange: flex/falcon/trunk/compiler.jx.tests/test-files/poc_result.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object.as
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object.as?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object.as (original)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object.as Fri Jan 25 13:30:37 2013
@@ -7,13 +7,27 @@ import spark.components.Button;
 
 public class A extends EventDispatcher
 {
-	public function A() {}
+	public function A() 
+	{
+		init();
+	}
 	
-	public function init()
+	private var _privateVar:Button;
+	
+	public function init():void
 	{
 		var btn:Button = new Button();
 		
+		_privateVar = new Button();
+		
 		addEventListener("click", function () {});
 	}
+	
+	public function start():void
+	{
+		var localVar:String = _privateVar.label;
+		init();
+		doIt();
+	}
 }
 }
\ No newline at end of file

Modified: flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object_result.js
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object_result.js?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object_result.js (original)
+++ flex/falcon/trunk/compiler.jx.tests/test-files/qualify-new-object_result.js Fri Jan 25 13:30:37 2013
@@ -8,12 +8,29 @@ goog.require('spark.components.Button');
  * @extends {flash.events.EventDispatcher}
  */
 org.apache.flex.A = function() {
+	var self = this;
 	goog.base(this);
+	self.init();
 }
 goog.inherits(org.apache.flex.A, flash.events.EventDispatcher);
 
+/**
+ * @private
+ * @type {spark.components.Button}
+ */
+org.apache.flex.A.prototype._privateVar;
+
 org.apache.flex.A.prototype.init = function() {
+	var self = this;
 	var /** @type {spark.components.Button} */ btn = new spark.components.Button();
-	this.addEventListener("click", function() {
+	self._privateVar = new spark.components.Button();
+	self.addEventListener("click", function() {
 	});
+};
+
+org.apache.flex.A.prototype.start = function() {
+	var self = this;
+	var /** @type {string} */ localVar = self._privateVar.label;
+	self.init();
+	doIt();
 };
\ No newline at end of file

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java?rev=1438502&r1=1438501&r2=1438502&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java (original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java Fri Jan 25 13:30:37 2013
@@ -21,9 +21,11 @@ package org.apache.flex.compiler.interna
 
 import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.DependencyType;
+import org.apache.flex.compiler.constants.IASGlobalFunctionConstants;
 import org.apache.flex.compiler.constants.IASKeywordConstants;
 import org.apache.flex.compiler.constants.IASLanguageConstants;
 import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.definitions.references.IReference;
 import org.apache.flex.compiler.internal.as.codegen.ASEmitter;
@@ -37,6 +39,7 @@ import org.apache.flex.compiler.projects
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IInterfaceNode;
 import org.apache.flex.compiler.tree.as.IPackageNode;
@@ -56,46 +59,50 @@ public class JSGoogDocEmitter extends JS
     {
         super(emitter);
     }
-    
+
     @Override
     public void emitInterfaceDoc(IInterfaceNode node)
     {
         begin();
-        
-        emitJSDocLine(JSGoogEmitter.INTERFACE); 
-        
+
+        emitJSDocLine(JSGoogEmitter.INTERFACE);
+
         String[] inodes = node.getExtendedInterfaces();
         for (String inode : inodes)
         {
             emitJSDocLine(IASKeywordConstants.EXTENDS, inode);
         }
-        
+
         end();
     }
-    
+
     @Override
-    public void emitFieldDoc(IVariableNode node)
+    public void emitFieldDoc(IVariableNode node, IDefinition def)
     {
-    	begin();
-    	
-    	String ns = node.getNamespace();
-    	if (ns == IASKeywordConstants.PRIVATE)
-    	{
-    		emitPrivate(node);
-    	}
-    	else if (ns == IASKeywordConstants.PROTECTED)
-    	{	
-    		emitProtected(node);
-    	}
-    	
-    	if (node.isConst())
-    		emitConst(node);
-    	
-    	emitType(node, "");
-    	
-    	end();
+        begin();
+
+        String ns = node.getNamespace();
+        if (ns == IASKeywordConstants.PRIVATE)
+        {
+            emitPrivate(node);
+        }
+        else if (ns == IASKeywordConstants.PROTECTED)
+        {
+            emitProtected(node);
+        }
+
+        if (node.isConst())
+            emitConst(node);
+
+        String packageName = "";
+        if (def != null)
+            packageName = def.getPackageName();
+
+        emitType(node, packageName);
+
+        end();
     }
-    
+
     @Override
     public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
     {
@@ -107,13 +114,13 @@ public class JSGoogDocEmitter extends JS
 
             if (node.isConstructor())
             {
-            	// TODO (erikdebruin) handle JSDOC for constructors with arguments
-            	
+                // TODO (erikdebruin) handle JSDOC for constructors with arguments
+
                 begin();
                 hasDoc = true;
-                
+
                 emitJSDocLine(JSGoogEmitter.CONSTRUCTOR);
-                
+
                 IClassDefinition parent = (IClassDefinition) node
                         .getDefinition().getParent();
                 IClassDefinition superClass = parent.resolveBaseClass(project);
@@ -121,15 +128,17 @@ public class JSGoogDocEmitter extends JS
 
                 if (superClass != null
                         && !qname.equals(IASLanguageConstants.Object))
-                    emitExtends(superClass);
+                    emitExtends(superClass, superClass.getPackageName());
 
                 IReference[] references = classDefinition
                         .getImplementedInterfaceReferences();
                 for (IReference iReference : references)
                 {
-                    emitImplements((ITypeDefinition) iReference.resolve(
-                            project, (ASScope) classDefinition.getContainingScope(),
-                            DependencyType.INHERITANCE, true));
+                    ITypeDefinition type = (ITypeDefinition) iReference
+                            .resolve(project, (ASScope) classDefinition
+                                    .getContainingScope(),
+                                    DependencyType.INHERITANCE, true);
+                    emitImplements(type, type.getPackageName());
                 }
 
                 //                IExpressionNode[] inodes = cnode.getImplementedInterfaceNodes();
@@ -149,7 +158,7 @@ public class JSGoogDocEmitter extends JS
                     begin();
                     hasDoc = true;
 
-                    emitThis(classDefinition);
+                    emitThis(classDefinition, classDefinition.getPackageName());
                 }
 
                 // @param
@@ -162,12 +171,16 @@ public class JSGoogDocEmitter extends JS
                         hasDoc = true;
                     }
 
-                    emitParam(pnode);
+                    IExpressionNode enode = pnode.getNameExpressionNode();
+                    emitParam(pnode, enode.resolveType(project)
+                            .getPackageName());
                 }
 
                 // @return
                 String returnType = node.getReturnType();
-                if (returnType != "" && returnType != ASTNodeID.LiteralVoidID.getParaphrase())
+                if (returnType != ""
+                        && returnType != ASTNodeID.LiteralVoidID
+                                .getParaphrase())
                 {
                     if (!hasDoc)
                     {
@@ -175,7 +188,7 @@ public class JSGoogDocEmitter extends JS
                         hasDoc = true;
                     }
 
-                    emitReturn(node);
+                    emitReturn(node, node.getPackageName());
                 }
 
                 // @override
@@ -191,33 +204,33 @@ public class JSGoogDocEmitter extends JS
                     emitOverride(node);
                 }
             }
-            
+
             if (hasDoc)
                 end();
         }
     }
 
     @Override
-    public void emitVarDoc(IVariableNode node, ITypeDefinition typedef)
+    public void emitVarDoc(IVariableNode node, IDefinition def)
     {
-    	String packageName = "";
-        if (typedef != null)
-        	packageName = typedef.getPackageName();
+        String packageName = "";
+        if (def != null)
+            packageName = def.getPackageName();
 
         if (!node.isConst())
-        {	
-        	emitTypeShort(node, packageName);
+        {
+            emitTypeShort(node, packageName);
         }
         else
         {
-        	writeNewline();
-        	begin();
-        	emitConst(node);
-        	emitType(node, packageName);
-        	end();
+            writeNewline();
+            begin();
+            emitConst(node);
+            emitType(node, packageName);
+            end();
         }
     }
-    
+
     @Override
     public void emitConst(IVariableNode node)
     {
@@ -225,50 +238,17 @@ public class JSGoogDocEmitter extends JS
     }
 
     @Override
-    public void emitDefine(IVariableNode node)
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void emitDeprecated(IASNode node)
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void emitEnum(IClassNode node)
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void emitExtends(IClassDefinition superDefinition)
+    public void emitExtends(IClassDefinition superDefinition, String packageName)
     {
-        emitJSDocLine(IASKeywordConstants.EXTENDS, superDefinition.getQualifiedName());
+        emitJSDocLine(IASKeywordConstants.EXTENDS,
+                superDefinition.getQualifiedName());
     }
 
     @Override
-    public void emitImplements(ITypeDefinition definition)
+    public void emitImplements(ITypeDefinition definition, String packageName)
     {
-        emitJSDocLine(IASKeywordConstants.IMPLEMENTS, definition.getQualifiedName());
-    }
-
-    @Override
-    public void emitInheritDoc(IClassNode node)
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void emitLicense(IClassNode node)
-    {
-        // TODO Auto-generated method stub
-
+        emitJSDocLine(IASKeywordConstants.IMPLEMENTS,
+                definition.getQualifiedName());
     }
 
     @Override
@@ -278,16 +258,17 @@ public class JSGoogDocEmitter extends JS
     }
 
     @Override
-    public void emitParam(IParameterNode node)
+    public void emitParam(IParameterNode node, String packageName)
     {
-    	String postfix = (node.getDefaultValue() == null) ? "" : ASEmitter.EQUALS;
-    	
-    	String paramType = "";
-    	if (node.isRest())
-    		paramType = IASLanguageConstants.REST;
-    	else
-    		paramType = convertASTypeToJS(node.getVariableType());
-    	
+        String postfix = (node.getDefaultValue() == null) ? ""
+                : ASEmitter.EQUALS;
+
+        String paramType = "";
+        if (node.isRest())
+            paramType = IASLanguageConstants.REST;
+        else
+            paramType = convertASTypeToJS(node.getVariableType(), packageName);
+
         emitJSDocLine(PARAM, paramType + postfix, node.getName());
     }
 
@@ -304,17 +285,18 @@ public class JSGoogDocEmitter extends JS
     }
 
     @Override
-    public void emitReturn(IFunctionNode node)
+    public void emitReturn(IFunctionNode node, String packageName)
     {
         String rtype = node.getReturnType();
         if (rtype != null)
         {
-            emitJSDocLine(IASKeywordConstants.RETURN, convertASTypeToJS(rtype));
+            emitJSDocLine(IASKeywordConstants.RETURN,
+                    convertASTypeToJS(rtype, packageName));
         }
     }
 
     @Override
-    public void emitThis(ITypeDefinition type)
+    public void emitThis(ITypeDefinition type, String packageName)
     {
         emitJSDocLine(IASKeywordConstants.THIS, type.getQualifiedName());
     }
@@ -323,37 +305,25 @@ public class JSGoogDocEmitter extends JS
     public void emitType(IASNode node, String packageName)
     {
         String type = ((IVariableNode) node).getVariableType();
-        emitJSDocLine(TYPE, convertASTypeToJS(type));
+        emitJSDocLine(TYPE, convertASTypeToJS(type, packageName));
     }
 
     public void emitTypeShort(IASNode node, String packageName)
     {
-        String type = ((IVariableNode) node).getVariableType(); 
+        String type = ((IVariableNode) node).getVariableType();
         write(JSDOC_OPEN);
         writeSpace();
         write(AT);
         write(TYPE);
-    	writeSpace();
+        writeSpace();
         writeBlockOpen();
-        if (packageName != "")
-        {
-        	write(packageName);
-        	write(ASEmitter.PERIOD);
-        }
-        write(convertASTypeToJS(type));
+        write(convertASTypeToJS(type, packageName));
         writeBlockClose();
         writeSpace();
         write(JSDOC_CLOSE);
         writeSpace();
     }
 
-    @Override
-    public void emitTypedef(IASNode node)
-    {
-        // TODO Auto-generated method stub
-
-    }
-
     //--------------------------------------------------------------------------
 
     public void emmitPackageHeader(IPackageNode node)
@@ -370,14 +340,14 @@ public class JSGoogDocEmitter extends JS
 
     private void emitJSDocLine(String name)
     {
-    	emitJSDocLine(name, "");
+        emitJSDocLine(name, "");
     }
-    
+
     private void emitJSDocLine(String name, String type)
     {
-    	emitJSDocLine(name, type, "");
+        emitJSDocLine(name, type, "");
     }
-    
+
     private void emitJSDocLine(String name, String type, String param)
     {
         writeSpace();
@@ -386,20 +356,20 @@ public class JSGoogDocEmitter extends JS
         write(AT);
         write(name);
         if (type != "")
-    	{
-	    	writeSpace();
-	        writeBlockOpen();
-	        write(type);
-	        writeBlockClose();
-    	}
+        {
+            writeSpace();
+            writeBlockOpen();
+            write(type);
+            writeBlockClose();
+        }
         if (param != "")
-    	{
-	    	writeSpace();
-	        write(param);
-    	}
+        {
+            writeSpace();
+            write(param);
+        }
         writeNewline();
     }
-    
+
     private boolean containsThisReference(IASNode node)
     {
         final int len = node.getChildCount();
@@ -420,22 +390,39 @@ public class JSGoogDocEmitter extends JS
         return false;
     }
 
-    private String convertASTypeToJS(String name)
+    private String convertASTypeToJS(String name, String pname)
     {
-    	String result = name;
-    	
-    	if (name.equals(""))
-    		result = IASLanguageConstants.ANY_TYPE;
-    	else if (name.equals(IASLanguageConstants.Boolean) || 
-    			 name.equals(IASLanguageConstants.String) || 
-    			 name.equals(IASLanguageConstants.Number))
-    		result = result.toLowerCase();
-    	else if (name.equals(IASLanguageConstants._int) || 
-    			 name.equals(IASLanguageConstants.uint))
-    		result = IASLanguageConstants.Number.toLowerCase();
-       
-    	result = result.replace(IASLanguageConstants.String, IASLanguageConstants.String.toLowerCase());
-    	
+        String result = "";
+
+        if (name.equals(""))
+            result = IASLanguageConstants.ANY_TYPE;
+        else if (name.equals(IASLanguageConstants.Boolean)
+                || name.equals(IASLanguageConstants.String)
+                || name.equals(IASLanguageConstants.Number))
+            result = name.toLowerCase();
+        else if (name.equals(IASLanguageConstants._int)
+                || name.equals(IASLanguageConstants.uint))
+            result = IASLanguageConstants.Number.toLowerCase();
+
+        boolean isBuiltinFunction = name.matches("Vector\\.<.*>");
+        IASGlobalFunctionConstants.BuiltinType[] builtinTypes = IASGlobalFunctionConstants.BuiltinType
+                .values();
+        for (IASGlobalFunctionConstants.BuiltinType builtinType : builtinTypes)
+        {
+            if (name.equalsIgnoreCase(builtinType.getName()))
+            {
+                isBuiltinFunction = true;
+                break;
+            }
+        }
+
+        if (result == "")
+            result = (pname != "" && !isBuiltinFunction) ? pname
+                    + ASEmitter.PERIOD + name : name;
+
+        result = result.replace(IASLanguageConstants.String,
+                IASLanguageConstants.String.toLowerCase());
+
         return result;
     }
 



Mime
View raw message