aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 5288dad0d0..16a475b2fc 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");
@@ -640,15 +641,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;
@@ -1025,6 +1030,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,
+ };
+ }
}
}