| author | |
| committer | |
| log | 2f28ecf946b566f40e648145af18d207d0c5770d |
| tree | 79c819f9e099ae04bc102fcf52ceffc0f8752f2d |
| parent | aaaebfe97fa876356c22469001c6511dbdb8354d |
| signature | Commit is signed but in an unrecognized format. |
3 files changed, 17 insertions(+), 2 deletions(-)
src-self-hosted/cgen.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const link = @import("link.zig"); | |
| 2 | const Module = @import("Module.zig"); | |
| 3 | ||
| 4 | const C = link.File.C; | |
| 5 | const Decl = Module.Decl; | |
| 6 | const CStandard = Module.CStandard; | |
| 7 | ||
| 8 | pub fn generate(file: *C, decl: *Decl, standard: CStandard) !void { | |
| 9 | const writer = file.file.?.writer(); | |
| 10 | try writer.print("Generating decl '{}', targeting {}", .{ decl.name, @tagName(standard) }); | |
| 11 | } |
src-self-hosted/link.zig+2-1| ... | ... | @@ -7,6 +7,7 @@ const Module = @import("Module.zig"); |
| 7 | 7 | const fs = std.fs; |
| 8 | 8 | const elf = std.elf; |
| 9 | 9 | const codegen = @import("codegen.zig"); |
| 10 | const cgen = @import("cgen.zig"); | |
| 10 | 11 | |
| 11 | 12 | const default_entry_addr = 0x8000000; |
| 12 | 13 | |
| ... | ... | @@ -229,7 +230,7 @@ pub const File = struct { |
| 229 | 230 | } |
| 230 | 231 | |
| 231 | 232 | pub fn updateDecl(self: *File.C, module: *Module, decl: *Module.Decl) !void { |
| 232 | return error.Unimplemented; | |
| 233 | try cgen.generate(self, decl, self.options.c_standard.?); | |
| 233 | 234 | } |
| 234 | 235 | }; |
| 235 | 236 |
src-self-hosted/test.zig+4-1| ... | ... | @@ -481,7 +481,10 @@ pub const TestContext = struct { |
| 481 | 481 | if (case.c_standard) |cstd| { |
| 482 | 482 | label = @tagName(cstd); |
| 483 | 483 | var c: *link.File.C = module.bin_file.cast(link.File.C).?; |
| 484 | var out = c.file.?.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!"); | |
| 484 | c.file.?.close(); | |
| 485 | var file = try tmp.dir.openFile(bin_name, .{ .read = true }); | |
| 486 | defer file.close(); | |
| 487 | var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!"); | |
| 485 | 488 | defer allocator.free(out); |
| 486 | 489 | |
| 487 | 490 | if (expected_output.len != out.len) { |