Skip to content

Commit fc29240

Browse files
authored
Merge pull request #20964 from mlugg/the-great-decl-split-mk2
compiler: split `Decl` into `Nav` and `Cau`
2 parents 531cd17 + 153e7d6 commit fc29240

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6455
-7288
lines changed

src/Compilation.zig

Lines changed: 76 additions & 151 deletions
Large diffs are not rendered by default.

src/InternPool.zig

Lines changed: 964 additions & 523 deletions
Large diffs are not rendered by default.

src/Sema.zig

Lines changed: 1054 additions & 1088 deletions
Large diffs are not rendered by default.

src/Sema/bitcast.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const UnpackValueBits = struct {
254254
.error_set_type,
255255
.inferred_error_set_type,
256256
.variable,
257-
.extern_func,
257+
.@"extern",
258258
.func,
259259
.err,
260260
.error_union,

src/Sema/comptime_ptr_access.zig

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,23 @@ fn loadComptimePtrInner(
217217
};
218218

219219
const base_val: MutableValue = switch (ptr.base_addr) {
220-
.decl => |decl_index| val: {
221-
try sema.declareDependency(.{ .decl_val = decl_index });
222-
try sema.ensureDeclAnalyzed(decl_index);
223-
const decl = zcu.declPtr(decl_index);
224-
if (decl.val.getVariable(zcu) != null) return .runtime_load;
225-
break :val .{ .interned = decl.val.toIntern() };
220+
.nav => |nav| val: {
221+
try sema.declareDependency(.{ .nav_val = nav });
222+
try sema.ensureNavResolved(src, nav);
223+
const val = ip.getNav(nav).status.resolved.val;
224+
switch (ip.indexToKey(val)) {
225+
.variable => return .runtime_load,
226+
// We let `.@"extern"` through here if it's a function.
227+
// This allows you to alias `extern fn`s.
228+
.@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .Fn)
229+
break :val .{ .interned = val }
230+
else
231+
return .runtime_load,
232+
else => break :val .{ .interned = val },
233+
}
226234
},
227235
.comptime_alloc => |alloc_index| sema.getComptimeAlloc(alloc_index).val,
228-
.anon_decl => |anon_decl| .{ .interned = anon_decl.val },
236+
.uav => |uav| .{ .interned = uav.val },
229237
.comptime_field => |val| .{ .interned = val },
230238
.int => return .runtime_load,
231239
.eu_payload => |base_ptr_ip| val: {
@@ -580,7 +588,7 @@ fn prepareComptimePtrStore(
580588

581589
// `base_strat` will not be an error case.
582590
const base_strat: ComptimeStoreStrategy = switch (ptr.base_addr) {
583-
.decl, .anon_decl, .int => return .runtime_store,
591+
.nav, .uav, .int => return .runtime_store,
584592
.comptime_field => return .comptime_field,
585593
.comptime_alloc => |alloc_index| .{ .direct = .{
586594
.alloc = alloc_index,

0 commit comments

Comments
 (0)