authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-10-01 17:45:13-05:00
committergravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-10-02 15:21:49-05:00
log272bad3f12a43e3613498080b6b656de5e28e2cf
tree8257a0a5416d6f70656ad441a12e2cb4a151fd18
parentfd60012c21360202a74b17d87d230a18d56edc88

Delete Module.Scope, move Block into Sema


12 files changed, 943 insertions(+), 1073 deletions(-)

src/Compilation.zig+6-6
......@@ -54,7 +54,7 @@ c_object_work_queue: std.fifo.LinearFifo(*CObject, .Dynamic),
5454/// These jobs are to tokenize, parse, and astgen files, which may be outdated
5555/// since the last compilation, as well as scan for `@import` and queue up
5656/// additional jobs corresponding to those new files.
57astgen_work_queue: std.fifo.LinearFifo(*Module.Scope.File, .Dynamic),
57astgen_work_queue: std.fifo.LinearFifo(*Module.File, .Dynamic),
5858
5959/// The ErrorMsg memory is owned by the `CObject`, using Compilation's general purpose allocator.
6060/// This data is accessed by multiple threads and is protected by `mutex`.
......@@ -446,7 +446,7 @@ pub const AllErrors = struct {
446446 pub fn addZir(
447447 arena: *Allocator,
448448 errors: *std.ArrayList(Message),
449 file: *Module.Scope.File,
449 file: *Module.File,
450450 ) !void {
451451 assert(file.zir_loaded);
452452 assert(file.tree_loaded);
......@@ -1444,7 +1444,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
14441444 .emit_docs = options.emit_docs,
14451445 .work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa),
14461446 .c_object_work_queue = std.fifo.LinearFifo(*CObject, .Dynamic).init(gpa),
1447 .astgen_work_queue = std.fifo.LinearFifo(*Module.Scope.File, .Dynamic).init(gpa),
1447 .astgen_work_queue = std.fifo.LinearFifo(*Module.File, .Dynamic).init(gpa),
14481448 .keep_source_files_loaded = options.keep_source_files_loaded,
14491449 .use_clang = use_clang,
14501450 .clang_argv = options.clang_argv,
......@@ -2465,14 +2465,14 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
24652465const AstGenSrc = union(enum) {
24662466 root,
24672467 import: struct {
2468 importing_file: *Module.Scope.File,
2468 importing_file: *Module.File,
24692469 import_tok: std.zig.Ast.TokenIndex,
24702470 },
24712471};
24722472
24732473fn workerAstGenFile(
24742474 comp: *Compilation,
2475 file: *Module.Scope.File,
2475 file: *Module.File,
24762476 prog_node: *std.Progress.Node,
24772477 wg: *WaitGroup,
24782478 src: AstGenSrc,
......@@ -2742,7 +2742,7 @@ fn reportRetryableCObjectError(
27422742fn reportRetryableAstGenError(
27432743 comp: *Compilation,
27442744 src: AstGenSrc,
2745 file: *Module.Scope.File,
2745 file: *Module.File,
27462746 err: anyerror,
27472747) error{OutOfMemory}!void {
27482748 const mod = comp.bin_file.options.module.?;
src/Module.zig+276-684
......@@ -59,7 +59,7 @@ export_owners: std.AutoArrayHashMapUnmanaged(*Decl, []*Export) = .{},
5959/// over it and check which source files have been modified on the file system when
6060/// an update is requested, as well as to cache `@import` results.
6161/// Keys are fully resolved file paths. This table owns the keys and values.
62import_table: std.StringArrayHashMapUnmanaged(*Scope.File) = .{},
62import_table: std.StringArrayHashMapUnmanaged(*File) = .{},
6363
6464/// The set of all the generic function instantiations. This is used so that when a generic
6565/// function is called twice with the same comptime parameter arguments, both calls dispatch
......@@ -85,8 +85,8 @@ failed_decls: std.AutoArrayHashMapUnmanaged(*Decl, *ErrorMsg) = .{},
8585/// The value is the AST node index offset from the Decl.
8686compile_log_decls: std.AutoArrayHashMapUnmanaged(*Decl, i32) = .{},
8787/// Using a map here for consistency with the other fields here.
88/// The ErrorMsg memory is owned by the `Scope.File`, using Module's general purpose allocator.
89failed_files: std.AutoArrayHashMapUnmanaged(*Scope.File, ?*ErrorMsg) = .{},
88/// The ErrorMsg memory is owned by the `File`, using Module's general purpose allocator.
89failed_files: std.AutoArrayHashMapUnmanaged(*File, ?*ErrorMsg) = .{},
9090/// Using a map here for consistency with the other fields here.
9191/// The ErrorMsg memory is owned by the `Export`, using Module's general purpose allocator.
9292failed_exports: std.AutoArrayHashMapUnmanaged(*Export, *ErrorMsg) = .{},
......@@ -350,7 +350,7 @@ pub const Decl = struct {
350350 /// Reference to externally owned memory.
351351 /// In the case of the Decl corresponding to a file, this is
352352 /// the namespace of the struct, since there is no parent.
353 src_namespace: *Scope.Namespace,
353 src_namespace: *Namespace,
354354
355355 /// The scope which lexically contains this decl. A decl must depend
356356 /// on its lexical parent, in order to ensure that this pointer is valid.
......@@ -690,7 +690,7 @@ pub const Decl = struct {
690690 /// Gets the namespace that this Decl creates by being a struct, union,
691691 /// enum, or opaque.
692692 /// Only returns it if the Decl is the owner.
693 pub fn getInnerNamespace(decl: *Decl) ?*Scope.Namespace {
693 pub fn getInnerNamespace(decl: *Decl) ?*Namespace {
694694 if (!decl.owns_tv) return null;
695695 const ty = (decl.val.castTag(.ty) orelse return null).data;
696696 switch (ty.tag()) {
......@@ -735,7 +735,7 @@ pub const Decl = struct {
735735 std.debug.print("\n", .{});
736736 }
737737
738 pub fn getFileScope(decl: Decl) *Scope.File {
738 pub fn getFileScope(decl: Decl) *File {
739739 return decl.src_namespace.file_scope;
740740 }
741741
......@@ -787,7 +787,7 @@ pub const Struct = struct {
787787 /// Set of field names in declaration order.
788788 fields: std.StringArrayHashMapUnmanaged(Field),
789789 /// Represents the declarations inside this struct.
790 namespace: Scope.Namespace,
790 namespace: Namespace,
791791 /// Offset from `owner_decl`, points to the struct AST node.
792792 node_offset: i32,
793793 /// Index of the struct_decl ZIR instruction.
......@@ -909,7 +909,7 @@ pub const EnumFull = struct {
909909 /// If this hash map is empty, it means the enum tags are auto-numbered.
910910 values: ValueMap,
911911 /// Represents the declarations inside this enum.
912 namespace: Scope.Namespace,
912 namespace: Namespace,
913913 /// Offset from `owner_decl`, points to the enum decl AST node.
914914 node_offset: i32,
915915
......@@ -937,7 +937,7 @@ pub const Union = struct {
937937 /// Set of field names in declaration order.
938938 fields: std.StringArrayHashMapUnmanaged(Field),
939939 /// Represents the declarations inside this union.
940 namespace: Scope.Namespace,
940 namespace: Namespace,
941941 /// Offset from `owner_decl`, points to the union decl AST node.
942942 node_offset: i32,
943943 /// Index of the union_decl ZIR instruction.
......@@ -1081,668 +1081,312 @@ pub const Var = struct {
10811081 is_threadlocal: bool,
10821082};
10831083
1084pub const Scope = struct {
1085 tag: Tag,
1084/// The container that structs, enums, unions, and opaques have.
1085pub const Namespace = struct {
1086 parent: ?*Namespace,
1087 file_scope: *File,
1088 /// Will be a struct, enum, union, or opaque.
1089 ty: Type,
1090 /// Direct children of the namespace. Used during an update to detect
1091 /// which decls have been added/removed from source.
1092 /// Declaration order is preserved via entry order.
1093 /// Key memory is owned by `decl.name`.
1094 /// TODO save memory with https://github.com/ziglang/zig/issues/8619.
1095 /// Anonymous decls are not stored here; they are kept in `anon_decls` instead.
1096 decls: std.StringArrayHashMapUnmanaged(*Decl) = .{},
10861097
1087 pub fn cast(base: *Scope, comptime T: type) ?*T {
1088 if (base.tag != T.base_tag)
1089 return null;
1098 anon_decls: std.AutoArrayHashMapUnmanaged(*Decl, void) = .{},
10901099
1091 return @fieldParentPtr(T, "base", base);
1092 }
1100 /// Key is usingnamespace Decl itself. To find the namespace being included,
1101 /// the Decl Value has to be resolved as a Type which has a Namespace.
1102 /// Value is whether the usingnamespace decl is marked `pub`.
1103 usingnamespace_set: std.AutoHashMapUnmanaged(*Decl, bool) = .{},
10931104
1094 /// Get the decl which contains this decl, for the purposes of source reporting
1095 pub fn srcDecl(scope: *Scope) ?*Decl {
1096 return switch (scope.tag) {
1097 .block => scope.cast(Block).?.src_decl,
1098 .file => null,
1099 .namespace => scope.cast(Namespace).?.getDecl(),
1100 };
1105 pub fn deinit(ns: *Namespace, mod: *Module) void {
1106 ns.destroyDecls(mod);
1107 ns.* = undefined;
11011108 }
11021109
1103 /// Get the scope which contains this decl, for resolving closure_get instructions.
1104 pub fn srcScope(scope: *Scope) ?*CaptureScope {
1105 return switch (scope.tag) {
1106 .block => scope.cast(Block).?.wip_capture_scope,
1107 .file => null,
1108 .namespace => scope.cast(Namespace).?.getDecl().src_scope,
1109 };
1110 }
1110 pub fn destroyDecls(ns: *Namespace, mod: *Module) void {
1111 const gpa = mod.gpa;
11111112
1112 /// Asserts the scope has a parent which is a Namespace and returns it.
1113 pub fn namespace(scope: *Scope) *Namespace {
1114 switch (scope.tag) {
1115 .block => return scope.cast(Block).?.namespace,
1116 .file => return scope.cast(File).?.root_decl.?.src_namespace,
1117 .namespace => return scope.cast(Namespace).?,
1118 }
1119 }
1113 log.debug("destroyDecls {*}", .{ns});
11201114
1121 /// Asserts the scope has a parent which is a Namespace or File and
1122 /// returns the sub_file_path field.
1123 pub fn subFilePath(base: *Scope) []const u8 {
1124 switch (base.tag) {
1125 .namespace => return @fieldParentPtr(Namespace, "base", base).file_scope.sub_file_path,
1126 .file => return @fieldParentPtr(File, "base", base).sub_file_path,
1127 .block => unreachable,
1128 }
1129 }
1115 var decls = ns.decls;
1116 ns.decls = .{};
11301117
1131 /// When called from inside a Block Scope, chases the namespace, not the owner_decl.
1132 pub fn getFileScope(base: *Scope) *Scope.File {
1133 var cur = base;
1134 while (true) {
1135 cur = switch (cur.tag) {
1136 .namespace => return @fieldParentPtr(Namespace, "base", cur).file_scope,
1137 .file => return @fieldParentPtr(File, "base", cur),
1138 .block => return @fieldParentPtr(Block, "base", cur).namespace.file_scope,
1139 };
1140 }
1141 }
1118 var anon_decls = ns.anon_decls;
1119 ns.anon_decls = .{};
11421120
1143 pub const Tag = enum {
1144 /// .zig source code.
1145 file,
1146 /// Namespace owned by structs, enums, unions, and opaques for decls.
1147 namespace,
1148 block,
1149 };
1150
1151 /// The container that structs, enums, unions, and opaques have.
1152 pub const Namespace = struct {
1153 pub const base_tag: Tag = .namespace;
1154 base: Scope = Scope{ .tag = base_tag },
1155
1156 parent: ?*Namespace,
1157 file_scope: *Scope.File,
1158 /// Will be a struct, enum, union, or opaque.
1159 ty: Type,
1160 /// Direct children of the namespace. Used during an update to detect
1161 /// which decls have been added/removed from source.
1162 /// Declaration order is preserved via entry order.
1163 /// Key memory is owned by `decl.name`.
1164 /// TODO save memory with https://github.com/ziglang/zig/issues/8619.
1165 /// Anonymous decls are not stored here; they are kept in `anon_decls` instead.
1166 decls: std.StringArrayHashMapUnmanaged(*Decl) = .{},
1167
1168 anon_decls: std.AutoArrayHashMapUnmanaged(*Decl, void) = .{},
1169
1170 /// Key is usingnamespace Decl itself. To find the namespace being included,
1171 /// the Decl Value has to be resolved as a Type which has a Namespace.
1172 /// Value is whether the usingnamespace decl is marked `pub`.
1173 usingnamespace_set: std.AutoHashMapUnmanaged(*Decl, bool) = .{},
1174
1175 pub fn deinit(ns: *Namespace, mod: *Module) void {
1176 ns.destroyDecls(mod);
1177 ns.* = undefined;
1121 for (decls.values()) |value| {
1122 value.destroy(mod);
11781123 }
1124 decls.deinit(gpa);
11791125
1180 pub fn destroyDecls(ns: *Namespace, mod: *Module) void {
1181 const gpa = mod.gpa;
1182
1183 log.debug("destroyDecls {*}", .{ns});
1184
1185 var decls = ns.decls;
1186 ns.decls = .{};
1187
1188 var anon_decls = ns.anon_decls;
1189 ns.anon_decls = .{};
1190
1191 for (decls.values()) |value| {
1192 value.destroy(mod);
1193 }
1194 decls.deinit(gpa);
1195
1196 for (anon_decls.keys()) |key| {
1197 key.destroy(mod);
1198 }
1199 anon_decls.deinit(gpa);
1126 for (anon_decls.keys()) |key| {
1127 key.destroy(mod);
12001128 }
1129 anon_decls.deinit(gpa);
1130 }
12011131
1202 pub fn deleteAllDecls(
1203 ns: *Namespace,
1204 mod: *Module,
1205 outdated_decls: ?*std.AutoArrayHashMap(*Decl, void),
1206 ) !void {
1207 const gpa = mod.gpa;
1208
1209 log.debug("deleteAllDecls {*}", .{ns});
1210
1211 var decls = ns.decls;
1212 ns.decls = .{};
1132 pub fn deleteAllDecls(
1133 ns: *Namespace,
1134 mod: *Module,
1135 outdated_decls: ?*std.AutoArrayHashMap(*Decl, void),
1136 ) !void {
1137 const gpa = mod.gpa;
12131138
1214 var anon_decls = ns.anon_decls;
1215 ns.anon_decls = .{};
1139 log.debug("deleteAllDecls {*}", .{ns});
12161140
1217 // TODO rework this code to not panic on OOM.
1218 // (might want to coordinate with the clearDecl function)
1141 var decls = ns.decls;
1142 ns.decls = .{};
12191143
1220 for (decls.values()) |child_decl| {
1221 mod.clearDecl(child_decl, outdated_decls) catch @panic("out of memory");
1222 child_decl.destroy(mod);
1223 }
1224 decls.deinit(gpa);
1144 var anon_decls = ns.anon_decls;
1145 ns.anon_decls = .{};
12251146
1226 for (anon_decls.keys()) |child_decl| {
1227 mod.clearDecl(child_decl, outdated_decls) catch @panic("out of memory");
1228 child_decl.destroy(mod);
1229 }
1230 anon_decls.deinit(gpa);
1231 }
1147 // TODO rework this code to not panic on OOM.
1148 // (might want to coordinate with the clearDecl function)
12321149
1233 // This renders e.g. "std.fs.Dir.OpenOptions"
1234 pub fn renderFullyQualifiedName(
1235 ns: Namespace,
1236 name: []const u8,
1237 writer: anytype,
1238 ) @TypeOf(writer).Error!void {
1239 if (ns.parent) |parent| {
1240 const decl = ns.getDecl();
1241 try parent.renderFullyQualifiedName(mem.spanZ(decl.name), writer);
1242 } else {
1243 try ns.file_scope.renderFullyQualifiedName(writer);
1244 }
1245 if (name.len != 0) {
1246 try writer.writeAll(".");
1247 try writer.writeAll(name);
1248 }
1150 for (decls.values()) |child_decl| {
1151 mod.clearDecl(child_decl, outdated_decls) catch @panic("out of memory");
1152 child_decl.destroy(mod);
12491153 }
1154 decls.deinit(gpa);
12501155
1251 /// This renders e.g. "std/fs.zig:Dir.OpenOptions"
1252 pub fn renderFullyQualifiedDebugName(
1253 ns: Namespace,
1254 name: []const u8,
1255 writer: anytype,
1256 ) @TypeOf(writer).Error!void {
1257 var separator_char: u8 = '.';
1258 if (ns.parent) |parent| {
1259 const decl = ns.getDecl();
1260 try parent.renderFullyQualifiedDebugName(mem.spanZ(decl.name), writer);
1261 } else {
1262 try ns.file_scope.renderFullyQualifiedDebugName(writer);
1263 separator_char = ':';
1264 }
1265 if (name.len != 0) {
1266 try writer.writeByte(separator_char);
1267 try writer.writeAll(name);
1268 }
1156 for (anon_decls.keys()) |child_decl| {
1157 mod.clearDecl(child_decl, outdated_decls) catch @panic("out of memory");
1158 child_decl.destroy(mod);
12691159 }
1270
1271 pub fn getDecl(ns: Namespace) *Decl {
1272 return ns.ty.getOwnerDecl();
1160 anon_decls.deinit(gpa);
1161 }
1162
1163 // This renders e.g. "std.fs.Dir.OpenOptions"
1164 pub fn renderFullyQualifiedName(
1165 ns: Namespace,
1166 name: []const u8,
1167 writer: anytype,
1168 ) @TypeOf(writer).Error!void {
1169 if (ns.parent) |parent| {
1170 const decl = ns.getDecl();
1171 try parent.renderFullyQualifiedName(mem.spanZ(decl.name), writer);
1172 } else {
1173 try ns.file_scope.renderFullyQualifiedName(writer);
12731174 }
1274 };
1275
1276 pub const File = struct {
1277 pub const base_tag: Tag = .file;
1278 base: Scope = Scope{ .tag = base_tag },
1279 status: enum {
1280 never_loaded,
1281 retryable_failure,
1282 parse_failure,
1283 astgen_failure,
1284 success_zir,
1285 },
1286 source_loaded: bool,
1287 tree_loaded: bool,
1288 zir_loaded: bool,
1289 /// Relative to the owning package's root_src_dir.
1290 /// Memory is stored in gpa, owned by File.
1291 sub_file_path: []const u8,
1292 /// Whether this is populated depends on `source_loaded`.
1293 source: [:0]const u8,
1294 /// Whether this is populated depends on `status`.
1295 stat_size: u64,
1296 /// Whether this is populated depends on `status`.
1297 stat_inode: std.fs.File.INode,
1298 /// Whether this is populated depends on `status`.
1299 stat_mtime: i128,
1300 /// Whether this is populated or not depends on `tree_loaded`.
1301 tree: Ast,
1302 /// Whether this is populated or not depends on `zir_loaded`.
1303 zir: Zir,
1304 /// Package that this file is a part of, managed externally.
1305 pkg: *Package,
1306 /// The Decl of the struct that represents this File.
1307 root_decl: ?*Decl,
1308
1309 /// Used by change detection algorithm, after astgen, contains the
1310 /// set of decls that existed in the previous ZIR but not in the new one.
1311 deleted_decls: std.ArrayListUnmanaged(*Decl) = .{},
1312 /// Used by change detection algorithm, after astgen, contains the
1313 /// set of decls that existed both in the previous ZIR and in the new one,
1314 /// but their source code has been modified.
1315 outdated_decls: std.ArrayListUnmanaged(*Decl) = .{},
1316
1317 /// The most recent successful ZIR for this file, with no errors.
1318 /// This is only populated when a previously successful ZIR
1319 /// newly introduces compile errors during an update. When ZIR is
1320 /// successful, this field is unloaded.
1321 prev_zir: ?*Zir = null,
1322
1323 pub fn unload(file: *File, gpa: *Allocator) void {
1324 file.unloadTree(gpa);
1325 file.unloadSource(gpa);
1326 file.unloadZir(gpa);
1175 if (name.len != 0) {
1176 try writer.writeAll(".");
1177 try writer.writeAll(name);
13271178 }
1179 }
13281180
1329 pub fn unloadTree(file: *File, gpa: *Allocator) void {
1330 if (file.tree_loaded) {
1331 file.tree_loaded = false;
1332 file.tree.deinit(gpa);
1333 }
1181 /// This renders e.g. "std/fs.zig:Dir.OpenOptions"
1182 pub fn renderFullyQualifiedDebugName(
1183 ns: Namespace,
1184 name: []const u8,
1185 writer: anytype,
1186 ) @TypeOf(writer).Error!void {
1187 var separator_char: u8 = '.';
1188 if (ns.parent) |parent| {
1189 const decl = ns.getDecl();
1190 try parent.renderFullyQualifiedDebugName(mem.spanZ(decl.name), writer);
1191 } else {
1192 try ns.file_scope.renderFullyQualifiedDebugName(writer);
1193 separator_char = ':';
13341194 }
1335
1336 pub fn unloadSource(file: *File, gpa: *Allocator) void {
1337 if (file.source_loaded) {
1338 file.source_loaded = false;
1339 gpa.free(file.source);
1340 }
1195 if (name.len != 0) {
1196 try writer.writeByte(separator_char);
1197 try writer.writeAll(name);
13411198 }
1199 }
13421200
1343 pub fn unloadZir(file: *File, gpa: *Allocator) void {
1344 if (file.zir_loaded) {
1345 file.zir_loaded = false;
1346 file.zir.deinit(gpa);
1347 }
1348 }
1201 pub fn getDecl(ns: Namespace) *Decl {
1202 return ns.ty.getOwnerDecl();
1203 }
1204};
13491205
1350 pub fn deinit(file: *File, mod: *Module) void {
1351 const gpa = mod.gpa;
1352 log.debug("deinit File {s}", .{file.sub_file_path});
1353 file.deleted_decls.deinit(gpa);
1354 file.outdated_decls.deinit(gpa);
1355 if (file.root_decl) |root_decl| {
1356 root_decl.destroy(mod);
1357 }
1358 gpa.free(file.sub_file_path);
1359 file.unload(gpa);
1360 if (file.prev_zir) |prev_zir| {
1361 prev_zir.deinit(gpa);
1362 gpa.destroy(prev_zir);
1363 }
1364 file.* = undefined;
1206pub const File = struct {
1207 status: enum {
1208 never_loaded,
1209 retryable_failure,
1210 parse_failure,
1211 astgen_failure,
1212 success_zir,
1213 },
1214 source_loaded: bool,
1215 tree_loaded: bool,
1216 zir_loaded: bool,
1217 /// Relative to the owning package's root_src_dir.
1218 /// Memory is stored in gpa, owned by File.
1219 sub_file_path: []const u8,
1220 /// Whether this is populated depends on `source_loaded`.
1221 source: [:0]const u8,
1222 /// Whether this is populated depends on `status`.
1223 stat_size: u64,
1224 /// Whether this is populated depends on `status`.
1225 stat_inode: std.fs.File.INode,
1226 /// Whether this is populated depends on `status`.
1227 stat_mtime: i128,
1228 /// Whether this is populated or not depends on `tree_loaded`.
1229 tree: Ast,
1230 /// Whether this is populated or not depends on `zir_loaded`.
1231 zir: Zir,
1232 /// Package that this file is a part of, managed externally.
1233 pkg: *Package,
1234 /// The Decl of the struct that represents this File.
1235 root_decl: ?*Decl,
1236
1237 /// Used by change detection algorithm, after astgen, contains the
1238 /// set of decls that existed in the previous ZIR but not in the new one.
1239 deleted_decls: std.ArrayListUnmanaged(*Decl) = .{},
1240 /// Used by change detection algorithm, after astgen, contains the
1241 /// set of decls that existed both in the previous ZIR and in the new one,
1242 /// but their source code has been modified.
1243 outdated_decls: std.ArrayListUnmanaged(*Decl) = .{},
1244
1245 /// The most recent successful ZIR for this file, with no errors.
1246 /// This is only populated when a previously successful ZIR
1247 /// newly introduces compile errors during an update. When ZIR is
1248 /// successful, this field is unloaded.
1249 prev_zir: ?*Zir = null,
1250
1251 pub fn unload(file: *File, gpa: *Allocator) void {
1252 file.unloadTree(gpa);
1253 file.unloadSource(gpa);
1254 file.unloadZir(gpa);
1255 }
1256
1257 pub fn unloadTree(file: *File, gpa: *Allocator) void {
1258 if (file.tree_loaded) {
1259 file.tree_loaded = false;
1260 file.tree.deinit(gpa);
13651261 }
1262 }
13661263
1367 pub fn getSource(file: *File, gpa: *Allocator) ![:0]const u8 {
1368 if (file.source_loaded) return file.source;
1369
1370 const root_dir_path = file.pkg.root_src_directory.path orelse ".";
1371 log.debug("File.getSource, not cached. pkgdir={s} sub_file_path={s}", .{
1372 root_dir_path, file.sub_file_path,
1373 });
1374
1375 // Keep track of inode, file size, mtime, hash so we can detect which files
1376 // have been modified when an incremental update is requested.
1377 var f = try file.pkg.root_src_directory.handle.openFile(file.sub_file_path, .{});
1378 defer f.close();
1379
1380 const stat = try f.stat();
1381
1382 if (stat.size > std.math.maxInt(u32))
1383 return error.FileTooBig;
1384
1385 const source = try gpa.allocSentinel(u8, @intCast(usize, stat.size), 0);
1386 defer if (!file.source_loaded) gpa.free(source);
1387 const amt = try f.readAll(source);
1388 if (amt != stat.size)
1389 return error.UnexpectedEndOfFile;
1390
1391 // Here we do not modify stat fields because this function is the one
1392 // used for error reporting. We need to keep the stat fields stale so that
1393 // astGenFile can know to regenerate ZIR.
1394
1395 file.source = source;
1396 file.source_loaded = true;
1397 return source;
1264 pub fn unloadSource(file: *File, gpa: *Allocator) void {
1265 if (file.source_loaded) {
1266 file.source_loaded = false;
1267 gpa.free(file.source);
13981268 }
1269 }
13991270
1400 pub fn getTree(file: *File, gpa: *Allocator) !*const Ast {
1401 if (file.tree_loaded) return &file.tree;
1402
1403 const source = try file.getSource(gpa);
1404 file.tree = try std.zig.parse(gpa, source);
1405 file.tree_loaded = true;
1406 return &file.tree;
1271 pub fn unloadZir(file: *File, gpa: *Allocator) void {
1272 if (file.zir_loaded) {
1273 file.zir_loaded = false;
1274 file.zir.deinit(gpa);
14071275 }
1276 }
14081277
1409 pub fn destroy(file: *File, mod: *Module) void {
1410 const gpa = mod.gpa;
1411 file.deinit(mod);
1412 gpa.destroy(file);
1278 pub fn deinit(file: *File, mod: *Module) void {
1279 const gpa = mod.gpa;
1280 log.debug("deinit File {s}", .{file.sub_file_path});
1281 file.deleted_decls.deinit(gpa);
1282 file.outdated_decls.deinit(gpa);
1283 if (file.root_decl) |root_decl| {
1284 root_decl.destroy(mod);
14131285 }
1414
1415 pub fn renderFullyQualifiedName(file: File, writer: anytype) !void {
1416 // Convert all the slashes into dots and truncate the extension.
1417 const ext = std.fs.path.extension(file.sub_file_path);
1418 const noext = file.sub_file_path[0 .. file.sub_file_path.len - ext.len];
1419 for (noext) |byte| switch (byte) {
1420 '/', '\\' => try writer.writeByte('.'),
1421 else => try writer.writeByte(byte),
1422 };
1286 gpa.free(file.sub_file_path);
1287 file.unload(gpa);
1288 if (file.prev_zir) |prev_zir| {
1289 prev_zir.deinit(gpa);
1290 gpa.destroy(prev_zir);
14231291 }
1292 file.* = undefined;
1293 }
14241294
1425 pub fn renderFullyQualifiedDebugName(file: File, writer: anytype) !void {
1426 for (file.sub_file_path) |byte| switch (byte) {
1427 '/', '\\' => try writer.writeByte('/'),
1428 else => try writer.writeByte(byte),
1429 };
1430 }
1295 pub fn getSource(file: *File, gpa: *Allocator) ![:0]const u8 {
1296 if (file.source_loaded) return file.source;
14311297
1432 pub fn fullyQualifiedNameZ(file: File, gpa: *Allocator) ![:0]u8 {
1433 var buf = std.ArrayList(u8).init(gpa);
1434 defer buf.deinit();
1435 try file.renderFullyQualifiedName(buf.writer());
1436 return buf.toOwnedSliceSentinel(0);
1437 }
1298 const root_dir_path = file.pkg.root_src_directory.path orelse ".";
1299 log.debug("File.getSource, not cached. pkgdir={s} sub_file_path={s}", .{
1300 root_dir_path, file.sub_file_path,
1301 });
14381302
1439 /// Returns the full path to this file relative to its package.
1440 pub fn fullPath(file: File, ally: *Allocator) ![]u8 {
1441 return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path});
1442 }
1303 // Keep track of inode, file size, mtime, hash so we can detect which files
1304 // have been modified when an incremental update is requested.
1305 var f = try file.pkg.root_src_directory.handle.openFile(file.sub_file_path, .{});
1306 defer f.close();
14431307
1444 pub fn dumpSrc(file: *File, src: LazySrcLoc) void {
1445 const loc = std.zig.findLineColumn(file.source.bytes, src);
1446 std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });
1447 }
1308 const stat = try f.stat();
14481309
1449 pub fn okToReportErrors(file: File) bool {
1450 return switch (file.status) {
1451 .parse_failure, .astgen_failure => false,
1452 else => true,
1453 };
1454 }
1455 };
1310 if (stat.size > std.math.maxInt(u32))
1311 return error.FileTooBig;
14561312
1457 /// This is the context needed to semantically analyze ZIR instructions and
1458 /// produce AIR instructions.
1459 /// This is a temporary structure stored on the stack; references to it are valid only
1460 /// during semantic analysis of the block.
1461 pub const Block = struct {
1462 pub const base_tag: Tag = .block;
1463
1464 base: Scope = Scope{ .tag = base_tag },
1465 parent: ?*Block,
1466 /// Shared among all child blocks.
1467 sema: *Sema,
1468 /// This Decl is the Decl according to the Zig source code corresponding to this Block.
1469 /// This can vary during inline or comptime function calls. See `Sema.owner_decl`
1470 /// for the one that will be the same for all Block instances.
1471 src_decl: *Decl,
1472 /// The namespace to use for lookups from this source block
1473 /// When analyzing fields, this is different from src_decl.src_namepsace.
1474 namespace: *Namespace,
1475 /// The AIR instructions generated for this block.
1476 instructions: ArrayListUnmanaged(Air.Inst.Index),
1477 // `param` instructions are collected here to be used by the `func` instruction.
1478 params: std.ArrayListUnmanaged(Param) = .{},
1479
1480 wip_capture_scope: *CaptureScope,
1481
1482 label: ?*Label = null,
1483 inlining: ?*Inlining,
1484 /// If runtime_index is not 0 then one of these is guaranteed to be non null.
1485 runtime_cond: ?LazySrcLoc = null,
1486 runtime_loop: ?LazySrcLoc = null,
1487 /// Non zero if a non-inline loop or a runtime conditional have been encountered.
1488 /// Stores to to comptime variables are only allowed when var.runtime_index <= runtime_index.
1489 runtime_index: u32 = 0,
1313 const source = try gpa.allocSentinel(u8, @intCast(usize, stat.size), 0);
1314 defer if (!file.source_loaded) gpa.free(source);
1315 const amt = try f.readAll(source);
1316 if (amt != stat.size)
1317 return error.UnexpectedEndOfFile;
14901318
1491 is_comptime: bool,
1319 // Here we do not modify stat fields because this function is the one
1320 // used for error reporting. We need to keep the stat fields stale so that
1321 // astGenFile can know to regenerate ZIR.
14921322
1493 /// when null, it is determined by build mode, changed by @setRuntimeSafety
1494 want_safety: ?bool = null,
1323 file.source = source;
1324 file.source_loaded = true;
1325 return source;
1326 }
14951327
1496 c_import_buf: ?*std.ArrayList(u8) = null,
1328 pub fn getTree(file: *File, gpa: *Allocator) !*const Ast {
1329 if (file.tree_loaded) return &file.tree;
14971330
1498 const Param = struct {
1499 /// `noreturn` means `anytype`.
1500 ty: Type,
1501 is_comptime: bool,
1502 };
1331 const source = try file.getSource(gpa);
1332 file.tree = try std.zig.parse(gpa, source);
1333 file.tree_loaded = true;
1334 return &file.tree;
1335 }
15031336
1504 /// This `Block` maps a block ZIR instruction to the corresponding
1505 /// AIR instruction for break instruction analysis.
1506 pub const Label = struct {
1507 zir_block: Zir.Inst.Index,
1508 merges: Merges,
1509 };
1337 pub fn destroy(file: *File, mod: *Module) void {
1338 const gpa = mod.gpa;
1339 file.deinit(mod);
1340 gpa.destroy(file);
1341 }
15101342
1511 /// This `Block` indicates that an inline function call is happening
1512 /// and return instructions should be analyzed as a break instruction
1513 /// to this AIR block instruction.
1514 /// It is shared among all the blocks in an inline or comptime called
1515 /// function.
1516 pub const Inlining = struct {
1517 comptime_result: Air.Inst.Ref,
1518 merges: Merges,
1343 pub fn renderFullyQualifiedName(file: File, writer: anytype) !void {
1344 // Convert all the slashes into dots and truncate the extension.
1345 const ext = std.fs.path.extension(file.sub_file_path);
1346 const noext = file.sub_file_path[0 .. file.sub_file_path.len - ext.len];
1347 for (noext) |byte| switch (byte) {
1348 '/', '\\' => try writer.writeByte('.'),
1349 else => try writer.writeByte(byte),
15191350 };
1351 }
15201352
1521 pub const Merges = struct {
1522 block_inst: Air.Inst.Index,
1523 /// Separate array list from break_inst_list so that it can be passed directly
1524 /// to resolvePeerTypes.
1525 results: ArrayListUnmanaged(Air.Inst.Ref),
1526 /// Keeps track of the break instructions so that the operand can be replaced
1527 /// if we need to add type coercion at the end of block analysis.
1528 /// Same indexes, capacity, length as `results`.
1529 br_list: ArrayListUnmanaged(Air.Inst.Index),
1353 pub fn renderFullyQualifiedDebugName(file: File, writer: anytype) !void {
1354 for (file.sub_file_path) |byte| switch (byte) {
1355 '/', '\\' => try writer.writeByte('/'),
1356 else => try writer.writeByte(byte),
15301357 };
1358 }
15311359
1532 /// For debugging purposes.
1533 pub fn dump(block: *Block, mod: Module) void {
1534 Zir.dumpBlock(mod, block);
1535 }
1536
1537 pub fn makeSubBlock(parent: *Block) Block {
1538 return .{
1539 .parent = parent,
1540 .sema = parent.sema,
1541 .src_decl = parent.src_decl,
1542 .namespace = parent.namespace,
1543 .instructions = .{},
1544 .wip_capture_scope = parent.wip_capture_scope,
1545 .label = null,
1546 .inlining = parent.inlining,
1547 .is_comptime = parent.is_comptime,
1548 .runtime_cond = parent.runtime_cond,
1549 .runtime_loop = parent.runtime_loop,
1550 .runtime_index = parent.runtime_index,
1551 .want_safety = parent.want_safety,
1552 .c_import_buf = parent.c_import_buf,
1553 };
1554 }
1555
1556 pub fn wantSafety(block: *const Block) bool {
1557 return block.want_safety orelse switch (block.sema.mod.optimizeMode()) {
1558 .Debug => true,
1559 .ReleaseSafe => true,
1560 .ReleaseFast => false,
1561 .ReleaseSmall => false,
1562 };
1563 }
1564
1565 pub fn getFileScope(block: *Block) *Scope.File {
1566 return block.namespace.file_scope;
1567 }
1568
1569 pub fn addTy(
1570 block: *Block,
1571 tag: Air.Inst.Tag,
1572 ty: Type,
1573 ) error{OutOfMemory}!Air.Inst.Ref {
1574 return block.addInst(.{
1575 .tag = tag,
1576 .data = .{ .ty = ty },
1577 });
1578 }
1579
1580 pub fn addTyOp(
1581 block: *Block,
1582 tag: Air.Inst.Tag,
1583 ty: Type,
1584 operand: Air.Inst.Ref,
1585 ) error{OutOfMemory}!Air.Inst.Ref {
1586 return block.addInst(.{
1587 .tag = tag,
1588 .data = .{ .ty_op = .{
1589 .ty = try block.sema.addType(ty),
1590 .operand = operand,
1591 } },
1592 });
1593 }
1594
1595 pub fn addNoOp(block: *Block, tag: Air.Inst.Tag) error{OutOfMemory}!Air.Inst.Ref {
1596 return block.addInst(.{
1597 .tag = tag,
1598 .data = .{ .no_op = {} },
1599 });
1600 }
1601
1602 pub fn addUnOp(
1603 block: *Block,
1604 tag: Air.Inst.Tag,
1605 operand: Air.Inst.Ref,
1606 ) error{OutOfMemory}!Air.Inst.Ref {
1607 return block.addInst(.{
1608 .tag = tag,
1609 .data = .{ .un_op = operand },
1610 });
1611 }
1612
1613 pub fn addBr(
1614 block: *Block,
1615 target_block: Air.Inst.Index,
1616 operand: Air.Inst.Ref,
1617 ) error{OutOfMemory}!Air.Inst.Ref {
1618 return block.addInst(.{
1619 .tag = .br,
1620 .data = .{ .br = .{
1621 .block_inst = target_block,
1622 .operand = operand,
1623 } },
1624 });
1625 }
1626
1627 pub fn addBinOp(
1628 block: *Block,
1629 tag: Air.Inst.Tag,
1630 lhs: Air.Inst.Ref,
1631 rhs: Air.Inst.Ref,
1632 ) error{OutOfMemory}!Air.Inst.Ref {
1633 return block.addInst(.{
1634 .tag = tag,
1635 .data = .{ .bin_op = .{
1636 .lhs = lhs,
1637 .rhs = rhs,
1638 } },
1639 });
1640 }
1641
1642 pub fn addArg(block: *Block, ty: Type, name: u32) error{OutOfMemory}!Air.Inst.Ref {
1643 return block.addInst(.{
1644 .tag = .arg,
1645 .data = .{ .ty_str = .{
1646 .ty = try block.sema.addType(ty),
1647 .str = name,
1648 } },
1649 });
1650 }
1651
1652 pub fn addStructFieldPtr(
1653 block: *Block,
1654 struct_ptr: Air.Inst.Ref,
1655 field_index: u32,
1656 ptr_field_ty: Type,
1657 ) !Air.Inst.Ref {
1658 const ty = try block.sema.addType(ptr_field_ty);
1659 const tag: Air.Inst.Tag = switch (field_index) {
1660 0 => .struct_field_ptr_index_0,
1661 1 => .struct_field_ptr_index_1,
1662 2 => .struct_field_ptr_index_2,
1663 3 => .struct_field_ptr_index_3,
1664 else => {
1665 return block.addInst(.{
1666 .tag = .struct_field_ptr,
1667 .data = .{ .ty_pl = .{
1668 .ty = ty,
1669 .payload = try block.sema.addExtra(Air.StructField{
1670 .struct_operand = struct_ptr,
1671 .field_index = @intCast(u32, field_index),
1672 }),
1673 } },
1674 });
1675 },
1676 };
1677 return block.addInst(.{
1678 .tag = tag,
1679 .data = .{ .ty_op = .{
1680 .ty = ty,
1681 .operand = struct_ptr,
1682 } },
1683 });
1684 }
1685
1686 pub fn addInst(block: *Block, inst: Air.Inst) error{OutOfMemory}!Air.Inst.Ref {
1687 return Air.indexToRef(try block.addInstAsIndex(inst));
1688 }
1689
1690 pub fn addInstAsIndex(block: *Block, inst: Air.Inst) error{OutOfMemory}!Air.Inst.Index {
1691 const sema = block.sema;
1692 const gpa = sema.gpa;
1693
1694 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
1695 try block.instructions.ensureUnusedCapacity(gpa, 1);
1696
1697 const result_index = @intCast(Air.Inst.Index, sema.air_instructions.len);
1698 sema.air_instructions.appendAssumeCapacity(inst);
1699 block.instructions.appendAssumeCapacity(result_index);
1700 return result_index;
1701 }
1702
1703 pub fn startAnonDecl(block: *Block) !WipAnonDecl {
1704 return WipAnonDecl{
1705 .block = block,
1706 .new_decl_arena = std.heap.ArenaAllocator.init(block.sema.gpa),
1707 .finished = false,
1708 };
1709 }
1710
1711 pub const WipAnonDecl = struct {
1712 block: *Scope.Block,
1713 new_decl_arena: std.heap.ArenaAllocator,
1714 finished: bool,
1360 pub fn fullyQualifiedNameZ(file: File, gpa: *Allocator) ![:0]u8 {
1361 var buf = std.ArrayList(u8).init(gpa);
1362 defer buf.deinit();
1363 try file.renderFullyQualifiedName(buf.writer());
1364 return buf.toOwnedSliceSentinel(0);
1365 }
17151366
1716 pub fn arena(wad: *WipAnonDecl) *Allocator {
1717 return &wad.new_decl_arena.allocator;
1718 }
1367 /// Returns the full path to this file relative to its package.
1368 pub fn fullPath(file: File, ally: *Allocator) ![]u8 {
1369 return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path});
1370 }
17191371
1720 pub fn deinit(wad: *WipAnonDecl) void {
1721 if (!wad.finished) {
1722 wad.new_decl_arena.deinit();
1723 }
1724 wad.* = undefined;
1725 }
1372 pub fn dumpSrc(file: *File, src: LazySrcLoc) void {
1373 const loc = std.zig.findLineColumn(file.source.bytes, src);
1374 std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });
1375 }
17261376
1727 pub fn finish(wad: *WipAnonDecl, ty: Type, val: Value) !*Decl {
1728 const new_decl = try wad.block.sema.mod.createAnonymousDecl(&wad.block.base, .{
1729 .ty = ty,
1730 .val = val,
1731 });
1732 errdefer wad.block.sema.mod.abortAnonDecl(new_decl);
1733 try new_decl.finalizeNewArena(&wad.new_decl_arena);
1734 wad.finished = true;
1735 return new_decl;
1736 }
1377 pub fn okToReportErrors(file: File) bool {
1378 return switch (file.status) {
1379 .parse_failure, .astgen_failure => false,
1380 else => true,
17371381 };
1738 };
1382 }
17391383};
17401384
17411385/// This struct holds data necessary to construct API-facing `AllErrors.Message`.
17421386/// Its memory is managed with the general purpose allocator so that they
17431387/// can be created and destroyed in response to incremental updates.
1744/// In some cases, the Scope.File could have been inferred from where the ErrorMsg
1745/// is stored. For example, if it is stored in Module.failed_decls, then the Scope.File
1388/// In some cases, the File could have been inferred from where the ErrorMsg
1389/// is stored. For example, if it is stored in Module.failed_decls, then the File
17461390/// would be determined by the Decl Scope. However, the data structure contains the field
17471391/// anyway so that `ErrorMsg` can be reused for error notes, which may be in a different
17481392/// file than the parent error message. It also simplifies processing of error messages.
......@@ -1794,7 +1438,7 @@ pub const ErrorMsg = struct {
17941438
17951439/// Canonical reference to a position within a source file.
17961440pub const SrcLoc = struct {
1797 file_scope: *Scope.File,
1441 file_scope: *File,
17981442 /// Might be 0 depending on tag of `lazy`.
17991443 parent_decl_node: Ast.Node.Index,
18001444 /// Relative to `parent_decl_node`.
......@@ -2371,60 +2015,8 @@ pub const LazySrcLoc = union(enum) {
23712015 /// The Decl is determined contextually.
23722016 node_offset_lib_name: i32,
23732017
2374 /// Upgrade to a `SrcLoc` based on the `Decl` or file in the provided scope.
2375 pub fn toSrcLoc(lazy: LazySrcLoc, block: *Scope.Block) SrcLoc {
2376 return switch (lazy) {
2377 .unneeded,
2378 .entire_file,
2379 .byte_abs,
2380 .token_abs,
2381 .node_abs,
2382 => .{
2383 .file_scope = block.getFileScope(),
2384 .parent_decl_node = 0,
2385 .lazy = lazy,
2386 },
2387
2388 .byte_offset,
2389 .token_offset,
2390 .node_offset,
2391 .node_offset_back2tok,
2392 .node_offset_var_decl_ty,
2393 .node_offset_for_cond,
2394 .node_offset_builtin_call_arg0,
2395 .node_offset_builtin_call_arg1,
2396 .node_offset_builtin_call_arg2,
2397 .node_offset_builtin_call_arg3,
2398 .node_offset_builtin_call_arg4,
2399 .node_offset_builtin_call_arg5,
2400 .node_offset_array_access_index,
2401 .node_offset_slice_sentinel,
2402 .node_offset_call_func,
2403 .node_offset_field_name,
2404 .node_offset_deref_ptr,
2405 .node_offset_asm_source,
2406 .node_offset_asm_ret_ty,
2407 .node_offset_if_cond,
2408 .node_offset_bin_op,
2409 .node_offset_bin_lhs,
2410 .node_offset_bin_rhs,
2411 .node_offset_switch_operand,
2412 .node_offset_switch_special_prong,
2413 .node_offset_switch_range,
2414 .node_offset_fn_type_cc,
2415 .node_offset_fn_type_ret_ty,
2416 .node_offset_anyframe_type,
2417 .node_offset_lib_name,
2418 => .{
2419 .file_scope = block.getFileScope(),
2420 .parent_decl_node = block.src_decl.src_node,
2421 .lazy = lazy,
2422 },
2423 };
2424 }
2425
24262018 /// Upgrade to a `SrcLoc` based on the `Decl` provided.
2427 pub fn toSrcLocWithDecl(lazy: LazySrcLoc, decl: *Decl) SrcLoc {
2019 pub fn toSrcLoc(lazy: LazySrcLoc, decl: *Decl) SrcLoc {
24282020 return switch (lazy) {
24292021 .unneeded,
24302022 .entire_file,
......@@ -2613,7 +2205,7 @@ comptime {
26132205 }
26142206}
26152207
2616pub fn astGenFile(mod: *Module, file: *Scope.File) !void {
2208pub fn astGenFile(mod: *Module, file: *File) !void {
26172209 const tracy = trace(@src());
26182210 defer tracy.end();
26192211
......@@ -2997,7 +2589,7 @@ pub fn astGenFile(mod: *Module, file: *Scope.File) !void {
29972589/// * Decl.zir_index
29982590/// * Fn.zir_body_inst
29992591/// * Decl.zir_decl_index
3000fn updateZirRefs(gpa: *Allocator, file: *Scope.File, old_zir: Zir) !void {
2592fn updateZirRefs(gpa: *Allocator, file: *File, old_zir: Zir) !void {
30012593 const new_zir = file.zir;
30022594
30032595 // Maps from old ZIR to new ZIR, struct_decl, enum_decl, etc. Any instruction which
......@@ -3253,7 +2845,7 @@ pub fn semaPkg(mod: *Module, pkg: *Package) !void {
32532845
32542846/// Regardless of the file status, will create a `Decl` so that we
32552847/// can track dependencies and re-analyze when the file becomes outdated.
3256pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void {
2848pub fn semaFile(mod: *Module, file: *File) SemaError!void {
32572849 const tracy = trace(@src());
32582850 defer tracy.end();
32592851
......@@ -3322,7 +2914,7 @@ pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void {
33222914 var wip_captures = try WipCaptureScope.init(gpa, &new_decl_arena.allocator, null);
33232915 defer wip_captures.deinit();
33242916
3325 var block_scope: Scope.Block = .{
2917 var block_scope: Sema.Block = .{
33262918 .parent = null,
33272919 .sema = &sema,
33282920 .src_decl = new_decl,
......@@ -3402,7 +2994,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
34022994 var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope);
34032995 defer wip_captures.deinit();
34042996
3405 var block_scope: Scope.Block = .{
2997 var block_scope: Sema.Block = .{
34062998 .parent = null,
34072999 .sema = &sema,
34083000 .src_decl = decl,
......@@ -3617,7 +3209,7 @@ pub fn declareDeclDependency(mod: *Module, depender: *Decl, dependee: *Decl) !vo
36173209}
36183210
36193211pub const ImportFileResult = struct {
3620 file: *Scope.File,
3212 file: *File,
36213213 is_new: bool,
36223214};
36233215
......@@ -3643,7 +3235,7 @@ pub fn importPkg(mod: *Module, pkg: *Package) !ImportFileResult {
36433235 const sub_file_path = try gpa.dupe(u8, pkg.root_src_path);
36443236 errdefer gpa.free(sub_file_path);
36453237
3646 const new_file = try gpa.create(Scope.File);
3238 const new_file = try gpa.create(File);
36473239 errdefer gpa.destroy(new_file);
36483240
36493241 gop.value_ptr.* = new_file;
......@@ -3670,7 +3262,7 @@ pub fn importPkg(mod: *Module, pkg: *Package) !ImportFileResult {
36703262
36713263pub fn importFile(
36723264 mod: *Module,
3673 cur_file: *Scope.File,
3265 cur_file: *File,
36743266 import_string: []const u8,
36753267) !ImportFileResult {
36763268 if (cur_file.pkg.table.get(import_string)) |pkg| {
......@@ -3698,7 +3290,7 @@ pub fn importFile(
36983290 };
36993291 keep_resolved_path = true; // It's now owned by import_table.
37003292
3701 const new_file = try gpa.create(Scope.File);
3293 const new_file = try gpa.create(File);
37023294 errdefer gpa.destroy(new_file);
37033295
37043296 const resolved_root_path = try std.fs.path.resolve(gpa, &[_][]const u8{cur_pkg_dir_path});
......@@ -3739,7 +3331,7 @@ pub fn importFile(
37393331
37403332pub fn scanNamespace(
37413333 mod: *Module,
3742 namespace: *Scope.Namespace,
3334 namespace: *Namespace,
37433335 extra_start: usize,
37443336 decls_len: u32,
37453337 parent_decl: *Decl,
......@@ -3783,7 +3375,7 @@ pub fn scanNamespace(
37833375
37843376const ScanDeclIter = struct {
37853377 module: *Module,
3786 namespace: *Scope.Namespace,
3378 namespace: *Namespace,
37873379 parent_decl: *Decl,
37883380 usingnamespace_index: usize = 0,
37893381 comptime_index: usize = 0,
......@@ -4146,7 +3738,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: *Allocator) Se
41463738 var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope);
41473739 defer wip_captures.deinit();
41483740
4149 var inner_block: Scope.Block = .{
3741 var inner_block: Sema.Block = .{
41503742 .parent = null,
41513743 .sema = &sema,
41523744 .src_decl = decl,
......@@ -4269,7 +3861,7 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void {
42693861 decl.analysis = .outdated;
42703862}
42713863
4272pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Scope.Namespace, src_node: Ast.Node.Index, src_scope: ?*CaptureScope) !*Decl {
3864pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, src_node: Ast.Node.Index, src_scope: ?*CaptureScope) !*Decl {
42733865 // If we have emit-h then we must allocate a bigger structure to store the emit-h state.
42743866 const new_decl: *Decl = if (mod.emit_h != null) blk: {
42753867 const parent_struct = try mod.gpa.create(DeclPlusEmitH);
......@@ -4350,21 +3942,21 @@ pub fn getErrorValue(mod: *Module, name: []const u8) !std.StringHashMapUnmanaged
43503942/// Takes ownership of `name` even if it returns an error.
43513943pub fn createAnonymousDeclNamed(
43523944 mod: *Module,
4353 scope: *Scope,
3945 block: *Sema.Block,
43543946 typed_value: TypedValue,
43553947 name: [:0]u8,
43563948) !*Decl {
4357 return mod.createAnonymousDeclFromDeclNamed(scope.srcDecl().?, scope.namespace(), scope.srcScope(), typed_value, name);
3949 return mod.createAnonymousDeclFromDeclNamed(block.src_decl, block.namespace, block.wip_capture_scope, typed_value, name);
43583950}
43593951
4360pub fn createAnonymousDecl(mod: *Module, scope: *Scope, typed_value: TypedValue) !*Decl {
4361 return mod.createAnonymousDeclFromDecl(scope.srcDecl().?, scope.namespace(), scope.srcScope(), typed_value);
3952pub fn createAnonymousDecl(mod: *Module, block: *Sema.Block, typed_value: TypedValue) !*Decl {
3953 return mod.createAnonymousDeclFromDecl(block.src_decl, block.namespace, block.wip_capture_scope, typed_value);
43623954}
43633955
43643956pub fn createAnonymousDeclFromDecl(
43653957 mod: *Module,
43663958 src_decl: *Decl,
4367 namespace: *Scope.Namespace,
3959 namespace: *Namespace,
43683960 src_scope: ?*CaptureScope,
43693961 tv: TypedValue,
43703962) !*Decl {
......@@ -4379,7 +3971,7 @@ pub fn createAnonymousDeclFromDecl(
43793971pub fn createAnonymousDeclFromDeclNamed(
43803972 mod: *Module,
43813973 src_decl: *Decl,
4382 namespace: *Scope.Namespace,
3974 namespace: *Namespace,
43833975 src_scope: ?*CaptureScope,
43843976 typed_value: TypedValue,
43853977 name: [:0]u8,
......@@ -4516,7 +4108,7 @@ pub fn optimizeMode(mod: Module) std.builtin.Mode {
45164108 return mod.comp.bin_file.options.optimize_mode;
45174109}
45184110
4519fn lockAndClearFileCompileError(mod: *Module, file: *Scope.File) void {
4111fn lockAndClearFileCompileError(mod: *Module, file: *File) void {
45204112 switch (file.status) {
45214113 .success_zir, .retryable_failure => {},
45224114 .never_loaded, .parse_failure, .astgen_failure => {
src/Sema.zig+640-360
......@@ -21,7 +21,7 @@ air_values: std.ArrayListUnmanaged(Value) = .{},
2121/// Maps ZIR to AIR.
2222inst_map: InstMap = .{},
2323/// When analyzing an inline function call, owner_decl is the Decl of the caller
24/// and `src_decl` of `Scope.Block` is the `Decl` of the callee.
24/// and `src_decl` of `Block` is the `Decl` of the callee.
2525/// This `Decl` owns the arena memory of this `Sema`.
2626owner_decl: *Decl,
2727/// For an inline or comptime function call, this will be the root parent function
......@@ -75,7 +75,7 @@ const Air = @import("Air.zig");
7575const Zir = @import("Zir.zig");
7676const Module = @import("Module.zig");
7777const trace = @import("tracy.zig").trace;
78const Scope = Module.Scope;
78const Namespace = Module.Namespace;
7979const CompileError = Module.CompileError;
8080const SemaError = Module.SemaError;
8181const Decl = Module.Decl;
......@@ -89,6 +89,286 @@ const crash_report = @import("crash_report.zig");
8989
9090pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref);
9191
92/// This is the context needed to semantically analyze ZIR instructions and
93/// produce AIR instructions.
94/// This is a temporary structure stored on the stack; references to it are valid only
95/// during semantic analysis of the block.
96pub const Block = struct {
97 parent: ?*Block,
98 /// Shared among all child blocks.
99 sema: *Sema,
100 /// This Decl is the Decl according to the Zig source code corresponding to this Block.
101 /// This can vary during inline or comptime function calls. See `Sema.owner_decl`
102 /// for the one that will be the same for all Block instances.
103 src_decl: *Decl,
104 /// The namespace to use for lookups from this source block
105 /// When analyzing fields, this is different from src_decl.src_namepsace.
106 namespace: *Namespace,
107 /// The AIR instructions generated for this block.
108 instructions: std.ArrayListUnmanaged(Air.Inst.Index),
109 // `param` instructions are collected here to be used by the `func` instruction.
110 params: std.ArrayListUnmanaged(Param) = .{},
111
112 wip_capture_scope: *CaptureScope,
113
114 label: ?*Label = null,
115 inlining: ?*Inlining,
116 /// If runtime_index is not 0 then one of these is guaranteed to be non null.
117 runtime_cond: ?LazySrcLoc = null,
118 runtime_loop: ?LazySrcLoc = null,
119 /// Non zero if a non-inline loop or a runtime conditional have been encountered.
120 /// Stores to to comptime variables are only allowed when var.runtime_index <= runtime_index.
121 runtime_index: u32 = 0,
122
123 is_comptime: bool,
124
125 /// when null, it is determined by build mode, changed by @setRuntimeSafety
126 want_safety: ?bool = null,
127
128 c_import_buf: ?*std.ArrayList(u8) = null,
129
130 const Param = struct {
131 /// `noreturn` means `anytype`.
132 ty: Type,
133 is_comptime: bool,
134 };
135
136 /// This `Block` maps a block ZIR instruction to the corresponding
137 /// AIR instruction for break instruction analysis.
138 pub const Label = struct {
139 zir_block: Zir.Inst.Index,
140 merges: Merges,
141 };
142
143 /// This `Block` indicates that an inline function call is happening
144 /// and return instructions should be analyzed as a break instruction
145 /// to this AIR block instruction.
146 /// It is shared among all the blocks in an inline or comptime called
147 /// function.
148 pub const Inlining = struct {
149 comptime_result: Air.Inst.Ref,
150 merges: Merges,
151 };
152
153 pub const Merges = struct {
154 block_inst: Air.Inst.Index,
155 /// Separate array list from break_inst_list so that it can be passed directly
156 /// to resolvePeerTypes.
157 results: std.ArrayListUnmanaged(Air.Inst.Ref),
158 /// Keeps track of the break instructions so that the operand can be replaced
159 /// if we need to add type coercion at the end of block analysis.
160 /// Same indexes, capacity, length as `results`.
161 br_list: std.ArrayListUnmanaged(Air.Inst.Index),
162 };
163
164 /// For debugging purposes.
165 pub fn dump(block: *Block, mod: Module) void {
166 Zir.dumpBlock(mod, block);
167 }
168
169 pub fn makeSubBlock(parent: *Block) Block {
170 return .{
171 .parent = parent,
172 .sema = parent.sema,
173 .src_decl = parent.src_decl,
174 .namespace = parent.namespace,
175 .instructions = .{},
176 .wip_capture_scope = parent.wip_capture_scope,
177 .label = null,
178 .inlining = parent.inlining,
179 .is_comptime = parent.is_comptime,
180 .runtime_cond = parent.runtime_cond,
181 .runtime_loop = parent.runtime_loop,
182 .runtime_index = parent.runtime_index,
183 .want_safety = parent.want_safety,
184 .c_import_buf = parent.c_import_buf,
185 };
186 }
187
188 pub fn wantSafety(block: *const Block) bool {
189 return block.want_safety orelse switch (block.sema.mod.optimizeMode()) {
190 .Debug => true,
191 .ReleaseSafe => true,
192 .ReleaseFast => false,
193 .ReleaseSmall => false,
194 };
195 }
196
197 pub fn getFileScope(block: *Block) *Module.File {
198 return block.namespace.file_scope;
199 }
200
201 pub fn addTy(
202 block: *Block,
203 tag: Air.Inst.Tag,
204 ty: Type,
205 ) error{OutOfMemory}!Air.Inst.Ref {
206 return block.addInst(.{
207 .tag = tag,
208 .data = .{ .ty = ty },
209 });
210 }
211
212 pub fn addTyOp(
213 block: *Block,
214 tag: Air.Inst.Tag,
215 ty: Type,
216 operand: Air.Inst.Ref,
217 ) error{OutOfMemory}!Air.Inst.Ref {
218 return block.addInst(.{
219 .tag = tag,
220 .data = .{ .ty_op = .{
221 .ty = try block.sema.addType(ty),
222 .operand = operand,
223 } },
224 });
225 }
226
227 pub fn addNoOp(block: *Block, tag: Air.Inst.Tag) error{OutOfMemory}!Air.Inst.Ref {
228 return block.addInst(.{
229 .tag = tag,
230 .data = .{ .no_op = {} },
231 });
232 }
233
234 pub fn addUnOp(
235 block: *Block,
236 tag: Air.Inst.Tag,
237 operand: Air.Inst.Ref,
238 ) error{OutOfMemory}!Air.Inst.Ref {
239 return block.addInst(.{
240 .tag = tag,
241 .data = .{ .un_op = operand },
242 });
243 }
244
245 pub fn addBr(
246 block: *Block,
247 target_block: Air.Inst.Index,
248 operand: Air.Inst.Ref,
249 ) error{OutOfMemory}!Air.Inst.Ref {
250 return block.addInst(.{
251 .tag = .br,
252 .data = .{ .br = .{
253 .block_inst = target_block,
254 .operand = operand,
255 } },
256 });
257 }
258
259 pub fn addBinOp(
260 block: *Block,
261 tag: Air.Inst.Tag,
262 lhs: Air.Inst.Ref,
263 rhs: Air.Inst.Ref,
264 ) error{OutOfMemory}!Air.Inst.Ref {
265 return block.addInst(.{
266 .tag = tag,
267 .data = .{ .bin_op = .{
268 .lhs = lhs,
269 .rhs = rhs,
270 } },
271 });
272 }
273
274 pub fn addArg(block: *Block, ty: Type, name: u32) error{OutOfMemory}!Air.Inst.Ref {
275 return block.addInst(.{
276 .tag = .arg,
277 .data = .{ .ty_str = .{
278 .ty = try block.sema.addType(ty),
279 .str = name,
280 } },
281 });
282 }
283
284 pub fn addStructFieldPtr(
285 block: *Block,
286 struct_ptr: Air.Inst.Ref,
287 field_index: u32,
288 ptr_field_ty: Type,
289 ) !Air.Inst.Ref {
290 const ty = try block.sema.addType(ptr_field_ty);
291 const tag: Air.Inst.Tag = switch (field_index) {
292 0 => .struct_field_ptr_index_0,
293 1 => .struct_field_ptr_index_1,
294 2 => .struct_field_ptr_index_2,
295 3 => .struct_field_ptr_index_3,
296 else => {
297 return block.addInst(.{
298 .tag = .struct_field_ptr,
299 .data = .{ .ty_pl = .{
300 .ty = ty,
301 .payload = try block.sema.addExtra(Air.StructField{
302 .struct_operand = struct_ptr,
303 .field_index = @intCast(u32, field_index),
304 }),
305 } },
306 });
307 },
308 };
309 return block.addInst(.{
310 .tag = tag,
311 .data = .{ .ty_op = .{
312 .ty = ty,
313 .operand = struct_ptr,
314 } },
315 });
316 }
317
318 pub fn addInst(block: *Block, inst: Air.Inst) error{OutOfMemory}!Air.Inst.Ref {
319 return Air.indexToRef(try block.addInstAsIndex(inst));
320 }
321
322 pub fn addInstAsIndex(block: *Block, inst: Air.Inst) error{OutOfMemory}!Air.Inst.Index {
323 const sema = block.sema;
324 const gpa = sema.gpa;
325
326 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
327 try block.instructions.ensureUnusedCapacity(gpa, 1);
328
329 const result_index = @intCast(Air.Inst.Index, sema.air_instructions.len);
330 sema.air_instructions.appendAssumeCapacity(inst);
331 block.instructions.appendAssumeCapacity(result_index);
332 return result_index;
333 }
334
335 pub fn startAnonDecl(block: *Block) !WipAnonDecl {
336 return WipAnonDecl{
337 .block = block,
338 .new_decl_arena = std.heap.ArenaAllocator.init(block.sema.gpa),
339 .finished = false,
340 };
341 }
342
343 pub const WipAnonDecl = struct {
344 block: *Block,
345 new_decl_arena: std.heap.ArenaAllocator,
346 finished: bool,
347
348 pub fn arena(wad: *WipAnonDecl) *Allocator {
349 return &wad.new_decl_arena.allocator;
350 }
351
352 pub fn deinit(wad: *WipAnonDecl) void {
353 if (!wad.finished) {
354 wad.new_decl_arena.deinit();
355 }
356 wad.* = undefined;
357 }
358
359 pub fn finish(wad: *WipAnonDecl, ty: Type, val: Value) !*Decl {
360 const new_decl = try wad.block.sema.mod.createAnonymousDecl(wad.block, .{
361 .ty = ty,
362 .val = val,
363 });
364 errdefer wad.block.sema.mod.abortAnonDecl(new_decl);
365 try new_decl.finalizeNewArena(&wad.new_decl_arena);
366 wad.finished = true;
367 return new_decl;
368 }
369 };
370};
371
92372pub fn deinit(sema: *Sema) void {
93373 const gpa = sema.gpa;
94374 sema.air_instructions.deinit(gpa);
......@@ -102,7 +382,7 @@ pub fn deinit(sema: *Sema) void {
102382/// Returns only the result from the body that is specified.
103383/// Only appropriate to call when it is determined at comptime that this body
104384/// has no peers.
105fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref {
385fn resolveBody(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref {
106386 const break_inst = try sema.analyzeBody(block, body);
107387 const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand;
108388 return sema.resolveInst(operand_ref);
......@@ -125,7 +405,7 @@ const always_noreturn: CompileError!Zir.Inst.Index = @as(Zir.Inst.Index, undefin
125405/// well as the operand. No block scope needs to be created for this strategy.
126406pub fn analyzeBody(
127407 sema: *Sema,
128 block: *Scope.Block,
408 block: *Block,
129409 body: []const Zir.Inst.Index,
130410) CompileError!Zir.Inst.Index {
131411 // No tracy calls here, to avoid interfering with the tail call mechanism.
......@@ -142,9 +422,9 @@ pub fn analyzeBody(
142422 wip_captures.deinit();
143423 };
144424
145 const map = &block.sema.inst_map;
146 const tags = block.sema.code.instructions.items(.tag);
147 const datas = block.sema.code.instructions.items(.data);
425 const map = &sema.inst_map;
426 const tags = sema.code.instructions.items(.tag);
427 const datas = sema.code.instructions.items(.data);
148428
149429 var orig_captures: usize = parent_capture_scope.captures.count();
150430
......@@ -667,7 +947,7 @@ pub fn analyzeBody(
667947 return result;
668948}
669949
670fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
950fn zirExtended(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
671951 const extended = sema.code.instructions.items(.data)[inst].extended;
672952 switch (extended.opcode) {
673953 // zig fmt: off
......@@ -719,7 +999,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
719999
7201000fn resolveConstBool(
7211001 sema: *Sema,
722 block: *Scope.Block,
1002 block: *Block,
7231003 src: LazySrcLoc,
7241004 zir_ref: Zir.Inst.Ref,
7251005) !bool {
......@@ -732,7 +1012,7 @@ fn resolveConstBool(
7321012
7331013fn resolveConstString(
7341014 sema: *Sema,
735 block: *Scope.Block,
1015 block: *Block,
7361016 src: LazySrcLoc,
7371017 zir_ref: Zir.Inst.Ref,
7381018) ![]u8 {
......@@ -743,14 +1023,14 @@ fn resolveConstString(
7431023 return val.toAllocatedBytes(sema.arena);
7441024}
7451025
746pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type {
1026pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type {
7471027 const air_inst = sema.resolveInst(zir_ref);
7481028 return sema.analyzeAsType(block, src, air_inst);
7491029}
7501030
7511031fn analyzeAsType(
7521032 sema: *Sema,
753 block: *Scope.Block,
1033 block: *Block,
7541034 src: LazySrcLoc,
7551035 air_inst: Air.Inst.Ref,
7561036) !Type {
......@@ -767,7 +1047,7 @@ fn analyzeAsType(
7671047/// Value Tag `generic_poison` causes `error.GenericPoison` to be returned.
7681048fn resolveValue(
7691049 sema: *Sema,
770 block: *Scope.Block,
1050 block: *Block,
7711051 src: LazySrcLoc,
7721052 air_ref: Air.Inst.Ref,
7731053) CompileError!Value {
......@@ -782,7 +1062,7 @@ fn resolveValue(
7821062/// Value Tag `undef` may be returned.
7831063fn resolveConstMaybeUndefVal(
7841064 sema: *Sema,
785 block: *Scope.Block,
1065 block: *Block,
7861066 src: LazySrcLoc,
7871067 inst: Air.Inst.Ref,
7881068) CompileError!Value {
......@@ -800,7 +1080,7 @@ fn resolveConstMaybeUndefVal(
8001080/// See `resolveValue` for an alternative.
8011081fn resolveConstValue(
8021082 sema: *Sema,
803 block: *Scope.Block,
1083 block: *Block,
8041084 src: LazySrcLoc,
8051085 air_ref: Air.Inst.Ref,
8061086) CompileError!Value {
......@@ -819,7 +1099,7 @@ fn resolveConstValue(
8191099/// Value Tag `undef` causes this function to return a compile error.
8201100fn resolveDefinedValue(
8211101 sema: *Sema,
822 block: *Scope.Block,
1102 block: *Block,
8231103 src: LazySrcLoc,
8241104 air_ref: Air.Inst.Ref,
8251105) CompileError!?Value {
......@@ -837,7 +1117,7 @@ fn resolveDefinedValue(
8371117/// Value Tag `generic_poison` causes `error.GenericPoison` to be returned.
8381118fn resolveMaybeUndefVal(
8391119 sema: *Sema,
840 block: *Scope.Block,
1120 block: *Block,
8411121 src: LazySrcLoc,
8421122 inst: Air.Inst.Ref,
8431123) CompileError!?Value {
......@@ -852,7 +1132,7 @@ fn resolveMaybeUndefVal(
8521132/// Returns all Value tags including `variable` and `undef`.
8531133fn resolveMaybeUndefValAllowVariables(
8541134 sema: *Sema,
855 block: *Scope.Block,
1135 block: *Block,
8561136 src: LazySrcLoc,
8571137 inst: Air.Inst.Ref,
8581138) CompileError!?Value {
......@@ -879,19 +1159,19 @@ fn resolveMaybeUndefValAllowVariables(
8791159 }
8801160}
8811161
882fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
1162fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError {
8831163 return sema.fail(block, src, "unable to resolve comptime value", .{});
8841164}
8851165
886fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
1166fn failWithUseOfUndef(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError {
8871167 return sema.fail(block, src, "use of undefined value here causes undefined behavior", .{});
8881168}
8891169
890fn failWithDivideByZero(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
1170fn failWithDivideByZero(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError {
8911171 return sema.fail(block, src, "division by zero here causes undefined behavior", .{});
8921172}
8931173
894fn failWithModRemNegative(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError {
1174fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError {
8951175 return sema.fail(block, src, "remainder division with '{}' and '{}': signed integers and floats must use @rem or @mod", .{ lhs_ty, rhs_ty });
8961176}
8971177
......@@ -899,28 +1179,28 @@ fn failWithModRemNegative(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, lhs
8991179/// becomes invalid when you add another one.
9001180fn errNote(
9011181 sema: *Sema,
902 block: *Scope.Block,
1182 block: *Block,
9031183 src: LazySrcLoc,
9041184 parent: *Module.ErrorMsg,
9051185 comptime format: []const u8,
9061186 args: anytype,
9071187) error{OutOfMemory}!void {
908 return sema.mod.errNoteNonLazy(src.toSrcLoc(block), parent, format, args);
1188 return sema.mod.errNoteNonLazy(src.toSrcLoc(block.src_decl), parent, format, args);
9091189}
9101190
9111191fn errMsg(
9121192 sema: *Sema,
913 block: *Scope.Block,
1193 block: *Block,
9141194 src: LazySrcLoc,
9151195 comptime format: []const u8,
9161196 args: anytype,
9171197) error{OutOfMemory}!*Module.ErrorMsg {
918 return Module.ErrorMsg.create(sema.gpa, src.toSrcLoc(block), format, args);
1198 return Module.ErrorMsg.create(sema.gpa, src.toSrcLoc(block.src_decl), format, args);
9191199}
9201200
9211201pub fn fail(
9221202 sema: *Sema,
923 block: *Scope.Block,
1203 block: *Block,
9241204 src: LazySrcLoc,
9251205 comptime format: []const u8,
9261206 args: anytype,
......@@ -958,7 +1238,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {
9581238/// TODO don't ever call this since we're migrating towards ResultLoc.coerced_ty.
9591239fn resolveAlreadyCoercedInt(
9601240 sema: *Sema,
961 block: *Scope.Block,
1241 block: *Block,
9621242 src: LazySrcLoc,
9631243 zir_ref: Zir.Inst.Ref,
9641244 comptime Int: type,
......@@ -974,7 +1254,7 @@ fn resolveAlreadyCoercedInt(
9741254
9751255fn resolveAlign(
9761256 sema: *Sema,
977 block: *Scope.Block,
1257 block: *Block,
9781258 src: LazySrcLoc,
9791259 zir_ref: Zir.Inst.Ref,
9801260) !u16 {
......@@ -991,7 +1271,7 @@ fn resolveAlign(
9911271
9921272fn resolveInt(
9931273 sema: *Sema,
994 block: *Scope.Block,
1274 block: *Block,
9951275 src: LazySrcLoc,
9961276 zir_ref: Zir.Inst.Ref,
9971277 dest_type: Type,
......@@ -1007,7 +1287,7 @@ fn resolveInt(
10071287// a function that does not.
10081288pub fn resolveInstConst(
10091289 sema: *Sema,
1010 block: *Scope.Block,
1290 block: *Block,
10111291 src: LazySrcLoc,
10121292 zir_ref: Zir.Inst.Ref,
10131293) CompileError!TypedValue {
......@@ -1023,7 +1303,7 @@ pub fn resolveInstConst(
10231303// See `resolveInstConst` for an alternative.
10241304pub fn resolveInstValue(
10251305 sema: *Sema,
1026 block: *Scope.Block,
1306 block: *Block,
10271307 src: LazySrcLoc,
10281308 zir_ref: Zir.Inst.Ref,
10291309) CompileError!TypedValue {
......@@ -1035,13 +1315,13 @@ pub fn resolveInstValue(
10351315 };
10361316}
10371317
1038fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1318fn zirBitcastResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
10391319 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
10401320 const src = inst_data.src();
10411321 return sema.fail(block, src, "TODO implement zir_sema.zirBitcastResultPtr", .{});
10421322}
10431323
1044fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1324fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
10451325 const tracy = trace(@src());
10461326 defer tracy.end();
10471327
......@@ -1103,7 +1383,7 @@ pub fn analyzeStructDecl(
11031383
11041384fn zirStructDecl(
11051385 sema: *Sema,
1106 block: *Scope.Block,
1386 block: *Block,
11071387 extended: Zir.Inst.Extended.InstData,
11081388 inst: Zir.Inst.Index,
11091389) CompileError!Air.Inst.Ref {
......@@ -1120,7 +1400,7 @@ fn zirStructDecl(
11201400 const struct_ty = try Type.Tag.@"struct".create(&new_decl_arena.allocator, struct_obj);
11211401 const struct_val = try Value.Tag.ty.create(&new_decl_arena.allocator, struct_ty);
11221402 const type_name = try sema.createTypeName(block, small.name_strategy);
1123 const new_decl = try sema.mod.createAnonymousDeclNamed(&block.base, .{
1403 const new_decl = try sema.mod.createAnonymousDeclNamed(block, .{
11241404 .ty = Type.initTag(.type),
11251405 .val = struct_val,
11261406 }, type_name);
......@@ -1148,7 +1428,7 @@ fn zirStructDecl(
11481428 return sema.analyzeDeclVal(block, src, new_decl);
11491429}
11501430
1151fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 {
1431fn createTypeName(sema: *Sema, block: *Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 {
11521432 switch (name_strategy) {
11531433 .anon => {
11541434 // It would be neat to have "struct:line:column" but this name has
......@@ -1176,7 +1456,7 @@ fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.Name
11761456
11771457fn zirEnumDecl(
11781458 sema: *Sema,
1179 block: *Scope.Block,
1459 block: *Block,
11801460 extended: Zir.Inst.Extended.InstData,
11811461) CompileError!Air.Inst.Ref {
11821462 const tracy = trace(@src());
......@@ -1229,7 +1509,7 @@ fn zirEnumDecl(
12291509 const enum_ty = Type.initPayload(&enum_ty_payload.base);
12301510 const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty);
12311511 const type_name = try sema.createTypeName(block, small.name_strategy);
1232 const new_decl = try mod.createAnonymousDeclNamed(&block.base, .{
1512 const new_decl = try mod.createAnonymousDeclNamed(block, .{
12331513 .ty = Type.initTag(.type),
12341514 .val = enum_val,
12351515 }, type_name);
......@@ -1287,7 +1567,7 @@ fn zirEnumDecl(
12871567 var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, new_decl.src_scope);
12881568 defer wip_captures.deinit();
12891569
1290 var enum_block: Scope.Block = .{
1570 var enum_block: Block = .{
12911571 .parent = null,
12921572 .sema = sema,
12931573 .src_decl = new_decl,
......@@ -1377,7 +1657,7 @@ fn zirEnumDecl(
13771657
13781658fn zirUnionDecl(
13791659 sema: *Sema,
1380 block: *Scope.Block,
1660 block: *Block,
13811661 extended: Zir.Inst.Extended.InstData,
13821662 inst: Zir.Inst.Index,
13831663) CompileError!Air.Inst.Ref {
......@@ -1416,7 +1696,7 @@ fn zirUnionDecl(
14161696 const union_ty = Type.initPayload(&union_payload.base);
14171697 const union_val = try Value.Tag.ty.create(&new_decl_arena.allocator, union_ty);
14181698 const type_name = try sema.createTypeName(block, small.name_strategy);
1419 const new_decl = try sema.mod.createAnonymousDeclNamed(&block.base, .{
1699 const new_decl = try sema.mod.createAnonymousDeclNamed(block, .{
14201700 .ty = Type.initTag(.type),
14211701 .val = union_val,
14221702 }, type_name);
......@@ -1448,7 +1728,7 @@ fn zirUnionDecl(
14481728
14491729fn zirOpaqueDecl(
14501730 sema: *Sema,
1451 block: *Scope.Block,
1731 block: *Block,
14521732 extended: Zir.Inst.Extended.InstData,
14531733 inst: Zir.Inst.Index,
14541734) CompileError!Air.Inst.Ref {
......@@ -1462,7 +1742,7 @@ fn zirOpaqueDecl(
14621742
14631743fn zirErrorSetDecl(
14641744 sema: *Sema,
1465 block: *Scope.Block,
1745 block: *Block,
14661746 inst: Zir.Inst.Index,
14671747 name_strategy: Zir.Inst.NameStrategy,
14681748) CompileError!Air.Inst.Ref {
......@@ -1482,7 +1762,7 @@ fn zirErrorSetDecl(
14821762 const error_set_ty = try Type.Tag.error_set.create(&new_decl_arena.allocator, error_set);
14831763 const error_set_val = try Value.Tag.ty.create(&new_decl_arena.allocator, error_set_ty);
14841764 const type_name = try sema.createTypeName(block, name_strategy);
1485 const new_decl = try sema.mod.createAnonymousDeclNamed(&block.base, .{
1765 const new_decl = try sema.mod.createAnonymousDeclNamed(block, .{
14861766 .ty = Type.initTag(.type),
14871767 .val = error_set_val,
14881768 }, type_name);
......@@ -1504,7 +1784,7 @@ fn zirErrorSetDecl(
15041784
15051785fn zirRetPtr(
15061786 sema: *Sema,
1507 block: *Scope.Block,
1787 block: *Block,
15081788 extended: Zir.Inst.Extended.InstData,
15091789) CompileError!Air.Inst.Ref {
15101790 const tracy = trace(@src());
......@@ -1524,7 +1804,7 @@ fn zirRetPtr(
15241804 return block.addTy(.alloc, ptr_type);
15251805}
15261806
1527fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1807fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
15281808 const tracy = trace(@src());
15291809 defer tracy.end();
15301810
......@@ -1535,7 +1815,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
15351815
15361816fn zirRetType(
15371817 sema: *Sema,
1538 block: *Scope.Block,
1818 block: *Block,
15391819 extended: Zir.Inst.Extended.InstData,
15401820) CompileError!Air.Inst.Ref {
15411821 const tracy = trace(@src());
......@@ -1546,7 +1826,7 @@ fn zirRetType(
15461826 return sema.addType(sema.fn_ret_ty);
15471827}
15481828
1549fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1829fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
15501830 const tracy = trace(@src());
15511831 defer tracy.end();
15521832
......@@ -1559,7 +1839,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) C
15591839
15601840fn ensureResultUsed(
15611841 sema: *Sema,
1562 block: *Scope.Block,
1842 block: *Block,
15631843 operand: Air.Inst.Ref,
15641844 src: LazySrcLoc,
15651845) CompileError!void {
......@@ -1570,7 +1850,7 @@ fn ensureResultUsed(
15701850 }
15711851}
15721852
1573fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1853fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
15741854 const tracy = trace(@src());
15751855 defer tracy.end();
15761856
......@@ -1584,7 +1864,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
15841864 }
15851865}
15861866
1587fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1867fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
15881868 const tracy = trace(@src());
15891869 defer tracy.end();
15901870
......@@ -1632,7 +1912,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co
16321912
16331913fn zirAllocExtended(
16341914 sema: *Sema,
1635 block: *Scope.Block,
1915 block: *Block,
16361916 extended: Zir.Inst.Extended.InstData,
16371917) CompileError!Air.Inst.Ref {
16381918 const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand);
......@@ -1675,7 +1955,7 @@ fn zirAllocExtended(
16751955 return block.addTy(.alloc, ptr_type);
16761956}
16771957
1678fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1958fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16791959 const tracy = trace(@src());
16801960 defer tracy.end();
16811961
......@@ -1695,7 +1975,7 @@ fn zirAllocInferredComptime(sema: *Sema, inst: Zir.Inst.Index) CompileError!Air.
16951975 );
16961976}
16971977
1698fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1978fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16991979 const tracy = trace(@src());
17001980 defer tracy.end();
17011981
......@@ -1711,7 +1991,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
17111991 return block.addTy(.alloc, ptr_type);
17121992}
17131993
1714fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1994fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
17151995 const tracy = trace(@src());
17161996 defer tracy.end();
17171997
......@@ -1733,7 +2013,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
17332013
17342014fn zirAllocInferred(
17352015 sema: *Sema,
1736 block: *Scope.Block,
2016 block: *Block,
17372017 inst: Zir.Inst.Index,
17382018 inferred_alloc_ty: Type,
17392019) CompileError!Air.Inst.Ref {
......@@ -1764,7 +2044,7 @@ fn zirAllocInferred(
17642044 return result;
17652045}
17662046
1767fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2047fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
17682048 const tracy = trace(@src());
17692049 defer tracy.end();
17702050
......@@ -1823,7 +2103,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
18232103 }
18242104}
18252105
1826fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2106fn zirValidateStructInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
18272107 const tracy = trace(@src());
18282108 defer tracy.end();
18292109
......@@ -1855,7 +2135,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind
18552135
18562136fn validateUnionInitPtr(
18572137 sema: *Sema,
1858 block: *Scope.Block,
2138 block: *Block,
18592139 union_obj: *Module.Union,
18602140 init_src: LazySrcLoc,
18612141 instrs: []const Zir.Inst.Index,
......@@ -1894,7 +2174,7 @@ fn validateUnionInitPtr(
18942174
18952175fn validateStructInitPtr(
18962176 sema: *Sema,
1897 block: *Scope.Block,
2177 block: *Block,
18982178 struct_obj: *Module.Struct,
18992179 init_src: LazySrcLoc,
19002180 instrs: []const Zir.Inst.Index,
......@@ -1956,7 +2236,7 @@ fn validateStructInitPtr(
19562236 }
19572237}
19582238
1959fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2239fn zirValidateArrayInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
19602240 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
19612241 const src = inst_data.src();
19622242 return sema.fail(block, src, "TODO implement Sema.zirValidateArrayInitPtr", .{});
......@@ -1964,7 +2244,7 @@ fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
19642244
19652245fn failWithBadFieldAccess(
19662246 sema: *Sema,
1967 block: *Scope.Block,
2247 block: *Block,
19682248 struct_obj: *Module.Struct,
19692249 field_src: LazySrcLoc,
19702250 field_name: []const u8,
......@@ -1990,7 +2270,7 @@ fn failWithBadFieldAccess(
19902270
19912271fn failWithBadUnionFieldAccess(
19922272 sema: *Sema,
1993 block: *Scope.Block,
2273 block: *Block,
19942274 union_obj: *Module.Union,
19952275 field_src: LazySrcLoc,
19962276 field_name: []const u8,
......@@ -2014,7 +2294,7 @@ fn failWithBadUnionFieldAccess(
20142294 return sema.failWithOwnedErrorMsg(msg);
20152295}
20162296
2017fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2297fn zirStoreToBlockPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
20182298 const tracy = trace(@src());
20192299 defer tracy.end();
20202300
......@@ -2039,7 +2319,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co
20392319 return sema.storePtr(block, src, bitcasted_ptr, value);
20402320}
20412321
2042fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2322fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
20432323 const tracy = trace(@src());
20442324 defer tracy.end();
20452325
......@@ -2087,7 +2367,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
20872367 unreachable;
20882368}
20892369
2090fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2370fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
20912371 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
20922372 const src = inst_data.src();
20932373 const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32);
......@@ -2095,7 +2375,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
20952375 sema.branch_quota = quota;
20962376}
20972377
2098fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2378fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
20992379 const tracy = trace(@src());
21002380 defer tracy.end();
21012381
......@@ -2105,7 +2385,7 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
21052385 return sema.storePtr(block, sema.src, ptr, value);
21062386}
21072387
2108fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2388fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
21092389 const tracy = trace(@src());
21102390 defer tracy.end();
21112391
......@@ -2117,7 +2397,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
21172397 return sema.storePtr(block, src, ptr, value);
21182398}
21192399
2120fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2400fn zirStr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21212401 const tracy = trace(@src());
21222402 defer tracy.end();
21232403
......@@ -2136,7 +2416,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
21362416 const decl_ty = try Type.Tag.array_u8_sentinel_0.create(&new_decl_arena.allocator, bytes.len);
21372417 const decl_val = try Value.Tag.bytes.create(&new_decl_arena.allocator, bytes);
21382418
2139 const new_decl = try sema.mod.createAnonymousDecl(&block.base, .{
2419 const new_decl = try sema.mod.createAnonymousDecl(block, .{
21402420 .ty = decl_ty,
21412421 .val = decl_val,
21422422 });
......@@ -2145,7 +2425,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
21452425 return sema.analyzeDeclRef(new_decl);
21462426}
21472427
2148fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2428fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21492429 _ = block;
21502430 const tracy = trace(@src());
21512431 defer tracy.end();
......@@ -2154,7 +2434,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
21542434 return sema.addIntUnsigned(Type.initTag(.comptime_int), int);
21552435}
21562436
2157fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2437fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21582438 _ = block;
21592439 const tracy = trace(@src());
21602440 defer tracy.end();
......@@ -2172,7 +2452,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
21722452 );
21732453}
21742454
2175fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2455fn zirFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21762456 _ = block;
21772457 const arena = sema.arena;
21782458 const number = sema.code.instructions.items(.data)[inst].float;
......@@ -2182,7 +2462,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
21822462 );
21832463}
21842464
2185fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2465fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21862466 _ = block;
21872467 const arena = sema.arena;
21882468 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
......@@ -2194,7 +2474,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
21942474 );
21952475}
21962476
2197fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
2477fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
21982478 const tracy = trace(@src());
21992479 defer tracy.end();
22002480
......@@ -2207,7 +2487,7 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi
22072487
22082488fn zirCompileLog(
22092489 sema: *Sema,
2210 block: *Scope.Block,
2490 block: *Block,
22112491 extended: Zir.Inst.Extended.InstData,
22122492) CompileError!Air.Inst.Ref {
22132493 var managed = sema.mod.compile_log_text.toManaged(sema.gpa);
......@@ -2239,7 +2519,7 @@ fn zirCompileLog(
22392519 return Air.Inst.Ref.void_value;
22402520}
22412521
2242fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
2522fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
22432523 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
22442524 const src: LazySrcLoc = inst_data.src();
22452525 const msg_inst = sema.resolveInst(inst_data.operand);
......@@ -2247,7 +2527,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
22472527 return sema.panicWithMsg(block, src, msg_inst);
22482528}
22492529
2250fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2530fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22512531 const tracy = trace(@src());
22522532 defer tracy.end();
22532533
......@@ -2275,7 +2555,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Compil
22752555 .payload = undefined,
22762556 } },
22772557 });
2278 var label: Scope.Block.Label = .{
2558 var label: Block.Label = .{
22792559 .zir_block = inst,
22802560 .merges = .{
22812561 .results = .{},
......@@ -2310,7 +2590,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Compil
23102590 return sema.analyzeBlockBody(parent_block, src, &child_block, merges);
23112591}
23122592
2313fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2593fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
23142594 const tracy = trace(@src());
23152595 defer tracy.end();
23162596
......@@ -2326,7 +2606,7 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com
23262606 var c_import_buf = std.ArrayList(u8).init(sema.gpa);
23272607 defer c_import_buf.deinit();
23282608
2329 var child_block: Scope.Block = .{
2609 var child_block: Block = .{
23302610 .parent = parent_block,
23312611 .sema = sema,
23322612 .src_decl = parent_block.src_decl,
......@@ -2389,7 +2669,7 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com
23892669 return sema.addConstant(file_root_decl.ty, file_root_decl.val);
23902670}
23912671
2392fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2672fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
23932673 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
23942674 const src = inst_data.src();
23952675 return sema.fail(parent_block, src, "TODO: implement Sema.zirSuspendBlock", .{});
......@@ -2397,7 +2677,7 @@ fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index
23972677
23982678fn zirBlock(
23992679 sema: *Sema,
2400 parent_block: *Scope.Block,
2680 parent_block: *Block,
24012681 inst: Zir.Inst.Index,
24022682) CompileError!Air.Inst.Ref {
24032683 const tracy = trace(@src());
......@@ -2418,7 +2698,7 @@ fn zirBlock(
24182698 .data = undefined,
24192699 });
24202700
2421 var label: Scope.Block.Label = .{
2701 var label: Block.Label = .{
24222702 .zir_block = inst,
24232703 .merges = .{
24242704 .results = .{},
......@@ -2427,7 +2707,7 @@ fn zirBlock(
24272707 },
24282708 };
24292709
2430 var child_block: Scope.Block = .{
2710 var child_block: Block = .{
24312711 .parent = parent_block,
24322712 .sema = sema,
24332713 .src_decl = parent_block.src_decl,
......@@ -2451,11 +2731,11 @@ fn zirBlock(
24512731
24522732fn resolveBlockBody(
24532733 sema: *Sema,
2454 parent_block: *Scope.Block,
2734 parent_block: *Block,
24552735 src: LazySrcLoc,
2456 child_block: *Scope.Block,
2736 child_block: *Block,
24572737 body: []const Zir.Inst.Index,
2458 merges: *Scope.Block.Merges,
2738 merges: *Block.Merges,
24592739) CompileError!Air.Inst.Ref {
24602740 if (child_block.is_comptime) {
24612741 return sema.resolveBody(child_block, body);
......@@ -2467,10 +2747,10 @@ fn resolveBlockBody(
24672747
24682748fn analyzeBlockBody(
24692749 sema: *Sema,
2470 parent_block: *Scope.Block,
2750 parent_block: *Block,
24712751 src: LazySrcLoc,
2472 child_block: *Scope.Block,
2473 merges: *Scope.Block.Merges,
2752 child_block: *Block,
2753 merges: *Block.Merges,
24742754) CompileError!Air.Inst.Ref {
24752755 const tracy = trace(@src());
24762756 defer tracy.end();
......@@ -2568,7 +2848,7 @@ fn analyzeBlockBody(
25682848 return Air.indexToRef(merges.block_inst);
25692849}
25702850
2571fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2851fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
25722852 const tracy = trace(@src());
25732853 defer tracy.end();
25742854
......@@ -2586,7 +2866,7 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
25862866 try sema.analyzeExport(block, src, options, decl);
25872867}
25882868
2589fn zirExportValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2869fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
25902870 const tracy = trace(@src());
25912871 defer tracy.end();
25922872
......@@ -2606,7 +2886,7 @@ fn zirExportValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
26062886
26072887pub fn analyzeExport(
26082888 sema: *Sema,
2609 block: *Scope.Block,
2889 block: *Block,
26102890 src: LazySrcLoc,
26112891 borrowed_options: std.builtin.ExportOptions,
26122892 exported_decl: *Decl,
......@@ -2682,7 +2962,7 @@ pub fn analyzeExport(
26822962 errdefer de_gop.value_ptr.* = gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1);
26832963}
26842964
2685fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2965fn zirSetAlignStack(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
26862966 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
26872967 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
26882968 const src: LazySrcLoc = inst_data.src();
......@@ -2714,7 +2994,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
27142994 gop.value_ptr.* = .{ .alignment = alignment, .src = src };
27152995}
27162996
2717fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2997fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
27182998 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
27192999 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
27203000 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand);
......@@ -2722,19 +3002,19 @@ fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
27223002 func.is_cold = is_cold;
27233003}
27243004
2725fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
3005fn zirSetFloatMode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
27263006 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
27273007 const src: LazySrcLoc = inst_data.src();
27283008 return sema.fail(block, src, "TODO: implement Sema.zirSetFloatMode", .{});
27293009}
27303010
2731fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
3011fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
27323012 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
27333013 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
27343014 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand);
27353015}
27363016
2737fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
3017fn zirFence(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
27383018 if (block.is_comptime) return;
27393019
27403020 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
......@@ -2751,7 +3031,7 @@ fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
27513031 });
27523032}
27533033
2754fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
3034fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
27553035 const tracy = trace(@src());
27563036 defer tracy.end();
27573037
......@@ -2773,7 +3053,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) Compil
27733053 }
27743054}
27753055
2776fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
3056fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
27773057 const tracy = trace(@src());
27783058 defer tracy.end();
27793059
......@@ -2793,7 +3073,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
27933073 });
27943074}
27953075
2796fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3076fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
27973077 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
27983078 const src = inst_data.src();
27993079 const decl_name = inst_data.get(sema.code);
......@@ -2801,7 +3081,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
28013081 return sema.analyzeDeclRef(decl);
28023082}
28033083
2804fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3084fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
28053085 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
28063086 const src = inst_data.src();
28073087 const decl_name = inst_data.get(sema.code);
......@@ -2809,7 +3089,7 @@ fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
28093089 return sema.analyzeDeclVal(block, src, decl);
28103090}
28113091
2812fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []const u8) !*Decl {
3092fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: []const u8) !*Decl {
28133093 var namespace = block.namespace;
28143094 while (true) {
28153095 if (try sema.lookupInNamespace(block, src, namespace, name, false)) |decl| {
......@@ -2824,9 +3104,9 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c
28243104/// only for ones in the specified namespace.
28253105fn lookupInNamespace(
28263106 sema: *Sema,
2827 block: *Scope.Block,
3107 block: *Block,
28283108 src: LazySrcLoc,
2829 namespace: *Scope.Namespace,
3109 namespace: *Namespace,
28303110 ident_name: []const u8,
28313111 observe_usingnamespace: bool,
28323112) CompileError!?*Decl {
......@@ -2842,7 +3122,7 @@ fn lookupInNamespace(
28423122 const src_file = block.namespace.file_scope;
28433123
28443124 const gpa = sema.gpa;
2845 var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Scope.Namespace, void) = .{};
3125 var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Namespace, void) = .{};
28463126 defer checked_namespaces.deinit(gpa);
28473127
28483128 // Keep track of name conflicts for error notes.
......@@ -2914,7 +3194,7 @@ fn lookupInNamespace(
29143194
29153195fn zirCall(
29163196 sema: *Sema,
2917 block: *Scope.Block,
3197 block: *Block,
29183198 inst: Zir.Inst.Index,
29193199) CompileError!Air.Inst.Ref {
29203200 const tracy = trace(@src());
......@@ -3016,7 +3296,7 @@ const GenericRemoveAdapter = struct {
30163296
30173297fn analyzeCall(
30183298 sema: *Sema,
3019 block: *Scope.Block,
3299 block: *Block,
30203300 func: Air.Inst.Ref,
30213301 func_src: LazySrcLoc,
30223302 call_src: LazySrcLoc,
......@@ -3097,7 +3377,7 @@ fn analyzeCall(
30973377
30983378 // Analyze the ZIR. The same ZIR gets analyzed into a runtime function
30993379 // or an inlined call depending on what union tag the `label` field is
3100 // set to in the `Scope.Block`.
3380 // set to in the `Block`.
31013381 // This block instruction will be used to capture the return value from the
31023382 // inlined function.
31033383 const block_inst = @intCast(Air.Inst.Index, sema.air_instructions.len);
......@@ -3107,7 +3387,7 @@ fn analyzeCall(
31073387 });
31083388 // This one is shared among sub-blocks within the same callee, but not
31093389 // shared among the entire inline/comptime call stack.
3110 var inlining: Scope.Block.Inlining = .{
3390 var inlining: Block.Inlining = .{
31113391 .comptime_result = undefined,
31123392 .merges = .{
31133393 .results = .{},
......@@ -3135,7 +3415,7 @@ fn analyzeCall(
31353415 var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, module_fn.owner_decl.src_scope);
31363416 defer wip_captures.deinit();
31373417
3138 var child_block: Scope.Block = .{
3418 var child_block: Block = .{
31393419 .parent = null,
31403420 .sema = sema,
31413421 .src_decl = module_fn.owner_decl,
......@@ -3437,7 +3717,7 @@ fn analyzeCall(
34373717 var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, new_decl.src_scope);
34383718 defer wip_captures.deinit();
34393719
3440 var child_block: Scope.Block = .{
3720 var child_block: Block = .{
34413721 .parent = null,
34423722 .sema = &child_sema,
34433723 .src_decl = new_decl,
......@@ -3598,7 +3878,7 @@ fn analyzeCall(
35983878
35993879fn finishGenericCall(
36003880 sema: *Sema,
3601 block: *Scope.Block,
3881 block: *Block,
36023882 call_src: LazySrcLoc,
36033883 callee: *Module.Fn,
36043884 func_src: LazySrcLoc,
......@@ -3665,7 +3945,7 @@ fn finishGenericCall(
36653945 return func_inst;
36663946}
36673947
3668fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3948fn zirIntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
36693949 _ = block;
36703950 const tracy = trace(@src());
36713951 defer tracy.end();
......@@ -3676,7 +3956,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
36763956 return sema.addType(ty);
36773957}
36783958
3679fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3959fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
36803960 const tracy = trace(@src());
36813961 defer tracy.end();
36823962
......@@ -3688,7 +3968,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi
36883968 return sema.addType(opt_type);
36893969}
36903970
3691fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3971fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
36923972 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
36933973 const src = inst_data.src();
36943974 const array_type = try sema.resolveType(block, src, inst_data.operand);
......@@ -3696,7 +3976,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
36963976 return sema.addType(elem_type);
36973977}
36983978
3699fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3979fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37003980 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
37013981 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
37023982 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -3710,7 +3990,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
37103990 return sema.addType(vector_type);
37113991}
37123992
3713fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3993fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37143994 const tracy = trace(@src());
37153995 defer tracy.end();
37163996
......@@ -3722,7 +4002,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
37224002 return sema.addType(array_ty);
37234003}
37244004
3725fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4005fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37264006 const tracy = trace(@src());
37274007 defer tracy.end();
37284008
......@@ -3738,7 +4018,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
37384018 return sema.addType(array_ty);
37394019}
37404020
3741fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4021fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37424022 const tracy = trace(@src());
37434023 defer tracy.end();
37444024
......@@ -3750,7 +4030,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi
37504030 return sema.addType(anyframe_type);
37514031}
37524032
3753fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4033fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37544034 const tracy = trace(@src());
37554035 defer tracy.end();
37564036
......@@ -3770,7 +4050,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
37704050 return sema.addType(err_union_ty);
37714051}
37724052
3773fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4053fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37744054 _ = block;
37754055 const tracy = trace(@src());
37764056 defer tracy.end();
......@@ -3788,7 +4068,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
37884068 );
37894069}
37904070
3791fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4071fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
37924072 const tracy = trace(@src());
37934073 defer tracy.end();
37944074
......@@ -3815,7 +4095,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
38154095 return block.addTyOp(.bitcast, result_ty, op_coerced);
38164096}
38174097
3818fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4098fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
38194099 const tracy = trace(@src());
38204100 defer tracy.end();
38214101
......@@ -3845,7 +4125,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
38454125 return block.addTyOp(.bitcast, Type.initTag(.anyerror), op);
38464126}
38474127
3848fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4128fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
38494129 const tracy = trace(@src());
38504130 defer tracy.end();
38514131
......@@ -3929,7 +4209,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
39294209 return sema.addConstant(Type.initTag(.type), try Value.Tag.ty.create(sema.arena, error_set_ty));
39304210}
39314211
3932fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4212fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
39334213 _ = block;
39344214 const tracy = trace(@src());
39354215 defer tracy.end();
......@@ -3942,7 +4222,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
39424222 );
39434223}
39444224
3945fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4225fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
39464226 const arena = sema.arena;
39474227 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
39484228 const src = inst_data.src();
......@@ -3988,7 +4268,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
39884268 return block.addTyOp(.bitcast, int_tag_ty, enum_tag);
39894269}
39904270
3991fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4271fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
39924272 const target = sema.mod.getTarget();
39934273 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
39944274 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -4038,7 +4318,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
40384318/// Pointer in, pointer out.
40394319fn zirOptionalPayloadPtr(
40404320 sema: *Sema,
4041 block: *Scope.Block,
4321 block: *Block,
40424322 inst: Zir.Inst.Index,
40434323 safety_check: bool,
40444324) CompileError!Air.Inst.Ref {
......@@ -4087,7 +4367,7 @@ fn zirOptionalPayloadPtr(
40874367/// Value in, value out.
40884368fn zirOptionalPayload(
40894369 sema: *Sema,
4090 block: *Scope.Block,
4370 block: *Block,
40914371 inst: Zir.Inst.Index,
40924372 safety_check: bool,
40934373) CompileError!Air.Inst.Ref {
......@@ -4124,7 +4404,7 @@ fn zirOptionalPayload(
41244404/// Value in, value out
41254405fn zirErrUnionPayload(
41264406 sema: *Sema,
4127 block: *Scope.Block,
4407 block: *Block,
41284408 inst: Zir.Inst.Index,
41294409 safety_check: bool,
41304410) CompileError!Air.Inst.Ref {
......@@ -4159,7 +4439,7 @@ fn zirErrUnionPayload(
41594439/// Pointer in, pointer out.
41604440fn zirErrUnionPayloadPtr(
41614441 sema: *Sema,
4162 block: *Scope.Block,
4442 block: *Block,
41634443 inst: Zir.Inst.Index,
41644444 safety_check: bool,
41654445) CompileError!Air.Inst.Ref {
......@@ -4203,7 +4483,7 @@ fn zirErrUnionPayloadPtr(
42034483}
42044484
42054485/// Value in, value out
4206fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4486fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
42074487 const tracy = trace(@src());
42084488 defer tracy.end();
42094489
......@@ -4226,7 +4506,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi
42264506}
42274507
42284508/// Pointer in, value out
4229fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4509fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
42304510 const tracy = trace(@src());
42314511 defer tracy.end();
42324512
......@@ -4252,7 +4532,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co
42524532 return block.addTyOp(.unwrap_errunion_err_ptr, result_ty, operand);
42534533}
42544534
4255fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
4535fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
42564536 const tracy = trace(@src());
42574537 defer tracy.end();
42584538
......@@ -4269,7 +4549,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
42694549
42704550fn zirFunc(
42714551 sema: *Sema,
4272 block: *Scope.Block,
4552 block: *Block,
42734553 inst: Zir.Inst.Index,
42744554 inferred_error_set: bool,
42754555) CompileError!Air.Inst.Ref {
......@@ -4312,7 +4592,7 @@ fn zirFunc(
43124592
43134593fn funcCommon(
43144594 sema: *Sema,
4315 block: *Scope.Block,
4595 block: *Block,
43164596 src_node_offset: i32,
43174597 body_inst: Zir.Inst.Index,
43184598 ret_ty_body: []const Zir.Inst.Index,
......@@ -4511,7 +4791,7 @@ fn funcCommon(
45114791
45124792fn zirParam(
45134793 sema: *Sema,
4514 block: *Scope.Block,
4794 block: *Block,
45154795 inst: Zir.Inst.Index,
45164796 is_comptime: bool,
45174797) CompileError!void {
......@@ -4581,7 +4861,7 @@ fn zirParam(
45814861
45824862fn zirParamAnytype(
45834863 sema: *Sema,
4584 block: *Scope.Block,
4864 block: *Block,
45854865 inst: Zir.Inst.Index,
45864866 is_comptime: bool,
45874867) CompileError!void {
......@@ -4616,7 +4896,7 @@ fn zirParamAnytype(
46164896 try sema.inst_map.put(sema.gpa, inst, .generic_poison);
46174897}
46184898
4619fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4899fn zirAs(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46204900 const tracy = trace(@src());
46214901 defer tracy.end();
46224902
......@@ -4624,7 +4904,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Ai
46244904 return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);
46254905}
46264906
4627fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4907fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46284908 const tracy = trace(@src());
46294909 defer tracy.end();
46304910
......@@ -4636,7 +4916,7 @@ fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
46364916
46374917fn analyzeAs(
46384918 sema: *Sema,
4639 block: *Scope.Block,
4919 block: *Block,
46404920 src: LazySrcLoc,
46414921 zir_dest_type: Zir.Inst.Ref,
46424922 zir_operand: Zir.Inst.Ref,
......@@ -4646,7 +4926,7 @@ fn analyzeAs(
46464926 return sema.coerce(block, dest_type, operand, src);
46474927}
46484928
4649fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4929fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46504930 const tracy = trace(@src());
46514931 defer tracy.end();
46524932
......@@ -4663,7 +4943,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
46634943 return block.addUnOp(.ptrtoint, ptr);
46644944}
46654945
4666fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4946fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46674947 const tracy = trace(@src());
46684948 defer tracy.end();
46694949
......@@ -4682,7 +4962,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
46824962 }
46834963}
46844964
4685fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4965fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46864966 const tracy = trace(@src());
46874967 defer tracy.end();
46884968
......@@ -4695,7 +4975,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
46954975 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src);
46964976}
46974977
4698fn zirFieldCallBind(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4978fn zirFieldCallBind(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
46994979 const tracy = trace(@src());
47004980 defer tracy.end();
47014981
......@@ -4708,7 +4988,7 @@ fn zirFieldCallBind(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
47084988 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);
47094989}
47104990
4711fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4991fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47124992 const tracy = trace(@src());
47134993 defer tracy.end();
47144994
......@@ -4721,7 +5001,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
47215001 return sema.fieldVal(block, src, object, field_name, field_name_src);
47225002}
47235003
4724fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5004fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47255005 const tracy = trace(@src());
47265006 defer tracy.end();
47275007
......@@ -4734,7 +5014,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
47345014 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src);
47355015}
47365016
4737fn zirFieldCallBindNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5017fn zirFieldCallBindNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47385018 const tracy = trace(@src());
47395019 defer tracy.end();
47405020
......@@ -4747,7 +5027,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
47475027 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);
47485028}
47495029
4750fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5030fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47515031 const tracy = trace(@src());
47525032 defer tracy.end();
47535033
......@@ -4773,7 +5053,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
47735053 return block.addTyOp(.intcast, dest_type, operand);
47745054}
47755055
4776fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5056fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47775057 const tracy = trace(@src());
47785058 defer tracy.end();
47795059
......@@ -4787,7 +5067,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
47875067 return sema.bitcast(block, dest_type, operand, operand_src);
47885068}
47895069
4790fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5070fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
47915071 const tracy = trace(@src());
47925072 defer tracy.end();
47935073
......@@ -4838,7 +5118,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
48385118 return block.addTyOp(.fptrunc, dest_type, operand);
48395119}
48405120
4841fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5121fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48425122 const tracy = trace(@src());
48435123 defer tracy.end();
48445124
......@@ -4848,7 +5128,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
48485128 return sema.elemVal(block, sema.src, array, elem_index, sema.src);
48495129}
48505130
4851fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5131fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48525132 const tracy = trace(@src());
48535133 defer tracy.end();
48545134
......@@ -4861,7 +5141,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
48615141 return sema.elemVal(block, src, array, elem_index, elem_index_src);
48625142}
48635143
4864fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5144fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48655145 const tracy = trace(@src());
48665146 defer tracy.end();
48675147
......@@ -4871,7 +5151,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
48715151 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);
48725152}
48735153
4874fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5154fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48755155 const tracy = trace(@src());
48765156 defer tracy.end();
48775157
......@@ -4884,7 +5164,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
48845164 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);
48855165}
48865166
4887fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5167fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
48885168 const tracy = trace(@src());
48895169 defer tracy.end();
48905170
......@@ -4897,7 +5177,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
48975177 return sema.analyzeSlice(block, src, array_ptr, start, .none, .none, .unneeded);
48985178}
48995179
4900fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5180fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
49015181 const tracy = trace(@src());
49025182 defer tracy.end();
49035183
......@@ -4911,7 +5191,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
49115191 return sema.analyzeSlice(block, src, array_ptr, start, end, .none, .unneeded);
49125192}
49135193
4914fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5194fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
49155195 const tracy = trace(@src());
49165196 defer tracy.end();
49175197
......@@ -4929,7 +5209,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
49295209
49305210fn zirSwitchCapture(
49315211 sema: *Sema,
4932 block: *Scope.Block,
5212 block: *Block,
49335213 inst: Zir.Inst.Index,
49345214 is_multi: bool,
49355215 is_ref: bool,
......@@ -4949,7 +5229,7 @@ fn zirSwitchCapture(
49495229
49505230fn zirSwitchCaptureElse(
49515231 sema: *Sema,
4952 block: *Scope.Block,
5232 block: *Block,
49535233 inst: Zir.Inst.Index,
49545234 is_ref: bool,
49555235) CompileError!Air.Inst.Ref {
......@@ -4967,7 +5247,7 @@ fn zirSwitchCaptureElse(
49675247
49685248fn zirSwitchBlock(
49695249 sema: *Sema,
4970 block: *Scope.Block,
5250 block: *Block,
49715251 inst: Zir.Inst.Index,
49725252 is_ref: bool,
49735253 special_prong: Zir.SpecialProng,
......@@ -5000,7 +5280,7 @@ fn zirSwitchBlock(
50005280
50015281fn zirSwitchBlockMulti(
50025282 sema: *Sema,
5003 block: *Scope.Block,
5283 block: *Block,
50045284 inst: Zir.Inst.Index,
50055285 is_ref: bool,
50065286 special_prong: Zir.SpecialProng,
......@@ -5033,7 +5313,7 @@ fn zirSwitchBlockMulti(
50335313
50345314fn analyzeSwitch(
50355315 sema: *Sema,
5036 block: *Scope.Block,
5316 block: *Block,
50375317 operand: Air.Inst.Ref,
50385318 extra_end: usize,
50395319 special_prong: Zir.SpecialProng,
......@@ -5451,7 +5731,7 @@ fn analyzeSwitch(
54515731 .tag = .block,
54525732 .data = undefined,
54535733 });
5454 var label: Scope.Block.Label = .{
5734 var label: Block.Label = .{
54555735 .zir_block = switch_inst,
54565736 .merges = .{
54575737 .results = .{},
......@@ -5460,7 +5740,7 @@ fn analyzeSwitch(
54605740 },
54615741 };
54625742
5463 var child_block: Scope.Block = .{
5743 var child_block: Block = .{
54645744 .parent = block,
54655745 .sema = sema,
54665746 .src_decl = block.src_decl,
......@@ -5771,7 +6051,7 @@ fn analyzeSwitch(
57716051
57726052fn resolveSwitchItemVal(
57736053 sema: *Sema,
5774 block: *Scope.Block,
6054 block: *Block,
57756055 item_ref: Zir.Inst.Ref,
57766056 switch_node_offset: i32,
57776057 switch_prong_src: Module.SwitchProngSrc,
......@@ -5798,7 +6078,7 @@ fn resolveSwitchItemVal(
57986078
57996079fn validateSwitchRange(
58006080 sema: *Sema,
5801 block: *Scope.Block,
6081 block: *Block,
58026082 range_set: *RangeSet,
58036083 first_ref: Zir.Inst.Ref,
58046084 last_ref: Zir.Inst.Ref,
......@@ -5814,7 +6094,7 @@ fn validateSwitchRange(
58146094
58156095fn validateSwitchItem(
58166096 sema: *Sema,
5817 block: *Scope.Block,
6097 block: *Block,
58186098 range_set: *RangeSet,
58196099 item_ref: Zir.Inst.Ref,
58206100 operand_ty: Type,
......@@ -5828,7 +6108,7 @@ fn validateSwitchItem(
58286108
58296109fn validateSwitchItemEnum(
58306110 sema: *Sema,
5831 block: *Scope.Block,
6111 block: *Block,
58326112 seen_fields: []?Module.SwitchProngSrc,
58336113 item_ref: Zir.Inst.Ref,
58346114 src_node_offset: i32,
......@@ -5862,7 +6142,7 @@ fn validateSwitchItemEnum(
58626142
58636143fn validateSwitchDupe(
58646144 sema: *Sema,
5865 block: *Scope.Block,
6145 block: *Block,
58666146 maybe_prev_src: ?Module.SwitchProngSrc,
58676147 switch_prong_src: Module.SwitchProngSrc,
58686148 src_node_offset: i32,
......@@ -5893,7 +6173,7 @@ fn validateSwitchDupe(
58936173
58946174fn validateSwitchItemBool(
58956175 sema: *Sema,
5896 block: *Scope.Block,
6176 block: *Block,
58976177 true_count: *u8,
58986178 false_count: *u8,
58996179 item_ref: Zir.Inst.Ref,
......@@ -5916,7 +6196,7 @@ const ValueSrcMap = std.HashMap(Value, Module.SwitchProngSrc, Value.HashContext,
59166196
59176197fn validateSwitchItemSparse(
59186198 sema: *Sema,
5919 block: *Scope.Block,
6199 block: *Block,
59206200 seen_values: *ValueSrcMap,
59216201 item_ref: Zir.Inst.Ref,
59226202 src_node_offset: i32,
......@@ -5929,7 +6209,7 @@ fn validateSwitchItemSparse(
59296209
59306210fn validateSwitchNoRange(
59316211 sema: *Sema,
5932 block: *Scope.Block,
6212 block: *Block,
59336213 ranges_len: u32,
59346214 operand_ty: Type,
59356215 src_node_offset: i32,
......@@ -5960,7 +6240,7 @@ fn validateSwitchNoRange(
59606240 return sema.failWithOwnedErrorMsg(msg);
59616241}
59626242
5963fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6243fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59646244 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59656245 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
59666246 _ = extra;
......@@ -5969,7 +6249,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
59696249 return sema.fail(block, src, "TODO implement zirHasField", .{});
59706250}
59716251
5972fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6252fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59736253 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
59746254 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
59756255 const src = inst_data.src();
......@@ -5985,14 +6265,14 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
59856265 .{container_type},
59866266 );
59876267 if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| {
5988 if (decl.is_pub or decl.getFileScope() == block.base.namespace().file_scope) {
6268 if (decl.is_pub or decl.getFileScope() == block.getFileScope()) {
59896269 return Air.Inst.Ref.bool_true;
59906270 }
59916271 }
59926272 return Air.Inst.Ref.bool_false;
59936273}
59946274
5995fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6275fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
59966276 const tracy = trace(@src());
59976277 defer tracy.end();
59986278
......@@ -6017,7 +6297,7 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
60176297 return sema.addConstant(file_root_decl.ty, file_root_decl.val);
60186298}
60196299
6020fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6300fn zirRetErrValueCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60216301 _ = block;
60226302 _ = inst;
60236303 return sema.fail(block, sema.src, "TODO implement zirRetErrValueCode", .{});
......@@ -6025,7 +6305,7 @@ fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co
60256305
60266306fn zirShl(
60276307 sema: *Sema,
6028 block: *Scope.Block,
6308 block: *Block,
60296309 inst: Zir.Inst.Index,
60306310 air_tag: Air.Inst.Tag,
60316311) CompileError!Air.Inst.Ref {
......@@ -6076,7 +6356,7 @@ fn zirShl(
60766356 return block.addBinOp(air_tag, lhs, rhs);
60776357}
60786358
6079fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6359fn zirShr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60806360 const tracy = trace(@src());
60816361 defer tracy.end();
60826362
......@@ -6109,7 +6389,7 @@ fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
61096389
61106390fn zirBitwise(
61116391 sema: *Sema,
6112 block: *Scope.Block,
6392 block: *Block,
61136393 inst: Zir.Inst.Index,
61146394 air_tag: Air.Inst.Tag,
61156395) CompileError!Air.Inst.Ref {
......@@ -6175,7 +6455,7 @@ fn zirBitwise(
61756455 return block.addBinOp(air_tag, casted_lhs, casted_rhs);
61766456}
61776457
6178fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6458fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61796459 const tracy = trace(@src());
61806460 defer tracy.end();
61816461
......@@ -6183,7 +6463,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
61836463 return sema.fail(block, sema.src, "TODO implement zirBitNot", .{});
61846464}
61856465
6186fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6466fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
61876467 const tracy = trace(@src());
61886468 defer tracy.end();
61896469
......@@ -6267,7 +6547,7 @@ fn getArrayCatInfo(t: Type) ?Type.ArrayInfo {
62676547 };
62686548}
62696549
6270fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6550fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
62716551 const tracy = trace(@src());
62726552 defer tracy.end();
62736553
......@@ -6321,7 +6601,7 @@ fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
63216601
63226602fn zirNegate(
63236603 sema: *Sema,
6324 block: *Scope.Block,
6604 block: *Block,
63256605 inst: Zir.Inst.Index,
63266606 tag_override: Zir.Inst.Tag,
63276607) CompileError!Air.Inst.Ref {
......@@ -6340,7 +6620,7 @@ fn zirNegate(
63406620
63416621fn zirArithmetic(
63426622 sema: *Sema,
6343 block: *Scope.Block,
6623 block: *Block,
63446624 inst: Zir.Inst.Index,
63456625 zir_tag: Zir.Inst.Tag,
63466626) CompileError!Air.Inst.Ref {
......@@ -6360,7 +6640,7 @@ fn zirArithmetic(
63606640
63616641fn zirOverflowArithmetic(
63626642 sema: *Sema,
6363 block: *Scope.Block,
6643 block: *Block,
63646644 extended: Zir.Inst.Extended.InstData,
63656645) CompileError!Air.Inst.Ref {
63666646 const tracy = trace(@src());
......@@ -6374,7 +6654,7 @@ fn zirOverflowArithmetic(
63746654
63756655fn analyzeArithmetic(
63766656 sema: *Sema,
6377 block: *Scope.Block,
6657 block: *Block,
63786658 /// TODO performance investigation: make this comptime?
63796659 zir_tag: Zir.Inst.Tag,
63806660 lhs: Air.Inst.Ref,
......@@ -7035,7 +7315,7 @@ fn analyzeArithmetic(
70357315 return block.addBinOp(rs.air_tag, casted_lhs, casted_rhs);
70367316}
70377317
7038fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7318fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
70397319 const tracy = trace(@src());
70407320 defer tracy.end();
70417321
......@@ -7048,7 +7328,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!
70487328
70497329fn zirAsm(
70507330 sema: *Sema,
7051 block: *Scope.Block,
7331 block: *Block,
70527332 extended: Zir.Inst.Extended.InstData,
70537333 inst: Zir.Inst.Index,
70547334) CompileError!Air.Inst.Ref {
......@@ -7127,7 +7407,7 @@ fn zirAsm(
71277407/// Only called for equality operators. See also `zirCmp`.
71287408fn zirCmpEq(
71297409 sema: *Sema,
7130 block: *Scope.Block,
7410 block: *Block,
71317411 inst: Zir.Inst.Index,
71327412 op: std.math.CompareOperator,
71337413 air_tag: Air.Inst.Tag,
......@@ -7216,7 +7496,7 @@ fn zirCmpEq(
72167496
72177497fn analyzeCmpUnionTag(
72187498 sema: *Sema,
7219 block: *Scope.Block,
7499 block: *Block,
72207500 un: Air.Inst.Ref,
72217501 un_src: LazySrcLoc,
72227502 tag: Air.Inst.Ref,
......@@ -7239,7 +7519,7 @@ fn analyzeCmpUnionTag(
72397519/// Only called for non-equality operators. See also `zirCmpEq`.
72407520fn zirCmp(
72417521 sema: *Sema,
7242 block: *Scope.Block,
7522 block: *Block,
72437523 inst: Zir.Inst.Index,
72447524 op: std.math.CompareOperator,
72457525) CompileError!Air.Inst.Ref {
......@@ -7258,7 +7538,7 @@ fn zirCmp(
72587538
72597539fn analyzeCmp(
72607540 sema: *Sema,
7261 block: *Scope.Block,
7541 block: *Block,
72627542 src: LazySrcLoc,
72637543 lhs: Air.Inst.Ref,
72647544 rhs: Air.Inst.Ref,
......@@ -7289,7 +7569,7 @@ fn analyzeCmp(
72897569
72907570fn cmpSelf(
72917571 sema: *Sema,
7292 block: *Scope.Block,
7572 block: *Block,
72937573 casted_lhs: Air.Inst.Ref,
72947574 casted_rhs: Air.Inst.Ref,
72957575 op: std.math.CompareOperator,
......@@ -7347,7 +7627,7 @@ fn cmpSelf(
73477627/// cmp_neq(x, true ) => not(x)
73487628fn runtimeBoolCmp(
73497629 sema: *Sema,
7350 block: *Scope.Block,
7630 block: *Block,
73517631 op: std.math.CompareOperator,
73527632 lhs: Air.Inst.Ref,
73537633 rhs: bool,
......@@ -7361,7 +7641,7 @@ fn runtimeBoolCmp(
73617641 }
73627642}
73637643
7364fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7644fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
73657645 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
73667646 const src = inst_data.src();
73677647 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -7402,7 +7682,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
74027682 return sema.addIntUnsigned(Type.initTag(.comptime_int), abi_size);
74037683}
74047684
7405fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7685fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
74067686 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
74077687 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
74087688 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
......@@ -7413,17 +7693,17 @@ fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
74137693
74147694fn zirThis(
74157695 sema: *Sema,
7416 block: *Scope.Block,
7696 block: *Block,
74177697 extended: Zir.Inst.Extended.InstData,
74187698) CompileError!Air.Inst.Ref {
7419 const this_decl = block.base.namespace().getDecl();
7699 const this_decl = block.namespace.getDecl();
74207700 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
74217701 return sema.analyzeDeclVal(block, src, this_decl);
74227702}
74237703
74247704fn zirClosureCapture(
74257705 sema: *Sema,
7426 block: *Scope.Block,
7706 block: *Block,
74277707 inst: Zir.Inst.Index,
74287708) CompileError!void {
74297709 // TODO: Compile error when closed over values are modified
......@@ -7437,7 +7717,7 @@ fn zirClosureCapture(
74377717
74387718fn zirClosureGet(
74397719 sema: *Sema,
7440 block: *Scope.Block,
7720 block: *Block,
74417721 inst: Zir.Inst.Index,
74427722) CompileError!Air.Inst.Ref {
74437723 // TODO CLOSURE: Test this with inline functions
......@@ -7459,7 +7739,7 @@ fn zirClosureGet(
74597739
74607740fn zirRetAddr(
74617741 sema: *Sema,
7462 block: *Scope.Block,
7742 block: *Block,
74637743 extended: Zir.Inst.Extended.InstData,
74647744) CompileError!Air.Inst.Ref {
74657745 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
......@@ -7468,14 +7748,14 @@ fn zirRetAddr(
74687748
74697749fn zirBuiltinSrc(
74707750 sema: *Sema,
7471 block: *Scope.Block,
7751 block: *Block,
74727752 extended: Zir.Inst.Extended.InstData,
74737753) CompileError!Air.Inst.Ref {
74747754 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
74757755 return sema.fail(block, src, "TODO: implement Sema.zirBuiltinSrc", .{});
74767756}
74777757
7478fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7758fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
74797759 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
74807760 const src = inst_data.src();
74817761 const ty = try sema.resolveType(block, src, inst_data.operand);
......@@ -7680,7 +7960,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
76807960 }
76817961}
76827962
7683fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7963fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
76847964 _ = block;
76857965 const zir_datas = sema.code.instructions.items(.data);
76867966 const inst_data = zir_datas[inst].un_node;
......@@ -7689,7 +7969,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
76897969 return sema.addType(operand_ty);
76907970}
76917971
7692fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7972fn zirTypeofElem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
76937973 _ = block;
76947974 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
76957975 const operand_ptr = sema.resolveInst(inst_data.operand);
......@@ -7697,7 +7977,7 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
76977977 return sema.addType(elem_ty);
76987978}
76997979
7700fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7980fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
77017981 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
77027982 const src = inst_data.src();
77037983 const operand = sema.resolveInst(inst_data.operand);
......@@ -7705,14 +7985,14 @@ fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
77057985 return sema.log2IntType(block, operand_ty, src);
77067986}
77077987
7708fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
7988fn zirLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
77097989 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
77107990 const src = inst_data.src();
77117991 const operand = try sema.resolveType(block, src, inst_data.operand);
77127992 return sema.log2IntType(block, operand, src);
77137993}
77147994
7715fn log2IntType(sema: *Sema, block: *Scope.Block, operand: Type, src: LazySrcLoc) CompileError!Air.Inst.Ref {
7995fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) CompileError!Air.Inst.Ref {
77167996 switch (operand.zigTypeTag()) {
77177997 .ComptimeInt => return Air.Inst.Ref.comptime_int_type,
77187998 .Int => {
......@@ -7735,7 +8015,7 @@ fn log2IntType(sema: *Sema, block: *Scope.Block, operand: Type, src: LazySrcLoc)
77358015
77368016fn zirTypeofPeer(
77378017 sema: *Sema,
7738 block: *Scope.Block,
8018 block: *Block,
77398019 extended: Zir.Inst.Extended.InstData,
77408020) CompileError!Air.Inst.Ref {
77418021 const tracy = trace(@src());
......@@ -7756,7 +8036,7 @@ fn zirTypeofPeer(
77568036 return sema.addType(result_type);
77578037}
77588038
7759fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8039fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
77608040 const tracy = trace(@src());
77618041 defer tracy.end();
77628042
......@@ -7780,7 +8060,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
77808060
77818061fn zirBoolBr(
77828062 sema: *Sema,
7783 parent_block: *Scope.Block,
8063 parent_block: *Block,
77848064 inst: Zir.Inst.Index,
77858065 is_bool_or: bool,
77868066) CompileError!Air.Inst.Ref {
......@@ -7866,7 +8146,7 @@ fn zirBoolBr(
78668146
78678147fn zirIsNonNull(
78688148 sema: *Sema,
7869 block: *Scope.Block,
8149 block: *Block,
78708150 inst: Zir.Inst.Index,
78718151) CompileError!Air.Inst.Ref {
78728152 const tracy = trace(@src());
......@@ -7880,7 +8160,7 @@ fn zirIsNonNull(
78808160
78818161fn zirIsNonNullPtr(
78828162 sema: *Sema,
7883 block: *Scope.Block,
8163 block: *Block,
78848164 inst: Zir.Inst.Index,
78858165) CompileError!Air.Inst.Ref {
78868166 const tracy = trace(@src());
......@@ -7893,7 +8173,7 @@ fn zirIsNonNullPtr(
78938173 return sema.analyzeIsNull(block, src, loaded, true);
78948174}
78958175
7896fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8176fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
78978177 const tracy = trace(@src());
78988178 defer tracy.end();
78998179
......@@ -7902,7 +8182,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
79028182 return sema.analyzeIsNonErr(block, inst_data.src(), operand);
79038183}
79048184
7905fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8185fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
79068186 const tracy = trace(@src());
79078187 defer tracy.end();
79088188
......@@ -7915,7 +8195,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
79158195
79168196fn zirCondbr(
79178197 sema: *Sema,
7918 parent_block: *Scope.Block,
8198 parent_block: *Block,
79198199 inst: Zir.Inst.Index,
79208200) CompileError!Zir.Inst.Index {
79218201 const tracy = trace(@src());
......@@ -7970,7 +8250,7 @@ fn zirCondbr(
79708250 return always_noreturn;
79718251}
79728252
7973fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
8253fn zirUnreachable(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
79748254 const tracy = trace(@src());
79758255 defer tracy.end();
79768256
......@@ -7989,7 +8269,7 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
79898269
79908270fn zirRetErrValue(
79918271 sema: *Sema,
7992 block: *Scope.Block,
8272 block: *Block,
79938273 inst: Zir.Inst.Index,
79948274) CompileError!Zir.Inst.Index {
79958275 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
......@@ -8013,7 +8293,7 @@ fn zirRetErrValue(
80138293
80148294fn zirRetCoerce(
80158295 sema: *Sema,
8016 block: *Scope.Block,
8296 block: *Block,
80178297 inst: Zir.Inst.Index,
80188298) CompileError!Zir.Inst.Index {
80198299 const tracy = trace(@src());
......@@ -8026,7 +8306,7 @@ fn zirRetCoerce(
80268306 return sema.analyzeRet(block, operand, src, true);
80278307}
80288308
8029fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
8309fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
80308310 const tracy = trace(@src());
80318311 defer tracy.end();
80328312
......@@ -8041,7 +8321,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
80418321 return sema.analyzeRet(block, operand, src, false);
80428322}
80438323
8044fn zirRetLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
8324fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
80458325 const tracy = trace(@src());
80468326 defer tracy.end();
80478327
......@@ -8058,7 +8338,7 @@ fn zirRetLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
80588338
80598339fn analyzeRet(
80608340 sema: *Sema,
8061 block: *Scope.Block,
8341 block: *Block,
80628342 uncasted_operand: Air.Inst.Ref,
80638343 src: LazySrcLoc,
80648344 need_coercion: bool,
......@@ -8091,7 +8371,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool {
80918371 };
80928372}
80938373
8094fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8374fn zirPtrTypeSimple(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
80958375 const tracy = trace(@src());
80968376 defer tracy.end();
80978377
......@@ -8108,7 +8388,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp
81088388 return sema.addType(ty);
81098389}
81108390
8111fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8391fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
81128392 const tracy = trace(@src());
81138393 defer tracy.end();
81148394
......@@ -8168,7 +8448,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
81688448 return sema.addType(ty);
81698449}
81708450
8171fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8451fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
81728452 const tracy = trace(@src());
81738453 defer tracy.end();
81748454
......@@ -8179,13 +8459,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co
81798459 return sema.addConstant(struct_type, Value.initTag(.empty_struct_value));
81808460}
81818461
8182fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8462fn zirUnionInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
81838463 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
81848464 const src = inst_data.src();
81858465 return sema.fail(block, src, "TODO: Sema.zirUnionInitPtr", .{});
81868466}
81878467
8188fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
8468fn zirStructInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
81898469 const gpa = sema.gpa;
81908470 const zir_datas = sema.code.instructions.items(.data);
81918471 const inst_data = zir_datas[inst].pl_node;
......@@ -8326,7 +8606,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
83268606 unreachable;
83278607}
83288608
8329fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
8609fn zirStructInitAnon(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
83308610 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
83318611 const src = inst_data.src();
83328612
......@@ -8334,7 +8614,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_
83348614 return sema.fail(block, src, "TODO: Sema.zirStructInitAnon", .{});
83358615}
83368616
8337fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
8617fn zirArrayInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
83388618 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
83398619 const src = inst_data.src();
83408620
......@@ -8386,7 +8666,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
83868666 try sema.analyzeLoad(block, .unneeded, alloc, .unneeded);
83878667}
83888668
8389fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
8669fn zirArrayInitAnon(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
83908670 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
83918671 const src = inst_data.src();
83928672
......@@ -8394,13 +8674,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r
83948674 return sema.fail(block, src, "TODO: Sema.zirArrayInitAnon", .{});
83958675}
83968676
8397fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8677fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
83988678 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
83998679 const src = inst_data.src();
84008680 return sema.fail(block, src, "TODO: Sema.zirFieldTypeRef", .{});
84018681}
84028682
8403fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8683fn zirFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84048684 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
84058685 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;
84068686 const src = inst_data.src();
......@@ -8428,7 +8708,7 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
84288708
84298709fn zirErrorReturnTrace(
84308710 sema: *Sema,
8431 block: *Scope.Block,
8711 block: *Block,
84328712 extended: Zir.Inst.Extended.InstData,
84338713) CompileError!Air.Inst.Ref {
84348714 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
......@@ -8437,7 +8717,7 @@ fn zirErrorReturnTrace(
84378717
84388718fn zirFrame(
84398719 sema: *Sema,
8440 block: *Scope.Block,
8720 block: *Block,
84418721 extended: Zir.Inst.Extended.InstData,
84428722) CompileError!Air.Inst.Ref {
84438723 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
......@@ -8446,14 +8726,14 @@ fn zirFrame(
84468726
84478727fn zirFrameAddress(
84488728 sema: *Sema,
8449 block: *Scope.Block,
8729 block: *Block,
84508730 extended: Zir.Inst.Extended.InstData,
84518731) CompileError!Air.Inst.Ref {
84528732 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
84538733 return sema.fail(block, src, "TODO: Sema.zirFrameAddress", .{});
84548734}
84558735
8456fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8736fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84578737 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84588738 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
84598739 const ty = try sema.resolveType(block, operand_src, inst_data.operand);
......@@ -8462,7 +8742,7 @@ fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
84628742 return sema.addIntUnsigned(Type.comptime_int, abi_align);
84638743}
84648744
8465fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8745fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84668746 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84678747 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
84688748 const operand = sema.resolveInst(inst_data.operand);
......@@ -8474,31 +8754,31 @@ fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
84748754 return block.addUnOp(.bool_to_int, operand);
84758755}
84768756
8477fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8757fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84788758 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84798759 const src = inst_data.src();
84808760 return sema.fail(block, src, "TODO: Sema.zirEmbedFile", .{});
84818761}
84828762
8483fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8763fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84848764 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84858765 const src = inst_data.src();
84868766 return sema.fail(block, src, "TODO: Sema.zirErrorName", .{});
84878767}
84888768
8489fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8769fn zirUnaryMath(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84908770 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84918771 const src = inst_data.src();
84928772 return sema.fail(block, src, "TODO: Sema.zirUnaryMath", .{});
84938773}
84948774
8495fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8775fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
84968776 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
84978777 const src = inst_data.src();
84988778 return sema.fail(block, src, "TODO: Sema.zirTagName", .{});
84998779}
85008780
8501fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8781fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85028782 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
85038783 const src = inst_data.src();
85048784 const type_info_ty = try sema.getBuiltinType(block, src, "TypeInfo");
......@@ -8551,32 +8831,32 @@ fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError
85518831 }
85528832}
85538833
8554fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8834fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85558835 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
85568836 const src = inst_data.src();
85578837 return sema.fail(block, src, "TODO: Sema.zirTypeName", .{});
85588838}
85598839
8560fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8840fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85618841 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
85628842 const src = inst_data.src();
85638843 return sema.fail(block, src, "TODO: Sema.zirFrameType", .{});
85648844}
85658845
8566fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8846fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85678847 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
85688848 const src = inst_data.src();
85698849 return sema.fail(block, src, "TODO: Sema.zirFrameSize", .{});
85708850}
85718851
8572fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8852fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85738853 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
85748854 const src = inst_data.src();
85758855 // TODO don't forget the safety check!
85768856 return sema.fail(block, src, "TODO: Sema.zirFloatToInt", .{});
85778857}
85788858
8579fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8859fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85808860 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
85818861 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
85828862 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -8598,7 +8878,7 @@ fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
85988878 return block.addTyOp(.int_to_float, dest_ty, operand);
85998879}
86008880
8601fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8881fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
86028882 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
86038883 const src = inst_data.src();
86048884
......@@ -8654,13 +8934,13 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
86548934 return block.addTyOp(.bitcast, type_res, operand_coerced);
86558935}
86568936
8657fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8937fn zirErrSetCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
86588938 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
86598939 const src = inst_data.src();
86608940 return sema.fail(block, src, "TODO: Sema.zirErrSetCast", .{});
86618941}
86628942
8663fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8943fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
86648944 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
86658945 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
86668946 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -8684,7 +8964,7 @@ fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr
86848964 return block.addTyOp(.bitcast, dest_ty, operand);
86858965}
86868966
8687fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8967fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
86888968 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
86898969 const src = inst_data.src();
86908970 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -8744,13 +9024,13 @@ fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
87449024 return block.addTyOp(.trunc, dest_ty, operand);
87459025}
87469026
8747fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9027fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
87489028 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
87499029 const src = inst_data.src();
87509030 return sema.fail(block, src, "TODO: Sema.zirAlignCast", .{});
87519031}
87529032
8753fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9033fn zirClz(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
87549034 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
87559035 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
87569036 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -8777,7 +9057,7 @@ fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
87779057 return block.addTyOp(.clz, result_ty, operand);
87789058}
87799059
8780fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9060fn zirCtz(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
87819061 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
87829062 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
87839063 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -8804,62 +9084,62 @@ fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A
88049084 return block.addTyOp(.ctz, result_ty, operand);
88059085}
88069086
8807fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9087fn zirPopCount(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88089088 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
88099089 const src = inst_data.src();
88109090 return sema.fail(block, src, "TODO: Sema.zirPopCount", .{});
88119091}
88129092
8813fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9093fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88149094 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
88159095 const src = inst_data.src();
88169096 return sema.fail(block, src, "TODO: Sema.zirByteSwap", .{});
88179097}
88189098
8819fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9099fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88209100 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
88219101 const src = inst_data.src();
88229102 return sema.fail(block, src, "TODO: Sema.zirBitReverse", .{});
88239103}
88249104
8825fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9105fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88269106 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88279107 const src = inst_data.src();
88289108 return sema.fail(block, src, "TODO: Sema.zirDivExact", .{});
88299109}
88309110
8831fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9111fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88329112 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88339113 const src = inst_data.src();
88349114 return sema.fail(block, src, "TODO: Sema.zirDivFloor", .{});
88359115}
88369116
8837fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9117fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88389118 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88399119 const src = inst_data.src();
88409120 return sema.fail(block, src, "TODO: Sema.zirDivTrunc", .{});
88419121}
88429122
8843fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9123fn zirShrExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88449124 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88459125 const src = inst_data.src();
88469126 return sema.fail(block, src, "TODO: Sema.zirShrExact", .{});
88479127}
88489128
8849fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9129fn zirBitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88509130 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88519131 const src = inst_data.src();
88529132 return sema.fail(block, src, "TODO: Sema.zirBitOffsetOf", .{});
88539133}
88549134
8855fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9135fn zirOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88569136 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
88579137 const src = inst_data.src();
88589138 return sema.fail(block, src, "TODO: Sema.zirOffsetOf", .{});
88599139}
88609140
88619141/// Returns `true` if the type was a comptime_int.
8862fn checkIntType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!bool {
9142fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool {
88639143 switch (ty.zigTypeTag()) {
88649144 .ComptimeInt => return true,
88659145 .Int => return false,
......@@ -8869,7 +9149,7 @@ fn checkIntType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) Com
88699149
88709150fn checkFloatType(
88719151 sema: *Sema,
8872 block: *Scope.Block,
9152 block: *Block,
88739153 ty_src: LazySrcLoc,
88749154 ty: Type,
88759155) CompileError!void {
......@@ -8883,7 +9163,7 @@ fn checkFloatType(
88839163
88849164fn checkAtomicOperandType(
88859165 sema: *Sema,
8886 block: *Scope.Block,
9166 block: *Block,
88879167 ty_src: LazySrcLoc,
88889168 ty: Type,
88899169) CompileError!void {
......@@ -8930,7 +9210,7 @@ fn checkAtomicOperandType(
89309210
89319211fn resolveExportOptions(
89329212 sema: *Sema,
8933 block: *Scope.Block,
9213 block: *Block,
89349214 src: LazySrcLoc,
89359215 zir_ref: Zir.Inst.Ref,
89369216) CompileError!std.builtin.ExportOptions {
......@@ -8955,7 +9235,7 @@ fn resolveExportOptions(
89559235
89569236fn resolveAtomicOrder(
89579237 sema: *Sema,
8958 block: *Scope.Block,
9238 block: *Block,
89599239 src: LazySrcLoc,
89609240 zir_ref: Zir.Inst.Ref,
89619241) CompileError!std.builtin.AtomicOrder {
......@@ -8968,7 +9248,7 @@ fn resolveAtomicOrder(
89689248
89699249fn resolveAtomicRmwOp(
89709250 sema: *Sema,
8971 block: *Scope.Block,
9251 block: *Block,
89729252 src: LazySrcLoc,
89739253 zir_ref: Zir.Inst.Ref,
89749254) CompileError!std.builtin.AtomicRmwOp {
......@@ -8981,7 +9261,7 @@ fn resolveAtomicRmwOp(
89819261
89829262fn zirCmpxchg(
89839263 sema: *Sema,
8984 block: *Scope.Block,
9264 block: *Block,
89859265 inst: Zir.Inst.Index,
89869266 air_tag: Air.Inst.Tag,
89879267) CompileError!Air.Inst.Ref {
......@@ -9069,31 +9349,31 @@ fn zirCmpxchg(
90699349 });
90709350}
90719351
9072fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9352fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
90739353 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
90749354 const src = inst_data.src();
90759355 return sema.fail(block, src, "TODO: Sema.zirSplat", .{});
90769356}
90779357
9078fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9358fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
90799359 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
90809360 const src = inst_data.src();
90819361 return sema.fail(block, src, "TODO: Sema.zirReduce", .{});
90829362}
90839363
9084fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9364fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
90859365 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
90869366 const src = inst_data.src();
90879367 return sema.fail(block, src, "TODO: Sema.zirShuffle", .{});
90889368}
90899369
9090fn zirSelect(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9370fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
90919371 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
90929372 const src = inst_data.src();
90939373 return sema.fail(block, src, "TODO: Sema.zirSelect", .{});
90949374}
90959375
9096fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9376fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
90979377 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
90989378 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
90999379 // zig fmt: off
......@@ -9138,7 +9418,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile
91389418 });
91399419}
91409420
9141fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9421fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
91429422 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
91439423 const extra = sema.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data;
91449424 const src = inst_data.src();
......@@ -9216,7 +9496,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE
92169496 });
92179497}
92189498
9219fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
9499fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
92209500 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92219501 const extra = sema.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data;
92229502 const src = inst_data.src();
......@@ -9250,37 +9530,37 @@ fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil
92509530 return sema.storePtr2(block, src, ptr, ptr_src, operand, operand_src, air_tag);
92519531}
92529532
9253fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9533fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
92549534 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92559535 const src = inst_data.src();
92569536 return sema.fail(block, src, "TODO: Sema.zirMulAdd", .{});
92579537}
92589538
9259fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9539fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
92609540 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92619541 const src = inst_data.src();
92629542 return sema.fail(block, src, "TODO: Sema.zirBuiltinCall", .{});
92639543}
92649544
9265fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9545fn zirFieldPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
92669546 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92679547 const src = inst_data.src();
92689548 return sema.fail(block, src, "TODO: Sema.zirFieldPtrType", .{});
92699549}
92709550
9271fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9551fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
92729552 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92739553 const src = inst_data.src();
92749554 return sema.fail(block, src, "TODO: Sema.zirFieldParentPtr", .{});
92759555}
92769556
9277fn zirMaximum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9557fn zirMaximum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
92789558 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92799559 const src = inst_data.src();
92809560 return sema.fail(block, src, "TODO: Sema.zirMaximum", .{});
92819561}
92829562
9283fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
9563fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
92849564 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
92859565 const extra = sema.code.extraData(Zir.Inst.Memcpy, inst_data.payload_index).data;
92869566 const src = inst_data.src();
......@@ -9345,7 +9625,7 @@ fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
93459625 });
93469626}
93479627
9348fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
9628fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
93499629 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
93509630 const extra = sema.code.extraData(Zir.Inst.Memset, inst_data.payload_index).data;
93519631 const src = inst_data.src();
......@@ -9391,19 +9671,19 @@ fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
93919671 });
93929672}
93939673
9394fn zirMinimum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9674fn zirMinimum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
93959675 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
93969676 const src = inst_data.src();
93979677 return sema.fail(block, src, "TODO: Sema.zirMinimum", .{});
93989678}
93999679
9400fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9680fn zirBuiltinAsyncCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
94019681 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
94029682 const src = inst_data.src();
94039683 return sema.fail(block, src, "TODO: Sema.zirBuiltinAsyncCall", .{});
94049684}
94059685
9406fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9686fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
94079687 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
94089688 const src = inst_data.src();
94099689 return sema.fail(block, src, "TODO: Sema.zirResume", .{});
......@@ -9411,7 +9691,7 @@ fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro
94119691
94129692fn zirAwait(
94139693 sema: *Sema,
9414 block: *Scope.Block,
9694 block: *Block,
94159695 inst: Zir.Inst.Index,
94169696 is_nosuspend: bool,
94179697) CompileError!Air.Inst.Ref {
......@@ -9424,7 +9704,7 @@ fn zirAwait(
94249704
94259705fn zirVarExtended(
94269706 sema: *Sema,
9427 block: *Scope.Block,
9707 block: *Block,
94289708 extended: Zir.Inst.Extended.InstData,
94299709) CompileError!Air.Inst.Ref {
94309710 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
......@@ -9499,7 +9779,7 @@ fn zirVarExtended(
94999779
95009780fn zirFuncExtended(
95019781 sema: *Sema,
9502 block: *Scope.Block,
9782 block: *Block,
95039783 extended: Zir.Inst.Extended.InstData,
95049784 inst: Zir.Inst.Index,
95059785) CompileError!Air.Inst.Ref {
......@@ -9566,7 +9846,7 @@ fn zirFuncExtended(
95669846
95679847fn zirCUndef(
95689848 sema: *Sema,
9569 block: *Scope.Block,
9849 block: *Block,
95709850 extended: Zir.Inst.Extended.InstData,
95719851) CompileError!Air.Inst.Ref {
95729852 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
......@@ -9579,7 +9859,7 @@ fn zirCUndef(
95799859
95809860fn zirCInclude(
95819861 sema: *Sema,
9582 block: *Scope.Block,
9862 block: *Block,
95839863 extended: Zir.Inst.Extended.InstData,
95849864) CompileError!Air.Inst.Ref {
95859865 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
......@@ -9592,7 +9872,7 @@ fn zirCInclude(
95929872
95939873fn zirCDefine(
95949874 sema: *Sema,
9595 block: *Scope.Block,
9875 block: *Block,
95969876 extended: Zir.Inst.Extended.InstData,
95979877) CompileError!Air.Inst.Ref {
95989878 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
......@@ -9610,7 +9890,7 @@ fn zirCDefine(
96109890
96119891fn zirWasmMemorySize(
96129892 sema: *Sema,
9613 block: *Scope.Block,
9893 block: *Block,
96149894 extended: Zir.Inst.Extended.InstData,
96159895) CompileError!Air.Inst.Ref {
96169896 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
......@@ -9620,7 +9900,7 @@ fn zirWasmMemorySize(
96209900
96219901fn zirWasmMemoryGrow(
96229902 sema: *Sema,
9623 block: *Scope.Block,
9903 block: *Block,
96249904 extended: Zir.Inst.Extended.InstData,
96259905) CompileError!Air.Inst.Ref {
96269906 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
......@@ -9630,7 +9910,7 @@ fn zirWasmMemoryGrow(
96309910
96319911fn zirBuiltinExtern(
96329912 sema: *Sema,
9633 block: *Scope.Block,
9913 block: *Block,
96349914 extended: Zir.Inst.Extended.InstData,
96359915) CompileError!Air.Inst.Ref {
96369916 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
......@@ -9638,13 +9918,13 @@ fn zirBuiltinExtern(
96389918 return sema.fail(block, src, "TODO: implement Sema.zirBuiltinExtern", .{});
96399919}
96409920
9641fn requireFunctionBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void {
9921fn requireFunctionBlock(sema: *Sema, block: *Block, src: LazySrcLoc) !void {
96429922 if (sema.func == null) {
96439923 return sema.fail(block, src, "instruction illegal outside function body", .{});
96449924 }
96459925}
96469926
9647fn requireRuntimeBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void {
9927fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc) !void {
96489928 if (block.is_comptime) {
96499929 return sema.failWithNeededComptime(block, src);
96509930 }
......@@ -9654,7 +9934,7 @@ fn requireRuntimeBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void
96549934/// Emit a compile error if type cannot be used for a runtime variable.
96559935fn validateVarType(
96569936 sema: *Sema,
9657 block: *Scope.Block,
9937 block: *Block,
96589938 src: LazySrcLoc,
96599939 var_ty: Type,
96609940 is_extern: bool,
......@@ -9713,13 +9993,13 @@ pub const PanicId = enum {
97139993
97149994fn addSafetyCheck(
97159995 sema: *Sema,
9716 parent_block: *Scope.Block,
9996 parent_block: *Block,
97179997 ok: Air.Inst.Ref,
97189998 panic_id: PanicId,
97199999) !void {
972010000 const gpa = sema.gpa;
972110001
9722 var fail_block: Scope.Block = .{
10002 var fail_block: Block = .{
972310003 .parent = parent_block,
972410004 .sema = sema,
972510005 .src_decl = parent_block.src_decl,
......@@ -9783,7 +10063,7 @@ fn addSafetyCheck(
978310063
978410064fn panicWithMsg(
978510065 sema: *Sema,
9786 block: *Scope.Block,
10066 block: *Block,
978710067 src: LazySrcLoc,
978810068 msg_inst: Air.Inst.Ref,
978910069) !Zir.Inst.Index {
......@@ -9817,7 +10097,7 @@ fn panicWithMsg(
981710097
981810098fn safetyPanic(
981910099 sema: *Sema,
9820 block: *Scope.Block,
10100 block: *Block,
982110101 src: LazySrcLoc,
982210102 panic_id: PanicId,
982310103) CompileError!Zir.Inst.Index {
......@@ -9845,7 +10125,7 @@ fn safetyPanic(
984510125 return sema.panicWithMsg(block, src, casted_msg_inst);
984610126}
984710127
9848fn emitBackwardBranch(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void {
10128fn emitBackwardBranch(sema: *Sema, block: *Block, src: LazySrcLoc) !void {
984910129 sema.branch_count += 1;
985010130 if (sema.branch_count > sema.branch_quota) {
985110131 // TODO show the "called from here" stack
......@@ -9855,7 +10135,7 @@ fn emitBackwardBranch(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void {
985510135
985610136fn fieldVal(
985710137 sema: *Sema,
9858 block: *Scope.Block,
10138 block: *Block,
985910139 src: LazySrcLoc,
986010140 object: Air.Inst.Ref,
986110141 field_name: []const u8,
......@@ -10036,7 +10316,7 @@ fn fieldVal(
1003610316
1003710317fn fieldPtr(
1003810318 sema: *Sema,
10039 block: *Scope.Block,
10319 block: *Block,
1004010320 src: LazySrcLoc,
1004110321 object_ptr: Air.Inst.Ref,
1004210322 field_name: []const u8,
......@@ -10227,7 +10507,7 @@ fn fieldPtr(
1022710507
1022810508fn fieldCallBind(
1022910509 sema: *Sema,
10230 block: *Scope.Block,
10510 block: *Block,
1023110511 src: LazySrcLoc,
1023210512 raw_ptr: Air.Inst.Ref,
1023310513 field_name: []const u8,
......@@ -10368,9 +10648,9 @@ fn fieldCallBind(
1036810648
1036910649fn namespaceLookup(
1037010650 sema: *Sema,
10371 block: *Scope.Block,
10651 block: *Block,
1037210652 src: LazySrcLoc,
10373 namespace: *Scope.Namespace,
10653 namespace: *Namespace,
1037410654 decl_name: []const u8,
1037510655) CompileError!?*Decl {
1037610656 const gpa = sema.gpa;
......@@ -10393,9 +10673,9 @@ fn namespaceLookup(
1039310673
1039410674fn namespaceLookupRef(
1039510675 sema: *Sema,
10396 block: *Scope.Block,
10676 block: *Block,
1039710677 src: LazySrcLoc,
10398 namespace: *Scope.Namespace,
10678 namespace: *Namespace,
1039910679 decl_name: []const u8,
1040010680) CompileError!?Air.Inst.Ref {
1040110681 const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null;
......@@ -10404,7 +10684,7 @@ fn namespaceLookupRef(
1040410684
1040510685fn structFieldPtr(
1040610686 sema: *Sema,
10407 block: *Scope.Block,
10687 block: *Block,
1040810688 src: LazySrcLoc,
1040910689 struct_ptr: Air.Inst.Ref,
1041010690 field_name: []const u8,
......@@ -10444,7 +10724,7 @@ fn structFieldPtr(
1044410724
1044510725fn structFieldVal(
1044610726 sema: *Sema,
10447 block: *Scope.Block,
10727 block: *Block,
1044810728 src: LazySrcLoc,
1044910729 struct_byval: Air.Inst.Ref,
1045010730 field_name: []const u8,
......@@ -10482,7 +10762,7 @@ fn structFieldVal(
1048210762
1048310763fn unionFieldPtr(
1048410764 sema: *Sema,
10485 block: *Scope.Block,
10765 block: *Block,
1048610766 src: LazySrcLoc,
1048710767 union_ptr: Air.Inst.Ref,
1048810768 field_name: []const u8,
......@@ -10524,7 +10804,7 @@ fn unionFieldPtr(
1052410804
1052510805fn unionFieldVal(
1052610806 sema: *Sema,
10527 block: *Scope.Block,
10807 block: *Block,
1052810808 src: LazySrcLoc,
1052910809 union_byval: Air.Inst.Ref,
1053010810 field_name: []const u8,
......@@ -10555,7 +10835,7 @@ fn unionFieldVal(
1055510835
1055610836fn elemPtr(
1055710837 sema: *Sema,
10558 block: *Scope.Block,
10838 block: *Block,
1055910839 src: LazySrcLoc,
1056010840 array_ptr: Air.Inst.Ref,
1056110841 elem_index: Air.Inst.Ref,
......@@ -10584,7 +10864,7 @@ fn elemPtr(
1058410864
1058510865fn elemVal(
1058610866 sema: *Sema,
10587 block: *Scope.Block,
10867 block: *Block,
1058810868 src: LazySrcLoc,
1058910869 array_maybe_ptr: Air.Inst.Ref,
1059010870 elem_index: Air.Inst.Ref,
......@@ -10673,7 +10953,7 @@ fn elemVal(
1067310953
1067410954fn elemPtrArray(
1067510955 sema: *Sema,
10676 block: *Scope.Block,
10956 block: *Block,
1067710957 src: LazySrcLoc,
1067810958 array_ptr: Air.Inst.Ref,
1067910959 elem_index: Air.Inst.Ref,
......@@ -10713,7 +10993,7 @@ fn elemPtrArray(
1071310993
1071410994fn coerce(
1071510995 sema: *Sema,
10716 block: *Scope.Block,
10996 block: *Block,
1071710997 dest_type_unresolved: Type,
1071810998 inst: Air.Inst.Ref,
1071910999 inst_src: LazySrcLoc,
......@@ -10985,7 +11265,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type, dest_is_mut: bool, tar
1098511265
1098611266fn coerceNum(
1098711267 sema: *Sema,
10988 block: *Scope.Block,
11268 block: *Block,
1098911269 dest_type: Type,
1099011270 inst: Air.Inst.Ref,
1099111271 inst_src: LazySrcLoc,
......@@ -11053,7 +11333,7 @@ fn coerceNum(
1105311333
1105411334fn coerceVarArgParam(
1105511335 sema: *Sema,
11056 block: *Scope.Block,
11336 block: *Block,
1105711337 inst: Air.Inst.Ref,
1105811338 inst_src: LazySrcLoc,
1105911339) !Air.Inst.Ref {
......@@ -11069,7 +11349,7 @@ fn coerceVarArgParam(
1106911349// TODO migrate callsites to use storePtr2 instead.
1107011350fn storePtr(
1107111351 sema: *Sema,
11072 block: *Scope.Block,
11352 block: *Block,
1107311353 src: LazySrcLoc,
1107411354 ptr: Air.Inst.Ref,
1107511355 uncasted_operand: Air.Inst.Ref,
......@@ -11079,7 +11359,7 @@ fn storePtr(
1107911359
1108011360fn storePtr2(
1108111361 sema: *Sema,
11082 block: *Scope.Block,
11362 block: *Block,
1108311363 src: LazySrcLoc,
1108411364 ptr: Air.Inst.Ref,
1108511365 ptr_src: LazySrcLoc,
......@@ -11116,7 +11396,7 @@ fn storePtr2(
1111611396/// assert the store must be done at comptime.
1111711397fn storePtrVal(
1111811398 sema: *Sema,
11119 block: *Scope.Block,
11399 block: *Block,
1112011400 src: LazySrcLoc,
1112111401 ptr_val: Value,
1112211402 operand_val: Value,
......@@ -11161,7 +11441,7 @@ fn storePtrVal(
1116111441
1116211442fn bitcast(
1116311443 sema: *Sema,
11164 block: *Scope.Block,
11444 block: *Block,
1116511445 dest_type: Type,
1116611446 inst: Air.Inst.Ref,
1116711447 inst_src: LazySrcLoc,
......@@ -11177,7 +11457,7 @@ fn bitcast(
1117711457
1117811458fn coerceArrayPtrToSlice(
1117911459 sema: *Sema,
11180 block: *Scope.Block,
11460 block: *Block,
1118111461 dest_type: Type,
1118211462 inst: Air.Inst.Ref,
1118311463 inst_src: LazySrcLoc,
......@@ -11192,7 +11472,7 @@ fn coerceArrayPtrToSlice(
1119211472
1119311473fn coerceArrayPtrToMany(
1119411474 sema: *Sema,
11195 block: *Scope.Block,
11475 block: *Block,
1119611476 dest_type: Type,
1119711477 inst: Air.Inst.Ref,
1119811478 inst_src: LazySrcLoc,
......@@ -11207,7 +11487,7 @@ fn coerceArrayPtrToMany(
1120711487
1120811488fn analyzeDeclVal(
1120911489 sema: *Sema,
11210 block: *Scope.Block,
11490 block: *Block,
1121111491 src: LazySrcLoc,
1121211492 decl: *Decl,
1121311493) CompileError!Air.Inst.Ref {
......@@ -11261,7 +11541,7 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref {
1126111541
1126211542fn analyzeRef(
1126311543 sema: *Sema,
11264 block: *Scope.Block,
11544 block: *Block,
1126511545 src: LazySrcLoc,
1126611546 operand: Air.Inst.Ref,
1126711547) CompileError!Air.Inst.Ref {
......@@ -11296,7 +11576,7 @@ fn analyzeRef(
1129611576
1129711577fn analyzeLoad(
1129811578 sema: *Sema,
11299 block: *Scope.Block,
11579 block: *Block,
1130011580 src: LazySrcLoc,
1130111581 ptr: Air.Inst.Ref,
1130211582 ptr_src: LazySrcLoc,
......@@ -11318,7 +11598,7 @@ fn analyzeLoad(
1131811598
1131911599fn analyzeSliceLen(
1132011600 sema: *Sema,
11321 block: *Scope.Block,
11601 block: *Block,
1132211602 src: LazySrcLoc,
1132311603 slice_inst: Air.Inst.Ref,
1132411604) CompileError!Air.Inst.Ref {
......@@ -11334,7 +11614,7 @@ fn analyzeSliceLen(
1133411614
1133511615fn analyzeIsNull(
1133611616 sema: *Sema,
11337 block: *Scope.Block,
11617 block: *Block,
1133811618 src: LazySrcLoc,
1133911619 operand: Air.Inst.Ref,
1134011620 invert_logic: bool,
......@@ -11359,7 +11639,7 @@ fn analyzeIsNull(
1135911639
1136011640fn analyzeIsNonErr(
1136111641 sema: *Sema,
11362 block: *Scope.Block,
11642 block: *Block,
1136311643 src: LazySrcLoc,
1136411644 operand: Air.Inst.Ref,
1136511645) CompileError!Air.Inst.Ref {
......@@ -11385,7 +11665,7 @@ fn analyzeIsNonErr(
1138511665
1138611666fn analyzeSlice(
1138711667 sema: *Sema,
11388 block: *Scope.Block,
11668 block: *Block,
1138911669 src: LazySrcLoc,
1139011670 array_ptr: Air.Inst.Ref,
1139111671 start: Air.Inst.Ref,
......@@ -11460,7 +11740,7 @@ fn analyzeSlice(
1146011740/// Asserts that lhs and rhs types are both numeric.
1146111741fn cmpNumeric(
1146211742 sema: *Sema,
11463 block: *Scope.Block,
11743 block: *Block,
1146411744 src: LazySrcLoc,
1146511745 lhs: Air.Inst.Ref,
1146611746 rhs: Air.Inst.Ref,
......@@ -11648,7 +11928,7 @@ fn cmpNumeric(
1164811928
1164911929fn wrapOptional(
1165011930 sema: *Sema,
11651 block: *Scope.Block,
11931 block: *Block,
1165211932 dest_type: Type,
1165311933 inst: Air.Inst.Ref,
1165411934 inst_src: LazySrcLoc,
......@@ -11663,7 +11943,7 @@ fn wrapOptional(
1166311943
1166411944fn wrapErrorUnion(
1166511945 sema: *Sema,
11666 block: *Scope.Block,
11946 block: *Block,
1166711947 dest_type: Type,
1166811948 inst: Air.Inst.Ref,
1166911949 inst_src: LazySrcLoc,
......@@ -11739,7 +12019,7 @@ fn wrapErrorUnion(
1173912019
1174012020fn unionToTag(
1174112021 sema: *Sema,
11742 block: *Scope.Block,
12022 block: *Block,
1174312023 dest_type: Type,
1174412024 un: Air.Inst.Ref,
1174512025 un_src: LazySrcLoc,
......@@ -11753,7 +12033,7 @@ fn unionToTag(
1175312033
1175412034fn resolvePeerTypes(
1175512035 sema: *Sema,
11756 block: *Scope.Block,
12036 block: *Block,
1175712037 src: LazySrcLoc,
1175812038 instructions: []Air.Inst.Ref,
1175912039 candidate_srcs: Module.PeerTypeCandidateSrc,
......@@ -11867,7 +12147,7 @@ fn resolvePeerTypes(
1186712147
1186812148pub fn resolveTypeLayout(
1186912149 sema: *Sema,
11870 block: *Scope.Block,
12150 block: *Block,
1187112151 src: LazySrcLoc,
1187212152 ty: Type,
1187312153) CompileError!void {
......@@ -11892,7 +12172,7 @@ pub fn resolveTypeLayout(
1189212172 }
1189312173}
1189412174
11895fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!Type {
12175fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type {
1189612176 switch (ty.tag()) {
1189712177 .@"struct" => {
1189812178 const struct_obj = ty.castTag(.@"struct").?.data;
......@@ -11943,7 +12223,7 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type
1194312223
1194412224fn resolveBuiltinTypeFields(
1194512225 sema: *Sema,
11946 block: *Scope.Block,
12226 block: *Block,
1194712227 src: LazySrcLoc,
1194812228 name: []const u8,
1194912229) CompileError!Type {
......@@ -12021,7 +12301,7 @@ fn semaStructFields(
1202112301 var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope);
1202212302 defer wip_captures.deinit();
1202312303
12024 var block_scope: Scope.Block = .{
12304 var block_scope: Block = .{
1202512305 .parent = null,
1202612306 .sema = &sema,
1202712307 .src_decl = decl,
......@@ -12191,7 +12471,7 @@ fn semaUnionFields(
1219112471 var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope);
1219212472 defer wip_captures.deinit();
1219312473
12194 var block_scope: Scope.Block = .{
12474 var block_scope: Block = .{
1219512475 .parent = null,
1219612476 .sema = &sema,
1219712477 .src_decl = decl,
......@@ -12322,7 +12602,7 @@ fn semaUnionFields(
1232212602
1232312603fn generateUnionTagTypeNumbered(
1232412604 sema: *Sema,
12325 block: *Scope.Block,
12605 block: *Block,
1232612606 fields_len: u32,
1232712607 int_ty: Type,
1232812608) !Type {
......@@ -12340,7 +12620,7 @@ fn generateUnionTagTypeNumbered(
1234012620 const enum_ty = Type.initPayload(&enum_ty_payload.base);
1234112621 const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty);
1234212622 // TODO better type name
12343 const new_decl = try mod.createAnonymousDecl(&block.base, .{
12623 const new_decl = try mod.createAnonymousDecl(block, .{
1234412624 .ty = Type.initTag(.type),
1234512625 .val = enum_val,
1234612626 });
......@@ -12361,7 +12641,7 @@ fn generateUnionTagTypeNumbered(
1236112641 return enum_ty;
1236212642}
1236312643
12364fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32) !Type {
12644fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: u32) !Type {
1236512645 const mod = sema.mod;
1236612646
1236712647 var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa);
......@@ -12376,7 +12656,7 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32)
1237612656 const enum_ty = Type.initPayload(&enum_ty_payload.base);
1237712657 const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty);
1237812658 // TODO better type name
12379 const new_decl = try mod.createAnonymousDecl(&block.base, .{
12659 const new_decl = try mod.createAnonymousDecl(block, .{
1238012660 .ty = Type.initTag(.type),
1238112661 .val = enum_val,
1238212662 });
......@@ -12396,7 +12676,7 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32)
1239612676
1239712677fn getBuiltin(
1239812678 sema: *Sema,
12399 block: *Scope.Block,
12679 block: *Block,
1240012680 src: LazySrcLoc,
1240112681 name: []const u8,
1240212682) CompileError!Air.Inst.Ref {
......@@ -12422,7 +12702,7 @@ fn getBuiltin(
1242212702
1242312703fn getBuiltinType(
1242412704 sema: *Sema,
12425 block: *Scope.Block,
12705 block: *Block,
1242612706 src: LazySrcLoc,
1242712707 name: []const u8,
1242812708) CompileError!Type {
......@@ -12436,7 +12716,7 @@ fn getBuiltinType(
1243612716/// that the types are already resolved.
1243712717fn typeHasOnePossibleValue(
1243812718 sema: *Sema,
12439 block: *Scope.Block,
12719 block: *Block,
1244012720 src: LazySrcLoc,
1244112721 starting_type: Type,
1244212722) CompileError!?Value {
......@@ -12599,7 +12879,7 @@ fn typeHasOnePossibleValue(
1259912879 };
1260012880}
1260112881
12602fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.Ast {
12882fn getAstTree(sema: *Sema, block: *Block) CompileError!*const std.zig.Ast {
1260312883 return block.namespace.file_scope.getTree(sema.gpa) catch |err| {
1260412884 log.err("unable to load AST to report compile error: {s}", .{@errorName(err)});
1260512885 return error.AnalysisFail;
......@@ -12789,7 +13069,7 @@ fn getBreakBlock(sema: *Sema, inst_index: Air.Inst.Index) ?Air.Inst.Index {
1278913069
1279013070fn isComptimeKnown(
1279113071 sema: *Sema,
12792 block: *Scope.Block,
13072 block: *Block,
1279313073 src: LazySrcLoc,
1279413074 inst: Air.Inst.Ref,
1279513075) !bool {
......@@ -12798,7 +13078,7 @@ fn isComptimeKnown(
1279813078
1279913079fn analyzeComptimeAlloc(
1280013080 sema: *Sema,
12801 block: *Scope.Block,
13081 block: *Block,
1280213082 var_type: Type,
1280313083) CompileError!Air.Inst.Ref {
1280413084 const ptr_type = try Type.ptr(sema.arena, .{
......@@ -12841,7 +13121,7 @@ pub const AddressSpaceContext = enum {
1284113121
1284213122pub fn analyzeAddrspace(
1284313123 sema: *Sema,
12844 block: *Scope.Block,
13124 block: *Block,
1284513125 src: LazySrcLoc,
1284613126 zir_ref: Zir.Inst.Ref,
1284713127 ctx: AddressSpaceContext,
src/codegen/c.zig+1-1
......@@ -246,7 +246,7 @@ pub const DeclGen = struct {
246246 fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {
247247 @setCold(true);
248248 const src: LazySrcLoc = .{ .node_offset = 0 };
249 const src_loc = src.toSrcLocWithDecl(dg.decl);
249 const src_loc = src.toSrcLoc(dg.decl);
250250 dg.error_msg = try Module.ErrorMsg.create(dg.module.gpa, src_loc, format, args);
251251 return error.AnalysisFail;
252252 }
src/codegen/llvm.zig+1-1
......@@ -557,7 +557,7 @@ pub const DeclGen = struct {
557557 fn todo(self: *DeclGen, comptime format: []const u8, args: anytype) error{ OutOfMemory, CodegenFail } {
558558 @setCold(true);
559559 assert(self.err_msg == null);
560 const src_loc = @as(LazySrcLoc, .{ .node_offset = 0 }).toSrcLocWithDecl(self.decl);
560 const src_loc = @as(LazySrcLoc, .{ .node_offset = 0 }).toSrcLoc(self.decl);
561561 self.err_msg = try Module.ErrorMsg.create(self.gpa, src_loc, "TODO (LLVM): " ++ format, args);
562562 return error.CodegenFail;
563563 }
src/codegen/spirv.zig+1-1
......@@ -295,7 +295,7 @@ pub const DeclGen = struct {
295295 fn fail(self: *DeclGen, comptime format: []const u8, args: anytype) Error {
296296 @setCold(true);
297297 const src: LazySrcLoc = .{ .node_offset = 0 };
298 const src_loc = src.toSrcLocWithDecl(self.decl);
298 const src_loc = src.toSrcLoc(self.decl);
299299 self.error_msg = try Module.ErrorMsg.create(self.spv.module.gpa, src_loc, format, args);
300300 return error.AnalysisFail;
301301 }
src/codegen/wasm.zig+1-1
......@@ -540,7 +540,7 @@ pub const Context = struct {
540540 /// Sets `err_msg` on `Context` and returns `error.CodegemFail` which is caught in link/Wasm.zig
541541 fn fail(self: *Context, comptime fmt: []const u8, args: anytype) InnerError {
542542 const src: LazySrcLoc = .{ .node_offset = 0 };
543 const src_loc = src.toSrcLocWithDecl(self.decl);
543 const src_loc = src.toSrcLoc(self.decl);
544544 self.err_msg = try Module.ErrorMsg.create(self.gpa, src_loc, fmt, args);
545545 return error.CodegenFail;
546546 }
src/crash_report.zig+5-7
......@@ -8,6 +8,7 @@ const print_zir = @import("print_zir.zig");
88const Module = @import("Module.zig");
99const Sema = @import("Sema.zig");
1010const Zir = @import("Zir.zig");
11const Decl = Module.Decl;
1112
1213pub const is_enabled = builtin.mode == .Debug;
1314
......@@ -36,7 +37,7 @@ fn en(val: anytype) En(@TypeOf(val)) {
3637pub const AnalyzeBody = struct {
3738 parent: if (is_enabled) ?*AnalyzeBody else void,
3839 sema: En(*Sema),
39 block: En(*Module.Scope.Block),
40 block: En(*Sema.Block),
4041 body: En([]const Zir.Inst.Index),
4142 body_index: En(usize),
4243
......@@ -64,7 +65,7 @@ pub const AnalyzeBody = struct {
6465
6566threadlocal var zir_state: ?*AnalyzeBody = if (is_enabled) null else @compileError("Cannot use zir_state if crash_report is disabled.");
6667
67pub fn prepAnalyzeBody(sema: *Sema, block: *Module.Scope.Block, body: []const Zir.Inst.Index) AnalyzeBody {
68pub fn prepAnalyzeBody(sema: *Sema, block: *Sema.Block, body: []const Zir.Inst.Index) AnalyzeBody {
6869 if (is_enabled) {
6970 return .{
7071 .parent = null,
......@@ -87,7 +88,7 @@ fn dumpStatusReport() !void {
8788 const allocator = &fba.allocator;
8889
8990 const stderr = io.getStdErr().writer();
90 const block: *Scope.Block = anal.block;
91 const block: *Sema.Block = anal.block;
9192
9293 try stderr.writeAll("Analyzing ");
9394 try writeFullyQualifiedDeclWithFile(block.src_decl, stderr);
......@@ -134,12 +135,9 @@ fn dumpStatusReport() !void {
134135 try stderr.writeAll("\n");
135136}
136137
137const Scope = Module.Scope;
138const Decl = Module.Decl;
139
140138var crash_heap: [16 * 4096]u8 = undefined;
141139
142fn writeFilePath(file: *Scope.File, stream: anytype) !void {
140fn writeFilePath(file: *Module.File, stream: anytype) !void {
143141 if (file.pkg.root_src_directory.path) |path| {
144142 try stream.writeAll(path);
145143 try stream.writeAll(std.fs.path.sep_str);
src/link/Plan9.zig+1-1
......@@ -57,7 +57,7 @@ path_arena: std.heap.ArenaAllocator,
5757/// of the function to know what file it came from.
5858/// If we group the decls by file, it makes it really easy to do this (put the symbol in the correct place)
5959fn_decl_table: std.AutoArrayHashMapUnmanaged(
60 *Module.Scope.File,
60 *Module.File,
6161 struct { sym_index: u32, functions: std.AutoArrayHashMapUnmanaged(*Module.Decl, FnDeclOutput) = .{} },
6262) = .{},
6363data_decl_table: std.AutoArrayHashMapUnmanaged(*Module.Decl, []const u8) = .{},
src/main.zig+4-4
......@@ -3233,7 +3233,7 @@ pub fn cmdFmt(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !voi
32333233 const Module = @import("Module.zig");
32343234 const AstGen = @import("AstGen.zig");
32353235
3236 var file: Module.Scope.File = .{
3236 var file: Module.File = .{
32373237 .status = .never_loaded,
32383238 .source_loaded = true,
32393239 .zir_loaded = false,
......@@ -3429,7 +3429,7 @@ fn fmtPathFile(
34293429 const Module = @import("Module.zig");
34303430 const AstGen = @import("AstGen.zig");
34313431
3432 var file: Module.Scope.File = .{
3432 var file: Module.File = .{
34333433 .status = .never_loaded,
34343434 .source_loaded = true,
34353435 .zir_loaded = false,
......@@ -4019,7 +4019,7 @@ pub fn cmdAstCheck(
40194019 }
40204020 }
40214021
4022 var file: Module.Scope.File = .{
4022 var file: Module.File = .{
40234023 .status = .never_loaded,
40244024 .source_loaded = false,
40254025 .tree_loaded = false,
......@@ -4170,7 +4170,7 @@ pub fn cmdChangelist(
41704170 if (stat.size > max_src_size)
41714171 return error.FileTooBig;
41724172
4173 var file: Module.Scope.File = .{
4173 var file: Module.File = .{
41744174 .status = .never_loaded,
41754175 .source_loaded = false,
41764176 .tree_loaded = false,
src/print_zir.zig+4-4
......@@ -11,7 +11,7 @@ const LazySrcLoc = Module.LazySrcLoc;
1111/// Write human-readable, debug formatted ZIR code to a file.
1212pub fn renderAsTextToFile(
1313 gpa: *Allocator,
14 scope_file: *Module.Scope.File,
14 scope_file: *Module.File,
1515 fs_file: std.fs.File,
1616) !void {
1717 var arena = std.heap.ArenaAllocator.init(gpa);
......@@ -64,7 +64,7 @@ pub fn renderInstructionContext(
6464 gpa: *Allocator,
6565 block: []const Zir.Inst.Index,
6666 block_index: usize,
67 scope_file: *Module.Scope.File,
67 scope_file: *Module.File,
6868 parent_decl_node: Ast.Node.Index,
6969 indent: u32,
7070 stream: anytype,
......@@ -96,7 +96,7 @@ pub fn renderInstructionContext(
9696pub fn renderSingleInstruction(
9797 gpa: *Allocator,
9898 inst: Zir.Inst.Index,
99 scope_file: *Module.Scope.File,
99 scope_file: *Module.File,
100100 parent_decl_node: Ast.Node.Index,
101101 indent: u32,
102102 stream: anytype,
......@@ -122,7 +122,7 @@ pub fn renderSingleInstruction(
122122const Writer = struct {
123123 gpa: *Allocator,
124124 arena: *Allocator,
125 file: *Module.Scope.File,
125 file: *Module.File,
126126 code: Zir,
127127 indent: u32,
128128 parent_decl_node: Ast.Node.Index,
src/type.zig+3-3
......@@ -3067,7 +3067,7 @@ pub const Type = extern union {
30673067 }
30683068
30693069 /// Returns null if the type has no namespace.
3070 pub fn getNamespace(self: Type) ?*Module.Scope.Namespace {
3070 pub fn getNamespace(self: Type) ?*Module.Namespace {
30713071 return switch (self.tag()) {
30723072 .@"struct" => &self.castTag(.@"struct").?.data.namespace,
30733073 .enum_full => &self.castTag(.enum_full).?.data.namespace,
......@@ -3833,12 +3833,12 @@ pub const Type = extern union {
38333833 /// Most commonly used for files.
38343834 pub const ContainerScope = struct {
38353835 base: Payload,
3836 data: *Module.Scope.Namespace,
3836 data: *Module.Namespace,
38373837 };
38383838
38393839 pub const Opaque = struct {
38403840 base: Payload = .{ .tag = .@"opaque" },
3841 data: Module.Scope.Namespace,
3841 data: Module.Namespace,
38423842 };
38433843
38443844 pub const Struct = struct {