incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschma...@apache.org
Subject svn commit: r1423423 - in /incubator/flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/js/internal/driver/ compiler.jx/src/org/apache/flex/as/ compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ compiler.jx/src/org/apa...
Date Tue, 18 Dec 2012 12:36:12 GMT
Author: mschmalle
Date: Tue Dec 18 12:36:11 2012
New Revision: 1423423

URL: http://svn.apache.org/viewvc?rev=1423423&view=rev
Log:
Flex:FalconJx:
- Added var/const declarations
- Added chained variable, constant lists to fields and block declarations

Modified:
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestAccessorMembers.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestFieldMembers.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestStatements.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/as/IASEmitter.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
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/JSEmitter.java

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestAccessorMembers.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestAccessorMembers.java?rev=1423423&r1=1423422&r2=1423423&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestAccessorMembers.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestAccessorMembers.java
Tue Dec 18 12:36:11 2012
@@ -94,7 +94,7 @@ public class TestAccessorMembers extends
     @Test
     public void testSetAccessor_withStatic()
     {
-        IAccessorNode node = getAccessor("public override function set foo(value:int):void{}");
+        IAccessorNode node = getAccessor("public static function set foo(value:int):void{}");
         visitor.visitFunction(node);
         assertOut("public static function set foo(value:int):void {\n}");
     }

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestFieldMembers.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestFieldMembers.java?rev=1423423&r1=1423422&r2=1423423&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestFieldMembers.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestFieldMembers.java
Tue Dec 18 12:36:11 2012
@@ -102,7 +102,7 @@ public class TestFieldMembers extends Te
         visitor.visitVariable(node);
         assertOut("protected var foo:Vector.<Vector.<Vector.<Foo>>>");
     }
-    
+
     @Test
     public void testField_withNamespaceTypeValueComplex()
     {
@@ -110,7 +110,15 @@ public class TestFieldMembers extends Te
         visitor.visitVariable(node);
         assertOut("protected var foo:Foo = new Foo('bar', 42)");
     }
-    
+
+    @Test
+    public void testField_withList()
+    {
+        IVariableNode node = getField("protected var a:int = 4, b:int = 11, c:int = 42;");
+        visitor.visitVariable(node);
+        assertOut("protected var a:int = 4, b:int = 11, c:int = 42");
+    }
+
     //--------------------------------------------------------------------------
     // Constant
     //--------------------------------------------------------------------------

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestStatements.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestStatements.java?rev=1423423&r1=1423422&r2=1423423&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestStatements.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/driver/TestStatements.java
Tue Dec 18 12:36:11 2012
@@ -26,6 +26,7 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.ISwitchNode;
 import org.apache.flex.compiler.tree.as.IThrowNode;
 import org.apache.flex.compiler.tree.as.ITryNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
 import org.apache.flex.compiler.tree.as.IWhileLoopNode;
 import org.apache.flex.compiler.tree.as.IWithNode;
 import org.junit.Test;
@@ -40,6 +41,86 @@ public class TestStatements extends Test
     //--------------------------------------------------------------------------
 
     //----------------------------------
+    // var declaration
+    //----------------------------------
+
+    @Test
+    public void testVarDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:*");
+    }
+
+    @Test
+    public void testVarDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int");
+    }
+
+    @Test
+    public void testVarDeclaration_withTypeAssignedValue()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int = 42");
+    }
+
+    @Test
+    public void testVarDeclaration_withTypeAssignedValueComplex()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:Foo = new Foo(42, 'goo');", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:Foo = new Foo(42, 'goo')");
+    }
+
+    @Test
+    public void testVarDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int = 4, b:int = 11, c:int = 42");
+    }
+
+    //----------------------------------
+    // const declaration
+    //----------------------------------
+
+    @Test
+    public void testConstDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:* = 42");
+    }
+
+    @Test
+    public void testConstDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:int = 42");
+    }
+
+    @Test
+    public void testConstDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:int = 4, b:int = 11, c:int = 42");
+    }
+
+    //----------------------------------
     // if ()
     //----------------------------------
 

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/as/IASEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/as/IASEmitter.java?rev=1423423&r1=1423422&r2=1423423&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/as/IASEmitter.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/as/IASEmitter.java
Tue Dec 18 12:36:11 2012
@@ -25,6 +25,7 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.IGetterNode;
 import org.apache.flex.compiler.tree.as.ISetterNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.visitor.IASBlockWalker;
 import org.apache.flex.compiler.visitor.IASNodeStrategy;
 
 /**
@@ -35,6 +36,10 @@ import org.apache.flex.compiler.visitor.
  */
 public interface IASEmitter
 {
+    IASBlockWalker getWalker();
+
+    void setWalker(IASBlockWalker asBlockWalker);
+
     /**
      * Writes a string to the writer.
      * 
@@ -54,6 +59,8 @@ public interface IASEmitter
      */
     void indentPop();
 
+    void emitVarDeclaration(IVariableNode node);
+
     /**
      * Emit a documentation comment for a Class field or constant
      * {@link IVariableNode}.
@@ -110,4 +117,5 @@ public interface IASEmitter
      * @param node The {@link ISetterNode} class setter member.
      */
     void emitSetAccessor(ISetterNode node);
+
 }

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=1423423&r1=1423422&r2=1423423&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
Tue Dec 18 12:36:11 2012
@@ -30,8 +30,10 @@ import org.apache.flex.compiler.definiti
 import org.apache.flex.compiler.definitions.IFunctionDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
 import org.apache.flex.compiler.definitions.references.INamespaceReference;
+import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IAccessorNode;
 import org.apache.flex.compiler.tree.as.IDefinitionNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
@@ -59,16 +61,16 @@ public class ASEmitter implements IASEmi
 
     private int currentIndent = 0;
 
-    private IASBlockWalker visitor;
+    private IASBlockWalker walker;
 
-    public IASBlockWalker getVisitor()
+    public IASBlockWalker getWalker()
     {
-        return visitor;
+        return walker;
     }
 
-    public void setVisitor(IASBlockWalker value)
+    public void setWalker(IASBlockWalker value)
     {
-        visitor = value;
+        walker = value;
     }
 
     public ASEmitter(FilterWriter out)
@@ -139,6 +141,42 @@ public class ASEmitter implements IASEmi
     //--------------------------------------------------------------------------
 
     @Override
+    public void emitVarDeclaration(IVariableNode node)
+    {
+        if (!(node instanceof ChainedVariableNode))
+        {
+            emitMemberKeyword(node);
+        }
+
+        emitDeclarationName(node);
+        emitType(node.getVariableTypeNode());
+        emitAssignedValue(node.getAssignedValueNode());
+
+        if (!(node instanceof ChainedVariableNode))
+        {
+            // check for chained variables
+            int len = node.getChildCount();
+            for (int i = 0; i < len; i++)
+            {
+                IASNode child = node.getChild(i);
+                if (child instanceof ChainedVariableNode)
+                {
+                    write(",");
+                    write(" ");
+                    emitVarDeclaration((IVariableNode) child);
+                }
+            }
+        }
+
+        // the client such as IASBlockWalker is responsible for the 
+        // semi-colon and newline handling
+    }
+
+    //--------------------------------------------------------------------------
+    // 
+    //--------------------------------------------------------------------------
+
+    @Override
     public void emitFieldDocumentation(IVariableNode node)
     {
     }
@@ -151,12 +189,33 @@ public class ASEmitter implements IASEmi
         IVariableDefinition definition = (IVariableDefinition) node
                 .getDefinition();
 
-        emitNamespace(definition);
-        emitModifiers(definition);
-        emitMemberKeyword(node);
+        if (!(node instanceof ChainedVariableNode))
+        {
+            emitNamespace(definition);
+            emitModifiers(definition);
+            emitMemberKeyword(node);
+        }
+
         emitMemberName(node);
         emitType(node.getVariableTypeNode());
         emitAssignedValue(node.getAssignedValueNode());
+
+        if (!(node instanceof ChainedVariableNode))
+        {
+            // check for chained variables
+            int len = node.getChildCount();
+            for (int i = 0; i < len; i++)
+            {
+                IASNode child = node.getChild(i);
+                if (child instanceof ChainedVariableNode)
+                {
+                    write(",");
+                    write(" ");
+                    emitField((IVariableNode) child);
+                }
+            }
+        }
+
         // the client such as IASBlockWalker is responsible for the 
         // semi-colon and newline handling
     }
@@ -282,7 +341,12 @@ public class ASEmitter implements IASEmi
 
     protected void emitMemberName(IDefinitionNode node)
     {
-        getVisitor().walk(node.getNameExpressionNode());
+        getWalker().walk(node.getNameExpressionNode());
+    }
+
+    protected void emitDeclarationName(IDefinitionNode node)
+    {
+        getWalker().walk(node.getNameExpressionNode());
     }
 
     protected void emitParamters(IParameterNode[] nodes)
@@ -292,7 +356,7 @@ public class ASEmitter implements IASEmi
         for (int i = 0; i < len; i++)
         {
             IParameterNode node = nodes[i];
-            getVisitor().walk(node);
+            getWalker().walk(node);
             if (i < len - 1)
                 write(", ");
         }
@@ -306,7 +370,7 @@ public class ASEmitter implements IASEmi
         if (node != null)
         {
             write(":");
-            getVisitor().walk(node);
+            getWalker().walk(node);
         }
     }
 
@@ -317,19 +381,19 @@ public class ASEmitter implements IASEmi
             write(" ");
             write("=");
             write(" ");
-            getVisitor().walk(node);
+            getWalker().walk(node);
         }
     }
 
     protected void emitMethodScope(IScopedNode node)
     {
         write(" ");
-        getVisitor().walk(node);
+        getWalker().walk(node);
     }
 
     protected void emitAccessorKeyword(IKeywordNode node)
     {
-        getVisitor().walk(node);
+        getWalker().walk(node);
         write(" ");
     }
 }

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=1423423&r1=1423422&r2=1423423&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
Tue Dec 18 12:36:11 2012
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Stack;
 
+import org.apache.flex.as.IASEmitter;
 import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IInterfaceDefinition;
@@ -68,6 +69,7 @@ import org.apache.flex.compiler.tree.as.
 import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
+import org.apache.flex.compiler.tree.as.IAccessorNode;
 import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
 import org.apache.flex.compiler.tree.as.INamespaceNode;
 import org.apache.flex.compiler.tree.as.INumericLiteralNode;
@@ -126,7 +128,7 @@ public class ASBlockWalker implements IA
         SUPER_ARGUMENTS
     }
 
-    private JSEmitter emitter;
+    private IASEmitter emitter;
 
     private final List<ICompilerProblem> errors;
 
@@ -220,12 +222,12 @@ public class ASBlockWalker implements IA
     }
 
     public ASBlockWalker(List<ICompilerProblem> errors, IASProject project,
-            JSEmitter emitter)
+            IASEmitter emitter)
     {
         this.errors = errors;
         this.project = project;
         this.emitter = emitter;
-        emitter.setVisitor(this);
+        emitter.setWalker(this);
         pushContext(TraverseContext.ROOT);
     }
 
@@ -261,7 +263,7 @@ public class ASBlockWalker implements IA
     {
         debug("visitPackage()");
         pushContext(TraverseContext.PACKAGE);
-        emitter.emitJSDocPackgeHeader(node);
+        //        emitter.emitJSDocPackgeHeader(node);
         walk(findTypeNode(node)); // IClassNode | IInterfaceNode
         popContext(TraverseContext.PACKAGE);
     }
@@ -274,8 +276,8 @@ public class ASBlockWalker implements IA
 
         debug("visitClass()");
         pushContext(TraverseContext.TYPE);
-        emitter.emitProvide(typeDefinition);
-        emitter.emitRequire(typeDefinition);
+        //        emitter.emitProvide(typeDefinition);
+        //        emitter.emitRequire(typeDefinition);
 
         // fields, methods, namespaces
         final IDefinitionNode[] members = node.getAllMemberNodes();
@@ -285,11 +287,11 @@ public class ASBlockWalker implements IA
             // TODO (mschmalle) handle null constructor
         }
 
-//        emitter.emitConstructor(currentConstructor);
-//        emitter.emitInherits(typeDefinition, project);
+        //        emitter.emitConstructor(currentConstructor);
+        //        emitter.emitInherits(typeDefinition, project);
 
-        emitter.emitFields(members);
-        emitter.emitMethods(members);
+        emitFields(members);
+        emitMethods(members);
 
         popContext(TraverseContext.TYPE);
         typeDefinition = null;
@@ -334,19 +336,19 @@ public class ASBlockWalker implements IA
     {
         // XXX (mschmalle) visitFunction() refactor, this is a mess
         debug("visitFunction()");
-        
+
         if (SemanticUtils.isMemberDefinition(node.getDefinition()))
         {
             emitter.emitMethod(node);
             return; // TEMP
         }
-        
+
         FunctionNode fn = (FunctionNode) node;
         fn.parseFunctionBody(new ArrayList<ICompilerProblem>());
         if (!inContext(TraverseContext.FUNCTION))
         {
-            emitter.emitJSDoc(node, project, node == currentConstructor,
-                    typeDefinition);
+            //            emitter.emitJSDoc(node, project, node == currentConstructor,
+            //                    typeDefinition);
             String key = "";
             if (node instanceof IGetterNode)
                 key = "get_";
@@ -567,7 +569,7 @@ public class ASBlockWalker implements IA
                 emitter.write(";");
             }
             if (i < len - 1)
-                emitter.writeNewline();
+                emitter.write("\n");
         }
     }
 
@@ -775,7 +777,7 @@ public class ASBlockWalker implements IA
         emitter.write(")");
         emitter.write(" {");
         emitter.indentPush();
-        emitter.writeNewline();
+        emitter.write("\n");
 
         IConditionalNode[] cnodes = getCaseNodes(node);
         ITerminalNode dnode = getDefaultNode(node);
@@ -1225,6 +1227,34 @@ public class ASBlockWalker implements IA
     // 
     //--------------------------------------------------------------------------
 
+    protected void emitFields(IDefinitionNode[] members)
+    {
+        //getWalker().pushContext(TraverseContext.FIELD);
+        for (IDefinitionNode node : members)
+        {
+            if (node instanceof IVariableNode
+                    && !(node instanceof IAccessorNode))
+            {
+                walk(node);
+            }
+        }
+        //getWalker().popContext(TraverseContext.FIELD);
+    }
+
+    protected void emitMethods(IDefinitionNode[] members)
+    {
+        //getWalker().pushContext(TraverseContext.METHOD);
+        for (IDefinitionNode node : members)
+        {
+            if (node instanceof IFunctionNode)
+            {
+                if (node != getCurrentClass().getConstructor())
+                    walk(node);
+            }
+        }
+        //getWalker().popContext(TraverseContext.METHOD);
+    }
+
     private IFunctionNode getConstructor(IDefinitionNode[] members)
     {
         for (IDefinitionNode node : members)

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/JSEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/JSEmitter.java?rev=1423423&r1=1423422&r2=1423423&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/JSEmitter.java
(original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codgen/JSEmitter.java
Tue Dec 18 12:36:11 2012
@@ -26,15 +26,10 @@ import org.apache.flex.compiler.definiti
 import org.apache.flex.compiler.definitions.IPackageDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.internal.as.codegen.ASEmitter;
-import org.apache.flex.compiler.internal.tree.as.FunctionObjectNode;
 import org.apache.flex.compiler.js.IJSEmitter;
 import org.apache.flex.compiler.projects.IASProject;
 import org.apache.flex.compiler.projects.ICompilerProject;
-import org.apache.flex.compiler.tree.as.IAccessorNode;
-import org.apache.flex.compiler.tree.as.IDefinitionNode;
-import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
 import org.apache.flex.compiler.tree.as.IPackageNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
@@ -48,11 +43,6 @@ public class JSEmitter extends ASEmitter
 
     private JSDocEmitter jsdoc;
 
-    public ICompilerProject getProject()
-    {
-        return getVisitor().getProject();
-    }
-
     public JSEmitter(FilterWriter out)
     {
         super(out);
@@ -149,35 +139,7 @@ public class JSEmitter extends ASEmitter
     {
         // for now, we just call back, this is to allow custom handling
         // straight from the emitter
-        getVisitor().visitConstructor(node);
-    }
-
-    public void emitFields(IDefinitionNode[] members)
-    {
-        //getVisitor().pushContext(TraverseContext.FIELD);
-        for (IDefinitionNode node : members)
-        {
-            if (node instanceof IVariableNode
-                    && !(node instanceof IAccessorNode))
-            {
-                getVisitor().walk(node);
-            }
-        }
-        //getVisitor().popContext(TraverseContext.FIELD);
-    }
-
-    public void emitMethods(IDefinitionNode[] members)
-    {
-        //getVisitor().pushContext(TraverseContext.METHOD);
-        for (IDefinitionNode node : members)
-        {
-            if (node instanceof IFunctionNode)
-            {
-                if (node != getVisitor().getCurrentClass().getConstructor())
-                    getVisitor().walk(node);
-            }
-        }
-        //getVisitor().popContext(TraverseContext.METHOD);
+        getWalker().visitConstructor(node);
     }
 
     public void emitField(IVariableNode node)
@@ -197,40 +159,40 @@ public class JSEmitter extends ASEmitter
 
     public void emitVarDeclaration(IVariableNode node)
     {
-        getVisitor().walk(node.getChild(0)); // VariableExpressionNode
-        write(" ");
-        getVisitor().walk(node.getNameExpressionNode());
-        // add :Type
-        if (!javascriptMode)
-        {
-            IExpressionNode tnode = node.getVariableTypeNode();
-            if (tnode instanceof ILanguageIdentifierNode)
-            {
-                ILanguageIdentifierNode lnode = (ILanguageIdentifierNode) tnode;
-                if (lnode.getKind() != ILanguageIdentifierNode.LanguageIdentifierKind.ANY_TYPE)
-                    write(":");
-            }
-            else
-            {
-                write(":");
-            }
-
-            getVisitor().walk(node.getVariableTypeNode());
-        }
-        IExpressionNode vnode = node.getAssignedValueNode();
-        if (vnode != null)
-        {
-            write(" = ");
-            if (vnode instanceof FunctionObjectNode)
-            {
-                //getVisitor().pushContext(TraverseContext.FUNCTION);
-                getVisitor().walk(vnode.getChild(0)); // IFunctionNode
-                //getVisitor().popContext(TraverseContext.FUNCTION);
-            }
-            else
-            {
-                getVisitor().walk(vnode);
-            }
-        }
+        super.emitVarDeclaration(node);
+        //        getWalker().walk(node.getChild(0)); // VariableExpressionNode
+        //        write(" ");
+        //        getWalker().walk(node.getNameExpressionNode());
+        //        // add :Type
+        //        {
+        //            IExpressionNode tnode = node.getVariableTypeNode();
+        //            if (tnode instanceof ILanguageIdentifierNode)
+        //            {
+        //                ILanguageIdentifierNode lnode = (ILanguageIdentifierNode) tnode;
+        //                if (lnode.getKind() != ILanguageIdentifierNode.LanguageIdentifierKind.ANY_TYPE)
+        //                    write(":");
+        //            }
+        //            else
+        //            {
+        //                write(":");
+        //            }
+        //
+        //            getWalker().walk(node.getVariableTypeNode());
+        //        }
+        //        IExpressionNode vnode = node.getAssignedValueNode();
+        //        if (vnode != null)
+        //        {
+        //            write(" = ");
+        //            if (vnode instanceof FunctionObjectNode)
+        //            {
+        //                //getWalker().pushContext(TraverseContext.FUNCTION);
+        //                getWalker().walk(vnode.getChild(0)); // IFunctionNode
+        //                //getWalker().popContext(TraverseContext.FUNCTION);
+        //            }
+        //            else
+        //            {
+        //                getWalker().walk(vnode);
+        //            }
+        //        }
     }
 }



Mime
View raw message