From 46471000c1851940777f6dce77fa9a4bc2fe877c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 21 Jun 2023 19:11:24 +0100 Subject: Add WASM section types --- .../backends/wasm/structure/WasmBinaryFormat.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormat.java b/src/main/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormat.java index 2ec10c2a..ab43d70d 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormat.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormat.java @@ -10,6 +10,29 @@ public class WasmBinaryFormat { private static final byte[] WASM_MAGIC = HexFormat.of().parseHex("0061736D"); private static final byte[] WASM_VERSION = HexFormat.of().parseHex("01000000"); + private enum SectionType { + CUSTOM(0), + TYPE(1), + IMPORT(2), + FUNCTION(3), + TABLE(4), + MEMORY(5), + GLOBAL(6), + EXPORT(7), + START(8), + ELEMENT(9), + CODE(10), + DATA(11), + DATA_COUNT(12), + TAG(13); + + private final byte id; + + SectionType(int id) { + this.id = (byte) id; + } + } + public static void serializeModule(WasmModule module, FileOutputStream outputStream) throws IOException { outputStream.write(WASM_MAGIC); outputStream.write(WASM_VERSION); -- cgit v1.2.3