stage2/wasm: implement basic container generation

Thus far, we only generate the type, function, export, and code
sections. These are sufficient to generate and export simple functions.

Codegen is currently hardcoded to `i32.const 42`, the main goal of this
commit is to create infrastructure for the container format which will
work with incremental compilation.
This commit is contained in:
Isaac Freund
2020-08-07 00:53:55 +02:00
parent 96a27557e2
commit 3370b5f109
5 changed files with 539 additions and 5 deletions

View File

@@ -1571,7 +1571,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void {
.macho => {
// TODO Implement for MachO
},
.c => {},
.c, .wasm => {},
}
}
} else {
@@ -1781,11 +1781,13 @@ fn allocateNewDecl(
.elf => .{ .elf = link.File.Elf.TextBlock.empty },
.macho => .{ .macho = link.File.MachO.TextBlock.empty },
.c => .{ .c = {} },
.wasm => .{ .wasm = {} },
},
.fn_link = switch (self.bin_file.tag) {
.elf => .{ .elf = link.File.Elf.SrcFn.empty },
.macho => .{ .macho = link.File.MachO.SrcFn.empty },
.c => .{ .c = {} },
.wasm => .{ .wasm = null },
},
.generation = 0,
};