diff --git a/src-self-hosted/cgen.zig b/src-self-hosted/cgen.zig new file mode 100644 index 0000000000..f06f9df6ac --- /dev/null +++ b/src-self-hosted/cgen.zig @@ -0,0 +1,11 @@ +const link = @import("link.zig"); +const Module = @import("Module.zig"); + +const C = link.File.C; +const Decl = Module.Decl; +const CStandard = Module.CStandard; + +pub fn generate(file: *C, decl: *Decl, standard: CStandard) !void { + const writer = file.file.?.writer(); + try writer.print("Generating decl '{}', targeting {}", .{ decl.name, @tagName(standard) }); +} diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index e37f567d92..98133a4f42 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -7,6 +7,7 @@ const Module = @import("Module.zig"); const fs = std.fs; const elf = std.elf; const codegen = @import("codegen.zig"); +const cgen = @import("cgen.zig"); const default_entry_addr = 0x8000000; @@ -229,7 +230,7 @@ pub const File = struct { } pub fn updateDecl(self: *File.C, module: *Module, decl: *Module.Decl) !void { - return error.Unimplemented; + try cgen.generate(self, decl, self.options.c_standard.?); } }; diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 0a4e9708ac..153c77ce47 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -481,7 +481,10 @@ pub const TestContext = struct { if (case.c_standard) |cstd| { label = @tagName(cstd); var c: *link.File.C = module.bin_file.cast(link.File.C).?; - var out = c.file.?.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!"); + c.file.?.close(); + var file = try tmp.dir.openFile(bin_name, .{ .read = true }); + defer file.close(); + var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!"); defer allocator.free(out); if (expected_output.len != out.len) {