You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by er...@apache.org on 2017/11/07 14:13:39 UTC

[royale-compiler] 01/01: Get first test to run to completion on WAST configured code; test fails -> must create emitters

This is an automated email from the ASF dual-hosted git repository.

erikdebruin pushed a commit to branch wast
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit e33602140d940367c35a976b060d4e68f4f5e010
Author: Erik de Bruin <er...@ixsoftware.nl>
AuthorDate: Tue Nov 7 15:08:44 2017 +0100

    Get first test to run to completion on WAST configured code; test fails -> must create emitters
    
    Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
---
 .../royale/compiler/clients/WASTConfiguration.java |  26 ++++
 .../compiler/codegen/wast/IWASTPublisher.java      |  35 +++++
 .../royale/compiler/driver/wast/IWASTBackend.java  |  26 ++++
 .../internal/codegen/wast/WASTEmitter.java         |  40 ++++++
 .../internal/codegen/wast/WASTPublisher.java       |  89 +++++++++++++
 .../compiler/internal/codegen/wast/WASTWriter.java |  78 +++++++++++
 .../compiler/internal/driver/wast/WASTBackend.java | 144 +++++++++++++++++++++
 .../internal/driver/wast/WASTCompilationUnit.java  |  70 ++++++++++
 .../driver/wast/WASTSourceFileHandler.java         |  52 ++++++++
 .../internal/codegen/wast/TestWASTClass.java       |  41 ++++++
 .../compiler/internal/test/WASTTestBase.java       |  64 +++++++++
 11 files changed, 665 insertions(+)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/WASTConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/WASTConfiguration.java
new file mode 100644
index 0000000..44a3204
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/WASTConfiguration.java
@@ -0,0 +1,26 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.royale.compiler.clients;
+
+import org.apache.royale.compiler.config.Configuration;
+
+public class WASTConfiguration extends Configuration {
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/wast/IWASTPublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/wast/IWASTPublisher.java
new file mode 100644
index 0000000..265bcd0
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/wast/IWASTPublisher.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.royale.compiler.codegen.wast;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.royale.compiler.clients.problems.ProblemQuery;
+import org.apache.royale.compiler.driver.IPublisher;
+
+public interface IWASTPublisher extends IPublisher {
+
+    File getOutputFolder();
+
+    boolean publish(ProblemQuery problems) throws IOException;
+
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/driver/wast/IWASTBackend.java b/compiler-jx/src/main/java/org/apache/royale/compiler/driver/wast/IWASTBackend.java
new file mode 100644
index 0000000..fb4fb09
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/driver/wast/IWASTBackend.java
@@ -0,0 +1,26 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.royale.compiler.driver.wast;
+
+import org.apache.royale.compiler.driver.IBackend;
+
+public interface IWASTBackend extends IBackend {
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTEmitter.java
new file mode 100644
index 0000000..2f63448
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTEmitter.java
@@ -0,0 +1,40 @@
+/*
+ *
+ *  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.royale.compiler.internal.codegen.wast;
+
+import java.io.FilterWriter;
+
+import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
+import org.apache.royale.compiler.tree.as.IClassNode;
+
+public class WASTEmitter extends ASEmitter {
+
+    public WASTEmitter(FilterWriter out)
+    {
+        super(out);
+    }
+
+    @Override
+    public void emitClass(IClassNode node)
+    {
+     	writeToken("Hoi");
+    }
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTPublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTPublisher.java
new file mode 100644
index 0000000..002ec5b
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTPublisher.java
@@ -0,0 +1,89 @@
+/*
+ *
+ *  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.royale.compiler.internal.codegen.wast;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.royale.compiler.clients.problems.ProblemQuery;
+import org.apache.royale.compiler.codegen.wast.IWASTPublisher;
+import org.apache.royale.compiler.config.Configuration;
+import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+
+public class WASTPublisher implements IWASTPublisher {
+
+    public WASTPublisher(RoyaleJSProject project, Configuration config)
+    {
+        this.project = project;
+        this.configuration = config;
+    }
+
+    protected RoyaleJSProject project;
+    protected File outputFolder;
+    protected File outputParentFolder;
+
+
+    protected Configuration configuration;
+
+	@Override
+    public File getOutputFolder()
+    {
+        outputFolder = new File(getOutputFilePath());
+        if (!outputFolder.isDirectory()) {
+            outputFolder = outputFolder.getParentFile();
+        }
+
+        outputParentFolder = outputFolder;
+
+        setupOutputFolder();
+
+        return outputFolder;
+    }
+
+    protected void setupOutputFolder()
+    {
+        if (!outputFolder.exists()) {
+            outputFolder.mkdirs();
+        }
+    }
+
+    private String getOutputFilePath()
+    {
+        if (configuration.getOutput() == null)
+        {
+            final String extension = "." + project.getBackend().getOutputExtension();
+            return FilenameUtils.removeExtension(configuration.getTargetFile())
+                    .concat(extension);
+        }
+        else {
+            return configuration.getOutput();
+        }
+    }
+
+	@Override
+    public boolean publish(ProblemQuery problems) throws IOException
+    {
+        System.out
+                .println("The project has been successfully compiled and optimized.");
+        return true;
+    }
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTWriter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTWriter.java
new file mode 100644
index 0000000..bf40057
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/wast/WASTWriter.java
@@ -0,0 +1,78 @@
+/*
+ *
+ *  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.royale.compiler.internal.codegen.wast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.apache.royale.compiler.codegen.as.IASEmitter;
+import org.apache.royale.compiler.codegen.as.IASWriter;
+import org.apache.royale.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.problems.ICompilerProblem;
+import org.apache.royale.compiler.units.ICompilationUnit;
+import org.apache.royale.compiler.visitor.as.IASBlockWalker;
+
+public class WASTWriter implements IASWriter {
+
+    private RoyaleJSProject project;
+    private List<ICompilerProblem> problems;
+    private ICompilationUnit compilationUnit;
+
+    public WASTWriter(RoyaleJSProject project, List<ICompilerProblem> problems,
+            ICompilationUnit compilationUnit, boolean enableDebug)
+	{
+		this.project = project;
+		this.problems = problems;
+		this.compilationUnit = compilationUnit;
+	}
+
+    @Override
+	public void close() throws IOException {}
+
+	@Override
+	public void writeTo(OutputStream out) {
+        ASFilterWriter writer = project.getBackend().createWriterBuffer(project);
+        IASEmitter emitter = project.getBackend().createEmitter(writer);
+        IASBlockWalker walker = project.getBackend().createWalker(project, problems, emitter);
+
+        walker.visitCompilationUnit(compilationUnit);
+
+        System.out.println(writer.toString());
+
+        try
+        {
+            out.write(writer.toString().getBytes());
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+	}
+
+	@Override
+	public int writeTo(File out) throws FileNotFoundException, IOException {
+		return 0;
+	}
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTBackend.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTBackend.java
new file mode 100644
index 0000000..c882d77
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTBackend.java
@@ -0,0 +1,144 @@
+/*
+ *
+ *  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.royale.compiler.internal.driver.wast;
+
+import java.io.FilterWriter;
+import java.io.StringWriter;
+import java.util.List;
+
+import org.apache.royale.compiler.clients.WASTConfiguration;
+import org.apache.royale.compiler.codegen.IDocEmitter;
+import org.apache.royale.compiler.codegen.as.IASEmitter;
+import org.apache.royale.compiler.codegen.as.IASWriter;
+import org.apache.royale.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.royale.compiler.config.Configuration;
+import org.apache.royale.compiler.config.Configurator;
+import org.apache.royale.compiler.driver.IBackend;
+import org.apache.royale.compiler.driver.IPublisher;
+import org.apache.royale.compiler.driver.wast.IWASTBackend;
+import org.apache.royale.compiler.internal.codegen.as.ASAfterNodeStrategy;
+import org.apache.royale.compiler.internal.codegen.as.ASBeforeNodeStrategy;
+import org.apache.royale.compiler.internal.codegen.as.ASBlockWalker;
+import org.apache.royale.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.royale.compiler.internal.codegen.wast.WASTEmitter;
+import org.apache.royale.compiler.internal.codegen.wast.WASTPublisher;
+import org.apache.royale.compiler.internal.codegen.wast.WASTWriter;
+import org.apache.royale.compiler.internal.projects.ISourceFileHandler;
+import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.internal.targets.JSTarget;
+import org.apache.royale.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.royale.compiler.internal.visitor.as.BeforeAfterStrategy;
+import org.apache.royale.compiler.problems.ICompilerProblem;
+import org.apache.royale.compiler.targets.ITarget;
+import org.apache.royale.compiler.targets.ITargetProgressMonitor;
+import org.apache.royale.compiler.targets.ITargetSettings;
+import org.apache.royale.compiler.tree.as.IFileNode;
+import org.apache.royale.compiler.units.ICompilationUnit;
+import org.apache.royale.compiler.visitor.IBlockWalker;
+import org.apache.royale.compiler.visitor.as.IASBlockWalker;
+import org.apache.royale.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link ASBlockWalker} is used to traverse the {@link IFileNode} AST.
+ * 
+ * @author Erik de Bruin
+ */
+public class WASTBackend implements IWASTBackend {
+
+	@Override
+	public ISourceFileHandler getSourceFileHandlerInstance() {
+        return WASTSourceFileHandler.INSTANCE;
+	}
+
+	@Override
+	public String getOutputExtension() {
+		return "wat";
+	}
+
+	@Override
+	public Configurator createConfigurator() {
+        return new Configurator(WASTConfiguration.class);
+	}
+
+	@Override
+	public ITarget createTarget(RoyaleJSProject project, ITargetSettings settings, ITargetProgressMonitor monitor) {
+        return new JSTarget(project, settings, monitor);
+	}
+
+	@Override
+	public IDocEmitter createDocEmitter(IASEmitter emitter) {
+        throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public IASEmitter createEmitter(FilterWriter writer) {
+        return new WASTEmitter(writer);
+	}
+
+	@Override
+	public IMXMLEmitter createMXMLEmitter(FilterWriter writer) {
+        throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public ASFilterWriter createWriterBuffer(RoyaleJSProject project) {
+        StringWriter out = new StringWriter();
+        ASFilterWriter writer = new ASFilterWriter(out);
+        return writer;
+	}
+
+	@Override
+	public IASWriter createWriter(RoyaleJSProject project, List<ICompilerProblem> errors,
+			ICompilationUnit compilationUnit, boolean enableDebug) {
+        return new WASTWriter(project, errors, compilationUnit, enableDebug);
+	}
+
+	@Override
+	public IASWriter createMXMLWriter(RoyaleJSProject project, List<ICompilerProblem> errors,
+			ICompilationUnit compilationUnit, boolean enableDebug) {
+        throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public IASBlockWalker createWalker(RoyaleJSProject project, List<ICompilerProblem> errors, IASEmitter emitter) {
+        ASBlockWalker walker = new ASBlockWalker(errors, project, emitter);
+
+        BeforeAfterStrategy strategy = new BeforeAfterStrategy(
+                new ASNodeSwitch(walker), new ASBeforeNodeStrategy(emitter),
+                new ASAfterNodeStrategy(emitter));
+
+        walker.setStrategy(strategy);
+
+        return walker;
+	}
+
+	@Override
+	public IPublisher createPublisher(RoyaleJSProject project, List<ICompilerProblem> errors, Configuration config) {
+        return new WASTPublisher(project, config);
+	}
+
+	@Override
+	public IMXMLBlockWalker createMXMLWalker(RoyaleJSProject project, List<ICompilerProblem> errors,
+			IMXMLEmitter mxmlEmitter, IASEmitter asEmitter, IBlockWalker asBlockWalker) {
+        throw new UnsupportedOperationException();
+	}
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTCompilationUnit.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTCompilationUnit.java
new file mode 100644
index 0000000..55422e2
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTCompilationUnit.java
@@ -0,0 +1,70 @@
+/*
+ *
+ *  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.royale.compiler.internal.driver.wast;
+
+import java.io.IOException;
+
+import org.apache.royale.compiler.common.DependencyType;
+import org.apache.royale.compiler.internal.projects.CompilerProject;
+import org.apache.royale.compiler.internal.projects.DefinitionPriority;
+import org.apache.royale.compiler.internal.units.ASCompilationUnit;
+import org.apache.royale.compiler.targets.ITarget.TargetType;
+
+public class WASTCompilationUnit extends ASCompilationUnit {
+
+	/**
+     * Create a compilation unit from an ABC file.
+     * 
+     * @param project compiler project
+     * @param path ABC file path
+     * @throws IOException error
+     */
+    public WASTCompilationUnit(CompilerProject project, String path)
+            throws IOException
+    {
+        this(project, path, DefinitionPriority.BasePriority.LIBRARY_PATH);
+    }
+
+    public WASTCompilationUnit(CompilerProject project, String path,
+            DefinitionPriority.BasePriority basePriority)
+    {
+        super(project, path, basePriority);
+    }
+
+    public WASTCompilationUnit(CompilerProject project, String path,
+            DefinitionPriority.BasePriority basePriority, String qname)
+    {
+        super(project, path, basePriority, 0, qname);
+    }
+    
+    public Boolean addDependency(String className, DependencyType dt)
+    {
+        return true;
+    }
+
+    @Override
+    public void startBuildAsync(TargetType targetType)
+    {
+        getSyntaxTreeRequest();
+        getFileScopeRequest();
+        getOutgoingDependenciesRequest();
+    }
+
+}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTSourceFileHandler.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTSourceFileHandler.java
new file mode 100644
index 0000000..1a1a97d
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/wast/WASTSourceFileHandler.java
@@ -0,0 +1,52 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.royale.compiler.internal.driver.wast;
+
+import org.apache.royale.compiler.internal.projects.CompilerProject;
+import org.apache.royale.compiler.internal.projects.DefinitionPriority.BasePriority;
+import org.apache.royale.compiler.internal.projects.ISourceFileHandler;
+import org.apache.royale.compiler.units.ICompilationUnit;
+
+public class WASTSourceFileHandler implements ISourceFileHandler {
+
+    public static final WASTSourceFileHandler INSTANCE = new WASTSourceFileHandler();
+
+	@Override
+	public String[] getExtensions() {
+		return new String[] { "as" };
+	}
+
+	@Override
+	public boolean needCompilationUnit(CompilerProject project, String path, String qname, String locale) {
+		return true;
+	}
+
+	@Override
+	public ICompilationUnit createCompilationUnit(CompilerProject project, String path, BasePriority priority,
+			int order, String qname, String locale) {
+        return new WASTCompilationUnit(project, path, priority, qname);
+	}
+
+	@Override
+	public boolean canCreateInvisibleCompilationUnit() {
+		return false;
+	}
+
+}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/wast/TestWASTClass.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/wast/TestWASTClass.java
new file mode 100644
index 0000000..958feab
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/wast/TestWASTClass.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.royale.compiler.internal.codegen.wast;
+
+import org.apache.royale.compiler.internal.test.WASTTestBase;
+import org.apache.royale.compiler.tree.as.IClassNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of WebAssembly Text Format code for Classes.
+ * 
+ * @author Erik de Bruin
+ */
+public class TestWASTClass extends WASTTestBase {
+
+    @Test
+    public void testClassSimple()
+    {
+        IClassNode node = (IClassNode) getNode("public class A{}", IClassNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitClass(node);
+        assertOut("Ola!");
+    }
+
+}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/WASTTestBase.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/WASTTestBase.java
new file mode 100644
index 0000000..7218e94
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/WASTTestBase.java
@@ -0,0 +1,64 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.royale.compiler.internal.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.royale.compiler.driver.IBackend;
+import org.apache.royale.compiler.internal.driver.wast.WASTBackend;
+import org.apache.royale.utils.FilenameNormalization;
+
+/**
+ * This class tests the production of WebAssembly Text Format output for for AS package.
+ * 
+ * @author Erik de Bruin
+ */
+public class WASTTestBase extends ASTestBase {
+
+    @Override
+    public void setUp()
+    {
+        super.setUp();
+
+        asEmitter = backend.createEmitter(writer);
+        asBlockWalker = backend.createWalker(project, errors, asEmitter);
+    }
+
+    @Override
+    protected void addSourcePaths(List<File> sourcePaths)
+    {
+        sourcePaths.add(tempDir);
+    }
+    
+    @Override
+    protected void addLibraries(List<File> libraries)
+    {
+        libraries.add(new File(FilenameNormalization.normalize(env.FPSDK
+                + "/" + env.FPVER + "/playerglobal.swc")));
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new WASTBackend();
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@royale.apache.org" <co...@royale.apache.org>.