From 4ff129c58d805a6c5887c1d6a1063a238e37d70b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 21 Dec 2023 16:25:47 +0000 Subject: Document behaviour of WasmMemoryBuilder --- .../org/shedlang/compiler/backends/wasm/WasmMemoryBuilder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmMemoryBuilder.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmMemoryBuilder.java index d2a13ee6..1f55af6c 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/WasmMemoryBuilder.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmMemoryBuilder.java @@ -23,11 +23,15 @@ public class WasmMemoryBuilder { this.size = size; } + /** + * This adds an import for linear memory, sized according to the data that + * has been added to this builder, and adds corresponding data segments. + *

+ * This assumes that no memory currently exists in the given module. + */ public WasmModule toModule(WasmModule module) { var pageCount = (size + PAGE_SIZE - 1) / PAGE_SIZE; - // TODO: we assume that we're in complete control of memory and data segments. - // Either remove this assumption or document it properly. module = module .addImport(new WasmImport( "env", -- cgit v1.2.3