From 43cb19ea4da63dcaa8a18a06e3ab23f1c822c1fe Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Thu, 3 Mar 2022 19:10:58 +0100 Subject: wasm: Implement `@wasmMemoryGrow` builtin Similarly to the other wasm builtin, this implements the grow variation where the memory index is a comptime known value. The operand as well as the result are runtime values. This also verifies during semantic analysis the target we're building for is wasm, or else emits a compilation error. This means that other backends do not have to handle this AIR instruction, other than the wasm and LLVM backends. --- src/AstGen.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/AstGen.zig') diff --git a/src/AstGen.zig b/src/AstGen.zig index a82d9dc360..d6d29d4a54 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -7148,7 +7148,7 @@ fn builtinCall( return rvalue(gz, rl, result, node); }, .wasm_memory_grow => { - const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); + const index_arg = try comptimeExpr(gz, scope, .{ .ty = .u32_type }, params[0]); const delta_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[1]); const result = try gz.addExtendedPayload(.wasm_memory_grow, Zir.Inst.BinNode{ .node = gz.nodeIndexToRelative(node), -- cgit v1.2.3