authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-17 15:29:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-17 16:09:20-07:00
logd5e894a9a7c63ebbfaa3c4eb6d173e15745ad39c
treecb1b68b50d9012c2c63ae2c4ad0469caeaaefef6
parentab6b0ad8a4f858c8e4e5591b2383156eab8ac0e4

stage2: get rid of failed_root_src_file


3 files changed, 11 insertions(+), 23 deletions(-)

BRANCH_TODO+10-9
...@@ -1,17 +1,8 @@...@@ -1,17 +1,8 @@
1 * modify stage2 CBE tests so that only 1 uses pub export main and the
2 rest use pub fn main
3
4 * get the test runner and `zig test` working
5 * get behavior tests passing for stage2
6
7 * use a hash map for instructions because the array is too big1 * use a hash map for instructions because the array is too big
8 - no, actually modify the Zir.Inst.Ref strategy so that each decl gets2 - no, actually modify the Zir.Inst.Ref strategy so that each decl gets
9 their indexes starting at 0 so that we can use an array to store Sema3 their indexes starting at 0 so that we can use an array to store Sema
10 results rather than a map.4 results rather than a map.
115
12 * implement the new AstGen compile errors
13
14 * get rid of failed_root_src_file
15 * get rid of Scope.DeclRef6 * get rid of Scope.DeclRef
16 * get rid of NameHash7 * get rid of NameHash
17 * handle decl collision with usingnamespace8 * handle decl collision with usingnamespace
...@@ -68,3 +59,13 @@...@@ -68,3 +59,13 @@
68 * repl: if you try `run` with -ofmt=c you get an access denied error because it59 * repl: if you try `run` with -ofmt=c you get an access denied error because it
69 tries to execute the .c file as a child process instead of executing `zig run`60 tries to execute the .c file as a child process instead of executing `zig run`
70 on it.61 on it.
62
63=== file issues: ===
64
65 * C backend: honor the exported symbol name. Right now if you do `pub fn main`
66 it generates bogus C code because the `@export` name is not honored, and it allows
67 the `main` which should be not exported, to clobber the exported symbol name.
68
69 * get the test runner and `zig test` working
70 - get behavior tests passing for stage2
71
src/Compilation.zig+1-11
...@@ -1681,8 +1681,7 @@ pub fn totalErrorCount(self: *Compilation) usize {...@@ -1681,8 +1681,7 @@ pub fn totalErrorCount(self: *Compilation) usize {
1681 var total: usize = self.failed_c_objects.count() + self.misc_failures.count();1681 var total: usize = self.failed_c_objects.count() + self.misc_failures.count();
16821682
1683 if (self.bin_file.options.module) |module| {1683 if (self.bin_file.options.module) |module| {
1684 total += module.failed_exports.items().len +1684 total += module.failed_exports.items().len;
1685 @boolToInt(module.failed_root_src_file != null);
16861685
1687 for (module.failed_files.items()) |entry| {1686 for (module.failed_files.items()) |entry| {
1688 if (entry.value) |_| {1687 if (entry.value) |_| {
...@@ -1789,15 +1788,6 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {...@@ -1789,15 +1788,6 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
1789 for (module.failed_exports.items()) |entry| {1788 for (module.failed_exports.items()) |entry| {
1790 try AllErrors.add(module, &arena, &errors, entry.value.*);1789 try AllErrors.add(module, &arena, &errors, entry.value.*);
1791 }1790 }
1792 if (module.failed_root_src_file) |err| {
1793 const file_path = try module.root_pkg.root_src_directory.join(&arena.allocator, &[_][]const u8{
1794 module.root_pkg.root_src_path,
1795 });
1796 const msg = try std.fmt.allocPrint(&arena.allocator, "unable to read {s}: {s}", .{
1797 file_path, @errorName(err),
1798 });
1799 try AllErrors.addPlain(&arena, &errors, msg);
1800 }
1801 }1791 }
18021792
1803 if (errors.items.len == 0 and self.link_error_flags.no_entry_point_found) {1793 if (errors.items.len == 0 and self.link_error_flags.no_entry_point_found) {
src/Module.zig-3
...@@ -92,9 +92,6 @@ error_name_list: ArrayListUnmanaged([]const u8) = .{},...@@ -92,9 +92,6 @@ error_name_list: ArrayListUnmanaged([]const u8) = .{},
92/// previous analysis.92/// previous analysis.
93generation: u32 = 0,93generation: u32 = 0,
9494
95/// When populated it means there was an error opening/reading the root source file.
96failed_root_src_file: ?anyerror = null,
97
98stage1_flags: packed struct {95stage1_flags: packed struct {
99 have_winmain: bool = false,96 have_winmain: bool = false,
100 have_wwinmain: bool = false,97 have_wwinmain: bool = false,