diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-20 18:27:22 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-20 18:27:22 +0100 |
| commit | 89f5a082b37c59d81e0561a863cb69622502eb62 (patch) | |
| tree | 063d2213060a90e60b488a417edc004f058237c7 /src/main/java | |
| parent | 4be0a1caf255fa3c1dd86dfc210671b7ae395ebe (diff) | |
Add stubbed WASM backend
Diffstat (limited to 'src/main/java')
3 files changed, 39 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/backends/Backends.java b/src/main/java/org/shedlang/compiler/backends/Backends.java new file mode 100644 index 00000000..93801fbc --- /dev/null +++ b/src/main/java/org/shedlang/compiler/backends/Backends.java @@ -0,0 +1,14 @@ +package org.shedlang.compiler.backends; + +import org.pcollections.OrderedPMap; +import org.shedlang.compiler.backends.llvm.LlvmBackend; +import org.shedlang.compiler.backends.wasm.WasmBackend; + +public class Backends { + private Backends() { + } + + public static final OrderedPMap<String, Backend> BACKENDS = OrderedPMap.<String, Backend>empty() + .plus("llvm", new LlvmBackend()) + .plus("wasm", new WasmBackend()); +} diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java new file mode 100644 index 00000000..85541f6e --- /dev/null +++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java @@ -0,0 +1,22 @@ +package org.shedlang.compiler.backends.wasm; + +import org.shedlang.compiler.backends.Backend; +import org.shedlang.compiler.config.ProjectConfig; +import org.shedlang.compiler.stackir.instructions.Instruction; +import org.shedlang.compiler.typechecker.TypeInfo; +import org.shedlang.compiler.types.NamespaceName; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class WasmBackend implements Backend { + @Override + public void compile( + ProjectConfig config, + Map<NamespaceName, List<Instruction>> namespaces, + TypeInfo typeInfo + ) throws IOException { + + } +} diff --git a/src/main/java/org/shedlang/compiler/cli/ShedCli.java b/src/main/java/org/shedlang/compiler/cli/ShedCli.java index 0e36cf13..f8ab153a 100644 --- a/src/main/java/org/shedlang/compiler/cli/ShedCli.java +++ b/src/main/java/org/shedlang/compiler/cli/ShedCli.java @@ -4,8 +4,8 @@ import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import org.shedlang.compiler.ShedCompiler; +import org.shedlang.compiler.backends.Backends; import org.shedlang.compiler.backends.GenerateInstructionsBackend; -import org.shedlang.compiler.backends.llvm.LlvmBackend; import org.shedlang.compiler.errors.SourceError; import java.io.IOException; @@ -30,7 +30,7 @@ public class ShedCli { switch (args.<Command>get("command")) { case COMPILE -> { - compiler.compile(sourcePath, new LlvmBackend()); + compiler.compile(sourcePath, Backends.BACKENDS.get(args.getString("backend"))); } case GENERATE_INSTRUCTIONS -> { compiler.compile(sourcePath, new GenerateInstructionsBackend()); @@ -47,7 +47,7 @@ public class ShedCli { var compileSubParser = subparsers.addParser("compile"); compileSubParser.setDefault("command", Command.COMPILE); compileSubParser.addArgument("source").required(true); - compileSubParser.addArgument("--backend").choices("llvm").required(true); + compileSubParser.addArgument("--backend").choices(Backends.BACKENDS.keySet()).required(true); var generateInstructionsSubParser = subparsers.addParser("generate-instructions"); generateInstructionsSubParser.setDefault("command", Command.GENERATE_INSTRUCTIONS); |
