diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-21 23:27:27 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-21 23:27:27 +0100 |
| commit | 7d7cf0405e12e2f888097ed6f504082d8397c2b7 (patch) | |
| tree | 57e8c791e52649877647bb6dedb0c41cf3ed54c9 /src/main/java | |
| parent | 20ba12d3bf07b56cba79c0d606648cac2c9e7325 (diff) | |
Extract writeNameSectionFunctionNameSubsection()
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormat.java | 24 |
1 files changed, 14 insertions, 10 deletions
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 6acafeac..1dc57d2e 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 @@ -108,20 +108,24 @@ public class WasmBinaryFormat { if (module.imports().size() > 0) { writeSection(SectionType.CUSTOM, writer, () -> { writeString("name", writer); - writeSection((byte) 1, writer, () -> { - writeVec( - module.imports(), - (importIndex, import_) -> { - Leb128Encoding.encodeUnsignedInt32(importIndex, writer); - writeString(module.imports().get(importIndex).identifier(), writer); - }, - writer - ); - }); + writeNameSectionFunctionNameSubsection(module, writer); }); } } + private static void writeNameSectionFunctionNameSubsection(WasmModule module, BinaryWriter writer) throws IOException { + writeSection((byte) 1, writer, () -> { + writeVec( + module.imports(), + (importIndex, import_) -> { + Leb128Encoding.encodeUnsignedInt32(importIndex, writer); + writeString(module.imports().get(importIndex).identifier(), writer); + }, + writer + ); + }); + } + private static void writeFuncType(WasmFuncType type, BinaryWriter writer) throws IOException { writer.writeByte((byte) 0x60); writeValueTypeVector(type.params(), writer); |
