diff options
| author | Vexu <git@vexu.eu> | 2020-09-30 18:02:00 +0300 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-09-30 18:03:10 +0300 |
| commit | 6d3858dc8a5e5d510a6c9cc972357dda551628b3 (patch) | |
| tree | ba3a2c2147601a7fa39eb4b71897bd33a7b1a5d1 /src/Compilation.zig | |
| parent | d819da4350cc4325a7281ebeaf6057586b8eb0d7 (diff) | |
| download | zig-6d3858dc8a5e5d510a6c9cc972357dda551628b3.tar.gz zig-6d3858dc8a5e5d510a6c9cc972357dda551628b3.zip | |
stage2: use directory handles for imports
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 623635a6b0..71d91b8d2a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -8,6 +8,7 @@ const log = std.log.scoped(.compilation); const Target = std.Target; const Value = @import("value.zig").Value; +const Type = @import("type.zig").Type; const target_util = @import("target.zig"); const Package = @import("Package.zig"); const link = @import("link.zig"); @@ -638,15 +639,19 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { const root_scope = rs: { if (mem.endsWith(u8, root_pkg.root_src_path, ".zig")) { + const struct_payload = try gpa.create(Type.Payload.EmptyStruct); const root_scope = try gpa.create(Module.Scope.File); + struct_payload.* = .{ .scope = &root_scope.root_container }; root_scope.* = .{ - .sub_file_path = root_pkg.root_src_path, + // TODO this is duped so it can be freed in Container.deinit + .sub_file_path = try gpa.dupe(u8, root_pkg.root_src_path), .source = .{ .unloaded = {} }, .contents = .{ .not_available = {} }, .status = .never_loaded, .root_container = .{ .file_scope = root_scope, .decls = .{}, + .ty = Type.initPayload(&struct_payload.base), }, }; break :rs &root_scope.base; @@ -1022,6 +1027,17 @@ pub fn update(self: *Compilation) !void { else => |e| return e, }; } + + // TODO only analyze imports if they are still referenced + for (module.import_table.items()) |entry| { + entry.value.unload(module.gpa); + module.analyzeContainer(&entry.value.root_container) catch |err| switch (err) { + error.AnalysisFail => { + assert(self.totalErrorCount() != 0); + }, + else => |e| return e, + }; + } } } |
