| ... | ... | @@ -2141,7 +2141,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) |
| 2141 | 2141 | const addrs_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(addr_arr_ty)); |
| 2142 | 2142 | |
| 2143 | 2143 | // var st: StackTrace = undefined; |
| 2144 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 2144 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 2145 | 2145 | try stack_trace_ty.resolveFields(pt); |
| 2146 | 2146 | const st_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(stack_trace_ty)); |
| 2147 | 2147 | |
| ... | ... | @@ -6945,7 +6945,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 6945 | 6945 | |
| 6946 | 6946 | if (!block.ownerModule().error_tracing) return .none; |
| 6947 | 6947 | |
| 6948 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 6948 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 6949 | 6949 | try stack_trace_ty.resolveFields(pt); |
| 6950 | 6950 | const field_name = try zcu.intern_pool.getOrPutString(gpa, pt.tid, "index", .no_embedded_nulls); |
| 6951 | 6951 | const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) { |
| ... | ... | @@ -6987,7 +6987,7 @@ fn popErrorReturnTrace( |
| 6987 | 6987 | // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or |
| 6988 | 6988 | // the result is comptime-known to be a non-error. Either way, pop unconditionally. |
| 6989 | 6989 | |
| 6990 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 6990 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 6991 | 6991 | try stack_trace_ty.resolveFields(pt); |
| 6992 | 6992 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 6993 | 6993 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| ... | ... | @@ -7013,7 +7013,7 @@ fn popErrorReturnTrace( |
| 7013 | 7013 | defer then_block.instructions.deinit(gpa); |
| 7014 | 7014 | |
| 7015 | 7015 | // If non-error, then pop the error return trace by restoring the index. |
| 7016 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 7016 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 7017 | 7017 | try stack_trace_ty.resolveFields(pt); |
| 7018 | 7018 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 7019 | 7019 | const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| ... | ... | @@ -7156,7 +7156,7 @@ fn zirCall( |
| 7156 | 7156 | // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only |
| 7157 | 7157 | // need to clean-up our own trace if we were passed to a non-error-handling expression. |
| 7158 | 7158 | if (input_is_error or (pop_error_return_trace and return_ty.isError(zcu))) { |
| 7159 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 7159 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 7160 | 7160 | try stack_trace_ty.resolveFields(pt); |
| 7161 | 7161 | const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "index", .no_embedded_nulls); |
| 7162 | 7162 | const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src); |
| ... | ... | @@ -10211,7 +10211,7 @@ fn finishFunc( |
| 10211 | 10211 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { |
| 10212 | 10212 | // Make sure that StackTrace's fields are resolved so that the backend can |
| 10213 | 10213 | // lower this fn type. |
| 10214 | | const unresolved_stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 10214 | const unresolved_stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 10215 | 10215 | try unresolved_stack_trace_ty.resolveFields(pt); |
| 10216 | 10216 | } |
| 10217 | 10217 | |
| ... | ... | @@ -14209,7 +14209,7 @@ fn maybeErrorUnwrap( |
| 14209 | 14209 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 14210 | 14210 | const msg_inst = try sema.resolveInst(inst_data.operand); |
| 14211 | 14211 | |
| 14212 | | const panic_fn = try pt.getBuiltinInnerType("Panic", "call"); |
| 14212 | const panic_fn = try getBuiltinInnerAsInst(sema, block, operand_src, "Panic", "call"); |
| 14213 | 14213 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 14214 | 14214 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; |
| 14215 | 14215 | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); |
| ... | ... | @@ -18246,7 +18246,7 @@ fn zirBuiltinSrc( |
| 18246 | 18246 | } }); |
| 18247 | 18247 | }; |
| 18248 | 18248 | |
| 18249 | | const src_loc_ty = try pt.getBuiltinType("SourceLocation"); |
| 18249 | const src_loc_ty = try sema.getBuiltinType("SourceLocation"); |
| 18250 | 18250 | const fields = .{ |
| 18251 | 18251 | // module: [:0]const u8, |
| 18252 | 18252 | module_name_val, |
| ... | ... | @@ -18273,7 +18273,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18273 | 18273 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 18274 | 18274 | const src = block.nodeOffset(inst_data.src_node); |
| 18275 | 18275 | const ty = try sema.resolveType(block, src, inst_data.operand); |
| 18276 | | const type_info_ty = try pt.getBuiltinType("Type"); |
| 18276 | const type_info_ty = try sema.getBuiltinType("Type"); |
| 18277 | 18277 | const type_info_tag_ty = type_info_ty.unionTagType(zcu).?; |
| 18278 | 18278 | |
| 18279 | 18279 | if (ty.typeDeclInst(zcu)) |type_decl_inst| { |
| ... | ... | @@ -18364,7 +18364,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18364 | 18364 | func_ty_info.return_type, |
| 18365 | 18365 | } }); |
| 18366 | 18366 | |
| 18367 | | const callconv_ty = try pt.getBuiltinType("CallingConvention"); |
| 18367 | const callconv_ty = try sema.getBuiltinType("CallingConvention"); |
| 18368 | 18368 | |
| 18369 | 18369 | const field_values = .{ |
| 18370 | 18370 | // calling_convention: CallingConvention, |
| ... | ... | @@ -18389,7 +18389,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18389 | 18389 | }, |
| 18390 | 18390 | .int => { |
| 18391 | 18391 | const int_info_ty = try getInnerType(sema, block, src, type_info_ty, "Int"); |
| 18392 | | const signedness_ty = try pt.getBuiltinType("Signedness"); |
| 18392 | const signedness_ty = try sema.getBuiltinType("Signedness"); |
| 18393 | 18393 | const info = ty.intInfo(zcu); |
| 18394 | 18394 | const field_values = .{ |
| 18395 | 18395 | // signedness: Signedness, |
| ... | ... | @@ -18429,7 +18429,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18429 | 18429 | else |
| 18430 | 18430 | try Type.fromInterned(info.child).lazyAbiAlignment(pt); |
| 18431 | 18431 | |
| 18432 | | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); |
| 18432 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); |
| 18433 | 18433 | const pointer_ty = try getInnerType(sema, block, src, type_info_ty, "Pointer"); |
| 18434 | 18434 | const ptr_size_ty = try getInnerType(sema, block, src, pointer_ty, "Size"); |
| 18435 | 18435 | |
| ... | ... | @@ -20047,11 +20047,11 @@ fn retWithErrTracing( |
| 20047 | 20047 | else => true, |
| 20048 | 20048 | }; |
| 20049 | 20049 | const gpa = sema.gpa; |
| 20050 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 20050 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 20051 | 20051 | try stack_trace_ty.resolveFields(pt); |
| 20052 | 20052 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 20053 | 20053 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 20054 | | const return_err_fn = try pt.getBuiltin("returnError"); |
| 20054 | const return_err_fn = try sema.getBuiltin("returnError"); |
| 20055 | 20055 | const args: [1]Air.Inst.Ref = .{err_return_trace}; |
| 20056 | 20056 | |
| 20057 | 20057 | if (!need_check) { |
| ... | ... | @@ -21455,7 +21455,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 21455 | 21455 | const pt = sema.pt; |
| 21456 | 21456 | const zcu = pt.zcu; |
| 21457 | 21457 | const ip = &zcu.intern_pool; |
| 21458 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 21458 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 21459 | 21459 | try stack_trace_ty.resolveFields(pt); |
| 21460 | 21460 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 21461 | 21461 | const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern()); |
| ... | ... | @@ -21744,7 +21744,7 @@ fn zirReify( |
| 21744 | 21744 | }, |
| 21745 | 21745 | }, |
| 21746 | 21746 | }; |
| 21747 | | const type_info_ty = try pt.getBuiltinType("Type"); |
| 21747 | const type_info_ty = try sema.getBuiltinType("Type"); |
| 21748 | 21748 | const uncasted_operand = try sema.resolveInst(extra.operand); |
| 21749 | 21749 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); |
| 21750 | 21750 | const val = try sema.resolveConstDefinedValue(block, operand_src, type_info, .{ |
| ... | ... | @@ -22946,7 +22946,7 @@ fn reifyStruct( |
| 22946 | 22946 | |
| 22947 | 22947 | fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref { |
| 22948 | 22948 | const pt = sema.pt; |
| 22949 | | const va_list_ty = try pt.getBuiltinType("VaList"); |
| 22949 | const va_list_ty = try sema.getBuiltinType("VaList"); |
| 22950 | 22950 | const va_list_ptr = try pt.singleMutPtrType(va_list_ty); |
| 22951 | 22951 | |
| 22952 | 22952 | const inst = try sema.resolveInst(zir_ref); |
| ... | ... | @@ -22985,7 +22985,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) |
| 22985 | 22985 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); |
| 22986 | 22986 | |
| 22987 | 22987 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand); |
| 22988 | | const va_list_ty = try sema.pt.getBuiltinType("VaList"); |
| 22988 | const va_list_ty = try sema.getBuiltinType("VaList"); |
| 22989 | 22989 | |
| 22990 | 22990 | try sema.requireRuntimeBlock(block, src, null); |
| 22991 | 22991 | return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref); |
| ... | ... | @@ -23005,7 +23005,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 23005 | 23005 | fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 23006 | 23006 | const src = block.nodeOffset(@bitCast(extended.operand)); |
| 23007 | 23007 | |
| 23008 | | const va_list_ty = try sema.pt.getBuiltinType("VaList"); |
| 23008 | const va_list_ty = try sema.getBuiltinType("VaList"); |
| 23009 | 23009 | try sema.requireRuntimeBlock(block, src, null); |
| 23010 | 23010 | return block.addInst(.{ |
| 23011 | 23011 | .tag = .c_va_start, |
| ... | ... | @@ -24617,7 +24617,7 @@ fn resolveExportOptions( |
| 24617 | 24617 | const zcu = pt.zcu; |
| 24618 | 24618 | const gpa = sema.gpa; |
| 24619 | 24619 | const ip = &zcu.intern_pool; |
| 24620 | | const export_options_ty = try pt.getBuiltinType("ExportOptions"); |
| 24620 | const export_options_ty = try sema.getBuiltinType("ExportOptions"); |
| 24621 | 24621 | const air_ref = try sema.resolveInst(zir_ref); |
| 24622 | 24622 | const options = try sema.coerce(block, export_options_ty, air_ref, src); |
| 24623 | 24623 | |
| ... | ... | @@ -24681,7 +24681,7 @@ fn resolveBuiltinEnum( |
| 24681 | 24681 | reason: NeededComptimeReason, |
| 24682 | 24682 | ) CompileError!@field(std.builtin, name) { |
| 24683 | 24683 | const pt = sema.pt; |
| 24684 | | const ty = try pt.getBuiltinType(name); |
| 24684 | const ty = try sema.getBuiltinType(name); |
| 24685 | 24685 | const air_ref = try sema.resolveInst(zir_ref); |
| 24686 | 24686 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 24687 | 24687 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| ... | ... | @@ -25450,7 +25450,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 25450 | 25450 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 25451 | 25451 | const func = try sema.resolveInst(extra.callee); |
| 25452 | 25452 | |
| 25453 | | const modifier_ty = try pt.getBuiltinType("CallModifier"); |
| 25453 | const modifier_ty = try sema.getBuiltinType("CallModifier"); |
| 25454 | 25454 | const air_ref = try sema.resolveInst(extra.modifier); |
| 25455 | 25455 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); |
| 25456 | 25456 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ |
| ... | ... | @@ -26576,7 +26576,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26576 | 26576 | const body = sema.code.bodySlice(extra_index, body_len); |
| 26577 | 26577 | extra_index += body.len; |
| 26578 | 26578 | |
| 26579 | | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); |
| 26579 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); |
| 26580 | 26580 | const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, .{ |
| 26581 | 26581 | .needed_comptime_reason = "addrspace must be comptime-known", |
| 26582 | 26582 | }); |
| ... | ... | @@ -26587,7 +26587,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26587 | 26587 | } else if (extra.data.bits.has_addrspace_ref) blk: { |
| 26588 | 26588 | const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 26589 | 26589 | extra_index += 1; |
| 26590 | | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); |
| 26590 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); |
| 26591 | 26591 | const uncoerced_addrspace = sema.resolveInst(addrspace_ref) catch |err| switch (err) { |
| 26592 | 26592 | error.GenericPoison => break :blk null, |
| 26593 | 26593 | else => |e| return e, |
| ... | ... | @@ -26641,7 +26641,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26641 | 26641 | const body = sema.code.bodySlice(extra_index, body_len); |
| 26642 | 26642 | extra_index += body.len; |
| 26643 | 26643 | |
| 26644 | | const cc_ty = try pt.getBuiltinType("CallingConvention"); |
| 26644 | const cc_ty = try sema.getBuiltinType("CallingConvention"); |
| 26645 | 26645 | const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ |
| 26646 | 26646 | .needed_comptime_reason = "calling convention must be comptime-known", |
| 26647 | 26647 | }); |
| ... | ... | @@ -26652,7 +26652,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26652 | 26652 | } else if (extra.data.bits.has_cc_ref) blk: { |
| 26653 | 26653 | const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 26654 | 26654 | extra_index += 1; |
| 26655 | | const cc_ty = try pt.getBuiltinType("CallingConvention"); |
| 26655 | const cc_ty = try sema.getBuiltinType("CallingConvention"); |
| 26656 | 26656 | const uncoerced_cc = sema.resolveInst(cc_ref) catch |err| switch (err) { |
| 26657 | 26657 | error.GenericPoison => break :blk null, |
| 26658 | 26658 | else => |e| return e, |
| ... | ... | @@ -26869,7 +26869,7 @@ fn resolvePrefetchOptions( |
| 26869 | 26869 | const zcu = pt.zcu; |
| 26870 | 26870 | const gpa = sema.gpa; |
| 26871 | 26871 | const ip = &zcu.intern_pool; |
| 26872 | | const options_ty = try pt.getBuiltinType("PrefetchOptions"); |
| 26872 | const options_ty = try sema.getBuiltinType("PrefetchOptions"); |
| 26873 | 26873 | const options = try sema.coerce(block, options_ty, try sema.resolveInst(zir_ref), src); |
| 26874 | 26874 | |
| 26875 | 26875 | const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | ... | @@ -26942,7 +26942,7 @@ fn resolveExternOptions( |
| 26942 | 26942 | const gpa = sema.gpa; |
| 26943 | 26943 | const ip = &zcu.intern_pool; |
| 26944 | 26944 | const options_inst = try sema.resolveInst(zir_ref); |
| 26945 | | const extern_options_ty = try pt.getBuiltinType("ExternOptions"); |
| 26945 | const extern_options_ty = try sema.getBuiltinType("ExternOptions"); |
| 26946 | 26946 | const options = try sema.coerce(block, extern_options_ty, options_inst, src); |
| 26947 | 26947 | |
| 26948 | 26948 | const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | ... | @@ -27129,7 +27129,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr |
| 27129 | 27129 | |
| 27130 | 27130 | // Values are handled here. |
| 27131 | 27131 | .calling_convention_c => { |
| 27132 | | const callconv_ty = try pt.getBuiltinType("CallingConvention"); |
| 27132 | const callconv_ty = try sema.getBuiltinType("CallingConvention"); |
| 27133 | 27133 | comptime assert(@intFromEnum(std.builtin.CallingConvention.C) == 1); |
| 27134 | 27134 | const val = try pt.intern(.{ .enum_tag = .{ |
| 27135 | 27135 | .ty = callconv_ty.toIntern(), |
| ... | ... | @@ -27138,7 +27138,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr |
| 27138 | 27138 | return Air.internedToRef(val); |
| 27139 | 27139 | }, |
| 27140 | 27140 | .calling_convention_inline => { |
| 27141 | | const callconv_ty = try pt.getBuiltinType("CallingConvention"); |
| 27141 | const callconv_ty = try sema.getBuiltinType("CallingConvention"); |
| 27142 | 27142 | comptime assert(@intFromEnum(std.builtin.CallingConvention.Inline) == 4); |
| 27143 | 27143 | const val = try pt.intern(.{ .enum_tag = .{ |
| 27144 | 27144 | .ty = callconv_ty.toIntern(), |
| ... | ... | @@ -27147,7 +27147,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr |
| 27147 | 27147 | return Air.internedToRef(val); |
| 27148 | 27148 | }, |
| 27149 | 27149 | }; |
| 27150 | | const ty = try pt.getBuiltinType(type_name); |
| 27150 | const ty = try sema.getBuiltinType(type_name); |
| 27151 | 27151 | return Air.internedToRef(ty.toIntern()); |
| 27152 | 27152 | } |
| 27153 | 27153 | |
| ... | ... | @@ -27186,7 +27186,7 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 27186 | 27186 | const uncoerced_hint = try sema.resolveInst(extra.operand); |
| 27187 | 27187 | const operand_src = block.builtinCallArgSrc(extra.node, 0); |
| 27188 | 27188 | |
| 27189 | | const hint_ty = try pt.getBuiltinType("BranchHint"); |
| 27189 | const hint_ty = try sema.getBuiltinType("BranchHint"); |
| 27190 | 27190 | const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src); |
| 27191 | 27191 | const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{ |
| 27192 | 27192 | .needed_comptime_reason = "operand to '@branchHint' must be comptime-known", |
| ... | ... | @@ -27650,7 +27650,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 27650 | 27650 | } |
| 27651 | 27651 | |
| 27652 | 27652 | if (zcu.null_stack_trace == .none) { |
| 27653 | | const stack_trace_ty = try pt.getBuiltinType("StackTrace"); |
| 27653 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 27654 | 27654 | try stack_trace_ty.resolveFields(pt); |
| 27655 | 27655 | const target = zcu.getTarget(); |
| 27656 | 27656 | const ptr_stack_trace_ty = try pt.ptrTypeSema(.{ |
| ... | ... | @@ -27678,7 +27678,7 @@ fn preparePanicId(sema: *Sema, block: *Block, src: LazySrcLoc, panic_id: Zcu.Pan |
| 27678 | 27678 | |
| 27679 | 27679 | try sema.prepareSimplePanic(block, src); |
| 27680 | 27680 | |
| 27681 | | const panic_messages_ty = try pt.getBuiltinType("panic_messages"); |
| 27681 | const panic_messages_ty = try sema.getBuiltinType("panic_messages"); |
| 27682 | 27682 | const msg_nav_index = (sema.namespaceLookup( |
| 27683 | 27683 | block, |
| 27684 | 27684 | LazySrcLoc.unneeded, |
| ... | ... | @@ -27846,7 +27846,7 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air. |
| 27846 | 27846 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 27847 | 27847 | _ = try block.addNoOp(.trap); |
| 27848 | 27848 | } else { |
| 27849 | | const panic_fn = try pt.getBuiltinInnerType("Panic", "unwrapError"); |
| 27849 | const panic_fn = try getBuiltinInnerAsInst(sema, block, src, "Panic", "unwrapError"); |
| 27850 | 27850 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 27851 | 27851 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; |
| 27852 | 27852 | try sema.callBuiltin(block, src, panic_fn, .auto, &args, .@"safety check"); |
| ... | ... | @@ -27950,7 +27950,7 @@ fn addSafetyCheckCall( |
| 27950 | 27950 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 27951 | 27951 | _ = try fail_block.addNoOp(.trap); |
| 27952 | 27952 | } else { |
| 27953 | | const panic_fn = try pt.getBuiltinInnerType("Panic", func_name); |
| 27953 | const panic_fn = try getBuiltinInnerAsInst(sema, &fail_block, src, "Panic", func_name); |
| 27954 | 27954 | try sema.callBuiltin(&fail_block, src, panic_fn, .auto, args, .@"safety check"); |
| 27955 | 27955 | } |
| 27956 | 27956 | |
| ... | ... | @@ -35604,7 +35604,7 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void { |
| 35604 | 35604 | Type.fromInterned(fn_ty_info.return_type).isError(zcu)) |
| 35605 | 35605 | { |
| 35606 | 35606 | // Ensure the type exists so that backends can assume that. |
| 35607 | | _ = try pt.getBuiltinType("StackTrace"); |
| 35607 | _ = try sema.getBuiltinType("StackTrace"); |
| 35608 | 35608 | } |
| 35609 | 35609 | |
| 35610 | 35610 | for (0..fn_ty_info.param_types.len) |i| { |
| ... | ... | @@ -37650,7 +37650,7 @@ pub fn analyzeAsAddressSpace( |
| 37650 | 37650 | ) !std.builtin.AddressSpace { |
| 37651 | 37651 | const pt = sema.pt; |
| 37652 | 37652 | const zcu = pt.zcu; |
| 37653 | | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); |
| 37653 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); |
| 37654 | 37654 | const coerced = try sema.coerce(block, addrspace_ty, air_ref, src); |
| 37655 | 37655 | const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ |
| 37656 | 37656 | .needed_comptime_reason = "address space must be comptime-known", |
| ... | ... | @@ -38908,6 +38908,19 @@ const ComptimeLoadResult = @import("Sema/comptime_ptr_access.zig").ComptimeLoadR |
| 38908 | 38908 | const storeComptimePtr = @import("Sema/comptime_ptr_access.zig").storeComptimePtr; |
| 38909 | 38909 | const ComptimeStoreResult = @import("Sema/comptime_ptr_access.zig").ComptimeStoreResult; |
| 38910 | 38910 | |
| 38911 | /// Convenience function that looks 2 levels deep into `std.builtin`. |
| 38912 | fn getBuiltinInnerAsInst( |
| 38913 | sema: *Sema, |
| 38914 | block: *Block, |
| 38915 | src: LazySrcLoc, |
| 38916 | outer_name: []const u8, |
| 38917 | inner_name: []const u8, |
| 38918 | ) !Air.Inst.Ref { |
| 38919 | const outer_ty = try sema.getBuiltinType(outer_name); |
| 38920 | const inner_val = try getInnerValue(sema, block, src, outer_ty, inner_name); |
| 38921 | return Air.internedToRef(inner_val.toIntern()); |
| 38922 | } |
| 38923 | |
| 38911 | 38924 | /// Convenience function that looks 2 levels deep into `std.builtin`. |
| 38912 | 38925 | fn getBuiltinInnerType( |
| 38913 | 38926 | sema: *Sema, |
| ... | ... | @@ -38916,7 +38929,7 @@ fn getBuiltinInnerType( |
| 38916 | 38929 | outer_name: []const u8, |
| 38917 | 38930 | inner_name: []const u8, |
| 38918 | 38931 | ) !Type { |
| 38919 | | const outer_ty = try sema.pt.getBuiltinType(outer_name); |
| 38932 | const outer_ty = try sema.getBuiltinType(outer_name); |
| 38920 | 38933 | return getInnerType(sema, block, src, outer_ty, inner_name); |
| 38921 | 38934 | } |
| 38922 | 38935 | |
| ... | ... | @@ -38927,6 +38940,17 @@ fn getInnerType( |
| 38927 | 38940 | outer_ty: Type, |
| 38928 | 38941 | inner_name: []const u8, |
| 38929 | 38942 | ) !Type { |
| 38943 | const inner_val = try getInnerValue(sema, block, src, outer_ty, inner_name); |
| 38944 | return inner_val.toType(); |
| 38945 | } |
| 38946 | |
| 38947 | fn getInnerValue( |
| 38948 | sema: *Sema, |
| 38949 | block: *Block, |
| 38950 | src: LazySrcLoc, |
| 38951 | outer_ty: Type, |
| 38952 | inner_name: []const u8, |
| 38953 | ) !Value { |
| 38930 | 38954 | const pt = sema.pt; |
| 38931 | 38955 | const zcu = pt.zcu; |
| 38932 | 38956 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -38938,5 +38962,22 @@ fn getInnerType( |
| 38938 | 38962 | try ip.getOrPutString(gpa, pt.tid, inner_name, .no_embedded_nulls), |
| 38939 | 38963 | ) orelse return sema.fail(block, src, "std.builtin missing {s}", .{inner_name}); |
| 38940 | 38964 | try sema.ensureNavResolved(src, nav); |
| 38941 | | return Type.fromInterned(ip.getNav(nav).status.resolved.val); |
| 38965 | return Value.fromInterned(ip.getNav(nav).status.resolved.val); |
| 38966 | } |
| 38967 | |
| 38968 | fn getBuiltin(sema: *Sema, name: []const u8) SemaError!Air.Inst.Ref { |
| 38969 | const pt = sema.pt; |
| 38970 | const zcu = pt.zcu; |
| 38971 | const ip = &zcu.intern_pool; |
| 38972 | const nav = try pt.getBuiltinNav(name); |
| 38973 | try pt.ensureCauAnalyzed(ip.getNav(nav).analysis_owner.unwrap().?); |
| 38974 | return Air.internedToRef(ip.getNav(nav).status.resolved.val); |
| 38975 | } |
| 38976 | |
| 38977 | fn getBuiltinType(sema: *Sema, name: []const u8) SemaError!Type { |
| 38978 | const pt = sema.pt; |
| 38979 | const ty_inst = try sema.getBuiltin(name); |
| 38980 | const ty = Type.fromInterned(ty_inst.toInterned() orelse @panic("std.builtin is corrupt")); |
| 38981 | try ty.resolveFully(pt); |
| 38982 | return ty; |
| 38942 | 38983 | } |