Ensure function indices are correct and fix a memory leak

This commit is contained in:
Luuk de Gram
2021-02-04 21:08:19 +01:00
parent aa3e0ff454
commit 36df6a008f
3 changed files with 73 additions and 49 deletions

View File

@@ -161,7 +161,6 @@ pub const Context = struct {
pub fn gen(self: *Context) InnerError!void {
assert(self.code.items.len == 0);
try self.genFunctype();
const writer = self.code.writer();
// Write instructions
// TODO: check for and handle death of instructions
@@ -194,6 +193,7 @@ pub const Context = struct {
}
}
const writer = self.code.writer();
try writer.writeByte(wasm.opcode(.end));
// Fill in the size of the generated code to the reserved space at the