authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-07 10:11:03+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-07 10:30:56+02:00
log56ea07f4fc20f479d82a7cb1633a15308a99c966
tree939afe92b57065b3aa61e4d1e51098e9e555e2df
parent7a2433419924af05e5e860031ff8279577fb25d5
signaturelock-open Commit is signed but in an unrecognized format.

self hosted compiler: comment out event.fs stuff


2 files changed, 68 insertions(+), 66 deletions(-)

src-self-hosted/compilation.zig+41-40
...@@ -242,7 +242,7 @@ pub const Compilation = struct {...@@ -242,7 +242,7 @@ pub const Compilation = struct {
242242
243 c_int_types: [CInt.list.len]*Type.Int,243 c_int_types: [CInt.list.len]*Type.Int,
244244
245 fs_watch: *fs.Watch(*Scope.Root),245 // fs_watch: *fs.Watch(*Scope.Root),
246246
247 const IntTypeTable = std.HashMap(*const Type.Int.Key, *Type.Int, Type.Int.Key.hash, Type.Int.Key.eql);247 const IntTypeTable = std.HashMap(*const Type.Int.Key, *Type.Int, Type.Int.Key.hash, Type.Int.Key.eql);
248 const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql);248 const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql);
...@@ -462,7 +462,7 @@ pub const Compilation = struct {...@@ -462,7 +462,7 @@ pub const Compilation = struct {
462 .have_err_ret_tracing = false,462 .have_err_ret_tracing = false,
463 .primitive_type_table = undefined,463 .primitive_type_table = undefined,
464464
465 .fs_watch = undefined,465 // .fs_watch = undefined,
466 };466 };
467 comp.link_libs_list = ArrayList(*LinkLib).init(comp.arena());467 comp.link_libs_list = ArrayList(*LinkLib).init(comp.arena());
468 comp.primitive_type_table = TypeTable.init(comp.arena());468 comp.primitive_type_table = TypeTable.init(comp.arena());
...@@ -531,8 +531,8 @@ pub const Compilation = struct {...@@ -531,8 +531,8 @@ pub const Compilation = struct {
531 comp.root_package = try Package.create(comp.arena(), ".", "");531 comp.root_package = try Package.create(comp.arena(), ".", "");
532 }532 }
533533
534 comp.fs_watch = try fs.Watch(*Scope.Root).create(16);534 // comp.fs_watch = try fs.Watch(*Scope.Root).create(16);
535 defer comp.fs_watch.destroy();535 // defer comp.fs_watch.destroy();
536536
537 try comp.initTypes();537 try comp.initTypes();
538 defer comp.primitive_type_table.deinit();538 defer comp.primitive_type_table.deinit();
...@@ -791,46 +791,47 @@ pub const Compilation = struct {...@@ -791,46 +791,47 @@ pub const Compilation = struct {
791 self.events.put(Event{ .Error = err });791 self.events.put(Event{ .Error = err });
792 }792 }
793793
794 // First, get an item from the watch channel, waiting on the channel.794 // // First, get an item from the watch channel, waiting on the channel.
795 var group = event.Group(BuildError!void).init(self.gpa());795 // var group = event.Group(BuildError!void).init(self.gpa());
796 {796 // {
797 const ev = (self.fs_watch.channel.get()) catch |err| {797 // const ev = (self.fs_watch.channel.get()) catch |err| {
798 build_result = err;798 // build_result = err;
799 continue;799 // continue;
800 };800 // };
801 const root_scope = ev.data;801 // const root_scope = ev.data;
802 group.call(rebuildFile, self, root_scope) catch |err| {802 // group.call(rebuildFile, self, root_scope) catch |err| {
803 build_result = err;803 // build_result = err;
804 continue;804 // continue;
805 };805 // };
806 }806 // }
807 // Next, get all the items from the channel that are buffered up.807 // // Next, get all the items from the channel that are buffered up.
808 while (self.fs_watch.channel.getOrNull()) |ev_or_err| {808 // while (self.fs_watch.channel.getOrNull()) |ev_or_err| {
809 if (ev_or_err) |ev| {809 // if (ev_or_err) |ev| {
810 const root_scope = ev.data;810 // const root_scope = ev.data;
811 group.call(rebuildFile, self, root_scope) catch |err| {811 // group.call(rebuildFile, self, root_scope) catch |err| {
812 build_result = err;812 // build_result = err;
813 continue;813 // continue;
814 };814 // };
815 } else |err| {815 // } else |err| {
816 build_result = err;816 // build_result = err;
817 continue;817 // continue;
818 }818 // }
819 }819 // }
820 build_result = group.wait();820 // build_result = group.wait();
821 }821 }
822 }822 }
823823
824 async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) !void {824 async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) !void {
825 const tree_scope = blk: {825 const tree_scope = blk: {
826 const source_code = fs.readFile(826 const source_code = "";
827 root_scope.realpath,827 // const source_code = fs.readFile(
828 max_src_size,828 // root_scope.realpath,
829 ) catch |err| {829 // max_src_size,
830 try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err));830 // ) catch |err| {
831 return;831 // try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err));
832 };832 // return;
833 errdefer self.gpa().free(source_code);833 // };
834 // errdefer self.gpa().free(source_code);
834835
835 const tree = try std.zig.parse(self.gpa(), source_code);836 const tree = try std.zig.parse(self.gpa(), source_code);
836 errdefer {837 errdefer {
...@@ -972,7 +973,7 @@ pub const Compilation = struct {...@@ -972,7 +973,7 @@ pub const Compilation = struct {
972 };973 };
973 defer root_scope.base.deref(self);974 defer root_scope.base.deref(self);
974975
975 assert((try self.fs_watch.addFile(root_scope.realpath, root_scope)) == null);976 // assert((try self.fs_watch.addFile(root_scope.realpath, root_scope)) == null);
976 try self.rebuildFile(root_scope);977 try self.rebuildFile(root_scope);
977 }978 }
978 }979 }
src-self-hosted/main.zig+27-26
...@@ -711,32 +711,33 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro...@@ -711,32 +711,33 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
711 if (try held.value.put(file_path, {})) |_| return;711 if (try held.value.put(file_path, {})) |_| return;
712 }712 }
713713
714 const source_code = event.fs.readFile(714 const source_code = "";
715 file_path,715 // const source_code = event.fs.readFile(
716 max_src_size,716 // file_path,
717 ) catch |err| switch (err) {717 // max_src_size,
718 error.IsDir, error.AccessDenied => {718 // ) catch |err| switch (err) {
719 // TODO make event based (and dir.next())719 // error.IsDir, error.AccessDenied => {
720 var dir = try fs.Dir.open(file_path);720 // // TODO make event based (and dir.next())
721 defer dir.close();721 // var dir = try fs.Dir.open(file_path);
722722 // defer dir.close();
723 var group = event.Group(FmtError!void).init(fmt.allocator);723
724 while (try dir.next()) |entry| {724 // var group = event.Group(FmtError!void).init(fmt.allocator);
725 if (entry.kind == fs.Dir.Entry.Kind.Directory or mem.endsWith(u8, entry.name, ".zig")) {725 // while (try dir.next()) |entry| {
726 const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name });726 // if (entry.kind == fs.Dir.Entry.Kind.Directory or mem.endsWith(u8, entry.name, ".zig")) {
727 try group.call(fmtPath, fmt, full_path, check_mode);727 // const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name });
728 }728 // try group.call(fmtPath, fmt, full_path, check_mode);
729 }729 // }
730 return group.wait();730 // }
731 },731 // return group.wait();
732 else => {732 // },
733 // TODO lock stderr printing733 // else => {
734 try stderr.print("unable to open '{}': {}\n", file_path, err);734 // // TODO lock stderr printing
735 fmt.any_error = true;735 // try stderr.print("unable to open '{}': {}\n", file_path, err);
736 return;736 // fmt.any_error = true;
737 },737 // return;
738 };738 // },
739 defer fmt.allocator.free(source_code);739 // };
740 // defer fmt.allocator.free(source_code);
740741
741 const tree = std.zig.parse(fmt.allocator, source_code) catch |err| {742 const tree = std.zig.parse(fmt.allocator, source_code) catch |err| {
742 try stderr.print("error parsing file '{}': {}\n", file_path, err);743 try stderr.print("error parsing file '{}': {}\n", file_path, err);