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:24 UTC

[32/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/mxml/vf2js/MXMLVF2JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
new file mode 100644
index 0000000..164806c
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
@@ -0,0 +1,600 @@
+/*
+ *
+ *  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.mxml.vf2js;
+
+import java.io.*;
+import java.net.URL;
+import java.util.*;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.filefilter.RegexFileFilter;
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.codegen.js.IJSPublisher;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
+import org.apache.flex.compiler.internal.driver.js.flexjs.JSCSSCompilationSession;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.graph.VF2JSDepsWriter;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.utils.VF2JSClosureCompilerWrapper;
+
+public class MXMLVF2JSPublisher extends JSGoogPublisher implements
+        IJSPublisher
+{
+
+    public static final String FLEXJS_OUTPUT_DIR_NAME = "bin";
+    public static final String FLEXJS_INTERMEDIATE_DIR_NAME = "js-debug";
+    public static final String FLEXJS_RELEASE_DIR_NAME = "js-release";
+
+    class DependencyRecord
+    {
+        String path;
+        String deps;
+        String line;
+        int lineNumber;
+    }
+    
+    class DependencyLineComparator implements Comparator<DependencyRecord> {
+        @Override
+        public int compare(DependencyRecord o1, DependencyRecord o2) {
+            return new Integer(o1.lineNumber).compareTo(o2.lineNumber);
+        }
+    }
+    
+    public MXMLVF2JSPublisher(Configuration config, FlexJSProject project)
+    {
+        super(config);
+
+        this.isMarmotinniRun = ((JSGoogConfiguration) configuration)
+                .getMarmotinni() != null;
+        this.outputPathParameter = configuration.getOutput();
+        this.useStrictPublishing = ((JSGoogConfiguration) configuration)
+                .getStrictPublish();
+
+        this.project = project;
+    }
+
+    private FlexJSProject project;
+
+    private boolean isMarmotinniRun;
+    private String outputPathParameter;
+    private boolean useStrictPublishing;
+
+    @Override
+    public File getOutputFolder()
+    {
+        // (erikdebruin) - If there is a -marmotinni switch, we want
+        //                 the output redirected to the directory it specifies.
+        //               - If there is an -output switch, use that path as the 
+        //                 output parent folder.
+        if (isMarmotinniRun)
+        {
+            outputParentFolder = new File(
+                    ((JSGoogConfiguration) configuration).getMarmotinni());
+        }
+        else if (outputPathParameter != null)
+        {
+            outputParentFolder = new File(outputPathParameter);
+            // FB usually specified -output <project-path>/bin-release/app.swf
+            if (outputPathParameter.contains(".swf"))
+                outputParentFolder = outputParentFolder.getParentFile().getParentFile();
+        }
+        else
+        {
+            outputParentFolder = new File(
+                    configuration.getTargetFileDirectory()).getParentFile();
+        }
+
+        outputParentFolder = new File(outputParentFolder,
+                FLEXJS_OUTPUT_DIR_NAME);
+
+        outputFolder = new File(outputParentFolder, File.separator
+                + FLEXJS_INTERMEDIATE_DIR_NAME);
+
+        // (erikdebruin) Marmotinni handles file management, so we 
+        //               bypass the setup.
+        if (!isMarmotinniRun)
+            setupOutputFolder();
+
+        return outputFolder;
+    }
+
+    @Override
+    public boolean publish(ProblemQuery problems) throws IOException
+    {
+        boolean ok;
+        boolean subsetGoog = true;
+        
+        final String intermediateDirPath = outputFolder.getPath();
+        final File intermediateDir = new File(intermediateDirPath);
+        File srcDir = new File(configuration.getTargetFile());
+        srcDir = srcDir.getParentFile();
+
+        final String projectName = FilenameUtils.getBaseName(configuration
+                .getTargetFile());
+        final String outputFileName = projectName
+                + "." + JSSharedData.OUTPUT_EXTENSION;
+
+        File releaseDir = new File(outputParentFolder, FLEXJS_RELEASE_DIR_NAME);
+        final String releaseDirPath = releaseDir.getPath();
+
+        if (!isMarmotinniRun)
+        {
+            if (releaseDir.exists())
+                org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
+
+            releaseDir.mkdirs();
+        }
+
+        // If the closure-lib parameter is empty we'll try to find the resources
+        // in the classpath, dump its content to the output directory and use this
+        // as closure-lib parameter.
+        final String closureLibDirPath;
+        if(((JSGoogConfiguration) configuration).isClosureLibSet()) {
+            closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+        } else {
+            // Check if the "goog/deps.js" is available in the classpath.
+            URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
+            if(resource != null) {
+                File closureLibDir = new File(intermediateDir.getParent(), "closure");
+
+                // Only create and dump the content, if the directory does not exists.
+                if(!closureLibDir.exists()) {
+                    if(!closureLibDir.mkdirs()) {
+                        throw new IOException(
+                                "Unable to create directory for closure-lib at " + closureLibDir.getAbsolutePath());
+                    }
+
+                    // Strip the url of the parts we don't need.
+                    // Unless we are not using some insanely complex setup
+                    // the resource will always be on the same machine.
+                    String resourceJarPath = resource.getFile();
+                    if(resourceJarPath.contains(":")) {
+                        resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
+                    }
+                    if(resourceJarPath.contains("!")) {
+                        resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+                    }
+                    File resourceJar = new File(resourceJarPath);
+
+                    // Dump the closure lib from classpath.
+                    dumpJar(resourceJar, closureLibDir);
+                }
+                // The compiler automatically adds a "closure" to the lib dir path,
+                // so we omit this here.
+                closureLibDirPath = intermediateDir.getParentFile().getPath();
+            }
+            // Fallback to the default.
+            else {
+                closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+            }
+        }
+
+        final String closureGoogSrcLibDirPath = closureLibDirPath
+                + "/closure/goog/";
+        final String closureGoogTgtLibDirPath = intermediateDirPath
+                + "/library/closure/goog";
+        final String depsSrcFilePath = intermediateDirPath
+                + "/library/closure/goog/deps.js";
+        final String depsTgtFilePath = intermediateDirPath + "/deps.js";
+        final String projectIntermediateJSFilePath = intermediateDirPath
+                + File.separator + outputFileName;
+        final String projectReleaseJSFilePath = releaseDirPath
+                + File.separator + outputFileName;
+
+        appendExportSymbol(projectIntermediateJSFilePath, projectName);
+        appendEncodedCSS(projectIntermediateJSFilePath, projectName);
+
+        if (!subsetGoog)
+        {
+            // (erikdebruin) We need to leave the 'goog' files and dependencies well
+            //               enough alone. We copy the entire library over so the
+            //               'goog' dependencies will resolve without our help.
+            FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(closureGoogTgtLibDirPath));
+        }
+        
+        VF2JSClosureCompilerWrapper compilerWrapper = new VF2JSClosureCompilerWrapper();
+
+        VF2JSDepsWriter gdw = new VF2JSDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration);
+        try
+        {
+            StringBuilder depsFileData = new StringBuilder();
+            ok = gdw.generateDeps(problems, depsFileData);
+            if (!subsetGoog)
+            {
+                writeFile(depsTgtFilePath, depsFileData.toString(), false); 
+            }
+            else
+            {
+                String s = depsFileData.toString();
+                int c = s.indexOf("'goog.");
+                ArrayList<String> googreqs = new ArrayList<String>();
+                while (c != -1)
+                {
+                    int c2 = s.indexOf("'", c + 1);
+                    String googreq = s.substring(c, c2 + 1);
+                    googreqs.add(googreq);
+                    c = s.indexOf("'goog.", c2);
+                }
+                HashMap<String, DependencyRecord> defmap = new HashMap<String, DependencyRecord>();
+                // read in goog's deps.js
+                FileInputStream fis = new FileInputStream(closureGoogSrcLibDirPath + "/deps.js");
+                Scanner scanner = new Scanner(fis, "UTF-8");
+                String addDependency = "goog.addDependency('";
+                int currentLine = 0;
+                while (scanner.hasNextLine())
+                {
+                    String googline = scanner.nextLine();
+                    if (googline.indexOf(addDependency) == 0)
+                    {
+                        int c1 = googline.indexOf("'", addDependency.length() + 1);
+                        String googpath = googline.substring(addDependency.length(), c1);
+                        String googdefs = googline.substring(googline.indexOf("[") + 1, googline.indexOf("]"));
+                        String googdeps = googline.substring(googline.lastIndexOf("[") + 1, googline.lastIndexOf("]"));
+                        String[] thedefs = googdefs.split(",");
+                        DependencyRecord deprec = new DependencyRecord();
+                        deprec.path = googpath;
+                        deprec.deps = googdeps;
+                        deprec.line = googline;
+                        deprec.lineNumber = currentLine;
+                        for (String def : thedefs)
+                        {
+                            def = def.trim();
+                            defmap.put(def, deprec);
+                        }
+                    }
+                    currentLine++;
+                }
+                // (erikdebruin) Prevent 'Resource leak' warning on line 212:
+                scanner.close();      
+                ArrayList<DependencyRecord> subsetdeps = new ArrayList<DependencyRecord>();
+                HashMap<String, String> gotgoog = new HashMap<String, String>();
+                for (String req : googreqs)
+                {
+                    DependencyRecord deprec = defmap.get(req);
+                    // if we've already processed this file, skip
+                    if (!gotgoog.containsKey(deprec.path))
+                    {
+                        gotgoog.put(deprec.path, null);
+                        subsetdeps.add(deprec);
+                        addDeps(subsetdeps, gotgoog, defmap, deprec.deps);                        
+                    }
+                }
+                // now we should have the subset of files we need in the order needed
+                StringBuilder sb = new StringBuilder();
+                sb.append("goog.addDependency('base.js', ['goog'], []);\n");
+                File file = new File(closureGoogSrcLibDirPath + "/base.js");
+                FileUtils.copyFileToDirectory(file, new File(closureGoogTgtLibDirPath));
+                compilerWrapper.addJSSourceFile(file.getCanonicalPath());
+                Collections.sort(subsetdeps, new DependencyLineComparator());
+                for (DependencyRecord subsetdeprec : subsetdeps)
+                {
+                    sb.append(subsetdeprec.line).append("\n");
+                }
+                writeFile(depsTgtFilePath, sb.toString() + depsFileData.toString(), false);
+                // copy the required files
+                for (String googfn : gotgoog.keySet())
+                {
+                    file = new File(closureGoogSrcLibDirPath + File.separator + googfn);
+                    String dir = closureGoogTgtLibDirPath;
+                    if (googfn.contains("/"))
+                    {
+                        dir += File.separator + googfn.substring(0, googfn.lastIndexOf("/"));
+                    }
+                    FileUtils.copyFileToDirectory(file, new File(dir));
+                    compilerWrapper.addJSSourceFile(file.getCanonicalPath());
+                }
+            }
+        }
+        catch (InterruptedException e)
+        {
+            e.printStackTrace();
+            return false;
+        }
+        
+        IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".png"));
+        IOFileFilter gifSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".gif"));
+        IOFileFilter jpgSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
+                FileFilterUtils.suffixFileFilter(".jpg"));
+        IOFileFilter assetFiles = FileFilterUtils.or(pngSuffixFilter,
+                jpgSuffixFilter, gifSuffixFilter);
+
+        FileUtils.copyDirectory(srcDir, intermediateDir, assetFiles);
+        FileUtils.copyDirectory(srcDir, releaseDir, assetFiles);
+
+        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);
+        writeCSS(projectName, releaseDirPath);
+
+        if (!subsetGoog)
+        {
+            // (erikdebruin) add 'goog' files
+            Collection<File> files = org.apache.commons.io.FileUtils.listFiles(new File(
+                    closureGoogTgtLibDirPath), new RegexFileFilter("^.*(\\.js)"),
+                    DirectoryFileFilter.DIRECTORY);
+            for (File file : files)
+            {
+                compilerWrapper.addJSSourceFile(file.getCanonicalPath());
+            }
+        }
+        
+        // (erikdebruin) add project files
+        for (String filePath : gdw.filePathsInOrder)
+        {
+            compilerWrapper.addJSSourceFile(
+                    new File(filePath).getCanonicalPath());   
+        }
+        
+        compilerWrapper.setOptions(
+                projectReleaseJSFilePath, useStrictPublishing);
+        
+        // (erikdebruin) Include the 'goog' deps to allow the compiler to resolve
+        //               dependencies.
+        compilerWrapper.addJSSourceFile(
+                closureGoogSrcLibDirPath + File.separator + "deps.js");
+        
+        List<String> externs = ((JSGoogConfiguration)configuration).getExternalJSLib();
+        for (String extern : externs)
+        {
+            compilerWrapper.addJSExternsFile(extern);
+        }
+        
+        compilerWrapper.targetFilePath = projectReleaseJSFilePath;
+        compilerWrapper.compile();
+        
+        appendSourceMapLocation(projectReleaseJSFilePath, projectName);
+
+        if (!isMarmotinniRun)
+        {
+            String allDeps = "";
+            if (!subsetGoog)
+                allDeps += FileUtils.readFileToString(srcDeps);
+            allDeps += FileUtils.readFileToString(new File(depsTgtFilePath));
+            
+            FileUtils.writeStringToFile(srcDeps, allDeps);
+            
+            org.apache.commons.io.FileUtils.deleteQuietly(new File(depsTgtFilePath));
+        }
+
+        if (ok)
+            System.out.println("The project '"
+                + projectName
+                + "' has been successfully compiled and optimized.");
+        
+        return true;
+    }
+
+    private void addDeps(ArrayList<DependencyRecord> subsetdeps, HashMap<String, String> gotgoog, 
+                            HashMap<String, DependencyRecord> defmap, String deps)
+    {
+        if (deps.length() == 0)
+            return;
+        
+        String[] deplist = deps.split(",");
+        for (String dep : deplist)
+        {
+            dep = dep.trim();
+            DependencyRecord deprec = defmap.get(dep);
+            if (!gotgoog.containsKey(deprec.path))
+            {
+                gotgoog.put(deprec.path, null);
+                // put addDependencyLine in subset file
+                subsetdeps.add(deprec);
+                addDeps(subsetdeps, gotgoog, defmap, deprec.deps);                        
+            }
+        }
+    }
+    
+    private void appendExportSymbol(String path, String projectName)
+            throws IOException
+    {
+        StringBuilder appendString = new StringBuilder();
+        appendString
+                .append("\n\n// Ensures the symbol will be visible after compiler renaming.\n");
+        appendString.append("goog.exportSymbol('");
+        appendString.append(projectName);
+        appendString.append("', ");
+        appendString.append(projectName);
+        appendString.append(");\n");
+        writeFile(path, appendString.toString(), true);
+    }
+
+    private void appendEncodedCSS(String path, String projectName)
+            throws IOException
+    {
+        StringBuilder appendString = new StringBuilder();
+        appendString.append("\n\n");
+        appendString.append(projectName);
+        appendString.append(".prototype.cssData = [");
+        JSCSSCompilationSession cssSession = (JSCSSCompilationSession) project.getCSSCompilationSession();
+        String s = cssSession.getEncodedCSS();
+        int reqidx = s.indexOf("goog.require");
+        if (reqidx != -1)
+        {
+            String reqs = s.substring(reqidx);
+            s = s.substring(0, reqidx - 1);
+            String fileData = readCode(new File(path));
+            reqidx = fileData.indexOf("goog.require");
+            String after = fileData.substring(reqidx);
+            String before = fileData.substring(0, reqidx - 1);
+            s = before + reqs + after + appendString.toString() + s;
+            writeFile(path, s, false);
+        }
+        else
+        {
+            appendString.append(s);
+            writeFile(path, appendString.toString(), true);
+        }
+    }
+        
+    protected String readCode(File file)
+    {
+        String code = "";
+        try
+        {
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    new FileInputStream(file), "UTF8"));
+
+            String line = in.readLine();
+
+            while (line != null)
+            {
+                code += line + "\n";
+                line = in.readLine();
+            }
+            code = code.substring(0, code.length() - 1);
+
+            in.close();
+        }
+        catch (Exception e)
+        {
+            // nothing to see, move along...
+        }
+
+        return code;
+    }
+
+    private void writeHTML(String type, String projectName, String dirPath, List<String> additionalHTML)
+            throws IOException
+    {
+        StringBuilder htmlFile = new StringBuilder();
+        htmlFile.append("<!DOCTYPE html>\n");
+        htmlFile.append("<html>\n");
+        htmlFile.append("<head>\n");
+        htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
+        htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
+        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"");
+        htmlFile.append(projectName);
+        htmlFile.append(".css\">\n");
+
+        for (String s : additionalHTML)
+            htmlFile.append(s).append("\n");
+        
+        if ("intermediate".equals(type))
+        {
+            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('mx.styles.StyleProtoChain');\n");
+            htmlFile.append("\t\tgoog.require('mx.managers.SystemManager');\n");
+            htmlFile.append("\t\tgoog.require('mx.managers.systemClasses.ChildManager');\n");
+            //htmlFile.append("\t\tgoog.require('" + projectName + "');\n");
+            htmlFile.append("\t</script>\n");
+        }
+        else
+        {
+            htmlFile.append("\t<script type=\"text/javascript\" src=\"./");
+            htmlFile.append(projectName);
+            htmlFile.append(".js\"></script>\n");
+        }
+
+        htmlFile.append("</head>\n");
+        htmlFile.append("<body onload=\"init();\">\n");
+        htmlFile.append("\t<script type=\"text/javascript\">\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    /** @type {mx.managers.systemClasses.ChildManager} */ childManager;\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[\"compiledLocales\"] = '';\n");
+        htmlFile.append("\t\t\t	infoObject[\"compiledResourceBundleNames\"] = '';\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\"] = '").append(projectName).append("';\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\tchildManager = new mx.managers.systemClasses.ChildManager(systemManager);\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\tmx.managers.DragManagerImpl.sm = window['apache-flex_system-manager'];\n");
+        htmlFile.append("\t\t\t\n");
+        htmlFile.append("\t\t\tmx.core.FlexGlobals.topLevelApplication = {};\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>");
+
+        writeFile(dirPath + File.separator + "index.html", htmlFile.toString(),
+                false);
+    }
+
+    private void writeCSS(String projectName, String dirPath)
+            throws IOException
+    {
+        StringBuilder cssFile = new StringBuilder();
+        JSCSSCompilationSession cssSession = (JSCSSCompilationSession) project.getCSSCompilationSession();
+        cssFile.append(cssSession.emitCSS());
+
+        writeFile(dirPath + File.separator + projectName + ".css",
+                cssFile.toString(), false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/as/ASBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/as/ASBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/as/ASBackend.java
new file mode 100644
index 0000000..647efa5
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/as/ASBackend.java
@@ -0,0 +1,159 @@
+/*
+ *
+ *  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.as;
+
+import java.io.FilterWriter;
+import java.io.StringWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.as.IASWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
+import org.apache.flex.compiler.internal.codegen.as.ASAfterNodeStrategy;
+import org.apache.flex.compiler.internal.codegen.as.ASBeforeNodeStrategy;
+import org.apache.flex.compiler.internal.codegen.as.ASBlockWalker;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.flex.compiler.internal.codegen.as.ASWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLEmitter;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.as.BeforeAfterStrategy;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITarget;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.as.IASBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link ASBlockWalker} is used to traverse the {@link IFileNode} AST.
+ * 
+ * @author Michael Schmalle
+ */
+public class ASBackend implements IBackend
+{
+    @Override
+    public String getOutputExtension()
+    {
+        return "as";
+    }
+
+    @Override
+    public ISourceFileHandler getSourceFileHandlerInstance()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Configurator createConfigurator()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ITarget createTarget(IASProject project, ITargetSettings settings,
+            ITargetProgressMonitor monitor)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public IASBlockWalker createWalker(IASProject project,
+            List<ICompilerProblem> errors, IASEmitter emitter)
+    {
+        ASBlockWalker walker = new ASBlockWalker(errors, project, emitter);
+
+        BeforeAfterStrategy strategy = new BeforeAfterStrategy(
+                new ASNodeSwitch(walker), new ASBeforeNodeStrategy(emitter),
+                new ASAfterNodeStrategy(emitter));
+
+        walker.setStrategy(strategy);
+
+        return walker;
+    }
+
+    @Override
+    public IMXMLBlockWalker createMXMLWalker(IASProject project,
+            List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+            IASEmitter asEmitter, IBlockWalker asBlockWalker)
+    {
+        return null;
+    }
+
+    @Override
+    public ASFilterWriter createWriterBuffer(IASProject project)
+    {
+        StringWriter out = new StringWriter();
+        ASFilterWriter writer = new ASFilterWriter(out);
+        return writer;
+    }
+
+    @Override
+    public IASEmitter createEmitter(FilterWriter writer)
+    {
+        return new ASEmitter(writer);
+    }
+
+    @Override
+    public IMXMLEmitter createMXMLEmitter(FilterWriter writer)
+    {
+        return new MXMLEmitter(writer);
+    }
+
+    @Override
+    public IASWriter createWriter(IASProject project,
+            List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+            boolean enableDebug)
+    {
+        return new ASWriter(project, problems, compilationUnit, enableDebug);
+    }
+
+    @Override
+    public IASWriter createMXMLWriter(IASProject project,
+            List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+            boolean enableDebug)
+    {
+        return null;
+    }
+
+    @Override
+    public IDocEmitter createDocEmitter(IASEmitter emitter)
+    {
+        return null;
+    }
+
+    @Override
+    public IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSApplication.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSApplication.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSApplication.java
new file mode 100644
index 0000000..edfd686
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSApplication.java
@@ -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 org.apache.flex.compiler.internal.driver.js;
+
+import org.apache.flex.compiler.driver.js.IJSApplication;
+
+/**
+ * @author Michael Schmalle
+ */
+public class JSApplication implements IJSApplication
+{
+    public JSApplication()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSBackend.java
new file mode 100644
index 0000000..a8b7737
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSBackend.java
@@ -0,0 +1,171 @@
+/*
+ *
+ *  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;
+
+import java.io.FilterWriter;
+import java.io.StringWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.clients.JSConfiguration;
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.ISourceMapEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
+import org.apache.flex.compiler.driver.js.IJSBackend;
+import org.apache.flex.compiler.internal.codegen.as.ASAfterNodeStrategy;
+import org.apache.flex.compiler.internal.codegen.as.ASBeforeNodeStrategy;
+import org.apache.flex.compiler.internal.codegen.as.ASBlockWalker;
+import org.apache.flex.compiler.internal.codegen.js.JSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSFilterWriter;
+import org.apache.flex.compiler.internal.codegen.js.JSPublisher;
+import org.apache.flex.compiler.internal.codegen.js.JSSourceMapEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSWriter;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.as.BeforeAfterStrategy;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.as.IASBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link ASBlockWalker} is used to traverse the {@link IFileNode} AST.
+ * 
+ * @author Michael Schmalle
+ */
+public class JSBackend implements IJSBackend
+{
+    @Override
+    public String getOutputExtension()
+    {
+        return "js";
+    }
+
+    @Override
+    public ISourceFileHandler getSourceFileHandlerInstance()
+    {
+        return JSSourceFileHandler.INSTANCE;
+    }
+
+    @Override
+    public Configurator createConfigurator()
+    {
+        return new Configurator(JSConfiguration.class);
+    }
+
+    @Override
+    public JSTarget createTarget(IASProject project, ITargetSettings settings,
+            ITargetProgressMonitor monitor)
+    {
+        return new JSTarget(project, settings, monitor);
+    }
+
+    @Override
+    public IASBlockWalker createWalker(IASProject project,
+            List<ICompilerProblem> errors, IASEmitter emitter)
+    {
+        ASBlockWalker walker = new ASBlockWalker(errors, project, emitter);
+
+        BeforeAfterStrategy strategy = new BeforeAfterStrategy(
+                new ASNodeSwitch(walker), new ASBeforeNodeStrategy(emitter),
+                new ASAfterNodeStrategy(emitter));
+
+        walker.setStrategy(strategy);
+
+        return walker;
+    }
+
+    @Override
+    public IMXMLBlockWalker createMXMLWalker(IASProject project,
+            List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+            IASEmitter asEmitter, IBlockWalker asBlockWalker)
+    {
+        return null;
+    }
+
+    @Override
+    public JSFilterWriter createWriterBuffer(IASProject project)
+    {
+        StringWriter out = new StringWriter();
+        JSFilterWriter writer = new JSFilterWriter(out);
+        return writer;
+    }
+
+    @Override
+    public IJSWriter createWriter(IASProject project,
+            List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+            boolean enableDebug)
+    {
+        return new JSWriter(project, problems, compilationUnit, enableDebug);
+    }
+
+    @Override
+    public IJSWriter createMXMLWriter(IASProject project,
+            List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+            boolean enableDebug)
+    {
+        return null;
+    }
+
+    @Override
+    public ISourceMapEmitter createSourceMapEmitter(IJSEmitter emitter)
+    {
+        return new JSSourceMapEmitter(emitter);
+    }
+
+    @Override
+    public IDocEmitter createDocEmitter(IASEmitter emitter)
+    {
+        return new JSDocEmitter((IJSEmitter) emitter);
+    }
+
+    @Override
+    public IASEmitter createEmitter(FilterWriter out)
+    {
+        return new JSEmitter(out);
+    }
+
+    @Override
+    public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+    {
+        return null;
+    }
+
+    @Override
+    public IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new JSPublisher(config);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSCompilationUnit.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSCompilationUnit.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSCompilationUnit.java
new file mode 100644
index 0000000..6583f3a
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSCompilationUnit.java
@@ -0,0 +1,217 @@
+/*
+ *
+ *  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;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.flex.compiler.common.DependencyType;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.units.ASCompilationUnit;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.units.requests.IOutgoingDependenciesRequestResult;
+
+/**
+ * JSCompilationUnit is the CompilationUnit for compiling ActionScript source
+ * files to JavasScript.
+ * <p>
+ * JSCompilationUnit is derived from ASCompilationUnit and overrides the parts
+ * that generate the code.
+ */
+public class JSCompilationUnit extends ASCompilationUnit
+{
+    @SuppressWarnings("unused")
+    private Boolean inCodeGen = false;
+
+    /**
+     * Create a compilation unit from an ABC file.
+     * 
+     * @param project compiler project
+     * @param path ABC file path
+     * @throws IOException error
+     */
+    public JSCompilationUnit(CompilerProject project, String path)
+            throws IOException
+    {
+        this(project, path, DefinitionPriority.BasePriority.LIBRARY_PATH);
+    }
+
+    public JSCompilationUnit(CompilerProject project, String path,
+            DefinitionPriority.BasePriority basePriority)
+    {
+        super(project, path, basePriority);
+    }
+
+    public JSCompilationUnit(CompilerProject project, String path,
+            DefinitionPriority.BasePriority basePriority, String qname)
+    {
+        super(project, path, basePriority, 0, qname);
+    }
+
+    //    protected IABCBytesRequestResult _handleABCBytesRequest(Operation buildPhase) throws InterruptedException
+    //    {
+    //        // If JSEmitter.needsSecondPass() returns true, JSGenerator.generate() will return null during scanning, 
+    //        // which will result in JSCompilationUnit::handleSemanticProblemsRequest not caching any abcBytes for 
+    //        // handleABCBytesRequest. The net result is that JSGenerator.generate() will be called again in handleABCBytesRequest. 
+    //        // This mechanic will ensure selective two-pass compilation. 
+    //        if (m_abcBytes != null &&
+    //            !JSSharedData.instance.hasSymbols() && // Symbol support
+    //            !JSSharedData.instance.hasAnyClassInit()) // support for class inits 
+    //            return m_abcBytes;
+    //
+    //        JSGenerator jsGenerator = new JSGenerator();
+    //        jsGenerator.m_compilationUnit = this;
+    //        jsGenerator.setBuildPhase(buildPhase);
+    //
+    //        // Need to force the file scope request to happen first to get the ASFileScope
+    //        // for this compilation unit registered with the project.
+    //        // ** TODO this is a hack!
+    //        getFileScopeRequest().get();
+    //
+    //        // This is also a hack!  If there are embed directives, need to ensure
+    //        // semantic pass has finished, as that is what will generate the embed classes
+    //        // which are needed by codegen
+    //        if (buildPhase != Operation.GET_SEMANTIC_PROBLEMS)
+    //        {
+    //        	// AJH this was deadlocking as getOutgoingDependencies calls handleABCBytes
+    //        	if (buildPhase != Operation.GET_ABC_BYTES)
+    //        		getOutgoingDependenciesRequest().get();
+    //        }
+    //
+    //        final ISyntaxTreeRequestResult fsr = getSyntaxTreeRequest().get();
+    //        final IASNode rootNode = fsr.getAST();
+    //
+    //        startProfile(buildPhase);
+    //        IABCBytesRequestResult result = jsGenerator.generate(getFilenameNoPath(), rootNode, this.getProject());
+    //        stopProfile(buildPhase);
+    //
+    //        m_needsSecondPass = jsGenerator.needsSecondPass();
+    //
+    //        return result;
+    //    }
+
+    //   @Override
+    //    protected IABCBytesRequestResult handleABCBytesRequest() throws InterruptedException
+    //    {
+    //        final IABCBytesRequestResult result = _handleABCBytesRequest(Operation.GET_ABC_BYTES);
+    //
+    //        /*
+    //         * // explicitly reference all classes this class depends on if(
+    //         * result.getProblems() == null || result.getProblems().length == 0 ) {
+    //         * final String code = new String( result.getABCBytes() ); if(
+    //         * code.contains(JSSharedData.REQUIRED_TAG_MARKER) ) { final
+    //         * ICompilationUnit cu = this; final Set<ICompilationUnit> deps = new
+    //         * HashSet<ICompilationUnit>(); deps.addAll(
+    //         * getProject().getDependencies(cu) ); if( !deps.isEmpty() ) { String
+    //         * depNames = ""; Boolean separator = false; final List<IDefinition>
+    //         * defs = MXMLJSC.getClassDefinitions( cu ); for( IDefinition def: defs
+    //         * ) { if( def instanceof ClassDefinition ) { final String defName =
+    //         * JSGeneratingReducer.createFullNameFromDefinition(def); if( defName !=
+    //         * null && !defName.isEmpty() ) { if( separator ) depNames += ":"; else
+    //         * separator = true; depNames += defName; } } }
+    //         * code.replaceFirst(JSSharedData.REQUIRED_TAG_MARKER, depNames); return
+    //         * new ABCBytesRequestResult(code.getBytes(), result.getProblems()); } }
+    //         * }
+    //         */
+    //        return result;
+    //    }
+
+    @Override
+    protected IOutgoingDependenciesRequestResult handleOutgoingDependenciesRequest()
+            throws InterruptedException
+    {
+        //        // Every CU is dependent on the class glue, which is implemented in browser.adobe.
+        //        // Add dependency from this JSCompilationUnit to browser.adobe's JSCompilationUnit.
+        //        addDependency(JSSharedData.JS_FRAMEWORK_NAME, DependencyType.INHERITANCE);
+        //        addDependency(JSSharedData.FRAMEWORK_CLASS, DependencyType.INHERITANCE);
+
+        IOutgoingDependenciesRequestResult result = super
+                .handleOutgoingDependenciesRequest();
+
+        //        // SWFTarget::startBuildAndFindAllCompilationUnits() is called by SWFTarget::collectProblems(), which is called by SWFTarget::addToSWF() in JSDriver::main().
+        //        // This is our first pass. jsGenerator.generate() will return null if JSGeneratingReducer.getMember 
+        //        // If JSEmitter.needsSecondPass() returns true, JSGenerator.generate() will return null during scanning, 
+        //        // which will result in JSCompilationUnit::handleSemanticProblemsRequest not caching any abcBytes for 
+        //        // handleABCBytesRequest. The net result is that JSGenerator.generate() will be called again in handleABCBytesRequest. 
+        //        // This mechanic will ensure selective two-pass compilation. 
+        //        if (result.getProblems().length == 0)
+        //        {
+        //            m_needsSecondPass = false;
+        //            m_abcBytes = _handleABCBytesRequest(Operation.GET_SEMANTIC_PROBLEMS);
+        //            if (m_needsSecondPass)
+        //                m_abcBytes = null;
+        //        }
+
+        return result;
+    }
+
+    public Boolean addDependency(String className, DependencyType dt)
+    {
+        //        if (JSGeneratingReducer.isReservedDataType(className))
+        //            return false;
+        //
+        //        final ICompilationUnit fromCU = this;
+        //        final CompilerProject compilerProject = this.getProject();
+        //        final ASProjectScope projectScope = compilerProject.getScope();
+        //
+        //        final IDefinition classDef = projectScope.findDefinitionByName(className);
+        //        if (classDef == null)
+        //            return false;
+        //
+        //        final ICompilationUnit toCU = projectScope.getCompilationUnitForDefinition(classDef);
+        //        if (fromCU == toCU)
+        //            return false;
+        //
+        //        // sharedData.verboseMessage( "Adding dependency: " + className );
+        //        compilerProject.addDependency(fromCU, toCU, dt);
+
+        return true;
+    }
+
+    @Override
+    public void startBuildAsync(TargetType targetType)
+    {
+        // super.startBuildAsync(targetType);
+
+        getSyntaxTreeRequest();
+        getFileScopeRequest();
+        getOutgoingDependenciesRequest();
+
+        //        // scanning and code generating phases need to be separated
+        //        // in order to create two distinct passes for m_needSecondPass.
+        //        if (m_inCodeGen)
+        //        {
+        //            getABCBytesRequest();
+        //            getSWFTagsRequest();
+        //        }
+    }
+
+    @Override
+    public void waitForBuildFinish(final Collection<ICompilerProblem> problems,
+            TargetType targetType) throws InterruptedException
+    {
+        inCodeGen = true;
+        super.waitForBuildFinish(problems, targetType);
+        inCodeGen = false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSSourceFileHandler.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSSourceFileHandler.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSSourceFileHandler.java
new file mode 100644
index 0000000..d2dd3c3
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/JSSourceFileHandler.java
@@ -0,0 +1,83 @@
+/*
+ *
+ *  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;
+
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.units.ASCompilationUnit;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+/**
+ * Implementation of ISourceFileHandler that constructs
+ * {@link ASCompilationUnit}'s. JSSourceFileHandler is the SourceFileHandler
+ * that provides JSCompilationUnit for *.as files. JSDriver registers
+ * JSSourceFileHandler at FlexApplicationProject. This implementation is part of
+ * FalconJS. For more details on FalconJS see org.apache.flex.compiler.JSDriver
+ */
+public final class JSSourceFileHandler implements ISourceFileHandler
+{
+
+    public static final String EXTENSION = "as"; //$NON-NLS-1$
+    public static final JSSourceFileHandler INSTANCE = new JSSourceFileHandler();
+
+    private JSSourceFileHandler()
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String[] getExtensions()
+    {
+        return new String[] { EXTENSION };
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ICompilationUnit createCompilationUnit(CompilerProject proj,
+            String path, DefinitionPriority.BasePriority basePriority,
+            int order, String qname, String locale)
+    {
+        return new JSCompilationUnit(proj, path, basePriority, qname);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean needCompilationUnit(CompilerProject project, String path,
+            String qname, String locale)
+    {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean canCreateInvisibleCompilationUnit()
+    {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/amd/AMDBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/amd/AMDBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/amd/AMDBackend.java
new file mode 100644
index 0000000..e3c68de
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/amd/AMDBackend.java
@@ -0,0 +1,53 @@
+/*
+ *
+ *  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.amd;
+
+import java.io.FilterWriter;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.amd.JSAMDDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.amd.JSAMDEmitter;
+import org.apache.flex.compiler.internal.driver.js.JSBackend;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for 'AMD' code
+ * production.
+ * 
+ * @author Michael Schmalle
+ */
+public class AMDBackend extends JSBackend
+{
+    @Override
+    public IDocEmitter createDocEmitter(IASEmitter emitter)
+    {
+        return new JSAMDDocEmitter((IJSEmitter) emitter);
+    }
+
+    @Override
+    public IJSEmitter createEmitter(FilterWriter out)
+    {
+        IJSEmitter emitter = new JSAMDEmitter(out);
+        emitter.setDocEmitter(createDocEmitter(emitter));
+        return emitter;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
new file mode 100644
index 0000000..cccbe71
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
@@ -0,0 +1,53 @@
+/*
+ *
+ *  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.flexjs;
+
+import java.io.FilterWriter;
+
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+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 FlexJSBackend extends GoogBackend
+{
+
+    @Override
+    public IJSEmitter createEmitter(FilterWriter out)
+    {
+        IJSEmitter emitter = new JSFlexJSEmitter(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/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/JSCSSCompilationSession.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/JSCSSCompilationSession.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/JSCSSCompilationSession.java
new file mode 100644
index 0000000..b61bbf5
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/flexjs/JSCSSCompilationSession.java
@@ -0,0 +1,414 @@
+/*
+ *
+ *  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.flexjs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.css.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSMediaQueryCondition;
+import org.apache.flex.compiler.css.ICSSProperty;
+import org.apache.flex.compiler.css.ICSSPropertyValue;
+import org.apache.flex.compiler.css.ICSSRule;
+import org.apache.flex.compiler.css.ICSSSelector;
+import org.apache.flex.compiler.css.ICSSSelectorCondition;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.css.CSSArrayPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSColorPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSFontFace;
+import org.apache.flex.compiler.internal.css.CSSFunctionCallPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSKeywordPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSNumberPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSProperty;
+import org.apache.flex.compiler.internal.css.CSSRgbColorPropertyValue;
+import org.apache.flex.compiler.internal.css.CSSStringPropertyValue;
+import org.apache.flex.compiler.internal.css.codegen.CSSCompilationSession;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+
+public class JSCSSCompilationSession extends CSSCompilationSession
+{
+
+    private ArrayList<String> requires;
+    
+    public String getEncodedCSS()
+    {
+        final ICSSDocument css = synthesisNormalizedCSS();
+        StringBuilder sb = new StringBuilder();
+        requires = new ArrayList<String>();
+        encodeCSS(css, sb);
+        sb.append("];\n");
+        for (String r : requires)
+        {
+            sb.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken() + "('" + formatQualifiedName(r) + "');\n");
+        }
+
+        return sb.toString();        
+    }
+    
+    public String emitCSS()
+    {
+        final ICSSDocument css = synthesisNormalizedCSS();
+        StringBuilder sb = new StringBuilder();
+        sb.append("/* Generated by Apache Flex Cross-Compiler */\n");
+        walkCSS(css, sb);
+        return sb.toString();
+    }
+    
+    private String fontFaceToString(CSSFontFace fontFace)
+    {
+        final StringBuilder result = new StringBuilder();
+        result.append("@font-face {\n");
+        result.append("    ");
+        result.append("font-family: ");
+        result.append(fontFace.getFontFamily() + ";\n");
+        result.append("    ");
+        result.append("font-style: ");
+        result.append(fontFace.getFontStyle() + ";\n");
+        result.append("    ");
+        result.append("font-weight: ");
+        result.append(fontFace.getFontStyle() + ";\n");
+        result.append("    ");
+        ArrayList<ICSSPropertyValue> sources = fontFace.getSources();
+        for (ICSSPropertyValue src : sources)
+        {
+        	result.append("src: ");
+        	result.append(src.toString() + ";\n");
+        }
+       	result.append("}\n");
+        return result.toString();
+    }
+    
+    private String cssRuleToString(ICSSRule rule)
+    {
+        final StringBuilder result = new StringBuilder();
+
+        ImmutableList<ICSSMediaQueryCondition> mqList = rule.getMediaQueryConditions();
+        boolean hasMediaQuery = !mqList.isEmpty();
+        if (hasMediaQuery)
+        {
+            result.append("@media ");
+            result.append(Joiner.on(" and ").join(rule.getMediaQueryConditions()));
+            result.append(" {\n");
+            result.append("    ");
+        }
+
+        ImmutableList<ICSSSelector> selectors = rule.getSelectorGroup();
+        boolean firstOne = true;
+        for (ICSSSelector selector : selectors)
+        {
+        	String s = selector.toString();
+	        // add "." to type selectors that don't map cleanly
+	        // to CSS type selectors to convert them to class
+	    	// selectors.
+	        if (!s.startsWith(".") && !s.startsWith("*") && !s.startsWith("#"))
+	        {
+	        	String condition = null;
+        		int colon = s.indexOf(":");
+	        	if (colon != -1)
+	        	{
+	        		condition = s.substring(colon);
+	        		s = s.substring(0, colon);
+	        	}
+	        	if (!htmlElementNames.contains(s.toLowerCase()))
+	        	{
+	        		int pipe = s.indexOf("|");
+	        		if (pipe != -1)
+	        			s = s.substring(pipe + 1);
+	        		s = "." + s;
+	        	}
+	        	if (condition != null)
+	        		s = s + condition;
+	        }
+	        if (!firstOne)
+	        	result.append(",\n");
+	        result.append(s);
+        }
+
+        result.append(" {\n");
+        for (final ICSSProperty prop : rule.getProperties())
+        {
+            if (!hasMediaQuery)
+                result.append("    ");
+
+            String propString = ((CSSProperty)prop).toCSSString();
+            // skip class references since the won't work in CSS
+            if (propString.contains("ClassReference"))
+            	continue;
+            result.append("    ").append(propString).append("\n");
+        }
+        if (hasMediaQuery)
+            result.append("    }\n");
+
+        result.append("}\n");
+
+        return result.toString();
+    }
+    
+    private void walkCSS(ICSSDocument css, StringBuilder sb)
+    {
+    	for (CSSFontFace fontFace : fontFaces)
+    	{
+    		sb.append(fontFaceToString(fontFace));
+    	}
+    	if (fontFaces.size() > 0)
+    		sb.append("\n\n");
+        ImmutableList<ICSSRule> rules = css.getRules();
+        for (ICSSRule rule : rules)
+        {
+        	String s = cssRuleToString(rule);
+        	if (s.startsWith("@media -flex-flash"))
+        		continue;
+        	if (s.startsWith(".global {"))
+        		s = s.replace(".global {", "* {");
+            sb.append(s);
+            sb.append("\n\n");
+        }
+    }
+    
+    private void encodeCSS(ICSSDocument css, StringBuilder sb)
+    {
+        ImmutableList<ICSSRule> rules = css.getRules();
+        boolean skipcomma = true;
+        for (ICSSRule rule : rules)
+        {
+            String s = encodeRule(rule);
+            if (s != null)
+            {
+                if (skipcomma)
+                    skipcomma = false;
+                else
+                    sb.append(",\n");
+                sb.append(s);
+            }
+        }
+    }
+    
+    List<String> htmlElementNames = Arrays.asList(
+    		"body",
+    		"button",
+    		"span"
+    );
+    
+    private String encodeRule(ICSSRule rule)
+    {
+        final StringBuilder result = new StringBuilder();
+
+        ImmutableList<ICSSMediaQueryCondition> mqlist = rule.getMediaQueryConditions();
+        int n = mqlist.size();
+        if (n > 0)
+        {
+            if (mqlist.get(0).toString().equals("-flex-flash"))
+                return null;
+            
+            result.append(n);
+            
+            for (ICSSMediaQueryCondition mqcond : mqlist)
+            {
+                result.append(",\n");
+                result.append("\"" + mqcond.toString() + "\"");
+            }
+        }
+        else
+            result.append(n);
+
+        result.append(",\n");
+
+        ImmutableList<ICSSSelector> slist = rule.getSelectorGroup();
+        result.append(slist.size());
+
+        for (ICSSSelector sel : slist)
+        {
+            result.append(",\n");
+            String selName = this.resolvedSelectors.get(sel);
+            if (selName == null || selName.equals("null"))
+                result.append("\"" + sel.toString() + "\"");
+            else
+            {
+            	selName = formatQualifiedName(selName);
+                ImmutableList<ICSSSelectorCondition> conds = sel.getConditions();
+                for (ICSSSelectorCondition cond : conds)
+                    selName += cond.toString();
+                result.append("\"" + selName + "\"");
+            }
+        }
+        result.append(",\n");
+        
+        ImmutableList<ICSSProperty> plist = rule.getProperties();
+        result.append(plist.size());
+        
+        for (final ICSSProperty prop : plist)
+        {
+            result.append(",\n");
+            result.append("\"" + prop.getName() + "\"");
+            result.append(",\n");
+            ICSSPropertyValue value = prop.getValue();
+            if (value instanceof CSSArrayPropertyValue)
+            {
+                ImmutableList<? extends ICSSPropertyValue> values = ((CSSArrayPropertyValue)value).getElements();
+                result.append("[");
+                boolean firstone = true;
+                for (ICSSPropertyValue val : values)
+                {
+                    if (firstone)
+                        firstone = false;
+                    else
+                        result.append(", ");
+                    if (val instanceof CSSStringPropertyValue)
+                    {
+                        result.append("\"" + ((CSSStringPropertyValue)val).getValue() + "\"");
+                    }
+                    else if (val instanceof CSSColorPropertyValue)
+                    {
+                        result.append(new Integer(((CSSColorPropertyValue)val).getColorAsInt()));
+                    }
+                    else if (val instanceof CSSRgbColorPropertyValue)
+                    {
+                        result.append(new Integer(((CSSRgbColorPropertyValue)val).getColorAsInt()));
+                    }
+                    else if (val instanceof CSSKeywordPropertyValue)
+                    {
+                        CSSKeywordPropertyValue keywordValue = (CSSKeywordPropertyValue)val;
+                        String keywordString = keywordValue.getKeyword();
+                        if (IASLanguageConstants.TRUE.equals(keywordString))
+                            result.append("true");
+                        else if (IASLanguageConstants.FALSE.equals(keywordString))
+                            result.append("false");
+                        else
+                            result.append("\"" + ((CSSKeywordPropertyValue)val).getKeyword() + "\"");
+                    }
+                    else if (val instanceof CSSNumberPropertyValue)
+                    {
+                        result.append(new Double(((CSSNumberPropertyValue)val).getNumber().doubleValue()));
+                    }
+                    else
+                    {
+                        result.append("unexpected value type: " + val.toString());
+                    }
+                }
+                result.append("]");
+            }
+            else if (value instanceof CSSStringPropertyValue)
+            {
+                result.append("\"" + ((CSSStringPropertyValue)value).getValue() + "\"");
+            }
+            else if (value instanceof CSSColorPropertyValue)
+            {
+                result.append(new Integer(((CSSColorPropertyValue)value).getColorAsInt()));
+            }
+            else if (value instanceof CSSRgbColorPropertyValue)
+            {
+                result.append(new Integer(((CSSRgbColorPropertyValue)value).getColorAsInt()));
+            }
+            else if (value instanceof CSSKeywordPropertyValue)
+            {
+                CSSKeywordPropertyValue keywordValue = (CSSKeywordPropertyValue)value;
+                String keywordString = keywordValue.getKeyword();
+                if (IASLanguageConstants.TRUE.equals(keywordString))
+                    result.append("true");
+                else if (IASLanguageConstants.FALSE.equals(keywordString))
+                    result.append("false");
+                else
+                    result.append("\"" + ((CSSKeywordPropertyValue)value).getKeyword() + "\"");
+            }
+            else if (value instanceof CSSNumberPropertyValue)
+            {
+                result.append(new Double(((CSSNumberPropertyValue)value).getNumber().doubleValue()));
+            }
+            else if (value instanceof CSSFunctionCallPropertyValue)
+            {
+                final CSSFunctionCallPropertyValue functionCall = (CSSFunctionCallPropertyValue)value;
+                if ("ClassReference".equals(functionCall.name))
+                {
+                    final String className = CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(functionCall.rawArguments);
+                    if ("null".equals(className))
+                    {
+                        // ClassReference(null) resets the property's class reference.
+                        result.append("null");
+                    }
+                    else
+                    {
+                        result.append(formatQualifiedName(className));
+                        requires.add(className);
+                    }
+                }
+                else if ("url".equals(functionCall.name))
+                {
+                    final String urlString = CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(functionCall.rawArguments);
+                    result.append("\"" + urlString + "\"");
+                }
+                else if ("PropertyReference".equals(functionCall.name))
+                {
+                    // TODO: implement me
+                }
+                else if ("Embed".equals(functionCall.name))
+                {
+                    // TODO: implement me
+                    /*
+                    final ICompilerProblem e = new CSSCodeGenProblem(
+                            new IllegalStateException("Unable to find compilation unit for " + functionCall));
+                    problems.add(e);
+                    */
+                }
+                else
+                {
+                    assert false : "CSS parser bug: unexpected function call property value: " + functionCall;
+                    throw new IllegalStateException("Unexpected function call property value: " + functionCall);
+                }
+            }
+        }
+
+        return result.toString();
+
+    }
+    
+    @Override
+    protected boolean keepRule(ICSSRule newRule)
+    {
+    	if (super.keepRule(newRule))
+    		return true;
+    	
+    	// include all rules not found in defaults.css
+    	// theoretically, defaults.css rules were
+    	// properly added in the super call.
+    	String sp = newRule.getSourcePath();
+    	if (!sp.contains("defaults.css"))
+    		return true;
+    	
+        return false;
+    }
+
+    private String formatQualifiedName(String name)
+    {
+    	/*
+    	if (name.contains("goog.") || name.startsWith("Vector."))
+    		return name;
+    	if (name.startsWith("."))
+    	{
+    		return "." + name.substring(1).replaceAll("\\.", "_");
+    	}
+    	name = name.replaceAll("\\.", "_");
+    	*/
+    	return name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
new file mode 100644
index 0000000..af8129a
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
@@ -0,0 +1,73 @@
+/*
+ *
+ *  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.goog;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
+import org.apache.flex.compiler.internal.driver.js.JSBackend;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for the 'goog' code
+ * production.
+ * 
+ * @author Michael Schmalle
+ */
+public class GoogBackend extends JSBackend
+{
+
+    @Override
+    public Configurator createConfigurator()
+    {
+        return new Configurator(JSGoogConfiguration.class);
+    }
+
+    @Override
+    public IDocEmitter createDocEmitter(IASEmitter emitter)
+    {
+        return new JSGoogDocEmitter((IJSEmitter) emitter);
+    }
+
+    @Override
+    public IJSEmitter createEmitter(FilterWriter out)
+    {
+        IJSEmitter emitter = new JSGoogEmitter(out);
+        emitter.setDocEmitter(createDocEmitter(emitter));
+        return emitter;
+    }
+
+    @Override
+    public JSGoogPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new JSGoogPublisher(config);
+    }
+}