| ... | ... | @@ -21,7 +21,7 @@ air_values: std.ArrayListUnmanaged(Value) = .{}, |
| 21 | 21 | /// Maps ZIR to AIR. |
| 22 | 22 | inst_map: InstMap = .{}, |
| 23 | 23 | /// 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. |
| 25 | 25 | /// This `Decl` owns the arena memory of this `Sema`. |
| 26 | 26 | owner_decl: *Decl, |
| 27 | 27 | /// For an inline or comptime function call, this will be the root parent function |
| ... | ... | @@ -75,7 +75,7 @@ const Air = @import("Air.zig"); |
| 75 | 75 | const Zir = @import("Zir.zig"); |
| 76 | 76 | const Module = @import("Module.zig"); |
| 77 | 77 | const trace = @import("tracy.zig").trace; |
| 78 | | const Scope = Module.Scope; |
| 78 | const Namespace = Module.Namespace; |
| 79 | 79 | const CompileError = Module.CompileError; |
| 80 | 80 | const SemaError = Module.SemaError; |
| 81 | 81 | const Decl = Module.Decl; |
| ... | ... | @@ -89,6 +89,286 @@ const crash_report = @import("crash_report.zig"); |
| 89 | 89 | |
| 90 | 90 | pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref); |
| 91 | 91 | |
| 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. |
| 96 | pub 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 | |
| 92 | 372 | pub fn deinit(sema: *Sema) void { |
| 93 | 373 | const gpa = sema.gpa; |
| 94 | 374 | sema.air_instructions.deinit(gpa); |
| ... | ... | @@ -102,7 +382,7 @@ pub fn deinit(sema: *Sema) void { |
| 102 | 382 | /// Returns only the result from the body that is specified. |
| 103 | 383 | /// Only appropriate to call when it is determined at comptime that this body |
| 104 | 384 | /// has no peers. |
| 105 | | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 385 | fn resolveBody(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 106 | 386 | const break_inst = try sema.analyzeBody(block, body); |
| 107 | 387 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 108 | 388 | return sema.resolveInst(operand_ref); |
| ... | ... | @@ -125,7 +405,7 @@ const always_noreturn: CompileError!Zir.Inst.Index = @as(Zir.Inst.Index, undefin |
| 125 | 405 | /// well as the operand. No block scope needs to be created for this strategy. |
| 126 | 406 | pub fn analyzeBody( |
| 127 | 407 | sema: *Sema, |
| 128 | | block: *Scope.Block, |
| 408 | block: *Block, |
| 129 | 409 | body: []const Zir.Inst.Index, |
| 130 | 410 | ) CompileError!Zir.Inst.Index { |
| 131 | 411 | // No tracy calls here, to avoid interfering with the tail call mechanism. |
| ... | ... | @@ -142,9 +422,9 @@ pub fn analyzeBody( |
| 142 | 422 | wip_captures.deinit(); |
| 143 | 423 | }; |
| 144 | 424 | |
| 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); |
| 148 | 428 | |
| 149 | 429 | var orig_captures: usize = parent_capture_scope.captures.count(); |
| 150 | 430 | |
| ... | ... | @@ -667,7 +947,7 @@ pub fn analyzeBody( |
| 667 | 947 | return result; |
| 668 | 948 | } |
| 669 | 949 | |
| 670 | | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 950 | fn zirExtended(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 671 | 951 | const extended = sema.code.instructions.items(.data)[inst].extended; |
| 672 | 952 | switch (extended.opcode) { |
| 673 | 953 | // zig fmt: off |
| ... | ... | @@ -719,7 +999,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref { |
| 719 | 999 | |
| 720 | 1000 | fn resolveConstBool( |
| 721 | 1001 | sema: *Sema, |
| 722 | | block: *Scope.Block, |
| 1002 | block: *Block, |
| 723 | 1003 | src: LazySrcLoc, |
| 724 | 1004 | zir_ref: Zir.Inst.Ref, |
| 725 | 1005 | ) !bool { |
| ... | ... | @@ -732,7 +1012,7 @@ fn resolveConstBool( |
| 732 | 1012 | |
| 733 | 1013 | fn resolveConstString( |
| 734 | 1014 | sema: *Sema, |
| 735 | | block: *Scope.Block, |
| 1015 | block: *Block, |
| 736 | 1016 | src: LazySrcLoc, |
| 737 | 1017 | zir_ref: Zir.Inst.Ref, |
| 738 | 1018 | ) ![]u8 { |
| ... | ... | @@ -743,14 +1023,14 @@ fn resolveConstString( |
| 743 | 1023 | return val.toAllocatedBytes(sema.arena); |
| 744 | 1024 | } |
| 745 | 1025 | |
| 746 | | pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 1026 | pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 747 | 1027 | const air_inst = sema.resolveInst(zir_ref); |
| 748 | 1028 | return sema.analyzeAsType(block, src, air_inst); |
| 749 | 1029 | } |
| 750 | 1030 | |
| 751 | 1031 | fn analyzeAsType( |
| 752 | 1032 | sema: *Sema, |
| 753 | | block: *Scope.Block, |
| 1033 | block: *Block, |
| 754 | 1034 | src: LazySrcLoc, |
| 755 | 1035 | air_inst: Air.Inst.Ref, |
| 756 | 1036 | ) !Type { |
| ... | ... | @@ -767,7 +1047,7 @@ fn analyzeAsType( |
| 767 | 1047 | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 768 | 1048 | fn resolveValue( |
| 769 | 1049 | sema: *Sema, |
| 770 | | block: *Scope.Block, |
| 1050 | block: *Block, |
| 771 | 1051 | src: LazySrcLoc, |
| 772 | 1052 | air_ref: Air.Inst.Ref, |
| 773 | 1053 | ) CompileError!Value { |
| ... | ... | @@ -782,7 +1062,7 @@ fn resolveValue( |
| 782 | 1062 | /// Value Tag `undef` may be returned. |
| 783 | 1063 | fn resolveConstMaybeUndefVal( |
| 784 | 1064 | sema: *Sema, |
| 785 | | block: *Scope.Block, |
| 1065 | block: *Block, |
| 786 | 1066 | src: LazySrcLoc, |
| 787 | 1067 | inst: Air.Inst.Ref, |
| 788 | 1068 | ) CompileError!Value { |
| ... | ... | @@ -800,7 +1080,7 @@ fn resolveConstMaybeUndefVal( |
| 800 | 1080 | /// See `resolveValue` for an alternative. |
| 801 | 1081 | fn resolveConstValue( |
| 802 | 1082 | sema: *Sema, |
| 803 | | block: *Scope.Block, |
| 1083 | block: *Block, |
| 804 | 1084 | src: LazySrcLoc, |
| 805 | 1085 | air_ref: Air.Inst.Ref, |
| 806 | 1086 | ) CompileError!Value { |
| ... | ... | @@ -819,7 +1099,7 @@ fn resolveConstValue( |
| 819 | 1099 | /// Value Tag `undef` causes this function to return a compile error. |
| 820 | 1100 | fn resolveDefinedValue( |
| 821 | 1101 | sema: *Sema, |
| 822 | | block: *Scope.Block, |
| 1102 | block: *Block, |
| 823 | 1103 | src: LazySrcLoc, |
| 824 | 1104 | air_ref: Air.Inst.Ref, |
| 825 | 1105 | ) CompileError!?Value { |
| ... | ... | @@ -837,7 +1117,7 @@ fn resolveDefinedValue( |
| 837 | 1117 | /// Value Tag `generic_poison` causes `error.GenericPoison` to be returned. |
| 838 | 1118 | fn resolveMaybeUndefVal( |
| 839 | 1119 | sema: *Sema, |
| 840 | | block: *Scope.Block, |
| 1120 | block: *Block, |
| 841 | 1121 | src: LazySrcLoc, |
| 842 | 1122 | inst: Air.Inst.Ref, |
| 843 | 1123 | ) CompileError!?Value { |
| ... | ... | @@ -852,7 +1132,7 @@ fn resolveMaybeUndefVal( |
| 852 | 1132 | /// Returns all Value tags including `variable` and `undef`. |
| 853 | 1133 | fn resolveMaybeUndefValAllowVariables( |
| 854 | 1134 | sema: *Sema, |
| 855 | | block: *Scope.Block, |
| 1135 | block: *Block, |
| 856 | 1136 | src: LazySrcLoc, |
| 857 | 1137 | inst: Air.Inst.Ref, |
| 858 | 1138 | ) CompileError!?Value { |
| ... | ... | @@ -879,19 +1159,19 @@ fn resolveMaybeUndefValAllowVariables( |
| 879 | 1159 | } |
| 880 | 1160 | } |
| 881 | 1161 | |
| 882 | | fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError { |
| 1162 | fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError { |
| 883 | 1163 | return sema.fail(block, src, "unable to resolve comptime value", .{}); |
| 884 | 1164 | } |
| 885 | 1165 | |
| 886 | | fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError { |
| 1166 | fn failWithUseOfUndef(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError { |
| 887 | 1167 | return sema.fail(block, src, "use of undefined value here causes undefined behavior", .{}); |
| 888 | 1168 | } |
| 889 | 1169 | |
| 890 | | fn failWithDivideByZero(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError { |
| 1170 | fn failWithDivideByZero(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError { |
| 891 | 1171 | return sema.fail(block, src, "division by zero here causes undefined behavior", .{}); |
| 892 | 1172 | } |
| 893 | 1173 | |
| 894 | | fn failWithModRemNegative(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError { |
| 1174 | fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError { |
| 895 | 1175 | return sema.fail(block, src, "remainder division with '{}' and '{}': signed integers and floats must use @rem or @mod", .{ lhs_ty, rhs_ty }); |
| 896 | 1176 | } |
| 897 | 1177 | |
| ... | ... | @@ -899,28 +1179,28 @@ fn failWithModRemNegative(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, lhs |
| 899 | 1179 | /// becomes invalid when you add another one. |
| 900 | 1180 | fn errNote( |
| 901 | 1181 | sema: *Sema, |
| 902 | | block: *Scope.Block, |
| 1182 | block: *Block, |
| 903 | 1183 | src: LazySrcLoc, |
| 904 | 1184 | parent: *Module.ErrorMsg, |
| 905 | 1185 | comptime format: []const u8, |
| 906 | 1186 | args: anytype, |
| 907 | 1187 | ) 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); |
| 909 | 1189 | } |
| 910 | 1190 | |
| 911 | 1191 | fn errMsg( |
| 912 | 1192 | sema: *Sema, |
| 913 | | block: *Scope.Block, |
| 1193 | block: *Block, |
| 914 | 1194 | src: LazySrcLoc, |
| 915 | 1195 | comptime format: []const u8, |
| 916 | 1196 | args: anytype, |
| 917 | 1197 | ) 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); |
| 919 | 1199 | } |
| 920 | 1200 | |
| 921 | 1201 | pub fn fail( |
| 922 | 1202 | sema: *Sema, |
| 923 | | block: *Scope.Block, |
| 1203 | block: *Block, |
| 924 | 1204 | src: LazySrcLoc, |
| 925 | 1205 | comptime format: []const u8, |
| 926 | 1206 | args: anytype, |
| ... | ... | @@ -958,7 +1238,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError { |
| 958 | 1238 | /// TODO don't ever call this since we're migrating towards ResultLoc.coerced_ty. |
| 959 | 1239 | fn resolveAlreadyCoercedInt( |
| 960 | 1240 | sema: *Sema, |
| 961 | | block: *Scope.Block, |
| 1241 | block: *Block, |
| 962 | 1242 | src: LazySrcLoc, |
| 963 | 1243 | zir_ref: Zir.Inst.Ref, |
| 964 | 1244 | comptime Int: type, |
| ... | ... | @@ -974,7 +1254,7 @@ fn resolveAlreadyCoercedInt( |
| 974 | 1254 | |
| 975 | 1255 | fn resolveAlign( |
| 976 | 1256 | sema: *Sema, |
| 977 | | block: *Scope.Block, |
| 1257 | block: *Block, |
| 978 | 1258 | src: LazySrcLoc, |
| 979 | 1259 | zir_ref: Zir.Inst.Ref, |
| 980 | 1260 | ) !u16 { |
| ... | ... | @@ -991,7 +1271,7 @@ fn resolveAlign( |
| 991 | 1271 | |
| 992 | 1272 | fn resolveInt( |
| 993 | 1273 | sema: *Sema, |
| 994 | | block: *Scope.Block, |
| 1274 | block: *Block, |
| 995 | 1275 | src: LazySrcLoc, |
| 996 | 1276 | zir_ref: Zir.Inst.Ref, |
| 997 | 1277 | dest_type: Type, |
| ... | ... | @@ -1007,7 +1287,7 @@ fn resolveInt( |
| 1007 | 1287 | // a function that does not. |
| 1008 | 1288 | pub fn resolveInstConst( |
| 1009 | 1289 | sema: *Sema, |
| 1010 | | block: *Scope.Block, |
| 1290 | block: *Block, |
| 1011 | 1291 | src: LazySrcLoc, |
| 1012 | 1292 | zir_ref: Zir.Inst.Ref, |
| 1013 | 1293 | ) CompileError!TypedValue { |
| ... | ... | @@ -1023,7 +1303,7 @@ pub fn resolveInstConst( |
| 1023 | 1303 | // See `resolveInstConst` for an alternative. |
| 1024 | 1304 | pub fn resolveInstValue( |
| 1025 | 1305 | sema: *Sema, |
| 1026 | | block: *Scope.Block, |
| 1306 | block: *Block, |
| 1027 | 1307 | src: LazySrcLoc, |
| 1028 | 1308 | zir_ref: Zir.Inst.Ref, |
| 1029 | 1309 | ) CompileError!TypedValue { |
| ... | ... | @@ -1035,13 +1315,13 @@ pub fn resolveInstValue( |
| 1035 | 1315 | }; |
| 1036 | 1316 | } |
| 1037 | 1317 | |
| 1038 | | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1318 | fn zirBitcastResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1039 | 1319 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1040 | 1320 | const src = inst_data.src(); |
| 1041 | 1321 | return sema.fail(block, src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); |
| 1042 | 1322 | } |
| 1043 | 1323 | |
| 1044 | | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1324 | fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1045 | 1325 | const tracy = trace(@src()); |
| 1046 | 1326 | defer tracy.end(); |
| 1047 | 1327 | |
| ... | ... | @@ -1103,7 +1383,7 @@ pub fn analyzeStructDecl( |
| 1103 | 1383 | |
| 1104 | 1384 | fn zirStructDecl( |
| 1105 | 1385 | sema: *Sema, |
| 1106 | | block: *Scope.Block, |
| 1386 | block: *Block, |
| 1107 | 1387 | extended: Zir.Inst.Extended.InstData, |
| 1108 | 1388 | inst: Zir.Inst.Index, |
| 1109 | 1389 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -1120,7 +1400,7 @@ fn zirStructDecl( |
| 1120 | 1400 | const struct_ty = try Type.Tag.@"struct".create(&new_decl_arena.allocator, struct_obj); |
| 1121 | 1401 | const struct_val = try Value.Tag.ty.create(&new_decl_arena.allocator, struct_ty); |
| 1122 | 1402 | 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, .{ |
| 1124 | 1404 | .ty = Type.initTag(.type), |
| 1125 | 1405 | .val = struct_val, |
| 1126 | 1406 | }, type_name); |
| ... | ... | @@ -1148,7 +1428,7 @@ fn zirStructDecl( |
| 1148 | 1428 | return sema.analyzeDeclVal(block, src, new_decl); |
| 1149 | 1429 | } |
| 1150 | 1430 | |
| 1151 | | fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 { |
| 1431 | fn createTypeName(sema: *Sema, block: *Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 { |
| 1152 | 1432 | switch (name_strategy) { |
| 1153 | 1433 | .anon => { |
| 1154 | 1434 | // 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 |
| 1176 | 1456 | |
| 1177 | 1457 | fn zirEnumDecl( |
| 1178 | 1458 | sema: *Sema, |
| 1179 | | block: *Scope.Block, |
| 1459 | block: *Block, |
| 1180 | 1460 | extended: Zir.Inst.Extended.InstData, |
| 1181 | 1461 | ) CompileError!Air.Inst.Ref { |
| 1182 | 1462 | const tracy = trace(@src()); |
| ... | ... | @@ -1229,7 +1509,7 @@ fn zirEnumDecl( |
| 1229 | 1509 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 1230 | 1510 | const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty); |
| 1231 | 1511 | 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, .{ |
| 1233 | 1513 | .ty = Type.initTag(.type), |
| 1234 | 1514 | .val = enum_val, |
| 1235 | 1515 | }, type_name); |
| ... | ... | @@ -1287,7 +1567,7 @@ fn zirEnumDecl( |
| 1287 | 1567 | var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, new_decl.src_scope); |
| 1288 | 1568 | defer wip_captures.deinit(); |
| 1289 | 1569 | |
| 1290 | | var enum_block: Scope.Block = .{ |
| 1570 | var enum_block: Block = .{ |
| 1291 | 1571 | .parent = null, |
| 1292 | 1572 | .sema = sema, |
| 1293 | 1573 | .src_decl = new_decl, |
| ... | ... | @@ -1377,7 +1657,7 @@ fn zirEnumDecl( |
| 1377 | 1657 | |
| 1378 | 1658 | fn zirUnionDecl( |
| 1379 | 1659 | sema: *Sema, |
| 1380 | | block: *Scope.Block, |
| 1660 | block: *Block, |
| 1381 | 1661 | extended: Zir.Inst.Extended.InstData, |
| 1382 | 1662 | inst: Zir.Inst.Index, |
| 1383 | 1663 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -1416,7 +1696,7 @@ fn zirUnionDecl( |
| 1416 | 1696 | const union_ty = Type.initPayload(&union_payload.base); |
| 1417 | 1697 | const union_val = try Value.Tag.ty.create(&new_decl_arena.allocator, union_ty); |
| 1418 | 1698 | 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, .{ |
| 1420 | 1700 | .ty = Type.initTag(.type), |
| 1421 | 1701 | .val = union_val, |
| 1422 | 1702 | }, type_name); |
| ... | ... | @@ -1448,7 +1728,7 @@ fn zirUnionDecl( |
| 1448 | 1728 | |
| 1449 | 1729 | fn zirOpaqueDecl( |
| 1450 | 1730 | sema: *Sema, |
| 1451 | | block: *Scope.Block, |
| 1731 | block: *Block, |
| 1452 | 1732 | extended: Zir.Inst.Extended.InstData, |
| 1453 | 1733 | inst: Zir.Inst.Index, |
| 1454 | 1734 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -1462,7 +1742,7 @@ fn zirOpaqueDecl( |
| 1462 | 1742 | |
| 1463 | 1743 | fn zirErrorSetDecl( |
| 1464 | 1744 | sema: *Sema, |
| 1465 | | block: *Scope.Block, |
| 1745 | block: *Block, |
| 1466 | 1746 | inst: Zir.Inst.Index, |
| 1467 | 1747 | name_strategy: Zir.Inst.NameStrategy, |
| 1468 | 1748 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -1482,7 +1762,7 @@ fn zirErrorSetDecl( |
| 1482 | 1762 | const error_set_ty = try Type.Tag.error_set.create(&new_decl_arena.allocator, error_set); |
| 1483 | 1763 | const error_set_val = try Value.Tag.ty.create(&new_decl_arena.allocator, error_set_ty); |
| 1484 | 1764 | 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, .{ |
| 1486 | 1766 | .ty = Type.initTag(.type), |
| 1487 | 1767 | .val = error_set_val, |
| 1488 | 1768 | }, type_name); |
| ... | ... | @@ -1504,7 +1784,7 @@ fn zirErrorSetDecl( |
| 1504 | 1784 | |
| 1505 | 1785 | fn zirRetPtr( |
| 1506 | 1786 | sema: *Sema, |
| 1507 | | block: *Scope.Block, |
| 1787 | block: *Block, |
| 1508 | 1788 | extended: Zir.Inst.Extended.InstData, |
| 1509 | 1789 | ) CompileError!Air.Inst.Ref { |
| 1510 | 1790 | const tracy = trace(@src()); |
| ... | ... | @@ -1524,7 +1804,7 @@ fn zirRetPtr( |
| 1524 | 1804 | return block.addTy(.alloc, ptr_type); |
| 1525 | 1805 | } |
| 1526 | 1806 | |
| 1527 | | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1807 | fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1528 | 1808 | const tracy = trace(@src()); |
| 1529 | 1809 | defer tracy.end(); |
| 1530 | 1810 | |
| ... | ... | @@ -1535,7 +1815,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A |
| 1535 | 1815 | |
| 1536 | 1816 | fn zirRetType( |
| 1537 | 1817 | sema: *Sema, |
| 1538 | | block: *Scope.Block, |
| 1818 | block: *Block, |
| 1539 | 1819 | extended: Zir.Inst.Extended.InstData, |
| 1540 | 1820 | ) CompileError!Air.Inst.Ref { |
| 1541 | 1821 | const tracy = trace(@src()); |
| ... | ... | @@ -1546,7 +1826,7 @@ fn zirRetType( |
| 1546 | 1826 | return sema.addType(sema.fn_ret_ty); |
| 1547 | 1827 | } |
| 1548 | 1828 | |
| 1549 | | fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 1829 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 1550 | 1830 | const tracy = trace(@src()); |
| 1551 | 1831 | defer tracy.end(); |
| 1552 | 1832 | |
| ... | ... | @@ -1559,7 +1839,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) C |
| 1559 | 1839 | |
| 1560 | 1840 | fn ensureResultUsed( |
| 1561 | 1841 | sema: *Sema, |
| 1562 | | block: *Scope.Block, |
| 1842 | block: *Block, |
| 1563 | 1843 | operand: Air.Inst.Ref, |
| 1564 | 1844 | src: LazySrcLoc, |
| 1565 | 1845 | ) CompileError!void { |
| ... | ... | @@ -1570,7 +1850,7 @@ fn ensureResultUsed( |
| 1570 | 1850 | } |
| 1571 | 1851 | } |
| 1572 | 1852 | |
| 1573 | | fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 1853 | fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 1574 | 1854 | const tracy = trace(@src()); |
| 1575 | 1855 | defer tracy.end(); |
| 1576 | 1856 | |
| ... | ... | @@ -1584,7 +1864,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1584 | 1864 | } |
| 1585 | 1865 | } |
| 1586 | 1866 | |
| 1587 | | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1867 | fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1588 | 1868 | const tracy = trace(@src()); |
| 1589 | 1869 | defer tracy.end(); |
| 1590 | 1870 | |
| ... | ... | @@ -1632,7 +1912,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 1632 | 1912 | |
| 1633 | 1913 | fn zirAllocExtended( |
| 1634 | 1914 | sema: *Sema, |
| 1635 | | block: *Scope.Block, |
| 1915 | block: *Block, |
| 1636 | 1916 | extended: Zir.Inst.Extended.InstData, |
| 1637 | 1917 | ) CompileError!Air.Inst.Ref { |
| 1638 | 1918 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| ... | ... | @@ -1675,7 +1955,7 @@ fn zirAllocExtended( |
| 1675 | 1955 | return block.addTy(.alloc, ptr_type); |
| 1676 | 1956 | } |
| 1677 | 1957 | |
| 1678 | | fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1958 | fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1679 | 1959 | const tracy = trace(@src()); |
| 1680 | 1960 | defer tracy.end(); |
| 1681 | 1961 | |
| ... | ... | @@ -1695,7 +1975,7 @@ fn zirAllocInferredComptime(sema: *Sema, inst: Zir.Inst.Index) CompileError!Air. |
| 1695 | 1975 | ); |
| 1696 | 1976 | } |
| 1697 | 1977 | |
| 1698 | | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1978 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1699 | 1979 | const tracy = trace(@src()); |
| 1700 | 1980 | defer tracy.end(); |
| 1701 | 1981 | |
| ... | ... | @@ -1711,7 +1991,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError |
| 1711 | 1991 | return block.addTy(.alloc, ptr_type); |
| 1712 | 1992 | } |
| 1713 | 1993 | |
| 1714 | | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1994 | fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 1715 | 1995 | const tracy = trace(@src()); |
| 1716 | 1996 | defer tracy.end(); |
| 1717 | 1997 | |
| ... | ... | @@ -1733,7 +2013,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 1733 | 2013 | |
| 1734 | 2014 | fn zirAllocInferred( |
| 1735 | 2015 | sema: *Sema, |
| 1736 | | block: *Scope.Block, |
| 2016 | block: *Block, |
| 1737 | 2017 | inst: Zir.Inst.Index, |
| 1738 | 2018 | inferred_alloc_ty: Type, |
| 1739 | 2019 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -1764,7 +2044,7 @@ fn zirAllocInferred( |
| 1764 | 2044 | return result; |
| 1765 | 2045 | } |
| 1766 | 2046 | |
| 1767 | | fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2047 | fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 1768 | 2048 | const tracy = trace(@src()); |
| 1769 | 2049 | defer tracy.end(); |
| 1770 | 2050 | |
| ... | ... | @@ -1823,7 +2103,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1823 | 2103 | } |
| 1824 | 2104 | } |
| 1825 | 2105 | |
| 1826 | | fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2106 | fn zirValidateStructInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 1827 | 2107 | const tracy = trace(@src()); |
| 1828 | 2108 | defer tracy.end(); |
| 1829 | 2109 | |
| ... | ... | @@ -1855,7 +2135,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind |
| 1855 | 2135 | |
| 1856 | 2136 | fn validateUnionInitPtr( |
| 1857 | 2137 | sema: *Sema, |
| 1858 | | block: *Scope.Block, |
| 2138 | block: *Block, |
| 1859 | 2139 | union_obj: *Module.Union, |
| 1860 | 2140 | init_src: LazySrcLoc, |
| 1861 | 2141 | instrs: []const Zir.Inst.Index, |
| ... | ... | @@ -1894,7 +2174,7 @@ fn validateUnionInitPtr( |
| 1894 | 2174 | |
| 1895 | 2175 | fn validateStructInitPtr( |
| 1896 | 2176 | sema: *Sema, |
| 1897 | | block: *Scope.Block, |
| 2177 | block: *Block, |
| 1898 | 2178 | struct_obj: *Module.Struct, |
| 1899 | 2179 | init_src: LazySrcLoc, |
| 1900 | 2180 | instrs: []const Zir.Inst.Index, |
| ... | ... | @@ -1956,7 +2236,7 @@ fn validateStructInitPtr( |
| 1956 | 2236 | } |
| 1957 | 2237 | } |
| 1958 | 2238 | |
| 1959 | | fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2239 | fn zirValidateArrayInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 1960 | 2240 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1961 | 2241 | const src = inst_data.src(); |
| 1962 | 2242 | return sema.fail(block, src, "TODO implement Sema.zirValidateArrayInitPtr", .{}); |
| ... | ... | @@ -1964,7 +2244,7 @@ fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1964 | 2244 | |
| 1965 | 2245 | fn failWithBadFieldAccess( |
| 1966 | 2246 | sema: *Sema, |
| 1967 | | block: *Scope.Block, |
| 2247 | block: *Block, |
| 1968 | 2248 | struct_obj: *Module.Struct, |
| 1969 | 2249 | field_src: LazySrcLoc, |
| 1970 | 2250 | field_name: []const u8, |
| ... | ... | @@ -1990,7 +2270,7 @@ fn failWithBadFieldAccess( |
| 1990 | 2270 | |
| 1991 | 2271 | fn failWithBadUnionFieldAccess( |
| 1992 | 2272 | sema: *Sema, |
| 1993 | | block: *Scope.Block, |
| 2273 | block: *Block, |
| 1994 | 2274 | union_obj: *Module.Union, |
| 1995 | 2275 | field_src: LazySrcLoc, |
| 1996 | 2276 | field_name: []const u8, |
| ... | ... | @@ -2014,7 +2294,7 @@ fn failWithBadUnionFieldAccess( |
| 2014 | 2294 | return sema.failWithOwnedErrorMsg(msg); |
| 2015 | 2295 | } |
| 2016 | 2296 | |
| 2017 | | fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2297 | fn zirStoreToBlockPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2018 | 2298 | const tracy = trace(@src()); |
| 2019 | 2299 | defer tracy.end(); |
| 2020 | 2300 | |
| ... | ... | @@ -2039,7 +2319,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 2039 | 2319 | return sema.storePtr(block, src, bitcasted_ptr, value); |
| 2040 | 2320 | } |
| 2041 | 2321 | |
| 2042 | | fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2322 | fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2043 | 2323 | const tracy = trace(@src()); |
| 2044 | 2324 | defer tracy.end(); |
| 2045 | 2325 | |
| ... | ... | @@ -2087,7 +2367,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 2087 | 2367 | unreachable; |
| 2088 | 2368 | } |
| 2089 | 2369 | |
| 2090 | | fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2370 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2091 | 2371 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2092 | 2372 | const src = inst_data.src(); |
| 2093 | 2373 | 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) |
| 2095 | 2375 | sema.branch_quota = quota; |
| 2096 | 2376 | } |
| 2097 | 2377 | |
| 2098 | | fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2378 | fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2099 | 2379 | const tracy = trace(@src()); |
| 2100 | 2380 | defer tracy.end(); |
| 2101 | 2381 | |
| ... | ... | @@ -2105,7 +2385,7 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError |
| 2105 | 2385 | return sema.storePtr(block, sema.src, ptr, value); |
| 2106 | 2386 | } |
| 2107 | 2387 | |
| 2108 | | fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2388 | fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2109 | 2389 | const tracy = trace(@src()); |
| 2110 | 2390 | defer tracy.end(); |
| 2111 | 2391 | |
| ... | ... | @@ -2117,7 +2397,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 2117 | 2397 | return sema.storePtr(block, src, ptr, value); |
| 2118 | 2398 | } |
| 2119 | 2399 | |
| 2120 | | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2400 | fn zirStr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2121 | 2401 | const tracy = trace(@src()); |
| 2122 | 2402 | defer tracy.end(); |
| 2123 | 2403 | |
| ... | ... | @@ -2136,7 +2416,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A |
| 2136 | 2416 | const decl_ty = try Type.Tag.array_u8_sentinel_0.create(&new_decl_arena.allocator, bytes.len); |
| 2137 | 2417 | const decl_val = try Value.Tag.bytes.create(&new_decl_arena.allocator, bytes); |
| 2138 | 2418 | |
| 2139 | | const new_decl = try sema.mod.createAnonymousDecl(&block.base, .{ |
| 2419 | const new_decl = try sema.mod.createAnonymousDecl(block, .{ |
| 2140 | 2420 | .ty = decl_ty, |
| 2141 | 2421 | .val = decl_val, |
| 2142 | 2422 | }); |
| ... | ... | @@ -2145,7 +2425,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A |
| 2145 | 2425 | return sema.analyzeDeclRef(new_decl); |
| 2146 | 2426 | } |
| 2147 | 2427 | |
| 2148 | | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2428 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2149 | 2429 | _ = block; |
| 2150 | 2430 | const tracy = trace(@src()); |
| 2151 | 2431 | defer tracy.end(); |
| ... | ... | @@ -2154,7 +2434,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A |
| 2154 | 2434 | return sema.addIntUnsigned(Type.initTag(.comptime_int), int); |
| 2155 | 2435 | } |
| 2156 | 2436 | |
| 2157 | | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2437 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2158 | 2438 | _ = block; |
| 2159 | 2439 | const tracy = trace(@src()); |
| 2160 | 2440 | defer tracy.end(); |
| ... | ... | @@ -2172,7 +2452,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 2172 | 2452 | ); |
| 2173 | 2453 | } |
| 2174 | 2454 | |
| 2175 | | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2455 | fn zirFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2176 | 2456 | _ = block; |
| 2177 | 2457 | const arena = sema.arena; |
| 2178 | 2458 | 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 |
| 2182 | 2462 | ); |
| 2183 | 2463 | } |
| 2184 | 2464 | |
| 2185 | | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2465 | fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2186 | 2466 | _ = block; |
| 2187 | 2467 | const arena = sema.arena; |
| 2188 | 2468 | 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 |
| 2194 | 2474 | ); |
| 2195 | 2475 | } |
| 2196 | 2476 | |
| 2197 | | fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 2477 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 2198 | 2478 | const tracy = trace(@src()); |
| 2199 | 2479 | defer tracy.end(); |
| 2200 | 2480 | |
| ... | ... | @@ -2207,7 +2487,7 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi |
| 2207 | 2487 | |
| 2208 | 2488 | fn zirCompileLog( |
| 2209 | 2489 | sema: *Sema, |
| 2210 | | block: *Scope.Block, |
| 2490 | block: *Block, |
| 2211 | 2491 | extended: Zir.Inst.Extended.InstData, |
| 2212 | 2492 | ) CompileError!Air.Inst.Ref { |
| 2213 | 2493 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| ... | ... | @@ -2239,7 +2519,7 @@ fn zirCompileLog( |
| 2239 | 2519 | return Air.Inst.Ref.void_value; |
| 2240 | 2520 | } |
| 2241 | 2521 | |
| 2242 | | fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 2522 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 2243 | 2523 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2244 | 2524 | const src: LazySrcLoc = inst_data.src(); |
| 2245 | 2525 | const msg_inst = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -2247,7 +2527,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError |
| 2247 | 2527 | return sema.panicWithMsg(block, src, msg_inst); |
| 2248 | 2528 | } |
| 2249 | 2529 | |
| 2250 | | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2530 | fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2251 | 2531 | const tracy = trace(@src()); |
| 2252 | 2532 | defer tracy.end(); |
| 2253 | 2533 | |
| ... | ... | @@ -2275,7 +2555,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 2275 | 2555 | .payload = undefined, |
| 2276 | 2556 | } }, |
| 2277 | 2557 | }); |
| 2278 | | var label: Scope.Block.Label = .{ |
| 2558 | var label: Block.Label = .{ |
| 2279 | 2559 | .zir_block = inst, |
| 2280 | 2560 | .merges = .{ |
| 2281 | 2561 | .results = .{}, |
| ... | ... | @@ -2310,7 +2590,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 2310 | 2590 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); |
| 2311 | 2591 | } |
| 2312 | 2592 | |
| 2313 | | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2593 | fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2314 | 2594 | const tracy = trace(@src()); |
| 2315 | 2595 | defer tracy.end(); |
| 2316 | 2596 | |
| ... | ... | @@ -2326,7 +2606,7 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com |
| 2326 | 2606 | var c_import_buf = std.ArrayList(u8).init(sema.gpa); |
| 2327 | 2607 | defer c_import_buf.deinit(); |
| 2328 | 2608 | |
| 2329 | | var child_block: Scope.Block = .{ |
| 2609 | var child_block: Block = .{ |
| 2330 | 2610 | .parent = parent_block, |
| 2331 | 2611 | .sema = sema, |
| 2332 | 2612 | .src_decl = parent_block.src_decl, |
| ... | ... | @@ -2389,7 +2669,7 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com |
| 2389 | 2669 | return sema.addConstant(file_root_decl.ty, file_root_decl.val); |
| 2390 | 2670 | } |
| 2391 | 2671 | |
| 2392 | | fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2672 | fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2393 | 2673 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2394 | 2674 | const src = inst_data.src(); |
| 2395 | 2675 | 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 |
| 2397 | 2677 | |
| 2398 | 2678 | fn zirBlock( |
| 2399 | 2679 | sema: *Sema, |
| 2400 | | parent_block: *Scope.Block, |
| 2680 | parent_block: *Block, |
| 2401 | 2681 | inst: Zir.Inst.Index, |
| 2402 | 2682 | ) CompileError!Air.Inst.Ref { |
| 2403 | 2683 | const tracy = trace(@src()); |
| ... | ... | @@ -2418,7 +2698,7 @@ fn zirBlock( |
| 2418 | 2698 | .data = undefined, |
| 2419 | 2699 | }); |
| 2420 | 2700 | |
| 2421 | | var label: Scope.Block.Label = .{ |
| 2701 | var label: Block.Label = .{ |
| 2422 | 2702 | .zir_block = inst, |
| 2423 | 2703 | .merges = .{ |
| 2424 | 2704 | .results = .{}, |
| ... | ... | @@ -2427,7 +2707,7 @@ fn zirBlock( |
| 2427 | 2707 | }, |
| 2428 | 2708 | }; |
| 2429 | 2709 | |
| 2430 | | var child_block: Scope.Block = .{ |
| 2710 | var child_block: Block = .{ |
| 2431 | 2711 | .parent = parent_block, |
| 2432 | 2712 | .sema = sema, |
| 2433 | 2713 | .src_decl = parent_block.src_decl, |
| ... | ... | @@ -2451,11 +2731,11 @@ fn zirBlock( |
| 2451 | 2731 | |
| 2452 | 2732 | fn resolveBlockBody( |
| 2453 | 2733 | sema: *Sema, |
| 2454 | | parent_block: *Scope.Block, |
| 2734 | parent_block: *Block, |
| 2455 | 2735 | src: LazySrcLoc, |
| 2456 | | child_block: *Scope.Block, |
| 2736 | child_block: *Block, |
| 2457 | 2737 | body: []const Zir.Inst.Index, |
| 2458 | | merges: *Scope.Block.Merges, |
| 2738 | merges: *Block.Merges, |
| 2459 | 2739 | ) CompileError!Air.Inst.Ref { |
| 2460 | 2740 | if (child_block.is_comptime) { |
| 2461 | 2741 | return sema.resolveBody(child_block, body); |
| ... | ... | @@ -2467,10 +2747,10 @@ fn resolveBlockBody( |
| 2467 | 2747 | |
| 2468 | 2748 | fn analyzeBlockBody( |
| 2469 | 2749 | sema: *Sema, |
| 2470 | | parent_block: *Scope.Block, |
| 2750 | parent_block: *Block, |
| 2471 | 2751 | src: LazySrcLoc, |
| 2472 | | child_block: *Scope.Block, |
| 2473 | | merges: *Scope.Block.Merges, |
| 2752 | child_block: *Block, |
| 2753 | merges: *Block.Merges, |
| 2474 | 2754 | ) CompileError!Air.Inst.Ref { |
| 2475 | 2755 | const tracy = trace(@src()); |
| 2476 | 2756 | defer tracy.end(); |
| ... | ... | @@ -2568,7 +2848,7 @@ fn analyzeBlockBody( |
| 2568 | 2848 | return Air.indexToRef(merges.block_inst); |
| 2569 | 2849 | } |
| 2570 | 2850 | |
| 2571 | | fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2851 | fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2572 | 2852 | const tracy = trace(@src()); |
| 2573 | 2853 | defer tracy.end(); |
| 2574 | 2854 | |
| ... | ... | @@ -2586,7 +2866,7 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 2586 | 2866 | try sema.analyzeExport(block, src, options, decl); |
| 2587 | 2867 | } |
| 2588 | 2868 | |
| 2589 | | fn zirExportValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2869 | fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2590 | 2870 | const tracy = trace(@src()); |
| 2591 | 2871 | defer tracy.end(); |
| 2592 | 2872 | |
| ... | ... | @@ -2606,7 +2886,7 @@ fn zirExportValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 2606 | 2886 | |
| 2607 | 2887 | pub fn analyzeExport( |
| 2608 | 2888 | sema: *Sema, |
| 2609 | | block: *Scope.Block, |
| 2889 | block: *Block, |
| 2610 | 2890 | src: LazySrcLoc, |
| 2611 | 2891 | borrowed_options: std.builtin.ExportOptions, |
| 2612 | 2892 | exported_decl: *Decl, |
| ... | ... | @@ -2682,7 +2962,7 @@ pub fn analyzeExport( |
| 2682 | 2962 | errdefer de_gop.value_ptr.* = gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1); |
| 2683 | 2963 | } |
| 2684 | 2964 | |
| 2685 | | fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2965 | fn zirSetAlignStack(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2686 | 2966 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2687 | 2967 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2688 | 2968 | const src: LazySrcLoc = inst_data.src(); |
| ... | ... | @@ -2714,7 +2994,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 2714 | 2994 | gop.value_ptr.* = .{ .alignment = alignment, .src = src }; |
| 2715 | 2995 | } |
| 2716 | 2996 | |
| 2717 | | fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 2997 | fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2718 | 2998 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2719 | 2999 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2720 | 3000 | 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 |
| 2722 | 3002 | func.is_cold = is_cold; |
| 2723 | 3003 | } |
| 2724 | 3004 | |
| 2725 | | fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 3005 | fn zirSetFloatMode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2726 | 3006 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2727 | 3007 | const src: LazySrcLoc = inst_data.src(); |
| 2728 | 3008 | return sema.fail(block, src, "TODO: implement Sema.zirSetFloatMode", .{}); |
| 2729 | 3009 | } |
| 2730 | 3010 | |
| 2731 | | fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 3011 | fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2732 | 3012 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2733 | 3013 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2734 | 3014 | block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand); |
| 2735 | 3015 | } |
| 2736 | 3016 | |
| 2737 | | fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 3017 | fn zirFence(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2738 | 3018 | if (block.is_comptime) return; |
| 2739 | 3019 | |
| 2740 | 3020 | 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 |
| 2751 | 3031 | }); |
| 2752 | 3032 | } |
| 2753 | 3033 | |
| 2754 | | fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 3034 | fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 2755 | 3035 | const tracy = trace(@src()); |
| 2756 | 3036 | defer tracy.end(); |
| 2757 | 3037 | |
| ... | ... | @@ -2773,7 +3053,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 2773 | 3053 | } |
| 2774 | 3054 | } |
| 2775 | 3055 | |
| 2776 | | fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 3056 | fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 2777 | 3057 | const tracy = trace(@src()); |
| 2778 | 3058 | defer tracy.end(); |
| 2779 | 3059 | |
| ... | ... | @@ -2793,7 +3073,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 2793 | 3073 | }); |
| 2794 | 3074 | } |
| 2795 | 3075 | |
| 2796 | | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3076 | fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2797 | 3077 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2798 | 3078 | const src = inst_data.src(); |
| 2799 | 3079 | const decl_name = inst_data.get(sema.code); |
| ... | ... | @@ -2801,7 +3081,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 2801 | 3081 | return sema.analyzeDeclRef(decl); |
| 2802 | 3082 | } |
| 2803 | 3083 | |
| 2804 | | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3084 | fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2805 | 3085 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2806 | 3086 | const src = inst_data.src(); |
| 2807 | 3087 | const decl_name = inst_data.get(sema.code); |
| ... | ... | @@ -2809,7 +3089,7 @@ fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 2809 | 3089 | return sema.analyzeDeclVal(block, src, decl); |
| 2810 | 3090 | } |
| 2811 | 3091 | |
| 2812 | | fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []const u8) !*Decl { |
| 3092 | fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: []const u8) !*Decl { |
| 2813 | 3093 | var namespace = block.namespace; |
| 2814 | 3094 | while (true) { |
| 2815 | 3095 | 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 |
| 2824 | 3104 | /// only for ones in the specified namespace. |
| 2825 | 3105 | fn lookupInNamespace( |
| 2826 | 3106 | sema: *Sema, |
| 2827 | | block: *Scope.Block, |
| 3107 | block: *Block, |
| 2828 | 3108 | src: LazySrcLoc, |
| 2829 | | namespace: *Scope.Namespace, |
| 3109 | namespace: *Namespace, |
| 2830 | 3110 | ident_name: []const u8, |
| 2831 | 3111 | observe_usingnamespace: bool, |
| 2832 | 3112 | ) CompileError!?*Decl { |
| ... | ... | @@ -2842,7 +3122,7 @@ fn lookupInNamespace( |
| 2842 | 3122 | const src_file = block.namespace.file_scope; |
| 2843 | 3123 | |
| 2844 | 3124 | const gpa = sema.gpa; |
| 2845 | | var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Scope.Namespace, void) = .{}; |
| 3125 | var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Namespace, void) = .{}; |
| 2846 | 3126 | defer checked_namespaces.deinit(gpa); |
| 2847 | 3127 | |
| 2848 | 3128 | // Keep track of name conflicts for error notes. |
| ... | ... | @@ -2914,7 +3194,7 @@ fn lookupInNamespace( |
| 2914 | 3194 | |
| 2915 | 3195 | fn zirCall( |
| 2916 | 3196 | sema: *Sema, |
| 2917 | | block: *Scope.Block, |
| 3197 | block: *Block, |
| 2918 | 3198 | inst: Zir.Inst.Index, |
| 2919 | 3199 | ) CompileError!Air.Inst.Ref { |
| 2920 | 3200 | const tracy = trace(@src()); |
| ... | ... | @@ -3016,7 +3296,7 @@ const GenericRemoveAdapter = struct { |
| 3016 | 3296 | |
| 3017 | 3297 | fn analyzeCall( |
| 3018 | 3298 | sema: *Sema, |
| 3019 | | block: *Scope.Block, |
| 3299 | block: *Block, |
| 3020 | 3300 | func: Air.Inst.Ref, |
| 3021 | 3301 | func_src: LazySrcLoc, |
| 3022 | 3302 | call_src: LazySrcLoc, |
| ... | ... | @@ -3097,7 +3377,7 @@ fn analyzeCall( |
| 3097 | 3377 | |
| 3098 | 3378 | // Analyze the ZIR. The same ZIR gets analyzed into a runtime function |
| 3099 | 3379 | // 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`. |
| 3101 | 3381 | // This block instruction will be used to capture the return value from the |
| 3102 | 3382 | // inlined function. |
| 3103 | 3383 | const block_inst = @intCast(Air.Inst.Index, sema.air_instructions.len); |
| ... | ... | @@ -3107,7 +3387,7 @@ fn analyzeCall( |
| 3107 | 3387 | }); |
| 3108 | 3388 | // This one is shared among sub-blocks within the same callee, but not |
| 3109 | 3389 | // shared among the entire inline/comptime call stack. |
| 3110 | | var inlining: Scope.Block.Inlining = .{ |
| 3390 | var inlining: Block.Inlining = .{ |
| 3111 | 3391 | .comptime_result = undefined, |
| 3112 | 3392 | .merges = .{ |
| 3113 | 3393 | .results = .{}, |
| ... | ... | @@ -3135,7 +3415,7 @@ fn analyzeCall( |
| 3135 | 3415 | var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, module_fn.owner_decl.src_scope); |
| 3136 | 3416 | defer wip_captures.deinit(); |
| 3137 | 3417 | |
| 3138 | | var child_block: Scope.Block = .{ |
| 3418 | var child_block: Block = .{ |
| 3139 | 3419 | .parent = null, |
| 3140 | 3420 | .sema = sema, |
| 3141 | 3421 | .src_decl = module_fn.owner_decl, |
| ... | ... | @@ -3437,7 +3717,7 @@ fn analyzeCall( |
| 3437 | 3717 | var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, new_decl.src_scope); |
| 3438 | 3718 | defer wip_captures.deinit(); |
| 3439 | 3719 | |
| 3440 | | var child_block: Scope.Block = .{ |
| 3720 | var child_block: Block = .{ |
| 3441 | 3721 | .parent = null, |
| 3442 | 3722 | .sema = &child_sema, |
| 3443 | 3723 | .src_decl = new_decl, |
| ... | ... | @@ -3598,7 +3878,7 @@ fn analyzeCall( |
| 3598 | 3878 | |
| 3599 | 3879 | fn finishGenericCall( |
| 3600 | 3880 | sema: *Sema, |
| 3601 | | block: *Scope.Block, |
| 3881 | block: *Block, |
| 3602 | 3882 | call_src: LazySrcLoc, |
| 3603 | 3883 | callee: *Module.Fn, |
| 3604 | 3884 | func_src: LazySrcLoc, |
| ... | ... | @@ -3665,7 +3945,7 @@ fn finishGenericCall( |
| 3665 | 3945 | return func_inst; |
| 3666 | 3946 | } |
| 3667 | 3947 | |
| 3668 | | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3948 | fn zirIntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3669 | 3949 | _ = block; |
| 3670 | 3950 | const tracy = trace(@src()); |
| 3671 | 3951 | defer tracy.end(); |
| ... | ... | @@ -3676,7 +3956,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 3676 | 3956 | return sema.addType(ty); |
| 3677 | 3957 | } |
| 3678 | 3958 | |
| 3679 | | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3959 | fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3680 | 3960 | const tracy = trace(@src()); |
| 3681 | 3961 | defer tracy.end(); |
| 3682 | 3962 | |
| ... | ... | @@ -3688,7 +3968,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi |
| 3688 | 3968 | return sema.addType(opt_type); |
| 3689 | 3969 | } |
| 3690 | 3970 | |
| 3691 | | fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3971 | fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3692 | 3972 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3693 | 3973 | const src = inst_data.src(); |
| 3694 | 3974 | 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 |
| 3696 | 3976 | return sema.addType(elem_type); |
| 3697 | 3977 | } |
| 3698 | 3978 | |
| 3699 | | fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3979 | fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3700 | 3980 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3701 | 3981 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 3702 | 3982 | 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 |
| 3710 | 3990 | return sema.addType(vector_type); |
| 3711 | 3991 | } |
| 3712 | 3992 | |
| 3713 | | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3993 | fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3714 | 3994 | const tracy = trace(@src()); |
| 3715 | 3995 | defer tracy.end(); |
| 3716 | 3996 | |
| ... | ... | @@ -3722,7 +4002,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 3722 | 4002 | return sema.addType(array_ty); |
| 3723 | 4003 | } |
| 3724 | 4004 | |
| 3725 | | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4005 | fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3726 | 4006 | const tracy = trace(@src()); |
| 3727 | 4007 | defer tracy.end(); |
| 3728 | 4008 | |
| ... | ... | @@ -3738,7 +4018,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 3738 | 4018 | return sema.addType(array_ty); |
| 3739 | 4019 | } |
| 3740 | 4020 | |
| 3741 | | fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4021 | fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3742 | 4022 | const tracy = trace(@src()); |
| 3743 | 4023 | defer tracy.end(); |
| 3744 | 4024 | |
| ... | ... | @@ -3750,7 +4030,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi |
| 3750 | 4030 | return sema.addType(anyframe_type); |
| 3751 | 4031 | } |
| 3752 | 4032 | |
| 3753 | | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4033 | fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3754 | 4034 | const tracy = trace(@src()); |
| 3755 | 4035 | defer tracy.end(); |
| 3756 | 4036 | |
| ... | ... | @@ -3770,7 +4050,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com |
| 3770 | 4050 | return sema.addType(err_union_ty); |
| 3771 | 4051 | } |
| 3772 | 4052 | |
| 3773 | | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4053 | fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3774 | 4054 | _ = block; |
| 3775 | 4055 | const tracy = trace(@src()); |
| 3776 | 4056 | defer tracy.end(); |
| ... | ... | @@ -3788,7 +4068,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 3788 | 4068 | ); |
| 3789 | 4069 | } |
| 3790 | 4070 | |
| 3791 | | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4071 | fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3792 | 4072 | const tracy = trace(@src()); |
| 3793 | 4073 | defer tracy.end(); |
| 3794 | 4074 | |
| ... | ... | @@ -3815,7 +4095,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 3815 | 4095 | return block.addTyOp(.bitcast, result_ty, op_coerced); |
| 3816 | 4096 | } |
| 3817 | 4097 | |
| 3818 | | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4098 | fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3819 | 4099 | const tracy = trace(@src()); |
| 3820 | 4100 | defer tracy.end(); |
| 3821 | 4101 | |
| ... | ... | @@ -3845,7 +4125,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 3845 | 4125 | return block.addTyOp(.bitcast, Type.initTag(.anyerror), op); |
| 3846 | 4126 | } |
| 3847 | 4127 | |
| 3848 | | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4128 | fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3849 | 4129 | const tracy = trace(@src()); |
| 3850 | 4130 | defer tracy.end(); |
| 3851 | 4131 | |
| ... | ... | @@ -3929,7 +4209,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com |
| 3929 | 4209 | return sema.addConstant(Type.initTag(.type), try Value.Tag.ty.create(sema.arena, error_set_ty)); |
| 3930 | 4210 | } |
| 3931 | 4211 | |
| 3932 | | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4212 | fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3933 | 4213 | _ = block; |
| 3934 | 4214 | const tracy = trace(@src()); |
| 3935 | 4215 | defer tracy.end(); |
| ... | ... | @@ -3942,7 +4222,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 3942 | 4222 | ); |
| 3943 | 4223 | } |
| 3944 | 4224 | |
| 3945 | | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4225 | fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3946 | 4226 | const arena = sema.arena; |
| 3947 | 4227 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3948 | 4228 | const src = inst_data.src(); |
| ... | ... | @@ -3988,7 +4268,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 3988 | 4268 | return block.addTyOp(.bitcast, int_tag_ty, enum_tag); |
| 3989 | 4269 | } |
| 3990 | 4270 | |
| 3991 | | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4271 | fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3992 | 4272 | const target = sema.mod.getTarget(); |
| 3993 | 4273 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3994 | 4274 | 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 |
| 4038 | 4318 | /// Pointer in, pointer out. |
| 4039 | 4319 | fn zirOptionalPayloadPtr( |
| 4040 | 4320 | sema: *Sema, |
| 4041 | | block: *Scope.Block, |
| 4321 | block: *Block, |
| 4042 | 4322 | inst: Zir.Inst.Index, |
| 4043 | 4323 | safety_check: bool, |
| 4044 | 4324 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4087,7 +4367,7 @@ fn zirOptionalPayloadPtr( |
| 4087 | 4367 | /// Value in, value out. |
| 4088 | 4368 | fn zirOptionalPayload( |
| 4089 | 4369 | sema: *Sema, |
| 4090 | | block: *Scope.Block, |
| 4370 | block: *Block, |
| 4091 | 4371 | inst: Zir.Inst.Index, |
| 4092 | 4372 | safety_check: bool, |
| 4093 | 4373 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4124,7 +4404,7 @@ fn zirOptionalPayload( |
| 4124 | 4404 | /// Value in, value out |
| 4125 | 4405 | fn zirErrUnionPayload( |
| 4126 | 4406 | sema: *Sema, |
| 4127 | | block: *Scope.Block, |
| 4407 | block: *Block, |
| 4128 | 4408 | inst: Zir.Inst.Index, |
| 4129 | 4409 | safety_check: bool, |
| 4130 | 4410 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4159,7 +4439,7 @@ fn zirErrUnionPayload( |
| 4159 | 4439 | /// Pointer in, pointer out. |
| 4160 | 4440 | fn zirErrUnionPayloadPtr( |
| 4161 | 4441 | sema: *Sema, |
| 4162 | | block: *Scope.Block, |
| 4442 | block: *Block, |
| 4163 | 4443 | inst: Zir.Inst.Index, |
| 4164 | 4444 | safety_check: bool, |
| 4165 | 4445 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4203,7 +4483,7 @@ fn zirErrUnionPayloadPtr( |
| 4203 | 4483 | } |
| 4204 | 4484 | |
| 4205 | 4485 | /// Value in, value out |
| 4206 | | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4486 | fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4207 | 4487 | const tracy = trace(@src()); |
| 4208 | 4488 | defer tracy.end(); |
| 4209 | 4489 | |
| ... | ... | @@ -4226,7 +4506,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compi |
| 4226 | 4506 | } |
| 4227 | 4507 | |
| 4228 | 4508 | /// Pointer in, value out |
| 4229 | | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4509 | fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4230 | 4510 | const tracy = trace(@src()); |
| 4231 | 4511 | defer tracy.end(); |
| 4232 | 4512 | |
| ... | ... | @@ -4252,7 +4532,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 4252 | 4532 | return block.addTyOp(.unwrap_errunion_err_ptr, result_ty, operand); |
| 4253 | 4533 | } |
| 4254 | 4534 | |
| 4255 | | fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 4535 | fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4256 | 4536 | const tracy = trace(@src()); |
| 4257 | 4537 | defer tracy.end(); |
| 4258 | 4538 | |
| ... | ... | @@ -4269,7 +4549,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 4269 | 4549 | |
| 4270 | 4550 | fn zirFunc( |
| 4271 | 4551 | sema: *Sema, |
| 4272 | | block: *Scope.Block, |
| 4552 | block: *Block, |
| 4273 | 4553 | inst: Zir.Inst.Index, |
| 4274 | 4554 | inferred_error_set: bool, |
| 4275 | 4555 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4312,7 +4592,7 @@ fn zirFunc( |
| 4312 | 4592 | |
| 4313 | 4593 | fn funcCommon( |
| 4314 | 4594 | sema: *Sema, |
| 4315 | | block: *Scope.Block, |
| 4595 | block: *Block, |
| 4316 | 4596 | src_node_offset: i32, |
| 4317 | 4597 | body_inst: Zir.Inst.Index, |
| 4318 | 4598 | ret_ty_body: []const Zir.Inst.Index, |
| ... | ... | @@ -4511,7 +4791,7 @@ fn funcCommon( |
| 4511 | 4791 | |
| 4512 | 4792 | fn zirParam( |
| 4513 | 4793 | sema: *Sema, |
| 4514 | | block: *Scope.Block, |
| 4794 | block: *Block, |
| 4515 | 4795 | inst: Zir.Inst.Index, |
| 4516 | 4796 | is_comptime: bool, |
| 4517 | 4797 | ) CompileError!void { |
| ... | ... | @@ -4581,7 +4861,7 @@ fn zirParam( |
| 4581 | 4861 | |
| 4582 | 4862 | fn zirParamAnytype( |
| 4583 | 4863 | sema: *Sema, |
| 4584 | | block: *Scope.Block, |
| 4864 | block: *Block, |
| 4585 | 4865 | inst: Zir.Inst.Index, |
| 4586 | 4866 | is_comptime: bool, |
| 4587 | 4867 | ) CompileError!void { |
| ... | ... | @@ -4616,7 +4896,7 @@ fn zirParamAnytype( |
| 4616 | 4896 | try sema.inst_map.put(sema.gpa, inst, .generic_poison); |
| 4617 | 4897 | } |
| 4618 | 4898 | |
| 4619 | | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4899 | fn zirAs(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4620 | 4900 | const tracy = trace(@src()); |
| 4621 | 4901 | defer tracy.end(); |
| 4622 | 4902 | |
| ... | ... | @@ -4624,7 +4904,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Ai |
| 4624 | 4904 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); |
| 4625 | 4905 | } |
| 4626 | 4906 | |
| 4627 | | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4907 | fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4628 | 4908 | const tracy = trace(@src()); |
| 4629 | 4909 | defer tracy.end(); |
| 4630 | 4910 | |
| ... | ... | @@ -4636,7 +4916,7 @@ fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 4636 | 4916 | |
| 4637 | 4917 | fn analyzeAs( |
| 4638 | 4918 | sema: *Sema, |
| 4639 | | block: *Scope.Block, |
| 4919 | block: *Block, |
| 4640 | 4920 | src: LazySrcLoc, |
| 4641 | 4921 | zir_dest_type: Zir.Inst.Ref, |
| 4642 | 4922 | zir_operand: Zir.Inst.Ref, |
| ... | ... | @@ -4646,7 +4926,7 @@ fn analyzeAs( |
| 4646 | 4926 | return sema.coerce(block, dest_type, operand, src); |
| 4647 | 4927 | } |
| 4648 | 4928 | |
| 4649 | | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4929 | fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4650 | 4930 | const tracy = trace(@src()); |
| 4651 | 4931 | defer tracy.end(); |
| 4652 | 4932 | |
| ... | ... | @@ -4663,7 +4943,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 4663 | 4943 | return block.addUnOp(.ptrtoint, ptr); |
| 4664 | 4944 | } |
| 4665 | 4945 | |
| 4666 | | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4946 | fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4667 | 4947 | const tracy = trace(@src()); |
| 4668 | 4948 | defer tracy.end(); |
| 4669 | 4949 | |
| ... | ... | @@ -4682,7 +4962,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 4682 | 4962 | } |
| 4683 | 4963 | } |
| 4684 | 4964 | |
| 4685 | | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4965 | fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4686 | 4966 | const tracy = trace(@src()); |
| 4687 | 4967 | defer tracy.end(); |
| 4688 | 4968 | |
| ... | ... | @@ -4695,7 +4975,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 4695 | 4975 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 4696 | 4976 | } |
| 4697 | 4977 | |
| 4698 | | fn zirFieldCallBind(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4978 | fn zirFieldCallBind(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4699 | 4979 | const tracy = trace(@src()); |
| 4700 | 4980 | defer tracy.end(); |
| 4701 | 4981 | |
| ... | ... | @@ -4708,7 +4988,7 @@ fn zirFieldCallBind(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 4708 | 4988 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); |
| 4709 | 4989 | } |
| 4710 | 4990 | |
| 4711 | | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4991 | fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4712 | 4992 | const tracy = trace(@src()); |
| 4713 | 4993 | defer tracy.end(); |
| 4714 | 4994 | |
| ... | ... | @@ -4721,7 +5001,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 4721 | 5001 | return sema.fieldVal(block, src, object, field_name, field_name_src); |
| 4722 | 5002 | } |
| 4723 | 5003 | |
| 4724 | | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5004 | fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4725 | 5005 | const tracy = trace(@src()); |
| 4726 | 5006 | defer tracy.end(); |
| 4727 | 5007 | |
| ... | ... | @@ -4734,7 +5014,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 4734 | 5014 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 4735 | 5015 | } |
| 4736 | 5016 | |
| 4737 | | fn zirFieldCallBindNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5017 | fn zirFieldCallBindNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4738 | 5018 | const tracy = trace(@src()); |
| 4739 | 5019 | defer tracy.end(); |
| 4740 | 5020 | |
| ... | ... | @@ -4747,7 +5027,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 4747 | 5027 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); |
| 4748 | 5028 | } |
| 4749 | 5029 | |
| 4750 | | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5030 | fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4751 | 5031 | const tracy = trace(@src()); |
| 4752 | 5032 | defer tracy.end(); |
| 4753 | 5033 | |
| ... | ... | @@ -4773,7 +5053,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 4773 | 5053 | return block.addTyOp(.intcast, dest_type, operand); |
| 4774 | 5054 | } |
| 4775 | 5055 | |
| 4776 | | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5056 | fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4777 | 5057 | const tracy = trace(@src()); |
| 4778 | 5058 | defer tracy.end(); |
| 4779 | 5059 | |
| ... | ... | @@ -4787,7 +5067,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 4787 | 5067 | return sema.bitcast(block, dest_type, operand, operand_src); |
| 4788 | 5068 | } |
| 4789 | 5069 | |
| 4790 | | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5070 | fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4791 | 5071 | const tracy = trace(@src()); |
| 4792 | 5072 | defer tracy.end(); |
| 4793 | 5073 | |
| ... | ... | @@ -4838,7 +5118,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 4838 | 5118 | return block.addTyOp(.fptrunc, dest_type, operand); |
| 4839 | 5119 | } |
| 4840 | 5120 | |
| 4841 | | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5121 | fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4842 | 5122 | const tracy = trace(@src()); |
| 4843 | 5123 | defer tracy.end(); |
| 4844 | 5124 | |
| ... | ... | @@ -4848,7 +5128,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 4848 | 5128 | return sema.elemVal(block, sema.src, array, elem_index, sema.src); |
| 4849 | 5129 | } |
| 4850 | 5130 | |
| 4851 | | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5131 | fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4852 | 5132 | const tracy = trace(@src()); |
| 4853 | 5133 | defer tracy.end(); |
| 4854 | 5134 | |
| ... | ... | @@ -4861,7 +5141,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 4861 | 5141 | return sema.elemVal(block, src, array, elem_index, elem_index_src); |
| 4862 | 5142 | } |
| 4863 | 5143 | |
| 4864 | | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5144 | fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4865 | 5145 | const tracy = trace(@src()); |
| 4866 | 5146 | defer tracy.end(); |
| 4867 | 5147 | |
| ... | ... | @@ -4871,7 +5151,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 4871 | 5151 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 4872 | 5152 | } |
| 4873 | 5153 | |
| 4874 | | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5154 | fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4875 | 5155 | const tracy = trace(@src()); |
| 4876 | 5156 | defer tracy.end(); |
| 4877 | 5157 | |
| ... | ... | @@ -4884,7 +5164,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 4884 | 5164 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 4885 | 5165 | } |
| 4886 | 5166 | |
| 4887 | | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5167 | fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4888 | 5168 | const tracy = trace(@src()); |
| 4889 | 5169 | defer tracy.end(); |
| 4890 | 5170 | |
| ... | ... | @@ -4897,7 +5177,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 4897 | 5177 | return sema.analyzeSlice(block, src, array_ptr, start, .none, .none, .unneeded); |
| 4898 | 5178 | } |
| 4899 | 5179 | |
| 4900 | | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5180 | fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4901 | 5181 | const tracy = trace(@src()); |
| 4902 | 5182 | defer tracy.end(); |
| 4903 | 5183 | |
| ... | ... | @@ -4911,7 +5191,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 4911 | 5191 | return sema.analyzeSlice(block, src, array_ptr, start, end, .none, .unneeded); |
| 4912 | 5192 | } |
| 4913 | 5193 | |
| 4914 | | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5194 | fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4915 | 5195 | const tracy = trace(@src()); |
| 4916 | 5196 | defer tracy.end(); |
| 4917 | 5197 | |
| ... | ... | @@ -4929,7 +5209,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 4929 | 5209 | |
| 4930 | 5210 | fn zirSwitchCapture( |
| 4931 | 5211 | sema: *Sema, |
| 4932 | | block: *Scope.Block, |
| 5212 | block: *Block, |
| 4933 | 5213 | inst: Zir.Inst.Index, |
| 4934 | 5214 | is_multi: bool, |
| 4935 | 5215 | is_ref: bool, |
| ... | ... | @@ -4949,7 +5229,7 @@ fn zirSwitchCapture( |
| 4949 | 5229 | |
| 4950 | 5230 | fn zirSwitchCaptureElse( |
| 4951 | 5231 | sema: *Sema, |
| 4952 | | block: *Scope.Block, |
| 5232 | block: *Block, |
| 4953 | 5233 | inst: Zir.Inst.Index, |
| 4954 | 5234 | is_ref: bool, |
| 4955 | 5235 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -4967,7 +5247,7 @@ fn zirSwitchCaptureElse( |
| 4967 | 5247 | |
| 4968 | 5248 | fn zirSwitchBlock( |
| 4969 | 5249 | sema: *Sema, |
| 4970 | | block: *Scope.Block, |
| 5250 | block: *Block, |
| 4971 | 5251 | inst: Zir.Inst.Index, |
| 4972 | 5252 | is_ref: bool, |
| 4973 | 5253 | special_prong: Zir.SpecialProng, |
| ... | ... | @@ -5000,7 +5280,7 @@ fn zirSwitchBlock( |
| 5000 | 5280 | |
| 5001 | 5281 | fn zirSwitchBlockMulti( |
| 5002 | 5282 | sema: *Sema, |
| 5003 | | block: *Scope.Block, |
| 5283 | block: *Block, |
| 5004 | 5284 | inst: Zir.Inst.Index, |
| 5005 | 5285 | is_ref: bool, |
| 5006 | 5286 | special_prong: Zir.SpecialProng, |
| ... | ... | @@ -5033,7 +5313,7 @@ fn zirSwitchBlockMulti( |
| 5033 | 5313 | |
| 5034 | 5314 | fn analyzeSwitch( |
| 5035 | 5315 | sema: *Sema, |
| 5036 | | block: *Scope.Block, |
| 5316 | block: *Block, |
| 5037 | 5317 | operand: Air.Inst.Ref, |
| 5038 | 5318 | extra_end: usize, |
| 5039 | 5319 | special_prong: Zir.SpecialProng, |
| ... | ... | @@ -5451,7 +5731,7 @@ fn analyzeSwitch( |
| 5451 | 5731 | .tag = .block, |
| 5452 | 5732 | .data = undefined, |
| 5453 | 5733 | }); |
| 5454 | | var label: Scope.Block.Label = .{ |
| 5734 | var label: Block.Label = .{ |
| 5455 | 5735 | .zir_block = switch_inst, |
| 5456 | 5736 | .merges = .{ |
| 5457 | 5737 | .results = .{}, |
| ... | ... | @@ -5460,7 +5740,7 @@ fn analyzeSwitch( |
| 5460 | 5740 | }, |
| 5461 | 5741 | }; |
| 5462 | 5742 | |
| 5463 | | var child_block: Scope.Block = .{ |
| 5743 | var child_block: Block = .{ |
| 5464 | 5744 | .parent = block, |
| 5465 | 5745 | .sema = sema, |
| 5466 | 5746 | .src_decl = block.src_decl, |
| ... | ... | @@ -5771,7 +6051,7 @@ fn analyzeSwitch( |
| 5771 | 6051 | |
| 5772 | 6052 | fn resolveSwitchItemVal( |
| 5773 | 6053 | sema: *Sema, |
| 5774 | | block: *Scope.Block, |
| 6054 | block: *Block, |
| 5775 | 6055 | item_ref: Zir.Inst.Ref, |
| 5776 | 6056 | switch_node_offset: i32, |
| 5777 | 6057 | switch_prong_src: Module.SwitchProngSrc, |
| ... | ... | @@ -5798,7 +6078,7 @@ fn resolveSwitchItemVal( |
| 5798 | 6078 | |
| 5799 | 6079 | fn validateSwitchRange( |
| 5800 | 6080 | sema: *Sema, |
| 5801 | | block: *Scope.Block, |
| 6081 | block: *Block, |
| 5802 | 6082 | range_set: *RangeSet, |
| 5803 | 6083 | first_ref: Zir.Inst.Ref, |
| 5804 | 6084 | last_ref: Zir.Inst.Ref, |
| ... | ... | @@ -5814,7 +6094,7 @@ fn validateSwitchRange( |
| 5814 | 6094 | |
| 5815 | 6095 | fn validateSwitchItem( |
| 5816 | 6096 | sema: *Sema, |
| 5817 | | block: *Scope.Block, |
| 6097 | block: *Block, |
| 5818 | 6098 | range_set: *RangeSet, |
| 5819 | 6099 | item_ref: Zir.Inst.Ref, |
| 5820 | 6100 | operand_ty: Type, |
| ... | ... | @@ -5828,7 +6108,7 @@ fn validateSwitchItem( |
| 5828 | 6108 | |
| 5829 | 6109 | fn validateSwitchItemEnum( |
| 5830 | 6110 | sema: *Sema, |
| 5831 | | block: *Scope.Block, |
| 6111 | block: *Block, |
| 5832 | 6112 | seen_fields: []?Module.SwitchProngSrc, |
| 5833 | 6113 | item_ref: Zir.Inst.Ref, |
| 5834 | 6114 | src_node_offset: i32, |
| ... | ... | @@ -5862,7 +6142,7 @@ fn validateSwitchItemEnum( |
| 5862 | 6142 | |
| 5863 | 6143 | fn validateSwitchDupe( |
| 5864 | 6144 | sema: *Sema, |
| 5865 | | block: *Scope.Block, |
| 6145 | block: *Block, |
| 5866 | 6146 | maybe_prev_src: ?Module.SwitchProngSrc, |
| 5867 | 6147 | switch_prong_src: Module.SwitchProngSrc, |
| 5868 | 6148 | src_node_offset: i32, |
| ... | ... | @@ -5893,7 +6173,7 @@ fn validateSwitchDupe( |
| 5893 | 6173 | |
| 5894 | 6174 | fn validateSwitchItemBool( |
| 5895 | 6175 | sema: *Sema, |
| 5896 | | block: *Scope.Block, |
| 6176 | block: *Block, |
| 5897 | 6177 | true_count: *u8, |
| 5898 | 6178 | false_count: *u8, |
| 5899 | 6179 | item_ref: Zir.Inst.Ref, |
| ... | ... | @@ -5916,7 +6196,7 @@ const ValueSrcMap = std.HashMap(Value, Module.SwitchProngSrc, Value.HashContext, |
| 5916 | 6196 | |
| 5917 | 6197 | fn validateSwitchItemSparse( |
| 5918 | 6198 | sema: *Sema, |
| 5919 | | block: *Scope.Block, |
| 6199 | block: *Block, |
| 5920 | 6200 | seen_values: *ValueSrcMap, |
| 5921 | 6201 | item_ref: Zir.Inst.Ref, |
| 5922 | 6202 | src_node_offset: i32, |
| ... | ... | @@ -5929,7 +6209,7 @@ fn validateSwitchItemSparse( |
| 5929 | 6209 | |
| 5930 | 6210 | fn validateSwitchNoRange( |
| 5931 | 6211 | sema: *Sema, |
| 5932 | | block: *Scope.Block, |
| 6212 | block: *Block, |
| 5933 | 6213 | ranges_len: u32, |
| 5934 | 6214 | operand_ty: Type, |
| 5935 | 6215 | src_node_offset: i32, |
| ... | ... | @@ -5960,7 +6240,7 @@ fn validateSwitchNoRange( |
| 5960 | 6240 | return sema.failWithOwnedErrorMsg(msg); |
| 5961 | 6241 | } |
| 5962 | 6242 | |
| 5963 | | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6243 | fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5964 | 6244 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5965 | 6245 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 5966 | 6246 | _ = extra; |
| ... | ... | @@ -5969,7 +6249,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 5969 | 6249 | return sema.fail(block, src, "TODO implement zirHasField", .{}); |
| 5970 | 6250 | } |
| 5971 | 6251 | |
| 5972 | | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6252 | fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5973 | 6253 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5974 | 6254 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 5975 | 6255 | const src = inst_data.src(); |
| ... | ... | @@ -5985,14 +6265,14 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 5985 | 6265 | .{container_type}, |
| 5986 | 6266 | ); |
| 5987 | 6267 | 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()) { |
| 5989 | 6269 | return Air.Inst.Ref.bool_true; |
| 5990 | 6270 | } |
| 5991 | 6271 | } |
| 5992 | 6272 | return Air.Inst.Ref.bool_false; |
| 5993 | 6273 | } |
| 5994 | 6274 | |
| 5995 | | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6275 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5996 | 6276 | const tracy = trace(@src()); |
| 5997 | 6277 | defer tracy.end(); |
| 5998 | 6278 | |
| ... | ... | @@ -6017,7 +6297,7 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 6017 | 6297 | return sema.addConstant(file_root_decl.ty, file_root_decl.val); |
| 6018 | 6298 | } |
| 6019 | 6299 | |
| 6020 | | fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6300 | fn zirRetErrValueCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6021 | 6301 | _ = block; |
| 6022 | 6302 | _ = inst; |
| 6023 | 6303 | 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 |
| 6025 | 6305 | |
| 6026 | 6306 | fn zirShl( |
| 6027 | 6307 | sema: *Sema, |
| 6028 | | block: *Scope.Block, |
| 6308 | block: *Block, |
| 6029 | 6309 | inst: Zir.Inst.Index, |
| 6030 | 6310 | air_tag: Air.Inst.Tag, |
| 6031 | 6311 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -6076,7 +6356,7 @@ fn zirShl( |
| 6076 | 6356 | return block.addBinOp(air_tag, lhs, rhs); |
| 6077 | 6357 | } |
| 6078 | 6358 | |
| 6079 | | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6359 | fn zirShr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6080 | 6360 | const tracy = trace(@src()); |
| 6081 | 6361 | defer tracy.end(); |
| 6082 | 6362 | |
| ... | ... | @@ -6109,7 +6389,7 @@ fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!A |
| 6109 | 6389 | |
| 6110 | 6390 | fn zirBitwise( |
| 6111 | 6391 | sema: *Sema, |
| 6112 | | block: *Scope.Block, |
| 6392 | block: *Block, |
| 6113 | 6393 | inst: Zir.Inst.Index, |
| 6114 | 6394 | air_tag: Air.Inst.Tag, |
| 6115 | 6395 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -6175,7 +6455,7 @@ fn zirBitwise( |
| 6175 | 6455 | return block.addBinOp(air_tag, casted_lhs, casted_rhs); |
| 6176 | 6456 | } |
| 6177 | 6457 | |
| 6178 | | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6458 | fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6179 | 6459 | const tracy = trace(@src()); |
| 6180 | 6460 | defer tracy.end(); |
| 6181 | 6461 | |
| ... | ... | @@ -6183,7 +6463,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 6183 | 6463 | return sema.fail(block, sema.src, "TODO implement zirBitNot", .{}); |
| 6184 | 6464 | } |
| 6185 | 6465 | |
| 6186 | | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6466 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6187 | 6467 | const tracy = trace(@src()); |
| 6188 | 6468 | defer tracy.end(); |
| 6189 | 6469 | |
| ... | ... | @@ -6267,7 +6547,7 @@ fn getArrayCatInfo(t: Type) ?Type.ArrayInfo { |
| 6267 | 6547 | }; |
| 6268 | 6548 | } |
| 6269 | 6549 | |
| 6270 | | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6550 | fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 6271 | 6551 | const tracy = trace(@src()); |
| 6272 | 6552 | defer tracy.end(); |
| 6273 | 6553 | |
| ... | ... | @@ -6321,7 +6601,7 @@ fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 6321 | 6601 | |
| 6322 | 6602 | fn zirNegate( |
| 6323 | 6603 | sema: *Sema, |
| 6324 | | block: *Scope.Block, |
| 6604 | block: *Block, |
| 6325 | 6605 | inst: Zir.Inst.Index, |
| 6326 | 6606 | tag_override: Zir.Inst.Tag, |
| 6327 | 6607 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -6340,7 +6620,7 @@ fn zirNegate( |
| 6340 | 6620 | |
| 6341 | 6621 | fn zirArithmetic( |
| 6342 | 6622 | sema: *Sema, |
| 6343 | | block: *Scope.Block, |
| 6623 | block: *Block, |
| 6344 | 6624 | inst: Zir.Inst.Index, |
| 6345 | 6625 | zir_tag: Zir.Inst.Tag, |
| 6346 | 6626 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -6360,7 +6640,7 @@ fn zirArithmetic( |
| 6360 | 6640 | |
| 6361 | 6641 | fn zirOverflowArithmetic( |
| 6362 | 6642 | sema: *Sema, |
| 6363 | | block: *Scope.Block, |
| 6643 | block: *Block, |
| 6364 | 6644 | extended: Zir.Inst.Extended.InstData, |
| 6365 | 6645 | ) CompileError!Air.Inst.Ref { |
| 6366 | 6646 | const tracy = trace(@src()); |
| ... | ... | @@ -6374,7 +6654,7 @@ fn zirOverflowArithmetic( |
| 6374 | 6654 | |
| 6375 | 6655 | fn analyzeArithmetic( |
| 6376 | 6656 | sema: *Sema, |
| 6377 | | block: *Scope.Block, |
| 6657 | block: *Block, |
| 6378 | 6658 | /// TODO performance investigation: make this comptime? |
| 6379 | 6659 | zir_tag: Zir.Inst.Tag, |
| 6380 | 6660 | lhs: Air.Inst.Ref, |
| ... | ... | @@ -7035,7 +7315,7 @@ fn analyzeArithmetic( |
| 7035 | 7315 | return block.addBinOp(rs.air_tag, casted_lhs, casted_rhs); |
| 7036 | 7316 | } |
| 7037 | 7317 | |
| 7038 | | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7318 | fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7039 | 7319 | const tracy = trace(@src()); |
| 7040 | 7320 | defer tracy.end(); |
| 7041 | 7321 | |
| ... | ... | @@ -7048,7 +7328,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError! |
| 7048 | 7328 | |
| 7049 | 7329 | fn zirAsm( |
| 7050 | 7330 | sema: *Sema, |
| 7051 | | block: *Scope.Block, |
| 7331 | block: *Block, |
| 7052 | 7332 | extended: Zir.Inst.Extended.InstData, |
| 7053 | 7333 | inst: Zir.Inst.Index, |
| 7054 | 7334 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -7127,7 +7407,7 @@ fn zirAsm( |
| 7127 | 7407 | /// Only called for equality operators. See also `zirCmp`. |
| 7128 | 7408 | fn zirCmpEq( |
| 7129 | 7409 | sema: *Sema, |
| 7130 | | block: *Scope.Block, |
| 7410 | block: *Block, |
| 7131 | 7411 | inst: Zir.Inst.Index, |
| 7132 | 7412 | op: std.math.CompareOperator, |
| 7133 | 7413 | air_tag: Air.Inst.Tag, |
| ... | ... | @@ -7216,7 +7496,7 @@ fn zirCmpEq( |
| 7216 | 7496 | |
| 7217 | 7497 | fn analyzeCmpUnionTag( |
| 7218 | 7498 | sema: *Sema, |
| 7219 | | block: *Scope.Block, |
| 7499 | block: *Block, |
| 7220 | 7500 | un: Air.Inst.Ref, |
| 7221 | 7501 | un_src: LazySrcLoc, |
| 7222 | 7502 | tag: Air.Inst.Ref, |
| ... | ... | @@ -7239,7 +7519,7 @@ fn analyzeCmpUnionTag( |
| 7239 | 7519 | /// Only called for non-equality operators. See also `zirCmpEq`. |
| 7240 | 7520 | fn zirCmp( |
| 7241 | 7521 | sema: *Sema, |
| 7242 | | block: *Scope.Block, |
| 7522 | block: *Block, |
| 7243 | 7523 | inst: Zir.Inst.Index, |
| 7244 | 7524 | op: std.math.CompareOperator, |
| 7245 | 7525 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -7258,7 +7538,7 @@ fn zirCmp( |
| 7258 | 7538 | |
| 7259 | 7539 | fn analyzeCmp( |
| 7260 | 7540 | sema: *Sema, |
| 7261 | | block: *Scope.Block, |
| 7541 | block: *Block, |
| 7262 | 7542 | src: LazySrcLoc, |
| 7263 | 7543 | lhs: Air.Inst.Ref, |
| 7264 | 7544 | rhs: Air.Inst.Ref, |
| ... | ... | @@ -7289,7 +7569,7 @@ fn analyzeCmp( |
| 7289 | 7569 | |
| 7290 | 7570 | fn cmpSelf( |
| 7291 | 7571 | sema: *Sema, |
| 7292 | | block: *Scope.Block, |
| 7572 | block: *Block, |
| 7293 | 7573 | casted_lhs: Air.Inst.Ref, |
| 7294 | 7574 | casted_rhs: Air.Inst.Ref, |
| 7295 | 7575 | op: std.math.CompareOperator, |
| ... | ... | @@ -7347,7 +7627,7 @@ fn cmpSelf( |
| 7347 | 7627 | /// cmp_neq(x, true ) => not(x) |
| 7348 | 7628 | fn runtimeBoolCmp( |
| 7349 | 7629 | sema: *Sema, |
| 7350 | | block: *Scope.Block, |
| 7630 | block: *Block, |
| 7351 | 7631 | op: std.math.CompareOperator, |
| 7352 | 7632 | lhs: Air.Inst.Ref, |
| 7353 | 7633 | rhs: bool, |
| ... | ... | @@ -7361,7 +7641,7 @@ fn runtimeBoolCmp( |
| 7361 | 7641 | } |
| 7362 | 7642 | } |
| 7363 | 7643 | |
| 7364 | | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7644 | fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7365 | 7645 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7366 | 7646 | const src = inst_data.src(); |
| 7367 | 7647 | 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 |
| 7402 | 7682 | return sema.addIntUnsigned(Type.initTag(.comptime_int), abi_size); |
| 7403 | 7683 | } |
| 7404 | 7684 | |
| 7405 | | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7685 | fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7406 | 7686 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7407 | 7687 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 7408 | 7688 | 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 |
| 7413 | 7693 | |
| 7414 | 7694 | fn zirThis( |
| 7415 | 7695 | sema: *Sema, |
| 7416 | | block: *Scope.Block, |
| 7696 | block: *Block, |
| 7417 | 7697 | extended: Zir.Inst.Extended.InstData, |
| 7418 | 7698 | ) CompileError!Air.Inst.Ref { |
| 7419 | | const this_decl = block.base.namespace().getDecl(); |
| 7699 | const this_decl = block.namespace.getDecl(); |
| 7420 | 7700 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 7421 | 7701 | return sema.analyzeDeclVal(block, src, this_decl); |
| 7422 | 7702 | } |
| 7423 | 7703 | |
| 7424 | 7704 | fn zirClosureCapture( |
| 7425 | 7705 | sema: *Sema, |
| 7426 | | block: *Scope.Block, |
| 7706 | block: *Block, |
| 7427 | 7707 | inst: Zir.Inst.Index, |
| 7428 | 7708 | ) CompileError!void { |
| 7429 | 7709 | // TODO: Compile error when closed over values are modified |
| ... | ... | @@ -7437,7 +7717,7 @@ fn zirClosureCapture( |
| 7437 | 7717 | |
| 7438 | 7718 | fn zirClosureGet( |
| 7439 | 7719 | sema: *Sema, |
| 7440 | | block: *Scope.Block, |
| 7720 | block: *Block, |
| 7441 | 7721 | inst: Zir.Inst.Index, |
| 7442 | 7722 | ) CompileError!Air.Inst.Ref { |
| 7443 | 7723 | // TODO CLOSURE: Test this with inline functions |
| ... | ... | @@ -7459,7 +7739,7 @@ fn zirClosureGet( |
| 7459 | 7739 | |
| 7460 | 7740 | fn zirRetAddr( |
| 7461 | 7741 | sema: *Sema, |
| 7462 | | block: *Scope.Block, |
| 7742 | block: *Block, |
| 7463 | 7743 | extended: Zir.Inst.Extended.InstData, |
| 7464 | 7744 | ) CompileError!Air.Inst.Ref { |
| 7465 | 7745 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| ... | ... | @@ -7468,14 +7748,14 @@ fn zirRetAddr( |
| 7468 | 7748 | |
| 7469 | 7749 | fn zirBuiltinSrc( |
| 7470 | 7750 | sema: *Sema, |
| 7471 | | block: *Scope.Block, |
| 7751 | block: *Block, |
| 7472 | 7752 | extended: Zir.Inst.Extended.InstData, |
| 7473 | 7753 | ) CompileError!Air.Inst.Ref { |
| 7474 | 7754 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 7475 | 7755 | return sema.fail(block, src, "TODO: implement Sema.zirBuiltinSrc", .{}); |
| 7476 | 7756 | } |
| 7477 | 7757 | |
| 7478 | | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7758 | fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7479 | 7759 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7480 | 7760 | const src = inst_data.src(); |
| 7481 | 7761 | 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 |
| 7680 | 7960 | } |
| 7681 | 7961 | } |
| 7682 | 7962 | |
| 7683 | | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7963 | fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7684 | 7964 | _ = block; |
| 7685 | 7965 | const zir_datas = sema.code.instructions.items(.data); |
| 7686 | 7966 | const inst_data = zir_datas[inst].un_node; |
| ... | ... | @@ -7689,7 +7969,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 7689 | 7969 | return sema.addType(operand_ty); |
| 7690 | 7970 | } |
| 7691 | 7971 | |
| 7692 | | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7972 | fn zirTypeofElem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7693 | 7973 | _ = block; |
| 7694 | 7974 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7695 | 7975 | const operand_ptr = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -7697,7 +7977,7 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 7697 | 7977 | return sema.addType(elem_ty); |
| 7698 | 7978 | } |
| 7699 | 7979 | |
| 7700 | | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7980 | fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7701 | 7981 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7702 | 7982 | const src = inst_data.src(); |
| 7703 | 7983 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -7705,14 +7985,14 @@ fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 7705 | 7985 | return sema.log2IntType(block, operand_ty, src); |
| 7706 | 7986 | } |
| 7707 | 7987 | |
| 7708 | | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7988 | fn zirLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7709 | 7989 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7710 | 7990 | const src = inst_data.src(); |
| 7711 | 7991 | const operand = try sema.resolveType(block, src, inst_data.operand); |
| 7712 | 7992 | return sema.log2IntType(block, operand, src); |
| 7713 | 7993 | } |
| 7714 | 7994 | |
| 7715 | | fn log2IntType(sema: *Sema, block: *Scope.Block, operand: Type, src: LazySrcLoc) CompileError!Air.Inst.Ref { |
| 7995 | fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) CompileError!Air.Inst.Ref { |
| 7716 | 7996 | switch (operand.zigTypeTag()) { |
| 7717 | 7997 | .ComptimeInt => return Air.Inst.Ref.comptime_int_type, |
| 7718 | 7998 | .Int => { |
| ... | ... | @@ -7735,7 +8015,7 @@ fn log2IntType(sema: *Sema, block: *Scope.Block, operand: Type, src: LazySrcLoc) |
| 7735 | 8015 | |
| 7736 | 8016 | fn zirTypeofPeer( |
| 7737 | 8017 | sema: *Sema, |
| 7738 | | block: *Scope.Block, |
| 8018 | block: *Block, |
| 7739 | 8019 | extended: Zir.Inst.Extended.InstData, |
| 7740 | 8020 | ) CompileError!Air.Inst.Ref { |
| 7741 | 8021 | const tracy = trace(@src()); |
| ... | ... | @@ -7756,7 +8036,7 @@ fn zirTypeofPeer( |
| 7756 | 8036 | return sema.addType(result_type); |
| 7757 | 8037 | } |
| 7758 | 8038 | |
| 7759 | | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8039 | fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7760 | 8040 | const tracy = trace(@src()); |
| 7761 | 8041 | defer tracy.end(); |
| 7762 | 8042 | |
| ... | ... | @@ -7780,7 +8060,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 7780 | 8060 | |
| 7781 | 8061 | fn zirBoolBr( |
| 7782 | 8062 | sema: *Sema, |
| 7783 | | parent_block: *Scope.Block, |
| 8063 | parent_block: *Block, |
| 7784 | 8064 | inst: Zir.Inst.Index, |
| 7785 | 8065 | is_bool_or: bool, |
| 7786 | 8066 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -7866,7 +8146,7 @@ fn zirBoolBr( |
| 7866 | 8146 | |
| 7867 | 8147 | fn zirIsNonNull( |
| 7868 | 8148 | sema: *Sema, |
| 7869 | | block: *Scope.Block, |
| 8149 | block: *Block, |
| 7870 | 8150 | inst: Zir.Inst.Index, |
| 7871 | 8151 | ) CompileError!Air.Inst.Ref { |
| 7872 | 8152 | const tracy = trace(@src()); |
| ... | ... | @@ -7880,7 +8160,7 @@ fn zirIsNonNull( |
| 7880 | 8160 | |
| 7881 | 8161 | fn zirIsNonNullPtr( |
| 7882 | 8162 | sema: *Sema, |
| 7883 | | block: *Scope.Block, |
| 8163 | block: *Block, |
| 7884 | 8164 | inst: Zir.Inst.Index, |
| 7885 | 8165 | ) CompileError!Air.Inst.Ref { |
| 7886 | 8166 | const tracy = trace(@src()); |
| ... | ... | @@ -7893,7 +8173,7 @@ fn zirIsNonNullPtr( |
| 7893 | 8173 | return sema.analyzeIsNull(block, src, loaded, true); |
| 7894 | 8174 | } |
| 7895 | 8175 | |
| 7896 | | fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8176 | fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7897 | 8177 | const tracy = trace(@src()); |
| 7898 | 8178 | defer tracy.end(); |
| 7899 | 8179 | |
| ... | ... | @@ -7902,7 +8182,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 7902 | 8182 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); |
| 7903 | 8183 | } |
| 7904 | 8184 | |
| 7905 | | fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8185 | fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7906 | 8186 | const tracy = trace(@src()); |
| 7907 | 8187 | defer tracy.end(); |
| 7908 | 8188 | |
| ... | ... | @@ -7915,7 +8195,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 7915 | 8195 | |
| 7916 | 8196 | fn zirCondbr( |
| 7917 | 8197 | sema: *Sema, |
| 7918 | | parent_block: *Scope.Block, |
| 8198 | parent_block: *Block, |
| 7919 | 8199 | inst: Zir.Inst.Index, |
| 7920 | 8200 | ) CompileError!Zir.Inst.Index { |
| 7921 | 8201 | const tracy = trace(@src()); |
| ... | ... | @@ -7970,7 +8250,7 @@ fn zirCondbr( |
| 7970 | 8250 | return always_noreturn; |
| 7971 | 8251 | } |
| 7972 | 8252 | |
| 7973 | | fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 8253 | fn zirUnreachable(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 7974 | 8254 | const tracy = trace(@src()); |
| 7975 | 8255 | defer tracy.end(); |
| 7976 | 8256 | |
| ... | ... | @@ -7989,7 +8269,7 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 7989 | 8269 | |
| 7990 | 8270 | fn zirRetErrValue( |
| 7991 | 8271 | sema: *Sema, |
| 7992 | | block: *Scope.Block, |
| 8272 | block: *Block, |
| 7993 | 8273 | inst: Zir.Inst.Index, |
| 7994 | 8274 | ) CompileError!Zir.Inst.Index { |
| 7995 | 8275 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| ... | ... | @@ -8013,7 +8293,7 @@ fn zirRetErrValue( |
| 8013 | 8293 | |
| 8014 | 8294 | fn zirRetCoerce( |
| 8015 | 8295 | sema: *Sema, |
| 8016 | | block: *Scope.Block, |
| 8296 | block: *Block, |
| 8017 | 8297 | inst: Zir.Inst.Index, |
| 8018 | 8298 | ) CompileError!Zir.Inst.Index { |
| 8019 | 8299 | const tracy = trace(@src()); |
| ... | ... | @@ -8026,7 +8306,7 @@ fn zirRetCoerce( |
| 8026 | 8306 | return sema.analyzeRet(block, operand, src, true); |
| 8027 | 8307 | } |
| 8028 | 8308 | |
| 8029 | | fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 8309 | fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 8030 | 8310 | const tracy = trace(@src()); |
| 8031 | 8311 | defer tracy.end(); |
| 8032 | 8312 | |
| ... | ... | @@ -8041,7 +8321,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 8041 | 8321 | return sema.analyzeRet(block, operand, src, false); |
| 8042 | 8322 | } |
| 8043 | 8323 | |
| 8044 | | fn zirRetLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 8324 | fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 8045 | 8325 | const tracy = trace(@src()); |
| 8046 | 8326 | defer tracy.end(); |
| 8047 | 8327 | |
| ... | ... | @@ -8058,7 +8338,7 @@ fn zirRetLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 8058 | 8338 | |
| 8059 | 8339 | fn analyzeRet( |
| 8060 | 8340 | sema: *Sema, |
| 8061 | | block: *Scope.Block, |
| 8341 | block: *Block, |
| 8062 | 8342 | uncasted_operand: Air.Inst.Ref, |
| 8063 | 8343 | src: LazySrcLoc, |
| 8064 | 8344 | need_coercion: bool, |
| ... | ... | @@ -8091,7 +8371,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 8091 | 8371 | }; |
| 8092 | 8372 | } |
| 8093 | 8373 | |
| 8094 | | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8374 | fn zirPtrTypeSimple(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8095 | 8375 | const tracy = trace(@src()); |
| 8096 | 8376 | defer tracy.end(); |
| 8097 | 8377 | |
| ... | ... | @@ -8108,7 +8388,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 8108 | 8388 | return sema.addType(ty); |
| 8109 | 8389 | } |
| 8110 | 8390 | |
| 8111 | | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8391 | fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8112 | 8392 | const tracy = trace(@src()); |
| 8113 | 8393 | defer tracy.end(); |
| 8114 | 8394 | |
| ... | ... | @@ -8168,7 +8448,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 8168 | 8448 | return sema.addType(ty); |
| 8169 | 8449 | } |
| 8170 | 8450 | |
| 8171 | | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8451 | fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8172 | 8452 | const tracy = trace(@src()); |
| 8173 | 8453 | defer tracy.end(); |
| 8174 | 8454 | |
| ... | ... | @@ -8179,13 +8459,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 8179 | 8459 | return sema.addConstant(struct_type, Value.initTag(.empty_struct_value)); |
| 8180 | 8460 | } |
| 8181 | 8461 | |
| 8182 | | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8462 | fn zirUnionInitPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8183 | 8463 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8184 | 8464 | const src = inst_data.src(); |
| 8185 | 8465 | return sema.fail(block, src, "TODO: Sema.zirUnionInitPtr", .{}); |
| 8186 | 8466 | } |
| 8187 | 8467 | |
| 8188 | | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8468 | fn zirStructInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8189 | 8469 | const gpa = sema.gpa; |
| 8190 | 8470 | const zir_datas = sema.code.instructions.items(.data); |
| 8191 | 8471 | 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: |
| 8326 | 8606 | unreachable; |
| 8327 | 8607 | } |
| 8328 | 8608 | |
| 8329 | | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8609 | fn zirStructInitAnon(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8330 | 8610 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8331 | 8611 | const src = inst_data.src(); |
| 8332 | 8612 | |
| ... | ... | @@ -8334,7 +8614,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ |
| 8334 | 8614 | return sema.fail(block, src, "TODO: Sema.zirStructInitAnon", .{}); |
| 8335 | 8615 | } |
| 8336 | 8616 | |
| 8337 | | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8617 | fn zirArrayInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8338 | 8618 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8339 | 8619 | const src = inst_data.src(); |
| 8340 | 8620 | |
| ... | ... | @@ -8386,7 +8666,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 8386 | 8666 | try sema.analyzeLoad(block, .unneeded, alloc, .unneeded); |
| 8387 | 8667 | } |
| 8388 | 8668 | |
| 8389 | | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8669 | fn zirArrayInitAnon(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 8390 | 8670 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8391 | 8671 | const src = inst_data.src(); |
| 8392 | 8672 | |
| ... | ... | @@ -8394,13 +8674,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r |
| 8394 | 8674 | return sema.fail(block, src, "TODO: Sema.zirArrayInitAnon", .{}); |
| 8395 | 8675 | } |
| 8396 | 8676 | |
| 8397 | | fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8677 | fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8398 | 8678 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8399 | 8679 | const src = inst_data.src(); |
| 8400 | 8680 | return sema.fail(block, src, "TODO: Sema.zirFieldTypeRef", .{}); |
| 8401 | 8681 | } |
| 8402 | 8682 | |
| 8403 | | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8683 | fn zirFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8404 | 8684 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8405 | 8685 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; |
| 8406 | 8686 | const src = inst_data.src(); |
| ... | ... | @@ -8428,7 +8708,7 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 8428 | 8708 | |
| 8429 | 8709 | fn zirErrorReturnTrace( |
| 8430 | 8710 | sema: *Sema, |
| 8431 | | block: *Scope.Block, |
| 8711 | block: *Block, |
| 8432 | 8712 | extended: Zir.Inst.Extended.InstData, |
| 8433 | 8713 | ) CompileError!Air.Inst.Ref { |
| 8434 | 8714 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| ... | ... | @@ -8437,7 +8717,7 @@ fn zirErrorReturnTrace( |
| 8437 | 8717 | |
| 8438 | 8718 | fn zirFrame( |
| 8439 | 8719 | sema: *Sema, |
| 8440 | | block: *Scope.Block, |
| 8720 | block: *Block, |
| 8441 | 8721 | extended: Zir.Inst.Extended.InstData, |
| 8442 | 8722 | ) CompileError!Air.Inst.Ref { |
| 8443 | 8723 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| ... | ... | @@ -8446,14 +8726,14 @@ fn zirFrame( |
| 8446 | 8726 | |
| 8447 | 8727 | fn zirFrameAddress( |
| 8448 | 8728 | sema: *Sema, |
| 8449 | | block: *Scope.Block, |
| 8729 | block: *Block, |
| 8450 | 8730 | extended: Zir.Inst.Extended.InstData, |
| 8451 | 8731 | ) CompileError!Air.Inst.Ref { |
| 8452 | 8732 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 8453 | 8733 | return sema.fail(block, src, "TODO: Sema.zirFrameAddress", .{}); |
| 8454 | 8734 | } |
| 8455 | 8735 | |
| 8456 | | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8736 | fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8457 | 8737 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8458 | 8738 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8459 | 8739 | 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 |
| 8462 | 8742 | return sema.addIntUnsigned(Type.comptime_int, abi_align); |
| 8463 | 8743 | } |
| 8464 | 8744 | |
| 8465 | | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8745 | fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8466 | 8746 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8467 | 8747 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8468 | 8748 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -8474,31 +8754,31 @@ fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 8474 | 8754 | return block.addUnOp(.bool_to_int, operand); |
| 8475 | 8755 | } |
| 8476 | 8756 | |
| 8477 | | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8757 | fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8478 | 8758 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8479 | 8759 | const src = inst_data.src(); |
| 8480 | 8760 | return sema.fail(block, src, "TODO: Sema.zirEmbedFile", .{}); |
| 8481 | 8761 | } |
| 8482 | 8762 | |
| 8483 | | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8763 | fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8484 | 8764 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8485 | 8765 | const src = inst_data.src(); |
| 8486 | 8766 | return sema.fail(block, src, "TODO: Sema.zirErrorName", .{}); |
| 8487 | 8767 | } |
| 8488 | 8768 | |
| 8489 | | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8769 | fn zirUnaryMath(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8490 | 8770 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8491 | 8771 | const src = inst_data.src(); |
| 8492 | 8772 | return sema.fail(block, src, "TODO: Sema.zirUnaryMath", .{}); |
| 8493 | 8773 | } |
| 8494 | 8774 | |
| 8495 | | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8775 | fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8496 | 8776 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8497 | 8777 | const src = inst_data.src(); |
| 8498 | 8778 | return sema.fail(block, src, "TODO: Sema.zirTagName", .{}); |
| 8499 | 8779 | } |
| 8500 | 8780 | |
| 8501 | | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8781 | fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8502 | 8782 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8503 | 8783 | const src = inst_data.src(); |
| 8504 | 8784 | 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 |
| 8551 | 8831 | } |
| 8552 | 8832 | } |
| 8553 | 8833 | |
| 8554 | | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8834 | fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8555 | 8835 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8556 | 8836 | const src = inst_data.src(); |
| 8557 | 8837 | return sema.fail(block, src, "TODO: Sema.zirTypeName", .{}); |
| 8558 | 8838 | } |
| 8559 | 8839 | |
| 8560 | | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8840 | fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8561 | 8841 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8562 | 8842 | const src = inst_data.src(); |
| 8563 | 8843 | return sema.fail(block, src, "TODO: Sema.zirFrameType", .{}); |
| 8564 | 8844 | } |
| 8565 | 8845 | |
| 8566 | | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8846 | fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8567 | 8847 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8568 | 8848 | const src = inst_data.src(); |
| 8569 | 8849 | return sema.fail(block, src, "TODO: Sema.zirFrameSize", .{}); |
| 8570 | 8850 | } |
| 8571 | 8851 | |
| 8572 | | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8852 | fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8573 | 8853 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8574 | 8854 | const src = inst_data.src(); |
| 8575 | 8855 | // TODO don't forget the safety check! |
| 8576 | 8856 | return sema.fail(block, src, "TODO: Sema.zirFloatToInt", .{}); |
| 8577 | 8857 | } |
| 8578 | 8858 | |
| 8579 | | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8859 | fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8580 | 8860 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8581 | 8861 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8582 | 8862 | 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 |
| 8598 | 8878 | return block.addTyOp(.int_to_float, dest_ty, operand); |
| 8599 | 8879 | } |
| 8600 | 8880 | |
| 8601 | | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8881 | fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8602 | 8882 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8603 | 8883 | const src = inst_data.src(); |
| 8604 | 8884 | |
| ... | ... | @@ -8654,13 +8934,13 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 8654 | 8934 | return block.addTyOp(.bitcast, type_res, operand_coerced); |
| 8655 | 8935 | } |
| 8656 | 8936 | |
| 8657 | | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8937 | fn zirErrSetCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8658 | 8938 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8659 | 8939 | const src = inst_data.src(); |
| 8660 | 8940 | return sema.fail(block, src, "TODO: Sema.zirErrSetCast", .{}); |
| 8661 | 8941 | } |
| 8662 | 8942 | |
| 8663 | | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8943 | fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8664 | 8944 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8665 | 8945 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8666 | 8946 | 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 |
| 8684 | 8964 | return block.addTyOp(.bitcast, dest_ty, operand); |
| 8685 | 8965 | } |
| 8686 | 8966 | |
| 8687 | | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8967 | fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8688 | 8968 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8689 | 8969 | const src = inst_data.src(); |
| 8690 | 8970 | 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 |
| 8744 | 9024 | return block.addTyOp(.trunc, dest_ty, operand); |
| 8745 | 9025 | } |
| 8746 | 9026 | |
| 8747 | | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9027 | fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8748 | 9028 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8749 | 9029 | const src = inst_data.src(); |
| 8750 | 9030 | return sema.fail(block, src, "TODO: Sema.zirAlignCast", .{}); |
| 8751 | 9031 | } |
| 8752 | 9032 | |
| 8753 | | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9033 | fn zirClz(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8754 | 9034 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8755 | 9035 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8756 | 9036 | 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 |
| 8777 | 9057 | return block.addTyOp(.clz, result_ty, operand); |
| 8778 | 9058 | } |
| 8779 | 9059 | |
| 8780 | | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9060 | fn zirCtz(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8781 | 9061 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8782 | 9062 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8783 | 9063 | 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 |
| 8804 | 9084 | return block.addTyOp(.ctz, result_ty, operand); |
| 8805 | 9085 | } |
| 8806 | 9086 | |
| 8807 | | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9087 | fn zirPopCount(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8808 | 9088 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8809 | 9089 | const src = inst_data.src(); |
| 8810 | 9090 | return sema.fail(block, src, "TODO: Sema.zirPopCount", .{}); |
| 8811 | 9091 | } |
| 8812 | 9092 | |
| 8813 | | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9093 | fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8814 | 9094 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8815 | 9095 | const src = inst_data.src(); |
| 8816 | 9096 | return sema.fail(block, src, "TODO: Sema.zirByteSwap", .{}); |
| 8817 | 9097 | } |
| 8818 | 9098 | |
| 8819 | | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9099 | fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8820 | 9100 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 8821 | 9101 | const src = inst_data.src(); |
| 8822 | 9102 | return sema.fail(block, src, "TODO: Sema.zirBitReverse", .{}); |
| 8823 | 9103 | } |
| 8824 | 9104 | |
| 8825 | | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9105 | fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8826 | 9106 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8827 | 9107 | const src = inst_data.src(); |
| 8828 | 9108 | return sema.fail(block, src, "TODO: Sema.zirDivExact", .{}); |
| 8829 | 9109 | } |
| 8830 | 9110 | |
| 8831 | | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9111 | fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8832 | 9112 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8833 | 9113 | const src = inst_data.src(); |
| 8834 | 9114 | return sema.fail(block, src, "TODO: Sema.zirDivFloor", .{}); |
| 8835 | 9115 | } |
| 8836 | 9116 | |
| 8837 | | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9117 | fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8838 | 9118 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8839 | 9119 | const src = inst_data.src(); |
| 8840 | 9120 | return sema.fail(block, src, "TODO: Sema.zirDivTrunc", .{}); |
| 8841 | 9121 | } |
| 8842 | 9122 | |
| 8843 | | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9123 | fn zirShrExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8844 | 9124 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8845 | 9125 | const src = inst_data.src(); |
| 8846 | 9126 | return sema.fail(block, src, "TODO: Sema.zirShrExact", .{}); |
| 8847 | 9127 | } |
| 8848 | 9128 | |
| 8849 | | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9129 | fn zirBitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8850 | 9130 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8851 | 9131 | const src = inst_data.src(); |
| 8852 | 9132 | return sema.fail(block, src, "TODO: Sema.zirBitOffsetOf", .{}); |
| 8853 | 9133 | } |
| 8854 | 9134 | |
| 8855 | | fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9135 | fn zirOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8856 | 9136 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 8857 | 9137 | const src = inst_data.src(); |
| 8858 | 9138 | return sema.fail(block, src, "TODO: Sema.zirOffsetOf", .{}); |
| 8859 | 9139 | } |
| 8860 | 9140 | |
| 8861 | 9141 | /// Returns `true` if the type was a comptime_int. |
| 8862 | | fn checkIntType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!bool { |
| 9142 | fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool { |
| 8863 | 9143 | switch (ty.zigTypeTag()) { |
| 8864 | 9144 | .ComptimeInt => return true, |
| 8865 | 9145 | .Int => return false, |
| ... | ... | @@ -8869,7 +9149,7 @@ fn checkIntType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) Com |
| 8869 | 9149 | |
| 8870 | 9150 | fn checkFloatType( |
| 8871 | 9151 | sema: *Sema, |
| 8872 | | block: *Scope.Block, |
| 9152 | block: *Block, |
| 8873 | 9153 | ty_src: LazySrcLoc, |
| 8874 | 9154 | ty: Type, |
| 8875 | 9155 | ) CompileError!void { |
| ... | ... | @@ -8883,7 +9163,7 @@ fn checkFloatType( |
| 8883 | 9163 | |
| 8884 | 9164 | fn checkAtomicOperandType( |
| 8885 | 9165 | sema: *Sema, |
| 8886 | | block: *Scope.Block, |
| 9166 | block: *Block, |
| 8887 | 9167 | ty_src: LazySrcLoc, |
| 8888 | 9168 | ty: Type, |
| 8889 | 9169 | ) CompileError!void { |
| ... | ... | @@ -8930,7 +9210,7 @@ fn checkAtomicOperandType( |
| 8930 | 9210 | |
| 8931 | 9211 | fn resolveExportOptions( |
| 8932 | 9212 | sema: *Sema, |
| 8933 | | block: *Scope.Block, |
| 9213 | block: *Block, |
| 8934 | 9214 | src: LazySrcLoc, |
| 8935 | 9215 | zir_ref: Zir.Inst.Ref, |
| 8936 | 9216 | ) CompileError!std.builtin.ExportOptions { |
| ... | ... | @@ -8955,7 +9235,7 @@ fn resolveExportOptions( |
| 8955 | 9235 | |
| 8956 | 9236 | fn resolveAtomicOrder( |
| 8957 | 9237 | sema: *Sema, |
| 8958 | | block: *Scope.Block, |
| 9238 | block: *Block, |
| 8959 | 9239 | src: LazySrcLoc, |
| 8960 | 9240 | zir_ref: Zir.Inst.Ref, |
| 8961 | 9241 | ) CompileError!std.builtin.AtomicOrder { |
| ... | ... | @@ -8968,7 +9248,7 @@ fn resolveAtomicOrder( |
| 8968 | 9248 | |
| 8969 | 9249 | fn resolveAtomicRmwOp( |
| 8970 | 9250 | sema: *Sema, |
| 8971 | | block: *Scope.Block, |
| 9251 | block: *Block, |
| 8972 | 9252 | src: LazySrcLoc, |
| 8973 | 9253 | zir_ref: Zir.Inst.Ref, |
| 8974 | 9254 | ) CompileError!std.builtin.AtomicRmwOp { |
| ... | ... | @@ -8981,7 +9261,7 @@ fn resolveAtomicRmwOp( |
| 8981 | 9261 | |
| 8982 | 9262 | fn zirCmpxchg( |
| 8983 | 9263 | sema: *Sema, |
| 8984 | | block: *Scope.Block, |
| 9264 | block: *Block, |
| 8985 | 9265 | inst: Zir.Inst.Index, |
| 8986 | 9266 | air_tag: Air.Inst.Tag, |
| 8987 | 9267 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -9069,31 +9349,31 @@ fn zirCmpxchg( |
| 9069 | 9349 | }); |
| 9070 | 9350 | } |
| 9071 | 9351 | |
| 9072 | | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9352 | fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9073 | 9353 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9074 | 9354 | const src = inst_data.src(); |
| 9075 | 9355 | return sema.fail(block, src, "TODO: Sema.zirSplat", .{}); |
| 9076 | 9356 | } |
| 9077 | 9357 | |
| 9078 | | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9358 | fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9079 | 9359 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9080 | 9360 | const src = inst_data.src(); |
| 9081 | 9361 | return sema.fail(block, src, "TODO: Sema.zirReduce", .{}); |
| 9082 | 9362 | } |
| 9083 | 9363 | |
| 9084 | | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9364 | fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9085 | 9365 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9086 | 9366 | const src = inst_data.src(); |
| 9087 | 9367 | return sema.fail(block, src, "TODO: Sema.zirShuffle", .{}); |
| 9088 | 9368 | } |
| 9089 | 9369 | |
| 9090 | | fn zirSelect(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9370 | fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9091 | 9371 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9092 | 9372 | const src = inst_data.src(); |
| 9093 | 9373 | return sema.fail(block, src, "TODO: Sema.zirSelect", .{}); |
| 9094 | 9374 | } |
| 9095 | 9375 | |
| 9096 | | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9376 | fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9097 | 9377 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9098 | 9378 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9099 | 9379 | // zig fmt: off |
| ... | ... | @@ -9138,7 +9418,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compile |
| 9138 | 9418 | }); |
| 9139 | 9419 | } |
| 9140 | 9420 | |
| 9141 | | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9421 | fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9142 | 9422 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9143 | 9423 | const extra = sema.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data; |
| 9144 | 9424 | const src = inst_data.src(); |
| ... | ... | @@ -9216,7 +9496,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileE |
| 9216 | 9496 | }); |
| 9217 | 9497 | } |
| 9218 | 9498 | |
| 9219 | | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 9499 | fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 9220 | 9500 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9221 | 9501 | const extra = sema.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data; |
| 9222 | 9502 | const src = inst_data.src(); |
| ... | ... | @@ -9250,37 +9530,37 @@ fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Compil |
| 9250 | 9530 | return sema.storePtr2(block, src, ptr, ptr_src, operand, operand_src, air_tag); |
| 9251 | 9531 | } |
| 9252 | 9532 | |
| 9253 | | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9533 | fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9254 | 9534 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9255 | 9535 | const src = inst_data.src(); |
| 9256 | 9536 | return sema.fail(block, src, "TODO: Sema.zirMulAdd", .{}); |
| 9257 | 9537 | } |
| 9258 | 9538 | |
| 9259 | | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9539 | fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9260 | 9540 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9261 | 9541 | const src = inst_data.src(); |
| 9262 | 9542 | return sema.fail(block, src, "TODO: Sema.zirBuiltinCall", .{}); |
| 9263 | 9543 | } |
| 9264 | 9544 | |
| 9265 | | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9545 | fn zirFieldPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9266 | 9546 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9267 | 9547 | const src = inst_data.src(); |
| 9268 | 9548 | return sema.fail(block, src, "TODO: Sema.zirFieldPtrType", .{}); |
| 9269 | 9549 | } |
| 9270 | 9550 | |
| 9271 | | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9551 | fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9272 | 9552 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9273 | 9553 | const src = inst_data.src(); |
| 9274 | 9554 | return sema.fail(block, src, "TODO: Sema.zirFieldParentPtr", .{}); |
| 9275 | 9555 | } |
| 9276 | 9556 | |
| 9277 | | fn zirMaximum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9557 | fn zirMaximum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9278 | 9558 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9279 | 9559 | const src = inst_data.src(); |
| 9280 | 9560 | return sema.fail(block, src, "TODO: Sema.zirMaximum", .{}); |
| 9281 | 9561 | } |
| 9282 | 9562 | |
| 9283 | | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 9563 | fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 9284 | 9564 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9285 | 9565 | const extra = sema.code.extraData(Zir.Inst.Memcpy, inst_data.payload_index).data; |
| 9286 | 9566 | const src = inst_data.src(); |
| ... | ... | @@ -9345,7 +9625,7 @@ fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 9345 | 9625 | }); |
| 9346 | 9626 | } |
| 9347 | 9627 | |
| 9348 | | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void { |
| 9628 | fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 9349 | 9629 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9350 | 9630 | const extra = sema.code.extraData(Zir.Inst.Memset, inst_data.payload_index).data; |
| 9351 | 9631 | const src = inst_data.src(); |
| ... | ... | @@ -9391,19 +9671,19 @@ fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 9391 | 9671 | }); |
| 9392 | 9672 | } |
| 9393 | 9673 | |
| 9394 | | fn zirMinimum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9674 | fn zirMinimum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9395 | 9675 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9396 | 9676 | const src = inst_data.src(); |
| 9397 | 9677 | return sema.fail(block, src, "TODO: Sema.zirMinimum", .{}); |
| 9398 | 9678 | } |
| 9399 | 9679 | |
| 9400 | | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9680 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9401 | 9681 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9402 | 9682 | const src = inst_data.src(); |
| 9403 | 9683 | return sema.fail(block, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); |
| 9404 | 9684 | } |
| 9405 | 9685 | |
| 9406 | | fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9686 | fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9407 | 9687 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 9408 | 9688 | const src = inst_data.src(); |
| 9409 | 9689 | return sema.fail(block, src, "TODO: Sema.zirResume", .{}); |
| ... | ... | @@ -9411,7 +9691,7 @@ fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 9411 | 9691 | |
| 9412 | 9692 | fn zirAwait( |
| 9413 | 9693 | sema: *Sema, |
| 9414 | | block: *Scope.Block, |
| 9694 | block: *Block, |
| 9415 | 9695 | inst: Zir.Inst.Index, |
| 9416 | 9696 | is_nosuspend: bool, |
| 9417 | 9697 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -9424,7 +9704,7 @@ fn zirAwait( |
| 9424 | 9704 | |
| 9425 | 9705 | fn zirVarExtended( |
| 9426 | 9706 | sema: *Sema, |
| 9427 | | block: *Scope.Block, |
| 9707 | block: *Block, |
| 9428 | 9708 | extended: Zir.Inst.Extended.InstData, |
| 9429 | 9709 | ) CompileError!Air.Inst.Ref { |
| 9430 | 9710 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| ... | ... | @@ -9499,7 +9779,7 @@ fn zirVarExtended( |
| 9499 | 9779 | |
| 9500 | 9780 | fn zirFuncExtended( |
| 9501 | 9781 | sema: *Sema, |
| 9502 | | block: *Scope.Block, |
| 9782 | block: *Block, |
| 9503 | 9783 | extended: Zir.Inst.Extended.InstData, |
| 9504 | 9784 | inst: Zir.Inst.Index, |
| 9505 | 9785 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -9566,7 +9846,7 @@ fn zirFuncExtended( |
| 9566 | 9846 | |
| 9567 | 9847 | fn zirCUndef( |
| 9568 | 9848 | sema: *Sema, |
| 9569 | | block: *Scope.Block, |
| 9849 | block: *Block, |
| 9570 | 9850 | extended: Zir.Inst.Extended.InstData, |
| 9571 | 9851 | ) CompileError!Air.Inst.Ref { |
| 9572 | 9852 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| ... | ... | @@ -9579,7 +9859,7 @@ fn zirCUndef( |
| 9579 | 9859 | |
| 9580 | 9860 | fn zirCInclude( |
| 9581 | 9861 | sema: *Sema, |
| 9582 | | block: *Scope.Block, |
| 9862 | block: *Block, |
| 9583 | 9863 | extended: Zir.Inst.Extended.InstData, |
| 9584 | 9864 | ) CompileError!Air.Inst.Ref { |
| 9585 | 9865 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| ... | ... | @@ -9592,7 +9872,7 @@ fn zirCInclude( |
| 9592 | 9872 | |
| 9593 | 9873 | fn zirCDefine( |
| 9594 | 9874 | sema: *Sema, |
| 9595 | | block: *Scope.Block, |
| 9875 | block: *Block, |
| 9596 | 9876 | extended: Zir.Inst.Extended.InstData, |
| 9597 | 9877 | ) CompileError!Air.Inst.Ref { |
| 9598 | 9878 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| ... | ... | @@ -9610,7 +9890,7 @@ fn zirCDefine( |
| 9610 | 9890 | |
| 9611 | 9891 | fn zirWasmMemorySize( |
| 9612 | 9892 | sema: *Sema, |
| 9613 | | block: *Scope.Block, |
| 9893 | block: *Block, |
| 9614 | 9894 | extended: Zir.Inst.Extended.InstData, |
| 9615 | 9895 | ) CompileError!Air.Inst.Ref { |
| 9616 | 9896 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| ... | ... | @@ -9620,7 +9900,7 @@ fn zirWasmMemorySize( |
| 9620 | 9900 | |
| 9621 | 9901 | fn zirWasmMemoryGrow( |
| 9622 | 9902 | sema: *Sema, |
| 9623 | | block: *Scope.Block, |
| 9903 | block: *Block, |
| 9624 | 9904 | extended: Zir.Inst.Extended.InstData, |
| 9625 | 9905 | ) CompileError!Air.Inst.Ref { |
| 9626 | 9906 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| ... | ... | @@ -9630,7 +9910,7 @@ fn zirWasmMemoryGrow( |
| 9630 | 9910 | |
| 9631 | 9911 | fn zirBuiltinExtern( |
| 9632 | 9912 | sema: *Sema, |
| 9633 | | block: *Scope.Block, |
| 9913 | block: *Block, |
| 9634 | 9914 | extended: Zir.Inst.Extended.InstData, |
| 9635 | 9915 | ) CompileError!Air.Inst.Ref { |
| 9636 | 9916 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| ... | ... | @@ -9638,13 +9918,13 @@ fn zirBuiltinExtern( |
| 9638 | 9918 | return sema.fail(block, src, "TODO: implement Sema.zirBuiltinExtern", .{}); |
| 9639 | 9919 | } |
| 9640 | 9920 | |
| 9641 | | fn requireFunctionBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { |
| 9921 | fn requireFunctionBlock(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 9642 | 9922 | if (sema.func == null) { |
| 9643 | 9923 | return sema.fail(block, src, "instruction illegal outside function body", .{}); |
| 9644 | 9924 | } |
| 9645 | 9925 | } |
| 9646 | 9926 | |
| 9647 | | fn requireRuntimeBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { |
| 9927 | fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 9648 | 9928 | if (block.is_comptime) { |
| 9649 | 9929 | return sema.failWithNeededComptime(block, src); |
| 9650 | 9930 | } |
| ... | ... | @@ -9654,7 +9934,7 @@ fn requireRuntimeBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void |
| 9654 | 9934 | /// Emit a compile error if type cannot be used for a runtime variable. |
| 9655 | 9935 | fn validateVarType( |
| 9656 | 9936 | sema: *Sema, |
| 9657 | | block: *Scope.Block, |
| 9937 | block: *Block, |
| 9658 | 9938 | src: LazySrcLoc, |
| 9659 | 9939 | var_ty: Type, |
| 9660 | 9940 | is_extern: bool, |
| ... | ... | @@ -9713,13 +9993,13 @@ pub const PanicId = enum { |
| 9713 | 9993 | |
| 9714 | 9994 | fn addSafetyCheck( |
| 9715 | 9995 | sema: *Sema, |
| 9716 | | parent_block: *Scope.Block, |
| 9996 | parent_block: *Block, |
| 9717 | 9997 | ok: Air.Inst.Ref, |
| 9718 | 9998 | panic_id: PanicId, |
| 9719 | 9999 | ) !void { |
| 9720 | 10000 | const gpa = sema.gpa; |
| 9721 | 10001 | |
| 9722 | | var fail_block: Scope.Block = .{ |
| 10002 | var fail_block: Block = .{ |
| 9723 | 10003 | .parent = parent_block, |
| 9724 | 10004 | .sema = sema, |
| 9725 | 10005 | .src_decl = parent_block.src_decl, |
| ... | ... | @@ -9783,7 +10063,7 @@ fn addSafetyCheck( |
| 9783 | 10063 | |
| 9784 | 10064 | fn panicWithMsg( |
| 9785 | 10065 | sema: *Sema, |
| 9786 | | block: *Scope.Block, |
| 10066 | block: *Block, |
| 9787 | 10067 | src: LazySrcLoc, |
| 9788 | 10068 | msg_inst: Air.Inst.Ref, |
| 9789 | 10069 | ) !Zir.Inst.Index { |
| ... | ... | @@ -9817,7 +10097,7 @@ fn panicWithMsg( |
| 9817 | 10097 | |
| 9818 | 10098 | fn safetyPanic( |
| 9819 | 10099 | sema: *Sema, |
| 9820 | | block: *Scope.Block, |
| 10100 | block: *Block, |
| 9821 | 10101 | src: LazySrcLoc, |
| 9822 | 10102 | panic_id: PanicId, |
| 9823 | 10103 | ) CompileError!Zir.Inst.Index { |
| ... | ... | @@ -9845,7 +10125,7 @@ fn safetyPanic( |
| 9845 | 10125 | return sema.panicWithMsg(block, src, casted_msg_inst); |
| 9846 | 10126 | } |
| 9847 | 10127 | |
| 9848 | | fn emitBackwardBranch(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { |
| 10128 | fn emitBackwardBranch(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 9849 | 10129 | sema.branch_count += 1; |
| 9850 | 10130 | if (sema.branch_count > sema.branch_quota) { |
| 9851 | 10131 | // TODO show the "called from here" stack |
| ... | ... | @@ -9855,7 +10135,7 @@ fn emitBackwardBranch(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { |
| 9855 | 10135 | |
| 9856 | 10136 | fn fieldVal( |
| 9857 | 10137 | sema: *Sema, |
| 9858 | | block: *Scope.Block, |
| 10138 | block: *Block, |
| 9859 | 10139 | src: LazySrcLoc, |
| 9860 | 10140 | object: Air.Inst.Ref, |
| 9861 | 10141 | field_name: []const u8, |
| ... | ... | @@ -10036,7 +10316,7 @@ fn fieldVal( |
| 10036 | 10316 | |
| 10037 | 10317 | fn fieldPtr( |
| 10038 | 10318 | sema: *Sema, |
| 10039 | | block: *Scope.Block, |
| 10319 | block: *Block, |
| 10040 | 10320 | src: LazySrcLoc, |
| 10041 | 10321 | object_ptr: Air.Inst.Ref, |
| 10042 | 10322 | field_name: []const u8, |
| ... | ... | @@ -10227,7 +10507,7 @@ fn fieldPtr( |
| 10227 | 10507 | |
| 10228 | 10508 | fn fieldCallBind( |
| 10229 | 10509 | sema: *Sema, |
| 10230 | | block: *Scope.Block, |
| 10510 | block: *Block, |
| 10231 | 10511 | src: LazySrcLoc, |
| 10232 | 10512 | raw_ptr: Air.Inst.Ref, |
| 10233 | 10513 | field_name: []const u8, |
| ... | ... | @@ -10368,9 +10648,9 @@ fn fieldCallBind( |
| 10368 | 10648 | |
| 10369 | 10649 | fn namespaceLookup( |
| 10370 | 10650 | sema: *Sema, |
| 10371 | | block: *Scope.Block, |
| 10651 | block: *Block, |
| 10372 | 10652 | src: LazySrcLoc, |
| 10373 | | namespace: *Scope.Namespace, |
| 10653 | namespace: *Namespace, |
| 10374 | 10654 | decl_name: []const u8, |
| 10375 | 10655 | ) CompileError!?*Decl { |
| 10376 | 10656 | const gpa = sema.gpa; |
| ... | ... | @@ -10393,9 +10673,9 @@ fn namespaceLookup( |
| 10393 | 10673 | |
| 10394 | 10674 | fn namespaceLookupRef( |
| 10395 | 10675 | sema: *Sema, |
| 10396 | | block: *Scope.Block, |
| 10676 | block: *Block, |
| 10397 | 10677 | src: LazySrcLoc, |
| 10398 | | namespace: *Scope.Namespace, |
| 10678 | namespace: *Namespace, |
| 10399 | 10679 | decl_name: []const u8, |
| 10400 | 10680 | ) CompileError!?Air.Inst.Ref { |
| 10401 | 10681 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; |
| ... | ... | @@ -10404,7 +10684,7 @@ fn namespaceLookupRef( |
| 10404 | 10684 | |
| 10405 | 10685 | fn structFieldPtr( |
| 10406 | 10686 | sema: *Sema, |
| 10407 | | block: *Scope.Block, |
| 10687 | block: *Block, |
| 10408 | 10688 | src: LazySrcLoc, |
| 10409 | 10689 | struct_ptr: Air.Inst.Ref, |
| 10410 | 10690 | field_name: []const u8, |
| ... | ... | @@ -10444,7 +10724,7 @@ fn structFieldPtr( |
| 10444 | 10724 | |
| 10445 | 10725 | fn structFieldVal( |
| 10446 | 10726 | sema: *Sema, |
| 10447 | | block: *Scope.Block, |
| 10727 | block: *Block, |
| 10448 | 10728 | src: LazySrcLoc, |
| 10449 | 10729 | struct_byval: Air.Inst.Ref, |
| 10450 | 10730 | field_name: []const u8, |
| ... | ... | @@ -10482,7 +10762,7 @@ fn structFieldVal( |
| 10482 | 10762 | |
| 10483 | 10763 | fn unionFieldPtr( |
| 10484 | 10764 | sema: *Sema, |
| 10485 | | block: *Scope.Block, |
| 10765 | block: *Block, |
| 10486 | 10766 | src: LazySrcLoc, |
| 10487 | 10767 | union_ptr: Air.Inst.Ref, |
| 10488 | 10768 | field_name: []const u8, |
| ... | ... | @@ -10524,7 +10804,7 @@ fn unionFieldPtr( |
| 10524 | 10804 | |
| 10525 | 10805 | fn unionFieldVal( |
| 10526 | 10806 | sema: *Sema, |
| 10527 | | block: *Scope.Block, |
| 10807 | block: *Block, |
| 10528 | 10808 | src: LazySrcLoc, |
| 10529 | 10809 | union_byval: Air.Inst.Ref, |
| 10530 | 10810 | field_name: []const u8, |
| ... | ... | @@ -10555,7 +10835,7 @@ fn unionFieldVal( |
| 10555 | 10835 | |
| 10556 | 10836 | fn elemPtr( |
| 10557 | 10837 | sema: *Sema, |
| 10558 | | block: *Scope.Block, |
| 10838 | block: *Block, |
| 10559 | 10839 | src: LazySrcLoc, |
| 10560 | 10840 | array_ptr: Air.Inst.Ref, |
| 10561 | 10841 | elem_index: Air.Inst.Ref, |
| ... | ... | @@ -10584,7 +10864,7 @@ fn elemPtr( |
| 10584 | 10864 | |
| 10585 | 10865 | fn elemVal( |
| 10586 | 10866 | sema: *Sema, |
| 10587 | | block: *Scope.Block, |
| 10867 | block: *Block, |
| 10588 | 10868 | src: LazySrcLoc, |
| 10589 | 10869 | array_maybe_ptr: Air.Inst.Ref, |
| 10590 | 10870 | elem_index: Air.Inst.Ref, |
| ... | ... | @@ -10673,7 +10953,7 @@ fn elemVal( |
| 10673 | 10953 | |
| 10674 | 10954 | fn elemPtrArray( |
| 10675 | 10955 | sema: *Sema, |
| 10676 | | block: *Scope.Block, |
| 10956 | block: *Block, |
| 10677 | 10957 | src: LazySrcLoc, |
| 10678 | 10958 | array_ptr: Air.Inst.Ref, |
| 10679 | 10959 | elem_index: Air.Inst.Ref, |
| ... | ... | @@ -10713,7 +10993,7 @@ fn elemPtrArray( |
| 10713 | 10993 | |
| 10714 | 10994 | fn coerce( |
| 10715 | 10995 | sema: *Sema, |
| 10716 | | block: *Scope.Block, |
| 10996 | block: *Block, |
| 10717 | 10997 | dest_type_unresolved: Type, |
| 10718 | 10998 | inst: Air.Inst.Ref, |
| 10719 | 10999 | inst_src: LazySrcLoc, |
| ... | ... | @@ -10985,7 +11265,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type, dest_is_mut: bool, tar |
| 10985 | 11265 | |
| 10986 | 11266 | fn coerceNum( |
| 10987 | 11267 | sema: *Sema, |
| 10988 | | block: *Scope.Block, |
| 11268 | block: *Block, |
| 10989 | 11269 | dest_type: Type, |
| 10990 | 11270 | inst: Air.Inst.Ref, |
| 10991 | 11271 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11053,7 +11333,7 @@ fn coerceNum( |
| 11053 | 11333 | |
| 11054 | 11334 | fn coerceVarArgParam( |
| 11055 | 11335 | sema: *Sema, |
| 11056 | | block: *Scope.Block, |
| 11336 | block: *Block, |
| 11057 | 11337 | inst: Air.Inst.Ref, |
| 11058 | 11338 | inst_src: LazySrcLoc, |
| 11059 | 11339 | ) !Air.Inst.Ref { |
| ... | ... | @@ -11069,7 +11349,7 @@ fn coerceVarArgParam( |
| 11069 | 11349 | // TODO migrate callsites to use storePtr2 instead. |
| 11070 | 11350 | fn storePtr( |
| 11071 | 11351 | sema: *Sema, |
| 11072 | | block: *Scope.Block, |
| 11352 | block: *Block, |
| 11073 | 11353 | src: LazySrcLoc, |
| 11074 | 11354 | ptr: Air.Inst.Ref, |
| 11075 | 11355 | uncasted_operand: Air.Inst.Ref, |
| ... | ... | @@ -11079,7 +11359,7 @@ fn storePtr( |
| 11079 | 11359 | |
| 11080 | 11360 | fn storePtr2( |
| 11081 | 11361 | sema: *Sema, |
| 11082 | | block: *Scope.Block, |
| 11362 | block: *Block, |
| 11083 | 11363 | src: LazySrcLoc, |
| 11084 | 11364 | ptr: Air.Inst.Ref, |
| 11085 | 11365 | ptr_src: LazySrcLoc, |
| ... | ... | @@ -11116,7 +11396,7 @@ fn storePtr2( |
| 11116 | 11396 | /// assert the store must be done at comptime. |
| 11117 | 11397 | fn storePtrVal( |
| 11118 | 11398 | sema: *Sema, |
| 11119 | | block: *Scope.Block, |
| 11399 | block: *Block, |
| 11120 | 11400 | src: LazySrcLoc, |
| 11121 | 11401 | ptr_val: Value, |
| 11122 | 11402 | operand_val: Value, |
| ... | ... | @@ -11161,7 +11441,7 @@ fn storePtrVal( |
| 11161 | 11441 | |
| 11162 | 11442 | fn bitcast( |
| 11163 | 11443 | sema: *Sema, |
| 11164 | | block: *Scope.Block, |
| 11444 | block: *Block, |
| 11165 | 11445 | dest_type: Type, |
| 11166 | 11446 | inst: Air.Inst.Ref, |
| 11167 | 11447 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11177,7 +11457,7 @@ fn bitcast( |
| 11177 | 11457 | |
| 11178 | 11458 | fn coerceArrayPtrToSlice( |
| 11179 | 11459 | sema: *Sema, |
| 11180 | | block: *Scope.Block, |
| 11460 | block: *Block, |
| 11181 | 11461 | dest_type: Type, |
| 11182 | 11462 | inst: Air.Inst.Ref, |
| 11183 | 11463 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11192,7 +11472,7 @@ fn coerceArrayPtrToSlice( |
| 11192 | 11472 | |
| 11193 | 11473 | fn coerceArrayPtrToMany( |
| 11194 | 11474 | sema: *Sema, |
| 11195 | | block: *Scope.Block, |
| 11475 | block: *Block, |
| 11196 | 11476 | dest_type: Type, |
| 11197 | 11477 | inst: Air.Inst.Ref, |
| 11198 | 11478 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11207,7 +11487,7 @@ fn coerceArrayPtrToMany( |
| 11207 | 11487 | |
| 11208 | 11488 | fn analyzeDeclVal( |
| 11209 | 11489 | sema: *Sema, |
| 11210 | | block: *Scope.Block, |
| 11490 | block: *Block, |
| 11211 | 11491 | src: LazySrcLoc, |
| 11212 | 11492 | decl: *Decl, |
| 11213 | 11493 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -11261,7 +11541,7 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref { |
| 11261 | 11541 | |
| 11262 | 11542 | fn analyzeRef( |
| 11263 | 11543 | sema: *Sema, |
| 11264 | | block: *Scope.Block, |
| 11544 | block: *Block, |
| 11265 | 11545 | src: LazySrcLoc, |
| 11266 | 11546 | operand: Air.Inst.Ref, |
| 11267 | 11547 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -11296,7 +11576,7 @@ fn analyzeRef( |
| 11296 | 11576 | |
| 11297 | 11577 | fn analyzeLoad( |
| 11298 | 11578 | sema: *Sema, |
| 11299 | | block: *Scope.Block, |
| 11579 | block: *Block, |
| 11300 | 11580 | src: LazySrcLoc, |
| 11301 | 11581 | ptr: Air.Inst.Ref, |
| 11302 | 11582 | ptr_src: LazySrcLoc, |
| ... | ... | @@ -11318,7 +11598,7 @@ fn analyzeLoad( |
| 11318 | 11598 | |
| 11319 | 11599 | fn analyzeSliceLen( |
| 11320 | 11600 | sema: *Sema, |
| 11321 | | block: *Scope.Block, |
| 11601 | block: *Block, |
| 11322 | 11602 | src: LazySrcLoc, |
| 11323 | 11603 | slice_inst: Air.Inst.Ref, |
| 11324 | 11604 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -11334,7 +11614,7 @@ fn analyzeSliceLen( |
| 11334 | 11614 | |
| 11335 | 11615 | fn analyzeIsNull( |
| 11336 | 11616 | sema: *Sema, |
| 11337 | | block: *Scope.Block, |
| 11617 | block: *Block, |
| 11338 | 11618 | src: LazySrcLoc, |
| 11339 | 11619 | operand: Air.Inst.Ref, |
| 11340 | 11620 | invert_logic: bool, |
| ... | ... | @@ -11359,7 +11639,7 @@ fn analyzeIsNull( |
| 11359 | 11639 | |
| 11360 | 11640 | fn analyzeIsNonErr( |
| 11361 | 11641 | sema: *Sema, |
| 11362 | | block: *Scope.Block, |
| 11642 | block: *Block, |
| 11363 | 11643 | src: LazySrcLoc, |
| 11364 | 11644 | operand: Air.Inst.Ref, |
| 11365 | 11645 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -11385,7 +11665,7 @@ fn analyzeIsNonErr( |
| 11385 | 11665 | |
| 11386 | 11666 | fn analyzeSlice( |
| 11387 | 11667 | sema: *Sema, |
| 11388 | | block: *Scope.Block, |
| 11668 | block: *Block, |
| 11389 | 11669 | src: LazySrcLoc, |
| 11390 | 11670 | array_ptr: Air.Inst.Ref, |
| 11391 | 11671 | start: Air.Inst.Ref, |
| ... | ... | @@ -11460,7 +11740,7 @@ fn analyzeSlice( |
| 11460 | 11740 | /// Asserts that lhs and rhs types are both numeric. |
| 11461 | 11741 | fn cmpNumeric( |
| 11462 | 11742 | sema: *Sema, |
| 11463 | | block: *Scope.Block, |
| 11743 | block: *Block, |
| 11464 | 11744 | src: LazySrcLoc, |
| 11465 | 11745 | lhs: Air.Inst.Ref, |
| 11466 | 11746 | rhs: Air.Inst.Ref, |
| ... | ... | @@ -11648,7 +11928,7 @@ fn cmpNumeric( |
| 11648 | 11928 | |
| 11649 | 11929 | fn wrapOptional( |
| 11650 | 11930 | sema: *Sema, |
| 11651 | | block: *Scope.Block, |
| 11931 | block: *Block, |
| 11652 | 11932 | dest_type: Type, |
| 11653 | 11933 | inst: Air.Inst.Ref, |
| 11654 | 11934 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11663,7 +11943,7 @@ fn wrapOptional( |
| 11663 | 11943 | |
| 11664 | 11944 | fn wrapErrorUnion( |
| 11665 | 11945 | sema: *Sema, |
| 11666 | | block: *Scope.Block, |
| 11946 | block: *Block, |
| 11667 | 11947 | dest_type: Type, |
| 11668 | 11948 | inst: Air.Inst.Ref, |
| 11669 | 11949 | inst_src: LazySrcLoc, |
| ... | ... | @@ -11739,7 +12019,7 @@ fn wrapErrorUnion( |
| 11739 | 12019 | |
| 11740 | 12020 | fn unionToTag( |
| 11741 | 12021 | sema: *Sema, |
| 11742 | | block: *Scope.Block, |
| 12022 | block: *Block, |
| 11743 | 12023 | dest_type: Type, |
| 11744 | 12024 | un: Air.Inst.Ref, |
| 11745 | 12025 | un_src: LazySrcLoc, |
| ... | ... | @@ -11753,7 +12033,7 @@ fn unionToTag( |
| 11753 | 12033 | |
| 11754 | 12034 | fn resolvePeerTypes( |
| 11755 | 12035 | sema: *Sema, |
| 11756 | | block: *Scope.Block, |
| 12036 | block: *Block, |
| 11757 | 12037 | src: LazySrcLoc, |
| 11758 | 12038 | instructions: []Air.Inst.Ref, |
| 11759 | 12039 | candidate_srcs: Module.PeerTypeCandidateSrc, |
| ... | ... | @@ -11867,7 +12147,7 @@ fn resolvePeerTypes( |
| 11867 | 12147 | |
| 11868 | 12148 | pub fn resolveTypeLayout( |
| 11869 | 12149 | sema: *Sema, |
| 11870 | | block: *Scope.Block, |
| 12150 | block: *Block, |
| 11871 | 12151 | src: LazySrcLoc, |
| 11872 | 12152 | ty: Type, |
| 11873 | 12153 | ) CompileError!void { |
| ... | ... | @@ -11892,7 +12172,7 @@ pub fn resolveTypeLayout( |
| 11892 | 12172 | } |
| 11893 | 12173 | } |
| 11894 | 12174 | |
| 11895 | | fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!Type { |
| 12175 | fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!Type { |
| 11896 | 12176 | switch (ty.tag()) { |
| 11897 | 12177 | .@"struct" => { |
| 11898 | 12178 | const struct_obj = ty.castTag(.@"struct").?.data; |
| ... | ... | @@ -11943,7 +12223,7 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type |
| 11943 | 12223 | |
| 11944 | 12224 | fn resolveBuiltinTypeFields( |
| 11945 | 12225 | sema: *Sema, |
| 11946 | | block: *Scope.Block, |
| 12226 | block: *Block, |
| 11947 | 12227 | src: LazySrcLoc, |
| 11948 | 12228 | name: []const u8, |
| 11949 | 12229 | ) CompileError!Type { |
| ... | ... | @@ -12021,7 +12301,7 @@ fn semaStructFields( |
| 12021 | 12301 | var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope); |
| 12022 | 12302 | defer wip_captures.deinit(); |
| 12023 | 12303 | |
| 12024 | | var block_scope: Scope.Block = .{ |
| 12304 | var block_scope: Block = .{ |
| 12025 | 12305 | .parent = null, |
| 12026 | 12306 | .sema = &sema, |
| 12027 | 12307 | .src_decl = decl, |
| ... | ... | @@ -12191,7 +12471,7 @@ fn semaUnionFields( |
| 12191 | 12471 | var wip_captures = try WipCaptureScope.init(gpa, &decl_arena.allocator, decl.src_scope); |
| 12192 | 12472 | defer wip_captures.deinit(); |
| 12193 | 12473 | |
| 12194 | | var block_scope: Scope.Block = .{ |
| 12474 | var block_scope: Block = .{ |
| 12195 | 12475 | .parent = null, |
| 12196 | 12476 | .sema = &sema, |
| 12197 | 12477 | .src_decl = decl, |
| ... | ... | @@ -12322,7 +12602,7 @@ fn semaUnionFields( |
| 12322 | 12602 | |
| 12323 | 12603 | fn generateUnionTagTypeNumbered( |
| 12324 | 12604 | sema: *Sema, |
| 12325 | | block: *Scope.Block, |
| 12605 | block: *Block, |
| 12326 | 12606 | fields_len: u32, |
| 12327 | 12607 | int_ty: Type, |
| 12328 | 12608 | ) !Type { |
| ... | ... | @@ -12340,7 +12620,7 @@ fn generateUnionTagTypeNumbered( |
| 12340 | 12620 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 12341 | 12621 | const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty); |
| 12342 | 12622 | // TODO better type name |
| 12343 | | const new_decl = try mod.createAnonymousDecl(&block.base, .{ |
| 12623 | const new_decl = try mod.createAnonymousDecl(block, .{ |
| 12344 | 12624 | .ty = Type.initTag(.type), |
| 12345 | 12625 | .val = enum_val, |
| 12346 | 12626 | }); |
| ... | ... | @@ -12361,7 +12641,7 @@ fn generateUnionTagTypeNumbered( |
| 12361 | 12641 | return enum_ty; |
| 12362 | 12642 | } |
| 12363 | 12643 | |
| 12364 | | fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32) !Type { |
| 12644 | fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: u32) !Type { |
| 12365 | 12645 | const mod = sema.mod; |
| 12366 | 12646 | |
| 12367 | 12647 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| ... | ... | @@ -12376,7 +12656,7 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32) |
| 12376 | 12656 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 12377 | 12657 | const enum_val = try Value.Tag.ty.create(&new_decl_arena.allocator, enum_ty); |
| 12378 | 12658 | // TODO better type name |
| 12379 | | const new_decl = try mod.createAnonymousDecl(&block.base, .{ |
| 12659 | const new_decl = try mod.createAnonymousDecl(block, .{ |
| 12380 | 12660 | .ty = Type.initTag(.type), |
| 12381 | 12661 | .val = enum_val, |
| 12382 | 12662 | }); |
| ... | ... | @@ -12396,7 +12676,7 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Scope.Block, fields_len: u32) |
| 12396 | 12676 | |
| 12397 | 12677 | fn getBuiltin( |
| 12398 | 12678 | sema: *Sema, |
| 12399 | | block: *Scope.Block, |
| 12679 | block: *Block, |
| 12400 | 12680 | src: LazySrcLoc, |
| 12401 | 12681 | name: []const u8, |
| 12402 | 12682 | ) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -12422,7 +12702,7 @@ fn getBuiltin( |
| 12422 | 12702 | |
| 12423 | 12703 | fn getBuiltinType( |
| 12424 | 12704 | sema: *Sema, |
| 12425 | | block: *Scope.Block, |
| 12705 | block: *Block, |
| 12426 | 12706 | src: LazySrcLoc, |
| 12427 | 12707 | name: []const u8, |
| 12428 | 12708 | ) CompileError!Type { |
| ... | ... | @@ -12436,7 +12716,7 @@ fn getBuiltinType( |
| 12436 | 12716 | /// that the types are already resolved. |
| 12437 | 12717 | fn typeHasOnePossibleValue( |
| 12438 | 12718 | sema: *Sema, |
| 12439 | | block: *Scope.Block, |
| 12719 | block: *Block, |
| 12440 | 12720 | src: LazySrcLoc, |
| 12441 | 12721 | starting_type: Type, |
| 12442 | 12722 | ) CompileError!?Value { |
| ... | ... | @@ -12599,7 +12879,7 @@ fn typeHasOnePossibleValue( |
| 12599 | 12879 | }; |
| 12600 | 12880 | } |
| 12601 | 12881 | |
| 12602 | | fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.Ast { |
| 12882 | fn getAstTree(sema: *Sema, block: *Block) CompileError!*const std.zig.Ast { |
| 12603 | 12883 | return block.namespace.file_scope.getTree(sema.gpa) catch |err| { |
| 12604 | 12884 | log.err("unable to load AST to report compile error: {s}", .{@errorName(err)}); |
| 12605 | 12885 | return error.AnalysisFail; |
| ... | ... | @@ -12789,7 +13069,7 @@ fn getBreakBlock(sema: *Sema, inst_index: Air.Inst.Index) ?Air.Inst.Index { |
| 12789 | 13069 | |
| 12790 | 13070 | fn isComptimeKnown( |
| 12791 | 13071 | sema: *Sema, |
| 12792 | | block: *Scope.Block, |
| 13072 | block: *Block, |
| 12793 | 13073 | src: LazySrcLoc, |
| 12794 | 13074 | inst: Air.Inst.Ref, |
| 12795 | 13075 | ) !bool { |
| ... | ... | @@ -12798,7 +13078,7 @@ fn isComptimeKnown( |
| 12798 | 13078 | |
| 12799 | 13079 | fn analyzeComptimeAlloc( |
| 12800 | 13080 | sema: *Sema, |
| 12801 | | block: *Scope.Block, |
| 13081 | block: *Block, |
| 12802 | 13082 | var_type: Type, |
| 12803 | 13083 | ) CompileError!Air.Inst.Ref { |
| 12804 | 13084 | const ptr_type = try Type.ptr(sema.arena, .{ |
| ... | ... | @@ -12841,7 +13121,7 @@ pub const AddressSpaceContext = enum { |
| 12841 | 13121 | |
| 12842 | 13122 | pub fn analyzeAddrspace( |
| 12843 | 13123 | sema: *Sema, |
| 12844 | | block: *Scope.Block, |
| 13124 | block: *Block, |
| 12845 | 13125 | src: LazySrcLoc, |
| 12846 | 13126 | zir_ref: Zir.Inst.Ref, |
| 12847 | 13127 | ctx: AddressSpaceContext, |