diff options
| author | Luuk de Gram <luuk@degram.dev> | 2021-07-16 14:48:51 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-20 12:19:16 -0700 |
| commit | 424f260f850cb22637888bbfdf5bfaf9c08a4dae (patch) | |
| tree | 627d18c4ab1a7905cfa041028a8fdb4d680b651b /src/link | |
| parent | 8082660118bba78de00e1e103e53730a87b2b70f (diff) | |
| download | zig-424f260f850cb22637888bbfdf5bfaf9c08a4dae.tar.gz zig-424f260f850cb22637888bbfdf5bfaf9c08a4dae.zip | |
Fix wasm-related compile errors:
- Update `fail()` to not require a `srcLoc`.
This brings it in line with other backends, and we were always passing 'node_offset = 0', anyway.
- Fix unused local due to change of architecture wrt function/decl generation.
- Replace all old instructions to indexes within the function signatures.
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Wasm.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index be6ad78701..1387615d15 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -228,7 +228,7 @@ pub fn updateFunc(self: *Wasm, module: *Module, func: *Module.Fn, air: Air, live }, else => |e| return e, }; - return self.finishUpdateDecl(decl, result); + return self.finishUpdateDecl(decl, result, &context); } // Generate code for the Decl, storing it in memory to be later written to @@ -270,18 +270,21 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void { }, else => |e| return e, }; - return self.finishUpdateDecl(decl, result); + + return self.finishUpdateDecl(decl, result, &context); } -fn finishUpdateDecl(self: *Wasm, decl: *Module.Decl, result: codegen.Result) !void { - const code: []const u8 = switch (result) { - .appended => @as([]const u8, context.code.items), - .externally_managed => |payload| payload, - }; +fn finishUpdateDecl(self: *Wasm, decl: *Module.Decl, result: codegen.Result, context: *codegen.Context) !void { + const fn_data: *FnData = &decl.fn_link.wasm; fn_data.code = context.code.toUnmanaged(); fn_data.functype = context.func_type_data.toUnmanaged(); + const code: []const u8 = switch (result) { + .appended => @as([]const u8, fn_data.code.items), + .externally_managed => |payload| payload, + }; + const block = &decl.link.wasm; if (decl.ty.zigTypeTag() == .Fn) { // as locals are patched afterwards, the offsets of funcidx's are off, |
