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 2016/04/13 20:56:30 UTC

[38/51] [partial] git commit: [flex-falcon] [refs/heads/feature/maven-migration-test] - - Check-In of the migrated project to make error analysis easier

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
new file mode 100644
index 0000000..d47c6dc
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
@@ -0,0 +1,290 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition;
+import org.apache.flex.compiler.definitions.IPackageDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.definitions.IVariableDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.scopes.ASProjectScope;
+import org.apache.flex.compiler.internal.scopes.PackageScope;
+import org.apache.flex.compiler.internal.tree.as.ClassNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.scopes.IASScope;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.utils.NativeUtils;
+
+public class PackageHeaderEmitter extends JSSubEmitter implements
+        ISubEmitter<IPackageDefinition>
+{
+
+    public PackageHeaderEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IPackageDefinition definition)
+    {
+        IASScope containedScope = definition.getContainedScope();
+        ITypeDefinition type = EmitterUtils.findType(containedScope
+                .getAllLocalDefinitions());
+        String qname = null;
+        if (type != null)
+        {
+            qname = type.getQualifiedName();
+        }
+        if (qname == null)
+        {
+            IFunctionDefinition fn = EmitterUtils.findFunction(containedScope
+                    .getAllLocalDefinitions());
+            if(fn != null)
+            {
+                qname = fn.getQualifiedName();
+            }
+        }
+        if (qname == null)
+        {
+            IVariableDefinition variable = EmitterUtils.findVariable(containedScope
+                    .getAllLocalDefinitions());
+            if(variable != null)
+            {
+                qname = variable.getQualifiedName();
+            }
+        }
+        if (qname == null)
+        {
+            return;
+        }
+        
+        FlexJSProject project = (FlexJSProject) getProject();
+        List<File> sourcePaths = project.getSourcePath();
+        String sourceName = definition.getSourcePath();
+        for (File sourcePath : sourcePaths)
+        {
+            if (sourceName.startsWith(sourcePath.getAbsolutePath())) 
+            {
+            	sourceName = sourceName.substring(sourcePath.getAbsolutePath().length() + 1);        	
+            }
+        }
+
+        writeNewline("/**");
+        writeNewline(" * Generated by Apache Flex Cross-Compiler from " + sourceName);
+        writeNewline(" * " + qname);
+        writeNewline(" *");
+        writeNewline(" * @fileoverview");
+        writeNewline(" *");
+        // need to suppress access controls so access to protected/private from defineProperties
+        // doesn't generate warnings. 
+        writeNewline(" * @suppress {checkTypes|accessControls}");
+        writeNewline(" */");
+        writeNewline();
+
+        /* goog.provide('x');\n\n */
+        write(JSGoogEmitterTokens.GOOG_PROVIDE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(getEmitter().formatQualifiedName(qname));
+        write(ASEmitterTokens.SINGLE_QUOTE);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        writeNewline(ASEmitterTokens.SEMICOLON);
+        writeNewline();
+    }
+
+    public void emitContents(IPackageDefinition definition)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+        
+        getEmitter().pushSourceMapName(definition.getNode());
+
+        PackageScope containedScope = (PackageScope) definition
+                .getContainedScope();
+
+        ArrayList<String> writtenRequires = new ArrayList<String>();
+
+        Collection<IDefinition> localDefinitions = containedScope.getAllLocalDefinitions();
+        ITypeDefinition type = EmitterUtils.findType(localDefinitions);
+        IDefinition otherMainDefinition = null;
+        if (type == null)
+        {
+        	if (localDefinitions.isEmpty())
+        		return;
+        	// function or variable definition
+        	otherMainDefinition = localDefinitions.iterator().next();
+        }
+        else
+        {
+	        ITypeNode typeNode = type.getNode();
+	        if (typeNode instanceof ClassNode)
+	        {
+	            ClassNode classNode = (ClassNode) typeNode;
+	            ASDocComment asDoc = (ASDocComment) classNode.getASDocComment();
+	            if (asDoc != null)
+	            {
+	                String asDocString = asDoc.commentNoEnd();
+	                String ignoreToken = JSFlexJSEmitterTokens.IGNORE_IMPORT
+	                        .getToken();
+	                int ignoreIndex = asDocString.indexOf(ignoreToken);
+	                while (ignoreIndex != -1)
+	                {
+	                    String ignorable = asDocString.substring(ignoreIndex
+	                            + ignoreToken.length());
+	                    int endIndex = ignorable.indexOf("\n");
+	                    ignorable = ignorable.substring(0, endIndex);
+	                    ignorable = ignorable.trim();
+	                    // pretend we've already written the goog.requires for this
+	                    writtenRequires.add(ignorable);
+	                    ignoreIndex = asDocString.indexOf(ignoreToken,
+	                            ignoreIndex + ignoreToken.length());
+	                }
+	            }
+	        }
+        }
+        
+        //        if (project == null)
+        //            project = getWalker().getProject();
+
+        FlexJSProject flexProject = (FlexJSProject) getProject();
+        ASProjectScope projectScope = (ASProjectScope) flexProject.getScope();
+        ICompilationUnit cu = projectScope
+                .getCompilationUnitForDefinition(type != null ? type : otherMainDefinition);
+        ArrayList<String> requiresList = flexProject.getRequires(cu);
+        ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
+        
+        String cname = (type != null) ? type.getQualifiedName() : otherMainDefinition.getQualifiedName();
+        writtenRequires.add(cname); // make sure we don't add ourselves
+
+        boolean emitsRequires = false;
+        if (requiresList != null)
+        {
+            Collections.sort(requiresList);
+            for (String imp : requiresList)
+            {
+                if (imp.contains(JSGoogEmitterTokens.AS3.getToken()))
+                    continue;
+
+                if (imp.equals(JSGoogEmitterTokens.GOOG_BIND.getToken()))
+                    continue;
+
+                if (imp.equals(cname))
+                    continue;
+
+                if (NativeUtils.isNative(imp))
+                {
+                	if (!(imp.equals("QName") || imp.equals("Namespace") || imp.equals("XML") || imp.equals("XMLList")))
+                		continue;                	
+                }
+
+                if (writtenRequires.indexOf(imp) == -1)
+                {
+
+                    /* goog.require('x');\n */
+                    write(JSGoogEmitterTokens.GOOG_REQUIRE);
+                    write(ASEmitterTokens.PAREN_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(fjs.formatQualifiedName(imp));
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.PAREN_CLOSE);
+                    writeNewline(ASEmitterTokens.SEMICOLON);
+
+                    writtenRequires.add(imp);
+
+                    emitsRequires = true;
+                }
+            }
+        }
+
+        boolean emitsInterfaces = false;
+        if (interfacesList != null)
+        {
+            Collections.sort(interfacesList);
+            for (String imp : interfacesList)
+            {
+                if (writtenRequires.indexOf(imp) == -1)
+                {
+                    write(JSGoogEmitterTokens.GOOG_REQUIRE);
+                    write(ASEmitterTokens.PAREN_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(fjs.formatQualifiedName(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 makingSWC = flexProject.getSWFTarget() != null && 
+        					flexProject.getSWFTarget().getTargetType() == TargetType.SWC;
+        boolean isMainCU = flexProject.mainCU != null
+                && cu.getName().equals(flexProject.mainCU.getName());
+        if (isMainCU || makingSWC)
+        {
+            ICompilerProject project = this.getProject();
+            if (project instanceof FlexJSProject)
+            {
+            	if (((FlexJSProject)project).needLanguage)
+            	{
+		            write(JSGoogEmitterTokens.GOOG_REQUIRE);
+		            write(ASEmitterTokens.PAREN_OPEN);
+		            write(ASEmitterTokens.SINGLE_QUOTE);
+		            write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+		            write(ASEmitterTokens.SINGLE_QUOTE);
+		            write(ASEmitterTokens.PAREN_CLOSE);
+		            writeNewline(ASEmitterTokens.SEMICOLON);
+            	}
+            }
+        }
+
+        if (emitsRequires || emitsInterfaces || isMainCU)
+        {
+            writeNewline();
+        }
+
+        writeNewline();
+        writeNewline();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParameterEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParameterEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParameterEmitter.java
new file mode 100644
index 0000000..832d691
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParameterEmitter.java
@@ -0,0 +1,61 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+
+public class ParameterEmitter extends JSSubEmitter implements
+        ISubEmitter<IParameterNode>
+{
+    public ParameterEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IParameterNode node)
+    {
+        startMapping(node);
+        if (node.isRest())
+        {
+            write(ASEmitterTokens.ELLIPSIS);
+            write(node.getName());
+        }
+        else
+        {
+            getWalker().walk(node.getNameExpressionNode());
+            write(ASEmitterTokens.COLON);
+            getWalker().walk(node.getVariableTypeNode());
+            IExpressionNode anode = node.getAssignedValueNode();
+            if (anode != null)
+            {
+                write(ASEmitterTokens.SPACE);
+                writeToken(ASEmitterTokens.EQUAL);
+                getWalker().walk(anode);
+            }
+        }
+        endMapping(node);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParametersEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParametersEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParametersEmitter.java
new file mode 100644
index 0000000..01e1f25
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ParametersEmitter.java
@@ -0,0 +1,64 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+
+public class ParametersEmitter extends JSSubEmitter implements
+        ISubEmitter<IContainerNode>
+{
+    public ParametersEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IContainerNode node)
+    {
+        startMapping(node);
+        write(ASEmitterTokens.PAREN_OPEN);
+        endMapping(node);
+
+        int len = node.getChildCount();
+        for (int i = 0; i < len; i++)
+        {
+            IParameterNode parameterNode = (IParameterNode) node.getChild(i);
+            getWalker().walk(parameterNode); //emitParameter
+            if (i < len - 1)
+            {
+                //we're mapping the comma to the container, but we use the
+                //parameter line/column in case the comma is not on the same
+                //line as the opening (
+                startMapping(node, parameterNode);
+                writeToken(ASEmitterTokens.COMMA);
+                endMapping(node);
+            }
+        }
+
+        startMapping(node, node.getLine(), node.getColumn() + node.getAbsoluteEnd() - node.getAbsoluteStart() - 1);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        endMapping(node);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ReturnEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ReturnEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ReturnEmitter.java
new file mode 100644
index 0000000..407b80c
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/ReturnEmitter.java
@@ -0,0 +1,57 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IReturnNode;
+
+public class ReturnEmitter extends JSSubEmitter implements
+        ISubEmitter<IReturnNode>
+{
+    public ReturnEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IReturnNode node)
+    {
+        IExpressionNode rnode = node.getReturnValueNode();
+        boolean hasReturnValue = rnode != null && rnode.getNodeID() != ASTNodeID.NilID;
+
+        startMapping(node);
+        write(ASEmitterTokens.RETURN);
+        if (hasReturnValue)
+        {
+            write(ASEmitterTokens.SPACE);
+        }
+        endMapping(node);
+
+        if (hasReturnValue)
+        {
+            getWalker().walk(rnode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SelfReferenceEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SelfReferenceEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SelfReferenceEmitter.java
new file mode 100644
index 0000000..6e662ce
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SelfReferenceEmitter.java
@@ -0,0 +1,52 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+
+public class SelfReferenceEmitter extends JSSubEmitter implements
+        ISubEmitter<IFunctionNode>
+{
+
+    public SelfReferenceEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IFunctionNode node)
+    {
+        // we don't want 'var self = this;' in FlexJS
+        // unless there are anonymous functions
+        if (node.containsLocalFunctions())
+        {
+            writeToken(ASEmitterTokens.VAR);
+            writeToken(JSGoogEmitterTokens.SELF);
+            writeToken(ASEmitterTokens.EQUAL);
+            write(ASEmitterTokens.THIS);
+            writeNewline(ASEmitterTokens.SEMICOLON);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SourceMapDirectiveEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SourceMapDirectiveEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SourceMapDirectiveEmitter.java
new file mode 100644
index 0000000..14674de
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SourceMapDirectiveEmitter.java
@@ -0,0 +1,60 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.clients.JSConfiguration;
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+
+public class SourceMapDirectiveEmitter extends JSSubEmitter implements
+        ISubEmitter<ITypeNode>
+{
+    public SourceMapDirectiveEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(ITypeNode node)
+    {
+        boolean sourceMap = false;
+
+        IBlockWalker walker = getWalker();
+        FlexJSProject project = (FlexJSProject) walker.getProject();
+        if (project != null)
+        {
+            JSConfiguration config = project.config;
+            if (config != null)
+            {
+                sourceMap = config.getSourceMap();
+            }
+        }
+
+        if (sourceMap)
+        {
+            writeNewline();
+            write("//# sourceMappingURL=./" + node.getName() + ".js.map");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
new file mode 100644
index 0000000..7cf897c
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
@@ -0,0 +1,55 @@
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IStatementNode;
+
+public class StatementEmitter extends JSSubEmitter implements
+        ISubEmitter<IASNode>
+{
+    public StatementEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IASNode node)
+    {
+        getWalker().walk(node);
+
+        // XXX (mschmalle) this should be in the after handler?
+        if (node.getParent().getNodeID() != ASTNodeID.LabledStatementID
+                && node.getNodeID() != ASTNodeID.ConfigBlockID
+                && !(node instanceof IStatementNode))
+        {
+            startMapping(node, node);
+            write(ASEmitterTokens.SEMICOLON);
+            endMapping(node);
+        }
+
+        if (!isLastStatement(node))
+            writeNewline();
+    }
+
+    protected static boolean isLastStatement(IASNode node)
+    {
+        return getChildIndex(node.getParent(), node) == node.getParent()
+                .getChildCount() - 1;
+    }
+
+    // this is not fair that we have to do this if (i < len - 1)
+    private static int getChildIndex(IASNode parent, IASNode node)
+    {
+        final int len = parent.getChildCount();
+        for (int i = 0; i < len; i++)
+        {
+            if (parent.getChild(i) == node)
+                return i;
+        }
+        return -1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
new file mode 100644
index 0000000..5546ee0
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
@@ -0,0 +1,268 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.clients.MXMLJSC.JSOutputType;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
+import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IFunctionCallNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+
+public class SuperCallEmitter extends JSSubEmitter
+{
+
+    public SuperCallEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    public void emit(IASNode node, String type)
+    {
+        IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
+                : null;
+        IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
+                : null;
+
+        final IClassDefinition thisClass = getModel().getCurrentClass();
+
+        if (type == JSSessionModel.SUPER_FUNCTION_CALL)
+        {
+            if (fnode == null)
+                fnode = (IFunctionNode) fcnode
+                        .getAncestorOfType(IFunctionNode.class);
+
+            if (fnode != null && fnode.isConstructor()
+                    && !EmitterUtils.hasSuperClass(getProject(), fnode))
+                return;
+
+            IClassNode cnode = (IClassNode) node
+                    .getAncestorOfType(IClassNode.class);
+
+            // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
+            if (cnode == null && MXMLJSC.jsOutputType == JSOutputType.VF2JS)
+                return;
+
+            if (fnode != null
+                    && (fnode.getNodeID() == ASTNodeID.GetterID || fnode
+                            .getNodeID() == ASTNodeID.SetterID))
+            {
+                ICompilerProject project = this.getProject();
+                if (project instanceof FlexJSProject)
+                	((FlexJSProject)project).needLanguage = true;
+                write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+                write(ASEmitterTokens.MEMBER_ACCESS);
+                if (fnode.getNodeID() == ASTNodeID.GetterID)
+                    write(JSFlexJSEmitterTokens.SUPERGETTER);
+                else
+                    write(JSFlexJSEmitterTokens.SUPERSETTER);
+                write(ASEmitterTokens.PAREN_OPEN);
+                if (cnode == null && thisClass != null)
+                    write(getEmitter().formatQualifiedName(
+                            thisClass.getQualifiedName()));
+                else
+                    write(getEmitter().formatQualifiedName(
+                            cnode.getQualifiedName()));
+                writeToken(ASEmitterTokens.COMMA);
+                write(ASEmitterTokens.THIS);
+                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 != null && fnode.isConstructor())
+                {
+                    anodes = fnode.getParameterNodes();
+
+                    writeArguments = (anodes != null && anodes.length > 0);
+                }
+                else if (node instanceof IFunctionNode
+                        && node instanceof BinaryOperatorAssignmentNode)
+                {
+                    BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node;
+
+                    IFunctionNode pnode = (IFunctionNode) bnode
+                            .getAncestorOfType(IFunctionNode.class);
+
+                    if (pnode.getNodeID() == ASTNodeID.SetterID)
+                    {
+                        writeToken(ASEmitterTokens.COMMA);
+                        getWalker().walk(bnode.getRightOperandNode());
+                    }
+                }
+
+                if (writeArguments)
+                {
+                    int len = anodes.length;
+                    for (int i = 0; i < len; i++)
+                    {
+                        writeToken(ASEmitterTokens.COMMA);
+
+                        getWalker().walk(anodes[i]);
+                    }
+                }
+
+                write(ASEmitterTokens.PAREN_CLOSE);
+                return;
+            }
+        }
+        super_emitSuperCall(node, type);
+    }
+
+    protected void super_emitSuperCall(IASNode node, String type)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
+                : null;
+        IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
+                : null;
+
+        if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
+        {
+            indentPush();
+            writeNewline();
+            indentPop();
+        }
+        else if (type == JSSessionModel.SUPER_FUNCTION_CALL)
+        {
+            if (fnode == null)
+                fnode = (IFunctionNode) fcnode
+                        .getAncestorOfType(IFunctionNode.class);
+        }
+
+        if (fnode.isConstructor()
+                && !EmitterUtils.hasSuperClass(getProject(), fnode))
+            return;
+
+        IClassNode cnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+
+        if (cnode == null)
+        {
+            IDefinition cdef = getModel().getCurrentClass();
+            write(fjs.formatQualifiedName(cdef.getQualifiedName()));
+        }
+        else
+            write(fjs.formatQualifiedName(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);
+            IExpressionNode namenode = fcnode.getNameNode();
+            String superName = fnode.getName();
+            if (namenode instanceof MemberAccessExpressionNode)
+            {
+            	namenode = ((MemberAccessExpressionNode)namenode).getRightOperandNode();
+            	if (namenode instanceof IdentifierNode)
+            	{
+            		superName = ((IdentifierNode)namenode).getName();
+            	}
+            }
+            write(superName);
+            write(ASEmitterTokens.SINGLE_QUOTE);
+        }
+
+        IASNode[] anodes = null;
+        boolean writeArguments = false;
+        if (fcnode != null)
+        {
+            anodes = fcnode.getArgumentNodes();
+
+            writeArguments = anodes.length > 0;
+        }
+        else if (fnode.isConstructor())
+        {
+        	// I think we only get here for implicit super calls
+        	// (when there is no mention of super() in the constructor
+        	// code and the compiler autogenerates the super() call)
+        	// and implicit super calls do not have parameters passed
+        	// to them.
+        	/*
+            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 == JSSessionModel.CONSTRUCTOR_FULL)
+        {
+            write(ASEmitterTokens.SEMICOLON);
+            writeNewline();
+        }
+        else if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
+        {
+            write(ASEmitterTokens.SEMICOLON);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/TernaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/TernaryOperatorEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/TernaryOperatorEmitter.java
new file mode 100644
index 0000000..8273e1b
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/TernaryOperatorEmitter.java
@@ -0,0 +1,67 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IOperatorNode;
+import org.apache.flex.compiler.tree.as.ITernaryOperatorNode;
+import org.apache.flex.compiler.utils.ASNodeUtils;
+
+public class TernaryOperatorEmitter extends JSSubEmitter implements
+        ISubEmitter<ITernaryOperatorNode>
+{
+    public TernaryOperatorEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(ITernaryOperatorNode node)
+    {
+        if (ASNodeUtils.hasParenOpen((IOperatorNode) node))
+            write(ASEmitterTokens.PAREN_OPEN);
+
+        IExpressionNode conditionalNode = node.getConditionalNode();
+        getWalker().walk(conditionalNode);
+
+        IExpressionNode leftOperandNode = node.getLeftOperandNode();
+        startMapping(node, conditionalNode);
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.TERNARY);
+        endMapping(node);
+
+        getWalker().walk(leftOperandNode);
+
+        IExpressionNode rightOperandNode = node.getRightOperandNode();
+        startMapping(node, leftOperandNode);
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.COLON);
+        endMapping(node);
+
+        getWalker().walk(rightOperandNode);
+
+        if (ASNodeUtils.hasParenClose((IOperatorNode) node))
+            write(ASEmitterTokens.PAREN_CLOSE);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/UnaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/UnaryOperatorEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/UnaryOperatorEmitter.java
new file mode 100644
index 0000000..88bb154
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/UnaryOperatorEmitter.java
@@ -0,0 +1,122 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
+import org.apache.flex.compiler.utils.ASNodeUtils;
+
+public class UnaryOperatorEmitter extends JSSubEmitter implements
+        ISubEmitter<IUnaryOperatorNode>
+{
+    public UnaryOperatorEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IUnaryOperatorNode node)
+    {
+        if (ASNodeUtils.hasParenOpen(node))
+            write(ASEmitterTokens.PAREN_OPEN);
+
+        if (node.getNodeID() == ASTNodeID.Op_PreIncrID
+                || node.getNodeID() == ASTNodeID.Op_PreDecrID
+                || node.getNodeID() == ASTNodeID.Op_BitwiseNotID
+                || node.getNodeID() == ASTNodeID.Op_LogicalNotID
+                || node.getNodeID() == ASTNodeID.Op_SubtractID
+                || node.getNodeID() == ASTNodeID.Op_AddID)
+        {
+            emitPreUnaryOperator(node);
+        }
+        else if (node.getNodeID() == ASTNodeID.Op_PostIncrID
+                || node.getNodeID() == ASTNodeID.Op_PostDecrID)
+        {
+            emitPostUnaryOperator(node);
+        }
+        else if (node.getNodeID() == ASTNodeID.Op_DeleteID)
+        {
+            emitDeleteOperator(node);
+        }
+        else if (node.getNodeID() == ASTNodeID.Op_VoidID)
+        {
+            emitVoidOperator(node);
+        }
+        else if (node.getNodeID() == ASTNodeID.Op_TypeOfID)
+        {
+            emitTypeOfOperator(node);
+        }
+
+        if (ASNodeUtils.hasParenClose(node))
+            write(ASEmitterTokens.PAREN_CLOSE);
+    }
+
+    public void emitPreUnaryOperator(IUnaryOperatorNode node)
+    {
+        startMapping(node);
+        write(node.getOperator().getOperatorText());
+        IExpressionNode opNode = node.getOperandNode();
+        endMapping(node);
+        getWalker().walk(opNode);
+    }
+
+    protected void emitPostUnaryOperator(IUnaryOperatorNode node)
+    {
+        IExpressionNode operandNode = node.getOperandNode();
+        getWalker().walk(operandNode);
+        startMapping(node, operandNode);
+        write(node.getOperator().getOperatorText());
+        endMapping(node);
+    }
+
+    protected void emitDeleteOperator(IUnaryOperatorNode node)
+    {
+        startMapping(node);
+        writeToken(node.getOperator().getOperatorText());
+        endMapping(node);
+        getWalker().walk(node.getOperandNode());
+    }
+
+    protected void emitVoidOperator(IUnaryOperatorNode node)
+    {
+        startMapping(node);
+        writeToken(node.getOperator().getOperatorText());
+        endMapping(node);
+        getWalker().walk(node.getOperandNode());
+    }
+
+    protected void emitTypeOfOperator(IUnaryOperatorNode node)
+    {
+        startMapping(node);
+        write(node.getOperator().getOperatorText());
+        write(ASEmitterTokens.PAREN_OPEN);
+        endMapping(node);
+        IExpressionNode operandNode = node.getOperandNode();
+        getWalker().walk(operandNode);
+        startMapping(node);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        endMapping(node);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
new file mode 100644
index 0000000..f43b288
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
@@ -0,0 +1,123 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IEmbedNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+
+public class VarDeclarationEmitter extends JSSubEmitter implements
+        ISubEmitter<IVariableNode>
+{
+
+    public VarDeclarationEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IVariableNode node)
+    {
+        // TODO (mschmalle) will remove this cast as more things get abstracted
+        JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+        getModel().getVars().add(node);
+        
+        if (!(node instanceof ChainedVariableNode) && !node.isConst())
+        {
+            fjs.emitMemberKeyword(node);
+        }
+
+        IExpressionNode variableTypeNode = node.getVariableTypeNode();
+        if(variableTypeNode.getLine() >= 0)
+        {
+            startMapping(variableTypeNode,
+                    variableTypeNode.getLine(),
+                    variableTypeNode.getColumn() - 1); //include the :
+        }
+        else
+        {
+            //the result of getVariableTypeNode() may not have a line and
+            //column. this can happen when the type is omitted in the code, and
+            //the compiler generates a node for type *.
+            //in this case, put it at the end of the name expression.
+            IExpressionNode nameExpressionNode = node.getNameExpressionNode();
+            startMapping(variableTypeNode, nameExpressionNode.getLine(),
+                    nameExpressionNode.getColumn() + nameExpressionNode.getAbsoluteEnd() - nameExpressionNode.getAbsoluteStart());
+        }
+        IExpressionNode avnode = node.getAssignedValueNode();
+        if (avnode != null)
+        {
+            IDefinition def = avnode.resolveType(getWalker().getProject());
+
+            String opcode = avnode.getNodeID().getParaphrase();
+            if (opcode != "AnonymousFunction")
+            {
+                fjs.getDocEmitter().emitVarDoc(node, def, getWalker().getProject());
+            }
+        }
+        else
+        {
+            fjs.getDocEmitter().emitVarDoc(node, null, getWalker().getProject());
+        }
+        endMapping(variableTypeNode);
+
+        if (!(node instanceof ChainedVariableNode) && node.isConst())
+        {
+            fjs.emitMemberKeyword(node);
+        }
+
+        fjs.emitDeclarationName(node);
+        if (avnode != null && !(avnode instanceof IEmbedNode))
+        {
+            startMapping(node, node.getVariableTypeNode());
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            endMapping(node);
+            fjs.emitAssignedValue(avnode);
+        }
+
+        if (!(node instanceof ChainedVariableNode))
+        {
+            // check for chained variables
+            int len = node.getChildCount();
+            for (int i = 0; i < len; i++)
+            {
+                IASNode child = node.getChild(i);
+                if (child instanceof ChainedVariableNode)
+                {
+                    startMapping(node, node.getChild(i - 1));
+                    writeToken(ASEmitterTokens.COMMA);
+                    endMapping(node);
+                    fjs.emitVarDeclaration((IVariableNode) child);
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WhileLoopEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
new file mode 100644
index 0000000..54f663d
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WhileLoopEmitter.java
@@ -0,0 +1,61 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IWhileLoopNode;
+
+public class WhileLoopEmitter extends JSSubEmitter implements
+        ISubEmitter<IWhileLoopNode>
+{
+    public WhileLoopEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IWhileLoopNode node)
+    {
+        IContainerNode cnode = (IContainerNode) node.getChild(1);
+
+        startMapping(node);
+        writeToken(ASEmitterTokens.WHILE);
+        write(ASEmitterTokens.PAREN_OPEN);
+        endMapping(node);
+
+        IASNode conditionalExpression = node.getConditionalExpressionNode();
+        getWalker().walk(conditionalExpression);
+
+        IASNode statementContentsNode = node.getStatementContentsNode();
+        startMapping(node, conditionalExpression);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        if (!EmitterUtils.isImplicit(cnode))
+            write(ASEmitterTokens.SPACE);
+        endMapping(node);
+
+        getWalker().walk(statementContentsNode);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
new file mode 100644
index 0000000..88b379a
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
@@ -0,0 +1,63 @@
+/*
+ *
+ *  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.node;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCPublisher;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+public class NodePublisher extends JSCPublisher
+{
+    public NodePublisher(Configuration config, FlexJSProject project)
+    {
+        super(config, project);
+    }
+
+    @Override
+    protected void writeHTML(String type, String projectName, String dirPath,
+                             String deps, List<String> additionalHTML) throws IOException
+    {
+        StringBuilder contents = new StringBuilder();
+        if ("intermediate".equals(type))
+        {
+            contents.append("require(\"./library/closure/goog/bootstrap/nodejs\");\n");
+            contents.append(deps);
+            contents.append("goog.require(\"");
+            contents.append(projectName);
+            contents.append("\");\n");
+            contents.append("new " + projectName + "();");
+        }
+        else 
+        {
+            contents.append("new ");
+            contents.append("require(\"./");
+            contents.append(projectName);
+            contents.append("\")");
+            contents.append(".");
+            contents.append(projectName);
+            contents.append("();");
+        }
+        writeFile(dirPath + File.separator + "index.js", contents.toString(), false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
new file mode 100644
index 0000000..7d7bf16
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/DocEmitterUtils.java
@@ -0,0 +1,49 @@
+/*
+ *
+ *  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.utils;
+
+import java.util.ArrayList;
+
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+
+public class DocEmitterUtils
+{
+    public static void loadImportIgnores(JSFlexJSEmitter emitter, String doc)
+    {
+        ArrayList<String> ignoreList = new ArrayList<String>();
+        String ignoreToken = JSFlexJSEmitterTokens.IGNORE_IMPORT.getToken();
+        int index = doc.indexOf(ignoreToken);
+        while (index != -1)
+        {
+            String ignorable = doc.substring(index + ignoreToken.length());
+            int endIndex = ignorable.indexOf("\n");
+            ignorable = ignorable.substring(0, endIndex);
+            ignorable = ignorable.trim();
+            ignoreList.add(ignorable);
+            System.out.println("Found ignorable: " + ignorable);
+            index = doc.indexOf(ignoreToken, index + endIndex);
+        }
+        
+        // TODO (mschmalle)
+        ((JSFlexJSDocEmitter)emitter.getDocEmitter()).setClassIgnoreList(ignoreList);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
new file mode 100644
index 0000000..ebe21ee
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/utils/EmitterUtils.java
@@ -0,0 +1,513 @@
+/*
+ *
+ *  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.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+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.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.ITypeDefinition;
+import org.apache.flex.compiler.definitions.IVariableDefinition;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
+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.ParameterDefinition;
+import org.apache.flex.compiler.internal.definitions.VariableDefinition;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.scopes.TypeScope;
+import org.apache.flex.compiler.internal.tree.as.ContainerNode;
+import org.apache.flex.compiler.internal.tree.as.NodeBase;
+import org.apache.flex.compiler.internal.tree.as.ParameterNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+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.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IIdentifierNode;
+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.ITypeNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.utils.NativeUtils;
+
+/**
+ * Various static methods used in shared emitter logic.
+ */
+public class EmitterUtils
+{
+    public static ITypeNode findTypeNode(IPackageNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        for (int i = 0; i < scope.getChildCount(); i++)
+        {
+            IASNode child = scope.getChild(i);
+            if (child instanceof ITypeNode)
+                return (ITypeNode) child;
+        }
+        return null;
+    }
+
+    public static ITypeDefinition findType(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof ITypeDefinition)
+                return (ITypeDefinition) definition;
+        }
+        return null;
+    }
+
+    public static IFunctionDefinition findFunction(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof IFunctionDefinition)
+                return (IFunctionDefinition) definition;
+        }
+        return null;
+    }
+
+    public static IFunctionNode findFunctionNode(IPackageNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        for (int i = 0; i < scope.getChildCount(); i++)
+        {
+            IASNode child = scope.getChild(i);
+            if (child instanceof IFunctionNode)
+                return (IFunctionNode) child;
+        }
+        return null;
+    }
+
+    public static IVariableNode findVariableNode(IPackageNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        for (int i = 0; i < scope.getChildCount(); i++)
+        {
+            IASNode child = scope.getChild(i);
+            if (child instanceof IVariableNode)
+                return (IVariableNode) child;
+        }
+        return null;
+    }
+
+    public static IVariableDefinition findVariable(Collection<IDefinition> definitions)
+    {
+        for (IDefinition definition : definitions)
+        {
+            if (definition instanceof IVariableDefinition)
+                return (IVariableDefinition) definition;
+        }
+        return null;
+    }
+
+    public static ITypeDefinition getTypeDefinition(IDefinitionNode node)
+    {
+        ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
+        if (tnode != null)
+        {
+            return (ITypeDefinition) tnode.getDefinition();
+        }
+        return null;
+    }
+
+    public static boolean isSameClass(IDefinition pdef, IDefinition thisClass,
+            ICompilerProject project)
+    {
+        if (pdef == thisClass)
+            return true;
+
+        IDefinition cdef = ((ClassDefinition) thisClass)
+                .resolveBaseClass(project);
+        while (cdef != null)
+        {
+            // needs to be a loop
+            if (cdef == pdef)
+                return true;
+            cdef = ((ClassDefinition) cdef).resolveBaseClass(project);
+        }
+        return false;
+    }
+
+    public static boolean hasSuperClass(ICompilerProject project,
+            IDefinitionNode node)
+    {
+        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);
+    }
+
+    public static 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;
+    }
+
+    public static boolean hasBody(IFunctionNode node)
+    {
+        IScopedNode scope = node.getScopedNode();
+        return scope.getChildCount() > 0;
+    }
+
+    public static IClassDefinition getSuperClassDefinition(
+            IDefinitionNode node, ICompilerProject project)
+    {
+        IDefinition parent = node.getDefinition().getParent();
+        if (parent instanceof IClassDefinition)
+        {
+            IClassDefinition parentClassDef = (IClassDefinition) parent;
+            IClassDefinition superClass = parentClassDef.resolveBaseClass(project);
+            return superClass;
+        }
+        return null;
+    }
+
+    public static 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;
+    }
+
+    public static IClassDefinition getClassDefinition(IDefinitionNode node)
+    {
+        IClassNode tnode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+        return (tnode != null) ? tnode.getDefinition() : null;
+    }
+
+    public static IParameterNode getRest(IParameterNode[] nodes)
+    {
+        for (IParameterNode node : nodes)
+        {
+            if (node.isRest())
+                return node;
+        }
+
+        return null;
+    }
+
+    public static 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;
+    }
+
+    public static boolean writeThis(ICompilerProject project,
+            JSSessionModel model, IIdentifierNode node)
+    {
+        IClassNode classNode = (IClassNode) node
+                .getAncestorOfType(IClassNode.class);
+
+        IDefinition nodeDef = node.resolve(project);
+
+        IASNode parentNode = node.getParent();
+        ASTNodeID parentNodeId = parentNode.getNodeID();
+
+        IASNode firstChild = parentNode.getChild(0);
+
+        final IClassDefinition thisClass = model.getCurrentClass();
+
+        boolean identifierIsMemberAccess = parentNodeId == ASTNodeID.MemberAccessExpressionID;
+
+        if (nodeDef instanceof ParameterDefinition)
+            return false;
+        
+        if (classNode == null) // script in MXML and AS interface definitions
+        {
+            if (nodeDef instanceof VariableDefinition)
+            {
+                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();
+
+                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
+            {
+                boolean isFileOrPackageMember = false;
+                if(nodeDef instanceof FunctionDefinition)
+                {
+                    FunctionClassification classification = ((FunctionDefinition) nodeDef).getFunctionClassification();
+                    if(classification == FunctionClassification.FILE_MEMBER ||
+                            classification == FunctionClassification.PACKAGE_MEMBER)
+                    {
+                        isFileOrPackageMember = true;
+                    }
+                }
+                return parentNodeId == ASTNodeID.FunctionCallID
+                        && !(nodeDef instanceof AccessorDefinition)
+                        && !identifierIsMemberAccess
+                        && !isFileOrPackageMember;
+            }
+        }
+        else
+        {
+            if (nodeDef != null && !nodeDef.isInternal()
+                    && isClassMember(project, nodeDef, classNode))
+            {
+                if (identifierIsMemberAccess)
+                {
+                    return node == firstChild;
+                }
+                else
+                {
+                    boolean identifierIsLocalFunction = nodeDef instanceof FunctionDefinition
+                            && !(nodeDef instanceof AccessorDefinition)
+                            && ((FunctionDefinition) nodeDef)
+                                    .getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL;
+
+                    return !identifierIsLocalFunction;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public static boolean isClassMember(ICompilerProject project,
+            IDefinition nodeDef, IClassNode classNode)
+    {
+        TypeScope cscope = (TypeScope) classNode.getDefinition()
+                .getContainedScope();
+
+        Set<INamespaceDefinition> nsSet = cscope.getNamespaceSet(project);
+        Collection<IDefinition> defs = new HashSet<IDefinition>();
+
+        cscope.getAllPropertiesForMemberAccess((CompilerProject) project, defs,
+                nsSet);
+
+        Iterator<IDefinition> visiblePropertiesIterator = defs.iterator();
+        while (visiblePropertiesIterator.hasNext())
+        {
+            if (nodeDef.getQualifiedName().equals(
+                    visiblePropertiesIterator.next().getQualifiedName()))
+                return true;
+        }
+
+        return false;
+    }
+    
+    public static boolean isScalar(IExpressionNode node)
+    {
+    	ASTNodeID id = node.getNodeID();
+        if (id == ASTNodeID.LiteralBooleanID ||
+        		id == ASTNodeID.LiteralIntegerID ||
+        		id == ASTNodeID.LiteralIntegerZeroID ||
+        		id == ASTNodeID.LiteralDoubleID ||
+        		id == ASTNodeID.LiteralNullID ||
+        		id == ASTNodeID.LiteralNumberID ||
+        		id == ASTNodeID.LiteralRegexID ||
+        		id == ASTNodeID.LiteralStringID ||
+        		id == ASTNodeID.LiteralUintID)
+        	return true;
+        if (id == ASTNodeID.IdentifierID)
+        {
+        	IIdentifierNode idnode = (IIdentifierNode)node;
+        	String idname = idnode.getName();
+        	if (idname.equals(NativeUtils.NativeASType.Infinity.name()) ||
+        		idname.equals(NativeUtils.NativeASType.undefined.name()) ||
+        		idname.equals(NativeUtils.NativeASType.NaN.name()))
+        		return true;
+        }
+        // special case -Infinity
+        if (id == ASTNodeID.Op_SubtractID &&
+        		node.getChildCount() == 1)
+        {
+        	IASNode child = node.getChild(0);
+        	if (child.getNodeID() == ASTNodeID.IdentifierID)
+        	{
+            	IIdentifierNode idnode = (IIdentifierNode)child;
+            	String idname = idnode.getName();
+            	if (idname.equals(NativeUtils.NativeASType.Infinity.name()))
+            		return true;        		
+        	}
+        }
+        return false;
+    }
+
+    public static IContainerNode insertArgumentsBefore(IContainerNode argumentsNode, IASNode... nodes)
+    {
+        int originalLength = argumentsNode.getChildCount();
+        int extraLength = nodes.length;
+        ContainerNode result = new ContainerNode(originalLength + extraLength);
+        result.setSourcePath(argumentsNode.getSourcePath());
+        result.span(argumentsNode);
+        result.setParent((NodeBase) argumentsNode.getParent());
+        for (int i = 0; i < extraLength; i++)
+        {
+            NodeBase node = (NodeBase) nodes[i];
+            node.setSourcePath(argumentsNode.getSourcePath());
+            result.addItem(node);
+        }
+        for (int i = 0; i < originalLength; i++)
+        {
+            result.addItem((NodeBase) argumentsNode.getChild(i));
+        }
+        return result;
+    }
+
+    public static IContainerNode insertArgumentsAfter(IContainerNode argumentsNode, IASNode... nodes)
+    {
+        int originalLength = argumentsNode.getChildCount();
+        int extraLength = nodes.length;
+        ContainerNode result = new ContainerNode(originalLength + extraLength);
+        result.setSourcePath(argumentsNode.getSourcePath());
+        result.span(argumentsNode);
+        result.setParent((NodeBase) argumentsNode.getParent());
+        for (int i = 0; i < originalLength; i++)
+        {
+            result.addItem((NodeBase) argumentsNode.getChild(i));
+        }
+        for (int i = 0; i < extraLength; i++)
+        {
+            NodeBase node = (NodeBase) nodes[i];
+            node.setSourcePath(argumentsNode.getSourcePath());
+            result.addItem(node);
+        }
+        return result;
+    }
+
+    public static IContainerNode insertArgumentsAt(IContainerNode argumentsNode, int index, IASNode... nodes)
+    {
+        int originalLength = argumentsNode.getChildCount();
+        int extraLength = nodes.length;
+        ContainerNode result = new ContainerNode(originalLength + extraLength);
+        result.setSourcePath(argumentsNode.getSourcePath());
+        result.span(argumentsNode);
+        result.setParent((NodeBase) argumentsNode.getParent());
+        for (int i = 0; i < originalLength; i++)
+        {
+            if(i < originalLength)
+            {
+                result.addItem((NodeBase) argumentsNode.getChild(i));
+            }
+            else
+            {
+                int j = i;
+                if (i >= index + extraLength)
+                {
+                    j -= extraLength;
+                    result.addItem((NodeBase) argumentsNode.getChild(j));
+                }
+                else
+                {
+                    j -= originalLength;
+                    NodeBase node = (NodeBase) nodes[j];
+                    node.setSourcePath(argumentsNode.getSourcePath());
+                    result.addItem(node);
+                }
+            }
+        }
+        return result;
+    }
+
+    public static boolean isImplicit(IContainerNode node)
+    {
+        return node.getContainerType() == IContainerNode.ContainerType.IMPLICIT
+                || node.getContainerType() == IContainerNode.ContainerType.SYNTHESIZED;
+    }
+
+}