flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - fix js when member is buried deep in the class hierarchy
Date Sat, 11 May 2013 00:04:31 GMT
Updated Branches:
  refs/heads/develop 3a979882a -> 9d7f35e53


fix js when member is buried deep in the class hierarchy


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

Branch: refs/heads/develop
Commit: 9d7f35e53c261fa1dbfe4724bf94a04c98a62b2a
Parents: 3a97988
Author: Alex Harui <aharui@apache.org>
Authored: Fri May 10 17:03:58 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri May 10 17:03:58 2013 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSExpressions.java   |   28 +++++++++++++++
 .../codegen/js/flexjs/JSFlexJSEmitter.java         |   12 ++++--
 2 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9d7f35e5/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index bf89f94..da33a4a 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -19,12 +19,16 @@
 
 package org.apache.flex.compiler.internal.codegen.js.flexjs;
 
+import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogExpressions;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
 import org.apache.flex.compiler.internal.tree.as.ClassNode;
+import org.apache.flex.compiler.internal.tree.as.NodeBase;
 import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
 import org.junit.Test;
@@ -464,6 +468,30 @@ public class TestFlexJSExpressions extends TestGoogExpressions
     }
 
     @Test
+    public void testVisitBinaryOperatorNode_varAssignmentFromSuperSuperClass()
+    {
+        // simulate MXML script conditions.
+        // get class def
+        // disconnect fileNode from parent
+        // set thisclass on emitter to class def
+        IFileNode node = (IFileNode) getNode(
+                "class B extends C { public function c() { E(model).labelText = null; } }
class C extends D {} class D { public var model:Object; } class E { public function set labelText(value:String)
{} }",
+                IFileNode.class, WRAP_LEVEL_PACKAGE, true);
+        IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
+                node, IFunctionNode.class);
+        IClassNode classnode = (IClassNode) findFirstDescendantOfType(
+                node, IClassNode.class);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
+                fnode, IBinaryOperatorNode.class);
+        ((NodeBase)fnode).setParent(null);
+        IDefinition def = classnode.getDefinition();
+
+        ((JSFlexJSEmitter)asEmitter).thisClass = def;
+        asBlockWalker.visitBinaryOperator(bnode);
+        assertOut("this.model/** Cast to foo.bar.E */.set_labelText(null)");
+    }
+
+    @Test
     public void testNamedFunctionAsArgument()
     {
         IFunctionNode node = (IFunctionNode) getNode(

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9d7f35e5/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 96d892c..1bcfe83 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -361,10 +361,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         if (pdef == thisClass)
             return true;
 
-        // needs to be a loop
-        if (((ClassDefinition) thisClass).resolveBaseClass(project) == pdef)
-            return true;
-
+        IDefinition cdef = ((ClassDefinition) thisClass).resolveBaseClass(project);
+        while (cdef != null)
+        {
+            // needs to be a loop
+            if (cdef == pdef)
+                return true;
+            cdef = ((ClassDefinition) cdef).resolveBaseClass(project);
+        }
         return false;
     }
 


Mime
View raw message