You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/10/31 09:28:23 UTC

[01/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Update and add various VF2JS pathway files

Repository: flex-falcon
Updated Branches:
  refs/heads/feature/flexmojos-tests 7ee797340 -> 142af1891


Update and add various VF2JS pathway files

In order to work on VF2JS specific code generation, we need to make a clean cut from the FlexJS code generation pathways.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: b1980b93e859a0fb3542cc480bcc359959b9c631
Parents: 26117b1
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 19:41:42 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/mxml/vf2js/MXMLVF2JSEmitter.java    |  3 +-
 .../internal/driver/js/vf2js/VF2JSBackend.java  | 55 ++++++++++++++++++++
 .../driver/mxml/vf2js/MXMLVF2JSBackend.java     |  8 +--
 3 files changed, 61 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b1980b93/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
index a8ad471..b0dcc61 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
@@ -46,6 +46,7 @@ import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLEmitter;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLEventSpecifier;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
@@ -146,7 +147,7 @@ public class MXMLVF2JSEmitter extends MXMLEmitter implements
         IClassDefinition cdef = node.getClassDefinition();
         IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                 .getASEmitter();
-        ((JSFlexJSEmitter) asEmitter).thisClass = cdef;
+        ((JSVF2JSEmitter) asEmitter).thisClass = cdef;
 
         // visit tags
         final int len = node.getChildCount();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b1980b93/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
new file mode 100644
index 0000000..d0030fe
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
@@ -0,0 +1,55 @@
+/*
+ *
+ *  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.driver.js.vf2js;
+
+import java.io.FilterWriter;
+
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+
+/**
+ * @author Erik de Bruin
+ */
+public class VF2JSBackend extends GoogBackend
+{
+
+    @Override
+    public IJSEmitter createEmitter(FilterWriter out)
+    {
+        IJSEmitter emitter = new JSVF2JSEmitter(out);
+        emitter.setDocEmitter(createDocEmitter(emitter));
+        return emitter;
+    }
+    
+    @Override
+    public JSTarget createTarget(IASProject project, ITargetSettings settings,
+            ITargetProgressMonitor monitor)
+    {
+        return new FlexJSTarget(project, settings, monitor);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b1980b93/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
index 3f164d9..397d977 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
@@ -29,8 +29,8 @@ import org.apache.flex.compiler.codegen.js.IJSWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
@@ -93,13 +93,13 @@ public class MXMLVF2JSBackend extends MXMLBackend
     @Override
     public IDocEmitter createDocEmitter(IASEmitter emitter)
     {
-        return new JSGoogDocEmitter((IJSEmitter) emitter);
+        return new JSVF2JSDocEmitter((IJSEmitter) emitter);
     }
 
     @Override
     public IJSEmitter createEmitter(FilterWriter out)
     {
-        IJSEmitter emitter = new JSFlexJSEmitter(out);
+        IJSEmitter emitter = new JSVF2JSEmitter(out);
         emitter.setDocEmitter(createDocEmitter(emitter));
         return emitter;
     }


[14/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Various E4X "bypass" measures ...

Posted by cd...@apache.org.
Various E4X "bypass" measures ...

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 7822c332c3d91a227b6120ffab226a048da073b5
Parents: 68a7c9e
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:20:30 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../flex/compiler/codegen/as/IASEmitter.java    |  2 +
 .../internal/codegen/as/ASBlockWalker.java      |  7 +++
 .../compiler/internal/codegen/as/ASEmitter.java |  4 ++
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 45 +++++++++++++++++++-
 .../internal/visitor/as/ASNodeSwitch.java       |  4 ++
 .../compiler/visitor/as/IASBlockVisitor.java    |  2 +
 6 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
index 9bf4aa5..e1c0e01 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
@@ -354,4 +354,6 @@ public interface IASEmitter extends IEmitter
 
     void emitMetaTag(IMetaTagNode node);
 
+    void emitE4XFilter(IMemberAccessExpressionNode node);
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
index d8b68f6..069e934 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
@@ -556,6 +556,13 @@ public class ASBlockWalker implements IASBlockVisitor, IASBlockWalker
     }
 
     @Override
+    public void visitE4XFilter(IMemberAccessExpressionNode node)
+    {
+        debug("visitE4XFilter()");
+        emitter.emitE4XFilter(node);
+    }
+    
+    @Override
     public void visitReturn(IReturnNode node)
     {
         debug("visitReturn()");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/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 379e86e..cd08e22 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
@@ -1448,6 +1448,10 @@ public class ASEmitter implements IASEmitter, IEmitter
     {
     }
 
+    public void emitE4XFilter(IMemberAccessExpressionNode node)
+    {
+    }
+
     public String stringifyNode(IASNode node)
     {
         setBufferWrite(true);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/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 454bae6..49e8192 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
@@ -1100,6 +1100,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     public void emitMemberAccessExpression(IMemberAccessExpressionNode node)
     {
         IASNode leftNode = node.getLeftOperandNode();
+        IASNode rightNode = node.getRightOperandNode();
 
         if (project == null)
             project = getWalker().getProject();
@@ -1109,12 +1110,41 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         if (def != null && def.isStatic())
             isStatic = true;
 
+        boolean continueWalk = true;
         if (!isStatic)
         {
             if (!(leftNode instanceof ILanguageIdentifierNode && ((ILanguageIdentifierNode) leftNode)
                         .getKind() == ILanguageIdentifierNode.LanguageIdentifierKind.THIS))
             {
-                if (leftNode.getNodeID() != ASTNodeID.SuperID)
+            	if (rightNode instanceof UnaryOperatorAtNode)
+                {
+            		// ToDo (erikdebruin): properly handle E4X
+            		
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                    getWalker().walk(node.getLeftOperandNode());
+                    write(ASEmitterTokens.SQUARE_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write("E4XOperator");
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.SQUARE_CLOSE);
+                    continueWalk = false;
+                }
+            	else if (node.getNodeID() == ASTNodeID.Op_DescendantsID)
+            	{
+            		// ToDo (erikdebruin): properly handle E4X
+            		
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                    getWalker().walk(node.getLeftOperandNode());
+                    write(ASEmitterTokens.SQUARE_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write("E4XSelector");
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.SQUARE_CLOSE);
+                    continueWalk = false;
+            	}
+            	else if (leftNode.getNodeID() != ASTNodeID.SuperID)
                 {
                     getWalker().walk(node.getLeftOperandNode());
                     write(node.getOperator().getOperatorText());
@@ -1128,7 +1158,8 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         
         }
         
-        getWalker().walk(node.getRightOperandNode());
+        if (continueWalk)
+        	getWalker().walk(node.getRightOperandNode());
     }
 
     private static ITypeDefinition getTypeDefinition(IDefinitionNode node)
@@ -1587,4 +1618,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
             write(s);
         }
     }
+    
+    @Override
+    public void emitE4XFilter(IMemberAccessExpressionNode node)
+    {
+    	// ToDo (erikdebruin): implement E4X replacement !?!
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write("E4XFilter");
+        write(ASEmitterTokens.SINGLE_QUOTE);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/compiler.jx/src/org/apache/flex/compiler/internal/visitor/as/ASNodeSwitch.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/visitor/as/ASNodeSwitch.java b/compiler.jx/src/org/apache/flex/compiler/internal/visitor/as/ASNodeSwitch.java
index 04b98ef..a64b599 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/visitor/as/ASNodeSwitch.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/visitor/as/ASNodeSwitch.java
@@ -116,6 +116,10 @@ public class ASNodeSwitch implements IASNodeStrategy
             // ToDo (erikdebruin): implement handler
             return;
 
+        case E4XFilterID:
+            visitor.visitE4XFilter((IMemberAccessExpressionNode) node);
+            return;
+
         case FileID:
             visitor.visitFile((IFileNode) node);
             return;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7822c332/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockVisitor.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockVisitor.java b/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockVisitor.java
index 9510ef8..0376dba 100644
--- a/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockVisitor.java
+++ b/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockVisitor.java
@@ -218,4 +218,6 @@ public interface IASBlockVisitor extends IBlockVisitor
 
     void visitEmbed(IEmbedNode node);
 
+    void visitE4XFilter(IMemberAccessExpressionNode node);
+
 }


[07/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Initial VF2JS (full SDK) Publisher

Posted by cd...@apache.org.
Initial VF2JS (full SDK) Publisher

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: fff03fa013a24d39e4d220bc6f5b6621bd318a39
Parents: 7822c33
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:26:12 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/mxml/vf2js/MXMLVF2JSPublisher.java  | 68 +++++++++++++++++---
 1 file changed, 59 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fff03fa0/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
index 4a0f6cc..5299df1 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
@@ -134,7 +134,7 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
     public boolean publish(ProblemQuery problems) throws IOException
     {
         boolean ok = true;
-        boolean subsetGoog = true;
+        boolean subsetGoog = false;
         
         final String intermediateDirPath = outputFolder.getPath();
         final File intermediateDir = new File(intermediateDirPath);
@@ -295,6 +295,11 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
 
         File srcDeps = new File(depsSrcFilePath);
 
+        // ToDo (erikdebruin): yeah, right, hard coded the path, nice!
+        File sdkDepsFile = new File("/Users/erik/Documents/ApacheFlex/git/flex-asjs/vf2js/frameworks/js/sdk-deps.js");
+        if (sdkDepsFile.exists())
+        	FileUtils.copyFile(sdkDepsFile, new File(intermediateDirPath + File.separator + "sdk-deps.js"));
+        
         writeHTML("intermediate", projectName, intermediateDirPath, gdw.additionalHTML);
         writeHTML("release", projectName, releaseDirPath, gdw.additionalHTML);
         writeCSS(projectName, intermediateDirPath);
@@ -465,10 +470,12 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
         if (type == "intermediate")
         {
             htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
+            htmlFile.append("\t<script type=\"text/javascript\" src=\"./sdk-deps.js\"></script>\n");
             htmlFile.append("\t<script type=\"text/javascript\">\n");
-            htmlFile.append("\t\tgoog.require(\"");
-            htmlFile.append(projectName);
-            htmlFile.append("\");\n");
+            htmlFile.append("\t\tgoog.require(");
+            htmlFile.append("'mx.managers.SystemManager'");
+            //htmlFile.append(projectName);
+            htmlFile.append(");\n");
             htmlFile.append("\t</script>\n");
         }
         else
@@ -479,12 +486,55 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
         }
 
         htmlFile.append("</head>\n");
-        htmlFile.append("<body>\n");
+        htmlFile.append("<body onload=\"init();\">\n");
         htmlFile.append("\t<script type=\"text/javascript\">\n");
-        htmlFile.append("\t\tnew ");
-        htmlFile.append(projectName);
-        htmlFile.append("()");
-        htmlFile.append(".start();\n");
+        htmlFile.append("\t\t'use strict';\n");
+        htmlFile.append("\t\t\n");
+        htmlFile.append("\t\tfunction init() {\n");
+        htmlFile.append("\t\t\tvar /** @type {flash.display.LoaderInfo} */ loaderInfo,\n");
+        htmlFile.append("\t\t\t    /** @type {flash.display.Stage} */ stage,\n");
+        htmlFile.append("\t\t\t    /** @type {mx.managers.SystemManager} */ systemManager;\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\tstage = new flash.display.Stage();\n");
+        htmlFile.append("\t\t\twindow['apache-flex_stage'] = stage;\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'] = new flash.display.LoaderInfo();\n");
+        htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'].get_parameters = function () {\n");
+        htmlFile.append("\t\t\t\tvar /** @type {Object} */ infoObject;\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\t	infoObject = {};\n");
+        htmlFile.append("\t\t\t	infoObject[\"resourceModuleURLs\"] = '';\n");
+        htmlFile.append("\t\t\t	\n");
+        htmlFile.append("\t\t\t	return infoObject;\n");
+        htmlFile.append("\t\t\t}\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\tsystemManager = new mx.managers.SystemManager();\n");
+        htmlFile.append("\t\t\tsystemManager.info = function () {\n");
+        htmlFile.append("\t\t\t\tvar /** @type {Object} */ infoObject;\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\t	infoObject = {};\n");
+        htmlFile.append("\t\t\t	infoObject[\"applicationDPI\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"backgroundAlpha\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"backgroundColor\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"backgroundImage\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"backgroundSize\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"cdRsls\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"currentDomain\"] = new flash.system.ApplicationDomain();\n");
+        htmlFile.append("\t\t\t	infoObject[\"fonts\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"frames\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"mainClassName\"] = '" + projectName + "';\n");
+        htmlFile.append("\t\t\t	infoObject[\"mixins\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"preloader\"] = new mx.preloaders.DownloadProgressBar();\n");
+        htmlFile.append("\t\t\t	infoObject[\"rsls\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"runtimeDPIProvider\"] = new mx.core.RuntimeDPIProvider();\n");
+        htmlFile.append("\t\t\t	infoObject[\"useNativeDragManager\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"usePreloader\"] = false; // we're not showing a preloader in JS\n");
+        htmlFile.append("\t\t\t	\n");
+        htmlFile.append("\t\t\t	return infoObject;\n");
+        htmlFile.append("\t\t\t}\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'].dispatchEvent(new flash.events.Event(flash.events.Event.INIT));\n");
+        htmlFile.append("\t\t}\n");
         htmlFile.append("\t</script>\n");
         htmlFile.append("</body>\n");
         htmlFile.append("</html>");


[12/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Suppress 'unused' warnings for a while.

Posted by cd...@apache.org.
Suppress 'unused' warnings for a while.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 1dca70018463352ec63d4394ddd1854de852960a
Parents: 0452743
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 16:52:28 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1dca7001/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
index 369e218..8fef083 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
@@ -111,6 +111,7 @@ public class MXMLVF2JSDescriptorSpecifier extends MXMLNodeSpecifier
     //    outputEventSpecifier
     //---------------------------------
 
+	@SuppressWarnings("unused")
     private void outputEventSpecifier(boolean writeNewline)
     {
         // number of events
@@ -229,6 +230,7 @@ public class MXMLVF2JSDescriptorSpecifier extends MXMLNodeSpecifier
     //    outputStyleSpecifier
     //---------------------------------
 
+	@SuppressWarnings("unused")
     private void outputStyleSpecifier(boolean writeNewline)
     {
         // TODO (erikdebruin) not yet implemented in FlexJS
@@ -324,6 +326,7 @@ public class MXMLVF2JSDescriptorSpecifier extends MXMLNodeSpecifier
         return sb.toString();
     }
     
+	@SuppressWarnings("unused")
     private void outputChildren(MXMLVF2JSDescriptorSpecifier children, boolean writeNewline)
     {
         write(ASEmitterTokens.SQUARE_OPEN.getToken());


[21/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Making sure we notice if stuff broke when running from ant (i.e. on the build VM)

Posted by cd...@apache.org.
Making sure we notice if stuff broke when running from ant (i.e. on the build VM)

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 200e2a12518845e69514aa06cb1865e8a9b0c33b
Parents: 6961f0f
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Fri Oct 24 12:11:55 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Fri Oct 24 12:11:55 2014 +0200

----------------------------------------------------------------------
 compiler.tests/build.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/200e2a12/compiler.tests/build.xml
----------------------------------------------------------------------
diff --git a/compiler.tests/build.xml b/compiler.tests/build.xml
index 6801404..96b384f 100644
--- a/compiler.tests/build.xml
+++ b/compiler.tests/build.xml
@@ -96,7 +96,7 @@
         <junit dir="${compiler.tests}"
                fork="yes" forkMode="perBatch" maxmemory="${maxmem}m" timeout="${test.timeout}"
                printsummary="true" showoutput="true"
-               haltonerror="false" haltonfailure="false"
+               haltonerror="true" haltonfailure="true"
                failureproperty="tests.unit.failed">
             <classpath>
                 <pathelement location="${compiler.tests}/classes"/>
@@ -134,7 +134,7 @@
         <junit dir="${compiler.tests}"
                fork="yes" forkMode="perBatch" maxmemory="${maxmem}m" timeout="${test.timeout}"
                printsummary="true" showoutput="true"
-               haltonerror="false" haltonfailure="false"
+               haltonerror="true" haltonfailure="true"
                failureproperty="tests.unit.failed">
             <classpath>
                 <pathelement location="${compiler.tests}/classes"/>
@@ -172,7 +172,7 @@
         <junit dir="${compiler.tests}"
                fork="yes" forkMode="perBatch" maxmemory="${maxmem}m" timeout="${test.timeout}"
                printsummary="true" showoutput="true"
-               haltonerror="false" haltonfailure="false"
+               haltonerror="true" haltonfailure="true"
                failureproperty="tests.functional.failed">
             <classpath>
                 <pathelement location="${compiler.tests}/classes"/>


[16/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Avoid an error when encountering an Embed node

Posted by cd...@apache.org.
Avoid an error when encountering an Embed node

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 601605b9a9c9580a5f276854e5d96d21ab2c1e20
Parents: fff03fa
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:27:37 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/601605b9/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 94e971a..1eb08a8 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
@@ -55,6 +55,7 @@ import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IClassNode;
 import org.apache.flex.compiler.tree.as.IContainerNode;
 import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IEmbedNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.as.IForLoopNode;
 import org.apache.flex.compiler.tree.as.IFunctionCallNode;
@@ -385,7 +386,8 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         }
 
         emitDeclarationName(node);
-        emitAssignedValue(avnode);
+        if (!(avnode instanceof IEmbedNode))
+        	emitAssignedValue(avnode);
 
         if (!(node instanceof ChainedVariableNode))
         {


[04/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Added type for new emitter class

Posted by cd...@apache.org.
Added type for new emitter class

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 4d778fdda9c33a959d8c639579a11fe38c7804c1
Parents: 76d2716
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 14:28:12 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/js/vf2js/IJSVF2JSEmitter.java       | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4d778fdd/compiler.jx/src/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
new file mode 100644
index 0000000..cd4cacd
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
@@ -0,0 +1,30 @@
+/*
+ *
+ *  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.codegen.js.vf2js;
+
+import org.apache.flex.compiler.codegen.js.goog.IJSGoogEmitter;
+
+/**
+ * @author Erik de Bruin
+ */
+public interface IJSVF2JSEmitter extends IJSGoogEmitter
+{
+
+}


[05/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Add option to exclude ASDoc from compilation

Posted by cd...@apache.org.
Add option to exclude ASDoc from compilation

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: dcb5c7066ed3393b651e48df40253ea04db6a583
Parents: c932239
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:13:56 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   |  7 ++++++-
 .../codegen/js/flexjs/JSFlexJSDocEmitter.java   | 15 +++++++-------
 .../driver/js/goog/JSGoogConfiguration.java     | 21 ++++++++++++++++++++
 3 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dcb5c706/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index bb581ac..81f7f0d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -56,6 +56,7 @@ import org.apache.flex.compiler.internal.config.FlashBuilderConfigurator;
 import org.apache.flex.compiler.internal.driver.as.ASBackend;
 import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
 import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
 import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
@@ -140,7 +141,8 @@ public class MXMLJSC
         final int code;
     }
 
-    protected static JSOutputType jsOutputType;
+    public static JSOutputType jsOutputType;
+    public static boolean keepASDoc;
 
     /**
      * Java program entry point.
@@ -290,6 +292,9 @@ public class MXMLJSC
 
             final boolean continueCompilation = configure(adjustedArgs);
 
+            // ToDo (erikdebruin): use JSSharedData for globals ...
+            keepASDoc = ((JSGoogConfiguration) config).getKeepASDoc();
+            
             if (outProblems != null && !config.isVerbose())
                 JSSharedData.STDOUT = JSSharedData.STDERR = null;
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dcb5c706/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
index 480583e..6e3524b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
@@ -20,6 +20,7 @@
 package org.apache.flex.compiler.internal.codegen.js.flexjs;
 
 import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.clients.MXMLJSC;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.DependencyType;
@@ -61,7 +62,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
 
             if (node.isConstructor())
             {
-                if (asDoc != null)
+                if (asDoc != null && MXMLJSC.keepASDoc)
                     write(asDoc.commentNoEnd());
                 else
                     begin();
@@ -96,7 +97,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
                 String ns = node.getNamespace();
                 if (ns != null)
                 {
-                    if (asDoc != null)
+                    if (asDoc != null && MXMLJSC.keepASDoc)
                         write(asDoc.commentNoEnd());
                     else
                         begin();
@@ -111,7 +112,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
             {
                 if (!hasDoc)
                 {
-                    if (asDoc != null)
+                    if (asDoc != null && MXMLJSC.keepASDoc)
                         write(asDoc.commentNoEnd());
                     else
                         begin();
@@ -138,7 +139,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
                 {
                     if (!hasDoc)
                     {
-                        if (asDoc != null)
+                        if (asDoc != null && MXMLJSC.keepASDoc)
                             write(asDoc.commentNoEnd());
                         else
                             begin();
@@ -164,7 +165,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
                 {
                     if (!hasDoc)
                     {
-                        if (asDoc != null)
+                        if (asDoc != null && MXMLJSC.keepASDoc)
                             write(asDoc.commentNoEnd());
                         else
                             begin();
@@ -191,7 +192,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
         if (returnType != ""
                 && returnType != ASEmitterTokens.VOID.getToken()) // has return
         {
-            if (asDoc != null)
+            if (asDoc != null && MXMLJSC.keepASDoc)
                 write(asDoc.commentNoEnd());
             else
                 begin();
@@ -208,7 +209,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
         {
             if (!hasDoc)
             {
-                if (asDoc != null)
+                if (asDoc != null && MXMLJSC.keepASDoc)
                     write(asDoc.commentNoEnd());
                 else
                     begin();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dcb5c706/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index e5216e6..d5608ea 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -211,6 +211,27 @@ public class JSGoogConfiguration extends JSConfiguration
         strictPublish = value;
     }
 
+    //
+    // 'keep-asdoc'
+    //
+
+    private boolean keepASDoc = true;
+
+    public boolean getKeepASDoc()
+    {
+        return keepASDoc;
+    }
+
+    @Config
+    @Mapping("keep-asdoc")
+    public void setKeepASDoc(ConfigurationValue cv, boolean value)
+            throws ConfigurationException
+    {
+    	keepASDoc = value;
+    }
+
+    
+    
     protected String getAbsolutePathFromPathRelativeToMXMLC(String relativePath)
         throws IOException
     {


[19/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Some more clones of FlexJS test projects, to keep VF2JS honest

Posted by cd...@apache.org.
Some more clones of FlexJS test projects, to keep VF2JS honest

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 9cab2bffb5eddf79064877d044bd80319b431058
Parents: 91688e9
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 19:42:42 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:53 2014 +0200

----------------------------------------------------------------------
 .../vf2js/projects/interfaces/Test.as           | 46 +++++++++++
 .../vf2js/projects/interfaces/Test_result.js    | 64 ++++++++++++++++
 .../vf2js/projects/interfaces/classes/A.as      | 32 ++++++++
 .../projects/interfaces/classes/A_result.js     | 51 ++++++++++++
 .../vf2js/projects/interfaces/classes/B.as      | 25 ++++++
 .../projects/interfaces/classes/B_result.js     | 38 +++++++++
 .../vf2js/projects/interfaces/classes/C.as      | 25 ++++++
 .../projects/interfaces/classes/C_result.js     | 38 +++++++++
 .../vf2js/projects/interfaces/interfaces/IA.as  | 22 ++++++
 .../projects/interfaces/interfaces/IA_result.js | 41 ++++++++++
 .../vf2js/projects/interfaces/interfaces/IB.as  | 22 ++++++
 .../projects/interfaces/interfaces/IB_result.js | 38 +++++++++
 .../vf2js/projects/interfaces/interfaces/IC.as  | 22 ++++++
 .../projects/interfaces/interfaces/IC_result.js | 41 ++++++++++
 .../vf2js/projects/interfaces/interfaces/ID.as  | 22 ++++++
 .../projects/interfaces/interfaces/ID_result.js | 38 +++++++++
 .../vf2js/projects/interfaces/interfaces/IE.as  | 26 +++++++
 .../projects/interfaces/interfaces/IE_result.js | 53 +++++++++++++
 .../test-files/vf2js/projects/super/Base.as     | 48 ++++++++++++
 .../vf2js/projects/super/Base_result.js         | 74 ++++++++++++++++++
 .../test-files/vf2js/projects/super/Super.as    | 47 ++++++++++++
 .../vf2js/projects/super/Super_result.js        | 81 ++++++++++++++++++++
 22 files changed, 894 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test.as
new file mode 100644
index 0000000..d89743e
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test.as
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	import classes.A;
+	import interfaces.IA;
+	import interfaces.IC;
+	import interfaces.IE;
+
+  public class Test extends A implements IA, IE
+  {
+    public function Test()
+    {
+      super();
+      
+      var ia:IA = doSomething(IC) as IA
+    }
+    
+    public function doSomething(ic:IC):IC
+    {
+      for (var i:int = 0; i < 3; i++ {
+        var a:A = null;
+      }
+      
+	  super.doStuff();
+	  
+      return ic;
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test_result.js
new file mode 100644
index 0000000..f6c5b6d
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/Test_result.js
@@ -0,0 +1,64 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * Test
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('Test');
+
+goog.require('classes.A');
+goog.require('interfaces.IA');
+goog.require('interfaces.IC');
+goog.require('interfaces.IE');
+goog.require('org.apache.flex.utils.Language');
+
+
+
+/**
+ * @constructor
+ * @extends {classes.A}
+ * @implements {interfaces.IA}
+ * @implements {interfaces.IE}
+ */
+Test = function() {
+  Test.base(this, 'constructor');
+  var /** @type {interfaces.IA} */ ia = org.apache.flex.utils.Language.as(this.doSomething(interfaces.IC), interfaces.IA);
+};
+goog.inherits(Test, classes.A);
+
+
+/**
+ * @expose
+ * @param {interfaces.IC} ic
+ * @return {interfaces.IC}
+ */
+Test.prototype.doSomething = function(ic) {
+  for (var /** @type {number} */ i = 0; i < 3; i++) {
+    var /** @type {classes.A} */ a = null;
+  }
+  Test.base(this, 'doStuff');
+  return ic;
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Test.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Test', qName: 'Test'}], interfaces: [interfaces.IA, interfaces.IE] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A.as
new file mode 100644
index 0000000..20a6a11
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A.as
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 classes
+{
+  public class A extends C
+  {
+    public function A()
+    {
+      super();
+    }
+	
+	public function doStuff():void{
+		trace("STUFF!!!");
+	}
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A_result.js
new file mode 100644
index 0000000..80208da
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/A_result.js
@@ -0,0 +1,51 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * classes.A
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('classes.A');
+
+goog.require('classes.C');
+
+
+
+/**
+ * @constructor
+ * @extends {classes.C}
+ */
+classes.A = function() {
+  classes.A.base(this, 'constructor');
+};
+goog.inherits(classes.A, classes.C);
+
+
+/**
+ * @expose
+ */
+classes.A.prototype.doStuff = function() {
+  org.apache.flex.utils.Language.trace("STUFF!!!");
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+classes.A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'A', qName: 'classes.A'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B.as
new file mode 100644
index 0000000..b410e59
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 classes
+{
+    public class B
+    {
+        public function B() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B_result.js
new file mode 100644
index 0000000..2fef89c
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/B_result.js
@@ -0,0 +1,38 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * classes.B
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('classes.B');
+
+
+
+/**
+ * @constructor
+ */
+classes.B = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+classes.B.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'B', qName: 'classes.B'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C.as
new file mode 100644
index 0000000..d414a26
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 classes
+{
+    public class C
+    {
+        public function C() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C_result.js
new file mode 100644
index 0000000..729cda3
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/classes/C_result.js
@@ -0,0 +1,38 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * classes.C
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('classes.C');
+
+
+
+/**
+ * @constructor
+ */
+classes.C = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+classes.C.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'C', qName: 'classes.C'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA.as
new file mode 100644
index 0000000..5fbd6c2
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 interfaces
+{
+  public interface IA extends IC {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA_result.js
new file mode 100644
index 0000000..2a00144
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IA_result.js
@@ -0,0 +1,41 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * interfaces.IA
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('interfaces.IA');
+
+goog.require('interfaces.IC');
+
+
+
+/**
+ * @interface
+ * @extends {interfaces.IC}
+ */
+interfaces.IA = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+interfaces.IA.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IA', qName: 'interfaces.IA'}], interfaces: [interfaces.IC] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB.as
new file mode 100644
index 0000000..a995635
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 interfaces
+{
+    public interface IB {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB_result.js
new file mode 100644
index 0000000..d4933c8
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IB_result.js
@@ -0,0 +1,38 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * interfaces.IB
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('interfaces.IB');
+
+
+
+/**
+ * @interface
+ */
+interfaces.IB = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+interfaces.IB.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IB', qName: 'interfaces.IB'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC.as
new file mode 100644
index 0000000..9183bac
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 interfaces
+{
+  public interface IC extends ID {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC_result.js
new file mode 100644
index 0000000..9e5298b
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IC_result.js
@@ -0,0 +1,41 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * interfaces.IC
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('interfaces.IC');
+
+goog.require('interfaces.ID');
+
+
+
+/**
+ * @interface
+ * @extends {interfaces.ID}
+ */
+interfaces.IC = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+interfaces.IC.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IC', qName: 'interfaces.IC'}], interfaces: [interfaces.ID] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID.as
new file mode 100644
index 0000000..d5e9543
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 interfaces
+{
+    public interface ID {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID_result.js
new file mode 100644
index 0000000..a730bbb
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/ID_result.js
@@ -0,0 +1,38 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * interfaces.ID
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('interfaces.ID');
+
+
+
+/**
+ * @interface
+ */
+interfaces.ID = function() {
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+interfaces.ID.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'ID', qName: 'interfaces.ID'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE.as b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE.as
new file mode 100644
index 0000000..d2c7ce1
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 interfaces
+{
+    public interface IE {
+      function myMethod():void;
+      function get myProp():String;
+      function set myProp(value:String):void;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE_result.js b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE_result.js
new file mode 100644
index 0000000..63d68c7
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/interfaces/interfaces/IE_result.js
@@ -0,0 +1,53 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * interfaces.IE
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('interfaces.IE');
+
+
+
+/**
+ * @interface
+ */
+interfaces.IE = function() {
+};
+
+
+interfaces.IE.prototype.myMethod = function() {};
+
+
+/**
+ * @return {string}
+ */
+interfaces.IE.prototype.get_myProp = function() {};
+
+
+/**
+ * @param {string} value
+ */
+interfaces.IE.prototype.set_myProp = function(value) {};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+interfaces.IE.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IE', qName: 'interfaces.IE'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/super/Base.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/super/Base.as b/compiler.jx.tests/test-files/vf2js/projects/super/Base.as
new file mode 100644
index 0000000..8dccc35
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/super/Base.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//	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
+{
+	import Super;
+
+	public class Base extends Super
+	{
+		public function Base() 
+		{
+			super();
+		}; 
+
+		override public function get text():String 
+		{
+			return "A" + super.text;
+		};
+	
+		override public function set text(value:String):void 
+		{
+			if (value != super.text)
+			{
+				super.text = "B" + value;
+			}
+		};
+		
+		public function getNumber():void
+		{
+			var x:Number = super.x;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/super/Base_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/super/Base_result.js b/compiler.jx.tests/test-files/vf2js/projects/super/Base_result.js
new file mode 100644
index 0000000..cd666d4
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/super/Base_result.js
@@ -0,0 +1,74 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * Base
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('Base');
+
+goog.require('Super');
+goog.require('org.apache.flex.utils.Language');
+
+
+
+/**
+ * @constructor
+ * @extends {Super}
+ */
+Base = function() {
+  Base.base(this, 'constructor');
+};
+goog.inherits(Base, Super);
+
+
+/**
+ * @expose
+ * @return {string}
+ * @override
+ */
+Base.prototype.get_text = function() {
+  return "A" + Base.base(this, 'get_text');
+};
+
+
+/**
+ * @expose
+ * @param {string} value
+ * @override
+ */
+Base.prototype.set_text = function(value) {
+  if (value != Base.base(this, 'get_text')) {
+    Base.base(this, 'set_text', "B" + value);
+  }
+};
+
+
+/**
+ * @expose
+ */
+Base.prototype.getNumber = function() {
+  var /** @type {number} */ x = this.get_x();
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Base.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Base', qName: 'Base'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/super/Super.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/super/Super.as b/compiler.jx.tests/test-files/vf2js/projects/super/Super.as
new file mode 100644
index 0000000..772c886
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/super/Super.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//	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
+{
+	public class Super
+	{
+		public function Super() {}; 
+
+		private var _text:String = '';
+	
+		public function get text():String 
+		{
+			return _text;
+		};
+	
+		public function set text(value:String):void 
+		{
+			if (value != _text)
+			{
+				_text = value;
+			}
+		};
+		
+		private var _x:Number = 5;
+		
+		public function get x():Number 
+		{
+			return _x;
+		};
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9cab2bff/compiler.jx.tests/test-files/vf2js/projects/super/Super_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/super/Super_result.js b/compiler.jx.tests/test-files/vf2js/projects/super/Super_result.js
new file mode 100644
index 0000000..9082c3e
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/super/Super_result.js
@@ -0,0 +1,81 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * Super
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('Super');
+
+
+
+/**
+ * @constructor
+ */
+Super = function() {
+};
+
+
+/**
+ * @private
+ * @type {string}
+ */
+Super.prototype._text = '';
+
+
+/**
+ * @expose
+ * @return {string}
+ */
+Super.prototype.get_text = function() {
+  return this._text;
+};
+
+
+/**
+ * @expose
+ * @param {string} value
+ */
+Super.prototype.set_text = function(value) {
+  if (value != this._text) {
+    this._text = value;
+  }
+};
+
+
+/**
+ * @private
+ * @type {number}
+ */
+Super.prototype._x = 5;
+
+
+/**
+ * @expose
+ * @return {number}
+ */
+Super.prototype.get_x = function() {
+  return this._x;
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Super.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Super', qName: 'Super'}] };


[09/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Added VF2JS emitting

Posted by cd...@apache.org.
Added VF2JS emitting

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: e63cc7fd072d6f2a87ea7e75af097752ac8e2b93
Parents: f8e0a82
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 14:51:52 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../internal/codegen/js/goog/JSGoogEmitter.java |    2 +-
 .../codegen/js/vf2js/JSVF2JSDocEmitter.java     |  428 +----
 .../codegen/js/vf2js/JSVF2JSEmitter.java        | 1630 ++++++++++++------
 3 files changed, 1167 insertions(+), 893 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e63cc7fd/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 1eb08a8..d801c22 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
@@ -88,7 +88,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
 
     protected List<String> propertyNames = new ArrayList<String>();
 
-    protected ICompilerProject project;
+    public ICompilerProject project;
 
     protected IJSGoogDocEmitter getDoc()
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e63cc7fd/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
index d6c1075..c0a1241 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
@@ -19,41 +19,31 @@
 
 package org.apache.flex.compiler.internal.codegen.js.vf2js;
 
-import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
-import org.apache.flex.compiler.codegen.IEmitterTokens;
+import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.clients.MXMLJSC;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
-import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
 import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.DependencyType;
 import org.apache.flex.compiler.constants.IASKeywordConstants;
 import org.apache.flex.compiler.constants.IASLanguageConstants;
 import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.definitions.references.IReference;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSDocEmitter;
-import org.apache.flex.compiler.internal.codegen.js.JSDocEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
-import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
 import org.apache.flex.compiler.internal.scopes.ASScope;
-import org.apache.flex.compiler.internal.semantics.SemanticUtils;
 import org.apache.flex.compiler.projects.ICompilerProject;
-import org.apache.flex.compiler.tree.as.IASNode;
-import org.apache.flex.compiler.tree.as.IClassNode;
 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.IInterfaceNode;
-import org.apache.flex.compiler.tree.as.IPackageNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
-import org.apache.flex.compiler.tree.as.IScopedNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 
-public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
+public class JSVF2JSDocEmitter extends JSGoogDocEmitter
 {
 
     public JSVF2JSDocEmitter(IJSEmitter emitter)
@@ -62,85 +52,22 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
     }
 
     @Override
-    public void emitInterfaceDoc(IInterfaceNode node, ICompilerProject project)
-    {
-        begin();
-
-        emitJSDocLine(JSEmitterTokens.INTERFACE.getToken());
-
-        boolean hasQualifiedNames = true;
-        IExpressionNode[] inodes = node.getExtendedInterfaceNodes();
-        for (IExpressionNode inode : inodes)
-        {
-            IDefinition dnode = inode.resolve(project);
-            if (dnode != null)
-            {
-                emitJSDocLine(ASEmitterTokens.EXTENDS, dnode.getQualifiedName());
-            }
-            else
-            {
-                hasQualifiedNames = false;
-                break;
-            }
-        }
-        
-        if (!hasQualifiedNames)
-        {
-            String[] inames = node.getExtendedInterfaces();
-            for (String iname : inames)
-            {
-                emitJSDocLine(ASEmitterTokens.EXTENDS, iname);
-            }
-        }
-
-        end();
-    }
-
-    public void emitInterfaceMemberDoc(IDefinitionNode node, ICompilerProject project)
-    {
-        // (erikdebruin) placeholder method, so we don't have to further complicate
-        //               the interface structure
-    }
-
-    @Override
-    public void emitFieldDoc(IVariableNode node, IDefinition def)
-    {
-        begin();
-
-        String ns = node.getNamespace();
-        if (ns == IASKeywordConstants.PRIVATE)
-        {
-            emitPrivate(node);
-        }
-        else if (ns == IASKeywordConstants.PROTECTED)
-        {
-            emitProtected(node);
-        }
-
-        if (node.isConst())
-            emitConst(node);
-
-        String packageName = "";
-        if (def != null)
-            packageName = def.getPackageName();
-
-        emitType(node, packageName);
-
-        end();
-    }
-
-    @Override
     public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
     {
         IClassDefinition classDefinition = resolveClassDefinition(node);
 
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        
         if (node instanceof IFunctionNode)
         {
             boolean hasDoc = false;
 
             if (node.isConstructor())
             {
-                begin();
+                if (asDoc != null && MXMLJSC.keepASDoc)
+                    write(asDoc.commentNoEnd());
+                else
+                    begin();
                 hasDoc = true;
 
                 emitJSDocLine(JSEmitterTokens.CONSTRUCTOR);
@@ -162,19 +89,22 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
                             .resolve(project, (ASScope) classDefinition
                                     .getContainingScope(),
                                     DependencyType.INHERITANCE, true);
+                    if (type == null)
+                    	System.out.println(iReference.getDisplayString() + " not resolved in " + classDefinition.getQualifiedName());
                     emitImplements(type, type.getPackageName());
                 }
             }
             else
             {
-                // @this
-                if (containsThisReference(node))
+                String ns = node.getNamespace();
+                if (ns != null)
                 {
-                    begin();
+                    if (asDoc != null && MXMLJSC.keepASDoc)
+                        write(asDoc.commentNoEnd());
+                    else
+                        begin();
                     emitMethodAccess(node);
                     hasDoc = true;
-                    
-                    emitThis(classDefinition, classDefinition.getPackageName());
                 }
             }
 
@@ -184,13 +114,22 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
             {
                 if (!hasDoc)
                 {
-                    begin();
+                    if (asDoc != null && MXMLJSC.keepASDoc)
+                        write(asDoc.commentNoEnd());
+                    else
+                        begin();
                     emitMethodAccess(node);
                     hasDoc = true;
                 }
 
                 IExpressionNode enode = pnode.getNameExpressionNode();
-                emitParam(pnode, enode.resolveType(project).getPackageName());
+
+                // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+                ITypeDefinition tdef = enode.resolveType(project);
+                if (tdef == null)
+                    continue;
+                
+                emitParam(pnode, tdef.getPackageName());
             }
 
             if (!node.isConstructor())
@@ -202,12 +141,24 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
                 {
                     if (!hasDoc)
                     {
-                        begin();
+                        if (asDoc != null && MXMLJSC.keepASDoc)
+                            write(asDoc.commentNoEnd());
+                        else
+                            begin();
                         emitMethodAccess(node);
                         hasDoc = true;
                     }
 
-                    emitReturn(node, node.getPackageName());
+                    ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
+                            .resolveReturnType(project);
+
+                    String packageName = "";
+                    if (tdef instanceof InterfaceDefinition)
+                        packageName = tdef.getPackageName();
+                    else
+                        packageName = node.getPackageName();
+                    
+                    emitReturn(node, packageName);
                 }
 
                 // @override
@@ -216,7 +167,10 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
                 {
                     if (!hasDoc)
                     {
-                        begin();
+                        if (asDoc != null && MXMLJSC.keepASDoc)
+                            write(asDoc.commentNoEnd());
+                        else
+                            begin();
                         emitMethodAccess(node);
                         hasDoc = true;
                     }
@@ -229,11 +183,6 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
                 end();
         }
     }
-
-    public void emitMethodAccess(IFunctionNode node)
-    {
-    	// do nothing
-    }
     
     @Override
     public void emitVarDoc(IVariableNode node, IDefinition def)
@@ -247,7 +196,7 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
             IDefinition ndef = node.getDefinition();
             if (emitter != null && emitter instanceof JSVF2JSEmitter)
             {
-                ICompilerProject project = ((JSVF2JSEmitter)emitter).project;
+            	ICompilerProject project = ((JSVF2JSEmitter)emitter).project;
                 if (project != null)
                 {
                     packageName = ((ITypeDefinition)ndef.resolveType(project))
@@ -259,263 +208,64 @@ public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
         emitTypeShort(node, packageName);
     }
 
-    @Override
-    public void emitConst(IVariableNode node)
-    {
-        emitJSDocLine(ASEmitterTokens.CONST);
-    }
-
-    @Override
-    public void emitExtends(IClassDefinition superDefinition, String packageName)
-    {
-        emitJSDocLine(ASEmitterTokens.EXTENDS,
-                superDefinition.getQualifiedName());
-    }
-
-    @Override
-    public void emitImplements(ITypeDefinition definition, String packageName)
-    {
-        emitJSDocLine(ASEmitterTokens.IMPLEMENTS, definition.getQualifiedName());
-    }
-
-    @Override
-    public void emitOverride(IFunctionNode node)
-    {
-        emitJSDocLine(ASEmitterTokens.OVERRIDE);
-    }
-
-    @Override
-    public void emitParam(IParameterNode node, String packageName)
+    
+    public void emitInterfaceMemberDoc(IDefinitionNode node, ICompilerProject project)
     {
-        String postfix = (node.getDefaultValue() == null) ? ""
-                : ASEmitterTokens.EQUAL.getToken();
-
-        String paramType = "";
-        if (node.isRest())
-        {
-            paramType = ASEmitterTokens.ELLIPSIS.getToken();
-        }
-        else
-        {
-            String typeName = node.getVariableType();
-            if (typeName.indexOf(packageName) > -1)
-            {
-                String[] parts = typeName.split("\\.");
-                if (parts.length > 0)
-                {
-                    typeName = parts[parts.length - 1];
-                }
-            }
-            paramType = convertASTypeToJS(typeName, packageName);
-        }
-
-        if (paramType.length() > 0)
-        {
-	        if (paramType.substring(0, 1).equalsIgnoreCase("<"))
-	        {
-	        	paramType = "Array";
-	        }
-        }
+        boolean hasDoc = false;
         
-        emitJSDocLine(JSGoogDocEmitterTokens.PARAM, paramType + postfix,
-                node.getName());
-    }
-
-    @Override
-    public void emitPrivate(IASNode node)
-    {
-        emitJSDocLine(ASEmitterTokens.PRIVATE);
-    }
+        ASDocComment asDoc = (ASDocComment) ((IFunctionNode) node).getASDocComment();
+        
+        String returnType = ((IFunctionNode) node).getReturnType();
+        if (returnType != ""
+                && returnType != ASEmitterTokens.VOID.getToken()) // has return
+        {
+            if (asDoc != null && MXMLJSC.keepASDoc)
+                write(asDoc.commentNoEnd());
+            else
+                begin();
+            hasDoc = true;
 
-    @Override
-    public void emitProtected(IASNode node)
-    {
-        emitJSDocLine(ASEmitterTokens.PROTECTED);
-    }
+            ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
+                    .resolveReturnType(project);
 
-    @Override
-    public void emitPublic(IASNode node)
-    {
-        emitJSDocLine(JSGoogDocEmitterTokens.EXPOSE);
-    }
+            emitReturn((IFunctionNode) node, tdef.getPackageName());
+        }
 
-    @Override
-    public void emitReturn(IFunctionNode node, String packageName)
-    {
-        String rtype = node.getReturnType();
-        if (rtype != null)
+        IParameterNode[] parameters = ((IFunctionNode) node).getParameterNodes();
+        for (IParameterNode pnode : parameters)
         {
-            if (rtype.length() > 1)
+            if (!hasDoc)
             {
-            	rtype = convertASTypeToJS(rtype, packageName);
-            	
-	            if (rtype.substring(rtype.length() - 1, rtype.length()).equalsIgnoreCase("*"))
-	            {
-	            	rtype = "*";
-	            }
+                if (asDoc != null && MXMLJSC.keepASDoc)
+                    write(asDoc.commentNoEnd());
+                else
+                    begin();
+                hasDoc = true;
             }
-            
-            emitJSDocLine(ASEmitterTokens.RETURN, rtype);
+
+            IExpressionNode enode = pnode.getNameExpressionNode();
+            emitParam(pnode, enode.resolveType(project).getPackageName());
         }
-    }
 
-    @Override
-    public void emitThis(ITypeDefinition type, String packageName)
-    {
-        emitJSDocLine(ASEmitterTokens.THIS.getToken(), type.getQualifiedName());
+        if (hasDoc)
+            end();
     }
 
     @Override
-    public void emitType(IASNode node, String packageName)
-    {
-        String type = ((IVariableNode) node).getVariableType();
-        emitJSDocLine(JSGoogDocEmitterTokens.TYPE.getToken(),
-                convertASTypeToJS(type, packageName));
-    }
-
-    public void emitTypeShort(IASNode node, String packageName)
-    {
-        String type = ((IVariableNode) node).getVariableType();
-        writeToken(JSDocEmitterTokens.JSDOC_OPEN);
-        write(ASEmitterTokens.ATSIGN);
-        writeToken(JSGoogDocEmitterTokens.TYPE);
-        writeBlockOpen();
-        write(convertASTypeToJS(type, packageName));
-        writeBlockClose();
-        write(ASEmitterTokens.SPACE);
-        writeToken(JSDocEmitterTokens.JSDOC_CLOSE);
-    }
-
-    //--------------------------------------------------------------------------
-
-    public void emmitPackageHeader(IPackageNode node)
-    {
-        begin();
-        write(ASEmitterTokens.SPACE);
-        writeToken(JSGoogDocEmitterTokens.STAR);
-        write(JSSharedData.getTimeStampString());
-        end();
-    }
-
-    //--------------------------------------------------------------------------
-
-    protected void emitJSDocLine(IEmitterTokens name)
-    {
-        emitJSDocLine(name.getToken(), "");
-    }
-
-    private void emitJSDocLine(String name)
-    {
-        emitJSDocLine(name, "");
-    }
-
-    private void emitJSDocLine(IEmitterTokens name, String type)
-    {
-        emitJSDocLine(name.getToken(), type, "");
-    }
-
-    private void emitJSDocLine(String name, String type)
-    {
-        emitJSDocLine(name, type, "");
-    }
-
-    private void emitJSDocLine(IEmitterTokens name, String type, String param)
-    {
-        emitJSDocLine(name.getToken(), type, param);
-    }
-
-    private void emitJSDocLine(String name, String type, String param)
+    public void emitMethodAccess(IFunctionNode node)
     {
-        write(ASEmitterTokens.SPACE);
-        writeToken(JSGoogDocEmitterTokens.STAR);
-        write(ASEmitterTokens.ATSIGN);
-        write(name);
-        if (type != "")
-        {
-            write(ASEmitterTokens.SPACE);
-            writeBlockOpen();
-            write(type);
-            writeBlockClose();
-        }
-        if (param != "")
+        String ns = node.getNamespace();
+        if (ns == IASKeywordConstants.PRIVATE)
         {
-            write(ASEmitterTokens.SPACE);
-            write(param);
+            emitPrivate(node);
         }
-        writeNewline();
-    }
-
-    protected boolean containsThisReference(IASNode node)
-    {
-        final int len = node.getChildCount();
-        for (int i = 0; i < len; i++)
+        else if (ns == IASKeywordConstants.PROTECTED)
         {
-            final IASNode child = node.getChild(i);
-            if (child.getChildCount() > 0)
-            {
-                return containsThisReference(child);
-            }
-            else
-            {
-                if (SemanticUtils.isThisKeyword(child))
-                    return true;
-            }
+            emitProtected(node);
         }
-
-        return false;
-    }
-
-    private String convertASTypeToJS(String name, String pname)
-    {
-        String result = "";
-
-        if (name.equals(""))
-            result = ASEmitterTokens.ANY_TYPE.getToken();
-        else if (name.equals(IASLanguageConstants.Class))
-            result = IASLanguageConstants.Object;
-        else if (name.equals(IASLanguageConstants.Boolean)
-                || name.equals(IASLanguageConstants.String)
-                || name.equals(IASLanguageConstants.Number))
-            result = name.toLowerCase();
-        else if (name.equals(IASLanguageConstants._int)
-                || name.equals(IASLanguageConstants.uint))
-            result = IASLanguageConstants.Number.toLowerCase();
-
-        boolean isBuiltinFunction = name.matches("Vector\\.<.*>");
-        IASGlobalFunctionConstants.BuiltinType[] builtinTypes = IASGlobalFunctionConstants.BuiltinType
-                .values();
-        for (IASGlobalFunctionConstants.BuiltinType builtinType : builtinTypes)
+        else if (ns == IASKeywordConstants.PUBLIC)
         {
-            if (name.equalsIgnoreCase(builtinType.getName()))
-            {
-                isBuiltinFunction = true;
-                break;
-            }
+            emitPublic(node);
         }
-
-        if (result == "")
-            result = (pname != "" && !isBuiltinFunction && name.indexOf(".") < 0) ? pname
-                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + name : name;
-
-        result = result.replace(IASLanguageConstants.String,
-                IASLanguageConstants.String.toLowerCase());
-
-        return result;
-    }
-
-    protected IClassDefinition resolveClassDefinition(IFunctionNode node)
-    {
-        IScopedNode scope = node.getContainingScope();
-        if (scope instanceof IMXMLDocumentNode)
-            return ((IMXMLDocumentNode) scope).getClassDefinition();
-
-        IClassNode cnode = (IClassNode) node
-                .getAncestorOfType(IClassNode.class);
-        
-        // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
-        if (cnode == null)
-            return null;
-        
-        return cnode.getDefinition();
     }
 }


[23/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Merge branch 'develop' into feature/flexmojos-tests

Posted by cd...@apache.org.
Merge branch 'develop' into feature/flexmojos-tests

* develop: (21 commits)
  Making sure we notice if stuff broke when running from ant (i.e. on the build VM) - part deux
  Making sure we notice if stuff broke when running from ant (i.e. on the build VM)
  Added 'const' emission (ECMA 6) + tests
  Some more clones of FlexJS test projects, to keep VF2JS honest
  Add VF2JS specific test base classes
  Update and add various VF2JS pathway files
  VF2JS tests
  VF2JS will no longer use the 'vf2js' namespaces.
  Suppress 'unused' warnings for a while.
  Changed name to avoid conflict with the other SimpleMXML test and added 'result' JS files.
  Add dependencies
  Added VF2JS emitting
  Fix imports
  Added type for new emitter class
  VF2JS Doc emitter
  Added super class to handle VF2JS specific JS emitting
  Avoid an error when encountering an Embed node
  Initial VF2JS (full SDK) Publisher
  Various E4X "bypass" measures ...
  If empty comment line, don't try to add "the rest of the line"
  ...


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 142af189120146888ada629dd6eb35e3f16beb0e
Parents: 7ee7973 1144b7b
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Oct 31 09:26:58 2014 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Oct 31 09:26:58 2014 +0100

----------------------------------------------------------------------
 compiler.jx.tests/build.xml                     |    2 +-
 .../codegen/js/vf2js/TestVF2JSClass.java        |  302 +++
 .../codegen/js/vf2js/TestVF2JSFile.java         |    4 +-
 .../codegen/js/vf2js/TestVF2JSProject.java      |   73 +-
 .../codegen/js/vf2js/TestVF2JSStatements.java   |  528 ++++++
 .../mxml/vf2js/TestVF2JSMXMLApplication.java    |   57 +-
 .../compiler/internal/test/FlexJSTestBase.java  |    2 +
 .../internal/test/VF2JSMXMLTestBase.java        |  219 +++
 .../compiler/internal/test/VF2JSTestBase.java   |  216 +--
 .../test-files/vf2js/files/SimpleMXML_result.js |   17 +-
 .../vf2js/projects/interfaces/Test.as           |   46 +
 .../vf2js/projects/interfaces/Test_result.js    |   64 +
 .../vf2js/projects/interfaces/classes/A.as      |   32 +
 .../projects/interfaces/classes/A_result.js     |   51 +
 .../vf2js/projects/interfaces/classes/B.as      |   25 +
 .../projects/interfaces/classes/B_result.js     |   38 +
 .../vf2js/projects/interfaces/classes/C.as      |   25 +
 .../projects/interfaces/classes/C_result.js     |   38 +
 .../vf2js/projects/interfaces/interfaces/IA.as  |   22 +
 .../projects/interfaces/interfaces/IA_result.js |   41 +
 .../vf2js/projects/interfaces/interfaces/IB.as  |   22 +
 .../projects/interfaces/interfaces/IB_result.js |   38 +
 .../vf2js/projects/interfaces/interfaces/IC.as  |   22 +
 .../projects/interfaces/interfaces/IC_result.js |   41 +
 .../vf2js/projects/interfaces/interfaces/ID.as  |   22 +
 .../projects/interfaces/interfaces/ID_result.js |   38 +
 .../vf2js/projects/interfaces/interfaces/IE.as  |   26 +
 .../projects/interfaces/interfaces/IE_result.js |   53 +
 .../projects/simpleMXML/src/SimpleMXML.mxml     |   19 -
 .../simpleMXML/src/SimpleMXML_Project.mxml      |   19 +
 .../simpleMXML/src/SimpleMXML_Project_result.js |   65 +
 .../simpleMXML/src/example/Component_result.js  |   45 +
 .../test-files/vf2js/projects/super/Base.as     |   48 +
 .../vf2js/projects/super/Base_result.js         |   74 +
 .../test-files/vf2js/projects/super/Super.as    |   47 +
 .../vf2js/projects/super/Super_result.js        |   81 +
 .../compiler/asdoc/flexjs/ASDocComment.java     |    4 +-
 .../apache/flex/compiler/clients/MXMLJSC.java   |    7 +-
 .../flex/compiler/codegen/as/IASEmitter.java    |    2 +
 .../codegen/js/vf2js/IJSVF2JSEmitter.java       |   30 +
 .../internal/codegen/as/ASBlockWalker.java      |    7 +
 .../compiler/internal/codegen/as/ASEmitter.java |    4 +
 .../codegen/js/flexjs/JSFlexJSDocEmitter.java   |   15 +-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      |   47 +-
 .../internal/codegen/js/goog/JSGoogEmitter.java |    6 +-
 .../codegen/js/vf2js/JSVF2JSDocEmitter.java     |  271 +++
 .../codegen/js/vf2js/JSVF2JSEmitter.java        | 1722 ++++++++++++++++++
 .../vf2js/MXMLVF2JSDescriptorSpecifier.java     |    3 +
 .../codegen/mxml/vf2js/MXMLVF2JSEmitter.java    |    3 +-
 .../codegen/mxml/vf2js/MXMLVF2JSPublisher.java  |   68 +-
 .../driver/js/goog/JSGoogConfiguration.java     |   21 +
 .../internal/driver/js/vf2js/VF2JSBackend.java  |   55 +
 .../driver/mxml/vf2js/MXMLVF2JSBackend.java     |    8 +-
 .../internal/visitor/as/ASNodeSwitch.java       |    4 +
 .../compiler/visitor/as/IASBlockVisitor.java    |    2 +
 compiler.tests/build.xml                        |    6 +-
 56 files changed, 4449 insertions(+), 298 deletions(-)
----------------------------------------------------------------------



[13/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Changed name to avoid conflict with the other SimpleMXML test and added 'result' JS files.

Posted by cd...@apache.org.
Changed name to avoid conflict with the other SimpleMXML test and added 'result' JS files.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 04527431c930a23690993816dcf30c30f023c565
Parents: fcdc392
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 16:51:17 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../projects/simpleMXML/src/SimpleMXML.mxml     | 19 ------
 .../simpleMXML/src/SimpleMXML_Project.mxml      | 19 ++++++
 .../simpleMXML/src/SimpleMXML_Project_result.js | 65 ++++++++++++++++++++
 .../simpleMXML/src/example/Component_result.js  | 45 ++++++++++++++
 4 files changed, 129 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/04527431/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML.mxml
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML.mxml b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML.mxml
deleted file mode 100644
index 389be97..0000000
--- a/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML.mxml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
-			   xmlns:s="library://ns.adobe.com/flex/spark" 
-			   xmlns:mx="library://ns.adobe.com/flex/mx" 
-			   xmlns:example="example.*"
-			   minHeight="600"
-			   minWidth="955">
-	
-	<fx:Script><![CDATA[
-		
-		private var myComponent:Component = new Component();
-		
-	]]></fx:Script>
-	
-	<fx:Declarations>
-		<example:Component myProperty="oops" />
-	</fx:Declarations>
-	
-</s:Application>

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/04527431/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
new file mode 100644
index 0000000..389be97
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
+			   xmlns:s="library://ns.adobe.com/flex/spark" 
+			   xmlns:mx="library://ns.adobe.com/flex/mx" 
+			   xmlns:example="example.*"
+			   minHeight="600"
+			   minWidth="955">
+	
+	<fx:Script><![CDATA[
+		
+		private var myComponent:Component = new Component();
+		
+	]]></fx:Script>
+	
+	<fx:Declarations>
+		<example:Component myProperty="oops" />
+	</fx:Declarations>
+	
+</s:Application>

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/04527431/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
new file mode 100644
index 0000000..aaad9b6
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
@@ -0,0 +1,65 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * SimpleMXML_Project
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('SimpleMXML_Project');
+
+goog.require('spark.components.Application');
+goog.require('example.Component');
+goog.require('org.apache.flex.utils.Language');
+
+
+
+
+/**
+ * @constructor
+ * @extends {spark.components.Application}
+ */
+SimpleMXML_Project = function() {
+  SimpleMXML_Project.base(this, 'constructor');
+  };
+goog.inherits(SimpleMXML_Project, spark.components.Application);
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+SimpleMXML_Project.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'SimpleMXML_Project', qName: 'SimpleMXML_Project' }] };
+
+
+/**
+ * @private
+ * @type {example.Component}
+ */
+SimpleMXML_Project.prototype.myComponent = new example.Component();
+
+
+/**
+ * start
+ *
+ * @expose
+ */
+SimpleMXML_Project.prototype.start = function () {
+this.null.minHeight = 600;
+this.null.minWidth = 955;
+
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/04527431/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/example/Component_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/example/Component_result.js b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/example/Component_result.js
new file mode 100644
index 0000000..23f3aa4
--- /dev/null
+++ b/compiler.jx.tests/test-files/vf2js/projects/simpleMXML/src/example/Component_result.js
@@ -0,0 +1,45 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * example.Component
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('example.Component');
+
+
+
+/**
+ * @constructor
+ */
+example.Component = function() {
+  ;
+};
+
+
+/**
+ * @type {Object}
+ */
+example.Component.prototype.myProperty = {};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+example.Component.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Component', qName: 'example.Component'}] };
\ No newline at end of file


[06/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - If empty comment line, don't try to add "the rest of the line"

Posted by cd...@apache.org.
If empty comment line, don't try to add "the rest of the line"

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 68a7c9ebbe34829cb4c52de56181d041195d8594
Parents: dcb5c70
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:14:47 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/68a7c9eb/compiler.jx/src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java b/compiler.jx/src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
index 379a4c2..b44253c 100644
--- a/compiler.jx/src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
+++ b/compiler.jx/src/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
@@ -20,7 +20,6 @@
 package org.apache.flex.compiler.asdoc.flexjs;
 
 import org.apache.flex.compiler.asdoc.IASDocComment;
-import org.apache.flex.compiler.internal.codegen.js.JSDocEmitterTokens;
 
 import antlr.Token;
 
@@ -47,7 +46,8 @@ public class ASDocComment implements IASDocComment
             String line = lines[i];
             int star = line.indexOf("*");
             sb.append(" ");
-            sb.append(line.substring(star));
+            if (star > -1)
+                sb.append(line.substring(star));
             sb.append("\n");
         }
         return sb.toString();


[08/23] Added VF2JS emitting

Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e63cc7fd/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 a0686c8..9b91eb2 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
@@ -21,33 +21,49 @@ package org.apache.flex.compiler.internal.codegen.js.vf2js;
 
 import java.io.FilterWriter;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
-import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants.BuiltinType;
+import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
 import org.apache.flex.compiler.codegen.IDocEmitter;
-import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
-import org.apache.flex.compiler.codegen.js.goog.IJSGoogEmitter;
+import org.apache.flex.compiler.codegen.js.vf2js.IJSVF2JSEmitter;
 import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.ModifiersSet;
-import org.apache.flex.compiler.constants.IASLanguageConstants;
 import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IFunctionDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition.FunctionClassification;
+import org.apache.flex.compiler.definitions.INamespaceDefinition;
 import org.apache.flex.compiler.definitions.IPackageDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
 import org.apache.flex.compiler.internal.definitions.ClassDefinition;
+import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
+import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
+import org.apache.flex.compiler.internal.definitions.ParameterDefinition;
+import org.apache.flex.compiler.internal.definitions.VariableDefinition;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.scopes.ASProjectScope;
 import org.apache.flex.compiler.internal.scopes.PackageScope;
+import org.apache.flex.compiler.internal.scopes.TypeScope;
+import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
 import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
-import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.internal.tree.as.NonResolvingIdentifierNode;
+import org.apache.flex.compiler.internal.tree.as.ParameterNode;
+import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
+import org.apache.flex.compiler.internal.tree.as.UnaryOperatorAtNode;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.scopes.IASScope;
 import org.apache.flex.compiler.tree.ASTNodeID;
@@ -55,7 +71,6 @@ import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IAccessorNode;
 import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IClassNode;
-import org.apache.flex.compiler.tree.as.IContainerNode;
 import org.apache.flex.compiler.tree.as.IDefinitionNode;
 import org.apache.flex.compiler.tree.as.IEmbedNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
@@ -65,130 +80,57 @@ 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.INamespaceAccessExpressionNode;
+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.IMemberAccessExpressionNode;
 import org.apache.flex.compiler.tree.as.IParameterNode;
-import org.apache.flex.compiler.tree.as.IScopedNode;
 import org.apache.flex.compiler.tree.as.ISetterNode;
 import org.apache.flex.compiler.tree.as.ITypeNode;
 import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
 import org.apache.flex.compiler.tree.as.IVariableExpressionNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.utils.ASNodeUtils;
+import org.apache.flex.compiler.utils.NativeUtils;
 
 /**
- * Concrete implementation of the 'goog' JavaScript production.
+ * Concrete implementation of the 'vf2js' JavaScript production.
  * 
- * @author Michael Schmalle
  * @author Erik de Bruin
  */
-public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
+public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
 {
 
-    protected static final String CONSTRUCTOR_EMPTY = "emptyConstructor";
-    protected static final String CONSTRUCTOR_FULL = "fullConstructor";
-    protected static final String SUPER_FUNCTION_CALL = "replaceSuperFunction";
-
-    protected List<String> propertyNames = new ArrayList<String>();
-
-    protected ICompilerProject project;
-
-    protected IJSGoogDocEmitter getDoc()
-    {
-        return (IJSGoogDocEmitter) getDocEmitter();
-    }
-
-    @Override
-    public IDocEmitter getDocEmitter()
+    public JSVF2JSEmitter(FilterWriter out)
     {
-        return new JSGoogDocEmitter(this);
+        super(out);
     }
 
-    //--------------------------------------------------------------------------
-    // 
-    //--------------------------------------------------------------------------
-
-    @Override
-    public void emitPackageHeader(IPackageDefinition definition)
-    {
-        IASScope containedScope = definition.getContainedScope();
-        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
-        if (type == null)
-            return;
-
-        /* goog.provide('x');\n\n */
-        write(JSGoogEmitterTokens.GOOG_PROVIDE);
-        write(ASEmitterTokens.PAREN_OPEN);
-        write(ASEmitterTokens.SINGLE_QUOTE);
-        write(type.getQualifiedName());
-        write(ASEmitterTokens.SINGLE_QUOTE);
-        write(ASEmitterTokens.PAREN_CLOSE);
-        writeNewline(ASEmitterTokens.SEMICOLON);
-        writeNewline();
-    }
+    public IDefinition thisClass;
 
     @Override
-    public void emitPackageHeaderContents(IPackageDefinition definition)
+    protected String getIndent(int numIndent)
     {
-        PackageScope containedScope = (PackageScope) definition
-                .getContainedScope();
-
-        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
-        if (type == null)
-            return;
-
-        List<String> list = resolveImports(type);
-        for (String imp : list)
-        {
-            if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
-                continue;
-
-            /* goog.require('x');\n */
-            write(JSGoogEmitterTokens.GOOG_REQUIRE);
-            write(ASEmitterTokens.PAREN_OPEN);
-            write(ASEmitterTokens.SINGLE_QUOTE);
-            write(imp);
-            write(ASEmitterTokens.SINGLE_QUOTE);
-            write(ASEmitterTokens.PAREN_CLOSE);
-            writeNewline(ASEmitterTokens.SEMICOLON);
-        }
-
-        // (erikdebruin) only write 'closing' line break when there are 
-        //               actually imports...
-        if (list.size() > 1
-                || (list.size() == 1 && list.get(0).indexOf(
-                        JSGoogEmitterTokens.AS3.getToken()) == -1))
-        {
-            writeNewline();
-        }
+        final StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < numIndent; i++)
+            sb.append(JSFlexJSEmitterTokens.INDENT.getToken());
+        return sb.toString();
     }
 
     @Override
-    public void emitPackageContents(IPackageDefinition definition)
+    protected void emitMemberName(IDefinitionNode node)
     {
-        IASScope containedScope = definition.getContainedScope();
-        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
-        if (type == null)
-            return;
-
-        ITypeNode tnode = findTypeNode(definition.getNode());
-        if (tnode != null)
-        {
-            getWalker().walk(tnode); // IClassNode | IInterfaceNode
-        }
+        write(node.getName());
     }
 
     @Override
-    public void emitPackageFooter(IPackageDefinition definition)
+    public void emitClass(IClassNode node)
     {
-    }
+        thisClass = node.getDefinition();
 
-    //--------------------------------------------------------------------------
-    // 
-    //--------------------------------------------------------------------------
+        project = getWalker().getProject();
 
-    @Override
-    public void emitClass(IClassNode node)
-    {
         IClassDefinition definition = node.getDefinition();
 
         IFunctionDefinition ctorDefinition = definition.getConstructor();
@@ -230,6 +172,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
             {
                 writeNewline();
                 writeNewline();
+                writeNewline();
                 emitField((IVariableNode) dnode);
                 write(ASEmitterTokens.SEMICOLON);
             }
@@ -239,6 +182,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
                 {
                     writeNewline();
                     writeNewline();
+                    writeNewline();
                     emitMethod((IFunctionNode) dnode);
                     write(ASEmitterTokens.SEMICOLON);
                 }
@@ -248,6 +192,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
             {
                 writeNewline();
                 writeNewline();
+                writeNewline();
                 emitAccessors((IAccessorNode) dnode);
                 write(ASEmitterTokens.SEMICOLON);
             }
@@ -277,72 +222,75 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
             write(ASEmitterTokens.SEMICOLON);
         }
 
+        
         final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
         for (IDefinitionNode mnode : members)
         {
             boolean isAccessor = mnode.getNodeID() == ASTNodeID.GetterID
                     || mnode.getNodeID() == ASTNodeID.SetterID;
 
-            if (!isAccessor || !propertyNames.contains(qname))
-            {
-                writeNewline();
-
-                write(qname);
-                write(ASEmitterTokens.MEMBER_ACCESS);
-                write(JSEmitterTokens.PROTOTYPE);
-                write(ASEmitterTokens.MEMBER_ACCESS);
-                write(mnode.getQualifiedName());
-
-                if (isAccessor && !propertyNames.contains(qname))
-                {
-                    propertyNames.add(qname);
-                }
-                else
-                {
-                    write(ASEmitterTokens.SPACE);
-                    writeToken(ASEmitterTokens.EQUAL);
-                    write(ASEmitterTokens.FUNCTION);
-
-                    emitParameters(((IFunctionNode) mnode).getParameterNodes());
-
-                    write(ASEmitterTokens.SPACE);
-                    write(ASEmitterTokens.BLOCK_OPEN);
-                    writeNewline();
-                    write(ASEmitterTokens.BLOCK_CLOSE);
-                }
+            writeNewline();
+            writeNewline();
+            writeNewline();
 
-                write(ASEmitterTokens.SEMICOLON);
+            getDoc().emitInterfaceMemberDoc((IFunctionNode) mnode, project);
+            
+            write(qname);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.PROTOTYPE);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            if (isAccessor)
+            {
+                writeGetSetPrefix(mnode.getNodeID() == ASTNodeID.GetterID);
             }
+            write(mnode.getQualifiedName());
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            write(ASEmitterTokens.FUNCTION);
+            emitParameters(((IFunctionNode) mnode).getParameterNodes());
+            write(ASEmitterTokens.SPACE);
+            write(ASEmitterTokens.BLOCK_OPEN);
+            write(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.SEMICOLON);
         }
     }
 
     @Override
     public void emitField(IVariableNode node)
     {
-        IClassDefinition definition = getClassDefinition(node);
+        IDefinition definition = getClassDefinition(node);
 
         IDefinition def = null;
         IExpressionNode enode = node.getVariableTypeNode();//getAssignedValueNode();
         if (enode != null)
-            def = enode.resolveType(getWalker().getProject());
+        {
+            if (project == null)
+                project = getWalker().getProject();
+
+            def = enode.resolveType(project);
+        }
 
         getDoc().emitFieldDoc(node, def);
 
-        /* x.prototype.y = z */
+        IDefinition ndef = node.getDefinition();
 
-        ModifiersSet modifierSet = node.getDefinition().getModifiers();
+        ModifiersSet modifierSet = ndef.getModifiers();
         String root = "";
         if (modifierSet != null && !modifierSet.hasModifier(ASModifier.STATIC))
         {
             root = JSEmitterTokens.PROTOTYPE.getToken();
             root += ASEmitterTokens.MEMBER_ACCESS.getToken();
         }
+
+        if (definition == null)
+            definition = ndef.getContainingScope().getDefinition();
+
         write(definition.getQualifiedName()
                 + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
                 + node.getName());
 
         IExpressionNode vnode = node.getAssignedValueNode();
-        if (vnode != null)
+        if (vnode != null && !(vnode instanceof IEmbedNode))
         {
             write(ASEmitterTokens.SPACE);
             writeToken(ASEmitterTokens.EQUAL);
@@ -363,75 +311,55 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
                 }
             }
         }
-    }
-
-    @Override
-    public void emitVarDeclaration(IVariableNode node)
-    {
-        if (!(node instanceof ChainedVariableNode))
-        {
-            emitMemberKeyword(node);
-        }
-
-        IExpressionNode avnode = node.getAssignedValueNode();
-        if (avnode != null)
-        {
-            IDefinition def = avnode.resolveType(getWalker().getProject());
-
-            String opcode = avnode.getNodeID().getParaphrase();
-            if (opcode != "AnonymousFunction")
-                getDoc().emitVarDoc(node, def);
-        }
-        else
-        {
-            getDoc().emitVarDoc(node, null);
-        }
-
-        emitDeclarationName(node);
-        if (!(avnode instanceof IEmbedNode))
-        	emitAssignedValue(avnode);
-
-        if (!(node instanceof ChainedVariableNode))
+        if (node.getNodeID() == ASTNodeID.BindableVariableID)
         {
-            // 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);
-                    emitVarDeclaration((IVariableNode) child);
-                }
-            }
+            // [Bindable]
+            writeNewline(ASEmitterTokens.SEMICOLON.getToken());
+            writeNewline();
+            writeNewline("/**");
+            writeNewline("@expose");
+            writeNewline(" */");
+            writeNewline(definition.getQualifiedName()
+                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
+                    + "get_" + node.getName()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.EQUAL.getToken()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
+                    + ASEmitterTokens.PAREN_OPEN.getToken() + ASEmitterTokens.PAREN_CLOSE.getToken()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
+            writeNewline(ASEmitterTokens.RETURN.getToken() + ASEmitterTokens.SPACE.getToken()
+                    + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+                    + node.getName() + ASEmitterTokens.SEMICOLON.getToken());
+            writeNewline(ASEmitterTokens.BLOCK_CLOSE.getToken() + ASEmitterTokens.SEMICOLON.getToken());
+            writeNewline();
+            writeNewline("/**");
+            writeNewline("@expose");
+            writeNewline(" */");
+            writeNewline(definition.getQualifiedName()
+                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
+                    + "set_" + node.getName()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.EQUAL.getToken()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.FUNCTION.getToken()
+                    + ASEmitterTokens.PAREN_OPEN.getToken() + "value" + ASEmitterTokens.PAREN_CLOSE.getToken()
+                    + ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.BLOCK_OPEN.getToken());
+            writeNewline("if (value != " + ASEmitterTokens.THIS.getToken()
+                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName() + ") {");
+            writeNewline("    var oldValue = "
+                    + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+                    + node.getName() + ASEmitterTokens.SEMICOLON.getToken());
+            writeNewline("    " + ASEmitterTokens.THIS.getToken() + ASEmitterTokens.MEMBER_ACCESS.getToken()
+                    + node.getName() + " = value;");
+            writeNewline("    this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(");
+            writeNewline("         this, \"" + node.getName() + "\", oldValue, value));");
+            writeNewline("}");
+            write(ASEmitterTokens.BLOCK_CLOSE.getToken());
+            
+            
         }
     }
 
     @Override
-    public void emitGetAccessor(IGetterNode node)
-    {
-        emitObjectDefineProperty(node);
-    }
-
-    @Override
-    public void emitSetAccessor(ISetterNode node)
-    {
-        emitObjectDefineProperty(node);
-    }
-
     protected void emitAccessors(IAccessorNode node)
     {
-        String qname = node.getQualifiedName();
-        if (!propertyNames.contains(qname))
-        {
-            emitField(node);
-            write(ASEmitterTokens.SEMICOLON);
-            writeNewline();
-            writeNewline();
-
-            propertyNames.add(qname);
-        }
-
         if (node.getNodeID() == ASTNodeID.GetterID)
         {
             emitGetAccessor((IGetterNode) node);
@@ -446,7 +374,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
     public void emitMethod(IFunctionNode node)
     {
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(new ArrayList<ICompilerProblem>());
+        fn.parseFunctionBody(getProblems());
 
         ICompilerProject project = getWalker().getProject();
 
@@ -495,7 +423,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
 
         if (isConstructor && hasSuperClass)
         {
-            writeNewline();
+            writeNewline(ASEmitterTokens.SEMICOLON);
             write(JSGoogEmitterTokens.GOOG_INHERITS);
             write(ASEmitterTokens.PAREN_OPEN);
             write(qname);
@@ -518,16 +446,67 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         ASTNodeID id = cnode.getNodeID();
         if (id != ASTNodeID.SuperID)
         {
+            ICompilerProject project = null;
+            IDefinition def = null;
+
+            boolean isClassCast = false;
+
             if (node.isNewExpression())
             {
                 writeToken(ASEmitterTokens.NEW);
             }
+            else
+            {
+                if (project == null)
+                    project = getWalker().getProject();
 
-            getWalker().walk(node.getNameNode());
+                def = node.getNameNode().resolve(project);
 
-            write(ASEmitterTokens.PAREN_OPEN);
-            walkArguments(node.getArgumentNodes());
-            write(ASEmitterTokens.PAREN_CLOSE);
+                isClassCast = (def instanceof ClassDefinition ||
+                        def instanceof InterfaceDefinition) && 
+                        !(NativeUtils.isJSNative(def.getBaseName()));
+            }
+
+            if (node.isNewExpression())
+            {
+                if (project == null)
+                    project = getWalker().getProject();
+
+                def = node.resolveCalledExpression(project);
+                // all new calls to a class should be fully qualified names
+                if (def instanceof ClassDefinition)
+                    write(def.getQualifiedName());
+                else
+                    // I think we still need this for "new someVarOfTypeClass"
+                    getWalker().walk(node.getNameNode());
+                write(ASEmitterTokens.PAREN_OPEN);
+                walkArguments(node.getArgumentNodes());
+                write(ASEmitterTokens.PAREN_CLOSE);
+            }
+            else if (!isClassCast)
+            {
+                if (def != null)
+                {
+                    boolean isInt = def.getBaseName().equals(IASGlobalFunctionConstants._int);
+                    if (isInt ||
+                        def.getBaseName().equals(IASGlobalFunctionConstants.trace) ||
+                        def.getBaseName().equals(IASGlobalFunctionConstants.uint))
+                    {
+                        write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+                        write(ASEmitterTokens.MEMBER_ACCESS);
+                        if (isInt)
+                            write(JSFlexJSEmitterTokens.UNDERSCORE);                        
+                    }
+                }
+                getWalker().walk(node.getNameNode());
+                write(ASEmitterTokens.PAREN_OPEN);
+                walkArguments(node.getArgumentNodes());
+                write(ASEmitterTokens.PAREN_CLOSE);
+            }
+            else
+            {
+                emitIsAs(node.getArgumentNodes()[0], node.getNameNode(), ASTNodeID.Op_AsID, true);
+            }
         }
         else
         {
@@ -535,140 +514,361 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    //--------------------------------------------------------------------------
+
     @Override
-    public void emitIdentifier(IIdentifierNode node)
+    protected void emitSelfReference(IFunctionNode node)
     {
-        ICompilerProject project = getWalker().getProject();
+        // we don't want 'var self = this;' in FlexJS
+    }
 
-        IClassNode cnode = (IClassNode) node
+    private boolean writeThis(IIdentifierNode node)
+    {
+        if (node instanceof NonResolvingIdentifierNode)
+            return false;
+        
+        IClassNode classNode = (IClassNode) node
                 .getAncestorOfType(IClassNode.class);
 
-        IDefinition def = ((IIdentifierNode) node).resolve(project);
+        IDefinition nodeDef = ((IIdentifierNode) node).resolve(project);
 
-        ITypeDefinition type = ((IIdentifierNode) node).resolveType(project);
+        IASNode parentNode = node.getParent();
+        ASTNodeID parentNodeId = parentNode.getNodeID();
 
-        IASNode pnode = node.getParent();
-        ASTNodeID inode = pnode.getNodeID();
+        IASNode firstChild = parentNode.getChild(0);
 
-        boolean writeSelf = false;
-        if (cnode != null)
+        boolean identifierIsMemberAccess = parentNodeId == ASTNodeID.MemberAccessExpressionID;
+
+        if (classNode == null) // script in MXML and AS interface definitions
         {
-            IDefinitionNode[] members = cnode.getAllMemberNodes();
-            for (IDefinitionNode mnode : members)
+            if (nodeDef instanceof ParameterDefinition)
+                return false;
+            
+            if (nodeDef instanceof VariableDefinition)
             {
-                if ((type != null && type.getQualifiedName().equalsIgnoreCase(
-                        IASLanguageConstants.Function))
-                        || (def != null && def.getQualifiedName()
-                                .equalsIgnoreCase(mnode.getQualifiedName())))
-                {
-                    if (!(pnode instanceof FunctionNode)
-                            && inode != ASTNodeID.MemberAccessExpressionID)
-                    {
-                        writeSelf = true;
-                        break;
-                    }
-                    else if (inode == ASTNodeID.MemberAccessExpressionID
-                            && !def.isStatic())
-                    {
-                        String tname = type.getQualifiedName();
-                        writeSelf = !tname.equalsIgnoreCase(cnode
-                                .getQualifiedName())
-                                && !tname.equals(IASLanguageConstants.Function);
-                        break;
-                    }
-                }
+                IDefinition pdef = ((VariableDefinition) nodeDef).getParent();
+
+                if (thisClass == null || !isSameClass(pdef, thisClass, project))
+                    return false;
+
+                if (identifierIsMemberAccess)
+                    return node == firstChild;
+
+                return parentNodeId == ASTNodeID.ContainerID
+                        || !(parentNode instanceof ParameterNode);
             }
-        }
+            else if (nodeDef instanceof AccessorDefinition)
+            {
+                IDefinition pdef = ((AccessorDefinition) nodeDef).getParent();
 
-        boolean isRunningInTestMode = cnode != null
-                && cnode.getQualifiedName().equalsIgnoreCase("FalconTest_A");
-        if (writeSelf && !isRunningInTestMode)
-        {
-            write(JSGoogEmitterTokens.SELF);
-            write(ASEmitterTokens.MEMBER_ACCESS);
+                if (thisClass == null || !isSameClass(pdef, thisClass, project))
+                    return false;
+
+                if (identifierIsMemberAccess)
+                    return node == firstChild;
+
+                return true;
+            }
+            else if (parentNodeId == ASTNodeID.ContainerID
+                    && nodeDef instanceof FunctionDefinition)
+            {
+                return ((FunctionDefinition) nodeDef)
+                        .getFunctionClassification() == FunctionClassification.CLASS_MEMBER; // for 'goog.bind'
+            }
+            else
+            {
+                return parentNodeId == ASTNodeID.FunctionCallID
+                        && !(nodeDef instanceof AccessorDefinition)
+                        && !identifierIsMemberAccess;
+            }
         }
         else
         {
-            String pname = (type != null) ? type.getPackageName() : "";
-            if (cnode != null
-                    && pname != ""
-                    && !pname.equalsIgnoreCase(cnode.getPackageName())
-                    && inode != ASTNodeID.ArgumentID
-                    && inode != ASTNodeID.VariableID
-                    && inode != ASTNodeID.TypedExpressionID)
+            if (nodeDef != null
+                    && !nodeDef.isInternal()
+                    && isClassMember(nodeDef, classNode))
             {
-                write(pname);
-                write(ASEmitterTokens.MEMBER_ACCESS);
+                if (identifierIsMemberAccess)
+                {
+                	if (parentNode.getNodeID() == ASTNodeID.MemberAccessExpressionID
+                            && parentNode.getChild(0).getNodeID() == ASTNodeID.SuperID
+                            && !isSuperCallForOverride(node))
+                	{
+                		return true;
+                	}
+                	
+                    return node == firstChild;
+                }
+                else
+                {
+                    boolean identifierIsLocalFunction = nodeDef instanceof FunctionDefinition
+                            && !(nodeDef instanceof AccessorDefinition)
+                            && ((FunctionDefinition) nodeDef)
+                                    .getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL;
+
+                    return !identifierIsLocalFunction;
+                }
             }
         }
 
-        super.emitIdentifier(node);
+        return false;
     }
 
-    @Override
-    public void emitFunctionBlockHeader(IFunctionNode node)
+    private boolean isClassMember(IDefinition nodeDef, IClassNode classNode)
     {
-        IDefinition def = node.getDefinition();
-        boolean isStatic = false;
-        if (def != null && def.isStatic())
-            isStatic = true;
-        boolean isLocal = false;
-        if (node.getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL)
-            isLocal = true;
-        if (hasBody(node) && !isStatic && !isLocal)
-            emitSelfReference(node);
+        TypeScope cscope = (TypeScope) classNode.getDefinition()
+                .getContainedScope();
 
-        if (node.isConstructor()
-                && hasSuperClass(node) && !hasSuperCall(node.getScopedNode()))
-            emitSuperCall(node, CONSTRUCTOR_FULL);
+        Set<INamespaceDefinition> nsSet = cscope.getNamespaceSet(project);
+        Collection<IDefinition> defs = new HashSet<IDefinition>();
 
-        emitRestParameterCodeBlock(node);
+        cscope.getAllPropertiesForMemberAccess((CompilerProject) project, defs,
+                nsSet);
 
-        emitDefaultParameterCodeBlock(node);
-    }
+        Iterator<IDefinition> visiblePropertiesIterator = defs.iterator();
+        while (visiblePropertiesIterator.hasNext())
+        {
+            if (nodeDef.getQualifiedName().equals(
+                    visiblePropertiesIterator.next().getQualifiedName()))
+                return true;
+        }
 
-    protected void emitSelfReference(IFunctionNode node)
-    {
-        writeToken(ASEmitterTokens.VAR);
-        writeToken(JSGoogEmitterTokens.SELF);
-        writeToken(ASEmitterTokens.EQUAL);
-        write(ASEmitterTokens.THIS);
-        writeNewline(ASEmitterTokens.SEMICOLON);
+        return false;
     }
 
-    protected void emitSuperCall(IASNode node, String type)
+    private boolean isSameClass(IDefinition pdef, IDefinition thisClass,
+            ICompilerProject project)
     {
-        IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
-                : null;
-        IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
-                : null;
+        if (pdef == thisClass)
+            return true;
 
-        if (type == CONSTRUCTOR_EMPTY)
-        {
-            indentPush();
-            writeNewline();
-            indentPop();
-        }
-        else if (type == SUPER_FUNCTION_CALL)
+        IDefinition cdef = ((ClassDefinition) thisClass).resolveBaseClass(project);
+        while (cdef != null)
         {
-            if (fnode == null)
-                fnode = (IFunctionNode) fcnode
-                        .getAncestorOfType(IFunctionNode.class);
+            // needs to be a loop
+            if (cdef == pdef)
+                return true;
+            cdef = ((ClassDefinition) cdef).resolveBaseClass(project);
         }
+        return false;
+    }
+
+    @Override
+    public void emitIdentifier(IIdentifierNode node)
+    {
+        if (project == null)
+            project = getWalker().getProject();
+
+        IDefinition nodeDef = ((IIdentifierNode) node).resolve(project);
+
+        IASNode parentNode = node.getParent();
+        ASTNodeID parentNodeId = parentNode.getNodeID();
+
+        boolean identifierIsAccessorFunction = nodeDef instanceof AccessorDefinition;
+        boolean identifierIsPlainFunction = nodeDef instanceof FunctionDefinition
+                && !identifierIsAccessorFunction;
+
+        boolean emitName = true;
+
+        if (nodeDef != null
+                && nodeDef.isStatic())
+        {
+            String sname = nodeDef.getParent().getQualifiedName();
+            if (sname.length() > 0)
+            {
+                write(sname);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+            }
+        }
+        else if (!NativeUtils.isNative(node.getName()))
+        {
+            // an instance method as a parameter or
+            // a local function
+            boolean useGoogBind = (parentNodeId == ASTNodeID.ContainerID
+                    && identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
+                    .getFunctionClassification() == FunctionClassification.CLASS_MEMBER)
+                    || (identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
+                            .getFunctionClassification() == FunctionClassification.LOCAL);
+
+            if (useGoogBind)
+            {
+                write(JSGoogEmitterTokens.GOOG_BIND);
+                write(ASEmitterTokens.PAREN_OPEN);
+            }
+
+            if (writeThis(node))
+            {
+                write(ASEmitterTokens.THIS);
+
+                write(ASEmitterTokens.MEMBER_ACCESS);
+            }
+
+            if (useGoogBind)
+            {
+                write(node.getName());
+
+                writeToken(ASEmitterTokens.COMMA);
+                write(ASEmitterTokens.THIS);
+                write(ASEmitterTokens.PAREN_CLOSE);
+
+                emitName = false;
+            }
+        }
+
+        IDefinition parentDef = (nodeDef != null) ? nodeDef.getParent() : null;
+        boolean isNative = (parentDef != null)
+                && NativeUtils.isNative(parentDef.getBaseName());
+        if ((identifierIsAccessorFunction && !isNative)
+                || (nodeDef instanceof VariableDefinition && ((VariableDefinition) nodeDef)
+                        .isBindable()))
+        {
+            IASNode anode = node
+                    .getAncestorOfType(BinaryOperatorAssignmentNode.class);
+
+            boolean isAssignment = false;
+            if (anode != null)
+            {
+                IASNode leftNode = anode.getChild(0);
+                if (anode == parentNode)
+                {
+                    if (node == leftNode)
+                        isAssignment = true;
+                }
+                else
+                {
+                    IASNode pnode = parentNode;
+                    IASNode thisNode = node;
+                    while (anode != pnode)
+                    {
+                        if (pnode instanceof IMemberAccessExpressionNode)
+                        {
+                            if (thisNode != pnode.getChild(1))
+                            {
+                                // can't be an assignment because 
+                                // we're on the left side of a memberaccessexpression
+                                break;
+                            }
+                        }
+                        if (pnode == leftNode)
+                        {
+                            isAssignment = true;
+                        }
+                        thisNode = pnode;
+                        pnode = pnode.getParent();
+                    }
+                }
+                String op = ((IBinaryOperatorNode) anode).getOperator()
+                        .getOperatorText();
+                if (op.contains("==") || !op.contains("="))
+                    isAssignment = false;
+            }
+
+            if (parentNode.getNodeID() == ASTNodeID.MemberAccessExpressionID
+                    && parentNode.getChild(0).getNodeID() == ASTNodeID.SuperID
+                    && isSuperCallForOverride(node))
+            {
+                IClassNode cnode = (IClassNode) node
+                        .getAncestorOfType(IClassNode.class);
+
+                // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+                if (cnode == null)
+                    return;
+                
+                write(cnode.getQualifiedName());
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSGoogEmitterTokens.GOOG_BASE);
+                write(ASEmitterTokens.PAREN_OPEN);
+                write(ASEmitterTokens.THIS);
+                writeToken(ASEmitterTokens.COMMA);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                writeGetSetPrefix(!isAssignment);
+                write(nodeDef.getQualifiedName());
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                if (isAssignment)
+                {
+                    writeToken(ASEmitterTokens.COMMA);
+                }
+            }
+            else if (node instanceof NonResolvingIdentifierNode)
+            {
+                write(node.getName());
+            }
+            else
+            {
+                writeGetSetPrefix(!isAssignment);
+                write(node.getName());
+                write(ASEmitterTokens.PAREN_OPEN);
+            }
+
+            if (anode != null && isAssignment)
+            {
+                getWalker().walk(((BinaryOperatorAssignmentNode) anode)
+                        .getRightOperandNode());
+            }
+
+            if (!(node instanceof NonResolvingIdentifierNode))
+            	write(ASEmitterTokens.PAREN_CLOSE);
+        }
+        else if (emitName)
+        {
+            if (nodeDef != null)    
+                write(nodeDef.getQualifiedName());
+            else
+                write(node.getName());
+        }
+    }
+
+    private boolean isSuperCallForOverride(IIdentifierNode node)
+    {
+    	IFunctionNode pfnode = (IFunctionNode) node.
+    			getAncestorOfType(FunctionNode.class);
+
+    	if (pfnode == null)
+    		return false;
+    	
+    	return pfnode.getName().equals(node.getName());
+    }
+    
+    //--------------------------------------------------------------------------
+
+    @Override
+    protected void emitSuperCall(IASNode node, String type)
+    {
+        IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
+                : null;
+        IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
+                : null;
+
+        if (type == CONSTRUCTOR_EMPTY)
+        {
+            indentPush();
+            writeNewline();
+            indentPop();
+        }
+        else if (type == SUPER_FUNCTION_CALL)
+        {
+            if (fnode == null)
+                fnode = (IFunctionNode) fcnode
+                        .getAncestorOfType(IFunctionNode.class);
+        }
+
+        if (fnode != null && fnode.isConstructor() && !hasSuperClass(fnode))
+            return;
 
-        if (fnode.isConstructor() && !hasSuperClass(fnode))
-            return;
-
         IClassNode cnode = (IClassNode) node
                 .getAncestorOfType(IClassNode.class);
 
+        // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+        if (cnode == null)
+            return;
+        
         write(cnode.getQualifiedName());
         write(ASEmitterTokens.MEMBER_ACCESS);
         write(JSGoogEmitterTokens.GOOG_BASE);
         write(ASEmitterTokens.PAREN_OPEN);
         write(ASEmitterTokens.THIS);
 
-        if (fnode.isConstructor())
+        if (fnode != null && fnode.isConstructor())
         {
             writeToken(ASEmitterTokens.COMMA);
             write(ASEmitterTokens.SINGLE_QUOTE);
@@ -680,7 +880,15 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         {
             writeToken(ASEmitterTokens.COMMA);
             write(ASEmitterTokens.SINGLE_QUOTE);
-            write(fnode.getName());
+            if (fnode.getNodeID() == ASTNodeID.GetterID
+                    || fnode.getNodeID() == ASTNodeID.SetterID)
+                writeGetSetPrefix(fnode.getNodeID() == ASTNodeID.GetterID);
+            
+            // (erikdebruin): write(fnode.getName());
+            IMemberAccessExpressionNode aenode = 
+            		(IMemberAccessExpressionNode) fcnode.getNameNode();
+            write(((IIdentifierNode) aenode.getRightOperandNode()).getName());
+            
             write(ASEmitterTokens.SINGLE_QUOTE);
         }
 
@@ -692,12 +900,29 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
 
             writeArguments = anodes.length > 0;
         }
-        else if (fnode.isConstructor())
+        else if (fnode != null && fnode.isConstructor())
         {
             anodes = fnode.getParameterNodes();
 
             writeArguments = (anodes != null && anodes.length > 0);
         }
+        else if (fnode == null && node instanceof BinaryOperatorAssignmentNode)
+        {
+            BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node;
+            
+            IFunctionNode pnode = (IFunctionNode) bnode.getAncestorOfType(IFunctionNode.class);
+            
+            if (pnode.getNodeID() == ASTNodeID.SetterID)
+            {
+                writeToken(ASEmitterTokens.COMMA);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                writeGetSetPrefix(false);
+                getWalker().walk(bnode.getLeftOperandNode());
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                writeToken(ASEmitterTokens.COMMA);
+                getWalker().walk(bnode.getRightOperandNode());
+            }
+        }
 
         if (writeArguments)
         {
@@ -723,6 +948,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
+    @Override
     protected void emitDefaultParameterCodeBlock(IFunctionNode node)
     {
         IParameterNode[] pnodes = node.getParameterNodes();
@@ -738,7 +964,7 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
             if (!hasBody(node))
             {
                 indentPush();
-                write(ASEmitterTokens.INDENT);
+                write(JSFlexJSEmitterTokens.INDENT);
             }
 
             List<IParameterNode> parameters = new ArrayList<IParameterNode>(
@@ -787,141 +1013,187 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         }
     }
 
-    private void emitRestParameterCodeBlock(IFunctionNode node)
+    @Override
+    public void emitBinaryOperator(IBinaryOperatorNode node)
     {
-        IParameterNode[] pnodes = node.getParameterNodes();
+        ASTNodeID id = node.getNodeID();
+        if (id == ASTNodeID.Op_InID
+                || id == ASTNodeID.Op_LogicalAndAssignID
+                || id == ASTNodeID.Op_LogicalOrAssignID)
+        {
+            super.emitBinaryOperator(node);
+        }
+        else if (id == ASTNodeID.Op_IsID || id == ASTNodeID.Op_AsID)
+        {
+            emitIsAs(node.getLeftOperandNode(), node.getRightOperandNode(), id, false);
+        }
+        else if (id == ASTNodeID.Op_InstanceOfID)
+        {
+            getWalker().walk(node.getLeftOperandNode());
 
-        IParameterNode rest = getRest(pnodes);
-        if (rest != null)
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.INSTANCEOF);
+            
+            IDefinition dnode = (node.getRightOperandNode()).resolve(project);
+            if (dnode != null)
+                write(dnode.getQualifiedName());
+            else
+                getWalker().walk(node.getRightOperandNode());
+        }
+        else
         {
-            final StringBuilder code = new StringBuilder();
+            IExpressionNode leftSide = node.getLeftOperandNode();
 
-            /* x = Array.prototype.slice.call(arguments, y);\n */
-            code.append(rest.getName());
-            code.append(ASEmitterTokens.SPACE.getToken());
-            code.append(ASEmitterTokens.EQUAL.getToken());
-            code.append(ASEmitterTokens.SPACE.getToken());
-            code.append(BuiltinType.ARRAY.getName());
-            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
-            code.append(JSEmitterTokens.PROTOTYPE.getToken());
-            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
-            code.append(JSEmitterTokens.SLICE.getToken());
-            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
-            code.append(JSEmitterTokens.CALL.getToken());
-            code.append(ASEmitterTokens.PAREN_OPEN.getToken());
-            code.append(JSEmitterTokens.ARGUMENTS.getToken());
-            code.append(ASEmitterTokens.COMMA.getToken());
-            code.append(ASEmitterTokens.SPACE.getToken());
-            code.append(String.valueOf(pnodes.length - 1));
-            code.append(ASEmitterTokens.PAREN_CLOSE.getToken());
-            code.append(ASEmitterTokens.SEMICOLON.getToken());
-
-            write(code.toString());
+            IExpressionNode property = null;
+            int leftSideChildCount = leftSide.getChildCount();
+            if (leftSideChildCount > 0)
+            {
+                IASNode childNode = leftSide.getChild(leftSideChildCount - 1);
+                if (childNode instanceof IExpressionNode)
+                    property = (IExpressionNode) childNode;
+                else
+                    property = leftSide;
+            }
+            else
+                property = leftSide;
 
-            writeNewline();
-        }
-    }
+            IDefinition def = null;
+            if (property instanceof IIdentifierNode)
+                def = ((IIdentifierNode) property).resolve(getWalker()
+                        .getProject());
 
-    @Override
-    public void emitParameter(IParameterNode node)
-    {
-        getWalker().walk(node.getNameExpressionNode());
-    }
+            boolean isSuper = false;
+            if (leftSide.getNodeID() == ASTNodeID.MemberAccessExpressionID)
+            {
+                IASNode cnode = leftSide.getChild(0);
+                ASTNodeID cId = cnode.getNodeID();
 
-    @Override
-    protected void emitAssignedValue(IExpressionNode node)
-    {
-        if (node != null)
-        {
-            write(ASEmitterTokens.SPACE);
-            writeToken(ASEmitterTokens.EQUAL);
-            if (node.getNodeID() == ASTNodeID.ClassReferenceID)
+                isSuper = cId == ASTNodeID.SuperID;
+            }
+
+            String op = node.getOperator().getOperatorText();
+            boolean isAssignment = !(op.contains("==") || !op.contains("="));
+
+            if (def instanceof AccessorDefinition && isAssignment)
+            {
+                getWalker().walk(leftSide);
+            }
+            else if (isSuper) 
             {
-                IDefinition definition = node.resolve(getWalker().getProject());
-                write(definition.getQualifiedName());
+                emitSuperCall(node, "");
             }
             else
             {
-                getWalker().walk(node);
+                if (ASNodeUtils.hasParenOpen(node))
+                    write(ASEmitterTokens.PAREN_OPEN);
+
+                getWalker().walk(leftSide);
+
+                if (node.getNodeID() != ASTNodeID.Op_CommaID)
+                    write(ASEmitterTokens.SPACE);
+
+                writeToken(node.getOperator().getOperatorText());
+
+                getWalker().walk(node.getRightOperandNode());
+
+                if (ASNodeUtils.hasParenClose(node))
+                    write(ASEmitterTokens.PAREN_CLOSE);
             }
         }
     }
 
-    @Override
-    public void emitTypedExpression(ITypedExpressionNode node)
-    {
-        getWalker().walk(node.getCollectionNode());
-    }
-
-    @Override
-    public void emitForEachLoop(IForLoopNode node)
+    private void emitIsAs(IExpressionNode left, IExpressionNode right, 
+            ASTNodeID id, boolean coercion)
     {
-        IContainerNode xnode = (IContainerNode) node.getChild(1);
-        IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
-                .getConditionalsContainerNode().getChild(0);
-        IASNode childNode = bnode.getChild(0);
-
-        write(JSGoogEmitterTokens.GOOG_ARRAY_FOREACH);
+        write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        if (id == ASTNodeID.Op_IsID)
+            write(ASEmitterTokens.IS);
+        else
+            write(ASEmitterTokens.AS);
         write(ASEmitterTokens.PAREN_OPEN);
-        getWalker().walk(bnode.getChild(1));
+        getWalker().walk(left);
         writeToken(ASEmitterTokens.COMMA);
-        writeToken(ASEmitterTokens.FUNCTION);
-        write(ASEmitterTokens.PAREN_OPEN);
-        if (childNode instanceof IVariableExpressionNode)
-            write(((IVariableNode) childNode.getChild(0)).getName());
+
+        IDefinition dnode = (right).resolve(project);
+        if (dnode != null)
+            write(dnode.getQualifiedName());
         else
-            write(((IIdentifierNode) childNode).getName());
-        writeToken(ASEmitterTokens.PAREN_CLOSE);
-        if (isImplicit(xnode))
-            write(ASEmitterTokens.BLOCK_OPEN);
-        getWalker().walk(node.getStatementContentsNode());
-        if (isImplicit(xnode))
+            getWalker().walk(right);
+        
+        if (coercion) 
         {
-            writeNewline();
-            write(ASEmitterTokens.BLOCK_CLOSE);
+            writeToken(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.TRUE);
         }
+        
         write(ASEmitterTokens.PAREN_CLOSE);
     }
-
-    public JSVF2JSEmitter(FilterWriter out)
+    
+    @Override
+    public void emitMemberAccessExpression(IMemberAccessExpressionNode node)
     {
-        super(out);
-    }
+        IASNode leftNode = node.getLeftOperandNode();
+        IASNode rightNode = node.getRightOperandNode();
 
-    protected Map<Integer, IParameterNode> getDefaults(IParameterNode[] nodes)
-    {
-        Map<Integer, IParameterNode> result = new HashMap<Integer, IParameterNode>();
-        int i = 0;
-        boolean hasDefaults = false;
-        for (IParameterNode node : nodes)
+        if (project == null)
+            project = getWalker().getProject();
+
+        IDefinition def = node.resolve(project);
+        boolean isStatic = false;
+        if (def != null && def.isStatic())
+            isStatic = true;
+
+        boolean continueWalk = true;
+        if (!isStatic)
         {
-            if (node.hasDefaultValue())
+            if (!(leftNode instanceof ILanguageIdentifierNode && ((ILanguageIdentifierNode) leftNode)
+                        .getKind() == ILanguageIdentifierNode.LanguageIdentifierKind.THIS))
             {
-                hasDefaults = true;
-                result.put(i, node);
+            	if (rightNode instanceof UnaryOperatorAtNode)
+                {
+            		// ToDo (erikdebruin): properly handle E4X
+            		
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                    getWalker().walk(node.getLeftOperandNode());
+                    write(ASEmitterTokens.SQUARE_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write("E4XOperator");
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.SQUARE_CLOSE);
+                    continueWalk = false;
+                }
+            	else if (node.getNodeID() == ASTNodeID.Op_DescendantsID)
+            	{
+            		// ToDo (erikdebruin): properly handle E4X
+            		
+                    write(ASEmitterTokens.THIS);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                    getWalker().walk(node.getLeftOperandNode());
+                    write(ASEmitterTokens.SQUARE_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write("E4XSelector");
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.SQUARE_CLOSE);
+                    continueWalk = false;
+            	}
+            	else if (leftNode.getNodeID() != ASTNodeID.SuperID)
+                {
+                    getWalker().walk(node.getLeftOperandNode());
+                    write(node.getOperator().getOperatorText());
+                }
             }
             else
             {
-                result.put(i, null);
+                write(ASEmitterTokens.THIS);
+                write(node.getOperator().getOperatorText());
             }
-            i++;
-        }
-
-        if (!hasDefaults)
-            return null;
-
-        return result;
-    }
-
-    private IParameterNode getRest(IParameterNode[] nodes)
-    {
-        for (IParameterNode node : nodes)
-        {
-            if (node.isRest())
-                return node;
+        
         }
-
-        return null;
+        
+        if (continueWalk)
+        	getWalker().walk(node.getRightOperandNode());
     }
 
     private static ITypeDefinition getTypeDefinition(IDefinitionNode node)
@@ -930,13 +1202,6 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         return (ITypeDefinition) tnode.getDefinition();
     }
 
-    protected static IClassDefinition getClassDefinition(IDefinitionNode node)
-    {
-        IClassNode tnode = (IClassNode) node
-                .getAncestorOfType(IClassNode.class);
-        return (tnode != null) ? tnode.getDefinition() : null;
-    }
-
     private static IClassDefinition getSuperClassDefinition(
             IDefinitionNode node, ICompilerProject project)
     {
@@ -946,211 +1211,470 @@ public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
         return superClass;
     }
 
-    protected boolean hasSuperClass(IDefinitionNode node)
-    {
-        ICompilerProject project = getWalker().getProject();
-        IClassDefinition superClassDefinition = getSuperClassDefinition(node,
-                project);
-        // XXX (mschmalle) this is nulling for MXML super class, figure out why
-        if (superClassDefinition == null)
-            return false;
-        String qname = superClassDefinition.getQualifiedName();
-        return superClassDefinition != null
-                && !qname.equals(IASLanguageConstants.Object);
-    }
-
-    private boolean hasSuperCall(IScopedNode node)
-    {
-        for (int i = node.getChildCount() - 1; i > -1; i--)
-        {
-            IASNode cnode = node.getChild(i);
-            if (cnode.getNodeID() == ASTNodeID.FunctionCallID
-                    && cnode.getChild(0).getNodeID() == ASTNodeID.SuperID)
-                return true;
-        }
-
-        return false;
-    }
-
-    protected static boolean hasBody(IFunctionNode node)
-    {
-        IScopedNode scope = node.getScopedNode();
-        return scope.getChildCount() > 0;
-    }
-
+    @Override
     protected void emitObjectDefineProperty(IAccessorNode node)
     {
-        /*
-        Object.defineProperty(
-            A.prototype, 
-            'foo', 
-            {get: function() {return -1;}, 
-            configurable: true}
-         );
-        */
-
         FunctionNode fn = (FunctionNode) node;
         fn.parseFunctionBody(getProblems());
 
-        // head
-        write(JSGoogEmitterTokens.OBJECT);
-        write(ASEmitterTokens.MEMBER_ACCESS);
-        write(JSEmitterTokens.DEFINE_PROPERTY);
-        writeNewline(ASEmitterTokens.PAREN_OPEN, true);
-
-        // Type
         IFunctionDefinition definition = node.getDefinition();
         ITypeDefinition type = (ITypeDefinition) definition.getParent();
+
+        // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+        if (type == null)
+            return;
+        
+        if (project == null)
+            project = getWalker().getProject();
+
+        getDoc().emitMethodDoc(fn, project);
         write(type.getQualifiedName());
         if (!node.hasModifier(ASModifier.STATIC))
         {
             write(ASEmitterTokens.MEMBER_ACCESS);
             write(JSEmitterTokens.PROTOTYPE);
         }
-        writeToken(ASEmitterTokens.COMMA);
-        writeNewline();
 
-        // name
-        write(ASEmitterTokens.SINGLE_QUOTE);
-        write(definition.getBaseName());
-        write(ASEmitterTokens.SINGLE_QUOTE);
-        writeToken(ASEmitterTokens.COMMA);
-        writeNewline();
-
-        // info object
-        // declaration
-        write(ASEmitterTokens.BLOCK_OPEN);
-        write(node.getNodeID() == ASTNodeID.GetterID ? ASEmitterTokens.GET
-                : ASEmitterTokens.SET);
-        write(ASEmitterTokens.COLON);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        writeGetSetPrefix(node instanceof IGetterNode);
+        writeToken(node.getName());
+        writeToken(ASEmitterTokens.EQUAL);
         write(ASEmitterTokens.FUNCTION);
         emitParameters(node.getParameterNodes());
-
+        //writeNewline();
         emitMethodScope(node.getScopedNode());
-
-        writeToken(ASEmitterTokens.COMMA);
-        write(JSEmitterTokens.CONFIGURABLE);
-        write(ASEmitterTokens.COLON);
-        write(ASEmitterTokens.TRUE);
-        writeNewline(ASEmitterTokens.BLOCK_CLOSE, false);
-
-        // tail, no colon; parent container will add it
-        write(ASEmitterTokens.PAREN_CLOSE);
     }
 
-    //--------------------------------------------------------------------------
-    // Operators
-    //--------------------------------------------------------------------------
-
-    @Override
-    public void emitNamespaceAccessExpression(INamespaceAccessExpressionNode node)
+    private void writeGetSetPrefix(boolean isGet)
     {
-        getWalker().walk(node.getLeftOperandNode());
-        write(ASEmitterTokens.MEMBER_ACCESS);
-        getWalker().walk(node.getRightOperandNode());
+        if (isGet)
+            write(ASEmitterTokens.GET);
+        else
+            write(ASEmitterTokens.SET);
+        write("_");
     }
 
     @Override
-    public void emitAsOperator(IBinaryOperatorNode node)
+    public IDocEmitter getDocEmitter()
     {
-        emitBinaryOperator(node);
+        return new JSVF2JSDocEmitter(this);
     }
 
     @Override
-    public void emitIsOperator(IBinaryOperatorNode node)
+    public void emitPackageHeader(IPackageDefinition definition)
     {
-        emitBinaryOperator(node);
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
+
+        writeNewline("/**");
+        writeNewline(" * " + type.getQualifiedName());
+        writeNewline(" *");
+        writeNewline(" * @fileoverview");
+        writeNewline(" *");
+        writeNewline(" * @suppress {checkTypes}");
+        writeNewline(" */");
+        writeNewline();
+        
+        /* goog.provide('x');\n\n */
+        write(JSGoogEmitterTokens.GOOG_PROVIDE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(type.getQualifiedName());
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        writeNewline(ASEmitterTokens.SEMICOLON);
+        writeNewline();
     }
 
     @Override
-    public void emitBinaryOperator(IBinaryOperatorNode node)
+    public void emitPackageHeaderContents(IPackageDefinition definition)
     {
-        if (ASNodeUtils.hasParenOpen(node))
-            write(ASEmitterTokens.PAREN_OPEN);
+        PackageScope containedScope = (PackageScope) definition
+                .getContainedScope();
 
-        ASTNodeID id = node.getNodeID();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
 
-        if (id == ASTNodeID.Op_IsID)
+        if (project == null)
+            project = getWalker().getProject();
+
+        FlexJSProject flexProject = (FlexJSProject) project;
+        ASProjectScope projectScope = (ASProjectScope) flexProject.getScope();
+        ICompilationUnit cu = projectScope
+                .getCompilationUnitForDefinition(type);
+        ArrayList<String> requiresList = flexProject.getRequires(cu);
+        ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
+
+        String cname = type.getQualifiedName();
+        ArrayList<String> writtenInstances = new ArrayList<String>();
+        writtenInstances.add(cname); // make sure we don't add ourselves
+
+        boolean emitsRequires = false;
+        if (requiresList != null)
         {
-            write(ASEmitterTokens.IS);
-            write(ASEmitterTokens.PAREN_OPEN);
-            getWalker().walk(node.getLeftOperandNode());
-            writeToken(ASEmitterTokens.COMMA);
-            getWalker().walk(node.getRightOperandNode());
-            write(ASEmitterTokens.PAREN_CLOSE);
+            for (String imp : requiresList)
+            {
+                if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
+                    continue;
+
+                if (imp.equals(cname))
+                    continue;
+
+                if (NativeUtils.isNative(imp))
+                    continue;
+
+                if (writtenInstances.indexOf(imp) == -1)
+                {
+
+                    /* goog.require('x');\n */
+                    write(JSGoogEmitterTokens.GOOG_REQUIRE);
+                    write(ASEmitterTokens.PAREN_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(imp);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.PAREN_CLOSE);
+                    writeNewline(ASEmitterTokens.SEMICOLON);
+                    
+                    writtenInstances.add(imp);
+                    
+                    emitsRequires = true;
+                }
+            }
         }
-        else if (id == ASTNodeID.Op_AsID)
+        
+        boolean emitsInterfaces = false;
+        if (interfacesList != null)
         {
-            // (is(a, b) ? a : null)
-            write(ASEmitterTokens.PAREN_OPEN);
-            write(ASEmitterTokens.IS);
+            for (String imp : interfacesList)
+            {
+                write(JSGoogEmitterTokens.GOOG_REQUIRE);
+                write(ASEmitterTokens.PAREN_OPEN);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                write(imp);
+                write(ASEmitterTokens.SINGLE_QUOTE);
+                write(ASEmitterTokens.PAREN_CLOSE);
+                writeNewline(ASEmitterTokens.SEMICOLON);
+                
+                emitsInterfaces = true;
+            }
+        }
+        
+        // erikdebruin: Add missing language feature support, with e.g. 'is' and 
+        //              'as' operators. We don't need to worry about requiring
+        //              this in every project: ADVANCED_OPTIMISATIONS will NOT
+        //              include any of the code if it is not used in the project.
+        boolean isMainCU = flexProject.mainCU != null && 
+                    cu.getName().equals(flexProject.mainCU.getName());
+        if (isMainCU)
+        {
+            write(JSGoogEmitterTokens.GOOG_REQUIRE);
             write(ASEmitterTokens.PAREN_OPEN);
-            getWalker().walk(node.getLeftOperandNode());
-            writeToken(ASEmitterTokens.COMMA);
-            getWalker().walk(node.getRightOperandNode());
-            writeToken(ASEmitterTokens.PAREN_CLOSE);
-            writeToken(ASEmitterTokens.TERNARY);
-            getWalker().walk(node.getLeftOperandNode());
-            write(ASEmitterTokens.SPACE);
-            writeToken(ASEmitterTokens.COLON);
-            write(ASEmitterTokens.NULL);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+            write(ASEmitterTokens.SINGLE_QUOTE);
             write(ASEmitterTokens.PAREN_CLOSE);
+            writeNewline(ASEmitterTokens.SEMICOLON);
         }
-        else
+
+        if (emitsRequires || emitsInterfaces || isMainCU)
         {
-            getWalker().walk(node.getLeftOperandNode());
+            writeNewline();
+        }
 
-            if (id != ASTNodeID.Op_CommaID)
-                write(ASEmitterTokens.SPACE);
+        writeNewline();
+        writeNewline();
+    }
 
-            // (erikdebruin) rewrite 'a &&= b' to 'a = a && b'
-            if (id == ASTNodeID.Op_LogicalAndAssignID
-                    || id == ASTNodeID.Op_LogicalOrAssignID)
-            {
-                IIdentifierNode lnode = (IIdentifierNode) node
-                        .getLeftOperandNode();
+    @Override
+    public void emitPackageFooter(IPackageDefinition definition)
+    {
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
 
-                writeToken(ASEmitterTokens.EQUAL);
-                writeToken(lnode.getName());
-                write((id == ASTNodeID.Op_LogicalAndAssignID) ? ASEmitterTokens.LOGICAL_AND
-                        : ASEmitterTokens.LOGICAL_OR);
-            }
+        ITypeNode tnode = findTypeNode(definition.getNode());
+        if (tnode != null)
+        {
+            /*
+             * Metadata
+             * 
+             * @type {Object.<string, Array.<Object>>}
+             */
+            writeNewline();
+            writeNewline();
+            writeNewline();
+            getDoc().begin();
+            writeNewline(" * Metadata");
+            writeNewline(" *");
+            writeNewline(" * @type {Object.<string, Array.<Object>>}");
+            getDoc().end();
+
+            // a.B.prototype.AFJS_CLASS_INFO = {  };
+            write(type.getQualifiedName());
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.PROTOTYPE);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            writeToken(JSFlexJSEmitterTokens.FLEXJS_CLASS_INFO);
+            writeToken(ASEmitterTokens.EQUAL);
+            writeToken(ASEmitterTokens.BLOCK_OPEN);
+            
+            // names: [{ name: '', qName: '' }]
+            write(JSFlexJSEmitterTokens.NAMES);
+            writeToken(ASEmitterTokens.COLON);
+            write(ASEmitterTokens.SQUARE_OPEN);
+            writeToken(ASEmitterTokens.BLOCK_OPEN);
+            write(JSFlexJSEmitterTokens.NAME);
+            writeToken(ASEmitterTokens.COLON);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(tnode.getName());
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            writeToken(ASEmitterTokens.COMMA);
+            write(JSFlexJSEmitterTokens.QNAME);
+            writeToken(ASEmitterTokens.COLON);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(tnode.getQualifiedName());
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(ASEmitterTokens.BLOCK_CLOSE);
+            write(ASEmitterTokens.SQUARE_CLOSE);
+
+            IExpressionNode[] enodes;
+            if (tnode instanceof IClassNode)
+                enodes = ((IClassNode) tnode).getImplementedInterfaceNodes();
             else
+                enodes = ((IInterfaceNode) tnode).getExtendedInterfaceNodes();
+            
+            if (enodes.length > 0)
             {
-                write(node.getOperator().getOperatorText());
+                writeToken(ASEmitterTokens.COMMA);
+
+                // interfaces: [a.IC, a.ID]
+                write(JSFlexJSEmitterTokens.INTERFACES);
+                writeToken(ASEmitterTokens.COLON);
+                write(ASEmitterTokens.SQUARE_OPEN);
+                int i = 0;
+                for (IExpressionNode enode : enodes)
+                { 
+                    write(enode.resolve(project).getQualifiedName());
+                    if (i < enodes.length - 1)
+                        writeToken(ASEmitterTokens.COMMA);
+                    i++;
+                }
+                write(ASEmitterTokens.SQUARE_CLOSE);
             }
 
             write(ASEmitterTokens.SPACE);
+            write(ASEmitterTokens.BLOCK_CLOSE);
+            writeNewline(ASEmitterTokens.SEMICOLON);
+        }
+    }
+
+    private int foreachLoopCounter = 0;
+
+    @Override
+    public void emitForEachLoop(IForLoopNode node)
+    {
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
+                .getConditionalsContainerNode().getChild(0);
+        IASNode childNode = bnode.getChild(0);
+
+        String iterName = "foreachiter"
+                + new Integer(foreachLoopCounter).toString();
+        foreachLoopCounter++;
 
-            getWalker().walk(node.getRightOperandNode());
+        write(ASEmitterTokens.FOR);
+        write(ASEmitterTokens.SPACE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.VAR);
+        write(ASEmitterTokens.SPACE);
+        write(iterName);
+        write(ASEmitterTokens.SPACE);
+        write(ASEmitterTokens.IN);
+        write(ASEmitterTokens.SPACE);
+        getWalker().walk(bnode.getChild(1));
+        writeToken(ASEmitterTokens.PAREN_CLOSE);
+        writeNewline();
+        write(ASEmitterTokens.BLOCK_OPEN);
+        writeNewline();
+        if (childNode instanceof IVariableExpressionNode)
+        {
+            write(ASEmitterTokens.VAR);
+            write(ASEmitterTokens.SPACE);
+            write(((IVariableNode) childNode.getChild(0)).getName());
         }
+        else
+            write(((IIdentifierNode) childNode).getName());
+        write(ASEmitterTokens.SPACE);
+        write(ASEmitterTokens.EQUAL);
+        write(ASEmitterTokens.SPACE);
+        getWalker().walk(bnode.getChild(1));
+        write(ASEmitterTokens.SQUARE_OPEN);
+        write(iterName);
+        write(ASEmitterTokens.SQUARE_CLOSE);
+        write(ASEmitterTokens.SEMICOLON);
+        writeNewline();
+        getWalker().walk(node.getStatementContentsNode());
+        write(ASEmitterTokens.BLOCK_CLOSE);
+        writeNewline();
 
-        if (ASNodeUtils.hasParenOpen(node))
-            write(ASEmitterTokens.PAREN_CLOSE);
     }
 
-    //--------------------------------------------------------------------------
-    // 
-    //--------------------------------------------------------------------------
+    /*
+    @Override
+    public void emitForEachLoop(IForLoopNode node)
+    {
+        IContainerNode xnode = (IContainerNode) node.getChild(1);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
+                .getConditionalsContainerNode().getChild(0);
+        IASNode childNode = bnode.getChild(0);
+
+        write(ASEmitterTokens.TRY);
+        write(ASEmitterTokens.BLOCK_OPEN);
+        writeNewline();
+        
+        write(JSGoogEmitterTokens.GOOG_ARRAY_FOREACH);
+        write(ASEmitterTokens.PAREN_OPEN);
+        getWalker().walk(bnode.getChild(1));
+        writeToken(ASEmitterTokens.COMMA);
+        writeToken(ASEmitterTokens.FUNCTION);
+        write(ASEmitterTokens.PAREN_OPEN);
+        if (childNode instanceof IVariableExpressionNode)
+        	write(((IVariableNode) childNode.getChild(0)).getName());
+        else
+        	write(((IIdentifierNode) childNode).getName());
+        writeToken(ASEmitterTokens.PAREN_CLOSE);
+        if (isImplicit(xnode))
+            write(ASEmitterTokens.BLOCK_OPEN);
+        getWalker().walk(node.getStatementContentsNode());
+        if (isImplicit(xnode))
+        {
+            writeNewline();
+            write(ASEmitterTokens.BLOCK_CLOSE);
+        }
+        write(ASEmitterTokens.PAREN_CLOSE);
+        writeNewline();
+        write(ASEmitterTokens.BLOCK_CLOSE);
+        writeNewline();
+        write(ASEmitterTokens.CATCH);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write("foreachbreakerror");
+        write(ASEmitterTokens.PAREN_CLOSE);
+        write(ASEmitterTokens.SPACE);
+        write(ASEmitterTokens.BLOCK_OPEN);
+        write(ASEmitterTokens.BLOCK_CLOSE);
+        writeNewline();
+        
+    }
 
-    private List<String> resolveImports(ITypeDefinition type)
+    @Override
+    public void emitIterationFlow(IIterationFlowNode node)
     {
-        ArrayList<String> list = new ArrayList<String>();
-        IScopedNode scopeNode = type.getContainedScope().getScopeNode();
-        if (scopeNode != null)
+    	// look for break in foreach and throw error instead
+    	if (node.getKind() == IIterationFlowNode.IterationFlowKind.BREAK)
+    	{
+    		IASNode pNode = node.getParent();
+    		while (pNode != null)
+    		{
+    			ASTNodeID id = pNode.getNodeID();
+    			if (id == ASTNodeID.ForEachLoopID)
+    			{
+    				write(ASEmitterTokens.THROW);
+    				write(ASEmitterTokens.SPACE);
+    				write(ASEmitterTokens.NEW);
+    				write(ASEmitterTokens.SPACE);
+    				write(JSGoogEmitterTokens.ERROR);
+    				write(ASEmitterTokens.PAREN_OPEN);
+    				write(ASEmitterTokens.PAREN_CLOSE);
+    				write(ASEmitterTokens.SEMICOLON);
+    				return;
+    			}
+    			else if (id == ASTNodeID.ForLoopID ||
+    					id == ASTNodeID.DoWhileLoopID ||
+    					id == ASTNodeID.WhileLoopID)
+    				break;
+    			pNode = pNode.getParent();
+    		}
+    	}
+        write(node.getKind().toString().toLowerCase());
+        IIdentifierNode lnode = node.getLabelNode();
+        if (lnode != null)
         {
-            scopeNode.getAllImports(list);
+            write(ASEmitterTokens.SPACE);
+            getWalker().walk(lnode);
         }
-        else
+    }
+    */
+
+    @Override
+    public void emitTypedExpression(ITypedExpressionNode node)
+    {
+        write(JSGoogEmitterTokens.ARRAY);
+    }
+
+    @Override
+    public void emitLiteral(ILiteralNode node)
+    {
+        boolean isWritten = false;
+        
+        String s = node.getValue(true);
+        if (!(node instanceof RegExpLiteralNode))
         {
-            // MXML
-            ClassDefinition cdefinition = (ClassDefinition) type;
-            String[] implicitImports = cdefinition.getImplicitImports();
-            for (String imp : implicitImports)
+            if (node.getLiteralType() == LiteralType.XML)
+            {
+                // ToDo (erikdebruin): VF2JS -> handle XML output properly...
+            	
+                write("'" + s + "'");
+                
+                isWritten = true;
+            }
+            s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
+            s = s.replaceAll("\r", "__CR_PLACEHOLDER__");
+            s = s.replaceAll("\t", "__TAB_PLACEHOLDER__");
+            s = s.replaceAll("\f", "__FORMFEED_PLACEHOLDER__");
+            s = s.replaceAll("\b", "__BACKSPACE_PLACEHOLDER__");
+            s = s.replaceAll("\\\\\"", "__QUOTE_PLACEHOLDER__");
+            s = s.replaceAll("\\\\", "__ESCAPE_PLACEHOLDER__");
+            //s = "\'" + s.replaceAll("\'", "\\\\\'") + "\'";
+            s = s.replaceAll("__ESCAPE_PLACEHOLDER__", "\\\\\\\\");
+            s = s.replaceAll("__QUOTE_PLACEHOLDER__", "\\\\\"");
+            s = s.replaceAll("__BACKSPACE_PLACEHOLDER__", "\\\\b");
+            s = s.replaceAll("__FORMFEED_PLACEHOLDER__", "\\\\f");
+            s = s.replaceAll("__TAB_PLACEHOLDER__", "\\\\t");
+            s = s.replaceAll("__CR_PLACEHOLDER__", "\\\\r");
+            s = s.replaceAll("__NEWLINE_PLACEHOLDER__", "\\\\n");
+            
+            Character c = s.charAt(0);
+            if (c.equals('"'))
             {
-                list.add(imp);
+            	s = s.substring(1, s.length() - 1);
+            	s = s.replaceAll("\"", "\\\\\"");
+            	s = "\"" + s + "\"";
             }
+            if (s.length() == 3)
+            {
+            	c = s.charAt(1);
+	            if (c.equals('\\')) {
+	            	s = "\"\\\\\"";
+	            }
+            }
+        }
+        
+        if (!isWritten)
+        {
+            write(s);
         }
-        return list;
     }
+    
+    @Override
+    public void emitE4XFilter(IMemberAccessExpressionNode node)
+    {
+    	// ToDo (erikdebruin): implement E4X replacement !?!
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write("E4XFilter");
+        write(ASEmitterTokens.SINGLE_QUOTE);
+    }
+
 }


[03/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Fix imports

Posted by cd...@apache.org.
Fix imports

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: f8e0a8268f46b07dab3ba0f3a52fefaf6ee94e5d
Parents: 4d778fd
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 14:30:34 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f8e0a826/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 49e8192..d1bc8b0 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
@@ -61,7 +61,7 @@ import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.ParameterNode;
 import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
-import org.apache.flex.compiler.problems.UnsupportedLanguageFeatureProblem;
+import org.apache.flex.compiler.internal.tree.as.UnaryOperatorAtNode;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.scopes.IASScope;
 import org.apache.flex.compiler.tree.ASTNodeID;


[20/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Added 'const' emission (ECMA 6) + tests

Posted by cd...@apache.org.
Added 'const' emission (ECMA 6) + tests

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 6961f0f59e3d8ca7994d4796b1f0db380c6e1a3c
Parents: 9cab2bf
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Fri Oct 24 11:49:10 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Fri Oct 24 11:49:10 2014 +0200

----------------------------------------------------------------------
 .../codegen/js/vf2js/TestVF2JSStatements.java   | 34 ++++++++++++++++
 .../codegen/js/vf2js/JSVF2JSEmitter.java        | 42 ++++++++++++++++++++
 2 files changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6961f0f5/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
index e32a5d2..648666f 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
@@ -76,6 +76,40 @@ public class TestVF2JSStatements extends TestGoogStatements
     	asBlockWalker.visitVariable(node);
     	assertOut("var /** @type {Object} */ falconTest_a.ShaderClass");
     }
+
+    //----------------------------------
+    // const declaration
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testConstDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("const /** @type {*} */ a = 42");
+    }
+
+    @Override
+    @Test
+    public void testConstDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("const /** @type {number} */ a = 42");
+    }
+
+    @Override
+    @Test
+    public void testConstDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("const /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
+    }
     
     //----------------------------------
     // for () { }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6961f0f5/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 9b91eb2..0ca8e4b 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
@@ -256,6 +256,48 @@ public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
     }
 
     @Override
+    public void emitVarDeclaration(IVariableNode node)
+    {
+        if (!(node instanceof ChainedVariableNode))
+        {
+            emitMemberKeyword(node);
+        }
+
+        IExpressionNode avnode = node.getAssignedValueNode();
+        if (avnode != null)
+        {
+            IDefinition def = avnode.resolveType(getWalker().getProject());
+
+            String opcode = avnode.getNodeID().getParaphrase();
+            if (opcode != "AnonymousFunction")
+                getDoc().emitVarDoc(node, def);
+        }
+        else
+        {
+            getDoc().emitVarDoc(node, null);
+        }
+
+        emitDeclarationName(node);
+        if (!(avnode instanceof IEmbedNode))
+        	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);
+                    emitVarDeclaration((IVariableNode) child);
+                }
+            }
+        }
+    }
+
+    @Override
     public void emitField(IVariableNode node)
     {
         IDefinition definition = getClassDefinition(node);


[17/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - VF2JS Doc emitter

Posted by cd...@apache.org.
VF2JS Doc emitter

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 76d27166cbd1793b72bc12dd0f1cebce6d1f1cd3
Parents: 8258864
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:50:07 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/js/vf2js/JSVF2JSDocEmitter.java     | 521 +++++++++++++++++++
 1 file changed, 521 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/76d27166/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
new file mode 100644
index 0000000..d6c1075
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
@@ -0,0 +1,521 @@
+/*
+ *
+ *  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.vf2js;
+
+import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
+import org.apache.flex.compiler.codegen.IEmitterTokens;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
+import org.apache.flex.compiler.common.ASModifier;
+import org.apache.flex.compiler.common.DependencyType;
+import org.apache.flex.compiler.constants.IASKeywordConstants;
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.definitions.references.IReference;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSDocEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitterTokens;
+import org.apache.flex.compiler.internal.scopes.ASScope;
+import org.apache.flex.compiler.internal.semantics.SemanticUtils;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+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.IInterfaceNode;
+import org.apache.flex.compiler.tree.as.IPackageNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+import org.apache.flex.compiler.tree.as.IScopedNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
+
+public class JSVF2JSDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
+{
+
+    public JSVF2JSDocEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emitInterfaceDoc(IInterfaceNode node, ICompilerProject project)
+    {
+        begin();
+
+        emitJSDocLine(JSEmitterTokens.INTERFACE.getToken());
+
+        boolean hasQualifiedNames = true;
+        IExpressionNode[] inodes = node.getExtendedInterfaceNodes();
+        for (IExpressionNode inode : inodes)
+        {
+            IDefinition dnode = inode.resolve(project);
+            if (dnode != null)
+            {
+                emitJSDocLine(ASEmitterTokens.EXTENDS, dnode.getQualifiedName());
+            }
+            else
+            {
+                hasQualifiedNames = false;
+                break;
+            }
+        }
+        
+        if (!hasQualifiedNames)
+        {
+            String[] inames = node.getExtendedInterfaces();
+            for (String iname : inames)
+            {
+                emitJSDocLine(ASEmitterTokens.EXTENDS, iname);
+            }
+        }
+
+        end();
+    }
+
+    public void emitInterfaceMemberDoc(IDefinitionNode node, ICompilerProject project)
+    {
+        // (erikdebruin) placeholder method, so we don't have to further complicate
+        //               the interface structure
+    }
+
+    @Override
+    public void emitFieldDoc(IVariableNode node, IDefinition def)
+    {
+        begin();
+
+        String ns = node.getNamespace();
+        if (ns == IASKeywordConstants.PRIVATE)
+        {
+            emitPrivate(node);
+        }
+        else if (ns == IASKeywordConstants.PROTECTED)
+        {
+            emitProtected(node);
+        }
+
+        if (node.isConst())
+            emitConst(node);
+
+        String packageName = "";
+        if (def != null)
+            packageName = def.getPackageName();
+
+        emitType(node, packageName);
+
+        end();
+    }
+
+    @Override
+    public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
+    {
+        IClassDefinition classDefinition = resolveClassDefinition(node);
+
+        if (node instanceof IFunctionNode)
+        {
+            boolean hasDoc = false;
+
+            if (node.isConstructor())
+            {
+                begin();
+                hasDoc = true;
+
+                emitJSDocLine(JSEmitterTokens.CONSTRUCTOR);
+
+                IClassDefinition parent = (IClassDefinition) node
+                        .getDefinition().getParent();
+                IClassDefinition superClass = parent.resolveBaseClass(project);
+                String qname = superClass.getQualifiedName();
+
+                if (superClass != null
+                        && !qname.equals(IASLanguageConstants.Object))
+                    emitExtends(superClass, superClass.getPackageName());
+
+                IReference[] references = classDefinition
+                        .getImplementedInterfaceReferences();
+                for (IReference iReference : references)
+                {
+                    ITypeDefinition type = (ITypeDefinition) iReference
+                            .resolve(project, (ASScope) classDefinition
+                                    .getContainingScope(),
+                                    DependencyType.INHERITANCE, true);
+                    emitImplements(type, type.getPackageName());
+                }
+            }
+            else
+            {
+                // @this
+                if (containsThisReference(node))
+                {
+                    begin();
+                    emitMethodAccess(node);
+                    hasDoc = true;
+                    
+                    emitThis(classDefinition, classDefinition.getPackageName());
+                }
+            }
+
+            // @param
+            IParameterNode[] parameters = node.getParameterNodes();
+            for (IParameterNode pnode : parameters)
+            {
+                if (!hasDoc)
+                {
+                    begin();
+                    emitMethodAccess(node);
+                    hasDoc = true;
+                }
+
+                IExpressionNode enode = pnode.getNameExpressionNode();
+                emitParam(pnode, enode.resolveType(project).getPackageName());
+            }
+
+            if (!node.isConstructor())
+            {
+                // @return
+                String returnType = node.getReturnType();
+                if (returnType != ""
+                        && returnType != ASEmitterTokens.VOID.getToken())
+                {
+                    if (!hasDoc)
+                    {
+                        begin();
+                        emitMethodAccess(node);
+                        hasDoc = true;
+                    }
+
+                    emitReturn(node, node.getPackageName());
+                }
+
+                // @override
+                Boolean override = node.hasModifier(ASModifier.OVERRIDE);
+                if (override)
+                {
+                    if (!hasDoc)
+                    {
+                        begin();
+                        emitMethodAccess(node);
+                        hasDoc = true;
+                    }
+
+                    emitOverride(node);
+                }
+            }
+
+            if (hasDoc)
+                end();
+        }
+    }
+
+    public void emitMethodAccess(IFunctionNode node)
+    {
+    	// do nothing
+    }
+    
+    @Override
+    public void emitVarDoc(IVariableNode node, IDefinition def)
+    {
+        String packageName = "";
+        if (def != null)
+            packageName = def.getPackageName();
+
+        if (!node.isConst())
+        {
+            IDefinition ndef = node.getDefinition();
+            if (emitter != null && emitter instanceof JSVF2JSEmitter)
+            {
+                ICompilerProject project = ((JSVF2JSEmitter)emitter).project;
+                if (project != null)
+                {
+                    packageName = ((ITypeDefinition)ndef.resolveType(project))
+                            .getPackageName();
+                }
+            }
+        }
+        
+        emitTypeShort(node, packageName);
+    }
+
+    @Override
+    public void emitConst(IVariableNode node)
+    {
+        emitJSDocLine(ASEmitterTokens.CONST);
+    }
+
+    @Override
+    public void emitExtends(IClassDefinition superDefinition, String packageName)
+    {
+        emitJSDocLine(ASEmitterTokens.EXTENDS,
+                superDefinition.getQualifiedName());
+    }
+
+    @Override
+    public void emitImplements(ITypeDefinition definition, String packageName)
+    {
+        emitJSDocLine(ASEmitterTokens.IMPLEMENTS, definition.getQualifiedName());
+    }
+
+    @Override
+    public void emitOverride(IFunctionNode node)
+    {
+        emitJSDocLine(ASEmitterTokens.OVERRIDE);
+    }
+
+    @Override
+    public void emitParam(IParameterNode node, String packageName)
+    {
+        String postfix = (node.getDefaultValue() == null) ? ""
+                : ASEmitterTokens.EQUAL.getToken();
+
+        String paramType = "";
+        if (node.isRest())
+        {
+            paramType = ASEmitterTokens.ELLIPSIS.getToken();
+        }
+        else
+        {
+            String typeName = node.getVariableType();
+            if (typeName.indexOf(packageName) > -1)
+            {
+                String[] parts = typeName.split("\\.");
+                if (parts.length > 0)
+                {
+                    typeName = parts[parts.length - 1];
+                }
+            }
+            paramType = convertASTypeToJS(typeName, packageName);
+        }
+
+        if (paramType.length() > 0)
+        {
+	        if (paramType.substring(0, 1).equalsIgnoreCase("<"))
+	        {
+	        	paramType = "Array";
+	        }
+        }
+        
+        emitJSDocLine(JSGoogDocEmitterTokens.PARAM, paramType + postfix,
+                node.getName());
+    }
+
+    @Override
+    public void emitPrivate(IASNode node)
+    {
+        emitJSDocLine(ASEmitterTokens.PRIVATE);
+    }
+
+    @Override
+    public void emitProtected(IASNode node)
+    {
+        emitJSDocLine(ASEmitterTokens.PROTECTED);
+    }
+
+    @Override
+    public void emitPublic(IASNode node)
+    {
+        emitJSDocLine(JSGoogDocEmitterTokens.EXPOSE);
+    }
+
+    @Override
+    public void emitReturn(IFunctionNode node, String packageName)
+    {
+        String rtype = node.getReturnType();
+        if (rtype != null)
+        {
+            if (rtype.length() > 1)
+            {
+            	rtype = convertASTypeToJS(rtype, packageName);
+            	
+	            if (rtype.substring(rtype.length() - 1, rtype.length()).equalsIgnoreCase("*"))
+	            {
+	            	rtype = "*";
+	            }
+            }
+            
+            emitJSDocLine(ASEmitterTokens.RETURN, rtype);
+        }
+    }
+
+    @Override
+    public void emitThis(ITypeDefinition type, String packageName)
+    {
+        emitJSDocLine(ASEmitterTokens.THIS.getToken(), type.getQualifiedName());
+    }
+
+    @Override
+    public void emitType(IASNode node, String packageName)
+    {
+        String type = ((IVariableNode) node).getVariableType();
+        emitJSDocLine(JSGoogDocEmitterTokens.TYPE.getToken(),
+                convertASTypeToJS(type, packageName));
+    }
+
+    public void emitTypeShort(IASNode node, String packageName)
+    {
+        String type = ((IVariableNode) node).getVariableType();
+        writeToken(JSDocEmitterTokens.JSDOC_OPEN);
+        write(ASEmitterTokens.ATSIGN);
+        writeToken(JSGoogDocEmitterTokens.TYPE);
+        writeBlockOpen();
+        write(convertASTypeToJS(type, packageName));
+        writeBlockClose();
+        write(ASEmitterTokens.SPACE);
+        writeToken(JSDocEmitterTokens.JSDOC_CLOSE);
+    }
+
+    //--------------------------------------------------------------------------
+
+    public void emmitPackageHeader(IPackageNode node)
+    {
+        begin();
+        write(ASEmitterTokens.SPACE);
+        writeToken(JSGoogDocEmitterTokens.STAR);
+        write(JSSharedData.getTimeStampString());
+        end();
+    }
+
+    //--------------------------------------------------------------------------
+
+    protected void emitJSDocLine(IEmitterTokens name)
+    {
+        emitJSDocLine(name.getToken(), "");
+    }
+
+    private void emitJSDocLine(String name)
+    {
+        emitJSDocLine(name, "");
+    }
+
+    private void emitJSDocLine(IEmitterTokens name, String type)
+    {
+        emitJSDocLine(name.getToken(), type, "");
+    }
+
+    private void emitJSDocLine(String name, String type)
+    {
+        emitJSDocLine(name, type, "");
+    }
+
+    private void emitJSDocLine(IEmitterTokens name, String type, String param)
+    {
+        emitJSDocLine(name.getToken(), type, param);
+    }
+
+    private void emitJSDocLine(String name, String type, String param)
+    {
+        write(ASEmitterTokens.SPACE);
+        writeToken(JSGoogDocEmitterTokens.STAR);
+        write(ASEmitterTokens.ATSIGN);
+        write(name);
+        if (type != "")
+        {
+            write(ASEmitterTokens.SPACE);
+            writeBlockOpen();
+            write(type);
+            writeBlockClose();
+        }
+        if (param != "")
+        {
+            write(ASEmitterTokens.SPACE);
+            write(param);
+        }
+        writeNewline();
+    }
+
+    protected boolean containsThisReference(IASNode node)
+    {
+        final int len = node.getChildCount();
+        for (int i = 0; i < len; i++)
+        {
+            final IASNode child = node.getChild(i);
+            if (child.getChildCount() > 0)
+            {
+                return containsThisReference(child);
+            }
+            else
+            {
+                if (SemanticUtils.isThisKeyword(child))
+                    return true;
+            }
+        }
+
+        return false;
+    }
+
+    private String convertASTypeToJS(String name, String pname)
+    {
+        String result = "";
+
+        if (name.equals(""))
+            result = ASEmitterTokens.ANY_TYPE.getToken();
+        else if (name.equals(IASLanguageConstants.Class))
+            result = IASLanguageConstants.Object;
+        else if (name.equals(IASLanguageConstants.Boolean)
+                || name.equals(IASLanguageConstants.String)
+                || name.equals(IASLanguageConstants.Number))
+            result = name.toLowerCase();
+        else if (name.equals(IASLanguageConstants._int)
+                || name.equals(IASLanguageConstants.uint))
+            result = IASLanguageConstants.Number.toLowerCase();
+
+        boolean isBuiltinFunction = name.matches("Vector\\.<.*>");
+        IASGlobalFunctionConstants.BuiltinType[] builtinTypes = IASGlobalFunctionConstants.BuiltinType
+                .values();
+        for (IASGlobalFunctionConstants.BuiltinType builtinType : builtinTypes)
+        {
+            if (name.equalsIgnoreCase(builtinType.getName()))
+            {
+                isBuiltinFunction = true;
+                break;
+            }
+        }
+
+        if (result == "")
+            result = (pname != "" && !isBuiltinFunction && name.indexOf(".") < 0) ? pname
+                    + ASEmitterTokens.MEMBER_ACCESS.getToken() + name : name;
+
+        result = result.replace(IASLanguageConstants.String,
+                IASLanguageConstants.String.toLowerCase());
+
+        return result;
+    }
+
+    protected IClassDefinition resolveClassDefinition(IFunctionNode node)
+    {
+        IScopedNode scope = node.getContainingScope();
+        if (scope instanceof IMXMLDocumentNode)
+            return ((IMXMLDocumentNode) scope).getClassDefinition();
+
+        IClassNode cnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+        
+        // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+        if (cnode == null)
+            return null;
+        
+        return cnode.getDefinition();
+    }
+}


[11/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - VF2JS tests

Posted by cd...@apache.org.
VF2JS tests

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 26117b18b96b6f5c4c8c3ce84885b0ecfefa9fdd
Parents: db8e7f0
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 16:57:27 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/js/vf2js/TestVF2JSClass.java        | 302 ++++++++++++
 .../codegen/js/vf2js/TestVF2JSFile.java         |   4 +-
 .../codegen/js/vf2js/TestVF2JSProject.java      |  73 +--
 .../codegen/js/vf2js/TestVF2JSStatements.java   | 494 +++++++++++++++++++
 .../mxml/vf2js/TestVF2JSMXMLApplication.java    |  57 ++-
 5 files changed, 895 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
new file mode 100644
index 0000000..8998868
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
@@ -0,0 +1,302 @@
+/*
+ *
+ *  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.vf2js;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogClass;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestVF2JSClass extends TestGoogClass
+{
+
+    @Override
+    @Test
+    public void testConstructor_super()
+    {
+        IClassNode node = getClassNode("public class A {public function A() { super(); }}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n  ;\n};");
+    }
+
+    @Override
+    @Test
+    public void testSimpleExtends()
+    {
+        IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testSimpleExtendsImplements()
+    {
+        IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher {public function A() {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testSimpleExtendsImplementsMultiple()
+    {
+        IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testSimpleFinalExtendsImplementsMultiple()
+    {
+        IClassNode node = getClassNode("public final class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testQualifiedExtendsImplementsMultiple()
+    {
+        IClassNode node = getClassNode("public class A extends spark.components.Button implements flash.events.IEventDispatcher, mx.logging.ILogger {public function A() {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testExtendsConstructor_super()
+    {
+        IClassNode node = getClassNode("public class A extends spark.components.Button { public function A() { super('foo', 42);}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n  org.apache.flex.A.base(this, 'constructor', 'foo', 42);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Test
+    public void testConstructor_withArgumentNameMatchingMemberName()
+    {
+        IClassNode node = getClassNode("public class B {public function B(arg1:String) {this.arg1 = arg1}; public var arg1:String;}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.flex.B = function(arg1) {\n  this.arg1 = arg1;\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.arg1;";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_withImplicitSelfInReturnValue()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; public var button:Button = new Button(); public function foo():String {return button.label;};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new spark.components.Button();\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n  return this.button.get_label();\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_noArgsNoReturn()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; public function foo():void {};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_override()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_overrideWithFunctionBody()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; override public function foo(value:Object):void {baz = ''};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.foo = function(value) {\n  baz = '';\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_overrideSuperCall()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {super.foo();};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n  org.apache.flex.B.base(this, 'foo');\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_setterCall()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; public function set baz(value:Object):void {}; public function set foo(value:Object):void {baz = value;};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_baz = function(value) {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n  this.set_baz(value);\n};";
+        assertOut(expected);
+    }
+
+    @Test
+    public void testMethod_overrideSetterSuperCall()
+    {
+        IClassNode node = getClassNode("public class B {public function B() {}; override public function set foo(value:Object):void {super.foo = value;};}");
+        asBlockWalker.visitClass(node);
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n  org.apache.flex.B.base(this, 'set_foo', value);\n};";
+        assertOut(expected);
+    }
+
+    @Override
+    @Test
+    public void testExtendsConstructor_withArguments()
+    {
+        IClassNode node = getClassNode("public class A extends spark.components.Button {public function A(arg1:String, arg2:int) {}}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {\n  org.apache.flex.A.base(this, 'constructor', arg1, arg2);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+    }
+
+    @Override
+    @Test
+    public void testFields()
+    {
+        IClassNode node = getClassNode("public class A {public var a:Object;protected var b:String; "
+                + "private var c:int; internal var d:uint; var e:Number}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
+    }
+
+    @Test
+    public void testFieldWithEmbed()
+    {
+        IClassNode node = getClassNode("public class A {[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.ShaderClass;");
+    }
+    
+    @Test
+    public void testFieldWithObjectAssignment()
+    {
+    	IClassNode node = getClassNode("public class A {private var controlBarGroupProperties:Object = { visible: true }; private var _visible:Boolean; public function get visible():Boolean { return _visible; }; public function set visible(value:Boolean):void { _visible = value; };}");
+    	asBlockWalker.visitClass(node);
+    	assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.prototype.controlBarGroupProperties = {visible:true};\n\n\n/**\n * @private\n * @type {boolean}\n */\norg.apache.flex.A.prototype._visible;\n\n\n/**\n * @expose\n * @return {boolean}\n */\norg.apache.flex.A.prototype.get_visible = function() {\n  return this._visible;\n};\n\n\n/**\n * @expose\n * @param {boolean} value\n */\norg.apache.flex.A.prototype.set_visible = function(value) {\n  this._visible = value;\n};");
+    }
+
+    @Override
+    @Test
+    public void testConstants()
+    {
+        IClassNode node = getClassNode("public class A {"
+                + "public static const A:int = 42;"
+                + "protected static const B:Number = 42;"
+                + "private static const C:Number = 42;"
+                + "foo_bar static const C:String = 'me' + 'you';");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
+    }
+
+    @Override
+    @Test
+    public void testAccessors()
+    {
+        IClassNode node = getClassNode("public class A {"
+                + "public function get foo1():Object{return null;}"
+                + "public function set foo1(value:Object):void{}"
+                + "protected function get foo2():Object{return null;}"
+                + "protected function set foo2(value:Object):void{}"
+                + "private function get foo3():Object{return null;}"
+                + "private function set foo3(value:Object):void{}"
+                + "internal function get foo5():Object{return null;}"
+                + "internal function set foo5(value:Object):void{}"
+                + "foo_bar function get foo6():Object{return null;}"
+                + "foo_bar function set foo6(value:Object):void{}" + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo1 = function() {\n  return null;\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo1 = function(value) {\n};\n\n\n/**\n * @protected\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo2 = function() {\n  return null;\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo3 = function() {\n  return null;\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo3 = function(value) {\n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo5 = function() {\n  return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo5 = function(value) 
 {\n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo6 = function() {\n  return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo6 = function(value) {\n};");
+    }
+
+    @Override
+    @Test
+    public void testMethods()
+    {
+        IClassNode node = getClassNode("public class A {"
+                + "public function foo1():Object{return null;}"
+                + "public final function foo1a():Object{return null;}"
+                + "override public function foo1b():Object{return super.foo1b();}"
+                + "protected function foo2(value:Object):void{}"
+                + "private function foo3(value:Object):void{}"
+                + "internal function foo5(value:Object):void{}"
+                + "foo_bar function foo6(value:Object):void{}"
+                + "public static function foo7(value:Object):void{}"
+                + "foo_bar static function foo7(value:Object):void{}" + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n  return null;\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n  return null;\n};\n\n\n/**\n * @expose\n * @return {Object}\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n  return org.apache.flex.A.base(this, 'foo1b');\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo6 = function(value) {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n
 };\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};");
+    }
+
+    @Test
+    public void testMethodsWithLocalFunctions()
+    {
+        IClassNode node = getClassNode("public class B {"
+                + "public function foo1():Object{function bar1():Object {return null;}; return bar1()}"
+                + "public function foo2():Object{function bar2(param1:Object):Object {return null;}; return bar2('foo');}"
+                + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n  function bar1() {\n    return null;\n  };\n  return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n  function bar2(param1) {\n    return null;\n  };\n  return goog.bind(bar2, this)('foo');\n};");
+    }
+
+    @Test
+    public void testMethodsWithLocalFunctions2()
+    {
+        IClassNode node = getClassNode("public class B {"
+                + "public var baz1:String;"
+                + "public function foo1():String{function bar1():String {return baz1;}; return bar1()}"
+                + "public function foo2():String{function bar2(param1:String):String {return param1 + baz1;}; return bar2('foo');}"
+                + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n  function bar1() {\n    return this.baz1;\n  };\n  return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n  function bar2(param1) {\n    return param1 + this.baz1;\n  };\n  return goog.bind(bar2, this)('foo');\n};");
+    }
+
+    @Test
+    public void testClassWithoutConstructor()
+    {
+        /* AJH couldn't find a way to reproduce the code paths
+         * in a simple test case.  May require multiple compilation
+         * units in the same package.
+         */
+        
+        // (erikdebruin) what's wrong with this test case and/or the resulting code?
+        
+        // (erikdebruin) if you're looking for a way to test multiple cu's 
+        //               (a project), look in 'TestGoogProject' for an example
+        
+        IClassNode node = getClassNode("public class B {"
+                + "public function clone():B { return new B() }"
+                + "}");
+        asBlockWalker.visitClass(node);
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @return {org.apache.flex.B}\n */\norg.apache.flex.B.prototype.clone = function() {\n  return new org.apache.flex.B();\n};");
+    }
+
+    protected IBackend createBackend()
+    {
+        return new VF2JSBackend();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
index 4ee33db..66a591d 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
@@ -23,7 +23,7 @@ import java.io.File;
 import java.util.List;
 
 import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
 import org.apache.flex.compiler.internal.test.VF2JSTestBase;
 import org.apache.flex.compiler.tree.as.IFileNode;
 import org.apache.flex.utils.FilenameNormalization;
@@ -68,6 +68,6 @@ public class TestVF2JSFile extends VF2JSTestBase
     @Override
     protected IBackend createBackend()
     {
-        return new FlexJSBackend();
+        return new VF2JSBackend();
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
index 38c21c8..06984bd 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
@@ -19,14 +19,14 @@
 
 package org.apache.flex.compiler.internal.codegen.js.vf2js;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
 import java.io.File;
 import java.util.List;
 
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogProject;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.test.VF2JSTestBase;
+import org.apache.flex.utils.FilenameNormalization;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -36,9 +36,11 @@ import org.junit.Test;
  * 
  * @author Erik de Bruin
  */
-public class TestVF2JSProject extends VF2JSTestBase
+public class TestVF2JSProject extends TestGoogProject
 {
 
+    private static String projectDirPath = "vf2js/projects";
+
     @Override
     public void setUp()
     {
@@ -46,41 +48,54 @@ public class TestVF2JSProject extends VF2JSTestBase
 
         super.setUp();
     }
-
+    
     @Ignore
     @Test
-    public void testSimpleMXMLProject()
+    public void test_imports()
+    {
+        // crude bypass to allow for successful inheritance
+    }
+
+    @Test
+    public void test_Test()
     {
-        String testDirPath = new File("test-files").getAbsolutePath()
-                + "/vf2js/projects/simpleMXML/src";
+        String testDirPath = projectDirPath + "/interfaces";
 
-        String fileName = "SimpleMXML";
+        String fileName = "Test";
 
         List<String> compiledFileNames = compileProject(fileName, testDirPath);
 
         assertProjectOut(compiledFileNames, testDirPath);
     }
 
-    protected void assertProjectOut(List<String> compiledFileNames,
-            String testDirPath)
+    @Test
+    public void test_Super()
+    {
+        String testDirPath = projectDirPath + "/super";
+
+        String fileName = "Base";
+
+        List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+        assertProjectOut(compiledFileNames, testDirPath);
+    }
+
+    @Override
+    protected void addSourcePaths(List<File> sourcePaths)
+    {
+        sourcePaths.add(new File(FilenameNormalization.normalize("test-files"
+                + File.separator + projectDirPath + "/interfaces")));
+
+        sourcePaths.add(new File(FilenameNormalization.normalize("test-files"
+                + File.separator + projectDirPath + "/super")));
+
+        super.addSourcePaths(sourcePaths);
+    }
+
+    @Override
+    protected IBackend createBackend()
     {
-        for (String compiledFileName : compiledFileNames)
-        {
-            String compiledFilePath = tempDir.getAbsolutePath()
-                    + File.separator + testDirPath + File.separator
-                    + compiledFileName + "_output" + "."
-                    + backend.getOutputExtension();
-            String compiledResult = readCodeFile(new File(compiledFilePath));
-
-            System.out.println(compiledResult);
-            
-            String expectedFilePath = testDirPath + File.separator
-                    + compiledFileName + "_result" + "."
-                    + backend.getOutputExtension();
-            String expectedResult = readCodeFile(new File(expectedFilePath));
-
-            assertThat(compiledResult, is(expectedResult));
-        }
+        return new VF2JSBackend();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
new file mode 100644
index 0000000..e32a5d2
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
@@ -0,0 +1,494 @@
+/*
+ *
+ *  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.vf2js;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogStatements;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.ISwitchNode;
+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;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestVF2JSStatements extends TestGoogStatements
+{
+    @Override
+    public void setUp()
+    {
+    	project = new FlexJSProject(workspace);
+        super.setUp();
+    }
+    
+    @Test
+    public void testVarDeclaration_withTypeAssignedStringWithNewLine()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:String = \"\\n\"",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = \"\\n\"");
+    }
+
+    @Test
+    public void testVarDeclaration_withXMLList()
+    {
+    	IVariableNode node = (IVariableNode) getNode(
+    			"var childDesc:XMLList = typeDescription.accessor."
+    			+ "(@name == childName) + typeDescription.method."
+    			+ "(@name == childName);",
+    			IVariableNode.class);
+    	asBlockWalker.visitVariable(node);
+    	assertOut("var /** @type {XMLList} */ childDesc = 'E4XFilter' + 'E4XFilter'");
+    }
+
+    @Test
+    public void testVarDeclaration_withEmbed()
+    {
+    	IVariableNode node = (IVariableNode) getNode(
+    			"[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;",
+    			IVariableNode.class);
+    	asBlockWalker.visitVariable(node);
+    	assertOut("var /** @type {Object} */ falconTest_a.ShaderClass");
+    }
+    
+    //----------------------------------
+    // for () { }
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitFor_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) { break; }",
+                IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i = 0; i < len; i++) {\n  break;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitFor_1b()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) break;", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i = 0; i < len; i++)\n  break;");
+    }
+
+    @Override
+    @Test
+    public void testVisitForIn_1()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj) { break; }", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i in obj) {\n  break;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitForIn_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i in obj)\n  break;");
+    }
+
+    @Override
+    @Test
+    public void testVisitForEach_1()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj) { break; }", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n  break;\n}}\n");
+    }
+
+    @Override
+    @Test
+    public void testVisitForEach_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n  break;}\n");
+    }
+
+    @Test
+    public void testVisitForEach_HoistedVar()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "var i:int; for each(i in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var foreachiter0 in obj) \n{\ni = obj[foreachiter0];\n\n  break;}\n");
+    }
+
+    //----------------------------------
+    // try {} catch () {} finally {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitTry_Catch()
+    {
+        ITryNode node = (ITryNode) getNode("try { a; } catch (e:Error) { b; }",
+                ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n  a;\n} catch (e) {\n  b;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_Catch_Finally()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) { b; } finally { c; }",
+                ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n  a;\n} catch (e) {\n  b;\n} finally {\n  c;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_Catch_Catch_Finally()
+    {
+        // TODO (erikdebruin) handle multiple 'catch' statements (FW in Wiki)
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) { b; } catch (f:Error) { c; } finally { d; }",
+                ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n  a;\n} catch (e) {\n  b;\n} catch (f) {\n  c;\n} finally {\n  d;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_CatchEmpty_FinallyEmpty_()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) {  } finally {  }", ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n  a;\n} catch (e) {\n} finally {\n}");
+    }
+
+    //----------------------------------
+    // switch {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitSwitch_1()
+    {
+        ISwitchNode node = (ISwitchNode) getNode("switch(i){case 1: break;}",
+                ISwitchNode.class);
+        asBlockWalker.visitSwitch(node);
+        assertOut("switch (i) {\n  case 1:\n    break;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitSwitch_1a()
+    {
+        ISwitchNode node = (ISwitchNode) getNode(
+                "switch(i){case 1: { break; }}", ISwitchNode.class);
+        asBlockWalker.visitSwitch(node);
+        // (erikdebruin) the code is valid without the extra braces, 
+        //               i.e. we're good, we "don't care"
+        assertOut("switch (i) {\n  case 1:\n    break;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitSwitch_2()
+    {
+        ISwitchNode node = (ISwitchNode) getNode(
+                "switch(i){case 1: break; default: return;}", ISwitchNode.class);
+        asBlockWalker.visitSwitch(node);
+        assertOut("switch (i) {\n  case 1:\n    break;\n  default:\n    return;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitSwitch_3()
+    {
+        ISwitchNode node = (ISwitchNode) getNode(
+                "switch(i){case 1: { var x:int = 42; break; }; case 2: { var y:int = 66; break; }}", ISwitchNode.class);
+        asBlockWalker.visitSwitch(node);
+        assertOut("switch (i) {\n  case 1:\n    var /** @type {number} */ x = 42;\n    break;\n  case 2:\n    var /** @type {number} */ y = 66;\n    break;\n}");
+    }
+
+    @Test
+    public void testVisitSwitch_EscapedQuotes()
+    {
+    	ISwitchNode node = (ISwitchNode) getNode(
+    			"switch (type) { case \"string\": { return \"\\\"\" + value.toString() + \"\\\"\"; } }", ISwitchNode.class);
+    	asBlockWalker.visitSwitch(node);
+    	assertOut("switch (type) {\n  case \"string\":\n    return \"\\\"\" + value.toString() + \"\\\"\";\n}");
+    }
+    
+    //----------------------------------
+    // if ()
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitIf_1()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a)\n  b++;");
+    }
+
+    @Override
+    @Test
+    public void testVisitIf_2()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++; else c++;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a)\n  b++;\nelse\n  c++;");
+    }
+
+    @Override
+    @Test
+    public void testVisitIf_4()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else if(e) --f;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a)\n  b++;\nelse if (c)\n  d++;\nelse if (e)\n  --f;");
+    }
+
+    @Test
+    public void testVisitIf_E4X()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (numChildren == 0) { if (!typeDescription.@dynamic) { trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + typeDescription.@name + \"'\"); } }", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (numChildren == 0) {\n  if (!this.typeDescription['E4XOperator']) {\n    org.apache.flex.utils.Language.trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + this.typeDescription['E4XOperator'] + \"'\");\n  }\n}");
+    }
+    
+    @Test
+    public void testVisitIf_E4X_Again()
+    {
+    	IIfNode node = (IIfNode) getNode(
+    			"if (options.includeReadOnly) { properties = classInfo..accessor.(@access != \"writeonly\") + classInfo..variable; }", IIfNode.class);
+    	asBlockWalker.visitIf(node);
+    	assertOut("if (options.includeReadOnly) {\n  properties = 'E4XFilter' + this.classInfo['E4XSelector'];\n}");
+    }
+    
+    @Test
+    public void testVisitIf_UnescapedBackSlash()
+    {
+    	IIfNode node = (IIfNode) getNode(
+    			"if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) { var index:int; }", IIfNode.class);
+    	asBlockWalker.visitIf(node);
+    	assertOut("if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) {\n  var /** @type {number} */ index;\n}");
+    }
+
+    //----------------------------------
+    // if () { }
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitIf_1a()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; }", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a) {\n  b++;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitIf_1b()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; } else { c++; }",
+                IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a) {\n  b++;\n} else {\n  c++;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitIf_1c()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) { b++; } else if (b) { c++; } else { d++; }",
+                IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a) {\n  b++;\n} else if (b) {\n  c++;\n} else {\n  d++;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitIf_3()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else --e;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a)\n  b++;\nelse if (c)\n  d++;\nelse\n  --e;");
+    }
+
+    //----------------------------------
+    // label : for () {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitFor_2()
+    {
+        IForLoopNode node = (IForLoopNode) getNode("for (;;) { break; }",
+                IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (;;) {\n  break;\n}");
+    }
+    
+    //----------------------------------
+    // while () { }
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitWhileLoop_1()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode(
+                "while(a > b){a++;--b;}", IWhileLoopNode.class);
+        asBlockWalker.visitWhileLoop(node);
+        assertOut("while (a > b) {\n  a++;\n  --b;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitWhileLoop_1a()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode("while(a > b) a++;",
+                IWhileLoopNode.class);
+        asBlockWalker.visitWhileLoop(node);
+        assertOut("while (a > b)\n  a++;");
+    }
+
+    //----------------------------------
+    // do {} while ()
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitWhileLoop_Do_1()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode(
+                "do {a++;--b;} while(a > b);", IWhileLoopNode.class);
+        asBlockWalker.visitWhileLoop(node);
+        assertOut("do {\n  a++;\n  --b;\n} while (a > b);");
+    }
+
+    @Override
+    @Test
+    public void testVisitWhileLoop_Do_1a()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode("do a++; while(a > b);",
+                IWhileLoopNode.class);
+        asBlockWalker.visitWhileLoop(node);
+        assertOut("do\n  a++;\nwhile (a > b);");
+    }
+
+    //----------------------------------
+    // label : for () {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitLabel_1()
+    {
+        LabeledStatementNode node = (LabeledStatementNode) getNode(
+                "foo: for each(var i:int in obj) { break foo; }",
+                LabeledStatementNode.class);
+        asBlockWalker.visitLabeledStatement(node);
+        assertOut("foo : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n  break foo;\n}}\n");
+    }
+
+    @Override
+    @Test
+    public void testVisitLabel_1a()
+    {
+        // TODO (mschmalle) LabelStatement messes up in finally{} block, something is wrong there
+        LabeledStatementNode node = (LabeledStatementNode) getNode(
+                "foo: for each(var i:int in obj) break foo;",
+                LabeledStatementNode.class);
+        asBlockWalker.visitLabeledStatement(node);
+        assertOut("foo : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n  break foo;}\n");
+    }
+
+    //----------------------------------
+    // with () {}
+    //----------------------------------
+
+    @Test
+    public void testVisitWith()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) { b; }", IWithNode.class);
+        asBlockWalker.visitWith(node);
+        assertOut("with (a) {\n  b;\n}");
+    }
+
+    @Test
+    public void testVisitWith_1a()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) b;", IWithNode.class);
+        asBlockWalker.visitWith(node);
+        assertOut("with (a)\n  b;");
+    }
+
+    @Override
+    @Test
+    public void testVisit()
+    {
+        IFileNode node = (IFileNode) getNode(
+                "try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally {  }"
+                        + "if (d) for (var i:int = 0; i < len; i++) break;"
+                        + "if (a) { with (ab) { c(); } "
+                        + "do {a++;do a++; while(a > b);} while(c > d); }"
+                        + "if (b) { try { a; throw new Error('foo'); } catch (e:Error) { "
+                        + " switch(i){case 1: break; default: return;}"
+                        + " } finally { "
+                        + "  d;  var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};"
+                        + "  eee.dd; eee.dd; eee.dd; eee.dd;} }"
+                        + "foo: for each(var i:int in obj) break foo;",
+                IFileNode.class);
+        asBlockWalker.visitFile(node);
+        assertOut("/**\n * FalconTest_A\n *\n * @fileoverview\n *\n * @suppress {checkTypes}\n */\n\ngoog.provide('FalconTest_A');\n\n\n\n/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\nFalconTest_A.prototype.falconTest_a = function() {\n  try {\n    a;\n  } catch (e) {\n    if (a) {\n      if (b) {\n        if (c)\n          b;\n        else if (f)\n          a;\n        else\n          e;\n      }\n    }\n  } finally {\n  }\n  if (d)\n    for (var /** @type {number} */ i = 0; i < len; i++)\n      break;\n  if (a) {\n    with (ab) {\n      c();\n    }\n    do {\n      a++;\n      do\n        a++;\n      while (a > b);\n    } while (c > d);\n  }\n  if (b) {\n    try {\n      a;\n      throw new Error('foo');\n    } catch (e) {\n      switch (i) {\n        case 1:\n          break;\n        default:\n          return;\n      }\n    } finally {\n      d;\n      var /** @type {Object} */ a = function(foo, bar) {\n        bar = typeof bar !== 'undefined' ? bar : 'goo';\n
         return -1;\n      };\n      eee.dd;\n      eee.dd;\n      eee.dd;\n      eee.dd;\n    }\n  }\n  foo : for (var foreachiter0 in obj) \n  {\n  var i = obj[foreachiter0];\n  \n    break foo;}\n  ;\n};\n\n\n/**\n * Metadata\n *\n * @type {Object.<string, Array.<Object>>}\n */\nFalconTest_A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'FalconTest_A', qName: 'FalconTest_A'}] };\n");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new VF2JSBackend();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
index 6ecadfa..376e95d 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
@@ -18,15 +18,29 @@
  */
 package org.apache.flex.compiler.internal.codegen.mxml.vf2js;
 
-import org.apache.flex.compiler.internal.test.VF2JSTestBase;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.flex.compiler.internal.test.VF2JSMXMLTestBase;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.junit.Ignore;
+import org.apache.flex.utils.FilenameNormalization;
 import org.junit.Test;
 
-public class TestVF2JSMXMLApplication extends VF2JSTestBase
+public class TestVF2JSMXMLApplication extends VF2JSMXMLTestBase
 {
 
-	@Ignore
+    @Override
+    protected void addSourcePaths(List<File> sourcePaths)
+    {
+        sourcePaths.add(new File(FilenameNormalization.normalize("test-files/vf2js/files")));
+        sourcePaths.add(new File(FilenameNormalization.normalize("test-files/vf2js/projects/simpleMXML/src")));
+
+        super.addSourcePaths(sourcePaths);
+    }
+
     @Test
     public void testSimple()
     {
@@ -42,4 +56,39 @@ public class TestVF2JSMXMLApplication extends VF2JSTestBase
         assertOut(getCodeFromFile(fileName + "_result", true, "vf2js/files"));
     }
 
+
+    @Test
+    public void testSimpleMXMLProject()
+    {
+        String testDirPath = "vf2js/projects/simpleMXML/src";
+
+        String fileName = "SimpleMXML_Project";
+
+        List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+        assertProjectOut(compiledFileNames, testDirPath);
+    }
+
+    protected void assertProjectOut(List<String> compiledFileNames,
+            String testDirPath)
+    {
+        for (String compiledFileName : compiledFileNames)
+        {
+            String compiledFilePath = tempDir.getAbsolutePath()
+                    + File.separator + testDirPath + File.separator
+                    + compiledFileName + "_output" + "."
+                    + backend.getOutputExtension();
+            String compiledResult = readCodeFile(new File(compiledFilePath));
+
+            //System.out.println(compiledResult);
+            
+            String expectedFilePath = new File("test-files").getAbsolutePath()
+                    + File.separator + testDirPath + File.separator
+                    + compiledFileName + "_result" + "."
+                    + backend.getOutputExtension();
+            String expectedResult = readCodeFile(new File(expectedFilePath));
+
+            assertThat(compiledResult, is(expectedResult));
+        }
+    }
 }


[15/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - VF2JS will no longer use the 'vf2js' namespaces.

Posted by cd...@apache.org.
VF2JS will no longer use the 'vf2js' namespaces.

I went a different way with VF2JS. The custom 'helper' namespaces are no longer needed.

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: db8e7f0a25cd5b575501348f25b86b4a1696d7ed
Parents: 1dca700
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 16:54:48 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../test-files/vf2js/files/SimpleMXML_result.js    | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/db8e7f0a/compiler.jx.tests/test-files/vf2js/files/SimpleMXML_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/vf2js/files/SimpleMXML_result.js b/compiler.jx.tests/test-files/vf2js/files/SimpleMXML_result.js
index 1a20d8a..a092dd7 100644
--- a/compiler.jx.tests/test-files/vf2js/files/SimpleMXML_result.js
+++ b/compiler.jx.tests/test-files/vf2js/files/SimpleMXML_result.js
@@ -21,32 +21,32 @@
 
 goog.provide('SimpleMXML');
 
-goog.require('vf2js_s.components.Application');
-goog.require('vf2js_s.components.Button');
+goog.require('spark.components.Application');
+goog.require('spark.components.Button');
 
 
 
 
 /**
  * @constructor
- * @extends {vf2js_s.components.Application}
+ * @extends {spark.components.Application}
  */
 SimpleMXML = function() {
   SimpleMXML.base(this, 'constructor');
   
   /**
    * @private
-   * @type {vf2js_s.components.Button}
+   * @type {spark.components.Button}
    */
   this.$ID0;
 
   /**
    * @private
-   * @type {vf2js_s.components.Button}
+   * @type {spark.components.Button}
    */
   this.$ID1;
 };
-goog.inherits(SimpleMXML, vf2js_s.components.Application);
+goog.inherits(SimpleMXML, spark.components.Application);
 
 
 /**
@@ -63,14 +63,15 @@ SimpleMXML.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'SimpleMXML', qName:
  * @expose
  */
 SimpleMXML.prototype.start = function () {
-this.$ID0 = new vf2js_s.components.Button();
+this.$ID0 = new spark.components.Button();
 this.$ID0.label = 'hello';
 this.$ID0.x = 100;
 this.$ID0.render();
-this.$ID1 = new vf2js_s.components.Button();
+this.$ID1 = new spark.components.Button();
 this.$ID1.label = 'bye';
 this.$ID1.x = 200;
 this.$ID1.render();
 
+
 };
 


[10/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Added super class to handle VF2JS specific JS emitting

Posted by cd...@apache.org.
Added super class to handle VF2JS specific JS emitting

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 82588644538bc1a3701d65ed319877ead121ea74
Parents: 601605b
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Tue Oct 21 13:34:48 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../codegen/js/vf2js/JSVF2JSEmitter.java        | 1156 ++++++++++++++++++
 1 file changed, 1156 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/82588644/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
new file mode 100644
index 0000000..a0686c8
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
@@ -0,0 +1,1156 @@
+/*
+ *
+ *  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.vf2js;
+
+import java.io.FilterWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants.BuiltinType;
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
+import org.apache.flex.compiler.codegen.js.goog.IJSGoogEmitter;
+import org.apache.flex.compiler.common.ASModifier;
+import org.apache.flex.compiler.common.ModifiersSet;
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition;
+import org.apache.flex.compiler.definitions.IPackageDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
+import org.apache.flex.compiler.internal.scopes.PackageScope;
+import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
+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.scopes.IASScope;
+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.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IEmbedNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+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.INamespaceAccessExpressionNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+import org.apache.flex.compiler.tree.as.IScopedNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
+import org.apache.flex.compiler.tree.as.IVariableExpressionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.utils.ASNodeUtils;
+
+/**
+ * Concrete implementation of the 'goog' JavaScript production.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class JSVF2JSEmitter extends JSEmitter implements IJSGoogEmitter
+{
+
+    protected static final String CONSTRUCTOR_EMPTY = "emptyConstructor";
+    protected static final String CONSTRUCTOR_FULL = "fullConstructor";
+    protected static final String SUPER_FUNCTION_CALL = "replaceSuperFunction";
+
+    protected List<String> propertyNames = new ArrayList<String>();
+
+    protected ICompilerProject project;
+
+    protected IJSGoogDocEmitter getDoc()
+    {
+        return (IJSGoogDocEmitter) getDocEmitter();
+    }
+
+    @Override
+    public IDocEmitter getDocEmitter()
+    {
+        return new JSGoogDocEmitter(this);
+    }
+
+    //--------------------------------------------------------------------------
+    // 
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitPackageHeader(IPackageDefinition definition)
+    {
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
+
+        /* goog.provide('x');\n\n */
+        write(JSGoogEmitterTokens.GOOG_PROVIDE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(type.getQualifiedName());
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        writeNewline(ASEmitterTokens.SEMICOLON);
+        writeNewline();
+    }
+
+    @Override
+    public void emitPackageHeaderContents(IPackageDefinition definition)
+    {
+        PackageScope containedScope = (PackageScope) definition
+                .getContainedScope();
+
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
+
+        List<String> list = resolveImports(type);
+        for (String imp : list)
+        {
+            if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
+                continue;
+
+            /* goog.require('x');\n */
+            write(JSGoogEmitterTokens.GOOG_REQUIRE);
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(imp);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(ASEmitterTokens.PAREN_CLOSE);
+            writeNewline(ASEmitterTokens.SEMICOLON);
+        }
+
+        // (erikdebruin) only write 'closing' line break when there are 
+        //               actually imports...
+        if (list.size() > 1
+                || (list.size() == 1 && list.get(0).indexOf(
+                        JSGoogEmitterTokens.AS3.getToken()) == -1))
+        {
+            writeNewline();
+        }
+    }
+
+    @Override
+    public void emitPackageContents(IPackageDefinition definition)
+    {
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
+        if (type == null)
+            return;
+
+        ITypeNode tnode = findTypeNode(definition.getNode());
+        if (tnode != null)
+        {
+            getWalker().walk(tnode); // IClassNode | IInterfaceNode
+        }
+    }
+
+    @Override
+    public void emitPackageFooter(IPackageDefinition definition)
+    {
+    }
+
+    //--------------------------------------------------------------------------
+    // 
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitClass(IClassNode node)
+    {
+        IClassDefinition definition = node.getDefinition();
+
+        IFunctionDefinition ctorDefinition = definition.getConstructor();
+
+        // Static-only (Singleton) classes may not have a constructor
+        if (ctorDefinition != null)
+        {
+            IFunctionNode ctorNode = (IFunctionNode) ctorDefinition.getNode();
+            if (ctorNode != null)
+            {
+                // constructor
+                emitMethod(ctorNode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+            else
+            {
+                String qname = definition.getQualifiedName();
+                if (qname != null && !qname.equals(""))
+                {
+                    write(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);
+                }
+            }
+        }
+
+        IDefinitionNode[] dnodes = node.getAllMemberNodes();
+        for (IDefinitionNode dnode : dnodes)
+        {
+            if (dnode.getNodeID() == ASTNodeID.VariableID)
+            {
+                writeNewline();
+                writeNewline();
+                emitField((IVariableNode) dnode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+            else if (dnode.getNodeID() == ASTNodeID.FunctionID)
+            {
+                if (!((IFunctionNode) dnode).isConstructor())
+                {
+                    writeNewline();
+                    writeNewline();
+                    emitMethod((IFunctionNode) dnode);
+                    write(ASEmitterTokens.SEMICOLON);
+                }
+            }
+            else if (dnode.getNodeID() == ASTNodeID.GetterID
+                    || dnode.getNodeID() == ASTNodeID.SetterID)
+            {
+                writeNewline();
+                writeNewline();
+                emitAccessors((IAccessorNode) dnode);
+                write(ASEmitterTokens.SEMICOLON);
+            }
+        }
+    }
+
+    @Override
+    public void emitInterface(IInterfaceNode node)
+    {
+        ICompilerProject project = getWalker().getProject();
+
+        getDoc().emitInterfaceDoc(node, project);
+
+        String qname = node.getQualifiedName();
+        if (qname != null && !qname.equals(""))
+        {
+            write(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 || !propertyNames.contains(qname))
+            {
+                writeNewline();
+
+                write(qname);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(JSEmitterTokens.PROTOTYPE);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                write(mnode.getQualifiedName());
+
+                if (isAccessor && !propertyNames.contains(qname))
+                {
+                    propertyNames.add(qname);
+                }
+                else
+                {
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(ASEmitterTokens.FUNCTION);
+
+                    emitParameters(((IFunctionNode) mnode).getParameterNodes());
+
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.BLOCK_OPEN);
+                    writeNewline();
+                    write(ASEmitterTokens.BLOCK_CLOSE);
+                }
+
+                write(ASEmitterTokens.SEMICOLON);
+            }
+        }
+    }
+
+    @Override
+    public void emitField(IVariableNode node)
+    {
+        IClassDefinition definition = getClassDefinition(node);
+
+        IDefinition def = null;
+        IExpressionNode enode = node.getVariableTypeNode();//getAssignedValueNode();
+        if (enode != null)
+            def = enode.resolveType(getWalker().getProject());
+
+        getDoc().emitFieldDoc(node, def);
+
+        /* x.prototype.y = z */
+
+        ModifiersSet modifierSet = node.getDefinition().getModifiers();
+        String root = "";
+        if (modifierSet != null && !modifierSet.hasModifier(ASModifier.STATIC))
+        {
+            root = JSEmitterTokens.PROTOTYPE.getToken();
+            root += ASEmitterTokens.MEMBER_ACCESS.getToken();
+        }
+        write(definition.getQualifiedName()
+                + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
+                + node.getName());
+
+        IExpressionNode vnode = node.getAssignedValueNode();
+        if (vnode != null)
+        {
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            getWalker().walk(vnode);
+        }
+
+        if (!(node instanceof ChainedVariableNode))
+        {
+            int len = node.getChildCount();
+            for (int i = 0; i < len; i++)
+            {
+                IASNode child = node.getChild(i);
+                if (child instanceof ChainedVariableNode)
+                {
+                    writeNewline(ASEmitterTokens.SEMICOLON);
+                    writeNewline();
+                    emitField((IVariableNode) child);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void emitVarDeclaration(IVariableNode node)
+    {
+        if (!(node instanceof ChainedVariableNode))
+        {
+            emitMemberKeyword(node);
+        }
+
+        IExpressionNode avnode = node.getAssignedValueNode();
+        if (avnode != null)
+        {
+            IDefinition def = avnode.resolveType(getWalker().getProject());
+
+            String opcode = avnode.getNodeID().getParaphrase();
+            if (opcode != "AnonymousFunction")
+                getDoc().emitVarDoc(node, def);
+        }
+        else
+        {
+            getDoc().emitVarDoc(node, null);
+        }
+
+        emitDeclarationName(node);
+        if (!(avnode instanceof IEmbedNode))
+        	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);
+                    emitVarDeclaration((IVariableNode) child);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void emitGetAccessor(IGetterNode node)
+    {
+        emitObjectDefineProperty(node);
+    }
+
+    @Override
+    public void emitSetAccessor(ISetterNode node)
+    {
+        emitObjectDefineProperty(node);
+    }
+
+    protected void emitAccessors(IAccessorNode node)
+    {
+        String qname = node.getQualifiedName();
+        if (!propertyNames.contains(qname))
+        {
+            emitField(node);
+            write(ASEmitterTokens.SEMICOLON);
+            writeNewline();
+            writeNewline();
+
+            propertyNames.add(qname);
+        }
+
+        if (node.getNodeID() == ASTNodeID.GetterID)
+        {
+            emitGetAccessor((IGetterNode) node);
+        }
+        else if (node.getNodeID() == ASTNodeID.SetterID)
+        {
+            emitSetAccessor((ISetterNode) node);
+        }
+    }
+
+    @Override
+    public void emitMethod(IFunctionNode node)
+    {
+        FunctionNode fn = (FunctionNode) node;
+        fn.parseFunctionBody(new ArrayList<ICompilerProblem>());
+
+        ICompilerProject project = getWalker().getProject();
+
+        getDoc().emitMethodDoc(node, project);
+
+        boolean isConstructor = node.isConstructor();
+
+        String qname = getTypeDefinition(node).getQualifiedName();
+        if (qname != null && !qname.equals(""))
+        {
+            write(qname);
+            if (!isConstructor)
+            {
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                if (!fn.hasModifier(ASModifier.STATIC))
+                {
+                    write(JSEmitterTokens.PROTOTYPE);
+                    write(ASEmitterTokens.MEMBER_ACCESS);
+                }
+            }
+        }
+
+        if (!isConstructor)
+            emitMemberName(node);
+
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.EQUAL);
+        write(ASEmitterTokens.FUNCTION);
+
+        emitParameters(node.getParameterNodes());
+
+        boolean hasSuperClass = hasSuperClass(node);
+
+        if (isConstructor && node.getScopedNode().getChildCount() == 0)
+        {
+            write(ASEmitterTokens.SPACE);
+            write(ASEmitterTokens.BLOCK_OPEN);
+            if (hasSuperClass)
+                emitSuperCall(node, CONSTRUCTOR_EMPTY);
+            writeNewline();
+            write(ASEmitterTokens.BLOCK_CLOSE);
+        }
+
+        if (!isConstructor || node.getScopedNode().getChildCount() > 0)
+            emitMethodScope(node.getScopedNode());
+
+        if (isConstructor && hasSuperClass)
+        {
+            writeNewline();
+            write(JSGoogEmitterTokens.GOOG_INHERITS);
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(qname);
+            writeToken(ASEmitterTokens.COMMA);
+            String sname = getSuperClassDefinition(node, project)
+                    .getQualifiedName();
+            write(sname);
+            write(ASEmitterTokens.PAREN_CLOSE);
+        }
+    }
+
+    @Override
+    public void emitFunctionCall(IFunctionCallNode node)
+    {
+        IASNode cnode = node.getChild(0);
+
+        if (cnode.getNodeID() == ASTNodeID.MemberAccessExpressionID)
+            cnode = cnode.getChild(0);
+
+        ASTNodeID id = cnode.getNodeID();
+        if (id != ASTNodeID.SuperID)
+        {
+            if (node.isNewExpression())
+            {
+                writeToken(ASEmitterTokens.NEW);
+            }
+
+            getWalker().walk(node.getNameNode());
+
+            write(ASEmitterTokens.PAREN_OPEN);
+            walkArguments(node.getArgumentNodes());
+            write(ASEmitterTokens.PAREN_CLOSE);
+        }
+        else
+        {
+            emitSuperCall(node, SUPER_FUNCTION_CALL);
+        }
+    }
+
+    @Override
+    public void emitIdentifier(IIdentifierNode node)
+    {
+        ICompilerProject project = getWalker().getProject();
+
+        IClassNode cnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+
+        IDefinition def = ((IIdentifierNode) node).resolve(project);
+
+        ITypeDefinition type = ((IIdentifierNode) node).resolveType(project);
+
+        IASNode pnode = node.getParent();
+        ASTNodeID inode = pnode.getNodeID();
+
+        boolean writeSelf = false;
+        if (cnode != null)
+        {
+            IDefinitionNode[] members = cnode.getAllMemberNodes();
+            for (IDefinitionNode mnode : members)
+            {
+                if ((type != null && type.getQualifiedName().equalsIgnoreCase(
+                        IASLanguageConstants.Function))
+                        || (def != null && def.getQualifiedName()
+                                .equalsIgnoreCase(mnode.getQualifiedName())))
+                {
+                    if (!(pnode instanceof FunctionNode)
+                            && inode != ASTNodeID.MemberAccessExpressionID)
+                    {
+                        writeSelf = true;
+                        break;
+                    }
+                    else if (inode == ASTNodeID.MemberAccessExpressionID
+                            && !def.isStatic())
+                    {
+                        String tname = type.getQualifiedName();
+                        writeSelf = !tname.equalsIgnoreCase(cnode
+                                .getQualifiedName())
+                                && !tname.equals(IASLanguageConstants.Function);
+                        break;
+                    }
+                }
+            }
+        }
+
+        boolean isRunningInTestMode = cnode != null
+                && cnode.getQualifiedName().equalsIgnoreCase("FalconTest_A");
+        if (writeSelf && !isRunningInTestMode)
+        {
+            write(JSGoogEmitterTokens.SELF);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+        }
+        else
+        {
+            String pname = (type != null) ? type.getPackageName() : "";
+            if (cnode != null
+                    && pname != ""
+                    && !pname.equalsIgnoreCase(cnode.getPackageName())
+                    && inode != ASTNodeID.ArgumentID
+                    && inode != ASTNodeID.VariableID
+                    && inode != ASTNodeID.TypedExpressionID)
+            {
+                write(pname);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+            }
+        }
+
+        super.emitIdentifier(node);
+    }
+
+    @Override
+    public void emitFunctionBlockHeader(IFunctionNode node)
+    {
+        IDefinition def = node.getDefinition();
+        boolean isStatic = false;
+        if (def != null && def.isStatic())
+            isStatic = true;
+        boolean isLocal = false;
+        if (node.getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL)
+            isLocal = true;
+        if (hasBody(node) && !isStatic && !isLocal)
+            emitSelfReference(node);
+
+        if (node.isConstructor()
+                && hasSuperClass(node) && !hasSuperCall(node.getScopedNode()))
+            emitSuperCall(node, CONSTRUCTOR_FULL);
+
+        emitRestParameterCodeBlock(node);
+
+        emitDefaultParameterCodeBlock(node);
+    }
+
+    protected void emitSelfReference(IFunctionNode node)
+    {
+        writeToken(ASEmitterTokens.VAR);
+        writeToken(JSGoogEmitterTokens.SELF);
+        writeToken(ASEmitterTokens.EQUAL);
+        write(ASEmitterTokens.THIS);
+        writeNewline(ASEmitterTokens.SEMICOLON);
+    }
+
+    protected void emitSuperCall(IASNode node, String type)
+    {
+        IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
+                : null;
+        IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
+                : null;
+
+        if (type == CONSTRUCTOR_EMPTY)
+        {
+            indentPush();
+            writeNewline();
+            indentPop();
+        }
+        else if (type == SUPER_FUNCTION_CALL)
+        {
+            if (fnode == null)
+                fnode = (IFunctionNode) fcnode
+                        .getAncestorOfType(IFunctionNode.class);
+        }
+
+        if (fnode.isConstructor() && !hasSuperClass(fnode))
+            return;
+
+        IClassNode cnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+
+        write(cnode.getQualifiedName());
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        write(JSGoogEmitterTokens.GOOG_BASE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.THIS);
+
+        if (fnode.isConstructor())
+        {
+            writeToken(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(JSGoogEmitterTokens.GOOG_CONSTRUCTOR);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+        }
+
+        if (fnode != null && !fnode.isConstructor())
+        {
+            writeToken(ASEmitterTokens.COMMA);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+            write(fnode.getName());
+            write(ASEmitterTokens.SINGLE_QUOTE);
+        }
+
+        IASNode[] anodes = null;
+        boolean writeArguments = false;
+        if (fcnode != null)
+        {
+            anodes = fcnode.getArgumentNodes();
+
+            writeArguments = anodes.length > 0;
+        }
+        else if (fnode.isConstructor())
+        {
+            anodes = fnode.getParameterNodes();
+
+            writeArguments = (anodes != null && anodes.length > 0);
+        }
+
+        if (writeArguments)
+        {
+            int len = anodes.length;
+            for (int i = 0; i < len; i++)
+            {
+                writeToken(ASEmitterTokens.COMMA);
+
+                getWalker().walk(anodes[i]);
+            }
+        }
+
+        write(ASEmitterTokens.PAREN_CLOSE);
+
+        if (type == CONSTRUCTOR_FULL)
+        {
+            write(ASEmitterTokens.SEMICOLON);
+            writeNewline();
+        }
+        else if (type == CONSTRUCTOR_EMPTY)
+        {
+            write(ASEmitterTokens.SEMICOLON);
+        }
+    }
+
+    protected void emitDefaultParameterCodeBlock(IFunctionNode node)
+    {
+        IParameterNode[] pnodes = node.getParameterNodes();
+        if (pnodes.length == 0)
+            return;
+
+        Map<Integer, IParameterNode> defaults = getDefaults(pnodes);
+
+        if (defaults != null)
+        {
+            final StringBuilder code = new StringBuilder();
+
+            if (!hasBody(node))
+            {
+                indentPush();
+                write(ASEmitterTokens.INDENT);
+            }
+
+            List<IParameterNode> parameters = new ArrayList<IParameterNode>(
+                    defaults.values());
+
+            for (int i = 0, n = parameters.size(); i < n; i++)
+            {
+                IParameterNode pnode = parameters.get(i);
+
+                if (pnode != null)
+                {
+                    code.setLength(0);
+
+                    /* x = typeof y !== 'undefined' ? y : z;\n */
+                    code.append(pnode.getName());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.EQUAL.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.TYPEOF.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(pnode.getName());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.STRICT_NOT_EQUAL.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                    code.append(ASEmitterTokens.UNDEFINED.getToken());
+                    code.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.TERNARY.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(pnode.getName());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(ASEmitterTokens.COLON.getToken());
+                    code.append(ASEmitterTokens.SPACE.getToken());
+                    code.append(pnode.getDefaultValue());
+                    code.append(ASEmitterTokens.SEMICOLON.getToken());
+
+                    write(code.toString());
+
+                    if (i == n - 1 && !hasBody(node))
+                        indentPop();
+
+                    writeNewline();
+                }
+            }
+        }
+    }
+
+    private void emitRestParameterCodeBlock(IFunctionNode node)
+    {
+        IParameterNode[] pnodes = node.getParameterNodes();
+
+        IParameterNode rest = getRest(pnodes);
+        if (rest != null)
+        {
+            final StringBuilder code = new StringBuilder();
+
+            /* x = Array.prototype.slice.call(arguments, y);\n */
+            code.append(rest.getName());
+            code.append(ASEmitterTokens.SPACE.getToken());
+            code.append(ASEmitterTokens.EQUAL.getToken());
+            code.append(ASEmitterTokens.SPACE.getToken());
+            code.append(BuiltinType.ARRAY.getName());
+            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
+            code.append(JSEmitterTokens.PROTOTYPE.getToken());
+            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
+            code.append(JSEmitterTokens.SLICE.getToken());
+            code.append(ASEmitterTokens.MEMBER_ACCESS.getToken());
+            code.append(JSEmitterTokens.CALL.getToken());
+            code.append(ASEmitterTokens.PAREN_OPEN.getToken());
+            code.append(JSEmitterTokens.ARGUMENTS.getToken());
+            code.append(ASEmitterTokens.COMMA.getToken());
+            code.append(ASEmitterTokens.SPACE.getToken());
+            code.append(String.valueOf(pnodes.length - 1));
+            code.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+            code.append(ASEmitterTokens.SEMICOLON.getToken());
+
+            write(code.toString());
+
+            writeNewline();
+        }
+    }
+
+    @Override
+    public void emitParameter(IParameterNode node)
+    {
+        getWalker().walk(node.getNameExpressionNode());
+    }
+
+    @Override
+    protected void emitAssignedValue(IExpressionNode node)
+    {
+        if (node != null)
+        {
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            if (node.getNodeID() == ASTNodeID.ClassReferenceID)
+            {
+                IDefinition definition = node.resolve(getWalker().getProject());
+                write(definition.getQualifiedName());
+            }
+            else
+            {
+                getWalker().walk(node);
+            }
+        }
+    }
+
+    @Override
+    public void emitTypedExpression(ITypedExpressionNode node)
+    {
+        getWalker().walk(node.getCollectionNode());
+    }
+
+    @Override
+    public void emitForEachLoop(IForLoopNode node)
+    {
+        IContainerNode xnode = (IContainerNode) node.getChild(1);
+        IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
+                .getConditionalsContainerNode().getChild(0);
+        IASNode childNode = bnode.getChild(0);
+
+        write(JSGoogEmitterTokens.GOOG_ARRAY_FOREACH);
+        write(ASEmitterTokens.PAREN_OPEN);
+        getWalker().walk(bnode.getChild(1));
+        writeToken(ASEmitterTokens.COMMA);
+        writeToken(ASEmitterTokens.FUNCTION);
+        write(ASEmitterTokens.PAREN_OPEN);
+        if (childNode instanceof IVariableExpressionNode)
+            write(((IVariableNode) childNode.getChild(0)).getName());
+        else
+            write(((IIdentifierNode) childNode).getName());
+        writeToken(ASEmitterTokens.PAREN_CLOSE);
+        if (isImplicit(xnode))
+            write(ASEmitterTokens.BLOCK_OPEN);
+        getWalker().walk(node.getStatementContentsNode());
+        if (isImplicit(xnode))
+        {
+            writeNewline();
+            write(ASEmitterTokens.BLOCK_CLOSE);
+        }
+        write(ASEmitterTokens.PAREN_CLOSE);
+    }
+
+    public JSVF2JSEmitter(FilterWriter out)
+    {
+        super(out);
+    }
+
+    protected Map<Integer, IParameterNode> getDefaults(IParameterNode[] nodes)
+    {
+        Map<Integer, IParameterNode> result = new HashMap<Integer, IParameterNode>();
+        int i = 0;
+        boolean hasDefaults = false;
+        for (IParameterNode node : nodes)
+        {
+            if (node.hasDefaultValue())
+            {
+                hasDefaults = true;
+                result.put(i, node);
+            }
+            else
+            {
+                result.put(i, null);
+            }
+            i++;
+        }
+
+        if (!hasDefaults)
+            return null;
+
+        return result;
+    }
+
+    private IParameterNode getRest(IParameterNode[] nodes)
+    {
+        for (IParameterNode node : nodes)
+        {
+            if (node.isRest())
+                return node;
+        }
+
+        return null;
+    }
+
+    private static ITypeDefinition getTypeDefinition(IDefinitionNode node)
+    {
+        ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
+        return (ITypeDefinition) tnode.getDefinition();
+    }
+
+    protected static IClassDefinition getClassDefinition(IDefinitionNode node)
+    {
+        IClassNode tnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+        return (tnode != null) ? tnode.getDefinition() : null;
+    }
+
+    private static IClassDefinition getSuperClassDefinition(
+            IDefinitionNode node, ICompilerProject project)
+    {
+        IClassDefinition parent = (IClassDefinition) node.getDefinition()
+                .getParent();
+        IClassDefinition superClass = parent.resolveBaseClass(project);
+        return superClass;
+    }
+
+    protected boolean hasSuperClass(IDefinitionNode node)
+    {
+        ICompilerProject project = getWalker().getProject();
+        IClassDefinition superClassDefinition = getSuperClassDefinition(node,
+                project);
+        // XXX (mschmalle) this is nulling for MXML super class, figure out why
+        if (superClassDefinition == null)
+            return false;
+        String qname = superClassDefinition.getQualifiedName();
+        return superClassDefinition != null
+                && !qname.equals(IASLanguageConstants.Object);
+    }
+
+    private boolean hasSuperCall(IScopedNode node)
+    {
+        for (int i = node.getChildCount() - 1; i > -1; i--)
+        {
+            IASNode cnode = node.getChild(i);
+            if (cnode.getNodeID() == ASTNodeID.FunctionCallID
+                    && cnode.getChild(0).getNodeID() == ASTNodeID.SuperID)
+                return true;
+        }
+
+        return false;
+    }
+
+    protected static boolean hasBody(IFunctionNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        return scope.getChildCount() > 0;
+    }
+
+    protected void emitObjectDefineProperty(IAccessorNode node)
+    {
+        /*
+        Object.defineProperty(
+            A.prototype, 
+            'foo', 
+            {get: function() {return -1;}, 
+            configurable: true}
+         );
+        */
+
+        FunctionNode fn = (FunctionNode) node;
+        fn.parseFunctionBody(getProblems());
+
+        // head
+        write(JSGoogEmitterTokens.OBJECT);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        write(JSEmitterTokens.DEFINE_PROPERTY);
+        writeNewline(ASEmitterTokens.PAREN_OPEN, true);
+
+        // Type
+        IFunctionDefinition definition = node.getDefinition();
+        ITypeDefinition type = (ITypeDefinition) definition.getParent();
+        write(type.getQualifiedName());
+        if (!node.hasModifier(ASModifier.STATIC))
+        {
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(JSEmitterTokens.PROTOTYPE);
+        }
+        writeToken(ASEmitterTokens.COMMA);
+        writeNewline();
+
+        // name
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(definition.getBaseName());
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        writeToken(ASEmitterTokens.COMMA);
+        writeNewline();
+
+        // info object
+        // declaration
+        write(ASEmitterTokens.BLOCK_OPEN);
+        write(node.getNodeID() == ASTNodeID.GetterID ? ASEmitterTokens.GET
+                : ASEmitterTokens.SET);
+        write(ASEmitterTokens.COLON);
+        write(ASEmitterTokens.FUNCTION);
+        emitParameters(node.getParameterNodes());
+
+        emitMethodScope(node.getScopedNode());
+
+        writeToken(ASEmitterTokens.COMMA);
+        write(JSEmitterTokens.CONFIGURABLE);
+        write(ASEmitterTokens.COLON);
+        write(ASEmitterTokens.TRUE);
+        writeNewline(ASEmitterTokens.BLOCK_CLOSE, false);
+
+        // tail, no colon; parent container will add it
+        write(ASEmitterTokens.PAREN_CLOSE);
+    }
+
+    //--------------------------------------------------------------------------
+    // Operators
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitNamespaceAccessExpression(INamespaceAccessExpressionNode node)
+    {
+        getWalker().walk(node.getLeftOperandNode());
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        getWalker().walk(node.getRightOperandNode());
+    }
+
+    @Override
+    public void emitAsOperator(IBinaryOperatorNode node)
+    {
+        emitBinaryOperator(node);
+    }
+
+    @Override
+    public void emitIsOperator(IBinaryOperatorNode node)
+    {
+        emitBinaryOperator(node);
+    }
+
+    @Override
+    public void emitBinaryOperator(IBinaryOperatorNode node)
+    {
+        if (ASNodeUtils.hasParenOpen(node))
+            write(ASEmitterTokens.PAREN_OPEN);
+
+        ASTNodeID id = node.getNodeID();
+
+        if (id == ASTNodeID.Op_IsID)
+        {
+            write(ASEmitterTokens.IS);
+            write(ASEmitterTokens.PAREN_OPEN);
+            getWalker().walk(node.getLeftOperandNode());
+            writeToken(ASEmitterTokens.COMMA);
+            getWalker().walk(node.getRightOperandNode());
+            write(ASEmitterTokens.PAREN_CLOSE);
+        }
+        else if (id == ASTNodeID.Op_AsID)
+        {
+            // (is(a, b) ? a : null)
+            write(ASEmitterTokens.PAREN_OPEN);
+            write(ASEmitterTokens.IS);
+            write(ASEmitterTokens.PAREN_OPEN);
+            getWalker().walk(node.getLeftOperandNode());
+            writeToken(ASEmitterTokens.COMMA);
+            getWalker().walk(node.getRightOperandNode());
+            writeToken(ASEmitterTokens.PAREN_CLOSE);
+            writeToken(ASEmitterTokens.TERNARY);
+            getWalker().walk(node.getLeftOperandNode());
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.COLON);
+            write(ASEmitterTokens.NULL);
+            write(ASEmitterTokens.PAREN_CLOSE);
+        }
+        else
+        {
+            getWalker().walk(node.getLeftOperandNode());
+
+            if (id != ASTNodeID.Op_CommaID)
+                write(ASEmitterTokens.SPACE);
+
+            // (erikdebruin) rewrite 'a &&= b' to 'a = a && b'
+            if (id == ASTNodeID.Op_LogicalAndAssignID
+                    || id == ASTNodeID.Op_LogicalOrAssignID)
+            {
+                IIdentifierNode lnode = (IIdentifierNode) node
+                        .getLeftOperandNode();
+
+                writeToken(ASEmitterTokens.EQUAL);
+                writeToken(lnode.getName());
+                write((id == ASTNodeID.Op_LogicalAndAssignID) ? ASEmitterTokens.LOGICAL_AND
+                        : ASEmitterTokens.LOGICAL_OR);
+            }
+            else
+            {
+                write(node.getOperator().getOperatorText());
+            }
+
+            write(ASEmitterTokens.SPACE);
+
+            getWalker().walk(node.getRightOperandNode());
+        }
+
+        if (ASNodeUtils.hasParenOpen(node))
+            write(ASEmitterTokens.PAREN_CLOSE);
+    }
+
+    //--------------------------------------------------------------------------
+    // 
+    //--------------------------------------------------------------------------
+
+    private List<String> resolveImports(ITypeDefinition type)
+    {
+        ArrayList<String> list = new ArrayList<String>();
+        IScopedNode scopeNode = type.getContainedScope().getScopeNode();
+        if (scopeNode != null)
+        {
+            scopeNode.getAllImports(list);
+        }
+        else
+        {
+            // MXML
+            ClassDefinition cdefinition = (ClassDefinition) type;
+            String[] implicitImports = cdefinition.getImplicitImports();
+            for (String imp : implicitImports)
+            {
+                list.add(imp);
+            }
+        }
+        return list;
+    }
+}


[02/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Add dependencies

Posted by cd...@apache.org.
Add dependencies

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: fcdc39211d5ba7544e5ec5252503adb30943e25c
Parents: e63cc7f
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 11:04:02 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200

----------------------------------------------------------------------
 .../src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fcdc3921/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
index 3fdf797..0f6e6d0 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
@@ -58,7 +58,9 @@ public class FlexJSTestBase extends TestBase
                 + "/frameworks/libs/framework.swc")));
         libraries.add(new File(FilenameNormalization.normalize(env.SDK
                 + "\\frameworks\\libs\\rpc.swc")));
+        libraries.add(new File(env.ASJS + "/frameworks/as/libs/FlexJSJX.swc"));
         libraries.add(new File(env.ASJS + "/frameworks/as/libs/FlexJSUI.swc"));
+        libraries.add(new File(env.ASJS + "/frameworks/as/libs/MXMLCClasses.swc"));
 
         super.addLibraries(libraries);
     }


[18/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Add VF2JS specific test base classes

Posted by cd...@apache.org.
Add VF2JS specific test base classes

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 91688e909aee0dad84b2ca82749c2d44005b4f48
Parents: b1980b9
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 19:42:16 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:53 2014 +0200

----------------------------------------------------------------------
 .../internal/test/VF2JSMXMLTestBase.java        | 219 +++++++++++++++++++
 .../compiler/internal/test/VF2JSTestBase.java   | 216 ++----------------
 2 files changed, 232 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/91688e90/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
new file mode 100644
index 0000000..37b40e9
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
@@ -0,0 +1,219 @@
+/*
+ *
+ *  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.test;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.utils.FilenameNormalization;
+import org.junit.Ignore;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+@Ignore
+public class VF2JSMXMLTestBase extends MXMLTestBase
+{
+
+    @Override
+    public void setUp()
+    {
+    	project = new FlexJSProject(workspace);
+    	
+        super.setUp();
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new MXMLVF2JSBackend();
+    }
+
+
+    @Override
+    protected List<String> compileProject(String inputFileName,
+            String inputDirName)
+    {
+        List<String> compiledFileNames = new ArrayList<String>();
+
+        String mainFileName = "test-files"
+                + File.separator + inputDirName + File.separator
+                + inputFileName + inputFileExtension;
+
+        addDependencies();
+
+        String normalizedFileName = FilenameNormalization.normalize(
+                mainFileName);
+        Collection<ICompilationUnit> compilationUnits = 
+                workspace.getCompilationUnits(normalizedFileName, project);
+        ICompilationUnit mainCU = Iterables.getOnlyElement(
+                compilationUnits);
+        
+        if (project instanceof FlexJSProject)
+            ((FlexJSProject) project).mainCU = mainCU;
+        
+        Configurator projectConfigurator = backend.createConfigurator();
+
+        JSTarget target = (JSTarget) backend.createTarget(project,
+                projectConfigurator.getTargetSettings(null), null);
+
+        target.build(mainCU, new ArrayList<ICompilerProblem>());
+
+        List<ICompilationUnit> reachableCompilationUnits = project
+                .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
+        for (final ICompilationUnit cu : reachableCompilationUnits)
+        {
+            ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+            if (cuType == ICompilationUnit.UnitType.AS_UNIT
+                    || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+            {
+                File outputRootDir = new File(
+                        FilenameNormalization.normalize(tempDir
+                                + File.separator + inputDirName));
+
+                String qname = "";
+                try
+                {
+                    qname = cu.getQualifiedNames().get(0);
+                }
+                catch (InterruptedException error)
+                {
+                    System.out.println(error);
+                }
+
+                compiledFileNames.add(qname.replace(".", "/"));
+
+                final File outputClassFile = getOutputClassFile(qname
+                        + "_output", outputRootDir);
+
+                ASFilterWriter outputWriter = backend.createWriterBuffer(project);
+
+                if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+                {
+                    asEmitter = backend.createEmitter(outputWriter);
+                    asBlockWalker = backend.createWalker(project, errors, asEmitter);
+
+                	asBlockWalker.visitCompilationUnit(cu);
+                }
+                else
+                {
+                    mxmlEmitter = backend.createMXMLEmitter(outputWriter);
+                    
+                    mxmlBlockWalker = backend.createMXMLWalker(project, errors,
+                            mxmlEmitter, asEmitter, asBlockWalker);
+
+                    mxmlBlockWalker.visitCompilationUnit(cu);
+                }
+                
+                //System.out.println(outputWriter.toString());
+
+                try
+                {
+                    BufferedOutputStream out = new BufferedOutputStream(
+                            new FileOutputStream(outputClassFile));
+
+                    out.write(outputWriter.toString().getBytes());
+                    out.flush();
+                    out.close();
+                }
+                catch (Exception error)
+                {
+                    System.out.println(error);
+                }
+                
+                outputWriter = null;
+            }
+        }
+
+        return compiledFileNames;
+    }
+
+    //--------------------------------------------------------------------------
+    // Node "factory"
+    //--------------------------------------------------------------------------
+
+    public static final int WRAP_LEVEL_DOCUMENT = 1;
+    public static final int WRAP_LEVEL_NODE = 2;
+
+    protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
+            int wrapLevel)
+    {
+        if (wrapLevel >= WRAP_LEVEL_NODE)
+            code = "<s:Button " + code + "></s:Button>";
+
+        if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
+            code = ""
+                    + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+                    + "               xmlns:s=\"library://ns.adobe.com/flex/spark\"" 
+                    + "               xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n"
+                    + code + "\n"
+                    + "</s:Application>";
+        
+        IMXMLFileNode node = compileMXML(code);
+
+        if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
+        {
+            IMXMLNode pnode = findFirstDescendantOfType(node, type);
+
+            IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
+
+            return cnode;
+        }
+        else
+        {
+            return findFirstDescendantOfType(node, type);
+        }
+    }
+
+    protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
+            Class<? extends IMXMLNode> nodeType)
+    {
+
+        int n = node.getChildCount();
+        for (int i = 0; i < n; i++)
+        {
+            IMXMLNode child = (IMXMLNode) node.getChild(i);
+            if (nodeType.isInstance(child))
+                return child;
+
+            IMXMLNode found = findFirstDescendantOfType(child,
+                    nodeType);
+            if (found != null)
+                return found;
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/91688e90/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
index 8ec44e6..3fee7eb 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
@@ -21,23 +21,17 @@ package org.apache.flex.compiler.internal.test;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
-import org.apache.flex.compiler.internal.mxml.MXMLNamespaceMapping;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
 import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.tree.as.IASNode;
-import org.apache.flex.compiler.tree.as.IFileNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
@@ -48,22 +42,15 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 @Ignore
-public class VF2JSTestBase extends TestBase
+public class VF2JSTestBase extends MXMLTestBase
 {
 
     @Override
     public void setUp()
     {
-        project = new FlexJSProject(workspace);
-        
-        super.setUp();
-
-        asEmitter = backend.createEmitter(writer);
-        mxmlEmitter = backend.createMXMLEmitter(writer);
+    	project = new FlexJSProject(workspace);
 
-        asBlockWalker = backend.createWalker(project, errors, asEmitter);
-        mxmlBlockWalker = backend.createMXMLWalker(project, errors,
-                mxmlEmitter, asEmitter, asBlockWalker);
+    	super.setUp();
     }
 
     @Override
@@ -78,45 +65,6 @@ public class VF2JSTestBase extends TestBase
     }
 
     @Override
-    protected void addLibraries(List<File> libraries)
-    {
-        libraries.add(new File(FilenameNormalization.normalize(env.FPSDK
-                + "/" + env.FPVER + "/playerglobal.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/framework.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/mx.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/spark.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/vf2js_mx.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/vf2js_s.swc")));
-        
-        super.addLibraries(libraries);
-    }
-
-    @Override
-    protected void addNamespaceMappings(
-            List<IMXMLNamespaceMapping> namespaceMappings)
-    {
-        namespaceMappings
-                .add(new MXMLNamespaceMapping("http://ns.adobe.com/mxml/2009",
-                        new File(env.SDK, "frameworks/mxml-2009-manifest.xml")
-                                .getAbsolutePath()));
-        
-        namespaceMappings.add(new MXMLNamespaceMapping(
-                "http://flex.apache.org/vf2js_mx/ns", new File(env.SDK,
-                        "frameworks/vf2js_mx-manifest.xml").getAbsolutePath()));
-        
-        namespaceMappings.add(new MXMLNamespaceMapping(
-                "http://flex.apache.org/vf2js_s/ns", new File(env.SDK,
-                        "frameworks/vf2js_s-manifest.xml").getAbsolutePath()));
-        
-        super.addNamespaceMappings(namespaceMappings);
-    }
-
-    @Override
     protected void addSourcePaths(List<File> sourcePaths)
     {
         //sourcePaths.add(new File(FilenameNormalization.normalize("")));
@@ -127,56 +75,17 @@ public class VF2JSTestBase extends TestBase
     @Override
     protected IBackend createBackend()
     {
-        return new MXMLVF2JSBackend();
-    }
-    
-    @Override
-    protected IASNode compile(String input, boolean isFileName,
-            String inputDir, boolean useTempFile)
-    {
-        File intermediateFile = new File(
-                inputDir + File.separator + input + inputFileExtension);
-        
-        File tmpFile = createTempFileWithVF2JSNamespace(intermediateFile, input,
-                false);
-        
-        String fileName = tmpFile.getName();
-        String onlyName = fileName.substring(0, fileName.lastIndexOf('.'));
-        String filePath = tmpFile.getAbsolutePath();
-        String onlyPath = filePath.substring(0,
-                filePath.lastIndexOf(File.separator));
-        
-        IASNode result = super.compile(onlyName, isFileName, onlyPath,
-                useTempFile);
-        
-        tmpFile.delete();
-        
-        return result;
-    }
-    
-    @Override
-    protected IFileNode compileAS(String input, boolean isFileName,
-            String inputDir, boolean useTempFile)
-    {
-        return (IFileNode) compile(input, isFileName, inputDir, useTempFile);
-    }
-    
-    @Override
-    protected IMXMLFileNode compileMXML(String input, boolean isFileName,
-            String inputDir, boolean useTempFile)
-    {
-        return (IMXMLFileNode) compile(input, isFileName, inputDir, useTempFile);
+        return new VF2JSBackend();
     }
 
     @Override
     protected List<String> compileProject(String inputFileName,
             String inputDirName)
     {
-        createTempProjectDir(new File(inputDirName).listFiles(), "");
-        
         List<String> compiledFileNames = new ArrayList<String>();
 
-        String mainFileName = "temp" + File.separator
+        String mainFileName = "test-files"
+                + File.separator + inputDirName + File.separator
                 + inputFileName + inputFileExtension;
 
         addDependencies();
@@ -207,6 +116,10 @@ public class VF2JSTestBase extends TestBase
             if (cuType == ICompilationUnit.UnitType.AS_UNIT
                     || cuType == ICompilationUnit.UnitType.MXML_UNIT)
             {
+                File outputRootDir = new File(
+                        FilenameNormalization.normalize(tempDir
+                                + File.separator + inputDirName));
+
                 String qname = "";
                 try
                 {
@@ -220,7 +133,7 @@ public class VF2JSTestBase extends TestBase
                 compiledFileNames.add(qname.replace(".", "/"));
 
                 final File outputClassFile = getOutputClassFile(qname
-                        + "_output", tempDir);
+                        + "_output", outputRootDir);
 
                 ASFilterWriter outputWriter = backend.createWriterBuffer(project);
 
@@ -285,18 +198,7 @@ public class VF2JSTestBase extends TestBase
                     + code + "\n"
                     + "</s:Application>";
         
-        File intermediateFile = writeCodeToTempFile(code, false, "");
-
-        File tmpFile = createTempFileWithVF2JSNamespace(intermediateFile,
-                getClass().getSimpleName(), true);
-        
-        String fileName = tmpFile.getName();
-        String onlyName = fileName.substring(0, fileName.lastIndexOf('.'));
-        String filePath = tmpFile.getAbsolutePath();
-        String onlyPath = filePath.substring(0,
-                filePath.lastIndexOf(File.separator));
-        
-        IMXMLFileNode node = compileMXML(onlyName, true, onlyPath, false);
+        IMXMLFileNode node = compileMXML(code);
 
         if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
         {
@@ -312,98 +214,6 @@ public class VF2JSTestBase extends TestBase
         }
     }
 
-    private void createTempProjectDir(File[] files, String parentPath)
-    {
-        for (File file : files) 
-        {
-            if (file.isDirectory()) 
-            {
-                String path = parentPath + File.separator + file.getName(); 
-                
-                new File(tempDir + File.separator + path).mkdirs();
-
-                createTempProjectDir(file.listFiles(), path);
-            } 
-            else 
-            {
-                String fileName = file.getName();
-
-                if (fileName.contains(".") && fileName.charAt(0) != '.')
-                {
-                    String extension = fileName.substring(fileName.lastIndexOf("."), fileName.length());
-    
-                    if (extension.equals(".mxml") || extension.equals(".as"))
-                    {
-                        File intermediateFile = file;
-                        String tempFileName = fileName.substring(0, fileName.indexOf("."));
-                        File targetDir = new File(tempDir + File.separator + parentPath);
-
-                        createTempFileWithVF2JSNamespace(intermediateFile, 
-                                tempFileName, false, targetDir, extension);
-                    }
-                }
-            }
-        }
-    }
-    
-    private File createTempFileWithVF2JSNamespace(File intermediateFile,
-            String tempFileName, boolean createTempFile)
-    {
-        return createTempFileWithVF2JSNamespace(intermediateFile,
-                tempFileName, createTempFile, tempDir, inputFileExtension); 
-    }
-    
-    private File createTempFileWithVF2JSNamespace(File intermediateFile,
-            String tempFileName, boolean createTempFile, File targetDir,
-            String extension)
-    {
-        File tempFile = null;
-        
-        try 
-        {
-            String content = FileUtils.readFileToString(intermediateFile, "UTF-8");
-
-            // mx (MXML)
-            content = content.replace(
-                    "xmlns:mx=\"library://ns.adobe.com/flex/mx\"", 
-                    "xmlns:vf2js_mx=\"http://flex.apache.org/vf2js_mx/ns\"");
-            content = content.replace("<mx:", "<vf2js_mx:");
-            content = content.replace("</mx:", "</vf2js_mx:");
-
-            // mx (AS)
-            content = content.replace("mx.", "vf2js_mx.");
-
-            // s (MXML)
-            content = content.replace(
-                    "xmlns:s=\"library://ns.adobe.com/flex/spark\"", 
-                    "xmlns:vf2js_s=\"http://flex.apache.org/vf2js_s/ns\"");
-            content = content.replace("<s:", "<vf2js_s:");
-            content = content.replace("</s:", "</vf2js_s:");
-
-            // s (AS)
-            content = content.replace("spark.", "vf2js_s.");
-
-            if (createTempFile)
-            {
-                tempFile = File.createTempFile(tempFileName, extension,
-                        targetDir);
-                tempFile.deleteOnExit();
-            }
-            else
-            {
-                tempFile = new File(targetDir.getAbsolutePath(),
-                        tempFileName + extension);
-            }
-            FileUtils.writeStringToFile(tempFile, content, "UTF-8");
-        } 
-        catch (IOException e) 
-        {
-            throw new RuntimeException("Generating file failed", e);
-        }
-
-        return tempFile;
-    }
-
     protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
             Class<? extends IMXMLNode> nodeType)
     {


[22/23] git commit: [flex-falcon] [refs/heads/feature/flexmojos-tests] - Making sure we notice if stuff broke when running from ant (i.e. on the build VM) - part deux

Posted by cd...@apache.org.
Making sure we notice if stuff broke when running from ant (i.e. on the build VM) - part deux

Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>


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

Branch: refs/heads/feature/flexmojos-tests
Commit: 1144b7b8dca5bcdc2b81ce80d2ab80935dae1b3c
Parents: 200e2a1
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Fri Oct 24 12:23:44 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Fri Oct 24 12:23:44 2014 +0200

----------------------------------------------------------------------
 compiler.jx.tests/build.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1144b7b8/compiler.jx.tests/build.xml
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/build.xml b/compiler.jx.tests/build.xml
index bb8ba74..8408342 100644
--- a/compiler.jx.tests/build.xml
+++ b/compiler.jx.tests/build.xml
@@ -60,7 +60,7 @@
         <junit dir="${compiler.tests}"
                fork="yes" forkMode="perBatch" maxmemory="${maxmem}m" timeout="${test.timeout}"
                printsummary="true" showoutput="true"
-               haltonerror="false" haltonfailure="false"
+               haltonerror="true" haltonfailure="true"
                failureproperty="tests.unit.failed">
             <classpath>
                 <pathelement location="${compiler.tests}/classes"/>