flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [31/42] git commit: [flex-falcon] [refs/heads/develop] - - Refactored interface to emitter. - Refactored var dec to emitter. - Refactored method to emitter.
Date Thu, 04 Jun 2015 06:06:37 GMT
- Refactored interface to emitter.
- Refactored var dec to emitter.
- Refactored method to emitter.


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

Branch: refs/heads/develop
Commit: 7f04314348326e966494548d5120fe5f0cbd48ca
Parents: 02e5a02
Author: Michael Schmalle <mschmalle@apache.org>
Authored: Sun May 31 15:08:04 2015 -0400
Committer: Frédéric THOMAS <webdoublefx@gmail.com>
Committed: Tue Jun 2 13:41:21 2015 +0100

----------------------------------------------------------------------
 .../compiler/internal/codegen/as/ASEmitter.java |   4 +-
 .../internal/codegen/js/JSSessionModel.java     |   7 ++
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 104 +++++++++++------
 .../internal/codegen/js/goog/JSGoogEmitter.java |  71 ++++++------
 .../codegen/js/jx/InterfaceEmitter.java         | 112 ++++++++++++++++++
 .../internal/codegen/js/jx/MethodEmitter.java   | 114 +++++++++++++++++++
 .../codegen/js/jx/VarDeclarationEmitter.java    |  88 ++++++++++++++
 .../internal/codegen/js/utils/EmitterUtils.java |   6 +
 .../codegen/js/vf2js/JSVF2JSEmitter.java        |   4 +-
 9 files changed, 437 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index 7f5f46f..d16081d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -699,7 +699,7 @@ public class ASEmitter implements IASEmitter, IEmitter
         }
     }
 
-    protected void emitMemberKeyword(IDefinitionNode node)
+    public void emitMemberKeyword(IDefinitionNode node)
     {
         if (node instanceof IFunctionNode)
         {
@@ -717,7 +717,7 @@ public class ASEmitter implements IASEmitter, IEmitter
         getWalker().walk(node.getNameExpressionNode());
     }
 
-    protected void emitDeclarationName(IDefinitionNode node)
+    public void emitDeclarationName(IDefinitionNode node)
     {
         getWalker().walk(node.getNameExpressionNode());
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
index 48079fa..8bb30b4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
@@ -46,6 +46,8 @@ public class JSSessionModel
 
     private HashMap<String, PropertyNodes> propertyMap = new HashMap<String, PropertyNodes>();
 
+    private List<String> interfacePropertyMap = new ArrayList<String>();
+
     private HashMap<String, PropertyNodes> staticPropertyMap = new HashMap<String,
PropertyNodes>();
 
     private ArrayList<String> bindableVars = new ArrayList<String>();
@@ -67,6 +69,11 @@ public class JSSessionModel
         return propertyMap;
     }
 
+    public List<String> getInterfacePropertyMap()
+    {
+        return interfacePropertyMap;
+    }
+
     public HashMap<String, PropertyNodes> getStaticPropertyMap()
     {
         return staticPropertyMap;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/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 d9b1c4e..4463d0a 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
@@ -41,10 +41,13 @@ import org.apache.flex.compiler.internal.codegen.js.jx.FieldEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.ForEachEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.FunctionCallEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.IdentifierEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.InterfaceEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.MemberAccessEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.MethodEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.PackageFooterEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.PackageHeaderEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.SuperCallEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.VarDeclarationEmitter;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
 import org.apache.flex.compiler.internal.tree.as.SetterNode;
@@ -60,6 +63,7 @@ import org.apache.flex.compiler.tree.as.IFunctionCallNode;
 import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IGetterNode;
 import org.apache.flex.compiler.tree.as.IIdentifierNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
 import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
@@ -85,8 +89,13 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     private BindableEmitter bindableEmitter;
 
     private ClassEmitter classEmitter;
+    private InterfaceEmitter interfaceEmitter;
+
     private FieldEmitter fieldEmitter;
+    private VarDeclarationEmitter varDeclarationEmitter;
     private AccessorEmitter accessorEmitter;
+    private MethodEmitter methodEmitter;
+
     private FunctionCallEmitter functionCallEmitter;
     private SuperCallEmitter superCallEmitter;
     private ForEachEmitter forEachEmitter;
@@ -129,8 +138,13 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         bindableEmitter = new BindableEmitter(this);
 
         classEmitter = new ClassEmitter(this);
+        interfaceEmitter = new InterfaceEmitter(this);
+
         fieldEmitter = new FieldEmitter(this);
+        varDeclarationEmitter = new VarDeclarationEmitter(this);
         accessorEmitter = new AccessorEmitter(this);
+        methodEmitter = new MethodEmitter(this);
+
         functionCallEmitter = new FunctionCallEmitter(this);
         superCallEmitter = new SuperCallEmitter(this);
         forEachEmitter = new ForEachEmitter(this);
@@ -156,7 +170,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     }
 
     @Override
-    protected void emitMemberName(IDefinitionNode node)
+    public void emitMemberName(IDefinitionNode node)
     {
         write(node.getName());
     }
@@ -170,6 +184,32 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         return name;
     }
 
+    //--------------------------------------------------------------------------
+    // Package Level
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitPackageHeader(IPackageDefinition definition)
+    {
+        packageHeaderEmitter.emit(definition);
+    }
+
+    @Override
+    public void emitPackageHeaderContents(IPackageDefinition definition)
+    {
+        packageHeaderEmitter.emitContents(definition);
+    }
+
+    @Override
+    public void emitPackageFooter(IPackageDefinition definition)
+    {
+        packageFooterEmitter.emit(definition);
+    }
+
+    //--------------------------------------------------------------------------
+    // Class
+    //--------------------------------------------------------------------------
+
     @Override
     public void emitClass(IClassNode node)
     {
@@ -177,18 +217,48 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     }
 
     @Override
+    public void emitInterface(IInterfaceNode node)
+    {
+        interfaceEmitter.emit(node);
+    }
+
+    @Override
     public void emitField(IVariableNode node)
     {
         fieldEmitter.emit(node);
     }
 
     @Override
+    public void emitVarDeclaration(IVariableNode node)
+    {
+        varDeclarationEmitter.emit(node);
+    }
+
+    @Override
     public void emitAccessors(IAccessorNode node)
     {
         accessorEmitter.emit(node);
     }
 
     @Override
+    public void emitGetAccessor(IGetterNode node)
+    {
+        accessorEmitter.emitGet(node);
+    }
+
+    @Override
+    public void emitSetAccessor(ISetterNode node)
+    {
+        accessorEmitter.emitSet(node);
+    }
+
+    @Override
+    public void emitMethod(IFunctionNode node)
+    {
+        methodEmitter.emit(node);
+    }
+
+    @Override
     public void emitFunctionCall(IFunctionCallNode node)
     {
         functionCallEmitter.emit(node);
@@ -208,7 +278,6 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     @Override
     public void emitIdentifier(IIdentifierNode node)
     {
-        // TODO (mschmalle) remove when project field is removed
         identifierEmitter.emit(node);
     }
 
@@ -235,23 +304,10 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     @Override
     public void emitMemberAccessExpression(IMemberAccessExpressionNode node)
     {
-        // TODO (mschmalle) remove when project field is removed
         memberAccessEmitter.emit(node);
     }
 
     @Override
-    public void emitGetAccessor(IGetterNode node)
-    {
-        accessorEmitter.emitGet(node);
-    }
-
-    @Override
-    public void emitSetAccessor(ISetterNode node)
-    {
-        accessorEmitter.emitSet(node);
-    }
-
-    @Override
     protected void emitObjectDefineProperty(IAccessorNode node)
     {
         //TODO: ajh  is this method needed anymore?
@@ -380,24 +436,6 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     }
 
     @Override
-    public void emitPackageHeader(IPackageDefinition definition)
-    {
-        packageHeaderEmitter.emit(definition);
-    }
-
-    @Override
-    public void emitPackageHeaderContents(IPackageDefinition definition)
-    {
-        packageHeaderEmitter.emitContents(definition);
-    }
-
-    @Override
-    public void emitPackageFooter(IPackageDefinition definition)
-    {
-        packageFooterEmitter.emit(definition);
-    }
-
-    @Override
     public void emitForEachLoop(IForLoopNode node)
     {
         forEachEmitter.emit(node);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
index 7dd7cdb..40453ec 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
@@ -95,16 +95,17 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         return docEmitter;
     }
 
-    //--------------------------------------------------------------------------
-    // 
-    //--------------------------------------------------------------------------
-
     @Override
     public String formatQualifiedName(String name)
     {
         return name;
     }
 
+    //--------------------------------------------------------------------------
+    // Package Level
+    //--------------------------------------------------------------------------
+
+    // XXX DEAD
     @Override
     public void emitPackageHeader(IPackageDefinition definition)
     {
@@ -124,6 +125,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         writeNewline();
     }
 
+    // XXX DEAD
     @Override
     public void emitPackageHeaderContents(IPackageDefinition definition)
     {
@@ -160,6 +162,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX DEAD
     @Override
     public void emitPackageContents(IPackageDefinition definition)
     {
@@ -175,15 +178,17 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX DEAD
     @Override
     public void emitPackageFooter(IPackageDefinition definition)
     {
     }
 
     //--------------------------------------------------------------------------
-    // 
+    // Class
     //--------------------------------------------------------------------------
 
+    // XXX DEAD
     @Override
     public void emitClass(IClassNode node)
     {
@@ -253,6 +258,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX Dead [InterfaceEmitter]
     @Override
     public void emitInterface(IInterfaceNode node)
     {
@@ -315,6 +321,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX Dead
     @Override
     public void emitField(IVariableNode node)
     {
@@ -364,6 +371,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX Dead [VarDeclarationEmitter]
     @Override
     public void emitVarDeclaration(IVariableNode node)
     {
@@ -406,19 +414,8 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
-    @Override
-    public void emitGetAccessor(IGetterNode node)
-    {
-        emitObjectDefineProperty(node);
-    }
-
-    @Override
-    public void emitSetAccessor(ISetterNode node)
-    {
-        emitObjectDefineProperty(node);
-    }
-
-    protected void emitAccessors(IAccessorNode node)
+    // XXX Dead 
+    public void emitAccessors(IAccessorNode node)
     {
         String qname = node.getQualifiedName();
         if (!propertyNames.contains(qname))
@@ -441,6 +438,21 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX Dead 
+    @Override
+    public void emitGetAccessor(IGetterNode node)
+    {
+        emitObjectDefineProperty(node);
+    }
+
+    // XXX Dead 
+    @Override
+    public void emitSetAccessor(ISetterNode node)
+    {
+        emitObjectDefineProperty(node);
+    }
+
+    // XXX Dead [MethodEmitter]
     @Override
     public void emitMethod(IFunctionNode node)
     {
@@ -453,7 +465,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
 
         boolean isConstructor = node.isConstructor();
 
-        String qname = getTypeDefinition(node).getQualifiedName();
+        String qname = EmitterUtils.getTypeDefinition(node).getQualifiedName();
         if (qname != null && !qname.equals(""))
         {
             write(formatQualifiedName(qname));
@@ -499,13 +511,14 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
             write(ASEmitterTokens.PAREN_OPEN);
             write(formatQualifiedName(qname));
             writeToken(ASEmitterTokens.COMMA);
-            String sname = getSuperClassDefinition(node, project)
+            String sname = EmitterUtils.getSuperClassDefinition(node, project)
                     .getQualifiedName();
             write(formatQualifiedName(sname));
             write(ASEmitterTokens.PAREN_CLOSE);
         }
     }
 
+    // XXX Dead
     @Override
     public void emitFunctionCall(IFunctionCallNode node)
     {
@@ -534,6 +547,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    // XXX Dead
     @Override
     public void emitIdentifier(IIdentifierNode node)
     {
@@ -836,7 +850,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
     }
 
     @Override
-    protected void emitAssignedValue(IExpressionNode node)
+    public void emitAssignedValue(IExpressionNode node)
     {
         if (node != null)
         {
@@ -895,21 +909,6 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         super(out);
     }
 
-    private static ITypeDefinition getTypeDefinition(IDefinitionNode node)
-    {
-        ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
-        return (ITypeDefinition) tnode.getDefinition();
-    }
-
-    private static IClassDefinition getSuperClassDefinition(
-            IDefinitionNode node, ICompilerProject project)
-    {
-        IClassDefinition parent = (IClassDefinition) node.getDefinition()
-                .getParent();
-        IClassDefinition superClass = parent.resolveBaseClass(project);
-        return superClass;
-    }
-
     protected void emitObjectDefineProperty(IAccessorNode node)
     {
         /*

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/InterfaceEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/InterfaceEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/InterfaceEmitter.java
new file mode 100644
index 0000000..d12a3ba
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/InterfaceEmitter.java
@@ -0,0 +1,112 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+
+public class InterfaceEmitter extends JSSubEmitter implements
+        ISubEmitter<IInterfaceNode>
+{
+
+    public InterfaceEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IInterfaceNode node)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        ICompilerProject project = getWalker().getProject();
+
+        fjs.getDocEmitter().emitInterfaceDoc(node, project);
+
+        String qname = node.getQualifiedName();
+        if (qname != null && !qname.equals(""))
+        {
+            write(getEmitter().formatQualifiedName(qname));
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            write(ASEmitterTokens.FUNCTION);
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(ASEmitterTokens.PAREN_CLOSE);
+            write(ASEmitterTokens.SPACE);
+            write(ASEmitterTokens.BLOCK_OPEN);
+            writeNewline();
+            write(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.SEMICOLON);
+        }
+
+        final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
+        for (IDefinitionNode mnode : members)
+        {
+            boolean isAccessor = mnode.getNodeID() == ASTNodeID.GetterID
+                    || mnode.getNodeID() == ASTNodeID.SetterID;
+
+            if (!isAccessor
+                    || !getModel().getInterfacePropertyMap().contains(qname))
+            {
+                writeNewline();
+
+                write(getEmitter().formatQualifiedName(qname));
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSEmitterTokens.PROTOTYPE);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(mnode.getQualifiedName());
+
+                if (isAccessor
+                        && !getModel().getInterfacePropertyMap()
+                                .contains(qname))
+                {
+                    getModel().getInterfacePropertyMap().add(qname);
+                }
+                else
+                {
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(ASEmitterTokens.FUNCTION);
+
+                    fjs.emitParameters(((IFunctionNode) mnode)
+                            .getParameterNodes());
+
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.BLOCK_OPEN);
+                    writeNewline();
+                    write(ASEmitterTokens.BLOCK_CLOSE);
+                }
+
+                write(ASEmitterTokens.SEMICOLON);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java
new file mode 100644
index 0000000..5caa357
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java
@@ -0,0 +1,114 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import java.util.ArrayList;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.common.ASModifier;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.internal.tree.as.FunctionNode;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+
+public class MethodEmitter extends JSSubEmitter implements
+        ISubEmitter<IFunctionNode>
+{
+    public MethodEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IFunctionNode node)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        FunctionNode fn = (FunctionNode) node;
+        fn.parseFunctionBody(new ArrayList<ICompilerProblem>());
+
+        ICompilerProject project = getWalker().getProject();
+
+        fjs.getDocEmitter().emitMethodDoc(node, project);
+
+        boolean isConstructor = node.isConstructor();
+
+        String qname = EmitterUtils.getTypeDefinition(node).getQualifiedName();
+        if (qname != null && !qname.equals(""))
+        {
+            write(fjs.formatQualifiedName(qname));
+            if (!isConstructor)
+            {
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                if (!fn.hasModifier(ASModifier.STATIC))
+                {
+                    write(JSEmitterTokens.PROTOTYPE);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                }
+            }
+        }
+
+        if (!isConstructor)
+            fjs.emitMemberName(node);
+
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.EQUAL);
+        write(ASEmitterTokens.FUNCTION);
+
+        fjs.emitParameters(node.getParameterNodes());
+
+        boolean hasSuperClass = EmitterUtils.hasSuperClass(project, node);
+
+        if (isConstructor && node.getScopedNode().getChildCount() == 0)
+        {
+            write(ASEmitterTokens.SPACE);
+            write(ASEmitterTokens.BLOCK_OPEN);
+            if (hasSuperClass)
+                fjs.emitSuperCall(node, JSSessionModel.CONSTRUCTOR_EMPTY);
+            writeNewline();
+            write(ASEmitterTokens.BLOCK_CLOSE);
+        }
+
+        if (!isConstructor || node.getScopedNode().getChildCount() > 0)
+            fjs.emitMethodScope(node.getScopedNode());
+
+        if (isConstructor && hasSuperClass)
+        {
+            writeNewline(ASEmitterTokens.SEMICOLON);
+            write(JSGoogEmitterTokens.GOOG_INHERITS);
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(fjs.formatQualifiedName(qname));
+            writeToken(ASEmitterTokens.COMMA);
+            String sname = EmitterUtils.getSuperClassDefinition(node, project)
+                    .getQualifiedName();
+            write(fjs.formatQualifiedName(sname));
+            write(ASEmitterTokens.PAREN_CLOSE);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
new file mode 100644
index 0000000..8b57ea9
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
@@ -0,0 +1,88 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IEmbedNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+
+public class VarDeclarationEmitter extends JSSubEmitter implements
+        ISubEmitter<IVariableNode>
+{
+
+    public VarDeclarationEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IVariableNode node)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        if (!(node instanceof ChainedVariableNode) && !node.isConst())
+        {
+            fjs.emitMemberKeyword(node);
+        }
+
+        IExpressionNode avnode = node.getAssignedValueNode();
+        if (avnode != null)
+        {
+            IDefinition def = avnode.resolveType(getWalker().getProject());
+
+            String opcode = avnode.getNodeID().getParaphrase();
+            if (opcode != "AnonymousFunction")
+                fjs.getDocEmitter().emitVarDoc(node, def);
+        }
+        else
+        {
+            fjs.getDocEmitter().emitVarDoc(node, null);
+        }
+
+        fjs.emitDeclarationName(node);
+        if (!(avnode instanceof IEmbedNode))
+            fjs.emitAssignedValue(avnode);
+
+        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)
+                {
+                    writeToken(ASEmitterTokens.COMMA);
+                    fjs.emitVarDeclaration((IVariableNode) child);
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
index 4f8482f..8a97565 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
@@ -83,6 +83,12 @@ public class EmitterUtils
         return null;
     }
 
+    public static ITypeDefinition getTypeDefinition(IDefinitionNode node)
+    {
+        ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
+        return (ITypeDefinition) tnode.getDefinition();
+    }
+
     public static boolean isSameClass(IDefinition pdef, IDefinition thisClass,
             ICompilerProject project)
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7f043143/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
index b436b8a..a25f98e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
@@ -369,7 +369,7 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
     }
 
     @Override
-    protected void emitMemberKeyword(IDefinitionNode node)
+    public void emitMemberKeyword(IDefinitionNode node)
     {
         if (node instanceof IFunctionNode)
         {
@@ -496,7 +496,7 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
     }
 
     @Override
-    protected void emitAccessors(IAccessorNode node)
+    public void emitAccessors(IAccessorNode node)
     {
         if (node.getNodeID() == ASTNodeID.GetterID)
         {


Mime
View raw message