incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschma...@apache.org
Subject svn commit: r1425164 - in /incubator/flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/js/internal/driver/ compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/
Date Fri, 21 Dec 2012 22:15:44 GMT
Author: mschmalle
Date: Fri Dec 21 22:15:44 2012
New Revision: 1425164

URL: http://svn.apache.org/viewvc?rev=1425164&view=rev
Log:
Flex:FalconJx
- From this commit and previous, Class and Interface now produce valid AS3 source code with
members.
- The basic framework will now produce a package, class, interface, constant, field, accessor,
method, constructor, blocks, statements and expressions

Modified:
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java?rev=1425164&r1=1425163&r2=1425164&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestInterface.java
Fri Dec 21 22:15:44 2012
@@ -66,7 +66,43 @@ public class TestInterface extends TestW
         visitor.visitInterface(node);
         assertOut("public interface IA extends foo.bar.IB, baz.goo.IC, foo.ID {\n}");
     }
-    
+
+    @Test
+    public void testAccessors()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA {\n\tfunction get foo1():Object;\n\t"
+                + "function set foo1(value:Object):void;\n}");
+    }
+
+    @Test
+    public void testMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function foo1():Object;"
+                + "function foo1(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA {\n\tfunction foo1():Object;\n\t"
+                + "function foo1(value:Object):void;\n}");
+    }
+
+    @Test
+    public void testAccessorsMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;"
+                + "function baz1():Object;"
+                + "function baz2(value:Object):void;}");
+        visitor.visitInterface(node);
+        assertOut("public interface IA {\n\tfunction get foo1():Object;"
+                + "\n\tfunction set foo1(value:Object):void;\n\tfunction baz1()"
+                + ":Object;\n\tfunction baz2(value:Object):void;\n}");
+    }
+
     protected IInterfaceNode getInterfaceNode(String code)
     {
         String source = "package {" + code + "}";

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java?rev=1425164&r1=1425163&r2=1425164&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASEmitter.java
Fri Dec 21 22:15:44 2012
@@ -34,6 +34,7 @@ import org.apache.flex.compiler.internal
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionObjectNode;
 import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IAccessorNode;
 import org.apache.flex.compiler.tree.as.IDefinitionNode;
@@ -272,7 +273,11 @@ public class ASEmitter implements IASEmi
         emitMemberName(node);
         emitParamters(node.getParameterNodes());
         emitType(node.getReturnTypeNode());
-        emitMethodScope(node.getScopedNode());
+        if (node.getParent().getParent().getNodeID() == ASTNodeID.ClassID)
+        {
+            emitMethodScope(node.getScopedNode());
+        }
+
         // the client such as IASBlockWalker is responsible for the 
         // semi-colon and newline handling
     }
@@ -315,7 +320,7 @@ public class ASEmitter implements IASEmi
     //--------------------------------------------------------------------------
     // 
     //--------------------------------------------------------------------------
-    
+
     protected void emitNamespace2(IDefinitionNode node)
     {
         String namespace = node.getNamespace();
@@ -325,7 +330,7 @@ public class ASEmitter implements IASEmi
             write(" ");
         }
     }
-    
+
     protected void emitNamespace(IDefinition definition)
     {
         // namespace (public, protected, private, foo_bar)

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java?rev=1425164&r1=1425163&r2=1425164&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/ASBlockWalker.java
Fri Dec 21 22:15:44 2012
@@ -423,9 +423,15 @@ public class ASBlockWalker implements IA
             emitter.write("\n");
 
             // TODO (mschmalle) Check to see if the node order is the order of member parsed
+            final int len = members.length;
+            int i = 0;
             for (IDefinitionNode mnode : members)
             {
                 walk(mnode);
+                emitter.write(";");
+                if (i < len - 1)
+                    emitter.write("\n");
+                i++;
             }
 
             emitter.indentPop();
@@ -472,6 +478,11 @@ public class ASBlockWalker implements IA
             emitter.emitMethod(node);
             return; // TEMP
         }
+        else if (node.getParent().getParent().getNodeID() == ASTNodeID.InterfaceID)
+        {
+            emitter.emitMethod(node);
+            return; // TEMP
+        }
     }
 
     @Override



Mime
View raw message