flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [49/51] [partial] git commit: [flex-falcon] [refs/heads/feature/maven-migration-test] - - Check-In of the migrated project to make error analysis easier
Date Wed, 13 Apr 2016 18:56:41 GMT
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/compiler/internal/as/codegen/UnknownTreePatternInputOutput.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/internal/as/codegen/UnknownTreePatternInputOutput.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/internal/as/codegen/UnknownTreePatternInputOutput.java
new file mode 100644
index 0000000..f551331
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/internal/as/codegen/UnknownTreePatternInputOutput.java
@@ -0,0 +1,306 @@
+/*
+ *
+ *  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.as.codegen;
+
+import java.io.PrintWriter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ext.DefaultHandler2;
+
+/**
+ *  UnknownTreePatternInputOutput is a support class that reads
+ *  an XML file with template data and populates a map of finding templates,
+ *  and may also write this map out as Java code to be copied into
+ *  the UnknownTreeHandler as hard-coded patterns.
+ */
+class UnknownTreePatternInputOutput extends DefaultHandler2
+{
+    /**
+     *  The map of templates by node ID to read into.
+     */
+    Map<String, ArrayList<Template>> destination;
+
+    /**
+     *  Package name to use.  Hard-coded for now.
+     */
+    String packageName = "org.apache.flex.compiler.internal.as.codegen";
+
+    /**
+     *  Class name to use.  Also hard-coded.
+     */
+    String className = "UnknownTreeHandlerPatterns";
+
+    /**
+     *  Emitter to use.  Hard-coded.
+     */
+    String emitterName = "org.apache.flex.compiler.internal.as.codegen.CmcEmitter";
+
+    /**
+     *  Load a map of templates from an XML file.
+     *  @param pattern_file - the path of the XML pattern file.
+     *  @param dest - the destination map.
+     */
+    boolean load(String pattern_file, Map<String, ArrayList<Template>> dest)
+    {
+        this.destination = dest;
+
+        try
+        {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+
+            SAXParser parser = factory.newSAXParser();
+            parser.parse( new java.io.FileInputStream(pattern_file), this);
+            return true;
+        }
+        catch ( Throwable load_failed )
+        {
+            System.err.println("Load of " + pattern_file + " failed!");
+            load_failed.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     *  This stack tracks UnknownTreeFindingTemplate objects from 
+     *  their startElement event to their endElement event; 
+     *  it's used to create the pattern/subpattern hierarchy.
+     */
+    Stack<Template> nodeStack = new Stack<Template>();
+
+    /**
+     *  Create new UnknownTreeFindingTemplate objects in response to Pattern
+     *  elements, and decode the Pattern's attributes.
+     */
+    @Override
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
+        {   
+            if ( ! (localName.equals("Pattern")) )
+            {
+                if ( ! (localName.equals("SEW")) )
+                    System.err.println("Unknown element " + localName);
+                return;
+            }
+
+            Template template = new Template();
+
+            for ( int index = 0; index < attributes.getLength(); index++)
+            {
+                String attr_name = attributes.getLocalName(index);
+                String attr_value = attributes.getValue(index);
+
+                if ( "ID".equals(attr_name) )
+                {
+                    template.id = attr_value;
+                }
+                else if ( "cantHaveState".equals(attr_name) )
+                {
+                    String state_id = "__" + attr_value + "_NT";
+                    template.cantHaveState = state_id;
+                }
+                else if ( "mustHaveState".equals(attr_name) )
+                {
+                    String state_id = "__" + attr_value + "_NT";
+                    template.mustHaveState = state_id;
+                }
+                else if ( "problem".equals(attr_name) )
+                {
+                    String class_name;
+                    if ( attr_value.startsWith("org.apache.") )
+                        class_name = attr_value;
+                    else
+                        class_name = "org.apache.flex.compiler.problems." + attr_value;
+                    template.problemClass = class_name;
+                }
+                else if ( "nodeClass".equals(attr_name) )
+                {
+                    String class_name;
+                    if ( attr_value.startsWith("org.apache.") )
+                        class_name = attr_value;
+                    else
+                        class_name = "org.apache.flex.compiler.internal.tree.as." + attr_value;
+                    template.nodeClass = class_name;
+                }
+                else if ( "provisional".equals(attr_name) )
+                {
+                    template.provisional = Boolean.valueOf(attr_value);
+                }
+                else
+                {
+                    System.err.println("** Unknown attr name:" + attr_name);
+                }
+            }
+
+
+            //  Top-level templates go into the map by node id;
+            //  subpatterns get linked to their immediate parent.
+            if ( nodeStack.isEmpty() )
+            {
+                assert template.problemClass != null : "Top-level template " + template + " must have a problem class.";
+
+                if ( ! (destination.containsKey(template.id)) )
+                    destination.put(template.id, new ArrayList<Template>());
+
+                destination.get(template.id).add(template);
+            }
+            else
+            {
+                Template base = nodeStack.peek();
+                if ( base.requiredSubtree == null )
+                    base.requiredSubtree = template;
+                else
+                    System.err.println("already has subtree: " + base);
+            }
+
+            this.nodeStack.push(template);
+        }
+
+    /**
+     *  Maintain the UnknownTreeFindingTemplate stack.
+     */
+    @Override
+    public void endElement(String uri,  String localName,  String qName)
+    {
+        if ( localName.equals("Pattern") )
+            this.nodeStack.pop();
+    }
+
+    /**
+     *  Load an XML file containing patterns and dump equivalent Java code to System.out.
+     */
+    public static void main(String[] argv)
+    throws Exception
+    {
+        if ( argv.length < 2 )
+        {
+            System.err.println("Usage: java org.apache.flex.compiler.internal.as.codegen.UnknownTreePatternInputOutput <xml pattern file> <destination java file>");
+            System.exit(1);
+        }
+
+        new UnknownTreePatternInputOutput().dumpTemplateData(argv[0], argv[1]);
+    }
+    
+    PrintWriter output;
+
+    /**
+     *  Read an XML file of patterns and dump the equivalent Java code to the target file.
+     *  @param src_file_name - the path of the XML file.
+     *  @param dest_file_name - the path of the output Java file.
+     */
+    void dumpTemplateData(String src_file_name, String dest_file_name)
+    throws Exception
+    {
+        if ( !load(src_file_name, new HashMap<String, ArrayList<Template>>()) )
+            return;
+
+        output = new PrintWriter(dest_file_name);
+
+        output.println("package " + this.packageName + ";");
+        output.println("import java.util.ArrayList;");
+        output.println("import java.util.HashMap;");
+        output.println("import java.util.Map;");
+        output.println("import org.apache.flex.compiler.tree.ASTNodeID;");
+        output.println("import static org.apache.flex.compiler.tree.ASTNodeID.*;");
+        output.println("import " + this.emitterName + ";");
+        output.println();
+        output.println("public class " + this.className);
+        output.println("{");
+        output.println();
+        output.println("    //  Patterns generated " + new java.util.Date().toString() + " from " + src_file_name.replaceAll("\\\\", "/"));
+        output.println("    public static Map<ASTNodeID, ArrayList<UnknownTreeFinding.Template> > allTemplates = new HashMap<ASTNodeID, ArrayList<UnknownTreeFinding.Template>>();");
+
+        output.println("    static");
+        output.println("    {");
+
+        for ( String id: destination.keySet() )
+        {
+            String templates_name = "templates_for_" + id;
+            output.printf("        ArrayList<UnknownTreeFinding.Template> %s = allTemplates.get(%s);%n", templates_name, id);
+            output.printf("        if ( %s == null ) {%n", templates_name);
+            output.printf("            %s = new ArrayList<UnknownTreeFinding.Template>();%n", templates_name);
+            output.printf("            allTemplates.put(%s, %s);%n", id, templates_name);
+            output.printf("        }%n");
+
+            for ( Template templ: destination.get(id) )
+            {
+                output.printf("        {%n");
+                dumpTemplate(templ, "current_template");
+                output.printf("            %s.add(current_template);%n", templates_name);
+                output.printf("        }%n");
+            }
+        }
+        output.println("    }");
+        output.println("}");
+        output.close();
+    }
+
+    /**
+     *  Recursively dump a template.
+     *  @param templ - the template to dump.
+     *  @param var_name - the name by which this template will be known
+     *    in the output Java code.  As this routine recurses, it builds
+     *    successively longer variable names.
+     */
+    void dumpTemplate(Template templ, String var_name)
+    {
+        output.printf("            UnknownTreeFinding.Template %s = new UnknownTreeFinding.Template();%n", var_name);
+        output.printf("            %s.id = %s;%n", var_name, templ.id);
+        if ( templ.problemClass != null )
+            output.printf("            %s.problemClass = %s.class;%n", var_name, templ.problemClass);
+        if ( templ.nodeClass != null )
+            output.printf("            %s.nodeClass = %s.class;%n", var_name, templ.nodeClass);
+        if ( templ.mustHaveState != null )
+            output.printf("            %s.mustHaveState = CmcEmitter.%s;%n", var_name, templ.mustHaveState);
+        if ( templ.cantHaveState != null )
+            output.printf("            %s.cantHaveState = CmcEmitter.%s;%n", var_name, templ.cantHaveState);
+        output.printf("            %s.provisional = %s;%n", var_name, templ.provisional);
+
+        if ( templ.requiredSubtree != null )
+        {
+            String subtemp_name = var_name + "_subtempl";
+            dumpTemplate(templ.requiredSubtree, subtemp_name);
+            output.printf("            %s.requiredSubtree = %s;%n", var_name, subtemp_name);
+        }
+    }
+
+    /**
+     *  Build-time representation of a UnknownTreeFinding.Template object.
+     */
+    private static class Template
+    {
+        String id = "UnknownID";
+
+        String problemClass;
+        String nodeClass;
+        String mustHaveState;
+        String cantHaveState;
+        Boolean provisional = Boolean.FALSE;
+
+        Template requiredSubtree;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
index 04929a5..f0c29ca 100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
@@ -50,6 +50,7 @@ public abstract class BaseProblemGeneratorMojo extends AbstractMojo
     abstract protected File getInputDirectory();
     abstract protected File getOutputDirectory();
     abstract protected String getOutputFile();
+    abstract protected void clean(File outputFile) throws MojoExecutionException;
 
     public void execute() throws MojoExecutionException
     {
@@ -61,12 +62,8 @@ public abstract class BaseProblemGeneratorMojo extends AbstractMojo
             }
         }
 
-        // If the file already exists, delete it before generating output.
-        if(generatedFile.exists()) {
-            if(!generatedFile.delete()) {
-                throw new MojoExecutionException("Could not clear previously created file: " + generatedFile.getPath());
-            }
-        }
+        // Give the generator a chance to clean up.
+        clean(generatedFile);
 
         try {
             PrintWriter writer = new PrintWriter(new FileWriter(generatedFile, true));

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemEnumGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemEnumGeneratorMojo.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemEnumGeneratorMojo.java
index 77c3d1c..b8d1fae 100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemEnumGeneratorMojo.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemEnumGeneratorMojo.java
@@ -149,4 +149,14 @@ public class ProblemEnumGeneratorMojo
         return "PROBLEM_" + problemTypeName;
     }
 
+    @Override
+    protected void clean(File outputFile) throws MojoExecutionException {
+        // If the file already exists, delete it before generating output.
+        if(outputFile.exists()) {
+            if(!outputFile.delete()) {
+                throw new MojoExecutionException("Could not clear previously created file: " + outputFile.getPath());
+            }
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemResourceBundleGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemResourceBundleGeneratorMojo.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemResourceBundleGeneratorMojo.java
index a240c0c..fd97798 100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemResourceBundleGeneratorMojo.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/ProblemResourceBundleGeneratorMojo.java
@@ -16,6 +16,7 @@
 
 package org.apache.flex.compiler.tools.problems;
 
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -98,4 +99,9 @@ public class ProblemResourceBundleGeneratorMojo
         return "";
     }
 
+    @Override
+    protected void clean(File outputFile) throws MojoExecutionException {
+        // TODO: Clear all the content after: "# Messages for Compiler problems are written below by ProblemLocalizer."
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/AntTestAdapter.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/AntTestAdapter.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/AntTestAdapter.java
new file mode 100644
index 0000000..cd3cb4f
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/AntTestAdapter.java
@@ -0,0 +1,115 @@
+/*
+ *
+ *  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.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Created by christoferdutz on 23.02.16.
+ */
+public class AntTestAdapter implements ITestAdapter {
+
+    private static EnvProperties env = EnvProperties.initiate();
+
+    private static final File PLAYERGLOBAL_SWC = new File(FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc"));
+    // The Ant script for compiler.tests copies a standalone player to the temp directory.
+    private static final File FLASHPLAYER = new File(FilenameNormalization.normalize(env.FDBG));
+
+    private static final File LIBS_ROOT = new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs"));
+    private static final File RESOURCE_BUNDLES_ROOT = new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US"));
+
+    @Override
+    public String getTempDir() {
+        return FilenameNormalization.normalize("temp"); // ensure this exists
+    }
+
+    @Override
+    public List<File> getLibraries(boolean withFlex) {
+        // Do some checks if all needed environment variables are set.
+        if (withFlex) {
+            assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
+        }
+        assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set", env.FPSDK);
+
+        // Create a list of libs needed to compile.
+        List<File> libraries = new ArrayList<File>();
+        libraries.add(getPlayerglobal());
+        if (withFlex)
+        {
+            libraries.add(getFlexArtifact("framework"));
+            libraries.add(getFlexArtifact("rpc"));
+            libraries.add(getFlexArtifact("spark"));
+        }
+        return libraries;
+    }
+
+    @Override
+    public File getPlayerglobal() {
+        return PLAYERGLOBAL_SWC;
+    }
+
+    @Override
+    public File getFlashplayerDebugger() {
+        return FLASHPLAYER;
+    }
+
+    @Override
+    public String getFlexManifestPath(String type) {
+        return env.SDK + "\\frameworks\\" + type + "-manifest.xml";
+    }
+
+    @Override
+    public File getFlexArtifact(String artifactName) {
+        return getLib(artifactName);
+    }
+
+    @Override
+    public File getFlexArtifactResourceBundle(String artifactName) {
+        return getResourceBundle(artifactName);
+    }
+
+    @Override
+    public String getFlexJsManifestPath(String type) {
+        return null;
+    }
+
+    @Override
+    public File getFlexJSArtifact(String artifactName) {
+        return null;
+    }
+
+    @Override
+    public File getUnitTestBaseDir() {
+        return new File("test-files");
+    }
+
+    private File getLib(String artifactId) {
+        return new File(LIBS_ROOT, artifactId + ".swc");
+    }
+
+    private File getResourceBundle(String artifactId) {
+        return new File(RESOURCE_BUNDLES_ROOT, artifactId + "_rb.swc");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/EnvProperties.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/EnvProperties.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/EnvProperties.java
new file mode 100644
index 0000000..be22fee
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/EnvProperties.java
@@ -0,0 +1,149 @@
+/*
+ *
+ *  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.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+
+/**
+ *  EnvProperties checks in following order for a value.
+ * 
+ *  1) unittest.properties 
+ *  2) environment variables
+ *  3) for key FLEX_HOME & PLAYERGLOBAL_HOME sets a default value.
+ */
+public class EnvProperties {
+	
+    /**
+     * FLEX_HOME
+     */
+    public String SDK;
+    
+    /**
+     * TLF_HOME
+     */
+    public String TLF;
+    
+	/**
+	 * PLAYERGLOBAL_HOME
+	 */
+	public String FPSDK;
+	
+	/**
+	 * AIR_HOME
+	 */
+	public String AIRSDK;
+	
+	/**
+	 * FLASHPLAYER_DEBUGGER
+	 */
+	public String FDBG;
+	
+    /**
+     * ASJS_HOME
+     */
+    public String ASJS;
+
+    /**
+     * PLAYERGLOBAL_VERSION
+     */
+    public String FPVER;
+    
+	
+	private static EnvProperties env;
+	
+	public static EnvProperties initiate() {
+		if(env == null) {
+			env = new EnvProperties();
+			env.setup();
+		}
+		return env;
+	}
+	
+	private void setup()
+	{
+        String prefix = "";
+		Properties p = new Properties();
+        String envFileName = FilenameNormalization.normalize("../env.properties");
+        try {
+            File f = new File(envFileName);
+            if (f.exists())
+            {
+            	p.load(new FileInputStream( f ));
+                prefix = "env.";
+            }
+        } catch (FileNotFoundException e) {
+            System.out.println(envFileName + " not found");
+            try {
+                File f = new File("unittest.properties");
+                p.load(new FileInputStream( f ));
+            } catch (FileNotFoundException e1) {
+                System.out.println("unittest.properties not found");
+            } catch (IOException e1) {
+	            // Ignore
+            }
+        } catch (IOException e) {
+	        // Ignore
+        }
+		
+		SDK = p.getProperty(prefix + "FLEX_HOME", System.getenv("FLEX_HOME"));
+		if(SDK == null)
+		{
+            SDK = FilenameNormalization.normalize("../../flex-sdk");
+	        File mxmlc = new File(SDK + "/lib/mxmlc.jar");
+	        if (!mxmlc.exists())
+	            SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");
+		}
+		System.out.println("environment property - FLEX_HOME = " + SDK);
+		
+		FPSDK = p.getProperty(prefix + "PLAYERGLOBAL_HOME", System.getenv("PLAYERGLOBAL_HOME"));
+		if(FPSDK == null)
+			FPSDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
+		System.out.println("environment property - PLAYERGLOBAL_HOME = " + FPSDK);
+        
+        FPVER = p.getProperty(prefix + "PLAYERGLOBAL_VERSION", System.getenv("PLAYERGLOBAL_VERSION"));
+        if (FPVER == null)
+            FPVER = "11.1";
+        System.out.println("environment property - PLAYERGLOBAL_VERSION = " + FPVER);
+        
+        TLF = p.getProperty(prefix + "TLF_HOME", System.getenv("TLF_HOME"));
+        if (TLF == null)
+        {
+            TLF = FilenameNormalization.normalize("../../flex-tlf");
+        }
+        System.out.println("environment property - TLF_HOME = " + TLF);
+		
+		AIRSDK = p.getProperty(prefix + "AIR_HOME", System.getenv("AIR_HOME"));
+		System.out.println("environment property - AIR_HOME = " + AIRSDK);
+
+		FDBG = p.getProperty(prefix + "FLASHPLAYER_DEBUGGER", System.getenv("FLASHPLAYER_DEBUGGER"));
+		System.out.println("environment property - FLASHPLAYER_DEBUGGER = " + FDBG);
+
+		ASJS = p.getProperty(prefix + "ASJS_HOME", System.getenv("ASJS_HOME"));
+		if (ASJS == null)
+			ASJS = FilenameNormalization.normalize("../../flex-asjs");
+		System.out.println("environment property - ASJS_HOME = " + ASJS);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/FilenameNormalization.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/FilenameNormalization.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/FilenameNormalization.java
new file mode 100644
index 0000000..7ef5e68
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/FilenameNormalization.java
@@ -0,0 +1,109 @@
+/*
+ *
+ *  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.utils;
+
+import java.io.File;
+
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ * Utility class to normalize filenames.  All Files entering the driver
+ * should be run through this class
+ */
+public class FilenameNormalization
+{
+    /**
+     * Normalizes an array of files.
+     * 
+     * @see #normalize(File)
+     * @param files Array of files to normalize.
+     * @return Array of normalized files.
+     */
+    public static File[] normalize(File[] files)
+    {
+        File[] result = new File[files.length];
+        for (int i = 0; i < files.length; ++i)
+        {
+            result[i] = normalize(files[i]);
+        }
+        return result;
+    }
+
+    /**
+     * Normalize a {@link File}.  This method normalizes the case of the file path
+     * characters and then calls {@link FilenameUtils#normalize(String)}.
+     * @see FilenameUtils#normalize(String)
+     * @param f A file.
+     * @return The normalized File.
+     */
+    public static File normalize(File f)
+    {
+        String caseNormalizedAbsPath = f.getAbsolutePath();
+        return new File(FilenameUtils.normalize(caseNormalizedAbsPath));
+    }
+
+    /**
+     * Normalize a {@link String}. This method normalizes the case of the file
+     * path characters and then calls {@link FilenameUtils#normalize(String)}.
+     * 
+     * @see FilenameUtils#normalize(String)
+     * @param path The fiel path.
+     * @return The normalized String. If the given path is already normalized,
+     * the original string object will be returned.
+     */
+    public static String normalize(String path)
+    {
+        File f = new File(path);
+        String caseNormalizedAbsPath = f.getAbsolutePath();
+        String normalized = FilenameUtils.normalize(caseNormalizedAbsPath);
+
+        if (normalized == null)
+            return path;
+
+        // If the path is already normalized, return the original string object
+        // to prevent duplicated string objects.
+        if (normalized.equals(path))
+            return path;
+        else
+            return normalized;
+    }
+    
+    /**
+     * Determines whether a file path is in normalized form.
+     * 
+     * @param path A file path.
+     */
+    public static boolean isNormalized(String path)
+    {
+        String normalizedPath = normalize(path);
+        return normalizedPath.equals(path);
+    }
+
+    /**
+     * Get the normalized file path of a Java {@link File} object.
+     * 
+     * @param file File object.
+     * @return Normalized file path.
+     */
+    public static String normalizeFileToPath(File file)
+    {
+        return normalize(file.getAbsolutePath());
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/ITestAdapter.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/ITestAdapter.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/ITestAdapter.java
new file mode 100644
index 0000000..5f35557
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/ITestAdapter.java
@@ -0,0 +1,50 @@
+/*
+ *
+ *  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.utils;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Created by christoferdutz on 23.02.16.
+ */
+public interface ITestAdapter {
+
+    String getTempDir();
+
+    List<File> getLibraries(boolean withFlex);
+
+    File getPlayerglobal();
+
+    File getFlashplayerDebugger();
+
+    String getFlexManifestPath(String type);
+
+    File getFlexArtifact(String artifactName);
+
+    File getFlexArtifactResourceBundle(String artifactName);
+
+    String getFlexJsManifestPath(String type);
+
+    File getFlexJSArtifact(String artifactName);
+
+    File getUnitTestBaseDir();
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/MavenTestAdapter.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/MavenTestAdapter.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/MavenTestAdapter.java
new file mode 100644
index 0000000..457249d
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/MavenTestAdapter.java
@@ -0,0 +1,208 @@
+/*
+ *
+ *  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.utils;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+
+/**
+ * Created by christoferdutz on 23.02.16.
+ */
+public class MavenTestAdapter implements ITestAdapter {
+
+    private static final int KILOBYTE = 1024;
+    private static final int MEGABYTE = KILOBYTE * 1024;
+    private static final int BUFFER_MAX = MEGABYTE;
+
+    @Override
+    public String getTempDir() {
+        File tempDir = new File("target/surefire-temp");
+        if(!tempDir.exists()) {
+            if(!tempDir.mkdirs()) {
+                throw new RuntimeException("Could not create temp dir at: " + tempDir.getAbsolutePath());
+            }
+        }
+        return tempDir.getPath();
+    }
+
+    @Override
+    public List<File> getLibraries(boolean withFlex) {
+        List<File> libs = new ArrayList<File>();
+        libs.add(getPlayerglobal());
+        if(withFlex) {
+            String flexVersion = System.getProperty("flexVersion");
+            libs.add(getDependency("org.apache.flex.framework", "framework", flexVersion, "swc", null));
+            libs.add(getDependency("org.apache.flex.framework", "rpc", flexVersion, "swc", null));
+            libs.add(getDependency("org.apache.flex.framework", "spark", flexVersion, "swc", null));
+        }
+        return libs;
+    }
+
+    @Override
+    public File getPlayerglobal() {
+        return getDependency("com.adobe.flash.framework", "playerglobal",
+                System.getProperty("flashVersion"), "swc", null);
+    }
+
+    @Override
+    public File getFlashplayerDebugger() {
+        // TODO: If the archive isn't unpacked, unpack it.
+        // TODO: Return a reference to the player debugger executable, depending on the current platform.
+        String FLASHPLAYER_DEBUGGER = System.getProperty("FLASHPLAYER_DEBUGGER", null);
+        if(FLASHPLAYER_DEBUGGER == null || FLASHPLAYER_DEBUGGER.length() == 0) {
+            throw new RuntimeException("You have to specify the location of the flash debug player executable.");
+        }
+        return new File(FLASHPLAYER_DEBUGGER);
+        /*return getDependency("com.adobe.flash.runtime", "player-debugger",
+                System.getProperty("flashVersion"), "zip", null);*/
+    }
+
+    @Override
+    public String getFlexManifestPath(String type) {
+        File configsZip = getDependency("org.apache.flex.framework", "framework",
+                System.getProperty("flexVersion"), "zip", "configs");
+        File frameworkDir = configsZip.getParentFile();
+        File unpackedConfigsDir = new File(frameworkDir, "configs_zip");
+        // If the directory doesn't exist, we have to create it by unpacking the zip archive.
+        // This is identical behaviour to Flexmojos, which does the same thing.
+        if(!unpackedConfigsDir.exists()) {
+            unpackFrameworkConfigs(configsZip, unpackedConfigsDir);
+        }
+        return new File(unpackedConfigsDir, type + "-manifest.xml").getPath();
+    }
+
+    @Override
+    public File getFlexArtifact(String artifactName) {
+        String flexVersion = System.getProperty("flexVersion");
+        return getDependency("org.apache.flex.framework", artifactName, flexVersion, "swc", null);
+    }
+
+    @Override
+    public File getFlexArtifactResourceBundle(String artifactName) {
+        String flexVersion = System.getProperty("flexVersion");
+        return getDependency("org.apache.flex.framework", artifactName, flexVersion, "rb.swc", "en_US");
+    }
+
+    @Override
+    public String getFlexJsManifestPath(String type) {
+        File configsZip = getDependency("org.apache.flex.framework.flexjs", "framework",
+                System.getProperty("flexJsVersion"), "zip", "configs");
+        File frameworkDir = configsZip.getParentFile();
+        File unpackedConfigsDir = new File(frameworkDir, "configs_zip");
+        // If the directory doesn't exist, we have to create it by unpacking the zip archive.
+        // This is identical behaviour to Flexmojos, which does the same thing.
+        if(!unpackedConfigsDir.exists()) {
+            unpackFrameworkConfigs(configsZip, unpackedConfigsDir);
+        }
+        return new File(unpackedConfigsDir, type + "-manifest.xml").getPath();
+    }
+
+    @Override
+    public File getFlexJSArtifact(String artifactName) {
+        String flexJsVersion = System.getProperty("flexJsVersion");
+        return getDependency("org.apache.flex.framework.flexjs", artifactName, flexJsVersion, "swc", null);
+    }
+
+    @Override
+    public File getUnitTestBaseDir() {
+        return new File(FilenameUtils.normalize("target/test-classes"));
+    }
+
+    private File getDependency(String groupId, String artifactId, String version, String type, String classifier) {
+        String dependencyPath = System.getProperty("mavenLocalRepoDir") + File.separator +
+                groupId.replaceAll("\\.", Matcher.quoteReplacement(File.separator)) + File.separator + artifactId + File.separator + version +
+                File.separator + artifactId + "-" + version + ((classifier != null) ? "-" + classifier : "") + "." +
+                type;
+        File dependency = new File(dependencyPath);
+        if(!dependency.exists()) {
+            throw new RuntimeException("Could not read SWC dependency at " + dependency.getAbsolutePath());
+        }
+        return dependency;
+    }
+
+    private void unpackFrameworkConfigs(File configZip, File outputDirectory) {
+        final byte[] data = new byte[BUFFER_MAX];
+        ArchiveInputStream archiveInputStream = null;
+        ArchiveEntry entry;
+        try {
+            archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(
+                    new BufferedInputStream(new FileInputStream(configZip)));
+            if(!outputDirectory.exists() && !outputDirectory.mkdirs()) {
+                throw new RuntimeException("Could not create output directory for config zip at " +
+                        outputDirectory.getPath());
+            }
+            while ((entry = archiveInputStream.getNextEntry()) != null) {
+                final File outputFile = new File(outputDirectory, entry.getName());
+
+                // Entry is a directory.
+                if (entry.isDirectory()) {
+                    if (!outputFile.exists()) {
+                        if(!outputFile.mkdirs()) {
+                            throw new RuntimeException(
+                                    "Could not create output directory " + outputFile.getAbsolutePath());
+                        }
+                    }
+                }
+
+                // Entry is a file.
+                else {
+                    final FileOutputStream fos = new FileOutputStream(outputFile);
+                    BufferedOutputStream dest = null;
+                    try {
+                        dest = new BufferedOutputStream(fos, BUFFER_MAX);
+
+                        int count;
+                        while ((count = archiveInputStream.read(data, 0, BUFFER_MAX)) != -1) {
+                            dest.write(data, 0, count);
+                        }
+                    } finally {
+                        if(dest != null) {
+                            dest.flush();
+                            dest.close();
+                        }
+                    }
+                }
+            }
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException("Error unpacking resources", e);
+        } catch (IOException e) {
+            throw new RuntimeException("Error unpacking resources", e);
+        } catch (ArchiveException e) {
+            throw new RuntimeException("Error unpacking resources", e);
+        } finally {
+            if(archiveInputStream != null) {
+                try {
+                    archiveInputStream.close();
+                } catch(Exception e) {
+                    // Ignore...
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-build-tools/src/main/java/org/apache/flex/utils/TestAdapterFactory.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/utils/TestAdapterFactory.java b/compiler-build-tools/src/main/java/org/apache/flex/utils/TestAdapterFactory.java
new file mode 100644
index 0000000..ccdb0c2
--- /dev/null
+++ b/compiler-build-tools/src/main/java/org/apache/flex/utils/TestAdapterFactory.java
@@ -0,0 +1,41 @@
+/*
+ *
+ *  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.utils;
+
+/**
+ * Created by christoferdutz on 10.03.16.
+ */
+public class TestAdapterFactory {
+
+    private static final ITestAdapter adapter =
+            System.getProperty("buildType", "Ant").equals("Maven") ?
+                    new MavenTestAdapter() : new AntTestAdapter();
+
+    /**
+     * Depending on the "buildType" system-property, create the corresponding test-adapter
+     * Make the AntTestAdapter the default.
+     *
+     * @return test adapter instance for the given type of build.
+     */
+    public static ITestAdapter getTestAdapter() {
+        return adapter;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jburg-types/src/main/java/org/apache/flex/compiler/internal/as/codegen/IASNodeAdapter.java
----------------------------------------------------------------------
diff --git a/compiler-jburg-types/src/main/java/org/apache/flex/compiler/internal/as/codegen/IASNodeAdapter.java b/compiler-jburg-types/src/main/java/org/apache/flex/compiler/internal/as/codegen/IASNodeAdapter.java
new file mode 100644
index 0000000..d35f2a4
--- /dev/null
+++ b/compiler-jburg-types/src/main/java/org/apache/flex/compiler/internal/as/codegen/IASNodeAdapter.java
@@ -0,0 +1,74 @@
+/*
+ *
+ *  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.as.codegen;
+
+import jburg.burg.emitlangs.EmitLang;
+import jburg.burg.inode.InodeAdapter;
+import jburg.burg.inode.InodeAdapter2;
+
+/**
+ *  IASNodeAdapter generates method calls into
+ *  a BURM to access properties of an IASNode.
+ */
+public class IASNodeAdapter implements InodeAdapter
+{
+	/**
+	 *  @return true if the adapter can handle this type of inode.
+	 */
+	public boolean accept(String inodeClassName)
+	{
+        return "IASNode".equals(inodeClassName);
+    }
+
+    /**
+     *  Generate an expression to fetch a node's child count.
+     *  @param node_path - the code generator's path to the node.
+     *  @param emitter - the compiler-compiler's code emitter.
+     *  @return said expression.
+     */
+	public String genGetArity(String node_path, EmitLang emitter)
+	{
+		return emitter.genCallMethod("SemanticUtils", "getChildCount", new String[] { node_path } );
+	}
+
+	/**
+	 *  Generate an expression to fetch a node's Nth child.
+	 *  @param node_path - the code generator's path to the node.
+	 *  @param index - the index expression. 
+	 *  @param emitter - the compiler-compiler's code emitter.
+     *  @return said expression.
+	 */
+	public String genGetNthChild(String node_path, String index, EmitLang emitter)
+	{
+		return emitter.genCallMethod("SemanticUtils", "getNthChild", new String[] { node_path, index } );
+	}
+
+	/**
+	 *  Generate an expression to fetch a node's node ID.
+	 *  @param node_path - the code generator's path to the node.
+     *  @param emitter - the compiler-compiler's code emitter.
+     *  @return said expression.
+	 */
+	public String genGetOperator(String node_path, EmitLang emitter)
+	{
+		return emitter.genCallMethod(node_path, "getNodeID", null);
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/asjsc
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/asjsc b/compiler-jx/src/assembly/scripts/asjsc
new file mode 100755
index 0000000..6c65155
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/asjsc
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+################################################################################
+##
+##  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.
+##
+################################################################################
+
+
+#
+# mxmlc shell script to launch falcon-mxmlc.jar on OSX, Unix, or Cygwin.
+# In Windows Command Prompt, use mxmlc.bat instead.
+#
+
+if [ "x${FALCON_HOME}" = "x" ]
+then
+    SCRIPT_HOME=`dirname "$0"`
+    FALCON_HOME=${SCRIPT_HOME}/../../compiler
+fi
+
+echo Using Falcon codebase: $FALCON_HOME
+
+if [ "x${FLEX_HOME}" = "x" ]
+then
+    FLEX_HOME=${FALCON_HOME}/generated/dist/sdk
+fi
+echo Using Flex SDK: $FLEX_HOME
+
+case `uname` in
+		CYGWIN*)
+			OS="Windows"
+		;;
+		*)
+			OS=Unix
+esac
+
+D32=''
+
+if [ $OS = "Windows" ]; then
+
+	FALCON_HOME=`cygpath -m $FALCON_HOME`
+	FLEX_HOME=`cygpath -m $FLEX_HOME`
+
+elif [ $OS = "Unix" ]; then
+
+    check64="`java -version 2>&1 | grep -i 64-Bit`"
+    isOSX="`uname | grep -i Darwin`"
+    javaVersion="`java -version 2>&1 | awk -F '[ ".]+' 'NR==1 {print $3 "." $4}'`"
+    
+    if [ "$isOSX" != "" -a "$HOSTTYPE" = "x86_64" -a "$check64" != "" -a "$javaVersion" = "1.6" ]; then
+        D32='-d32'
+    fi	
+fi
+
+VMARGS="-Xmx384m -Dsun.io.useCanonCaches=false "
+
+java $VMARGS $D32 $SETUP_SH_VMARGS -Dflexcompiler="$FALCON_HOME" -Dflexlib="$FLEX_HOME/frameworks" -jar "$SCRIPT_HOME/../lib/mxmlc.jar" +flexlib="$FLEX_HOME/frameworks" -external-library-path="$SCRIPT_HOME/../libs/JS.swc" "$@"

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/asjsc.bat
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/asjsc.bat b/compiler-jx/src/assembly/scripts/asjsc.bat
new file mode 100644
index 0000000..041fbcf
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/asjsc.bat
@@ -0,0 +1,29 @@
+@echo off
+
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+rem
+rem mxmlc.bat script to launch falcon-mxmlc.jar in Windows Command Prompt.
+rem On OSX, Unix, or Cygwin, use the mxmlc shell script instead.
+rem
+
+if "x%FALCON_HOME%"=="x"  (set FALCON_HOME=%~dp0..) else echo Using Falcon codebase: %FALCON_HOME%
+
+if "x%FLEX_HOME%"=="x" (set FLEX_HOME=%~dp0..) else echo Using Flex SDK: %FLEX_HOME%
+
+@java -Dsun.io.useCanonCaches=false -Xms32m -Xmx512m -Dflexcompiler="%FALCON_HOME%" -Dflexlib="%FLEX_HOME%\frameworks" -jar "%FALCON_HOME%\lib\mxmlc.jar" -external-library-path="%FALCON_HOME%\libs\JS.swc" %*
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/compc
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/compc b/compiler-jx/src/assembly/scripts/compc
new file mode 100755
index 0000000..bb48e71
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/compc
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+################################################################################
+##
+##  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.
+##
+################################################################################
+
+
+#
+# mxmlc shell script to launch falcon-mxmlc.jar on OSX, Unix, or Cygwin.
+# In Windows Command Prompt, use mxmlc.bat instead.
+#
+
+if [ "x${FALCON_HOME}" = "x" ]
+then
+    SCRIPT_HOME=`dirname "$0"`
+    FALCON_HOME=${SCRIPT_HOME}/../../compiler
+fi
+
+echo Using Falcon codebase: $FALCON_HOME
+
+if [ "x${FLEX_HOME}" = "x" ]
+then
+    FLEX_HOME=${FALCON_HOME}/generated/dist/sdk
+fi
+echo Using Flex SDK: $FLEX_HOME
+
+case `uname` in
+		CYGWIN*)
+			OS="Windows"
+		;;
+		*)
+			OS=Unix
+esac
+
+D32=''
+
+if [ $OS = "Windows" ]; then
+
+	FALCON_HOME=`cygpath -m $FALCON_HOME`
+	FLEX_HOME=`cygpath -m $FLEX_HOME`
+
+elif [ $OS = "Unix" ]; then
+
+    check64="`java -version 2>&1 | grep -i 64-Bit`"
+    isOSX="`uname | grep -i Darwin`"
+    javaVersion="`java -version 2>&1 | awk -F '[ ".]+' 'NR==1 {print $3 "." $4}'`"
+    
+    if [ "$isOSX" != "" -a "$HOSTTYPE" = "x86_64" -a "$check64" != "" -a "$javaVersion" = "1.6" ]; then
+        D32='-d32'
+    fi	
+fi
+
+VMARGS="-Xmx384m -Dsun.io.useCanonCaches=false "
+
+java $VMARGS $D32 $SETUP_SH_VMARGS -Dflexcompiler="$FALCON_HOME" -Dflexlib="$FLEX_HOME/frameworks" -jar "$SCRIPT_HOME/../lib/compc.jar" +flexlib="$FLEX_HOME/frameworks" "$@"

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/compc.bat
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/compc.bat b/compiler-jx/src/assembly/scripts/compc.bat
new file mode 100644
index 0000000..6626760
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/compc.bat
@@ -0,0 +1,29 @@
+@echo off
+
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+rem
+rem mxmlc.bat script to launch falcon-mxmlc.jar in Windows Command Prompt.
+rem On OSX, Unix, or Cygwin, use the mxmlc shell script instead.
+rem
+
+if "x%FALCON_HOME%"=="x"  (set FALCON_HOME=%~dp0..) else echo Using Falcon codebase: %FALCON_HOME%
+
+if "x%FLEX_HOME%"=="x" (set FLEX_HOME=%~dp0..) else echo Using Flex SDK: %FLEX_HOME%
+
+@java -Dsun.io.useCanonCaches=false -Xms32m -Xmx512m -Dflexcompiler="%FALCON_HOME%" -Dflexlib="%FLEX_HOME%\frameworks" -jar "%FALCON_HOME%\lib\mxmlc.jar" %*
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/mxmlc
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/mxmlc b/compiler-jx/src/assembly/scripts/mxmlc
new file mode 100755
index 0000000..9218961
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/mxmlc
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+################################################################################
+##
+##  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.
+##
+################################################################################
+
+
+#
+# mxmlc shell script to launch falcon-mxmlc.jar on OSX, Unix, or Cygwin.
+# In Windows Command Prompt, use mxmlc.bat instead.
+#
+
+if [ "x${FALCON_HOME}" = "x" ]
+then
+    SCRIPT_HOME=`dirname "$0"`
+    FALCON_HOME=${SCRIPT_HOME}/../../compiler
+fi
+
+echo Using Falcon codebase: $FALCON_HOME
+
+if [ "x${FLEX_HOME}" = "x" ]
+then
+    FLEX_HOME=${FALCON_HOME}/generated/dist/sdk
+fi
+echo Using Flex SDK: $FLEX_HOME
+
+case `uname` in
+		CYGWIN*)
+			OS="Windows"
+		;;
+		*)
+			OS=Unix
+esac
+
+D32=''
+
+if [ $OS = "Windows" ]; then
+
+	FALCON_HOME=`cygpath -m $FALCON_HOME`
+	FLEX_HOME=`cygpath -m $FLEX_HOME`
+
+elif [ $OS = "Unix" ]; then
+
+    check64="`java -version 2>&1 | grep -i 64-Bit`"
+    isOSX="`uname | grep -i Darwin`"
+    javaVersion="`java -version 2>&1 | awk -F '[ ".]+' 'NR==1 {print $3 "." $4}'`"
+    
+    if [ "$isOSX" != "" -a "$HOSTTYPE" = "x86_64" -a "$check64" != "" -a "$javaVersion" = "1.6" ]; then
+        D32='-d32'
+    fi	
+fi
+
+VMARGS="-Xmx384m -Dsun.io.useCanonCaches=false "
+
+java $VMARGS $D32 $SETUP_SH_VMARGS -Dflexcompiler="$FALCON_HOME" -Dflexlib="$FLEX_HOME/frameworks" -jar "$SCRIPT_HOME/../lib/mxmlc.jar" +flexlib="$FLEX_HOME/frameworks" "$@"

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/assembly/scripts/mxmlc.bat
----------------------------------------------------------------------
diff --git a/compiler-jx/src/assembly/scripts/mxmlc.bat b/compiler-jx/src/assembly/scripts/mxmlc.bat
new file mode 100644
index 0000000..6626760
--- /dev/null
+++ b/compiler-jx/src/assembly/scripts/mxmlc.bat
@@ -0,0 +1,29 @@
+@echo off
+
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+rem
+rem mxmlc.bat script to launch falcon-mxmlc.jar in Windows Command Prompt.
+rem On OSX, Unix, or Cygwin, use the mxmlc shell script instead.
+rem
+
+if "x%FALCON_HOME%"=="x"  (set FALCON_HOME=%~dp0..) else echo Using Falcon codebase: %FALCON_HOME%
+
+if "x%FLEX_HOME%"=="x" (set FLEX_HOME=%~dp0..) else echo Using Flex SDK: %FLEX_HOME%
+
+@java -Dsun.io.useCanonCaches=false -Xms32m -Xmx512m -Dflexcompiler="%FALCON_HOME%" -Dflexlib="%FLEX_HOME%\frameworks" -jar "%FALCON_HOME%\lib\mxmlc.jar" %*
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/com/google/javascript/jscomp/FlexJSDiagnosticGroups.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/com/google/javascript/jscomp/FlexJSDiagnosticGroups.java b/compiler-jx/src/main/java/com/google/javascript/jscomp/FlexJSDiagnosticGroups.java
new file mode 100644
index 0000000..5b77b44
--- /dev/null
+++ b/compiler-jx/src/main/java/com/google/javascript/jscomp/FlexJSDiagnosticGroups.java
@@ -0,0 +1,58 @@
+/*
+ *
+ *  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 com.google.javascript.jscomp;
+
+/**
+ * Custom DiagnosticGroups allow @suppress directives to disable
+ * certain warnings while letting other warnings in the group
+ * show.
+ */
+public class FlexJSDiagnosticGroups {
+
+	/**
+	 * Flex ItemRenderer Factories store the constructor in a variable
+	 * resulting in this warning.
+	 */
+	public static final DiagnosticGroup FLEXJS_NOT_A_CONSTRUCTOR =
+		DiagnosticGroups.registerGroup("flexjsNotAConstructor",
+                TypeCheck.NOT_A_CONSTRUCTOR);
+
+	/**
+	 * Flex code calls super.methodName from functions other than
+	 * overrides of the methodName.
+	 */
+	public static final DiagnosticGroup FLEXJS_SUPER_CALL_TO_DIFFERENT_NAME =
+		DiagnosticGroups.registerGroup("flexjsSuperCallToDifferentName",
+                ProcessClosurePrimitives.BASE_CLASS_ERROR);
+	/*
+	public static final DiagnosticGroup FLEXJS_REFERENCE_BEFORE_DECLARE =
+		DiagnosticGroups.registerGroup("flexjsReferenceBeforeDeclare",
+                VariableReferenceCheck.UNDECLARED_REFERENCE);
+    */
+	
+	/**
+	 * Flex code won't always generate a goog.requires for types only used
+	 * in JSDoc annotations, but the compiler complains.
+	 */
+	public static final DiagnosticGroup FLEXJS_UNKNOWN_JSDOC_TYPE_NAME =
+		DiagnosticGroups.registerGroup("flexjsUnknownJSDocTypeName",
+                RhinoErrorReporter.TYPE_PARSE_ERROR);
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/com/google/javascript/jscomp/JXCompilerOptions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/com/google/javascript/jscomp/JXCompilerOptions.java b/compiler-jx/src/main/java/com/google/javascript/jscomp/JXCompilerOptions.java
new file mode 100644
index 0000000..c31c46d
--- /dev/null
+++ b/compiler-jx/src/main/java/com/google/javascript/jscomp/JXCompilerOptions.java
@@ -0,0 +1,34 @@
+/*
+ *
+ *  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 com.google.javascript.jscomp;
+
+public class JXCompilerOptions extends CompilerOptions
+{
+
+    private static final long serialVersionUID = 2021530437904249081L;
+
+    public JXCompilerOptions()
+    {
+        super();
+        
+        declaredGlobalExternsOnWindow = false;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java b/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
new file mode 100644
index 0000000..5470f47
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java
@@ -0,0 +1,107 @@
+/*
+ *
+ *  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.asdoc.flexjs;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.flex.compiler.asdoc.IASDocComment;
+import org.apache.flex.compiler.asdoc.IASDocTag;
+
+import antlr.Token;
+
+public class ASDocComment implements IASDocComment
+{
+
+    public ASDocComment(Token t)
+    {
+        token = t;
+    }
+
+    Token token;
+
+    public String commentNoEnd()
+    {
+        String s = token.getText();
+        String[] lines = s.split("\n");
+        StringBuilder sb = new StringBuilder();
+        int n = lines.length;
+        if (n == 1)
+        {
+        	int c = lines[0].indexOf("*/");
+        	if (c != -1)
+        		lines[0] = lines[0].substring(0, c);
+        }
+        sb.append(lines[0]);
+        sb.append("\n");
+        for (int i = 1; i < n - 1; i++)
+        {
+            String line = lines[i];
+            int star = line.indexOf("*");
+            sb.append(" ");
+            if (star > -1)
+                sb.append(line.substring(star));
+            sb.append("\n");
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public String getDescription()
+    {
+        return null;
+    }
+
+    @Override
+    public void compile()
+    {
+    }
+
+    @Override
+    public boolean hasTag(String name)
+    {
+        return false;
+    }
+
+    @Override
+    public IASDocTag getTag(String name)
+    {
+        return null;
+    }
+
+    @Override
+    public Map<String, List<IASDocTag>> getTags()
+    {
+        return null;
+    }
+
+    @Override
+    public Collection<IASDocTag> getTagsByName(String string)
+    {
+        return null;
+    }
+
+    @Override
+    public void paste(IASDocComment source)
+    {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
new file mode 100644
index 0000000..b3b9c64
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
@@ -0,0 +1,430 @@
+/*
+ *
+ *  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.clients;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.flex.compiler.codegen.as.IASWriter;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.js.IJSApplication;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
+import org.apache.flex.compiler.exceptions.ConfigurationException.IOError;
+import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.driver.as.ASBackend;
+import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSSWCBackend;
+import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSSWCBackend;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.InternalCompilerProblem;
+import org.apache.flex.compiler.problems.UnableToBuildSWFProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+/**
+ * @author Erik de Bruin
+ * @author Michael Schmalle
+ */
+public class COMPJSC extends MXMLJSC
+{
+    /*
+     * Exit code enumerations.
+     */
+    static enum ExitCode
+    {
+        SUCCESS(0),
+        PRINT_HELP(1),
+        FAILED_WITH_PROBLEMS(2),
+        FAILED_WITH_EXCEPTIONS(3),
+        FAILED_WITH_CONFIG_PROBLEMS(4);
+
+        ExitCode(int code)
+        {
+            this.code = code;
+        }
+
+        final int code;
+    }
+
+    @Override
+    public String getName()
+    {
+        return FLEX_TOOL_COMPC;
+    }
+
+    @Override
+    public int execute(String[] args)
+    {
+        return staticMainNoExit(args);
+    }
+
+    /**
+     * Java program entry point.
+     * 
+     * @param args command line arguments
+     */
+    public static void main(final String[] args)
+    {
+        int exitCode = staticMainNoExit(args);
+        System.exit(exitCode);
+    }
+
+    /**
+     * Entry point for the {@code <compc>} Ant task.
+     *
+     * @param args Command line arguments.
+     * @return An exit code.
+     */
+    public static int staticMainNoExit(final String[] args)
+    {
+        long startTime = System.nanoTime();
+
+        IBackend backend = new ASBackend();
+        for (String s : args)
+        {
+            if (s.contains("-js-output-type"))
+            {
+                jsOutputType = JSOutputType.fromString(s.split("=")[1]);
+
+                switch (jsOutputType)
+                {
+                case AMD:
+                    backend = new AMDBackend();
+                    break;
+
+                case JSC:
+                    backend = new MXMLJSCJSSWCBackend();
+                    break;
+
+                case FLEXJS:
+                case FLEXJS_DUAL:
+                    backend = new MXMLFlexJSSWCBackend();
+                    break;
+
+                case GOOG:
+                    backend = new GoogBackend();
+                    break;
+
+                case VF2JS:
+                    backend = new MXMLVF2JSSWCBackend();
+                    break;
+
+                default:
+                    throw new UnsupportedOperationException();
+                }
+            }
+        }
+
+        final COMPJSC mxmlc = new COMPJSC(backend);
+        final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+        final int exitCode = mxmlc.mainNoExit(args, problems, true);
+
+        long endTime = System.nanoTime();
+        JSSharedData.instance.stdout((endTime - startTime) / 1e9 + " seconds");
+
+        return exitCode;
+    }
+
+    public COMPJSC(IBackend backend)
+    {
+        super(backend);
+    }
+
+    /**
+     * Main body of this program. This method is called from the public static
+     * method's for this program.
+     * 
+     * @return true if compiler succeeds
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    @Override
+    protected boolean compile()
+    {
+        boolean compilationSuccess = false;
+
+        try
+        {
+            project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
+
+            if (setupTargetFile())
+                buildArtifact();
+
+            if (jsTarget != null)
+            {
+                Collection<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
+                Collection<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
+
+                if (!config.getCreateTargetWithErrors())
+                {
+                    problems.getErrorsAndWarnings(errors, warnings);
+                    if (errors.size() > 0)
+                        return false;
+                }
+
+                File outputFolder = new File(getOutputFilePath());
+
+                Set<String> externs = config.getExterns();
+                Collection<ICompilationUnit> roots = ((FlexJSSWCTarget)target).getReachableCompilationUnits(errors);
+                Collection<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
+                for (final ICompilationUnit cu : reachableCompilationUnits)
+                {
+                    ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+                    if (cuType == ICompilationUnit.UnitType.AS_UNIT
+                            || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+                    {
+                    	String symbol = cu.getQualifiedNames().get(0);
+                    	if (externs.contains(symbol)) continue;
+                    	
+                        final File outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0), outputFolder);
+
+                        System.out.println("Compiling file: " + outputClassFile);
+
+                        ICompilationUnit unit = cu;
+
+                        IASWriter writer;
+                        if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+                        {
+                            writer = JSSharedData.backend.createWriter(project,
+                                    (List<ICompilerProblem>) errors, unit,
+                                    false);
+                        }
+                        else
+                        {
+                            writer = JSSharedData.backend.createMXMLWriter(
+                                    project, (List<ICompilerProblem>) errors,
+                                    unit, false);
+                        }
+                        problems.addAll(errors);
+                        BufferedOutputStream out = new BufferedOutputStream(
+                                new FileOutputStream(outputClassFile));
+                        writer.writeTo(out);
+                        out.flush();
+                        out.close();
+                        writer.close();
+                    }
+                }
+
+                compilationSuccess = true;
+            }
+        }
+        catch (Exception e)
+        {
+            final ICompilerProblem problem = new InternalCompilerProblem(e);
+            problems.add(problem);
+        }
+
+        return compilationSuccess;
+    }
+
+    /**
+     * Build target artifact.
+     * 
+     * @throws InterruptedException threading error
+     * @throws IOException IO error
+     * @throws ConfigurationException
+     */
+    @Override
+    protected void buildArtifact() throws InterruptedException, IOException,
+            ConfigurationException
+    {
+        jsTarget = buildJSTarget();
+    }
+
+    private IJSApplication buildJSTarget() throws InterruptedException,
+            FileNotFoundException, ConfigurationException
+    {
+        final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
+
+        final IJSApplication app = buildApplication(project,
+                config.getMainDefinition(), null, problemsBuildingSWF);
+        problems.addAll(problemsBuildingSWF);
+        if (app == null)
+        {
+            ICompilerProblem problem = new UnableToBuildSWFProblem(
+                    getOutputFilePath());
+            problems.add(problem);
+        }
+
+        return app;
+    }
+
+    /**
+     * Replaces FlexApplicationProject::buildSWF()
+     * 
+     * @param applicationProject
+     * @param rootClassName
+     * @param problems
+     * @return
+     * @throws InterruptedException
+     */
+
+    private IJSApplication buildApplication(CompilerProject applicationProject,
+            String rootClassName, ICompilationUnit mainCU,
+            Collection<ICompilerProblem> problems) throws InterruptedException,
+            ConfigurationException, FileNotFoundException
+    {
+        Collection<ICompilerProblem> fatalProblems = applicationProject.getFatalProblems();
+        if (!fatalProblems.isEmpty())
+        {
+            problems.addAll(fatalProblems);
+            return null;
+        }
+
+        return ((JSTarget) target).build(mainCU, problems);
+    }
+
+    /**
+     * Get the output file path. If {@code -output} is specified, use its value;
+     * otherwise, use the same base name as the target file.
+     * 
+     * @return output file path
+     */
+    private String getOutputFilePath()
+    {
+        if (config.getOutput() == null)
+        {
+            final String extension = "." + JSSharedData.OUTPUT_EXTENSION;
+            return FilenameUtils.removeExtension(config.getTargetFile()).concat(
+                    extension);
+        }
+        else
+        {
+            String outputFolderName = config.getOutput();
+            if (outputFolderName.endsWith(".swc"))
+            {
+                File outputFolder = new File(outputFolderName);
+                outputFolderName = outputFolder.getParent();
+            }
+            return outputFolderName;
+        }
+    }
+
+    /**
+     * Get the output class file. This includes the (sub)directory in which the
+     * original class file lives. If the directory structure doesn't exist, it
+     * is created.
+     * 
+     * @author Erik de Bruin
+     * @param qname
+     * @param outputFolder
+     * @return output class file path
+     */
+    private File getOutputClassFile(String qname, File outputFolder)
+    {
+        String[] cname = qname.split("\\.");
+        String sdirPath = outputFolder + File.separator;
+        if (cname.length > 0)
+        {
+            for (int i = 0, n = cname.length - 1; i < n; i++)
+            {
+                sdirPath += cname[i] + File.separator;
+            }
+
+            File sdir = new File(sdirPath);
+            if (!sdir.exists())
+                sdir.mkdirs();
+
+            qname = cname[cname.length - 1];
+        }
+
+        return new File(sdirPath + qname + "." + JSSharedData.OUTPUT_EXTENSION);
+    }
+
+    /**
+     * Mxmlc uses target file as the main compilation unit and derive the output
+     * SWF file name from this file.
+     * 
+     * @return true if successful, false otherwise.
+     * @throws InterruptedException
+     */
+    @Override
+    protected boolean setupTargetFile() throws InterruptedException
+    {
+        config.getTargetFile();
+
+        ITargetSettings settings = getTargetSettings();
+        if (settings != null)
+            project.setTargetSettings(settings);
+        else
+            return false;
+
+        target = JSSharedData.backend.createTarget(project,
+                getTargetSettings(), null);
+
+        return true;
+    }
+
+    private ITargetSettings getTargetSettings()
+    {
+        if (targetSettings == null)
+            targetSettings = projectConfigurator.getTargetSettings(getTargetType());
+
+        if (targetSettings == null)
+            problems.addAll(projectConfigurator.getConfigurationProblems());
+
+        return targetSettings;
+    }
+
+    /**
+     * Validate target file.
+     * 
+     * @throws MustSpecifyTarget
+     * @throws IOError
+     */
+    @Override
+    protected void validateTargetFile() throws ConfigurationException
+    {
+
+    }
+
+    protected String getProgramName()
+    {
+        return "compc";
+    }
+
+    protected boolean isCompc()
+    {
+        return true;
+    }
+
+    @Override
+    protected TargetType getTargetType()
+    {
+        return TargetType.SWC;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
new file mode 100644
index 0000000..ed96162
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
@@ -0,0 +1,216 @@
+/*
+ *
+ *  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.clients;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.internal.codegen.externals.emit.ReferenceEmitter;
+import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+
+import com.google.javascript.jscomp.Result;
+import org.apache.flex.tools.FlexTool;
+
+/**
+ * @author Michael Schmalle
+ */
+public class EXTERNC implements FlexTool
+{
+    static enum ExitCode
+    {
+        SUCCESS(0),
+        PRINT_HELP(1),
+        FAILED_WITH_PROBLEMS(2),
+        FAILED_WITH_EXCEPTIONS(3),
+        FAILED_WITH_CONFIG_PROBLEMS(4);
+
+        ExitCode(int code)
+        {
+            this.code = code;
+        }
+
+        final int code;
+    }
+
+    protected Configurator projectConfigurator;
+    private ExternCConfiguration configuration;
+    private ReferenceModel model;
+    private ReferenceCompiler compiler;
+    private ReferenceEmitter emitter;
+
+    public ReferenceModel getModel()
+    {
+        return model;
+    }
+
+    public ReferenceCompiler getCompiler()
+    {
+        return compiler;
+    }
+
+    public ReferenceEmitter getEmitter()
+    {
+        return emitter;
+    }
+
+    public EXTERNC()
+    {
+    }
+
+    public EXTERNC(ExternCConfiguration configuration)
+    {
+        configure(configuration);
+    }
+
+    public void configure(String[] args)
+    {
+        projectConfigurator = createConfigurator();
+        projectConfigurator.setConfiguration(args, "external", false);
+        projectConfigurator.getTargetSettings(TargetType.SWC);
+        configure((ExternCConfiguration) projectConfigurator.getConfiguration());
+    }
+
+    public void configure(ExternCConfiguration configuration)
+    {
+        this.configuration = configuration;
+
+        model = new ReferenceModel(configuration);
+        compiler = new ReferenceCompiler(model);
+        emitter = new ReferenceEmitter(model);
+    }
+
+    /**
+     * Create a new Configurator. This method may be overridden to allow
+     * Configurator subclasses to be created that have custom configurations.
+     * 
+     * @return a new instance or subclass of {@link Configurator}.
+     */
+    protected Configurator createConfigurator()
+    {
+        return new Configurator(ExternCConfiguration.class);
+    }
+
+    /**
+     * Java program entry point.
+     * 
+     * @param args command line arguments
+     */
+    public static void main(final String[] args)
+    {
+        int exitCode = staticMainNoExit(args);
+        System.exit(exitCode);
+    }
+
+    /**
+     * Entry point for the <code>externc</code>.
+     *
+     * @param args Command line arguments.
+     * @return An exit code.
+     */
+    public static int staticMainNoExit(final String[] args)
+    {
+        long startTime = System.nanoTime();
+
+        final EXTERNC compiler = new EXTERNC();
+        compiler.configure(args);
+        final Set<ICompilerProblem> problems = new HashSet<ICompilerProblem>();
+        final int exitCode = compiler.mainNoExit(args, problems, true);
+
+        long endTime = System.nanoTime();
+        JSSharedData.instance.stdout((endTime - startTime) / 1e9 + " seconds");
+
+        return exitCode;
+    }
+
+    public int mainNoExit(final String[] args, Set<ICompilerProblem> problems,
+            Boolean printProblems)
+    {
+        int exitCode = -1;
+
+        try
+        {
+            cleanOutput();
+            compile();
+            emit();
+        }
+        catch (IOException e)
+        {
+            JSSharedData.instance.stderr(e.toString());
+        }
+        finally
+        {
+            if (problems != null && !problems.isEmpty())
+            {
+                if (printProblems)
+                {
+                }
+            }
+        }
+
+        return exitCode;
+    }
+
+    public void cleanOutput() throws IOException
+    {
+        FileUtils.deleteDirectory(configuration.getAsRoot());
+    }
+
+    public void emit() throws IOException
+    {
+        emitter.emit();
+    }
+
+    public Result compile() throws IOException
+    {
+        return compiler.compile();
+    }
+
+    @Override
+    public String getName() {
+        // TODO: Change this to a flex-tool-api constant ...
+        return "EXTERNC";
+    }
+
+    @Override
+    public int execute(String[] args) {
+        EXTERNC generator = new EXTERNC();
+        generator.configure(args);
+        try {
+            generator.cleanOutput();
+            /*Result result =*/ generator.compile();
+            // We ignore errors for now ... they seem to be normal.
+            /*if(result.errors.length > 0) {
+                return 1;
+            }*/
+            generator.emit();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+}


Mime
View raw message