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:40 UTC
[48/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/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
new file mode 100644
index 0000000..7eea457
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -0,0 +1,357 @@
+/*
+ *
+ * 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.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationValue;
+import org.apache.flex.compiler.exceptions.ConfigurationException.CannotOpen;
+import org.apache.flex.compiler.exceptions.ConfigurationException.IncorrectArgumentCount;
+import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler.ExternalFile;
+import org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.FieldReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
+import org.apache.flex.compiler.internal.config.annotations.Arguments;
+import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
+import org.apache.flex.compiler.internal.config.annotations.Mapping;
+import org.apache.flex.utils.FilenameNormalization;
+
+public class ExternCConfiguration extends Configuration
+{
+ private File jsRoot;
+
+ private File asRoot;
+
+ private File asClassRoot;
+ private File asInterfaceRoot;
+ private File asFunctionRoot;
+ private File asConstantRoot;
+ private File asTypeDefRoot;
+
+ private List<ExternalFile> externals = new ArrayList<ExternalFile>();
+ private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
+
+ private List<String> classToFunctions = new ArrayList<String>();
+ private List<ExcludedMember> excludesClass = new ArrayList<ExcludedMember>();
+ private List<ExcludedMember> excludesField = new ArrayList<ExcludedMember>();
+ private List<ExcludedMember> excludes = new ArrayList<ExcludedMember>();
+
+ public ExternCConfiguration()
+ {
+ }
+
+ public File getAsRoot()
+ {
+ return asRoot;
+ }
+
+ @Config
+ @Mapping("as-root")
+ public void setASRoot(ConfigurationValue cfgval, String filename) throws CannotOpen
+ {
+ setASRoot(new File(FilenameNormalization.normalize(getOutputPath(cfgval, filename))));
+ }
+
+ public void setASRoot(File file)
+ {
+ this.asRoot = file;
+
+ asClassRoot = new File(asRoot, "classes");
+ asInterfaceRoot = new File(asRoot, "interfaces");
+ asFunctionRoot = new File(asRoot, "functions");
+ asConstantRoot = new File(asRoot, "constants");
+ asTypeDefRoot = new File(asRoot, "typedefs");
+ }
+
+ public File getAsClassRoot()
+ {
+ return asClassRoot;
+ }
+
+ public File getAsInterfaceRoot()
+ {
+ return asInterfaceRoot;
+ }
+
+ public File getAsFunctionRoot()
+ {
+ return asFunctionRoot;
+ }
+
+ public File getAsConstantRoot()
+ {
+ return asConstantRoot;
+ }
+
+ public File getAsTypeDefRoot()
+ {
+ return asTypeDefRoot;
+ }
+
+ public Collection<ExternalFile> getExternals()
+ {
+ return externals;
+ }
+
+ public Collection<ExternalFile> getExternalExterns()
+ {
+ return externalExterns;
+ }
+
+ public boolean isClassToFunctions(String className)
+ {
+ return classToFunctions.contains(className);
+ }
+
+ public void addClassToFunction(String className)
+ {
+ classToFunctions.add(className);
+ }
+
+ public void addExternal(File file) throws IOException
+ {
+ if (!file.exists())
+ throw new IOException(file.getAbsolutePath() + " does not exist.");
+ externals.add(new ExternalFile(file));
+ }
+
+ public void addExternal(String externalFile) throws IOException
+ {
+ addExternal(new File(FilenameNormalization.normalize(externalFile)));
+ }
+
+ public void addExternalExtern(File file) throws IOException
+ {
+ if (!file.exists())
+ throw new IOException(file.getAbsolutePath() + " does not exist.");
+ externalExterns.add(new ExternalFile(file));
+ }
+
+ public void addExternalExtern(String externalFile) throws IOException
+ {
+ addExternalExtern(new File(FilenameNormalization.normalize(externalFile)));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("class-to-function")
+ @Arguments(Arguments.CLASS)
+ public void setClassToFunctions(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ addClassToFunction(values.get(0));
+ }
+
+ @Config(allowMultiple = true, isPath = true)
+ @Mapping("external")
+ @Arguments(Arguments.PATH_ELEMENT)
+ @InfiniteArguments
+ public void setExternal(ConfigurationValue cfgval, String[] vals) throws IOException, CannotOpen
+ {
+ for (String val : vals)
+ addExternal(resolvePathStrict(val, cfgval));
+ }
+
+ @Config(allowMultiple = true, isPath = true)
+ @Mapping("external-externs")
+ @Arguments(Arguments.PATH_ELEMENT)
+ @InfiniteArguments
+ public void setExternalExterns(ConfigurationValue cfgval, String[] vals) throws IOException, CannotOpen
+ {
+ for (String val : vals)
+ addExternalExtern(resolvePathStrict(val, cfgval));
+ }
+
+ public boolean isExternalExtern(BaseReference reference)
+ {
+ String sourceFileName = reference.getNode().getSourceFileName();
+ for (ExternalFile file : externalExterns)
+ {
+ if (sourceFileName.equals("[" + file.getName() + "]"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public ExcludedMember isExcludedClass(ClassReference classReference)
+ {
+ for (ExcludedMember memeber : excludesClass)
+ {
+ if (memeber.isExcluded(classReference, null))
+ return memeber;
+ }
+ return null;
+ }
+
+ public ExcludedMember isExcludedMember(ClassReference classReference,
+ MemberReference memberReference)
+ {
+ if (memberReference instanceof FieldReference)
+ {
+ for (ExcludedMember memeber : excludesField)
+ {
+ if (memeber.isExcluded(classReference, memberReference))
+ return memeber;
+ }
+ }
+ for (ExcludedMember memeber : excludes)
+ {
+ if (memeber.isExcluded(classReference, memberReference))
+ return memeber;
+ }
+ return null;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("exclude")
+ @Arguments({"class", "name"})
+ public void setExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ final int size = values.size();
+ if (size % 2 != 0)
+ throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+ for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+ {
+ final String className = values.get(nameIndex);
+ final String name = values.get(nameIndex + 1);
+ addExclude(className, name);
+ }
+ }
+
+ public void addExclude(String className, String name)
+ {
+ excludes.add(new ExcludedMember(className, name));
+ }
+
+ public void addExclude(String className, String name, String description)
+ {
+ excludes.add(new ExcludedMember(className, name, description));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("field-exclude")
+ @Arguments({"class", "field"})
+ public void setFieldExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ final int size = values.size();
+ if (size % 2 != 0)
+ throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+ for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+ {
+ final String className = values.get(nameIndex);
+ final String fieldName = values.get(nameIndex + 1);
+ addFieldExclude(className, fieldName);
+ }
+ }
+
+ public void addFieldExclude(String className, String fieldName)
+ {
+ excludesField.add(new ExcludedMember(className, fieldName, ""));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("class-exclude")
+ @Arguments("class")
+ public void setClassExcludes(ConfigurationValue cfgval, List<String> values)
+ {
+ for (String className : values)
+ addClassExclude(className);
+ }
+ public void addClassExclude(String className)
+ {
+ excludesClass.add(new ExcludedMember(className, null, ""));
+ }
+
+ public File getJsRoot()
+ {
+ return jsRoot;
+ }
+
+ @Config
+ @Mapping("js-root")
+ public void setJSRoot(ConfigurationValue cfgval, String filename) throws CannotOpen
+ {
+ this.jsRoot = new File(filename);
+ }
+
+
+ public static class ExcludedMember
+ {
+ private String className;
+ private String name;
+ private String description;
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public ExcludedMember(String className, String name)
+ {
+ this.className = className;
+ this.name = name;
+ }
+
+ public ExcludedMember(String className, String name, String description)
+ {
+ this.className = className;
+ this.name = name;
+ this.description = description;
+ }
+
+ public boolean isExcluded(ClassReference classReference,
+ MemberReference memberReference)
+ {
+ if (memberReference == null)
+ {
+ return classReference.getQualifiedName().equals(className);
+ }
+ return classReference.getQualifiedName().equals(className)
+ && memberReference.getQualifiedName().equals(name);
+ }
+
+ public void print(StringBuilder sb)
+ {
+ if (description != null)
+ sb.append("// " + description + "\n");
+ sb.append("//");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/FlexJSToolGroup.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/FlexJSToolGroup.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/FlexJSToolGroup.java
new file mode 100644
index 0000000..e99a5ab
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/FlexJSToolGroup.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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 org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
+import org.apache.flex.tools.AbstractFlexToolGroup;
+
+/**
+ * Created by christoferdutz on 10.11.14.
+ */
+public class FlexJSToolGroup extends AbstractFlexToolGroup {
+
+ public FlexJSToolGroup() {
+ super("FlexJS");
+ addFlexTool(new COMPJSC(new MXMLFlexJSBackend()));
+ addFlexTool(new MXMLJSC(new MXMLFlexJSBackend()));
+ addFlexTool(new EXTERNC());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
new file mode 100644
index 0000000..0ffa22e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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 org.apache.flex.compiler.problems.ICompilerProblem;
+
+import java.util.List;
+
+public interface JSCompilerEntryPoint {
+ public int mainNoExit(final String[] args, List<ICompilerProblem> problems,
+ Boolean printProblems);
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
new file mode 100644
index 0000000..3ce8665
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.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.clients;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationValue;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
+import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.Mapping;
+
+/**
+ * The {@link JSConfiguration} class holds all compiler arguments needed for
+ * compiling ActionScript to JavaScript.
+ * <p>
+ * Specific flags are implemented here for the configuration to be loaded by the
+ * configure() method of {@link MXMLJSC}.
+ * <p>
+ * This class inherits all compiler arguments from the MXMLC compiler.
+ *
+ * @author Michael Schmalle
+ */
+public class JSConfiguration extends Configuration
+{
+ public JSConfiguration()
+ {
+ }
+
+ //
+ // 'js-output-type'
+ //
+
+ private String jsOutputType = MXMLJSC.JSOutputType.FLEXJS.getText();
+
+ public String getJSOutputType()
+ {
+ return jsOutputType;
+ }
+
+ @Config
+ @Mapping("js-output-type")
+ public void setJSOutputType(ConfigurationValue cv, String value)
+ throws ConfigurationException
+ {
+ jsOutputType = value;
+ }
+
+ //
+ // 'source-map'
+ //
+
+ private boolean sourceMap = false;
+
+ public boolean getSourceMap()
+ {
+ return sourceMap;
+ }
+
+ @Config
+ @Mapping("source-map")
+ public void setSourceMap(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ sourceMap = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
new file mode 100644
index 0000000..d324c9f
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -0,0 +1,847 @@
+/*
+ *
+ * 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.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.flex.compiler.clients.problems.ProblemPrinter;
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.clients.problems.ProblemQueryProvider;
+import org.apache.flex.compiler.clients.problems.WorkspaceProblemFormatter;
+import org.apache.flex.compiler.codegen.js.IJSPublisher;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationBuffer;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.config.ICompilerSettingsConstants;
+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.exceptions.ConfigurationException.OnlyOneSource;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.config.FlashBuilderConfigurator;
+import org.apache.flex.compiler.internal.driver.as.ASBackend;
+import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
+import org.apache.flex.compiler.internal.driver.js.node.NodeBackend;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
+import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.units.ResourceModuleCompilationUnit;
+import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
+import org.apache.flex.compiler.internal.workspaces.Workspace;
+import org.apache.flex.compiler.problems.ConfigurationProblem;
+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.problems.UnexpectedExceptionProblem;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.targets.ITarget;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.tools.FlexTool;
+import org.apache.flex.utils.ArgumentUtil;
+import org.apache.flex.utils.FilenameNormalization;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Erik de Bruin
+ * @author Michael Schmalle
+ */
+public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
+ FlexTool
+{
+ @Override
+ public ProblemQuery getProblemQuery()
+ {
+ return problems;
+ }
+
+ /*
+ * JS output type enumerations.
+ */
+ public enum JSOutputType
+ {
+ AMD("amd"),
+ FLEXJS("flexjs"),
+ GOOG("goog"),
+ VF2JS("vf2js"),
+ FLEXJS_DUAL("flexjs_dual"),
+ JSC("jsc"),
+ NODE("node");
+
+ private String text;
+
+ JSOutputType(String text)
+ {
+ this.text = text;
+ }
+
+ public String getText()
+ {
+ return this.text;
+ }
+
+ public static JSOutputType fromString(String text)
+ {
+ for (JSOutputType jsOutputType : JSOutputType.values())
+ {
+ if (text.equalsIgnoreCase(jsOutputType.text))
+ return jsOutputType;
+ }
+ return GOOG;
+ }
+ }
+
+ /*
+ * Exit code enumerations.
+ */
+ static enum ExitCode
+ {
+ SUCCESS(0),
+ PRINT_HELP(1),
+ FAILED_WITH_PROBLEMS(2),
+ FAILED_WITH_ERRORS(3),
+ FAILED_WITH_EXCEPTIONS(4),
+ FAILED_WITH_CONFIG_PROBLEMS(5);
+
+ ExitCode(int code)
+ {
+ this.code = code;
+ }
+
+ final int code;
+ }
+
+ public static JSOutputType jsOutputType;
+ public static boolean keepASDoc;
+
+ @Override
+ public String getName()
+ {
+ return FLEX_TOOL_MXMLC;
+ }
+
+ @Override
+ public int execute(String[] args)
+ {
+ final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+ return mainNoExit(args, problems, true);
+ }
+
+ /**
+ * 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();
+ String jsOutputTypeString = "";
+ for (String s : args)
+ {
+ String[] kvp = s.split("=");
+
+ if (s.contains("-js-output-type"))
+ {
+ jsOutputTypeString = kvp[1];
+ }
+ }
+
+ if (jsOutputTypeString.equals(""))
+ {
+ jsOutputTypeString = JSOutputType.FLEXJS.getText();
+ }
+
+ jsOutputType = JSOutputType.fromString(jsOutputTypeString);
+ switch (jsOutputType)
+ {
+ case AMD:
+ backend = new AMDBackend();
+ break;
+ case JSC:
+ backend = new JSCBackend();
+ break;
+ case NODE:
+ backend = new NodeBackend();
+ break;
+ case FLEXJS:
+ case FLEXJS_DUAL:
+ backend = new MXMLFlexJSBackend();
+ break;
+ case GOOG:
+ backend = new GoogBackend();
+ break;
+ case VF2JS:
+ backend = new MXMLVF2JSBackend();
+ break;
+ // if you add a new js-output-type here, don't forget to also add it
+ // to flex2.tools.MxmlJSC in flex-compiler-oem for IDE support
+ }
+
+ final MXMLJSC mxmlc = new MXMLJSC(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;
+ }
+
+ protected Workspace workspace;
+ protected FlexJSProject project;
+
+ protected ProblemQuery problems;
+ protected ISourceFileHandler asFileHandler;
+ protected Configuration config;
+ protected Configurator projectConfigurator;
+ private ConfigurationBuffer configBuffer;
+ private ICompilationUnit mainCU;
+ protected ITarget target;
+ protected ITargetSettings targetSettings;
+ protected IJSApplication jsTarget;
+ private IJSPublisher jsPublisher;
+
+ public MXMLJSC(IBackend backend)
+ {
+ JSSharedData.backend = backend;
+ workspace = new Workspace();
+ workspace.setASDocDelegate(new FlexJSASDocDelegate());
+ project = new FlexJSProject(workspace);
+ problems = new ProblemQuery(); // this gets replaced in configure(). Do we need it here?
+ JSSharedData.OUTPUT_EXTENSION = backend.getOutputExtension();
+ JSSharedData.workspace = workspace;
+ asFileHandler = backend.getSourceFileHandlerInstance();
+ }
+
+ @Override
+ public int mainNoExit(final String[] args, List<ICompilerProblem> problems,
+ Boolean printProblems)
+ {
+ int exitCode = -1;
+ try
+ {
+ exitCode = _mainNoExit(ArgumentUtil.fixArgs(args), problems);
+ }
+ catch (Exception e)
+ {
+ JSSharedData.instance.stderr(e.toString());
+ }
+ finally
+ {
+ if (problems != null && !problems.isEmpty())
+ {
+ if (printProblems)
+ {
+ final WorkspaceProblemFormatter formatter = new WorkspaceProblemFormatter(
+ workspace);
+ final ProblemPrinter printer = new ProblemPrinter(formatter);
+ printer.printProblems(problems);
+ }
+ }
+ }
+ return exitCode;
+ }
+
+ /**
+ * Entry point that doesn't call <code>System.exit()</code>. This is for
+ * unit testing.
+ *
+ * @param args command line arguments
+ * @return exit code
+ */
+ private int _mainNoExit(final String[] args,
+ List<ICompilerProblem> outProblems)
+ {
+ ExitCode exitCode = ExitCode.SUCCESS;
+ try
+ {
+ String[] adjustedArgs = args;
+
+ if (jsOutputType != null)
+ {
+ switch (jsOutputType)
+ {
+ case VF2JS:
+ boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
+
+ if (isFlashBuilderProject)
+ {
+ adjustedArgs = FlashBuilderConfigurator.computeFlashBuilderArgs(
+ adjustedArgs, getTargetType().getExtension());
+ }
+
+ //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
+ //
+ //String newProjectFilePath = VF2JSProjectUtils
+ // .createTempProject(projectFilePath,
+ // isFlashBuilderProject);
+ //
+ //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ final boolean continueCompilation = configure(adjustedArgs);
+
+ // ToDo (erikdebruin): use JSSharedData for globals ...
+ keepASDoc = ((JSGoogConfiguration) config).getKeepASDoc();
+
+ if (outProblems != null && !config.isVerbose())
+ JSSharedData.STDOUT = JSSharedData.STDERR = null;
+
+ if (continueCompilation)
+ {
+ project.setProblems(problems.getProblems());
+ compile();
+ if (problems.hasFilteredProblems())
+ {
+ if (problems.hasErrors())
+ exitCode = ExitCode.FAILED_WITH_ERRORS;
+ else
+ exitCode = ExitCode.FAILED_WITH_PROBLEMS;
+ }
+ }
+ else if (problems.hasFilteredProblems())
+ {
+ exitCode = ExitCode.FAILED_WITH_CONFIG_PROBLEMS;
+ }
+ else
+ {
+ exitCode = ExitCode.PRINT_HELP;
+ }
+ }
+ catch (Exception e)
+ {
+ if (outProblems == null)
+ JSSharedData.instance.stderr(e.getMessage());
+ else
+ {
+ final ICompilerProblem unexpectedExceptionProblem = new UnexpectedExceptionProblem(
+ e);
+ problems.add(unexpectedExceptionProblem);
+ }
+ exitCode = ExitCode.FAILED_WITH_EXCEPTIONS;
+ }
+ finally
+ {
+ waitAndClose();
+
+ if (outProblems != null && problems.hasFilteredProblems())
+ {
+ for (ICompilerProblem problem : problems.getFilteredProblems())
+ {
+ outProblems.add(problem);
+ }
+ }
+ }
+ return exitCode.code;
+ }
+
+ /**
+ * 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
+ */
+ protected boolean compile()
+ {
+ boolean compilationSuccess = false;
+
+ try
+ {
+ project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
+
+ if (!setupTargetFile())
+ return false;
+
+ buildArtifact();
+
+ if (jsTarget != null)
+ {
+ List<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
+ List<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
+
+ if (!config.getCreateTargetWithErrors())
+ {
+ problems.getErrorsAndWarnings(errors, warnings);
+ if (errors.size() > 0)
+ return false;
+ }
+
+ jsPublisher = (IJSPublisher) JSSharedData.backend.createPublisher(
+ project, errors, config);
+
+ File outputFolder = jsPublisher.getOutputFolder();
+
+ ArrayList<ICompilationUnit> roots = new ArrayList<ICompilationUnit>();
+ roots.add(mainCU);
+ Set<ICompilationUnit> incs = target.getIncludesCompilationUnits();
+ roots.addAll(incs);
+ List<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)
+ {
+ final File outputClassFile = getOutputClassFile(
+ cu.getQualifiedNames().get(0), outputFolder);
+
+ System.out.println("Compiling file: " + outputClassFile);
+
+ ICompilationUnit unit = cu;
+
+ IJSWriter writer;
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+ {
+ writer = (IJSWriter) JSSharedData.backend.createWriter(project,
+ errors, unit, false);
+ }
+ else
+ {
+ writer = (IJSWriter) JSSharedData.backend.createMXMLWriter(
+ project, errors, unit, false);
+ }
+
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(outputClassFile));
+
+ File outputSourceMapFile = null;
+ if (project.config.getSourceMap())
+ {
+ outputSourceMapFile = getOutputSourceMapFile(
+ cu.getQualifiedNames().get(0), outputFolder);
+ }
+
+ writer.writeTo(out, outputSourceMapFile);
+ out.flush();
+ out.close();
+ writer.close();
+ }
+ }
+
+ if (jsPublisher != null)
+ {
+ compilationSuccess = jsPublisher.publish(problems);
+ }
+ else
+ {
+ 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
+ */
+ protected void buildArtifact() throws InterruptedException, IOException,
+ ConfigurationException
+ {
+ jsTarget = buildJSTarget();
+ }
+
+ private IJSApplication buildJSTarget() throws InterruptedException,
+ FileNotFoundException, ConfigurationException
+ {
+ final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
+
+ project.mainCU = mainCU;
+ final IJSApplication app = buildApplication(project,
+ config.getMainDefinition(), mainCU, 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
+ return config.getOutput();
+ }
+
+ /**
+ * @author Erik de Bruin
+ *
+ * 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.
+ *
+ * @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);
+ }
+
+ /**
+ * @param qname
+ * @param outputFolder
+ * @return output source map file path
+ */
+ private File getOutputSourceMapFile(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 + ".map");
+ }
+
+ /**
+ * 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 OnlyOneSource
+ * @throws InterruptedException
+ */
+ protected boolean setupTargetFile() throws InterruptedException
+ {
+ final String mainFileName = config.getTargetFile();
+
+ final String normalizedMainFileName = FilenameNormalization.normalize(mainFileName);
+
+ final SourceCompilationUnitFactory compilationUnitFactory = project.getSourceCompilationUnitFactory();
+
+ File normalizedMainFile = new File(normalizedMainFileName);
+ if (compilationUnitFactory.canCreateCompilationUnit(normalizedMainFile))
+ {
+ project.addIncludeSourceFile(normalizedMainFile);
+
+ final List<String> sourcePath = config.getCompilerSourcePath();
+ String mainQName = null;
+ if (sourcePath != null && !sourcePath.isEmpty())
+ {
+ for (String path : sourcePath)
+ {
+ final String otherPath = new File(path).getAbsolutePath();
+ if (mainFileName.startsWith(otherPath))
+ {
+ mainQName = mainFileName.substring(otherPath.length() + 1);
+ mainQName = mainQName.replaceAll("\\\\", "/");
+ mainQName = mainQName.replaceAll("\\/", ".");
+ if (mainQName.endsWith(".as"))
+ mainQName = mainQName.substring(0,
+ mainQName.length() - 3);
+ break;
+ }
+ }
+ }
+
+ if (mainQName == null)
+ mainQName = FilenameUtils.getBaseName(mainFileName);
+
+ Collection<ICompilationUnit> mainFileCompilationUnits = workspace.getCompilationUnits(
+ normalizedMainFileName, project);
+
+ mainCU = Iterables.getOnlyElement(mainFileCompilationUnits);
+
+ config.setMainDefinition(mainQName);
+ }
+
+ Preconditions.checkNotNull(mainCU,
+ "Main compilation unit can't be null");
+
+ ITargetSettings settings = getTargetSettings();
+ if (settings != null)
+ project.setTargetSettings(settings);
+
+ target = JSSharedData.backend.createTarget(project,
+ getTargetSettings(), null);
+
+ return true;
+ }
+
+ private ITargetSettings getTargetSettings()
+ {
+ if (targetSettings == null)
+ targetSettings = projectConfigurator.getTargetSettings(null);
+
+ return targetSettings;
+ }
+
+ /**
+ * 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 JSSharedData.backend.createConfigurator();
+ }
+
+ /**
+ * Load configurations from all the sources.
+ *
+ * @param args command line arguments
+ * @return True if mxmlc should continue with compilation.
+ */
+ protected boolean configure(final String[] args)
+ {
+ project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
+ projectConfigurator = createConfigurator();
+
+ try
+ {
+ if (useFlashBuilderProjectFiles(args)
+ && !jsOutputType.equals(JSOutputType.VF2JS))
+ {
+ projectConfigurator.setConfiguration(
+ FlashBuilderConfigurator.computeFlashBuilderArgs(args,
+ getTargetType().getExtension()),
+ ICompilerSettingsConstants.FILE_SPECS_VAR);
+ }
+ else
+ {
+ projectConfigurator.setConfiguration(args,
+ ICompilerSettingsConstants.FILE_SPECS_VAR);
+ }
+
+ projectConfigurator.applyToProject(project);
+ problems = new ProblemQuery(
+ projectConfigurator.getCompilerProblemSettings());
+
+ project.config = (JSGoogConfiguration)projectConfigurator.getConfiguration();
+ config = projectConfigurator.getConfiguration();
+ configBuffer = projectConfigurator.getConfigurationBuffer();
+ problems.addAll(projectConfigurator.getConfigurationProblems());
+
+ if (configBuffer.getVar("version") != null) //$NON-NLS-1$
+ return false;
+
+ if (problems.hasErrors())
+ return false;
+
+ validateTargetFile();
+ return true;
+ }
+ catch (ConfigurationException e)
+ {
+ final ICompilerProblem problem = new ConfigurationProblem(e);
+ problems.add(problem);
+ return false;
+ }
+ catch (Exception e)
+ {
+ final ICompilerProblem problem = new ConfigurationProblem(null, -1,
+ -1, -1, -1, e.getMessage());
+ problems.add(problem);
+ return false;
+ }
+ finally
+ {
+ if (config == null)
+ {
+ config = new Configuration();
+ configBuffer = new ConfigurationBuffer(Configuration.class,
+ Configuration.getAliases());
+ }
+ }
+ }
+
+ private boolean useFlashBuilderProjectFiles(String[] args)
+ {
+ for (String arg : args)
+ {
+ if (arg.equals("-fb")
+ || arg.equals("-use-flashbuilder-project-files"))
+ return true;
+ }
+ return false;
+ }
+
+ protected TargetType getTargetType()
+ {
+ return TargetType.SWF;
+ }
+
+ /**
+ * Validate target file.
+ *
+ * @throws MustSpecifyTarget
+ * @throws IOError
+ */
+ protected void validateTargetFile() throws ConfigurationException
+ {
+ if (mainCU instanceof ResourceModuleCompilationUnit)
+ return; //when compiling a Resource Module, no target file is defined.
+
+ final String targetFile = config.getTargetFile();
+ if (targetFile == null)
+ throw new ConfigurationException.MustSpecifyTarget(null, null, -1);
+
+ final File file = new File(targetFile);
+ if (!file.exists())
+ throw new ConfigurationException.IOError(targetFile);
+ }
+
+ /**
+ * Wait till the workspace to finish compilation and close.
+ */
+ protected void waitAndClose()
+ {
+ workspace.startIdleState();
+ try
+ {
+ workspace.close();
+ }
+ finally
+ {
+ workspace.endIdleState(Collections.<ICompilerProject, Set<ICompilationUnit>> emptyMap());
+ }
+ }
+
+ /**
+ * Force terminate the compilation process.
+ */
+ protected void close()
+ {
+ workspace.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/clients/VF2JSToolGroup.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/VF2JSToolGroup.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/VF2JSToolGroup.java
new file mode 100644
index 0000000..07cb796
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/VF2JSToolGroup.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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 org.apache.flex.tools.AbstractFlexToolGroup;
+
+/**
+ * Created by christoferdutz on 10.11.14.
+ */
+public class VF2JSToolGroup extends AbstractFlexToolGroup {
+
+ public VF2JSToolGroup() {
+ super("VF2JS");
+// addFlexTool(new COMPJSC(new MXMLVF2JSBackend()));
+// addFlexTool(new MXMLJSC(new MXMLVF2JSBackend()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IASGlobalFunctionConstants.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IASGlobalFunctionConstants.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IASGlobalFunctionConstants.java
new file mode 100644
index 0000000..6d0106e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IASGlobalFunctionConstants.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen;
+
+/**
+ * AS3 language global functions, such as Array, encodeURI, isNaN etc.
+ *
+ * @author Erik de Bruin
+ */
+public interface IASGlobalFunctionConstants
+{
+ static final String Array = "Array";
+ static final String Boolean = "Boolean";
+ static final String decodeURI = "decodeURI";
+ static final String decodeURIComponent = "decodeURIComponent";
+ static final String encodeURI = "encodeURI";
+ static final String encodeURIComponent = "encodeURIComponent";
+ static final String escape = "escape";
+ static final String _int = "int";
+ static final String isFinite = "isFinite";
+ static final String isNaN = "isNaN";
+ static final String isXMLName = "isXMLName";
+ static final String Number = "Number";
+ static final String Object = "Object";
+ static final String parseFloat = "parseFloat";
+ static final String parseInt = "parseInt";
+ static final String String = "String";
+ static final String trace = "trace";
+ static final String uint = "uint";
+ static final String unescape = "unescape";
+ static final String Vector = "Vector";
+ static final String XML = "XML";
+ static final String XMLList = "XMLList";
+
+ /**
+ * An enumeration of core built-in functions.
+ */
+ public static enum BuiltinType
+ {
+ ARRAY(IASGlobalFunctionConstants.Array), BOOLEAN(
+ IASGlobalFunctionConstants.Boolean), DECODEURI(
+ IASGlobalFunctionConstants.decodeURI), DECODEURICOMPONENT(
+ IASGlobalFunctionConstants.decodeURIComponent), ENCODEURI(
+ IASGlobalFunctionConstants.encodeURI), ENCODEURICOMPONENT(
+ IASGlobalFunctionConstants.encodeURIComponent), ESCAPE(
+ IASGlobalFunctionConstants.escape), INT(
+ IASGlobalFunctionConstants._int), ISFINITE(
+ IASGlobalFunctionConstants.isFinite), ISNAN(
+ IASGlobalFunctionConstants.isNaN), ISXMLNAME(
+ IASGlobalFunctionConstants.isXMLName), NUMBER(
+ IASGlobalFunctionConstants.Number), OBJECT(
+ IASGlobalFunctionConstants.Object), PARSEFLOAT(
+ IASGlobalFunctionConstants.parseFloat), PARSEINT(
+ IASGlobalFunctionConstants.parseInt), STRING(
+ IASGlobalFunctionConstants.String), TRACE(
+ IASGlobalFunctionConstants.trace), UINT(
+ IASGlobalFunctionConstants.uint), UNESCAPE(
+ IASGlobalFunctionConstants.unescape), VECTOR(
+ IASGlobalFunctionConstants.Vector), XML(
+ IASGlobalFunctionConstants.XML), XMLLIST(
+ IASGlobalFunctionConstants.XMLList);
+
+ private BuiltinType(String name)
+ {
+ this.name = name;
+ }
+
+ private final String name;
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IDocEmitter.java
new file mode 100644
index 0000000..f71ae5e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IDocEmitter.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen;
+
+/**
+ * Base interface for documentation emitters.
+ *
+ * @author Michael Schmalle
+ */
+public interface IDocEmitter
+{
+ void begin();
+
+ String flushBuffer();
+
+ void setBufferWrite(boolean value);
+
+ void end();
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitter.java
new file mode 100644
index 0000000..5e2e596
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitter.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen;
+
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.tree.as.IASNode;
+
+/**
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public interface IEmitter
+{
+
+ /**
+ * Pushes an indent into the emitter so after newlines are emitted, the
+ * output is correctly formatted.
+ */
+ void indentPush();
+
+ /**
+ * Pops an indent from the emitter so after newlines are emitted, the output
+ * is correctly formatted.
+ */
+ void indentPop();
+
+ /**
+ * Writes a string to the writer.
+ *
+ * @param value The string to write to the output buffer.
+ */
+ void write(IEmitterTokens value);
+
+ void write(String value);
+
+ /**
+ * Writes newline character(s)
+ */
+ void writeNewline();
+
+ /**
+ * Writes the <code>value</code> and then a newline which will automatically
+ * have the indent applied after the \n character.
+ *
+ * @param value The String value to write before the \n is appended.
+ */
+ void writeNewline(IEmitterTokens value);
+
+ void writeNewline(String value);
+
+ /**
+ * Writes the <code>value</code> after a push or pop of the indent.
+ * <p>
+ * This method effectively lets you write a value and then indent our
+ * outdent. The method can be useful in the following where your cursor
+ * writer is at <code>[0]</code>, you write
+ * <code>writeNewline("if (foo) {", true);</code> and the cursor after the
+ * call will end up at <code>[1]</code>.
+ *
+ * <pre>
+ * [0]if (foo) {
+ * [1]this.something;
+ * }
+ * </pre>
+ *
+ * @param value The String value to write before the \n is appended.
+ * @param pushIndent Whether to push indent <code>true</code> or pop indent
+ * <code>false</code>.
+ */
+ void writeNewline(IEmitterTokens value, boolean pushIndent);
+
+ void writeNewline(String value, boolean pushIndent);
+
+ /**
+ * Writes a {@link ASEmitterTokens} character to the buffer and appends a
+ * space after automatically.
+ *
+ * @param value The {@link ASEmitterTokens} value.
+ */
+ void writeToken(IEmitterTokens value);
+
+ void writeToken(String value);
+
+ /**
+ * Takes the node argument and created a String representation if it using
+ * the buffer temporarily.
+ * <p>
+ * Note; This method is still beta, it need more logic if an emitter is
+ * actually using the buffer!
+ *
+ * @param node The node walk and create a String for.
+ * @return The node's output.
+ */
+ String stringifyNode(IASNode node);
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitterTokens.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitterTokens.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitterTokens.java
new file mode 100644
index 0000000..09be781
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/IEmitterTokens.java
@@ -0,0 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.flex.compiler.codegen;
+
+public interface IEmitterTokens
+{
+ String getToken();
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISourceMapEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISourceMapEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISourceMapEmitter.java
new file mode 100644
index 0000000..3fef28e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISourceMapEmitter.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen;
+
+/**
+ * Base interface for source map emitters.
+ *
+ * @author Josh Tynjala
+ */
+public interface ISourceMapEmitter
+{
+ String emitSourceMap(String sourceFilePath, String sourceMapPath, String sourceRoot);
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISubEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISubEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISubEmitter.java
new file mode 100644
index 0000000..1431c4b
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/ISubEmitter.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen;
+
+import org.apache.flex.compiler.tree.as.IASNode;
+
+/**
+ * The {@link IEmitter} emitter can use composition for it's more
+ * complicated production sequences with member, dynamic, binary expressions and
+ * identifiers etc.
+ *
+ * @author Michael Schmalle
+ */
+public interface ISubEmitter<T>
+{
+ /**
+ * The main emitter will call this method of the sub emitter with the
+ * correct generic type implemented.
+ * <p>
+ * The main idea here is abstraction. Producing JavaScript can get
+ * complicated, the best way to avoid bugs is to avoid as much state and
+ * interdependence between emit() calls of the main emitter.
+ *
+ * @param node The current {@link IASNode} being emitted by the
+ * {@link IEmitter}.
+ */
+ void emit(T node);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASEmitter.java
new file mode 100644
index 0000000..bd0d1eb
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASEmitter.java
@@ -0,0 +1,369 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen.as;
+
+import java.io.Writer;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.IEmitter;
+import org.apache.flex.compiler.definitions.IPackageDefinition;
+import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IBlockNode;
+import org.apache.flex.compiler.tree.as.ICatchNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IDynamicAccessNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IFunctionCallNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IFunctionObjectNode;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IIdentifierNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.IImportNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.apache.flex.compiler.tree.as.IIterationFlowNode;
+import org.apache.flex.compiler.tree.as.IKeywordNode;
+import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.flex.compiler.tree.as.ILiteralContainerNode;
+import org.apache.flex.compiler.tree.as.ILiteralNode;
+import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
+import org.apache.flex.compiler.tree.as.INamespaceAccessExpressionNode;
+import org.apache.flex.compiler.tree.as.INamespaceNode;
+import org.apache.flex.compiler.tree.as.INumericLiteralNode;
+import org.apache.flex.compiler.tree.as.IObjectLiteralValuePairNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+import org.apache.flex.compiler.tree.as.IReturnNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.ISwitchNode;
+import org.apache.flex.compiler.tree.as.ITernaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IThrowNode;
+import org.apache.flex.compiler.tree.as.ITryNode;
+import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
+import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IUseNamespaceNode;
+import org.apache.flex.compiler.tree.as.IVariableExpressionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.as.IWhileLoopNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
+import org.apache.flex.compiler.tree.metadata.IMetaTagNode;
+import org.apache.flex.compiler.visitor.IASNodeStrategy;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+
+/**
+ * The {@link IASEmitter} interface allows abstraction between the
+ * {@link IASNodeStrategy} and the current output buffer {@link Writer}.
+ *
+ * @author Michael Schmalle
+ */
+public interface IASEmitter extends IEmitter
+{
+ IBlockWalker getWalker();
+
+ void setWalker(IBlockWalker asBlockWalker);
+
+ IDocEmitter getDocEmitter();
+
+ void setDocEmitter(IDocEmitter value);
+
+ String postProcess(String output);
+
+ void emitImport(IImportNode node);
+
+ void emitPackageHeader(IPackageDefinition definition);
+
+ void emitPackageHeaderContents(IPackageDefinition definition);
+
+ void emitPackageContents(IPackageDefinition definition);
+
+ void emitPackageFooter(IPackageDefinition definition);
+
+ /**
+ * Emit a Class.
+ *
+ * @param node The {@link IClassNode} class.
+ */
+ void emitClass(IClassNode node);
+
+ /**
+ * Emit an Interface.
+ *
+ * @param node The {@link IInterfaceNode} class.
+ */
+ void emitInterface(IInterfaceNode node);
+
+ /**
+ * Emit a documentation comment for a Class field or constant
+ * {@link IVariableNode}.
+ *
+ * @param node The {@link IVariableNode} class field member.
+ */
+ void emitFieldDocumentation(IVariableNode node);
+
+ /**
+ * Emit a full Class field member.
+ *
+ * @param node The {@link IVariableNode} class field member.
+ */
+ void emitField(IVariableNode node);
+
+ /**
+ * Emit a documentation comment for a Class method {@link IFunctionNode}.
+ *
+ * @param node The {@link IFunctionNode} class method member.
+ */
+ void emitMethodDocumentation(IFunctionNode node);
+
+ /**
+ * Emit a full Class or Interface method member.
+ *
+ * @param node The {@link IFunctionNode} class method member.
+ */
+ void emitMethod(IFunctionNode node);
+
+ /**
+ * Emit a documentation comment for a Class method {@link IGetterNode}.
+ *
+ * @param node The {@link IGetterNode} class accessor member.
+ */
+ void emitGetAccessorDocumentation(IGetterNode node);
+
+ /**
+ * Emit a full Class getter member.
+ *
+ * @param node The {@link IVariableNode} class getter member.
+ */
+ void emitGetAccessor(IGetterNode node);
+
+ /**
+ * Emit a documentation comment for a Class accessor {@link IGetterNode}.
+ *
+ * @param node The {@link ISetterNode} class accessor member.
+ */
+ void emitSetAccessorDocumentation(ISetterNode node);
+
+ /**
+ * Emit a full Class setter member.
+ *
+ * @param node The {@link ISetterNode} class setter member.
+ */
+ void emitSetAccessor(ISetterNode node);
+
+ void emitParameter(IParameterNode node);
+
+ /**
+ * Emit a namespace member.
+ *
+ * @param node The {@link INamespaceNode} class member.
+ */
+ void emitNamespace(INamespaceNode node);
+
+ //--------------------------------------------------------------------------
+ // Statements
+ //--------------------------------------------------------------------------
+
+ /**
+ * Emit a statement found within an {@link IBlockNode}.
+ *
+ * @param node The {@link IASNode} statement.
+ */
+ void emitStatement(IASNode node);
+
+ /**
+ * Emit a <code>if(){}else if(){}else{}</code> statement.
+ *
+ * @param node The {@link IIfNode} node.
+ */
+ void emitIf(IIfNode node);
+
+ /**
+ * Emit a <code>for each</code> statement.
+ *
+ * @param node The {@link IForLoopNode} node.
+ */
+ void emitForEachLoop(IForLoopNode node);
+
+ /**
+ * Emit a <code>for</code> statement.
+ *
+ * @param node The {@link IForLoopNode} node.
+ */
+ void emitForLoop(IForLoopNode node);
+
+ /**
+ * Emit a <code>switch(){}</code> statement.
+ *
+ * @param node The {@link ISwitchNode} node.
+ */
+ void emitSwitch(ISwitchNode node);
+
+ /**
+ * Emit a <code>while(){}</code> statement.
+ *
+ * @param node The {@link IWhileLoopNode} node.
+ */
+ void emitWhileLoop(IWhileLoopNode node);
+
+ /**
+ * Emit a <code>do{}while()</code> statement.
+ *
+ * @param node The {@link IWhileLoopNode} node.
+ */
+ void emitDoLoop(IWhileLoopNode node);
+
+ /**
+ * Emit a <code>with(){}</code> statement.
+ *
+ * @param node The {@link IWithNode} node.
+ */
+ void emitWith(IWithNode node);
+
+ /**
+ * Emit a <code>throw</code> statement.
+ *
+ * @param node The {@link IThrowNode} node.
+ */
+ void emitThrow(IThrowNode node);
+
+ /**
+ * Emit a <code>try{}</code> statement.
+ *
+ * @param node The {@link ITryNode} node.
+ */
+ void emitTry(ITryNode node);
+
+ /**
+ * Emit a <code>catch(){}</code> statement.
+ *
+ * @param node The {@link ICatchNode} node.
+ */
+ void emitCatch(ICatchNode node);
+
+ /**
+ * Emit a <code>foo:{}</code> statement.
+ *
+ * @param node The {@link LabeledStatementNode} node.
+ */
+ void emitLabelStatement(LabeledStatementNode node);
+
+ void emitReturn(IReturnNode node);
+
+ //--------------------------------------------------------------------------
+ // Expressions
+ //--------------------------------------------------------------------------
+
+ /**
+ * Emit a variable declaration found in expression statements within scoped
+ * blocks.
+ *
+ * @param node The {@link IVariableNode} or chain of variable nodes.
+ */
+ void emitVarDeclaration(IVariableNode node);
+
+ /**
+ * Emit an anonymous {@link IFunctionObjectNode}.
+ *
+ * @param node The anonymous {@link IFunctionObjectNode}.
+ */
+ void emitFunctionObject(IFunctionObjectNode node);
+
+ /**
+ * Emit an local named function {@link IFunctionNode}.
+ *
+ * @param node The local named function {@link IFunctionNode}.
+ */
+ void emitLocalNamedFunction(IFunctionNode node);
+
+ /**
+ * Emit a header at the start of a function block.
+ *
+ * @param node The {@link IFunctionNode} node.
+ */
+ void emitFunctionBlockHeader(IFunctionNode node);
+
+ /**
+ * Emit a function call like <code>new Foo()</code> or <code>foo(42)</code>.
+ *
+ * @param node The {@link IFunctionCallNode} node.
+ */
+ void emitFunctionCall(IFunctionCallNode node);
+
+ void emitArguments(IContainerNode node);
+
+ void emitIterationFlow(IIterationFlowNode node);
+
+ void emitNamespaceAccessExpression(INamespaceAccessExpressionNode node);
+
+ void emitMemberAccessExpression(IMemberAccessExpressionNode node);
+
+ void emitVariableExpression(IVariableExpressionNode node);
+
+ void emitDynamicAccess(IDynamicAccessNode node);
+
+ void emitTypedExpression(ITypedExpressionNode node);
+
+ void emitObjectLiteralValuePair(IObjectLiteralValuePairNode node);
+
+ void emitIdentifier(IIdentifierNode node);
+
+ void emitLiteral(ILiteralNode node);
+
+ void emitLiteralContainer(ILiteralContainerNode node);
+
+ void emitNumericLiteral(INumericLiteralNode node);
+
+ //--------------------------------------------------------------------------
+ // Operators
+ //--------------------------------------------------------------------------
+
+ void emitUnaryOperator(IUnaryOperatorNode node);
+
+ void emitAsOperator(IBinaryOperatorNode node);
+
+ void emitIsOperator(IBinaryOperatorNode node);
+
+ /**
+ * Emit an operator statement.
+ *
+ * @param node The {@link IBinaryOperatorNode} or chain of variable nodes.
+ */
+ void emitBinaryOperator(IBinaryOperatorNode node);
+
+ void emitTernaryOperator(ITernaryOperatorNode node);
+
+ //--------------------------------------------------------------------------
+ // Node
+ //--------------------------------------------------------------------------
+
+ void emitKeyword(IKeywordNode node);
+
+ void emitLanguageIdentifier(ILanguageIdentifierNode node);
+
+ void emitMetaTag(IMetaTagNode node);
+
+ void emitContainer(IContainerNode node);
+
+ void emitE4XFilter(IMemberAccessExpressionNode node);
+
+ void emitUseNamespace(IUseNamespaceNode node);
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASWriter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASWriter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASWriter.java
new file mode 100644
index 0000000..c2c2ded
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/as/IASWriter.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen.as;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An ActionScript writer that outputs cross compiled string data to the output
+ * stream.
+ *
+ * @author Michael Schmalle
+ */
+public interface IASWriter extends Closeable
+{
+ /**
+ * Start writing to output stream.
+ *
+ * @param out output stream
+ */
+ void writeTo(OutputStream out);
+
+ /**
+ * Start writing to a file.
+ *
+ * @param out The output {@link File}.
+ * @return The number of bytes written.
+ */
+ int writeTo(File out) throws FileNotFoundException, IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSDocEmitter.java
new file mode 100644
index 0000000..e37dd18
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSDocEmitter.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen.js;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+
+/**
+ * The {@link IJSDocEmitter} interface allows the abstraction of JavaScript
+ * document comments to be emitted per tag.
+ *
+ * @author Michael Schmalle
+ */
+public interface IJSDocEmitter extends IDocEmitter
+{
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSEmitter.java
new file mode 100644
index 0000000..218b5be
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSEmitter.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen.js;
+
+import java.io.Writer;
+import java.util.List;
+
+import com.google.debugging.sourcemap.FilePosition;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.common.ISourceLocation;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.visitor.IASNodeStrategy;
+
+/**
+ * The {@link IJSEmitter} interface allows abstraction between the
+ * {@link IASNodeStrategy} and the current output buffer {@link Writer}.
+ *
+ * @author Michael Schmalle
+ */
+public interface IJSEmitter extends IASEmitter
+{
+ JSSessionModel getModel();
+ List<SourceMapMapping> getSourceMapMappings();
+
+ String formatQualifiedName(String name);
+
+ /**
+ * Adds a node to the source map.
+ */
+ void startMapping(ISourceLocation node);
+
+ /**
+ * Adds a node to the source map using custom line and column values,
+ * instead of the node's own line and column. Useful for starting a mapping
+ * in the middle of the node.
+ */
+ void startMapping(ISourceLocation node, int line, int column);
+
+ /**
+ * Adds a node to the source map after a particular node instead using the
+ * node's own line and column.
+ */
+ void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping);
+
+ /**
+ * Commits a mapping to the source map.
+ */
+ void endMapping(ISourceLocation node);
+
+ void pushSourceMapName(ISourceLocation node);
+ void popSourceMapName();
+
+ void emitSourceMapDirective(ITypeNode node);
+
+ void emitClosureStart();
+ void emitClosureEnd(IASNode node);
+
+ class SourceMapMapping
+ {
+ public String sourcePath;
+ public String name;
+ public FilePosition sourceStartPosition;
+ public FilePosition destStartPosition;
+ public FilePosition destEndPosition;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSPublisher.java
new file mode 100644
index 0000000..2d62436
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSPublisher.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.compiler.codegen.js;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.driver.IPublisher;
+
+/**
+ * The {@link IJSPublisher} interface allows the abstraction of project output
+ * generation.
+ *
+ * @author Erik de Bruin
+ */
+public interface IJSPublisher extends IPublisher
+{
+
+ File getOutputFolder();
+
+ boolean publish(ProblemQuery problems) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSWriter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSWriter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSWriter.java
new file mode 100644
index 0000000..aae8011
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/IJSWriter.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.codegen.js;
+
+import java.io.File;
+import java.io.OutputStream;
+
+import org.apache.flex.compiler.codegen.as.IASWriter;
+
+/**
+ * A JavaScript writer that outputs cross compiled string data to the output
+ * stream.
+ *
+ * @author Michael Schmalle
+ */
+public interface IJSWriter extends IASWriter
+{
+ /**
+ * Write JS file and source map.
+ *
+ * @param jsOut JS output stream
+ * @param sourceMapOut Source map file
+ */
+ void writeTo(OutputStream jsOut, File sourceMapOut);
+
+}