From ec4c30ae483e6700a1fd1d5edaadbb042790c52e Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Wed, 2 Mar 2022 22:18:45 +0100 Subject: wasm: Implement `@wasmMemorySize()` builtin This implements the `wasmMemorySize` builtin, in Sema and the Wasm backend. The Stage2 implementation differs from stage1 in the way that `index` must be a comptime value. The stage1 variant is incorrect, as the index is part of the instruction encoding, and therefore, cannot be a runtime value. --- 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 2fee02751c..a82d9dc360 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -7140,7 +7140,7 @@ fn builtinCall( // zig fmt: on .wasm_memory_size => { - const operand = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); + const operand = try comptimeExpr(gz, scope, .{ .ty = .u32_type }, params[0]); const result = try gz.addExtendedPayload(.wasm_memory_size, Zir.Inst.UnNode{ .node = gz.nodeIndexToRelative(node), .operand = operand, -- cgit v1.2.3