flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-falcon] [refs/heads/develop] - wasn't handling static properly
Date Tue, 25 Aug 2015 06:07:27 GMT
wasn't handling static properly


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

Branch: refs/heads/develop
Commit: c044d2c28bf32e092b1674cc8c6bc9b0da183ebb
Parents: 9053aac
Author: Alex Harui <aharui@apache.org>
Authored: Mon Aug 24 23:07:14 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Aug 24 23:07:14 2015 -0700

----------------------------------------------------------------------
 .../js/flexjs/TestFlexJSFieldMembers.java       | 33 ++++++++++++++++++++
 .../internal/codegen/js/jx/ClassEmitter.java    |  2 +-
 .../internal/codegen/js/jx/FieldEmitter.java    |  2 +-
 3 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c044d2c2/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
index 6b8b4fa..820cd51 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
@@ -121,6 +121,30 @@ public class TestFlexJSFieldMembers extends TestGoogFieldMembers
     }
 
     @Test
+    public void testStaticField()
+    {
+        IVariableNode node = getField("static var foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @export\n * @type {*}\n */\nFalconTest_A.foo");
+    }
+
+    @Test
+    public void testStaticField_withType()
+    {
+        IVariableNode node = getField("static var foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @export\n * @type {number}\n */\nFalconTest_A.foo");
+    }
+
+    @Test
+    public void testStaticField_withTypeValue()
+    {
+        IVariableNode node = getField("static var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @export\n * @type {number}\n */\nFalconTest_A.foo = 420");
+    }
+
+    @Test
     public void testField_withTypeValueArrayLiteral()
     {
     	IClassNode node = (IClassNode) getNode("protected var foo:Array = [ 'foo' ]",
@@ -139,6 +163,15 @@ public class TestFlexJSFieldMembers extends TestGoogFieldMembers
     }
     
     @Test
+    public void testStaticField_withTypeValueObjectLiteral()
+    {
+    	IClassNode node = (IClassNode) getNode("static public var foo:Object = { 'foo': 'bar'
}",
+        		IClassNode.class, WRAP_LEVEL_CLASS);
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\n/**\n
* @export\n * @type {Object}\n */\nFalconTest_A.foo = {'foo':'bar'};");
+    }
+    
+    @Test
     public void testField_withTypeValueFunctionCall()
     {
     	IClassNode node = (IClassNode) getNode("protected var foo:Number = parseFloat('1E2')",

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c044d2c2/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
index 5112cba..7ac11be 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -152,7 +152,7 @@ public class ClassEmitter extends JSSubEmitter implements
             {
             	IVariableNode varnode = ((IVariableNode)dnode);
                 IExpressionNode vnode = varnode.getAssignedValueNode();
-                if (vnode != null && (!(varnode.isConst() || EmitterUtils.isScalar(vnode))))
+                if (vnode != null && (!(varnode.isConst() || dnode.getDefinition().isStatic()
|| EmitterUtils.isScalar(vnode))))
                 {
                     writeNewline();
                     write(ASEmitterTokens.THIS);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c044d2c2/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
index f5aef1a..e619cfb 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
@@ -85,7 +85,7 @@ public class FieldEmitter extends JSSubEmitter implements
         	write("_");
         }
         IExpressionNode vnode = node.getAssignedValueNode();
-        if (vnode != null && (node.isConst() || EmitterUtils.isScalar(vnode)))
+        if (vnode != null && (node.isConst() || ndef.isStatic() || EmitterUtils.isScalar(vnode)))
         {
             write(ASEmitterTokens.SPACE);
             writeToken(ASEmitterTokens.EQUAL);


Mime
View raw message