aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-10-04 18:00:21 -0400
committerGitHub <noreply@github.com>2020-10-04 18:00:21 -0400
commit302a69f127ae8542f49d9cd07c7cc49f3bbd6181 (patch)
tree063f062e7701e4679a0e97ad1a25021294663640 /src/Compilation.zig
parent0e2d858d69ee1595bb58d936f83f0e0248d54d68 (diff)
parent6d3858dc8a5e5d510a6c9cc972357dda551628b3 (diff)
downloadzig-302a69f127ae8542f49d9cd07c7cc49f3bbd6181.tar.gz
zig-302a69f127ae8542f49d9cd07c7cc49f3bbd6181.zip
Merge pull request #6295 from Vexu/stage2
Stage2: basic imports
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,
+ };
+ }
}
}