| ... | ... | @@ -1473,7 +1473,7 @@ fn analyzeBodyInner( |
| 1473 | 1473 | }, |
| 1474 | 1474 | .value_placeholder => unreachable, // never appears in a body |
| 1475 | 1475 | .field_parent_ptr => try sema.zirFieldParentPtr(block, extended), |
| 1476 | | .builtin_value => try sema.zirBuiltinValue(block, extended), |
| 1476 | .std_lang_value => try sema.zirStdLangValue(block, extended), |
| 1477 | 1477 | .inplace_arith_result_ty => try sema.zirInplaceArithResultTy(extended), |
| 1478 | 1478 | .dbg_empty_stmt => { |
| 1479 | 1479 | try sema.zirDbgEmptyStmt(block, inst); |
| ... | ... | @@ -2225,7 +2225,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) |
| 2225 | 2225 | const addrs_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(addr_arr_ty)); |
| 2226 | 2226 | |
| 2227 | 2227 | // var st: StackTrace = undefined; |
| 2228 | | const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace); |
| 2228 | const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace); |
| 2229 | 2229 | const st_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(stack_trace_ty)); |
| 2230 | 2230 | |
| 2231 | 2231 | // st.instruction_addresses = &addrs; |
| ... | ... | @@ -2805,10 +2805,10 @@ fn analyzeValueAsCallconv( |
| 2805 | 2805 | src: LazySrcLoc, |
| 2806 | 2806 | val: Value, |
| 2807 | 2807 | ) !std.builtin.CallingConvention { |
| 2808 | | return interpretBuiltinType(sema, block, src, val, std.builtin.CallingConvention); |
| 2808 | return interpretStdLangType(sema, block, src, val, std.builtin.CallingConvention); |
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | | fn interpretBuiltinType( |
| 2811 | fn interpretStdLangType( |
| 2812 | 2812 | sema: *Sema, |
| 2813 | 2813 | block: *Block, |
| 2814 | 2814 | src: LazySrcLoc, |
| ... | ... | @@ -2818,7 +2818,7 @@ fn interpretBuiltinType( |
| 2818 | 2818 | return val.interpret(T, sema.pt) catch |err| switch (err) { |
| 2819 | 2819 | error.OutOfMemory => |e| return e, |
| 2820 | 2820 | error.UndefinedValue => return sema.failWithUseOfUndef(block, src, null), |
| 2821 | | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| 2821 | error.TypeMismatch => @panic("std.lang is corrupt"), |
| 2822 | 2822 | }; |
| 2823 | 2823 | } |
| 2824 | 2824 | |
| ... | ... | @@ -5074,7 +5074,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 5074 | 5074 | } |
| 5075 | 5075 | |
| 5076 | 5076 | try sema.ensureMemoizedStateResolved(src, .panic); |
| 5077 | | const panic_fn_index = zcu.builtin_decl_values.get(.@"panic.call"); |
| 5077 | const panic_fn_index = zcu.std_lang_decl_values.get(.@"panic.call"); |
| 5078 | 5078 | const opt_usize_ty = try pt.optionalType(.usize_type); |
| 5079 | 5079 | const null_ret_addr = Air.internedToRef((try pt.intern(.{ .opt = .{ |
| 5080 | 5080 | .ty = opt_usize_ty.toIntern(), |
| ... | ... | @@ -5692,7 +5692,7 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void { |
| 5692 | 5692 | fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void { |
| 5693 | 5693 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 5694 | 5694 | const src = block.builtinCallArgSrc(extra.node, 0); |
| 5695 | | block.float_mode = try sema.resolveBuiltinEnum(block, src, extra.operand, .FloatMode, .{ .simple = .operand_setFloatMode }); |
| 5695 | block.float_mode = try sema.resolveStdLangEnum(block, src, extra.operand, .FloatMode, .{ .simple = .operand_setFloatMode }); |
| 5696 | 5696 | } |
| 5697 | 5697 | |
| 5698 | 5698 | fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| ... | ... | @@ -6008,10 +6008,10 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 6008 | 6008 | |
| 6009 | 6009 | if (!block.ownerModule().error_tracing) return .none; |
| 6010 | 6010 | |
| 6011 | | const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace); |
| 6011 | const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace); |
| 6012 | 6012 | const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls); |
| 6013 | 6013 | const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) { |
| 6014 | | error.AnalysisFail => @panic("std.builtin.StackTrace is corrupt"), |
| 6014 | error.AnalysisFail => @panic("std.lang.StackTrace is corrupt"), |
| 6015 | 6015 | error.ComptimeReturn, error.ComptimeBreak => unreachable, |
| 6016 | 6016 | error.OutOfMemory, error.Canceled => |e| return e, |
| 6017 | 6017 | }; |
| ... | ... | @@ -6051,7 +6051,7 @@ fn popErrorReturnTrace( |
| 6051 | 6051 | // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or |
| 6052 | 6052 | // the result is comptime-known to be a non-error. Either way, pop unconditionally. |
| 6053 | 6053 | |
| 6054 | | const stack_trace_ty = try sema.getBuiltinType(src, .StackTrace); |
| 6054 | const stack_trace_ty = try sema.getStdLangType(src, .StackTrace); |
| 6055 | 6055 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 6056 | 6056 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 6057 | 6057 | const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls); |
| ... | ... | @@ -6076,7 +6076,7 @@ fn popErrorReturnTrace( |
| 6076 | 6076 | defer then_block.instructions.deinit(gpa); |
| 6077 | 6077 | |
| 6078 | 6078 | // If non-error, then pop the error return trace by restoring the index. |
| 6079 | | const stack_trace_ty = try sema.getBuiltinType(src, .StackTrace); |
| 6079 | const stack_trace_ty = try sema.getStdLangType(src, .StackTrace); |
| 6080 | 6080 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 6081 | 6081 | const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty); |
| 6082 | 6082 | const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls); |
| ... | ... | @@ -6215,7 +6215,7 @@ fn zirCall( |
| 6215 | 6215 | // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only |
| 6216 | 6216 | // need to clean-up our own trace if we were passed to a non-error-handling expression. |
| 6217 | 6217 | if (input_is_error or (pop_error_return_trace and return_ty.isError(zcu))) { |
| 6218 | | const stack_trace_ty = try sema.getBuiltinType(call_src, .StackTrace); |
| 6218 | const stack_trace_ty = try sema.getStdLangType(call_src, .StackTrace); |
| 6219 | 6219 | const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls); |
| 6220 | 6220 | const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src); |
| 6221 | 6221 | |
| ... | ... | @@ -8377,10 +8377,10 @@ fn zirFunc( |
| 8377 | 8377 | if (fn_is_exported) { |
| 8378 | 8378 | break :cc target.cCallingConvention() orelse { |
| 8379 | 8379 | // This target has no default C calling convention. We sometimes trigger a similar |
| 8380 | | // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency, |
| 8380 | // error by trying to evaluate `std.lang.CallingConvention.c`, so for consistency, |
| 8381 | 8381 | // let's eval that now and just get the transitive error. (It's guaranteed to error |
| 8382 | 8382 | // because it does the exact `cCallingConvention` call we just did.) |
| 8383 | | const cc_type = try sema.getBuiltinType(src, .CallingConvention); |
| 8383 | const cc_type = try sema.getStdLangType(src, .CallingConvention); |
| 8384 | 8384 | _ = try sema.namespaceLookupVal( |
| 8385 | 8385 | block, |
| 8386 | 8386 | LazySrcLoc.unneeded, |
| ... | ... | @@ -8388,7 +8388,7 @@ fn zirFunc( |
| 8388 | 8388 | try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls), |
| 8389 | 8389 | ); |
| 8390 | 8390 | // The above should have errored. |
| 8391 | | @panic("std.builtin is corrupt"); |
| 8391 | @panic("std.lang is corrupt"); |
| 8392 | 8392 | }; |
| 8393 | 8393 | } else { |
| 8394 | 8394 | break :cc .auto; |
| ... | ... | @@ -12711,7 +12711,7 @@ fn maybeErrorUnwrap( |
| 12711 | 12711 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 12712 | 12712 | const msg_inst = sema.resolveInst(inst_data.operand); |
| 12713 | 12713 | |
| 12714 | | const panic_fn = try getBuiltin(sema, operand_src, .@"panic.call"); |
| 12714 | const panic_fn = try getStdLangValue(sema, operand_src, .@"panic.call"); |
| 12715 | 12715 | const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value }; |
| 12716 | 12716 | try sema.callBuiltin(block, operand_src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check"); |
| 12717 | 12717 | return true; |
| ... | ... | @@ -15319,7 +15319,7 @@ fn zirAsm( |
| 15319 | 15319 | } |
| 15320 | 15320 | |
| 15321 | 15321 | const clobbers_src = block.src(.{ .asm_clobbers = src.offset.node_offset.x }); |
| 15322 | | const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers"); |
| 15322 | const clobbers_ty = try sema.getStdLangType(src, .@"assembly.Clobbers"); |
| 15323 | 15323 | const clobbers = if (extra.data.clobbers == .none) empty: { |
| 15324 | 15324 | break :empty try sema.structInitEmpty(block, clobbers_ty, src, src); |
| 15325 | 15325 | } else clobbers: { |
| ... | ... | @@ -15930,7 +15930,7 @@ fn zirBuiltinSrc( |
| 15930 | 15930 | } }); |
| 15931 | 15931 | }; |
| 15932 | 15932 | |
| 15933 | | const src_loc_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .SourceLocation); |
| 15933 | const src_loc_ty = try sema.getStdLangType(block.nodeOffset(.zero), .SourceLocation); |
| 15934 | 15934 | const fields = .{ |
| 15935 | 15935 | // module: [:0]const u8, |
| 15936 | 15936 | module_name_val, |
| ... | ... | @@ -15957,7 +15957,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15957 | 15957 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 15958 | 15958 | const src = block.nodeOffset(inst_data.src_node); |
| 15959 | 15959 | const ty = try sema.resolveType(block, src, inst_data.operand); |
| 15960 | | const type_info_ty = try sema.getBuiltinType(src, .Type); |
| 15960 | const type_info_ty = try sema.getStdLangType(src, .Type); |
| 15961 | 15961 | const type_info_tag_ty = type_info_ty.unionTagType(zcu).?; |
| 15962 | 15962 | |
| 15963 | 15963 | try sema.ensureLayoutResolved(ty, src, .type_info); |
| ... | ... | @@ -15979,15 +15979,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15979 | 15979 | => |type_info_tag| return .fromValue(try pt.unionValue( |
| 15980 | 15980 | type_info_ty, |
| 15981 | 15981 | Value.uninterpret(type_info_tag, type_info_tag_ty, pt) catch |err| switch (err) { |
| 15982 | | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| 15982 | error.TypeMismatch => @panic("std.lang is corrupt"), |
| 15983 | 15983 | error.OutOfMemory => |e| return e, |
| 15984 | 15984 | }, |
| 15985 | 15985 | .void, |
| 15986 | 15986 | )), |
| 15987 | 15987 | |
| 15988 | 15988 | .@"fn" => { |
| 15989 | | const fn_info_ty = try sema.getBuiltinType(src, .@"Type.Fn"); |
| 15990 | | const param_info_ty = try sema.getBuiltinType(src, .@"Type.Fn.Param"); |
| 15989 | const fn_info_ty = try sema.getStdLangType(src, .@"Type.Fn"); |
| 15990 | const param_info_ty = try sema.getStdLangType(src, .@"Type.Fn.Param"); |
| 15991 | 15991 | |
| 15992 | 15992 | const func_ty_info = zcu.typeToFunc(ty).?; |
| 15993 | 15993 | const param_vals = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len); |
| ... | ... | @@ -16068,9 +16068,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16068 | 16068 | .val = if (ret_ty_is_generic) .none else func_ty_info.return_type, |
| 16069 | 16069 | } }); |
| 16070 | 16070 | |
| 16071 | | const callconv_ty = try sema.getBuiltinType(src, .CallingConvention); |
| 16071 | const callconv_ty = try sema.getStdLangType(src, .CallingConvention); |
| 16072 | 16072 | const callconv_val = Value.uninterpret(func_ty_info.cc, callconv_ty, pt) catch |err| switch (err) { |
| 16073 | | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| 16073 | error.TypeMismatch => @panic("std.lang is corrupt"), |
| 16074 | 16074 | error.OutOfMemory => |e| return e, |
| 16075 | 16075 | }; |
| 16076 | 16076 | |
| ... | ... | @@ -16093,8 +16093,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16093 | 16093 | }))); |
| 16094 | 16094 | }, |
| 16095 | 16095 | .int => { |
| 16096 | | const int_info_ty = try sema.getBuiltinType(src, .@"Type.Int"); |
| 16097 | | const signedness_ty = try sema.getBuiltinType(src, .Signedness); |
| 16096 | const int_info_ty = try sema.getStdLangType(src, .@"Type.Int"); |
| 16097 | const signedness_ty = try sema.getStdLangType(src, .Signedness); |
| 16098 | 16098 | const info = ty.intInfo(zcu); |
| 16099 | 16099 | const field_values = .{ |
| 16100 | 16100 | // signedness: Signedness, |
| ... | ... | @@ -16109,7 +16109,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16109 | 16109 | }))); |
| 16110 | 16110 | }, |
| 16111 | 16111 | .float => { |
| 16112 | | const float_info_ty = try sema.getBuiltinType(src, .@"Type.Float"); |
| 16112 | const float_info_ty = try sema.getStdLangType(src, .@"Type.Float"); |
| 16113 | 16113 | |
| 16114 | 16114 | const field_vals = .{ |
| 16115 | 16115 | // bits: u16, |
| ... | ... | @@ -16135,9 +16135,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16135 | 16135 | } })); |
| 16136 | 16136 | }; |
| 16137 | 16137 | |
| 16138 | | const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace); |
| 16139 | | const pointer_ty = try sema.getBuiltinType(src, .@"Type.Pointer"); |
| 16140 | | const ptr_size_ty = try sema.getBuiltinType(src, .@"Type.Pointer.Size"); |
| 16138 | const addrspace_ty = try sema.getStdLangType(src, .AddressSpace); |
| 16139 | const pointer_ty = try sema.getStdLangType(src, .@"Type.Pointer"); |
| 16140 | const ptr_size_ty = try sema.getStdLangType(src, .@"Type.Pointer.Size"); |
| 16141 | 16141 | |
| 16142 | 16142 | const field_values = .{ |
| 16143 | 16143 | // size: Size, |
| ... | ... | @@ -16167,7 +16167,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16167 | 16167 | }))); |
| 16168 | 16168 | }, |
| 16169 | 16169 | .array => { |
| 16170 | | const array_field_ty = try sema.getBuiltinType(src, .@"Type.Array"); |
| 16170 | const array_field_ty = try sema.getStdLangType(src, .@"Type.Array"); |
| 16171 | 16171 | |
| 16172 | 16172 | const info = ty.arrayInfo(zcu); |
| 16173 | 16173 | const field_values = .{ |
| ... | ... | @@ -16185,7 +16185,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16185 | 16185 | }))); |
| 16186 | 16186 | }, |
| 16187 | 16187 | .vector => { |
| 16188 | | const vector_field_ty = try sema.getBuiltinType(src, .@"Type.Vector"); |
| 16188 | const vector_field_ty = try sema.getStdLangType(src, .@"Type.Vector"); |
| 16189 | 16189 | |
| 16190 | 16190 | const info = ty.arrayInfo(zcu); |
| 16191 | 16191 | const field_values = .{ |
| ... | ... | @@ -16201,7 +16201,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16201 | 16201 | }))); |
| 16202 | 16202 | }, |
| 16203 | 16203 | .optional => { |
| 16204 | | const optional_field_ty = try sema.getBuiltinType(src, .@"Type.Optional"); |
| 16204 | const optional_field_ty = try sema.getStdLangType(src, .@"Type.Optional"); |
| 16205 | 16205 | |
| 16206 | 16206 | const field_values = .{ |
| 16207 | 16207 | // child: type, |
| ... | ... | @@ -16215,7 +16215,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16215 | 16215 | }, |
| 16216 | 16216 | .error_set => { |
| 16217 | 16217 | // Get the Error type |
| 16218 | | const error_field_ty = try sema.getBuiltinType(src, .@"Type.Error"); |
| 16218 | const error_field_ty = try sema.getStdLangType(src, .@"Type.Error"); |
| 16219 | 16219 | |
| 16220 | 16220 | // Build our list of Error values |
| 16221 | 16221 | // Optional value is only null if anyerror |
| ... | ... | @@ -16305,7 +16305,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16305 | 16305 | }))); |
| 16306 | 16306 | }, |
| 16307 | 16307 | .error_union => { |
| 16308 | | const error_union_field_ty = try sema.getBuiltinType(src, .@"Type.ErrorUnion"); |
| 16308 | const error_union_field_ty = try sema.getStdLangType(src, .@"Type.ErrorUnion"); |
| 16309 | 16309 | |
| 16310 | 16310 | const field_values = .{ |
| 16311 | 16311 | // error_set: type, |
| ... | ... | @@ -16323,7 +16323,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16323 | 16323 | const enum_obj = ip.loadEnumType(ty.toIntern()); |
| 16324 | 16324 | const is_exhaustive: Value = .makeBool(!enum_obj.nonexhaustive); |
| 16325 | 16325 | |
| 16326 | | const enum_field_ty = try sema.getBuiltinType(src, .@"Type.EnumField"); |
| 16326 | const enum_field_ty = try sema.getStdLangType(src, .@"Type.EnumField"); |
| 16327 | 16327 | |
| 16328 | 16328 | const enum_field_vals = try sema.arena.alloc(InternPool.Index, enum_obj.field_names.len); |
| 16329 | 16329 | for (enum_field_vals, 0..) |*field_val, tag_index| { |
| ... | ... | @@ -16404,7 +16404,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16404 | 16404 | |
| 16405 | 16405 | const decls_val = try sema.typeInfoDecls(src, ip.loadEnumType(ty.toIntern()).namespace.toOptional()); |
| 16406 | 16406 | |
| 16407 | | const type_enum_ty = try sema.getBuiltinType(src, .@"Type.Enum"); |
| 16407 | const type_enum_ty = try sema.getStdLangType(src, .@"Type.Enum"); |
| 16408 | 16408 | |
| 16409 | 16409 | const field_values = .{ |
| 16410 | 16410 | // tag_type: type, |
| ... | ... | @@ -16423,8 +16423,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16423 | 16423 | }))); |
| 16424 | 16424 | }, |
| 16425 | 16425 | .@"union" => { |
| 16426 | | const type_union_ty = try sema.getBuiltinType(src, .@"Type.Union"); |
| 16427 | | const union_field_ty = try sema.getBuiltinType(src, .@"Type.UnionField"); |
| 16426 | const type_union_ty = try sema.getStdLangType(src, .@"Type.Union"); |
| 16427 | const union_field_ty = try sema.getStdLangType(src, .@"Type.UnionField"); |
| 16428 | 16428 | |
| 16429 | 16429 | const union_obj = ip.loadUnionType(ty.toIntern()); |
| 16430 | 16430 | const enum_obj = ip.loadEnumType(union_obj.enum_tag_type); |
| ... | ... | @@ -16524,7 +16524,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16524 | 16524 | .val = if (ty.unionTagType(zcu)) |tag_ty| tag_ty.toIntern() else .none, |
| 16525 | 16525 | } }); |
| 16526 | 16526 | |
| 16527 | | const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout"); |
| 16527 | const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout"); |
| 16528 | 16528 | |
| 16529 | 16529 | const field_values = .{ |
| 16530 | 16530 | // layout: ContainerLayout, |
| ... | ... | @@ -16544,8 +16544,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16544 | 16544 | }))); |
| 16545 | 16545 | }, |
| 16546 | 16546 | .@"struct" => { |
| 16547 | | const type_struct_ty = try sema.getBuiltinType(src, .@"Type.Struct"); |
| 16548 | | const struct_field_ty = try sema.getBuiltinType(src, .@"Type.StructField"); |
| 16547 | const type_struct_ty = try sema.getStdLangType(src, .@"Type.Struct"); |
| 16548 | const struct_field_ty = try sema.getStdLangType(src, .@"Type.StructField"); |
| 16549 | 16549 | |
| 16550 | 16550 | var struct_field_vals: []InternPool.Index = &.{}; |
| 16551 | 16551 | defer gpa.free(struct_field_vals); |
| ... | ... | @@ -16713,7 +16713,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16713 | 16713 | } else .none, |
| 16714 | 16714 | } }); |
| 16715 | 16715 | |
| 16716 | | const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout"); |
| 16716 | const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout"); |
| 16717 | 16717 | |
| 16718 | 16718 | const layout = ty.containerLayout(zcu); |
| 16719 | 16719 | |
| ... | ... | @@ -16736,7 +16736,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16736 | 16736 | }))); |
| 16737 | 16737 | }, |
| 16738 | 16738 | .@"opaque" => { |
| 16739 | | const type_opaque_ty = try sema.getBuiltinType(src, .@"Type.Opaque"); |
| 16739 | const type_opaque_ty = try sema.getStdLangType(src, .@"Type.Opaque"); |
| 16740 | 16740 | |
| 16741 | 16741 | const decls_val = try sema.typeInfoDecls(src, ty.getNamespace(zcu)); |
| 16742 | 16742 | |
| ... | ... | @@ -16764,7 +16764,7 @@ fn typeInfoDecls( |
| 16764 | 16764 | const zcu = pt.zcu; |
| 16765 | 16765 | const gpa = sema.gpa; |
| 16766 | 16766 | |
| 16767 | | const declaration_ty = try sema.getBuiltinType(src, .@"Type.Declaration"); |
| 16767 | const declaration_ty = try sema.getStdLangType(src, .@"Type.Declaration"); |
| 16768 | 16768 | |
| 16769 | 16769 | var decl_vals = std.array_list.Managed(InternPool.Index).init(gpa); |
| 16770 | 16770 | defer decl_vals.deinit(); |
| ... | ... | @@ -17714,7 +17714,7 @@ fn maybePushErrorTrace( |
| 17714 | 17714 | assert(pt.zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace); |
| 17715 | 17715 | |
| 17716 | 17716 | const gpa = sema.gpa; |
| 17717 | | const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError)); |
| 17717 | const return_err_fn = Air.internedToRef(try sema.getStdLangValue(src, .returnError)); |
| 17718 | 17718 | |
| 17719 | 17719 | if (!need_check) { |
| 17720 | 17720 | try sema.callBuiltin(parent_block, src, return_err_fn, .never_tail, &.{}, .@"error return"); |
| ... | ... | @@ -19179,7 +19179,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 19179 | 19179 | const pt = sema.pt; |
| 19180 | 19180 | const zcu = pt.zcu; |
| 19181 | 19181 | const ip = &zcu.intern_pool; |
| 19182 | | const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace); |
| 19182 | const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace); |
| 19183 | 19183 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); |
| 19184 | 19184 | const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern()); |
| 19185 | 19185 | |
| ... | ... | @@ -19446,7 +19446,7 @@ fn zirReifyInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 19446 | 19446 | const signedness_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 19447 | 19447 | const bits_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| 19448 | 19448 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 19449 | | const signedness = try sema.resolveBuiltinEnum(block, signedness_src, extra.lhs, .Signedness, .{ .simple = .int_signedness }); |
| 19449 | const signedness = try sema.resolveStdLangEnum(block, signedness_src, extra.lhs, .Signedness, .{ .simple = .int_signedness }); |
| 19450 | 19450 | const bits: u16 = @intCast(try sema.resolveInt(block, bits_src, extra.rhs, .u16, .{ .simple = .int_bit_width })); |
| 19451 | 19451 | if (bits == 0 and signedness == .signed) { |
| 19452 | 19452 | return sema.fail(block, bits_src, "signed integer cannot have bit width 0", .{}); |
| ... | ... | @@ -19469,11 +19469,11 @@ fn zirReifySliceArgTy( |
| 19469 | 19469 | |
| 19470 | 19470 | const comptime_reason: std.zig.SimpleComptimeReason, const in_scalar_ty: Type, const out_scalar_ty: Type = switch (info) { |
| 19471 | 19471 | // zig fmt: off |
| 19472 | | .type_to_fn_param_attrs => .{ .fn_param_attrs, .type, try sema.getBuiltinType(src, .@"Type.Fn.Param.Attributes") }, |
| 19472 | .type_to_fn_param_attrs => .{ .fn_param_attrs, .type, try sema.getStdLangType(src, .@"Type.Fn.Param.Attributes") }, |
| 19473 | 19473 | .string_to_struct_field_type => .{ .struct_field_types, .slice_const_u8, .type }, |
| 19474 | 19474 | .string_to_union_field_type => .{ .union_field_types, .slice_const_u8, .type }, |
| 19475 | | .string_to_struct_field_attrs => .{ .struct_field_attrs, .slice_const_u8, try sema.getBuiltinType(src, .@"Type.StructField.Attributes") }, |
| 19476 | | .string_to_union_field_attrs => .{ .union_field_attrs, .slice_const_u8, try sema.getBuiltinType(src, .@"Type.UnionField.Attributes") }, |
| 19475 | .string_to_struct_field_attrs => .{ .struct_field_attrs, .slice_const_u8, try sema.getStdLangType(src, .@"Type.StructField.Attributes") }, |
| 19476 | .string_to_union_field_attrs => .{ .union_field_attrs, .slice_const_u8, try sema.getStdLangType(src, .@"Type.UnionField.Attributes") }, |
| 19477 | 19477 | // zig fmt: on |
| 19478 | 19478 | }; |
| 19479 | 19479 | |
| ... | ... | @@ -19599,18 +19599,18 @@ fn zirReifyPointer( |
| 19599 | 19599 | const elem_ty_src = block.builtinCallArgSrc(extra.node, 2); |
| 19600 | 19600 | const sentinel_src = block.builtinCallArgSrc(extra.node, 3); |
| 19601 | 19601 | |
| 19602 | | const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size"); |
| 19603 | | const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes"); |
| 19602 | const size_ty = try sema.getStdLangType(size_src, .@"Type.Pointer.Size"); |
| 19603 | const attrs_ty = try sema.getStdLangType(attrs_src, .@"Type.Pointer.Attributes"); |
| 19604 | 19604 | |
| 19605 | 19605 | const size_uncoerced = sema.resolveInst(extra.size); |
| 19606 | 19606 | const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src); |
| 19607 | 19607 | const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size }); |
| 19608 | | const size = try sema.interpretBuiltinType(block, size_src, size_val, std.builtin.Type.Pointer.Size); |
| 19608 | const size = try sema.interpretStdLangType(block, size_src, size_val, std.builtin.Type.Pointer.Size); |
| 19609 | 19609 | |
| 19610 | 19610 | const attrs_uncoerced = sema.resolveInst(extra.attrs); |
| 19611 | 19611 | const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src); |
| 19612 | 19612 | const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs }); |
| 19613 | | const attrs = try sema.interpretBuiltinType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes); |
| 19613 | const attrs = try sema.interpretStdLangType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes); |
| 19614 | 19614 | |
| 19615 | 19615 | const @"align": Alignment = if (attrs.@"align") |bytes| a: { |
| 19616 | 19616 | break :a try sema.validateAlign(block, attrs_src, bytes); |
| ... | ... | @@ -19687,8 +19687,8 @@ fn zirReifyFn( |
| 19687 | 19687 | const ret_ty_src = block.builtinCallArgSrc(extra.node, 2); |
| 19688 | 19688 | const fn_attrs_src = block.builtinCallArgSrc(extra.node, 3); |
| 19689 | 19689 | |
| 19690 | | const single_param_attrs_ty = try sema.getBuiltinType(param_attrs_src, .@"Type.Fn.Param.Attributes"); |
| 19691 | | const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes"); |
| 19690 | const single_param_attrs_ty = try sema.getStdLangType(param_attrs_src, .@"Type.Fn.Param.Attributes"); |
| 19691 | const fn_attrs_ty = try sema.getStdLangType(fn_attrs_src, .@"Type.Fn.Attributes"); |
| 19692 | 19692 | |
| 19693 | 19693 | const param_types_uncoerced = sema.resolveInst(extra.param_types); |
| 19694 | 19694 | const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src); |
| ... | ... | @@ -19711,13 +19711,13 @@ fn zirReifyFn( |
| 19711 | 19711 | const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs); |
| 19712 | 19712 | const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src); |
| 19713 | 19713 | const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs }); |
| 19714 | | const fn_attrs = try sema.interpretBuiltinType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes); |
| 19714 | const fn_attrs = try sema.interpretStdLangType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes); |
| 19715 | 19715 | |
| 19716 | 19716 | var noalias_bits: u32 = 0; |
| 19717 | 19717 | const param_types_ip = try sema.arena.alloc(InternPool.Index, @intCast(params_len)); |
| 19718 | 19718 | for (param_types_ip, 0..@intCast(params_len)) |*param_ty_ip, param_idx| { |
| 19719 | 19719 | const param_ty: Type = (try param_types_arr.elemValue(pt, param_idx)).toType(); |
| 19720 | | const param_attrs = try sema.interpretBuiltinType( |
| 19720 | const param_attrs = try sema.interpretStdLangType( |
| 19721 | 19721 | block, |
| 19722 | 19722 | param_attrs_src, |
| 19723 | 19723 | try param_attrs_arr.elemValue(pt, param_idx), |
| ... | ... | @@ -19825,13 +19825,13 @@ fn zirReifyStruct( |
| 19825 | 19825 | } }, |
| 19826 | 19826 | }; |
| 19827 | 19827 | |
| 19828 | | const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout"); |
| 19829 | | const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes"); |
| 19828 | const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout"); |
| 19829 | const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.StructField.Attributes"); |
| 19830 | 19830 | |
| 19831 | 19831 | const layout_uncoerced = sema.resolveInst(extra.layout); |
| 19832 | 19832 | const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src); |
| 19833 | 19833 | const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout }); |
| 19834 | | const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout); |
| 19834 | const layout = try sema.interpretStdLangType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout); |
| 19835 | 19835 | |
| 19836 | 19836 | const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty); |
| 19837 | 19837 | const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src); |
| ... | ... | @@ -20105,13 +20105,13 @@ fn zirReifyUnion( |
| 20105 | 20105 | } }, |
| 20106 | 20106 | }; |
| 20107 | 20107 | |
| 20108 | | const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout"); |
| 20109 | | const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes"); |
| 20108 | const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout"); |
| 20109 | const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.UnionField.Attributes"); |
| 20110 | 20110 | |
| 20111 | 20111 | const layout_uncoerced = sema.resolveInst(extra.layout); |
| 20112 | 20112 | const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src); |
| 20113 | 20113 | const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout }); |
| 20114 | | const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout); |
| 20114 | const layout = try sema.interpretStdLangType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout); |
| 20115 | 20115 | |
| 20116 | 20116 | const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty); |
| 20117 | 20117 | const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src); |
| ... | ... | @@ -20191,7 +20191,7 @@ fn zirReifyUnion( |
| 20191 | 20191 | const field_name = try sema.sliceToIpString(block, field_names_src, field_name_val, .{ .simple = .union_field_names }); |
| 20192 | 20192 | std.hash.autoHash(&hasher, field_name); |
| 20193 | 20193 | |
| 20194 | | const field_attrs = try sema.interpretBuiltinType( |
| 20194 | const field_attrs = try sema.interpretStdLangType( |
| 20195 | 20195 | block, |
| 20196 | 20196 | field_attrs_src, |
| 20197 | 20197 | try field_attrs_arr.elemValue(pt, field_idx), |
| ... | ... | @@ -20240,7 +20240,7 @@ fn zirReifyUnion( |
| 20240 | 20240 | wip.field_types.get(ip)[field_idx] = field_ty.toIntern(); |
| 20241 | 20241 | |
| 20242 | 20242 | // No source location; first loop checked this is valid. |
| 20243 | | const field_attrs = try sema.interpretBuiltinType( |
| 20243 | const field_attrs = try sema.interpretStdLangType( |
| 20244 | 20244 | block, |
| 20245 | 20245 | .unneeded, |
| 20246 | 20246 | try field_attrs_arr.elemValue(pt, field_idx), |
| ... | ... | @@ -20319,7 +20319,7 @@ fn zirReifyEnum( |
| 20319 | 20319 | } }, |
| 20320 | 20320 | }; |
| 20321 | 20321 | |
| 20322 | | const enum_mode_ty = try sema.getBuiltinType(mode_src, .@"Type.Enum.Mode"); |
| 20322 | const enum_mode_ty = try sema.getStdLangType(mode_src, .@"Type.Enum.Mode"); |
| 20323 | 20323 | |
| 20324 | 20324 | const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty); |
| 20325 | 20325 | const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src); |
| ... | ... | @@ -20329,7 +20329,7 @@ fn zirReifyEnum( |
| 20329 | 20329 | const mode_uncoerced = sema.resolveInst(extra.mode); |
| 20330 | 20330 | const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src); |
| 20331 | 20331 | const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type }); |
| 20332 | | const nonexhaustive = switch (try sema.interpretBuiltinType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) { |
| 20332 | const nonexhaustive = switch (try sema.interpretStdLangType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) { |
| 20333 | 20333 | .exhaustive => false, |
| 20334 | 20334 | .nonexhaustive => true, |
| 20335 | 20335 | }; |
| ... | ... | @@ -20423,7 +20423,7 @@ fn zirReifyEnum( |
| 20423 | 20423 | |
| 20424 | 20424 | fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref { |
| 20425 | 20425 | const pt = sema.pt; |
| 20426 | | const va_list_ty = try sema.getBuiltinType(src, .VaList); |
| 20426 | const va_list_ty = try sema.getStdLangType(src, .VaList); |
| 20427 | 20427 | const va_list_ptr = try pt.singleMutPtrType(va_list_ty); |
| 20428 | 20428 | |
| 20429 | 20429 | const inst = sema.resolveInst(zir_ref); |
| ... | ... | @@ -20462,7 +20462,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) |
| 20462 | 20462 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); |
| 20463 | 20463 | |
| 20464 | 20464 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand); |
| 20465 | | const va_list_ty = try sema.getBuiltinType(src, .VaList); |
| 20465 | const va_list_ty = try sema.getStdLangType(src, .VaList); |
| 20466 | 20466 | |
| 20467 | 20467 | try sema.requireRuntimeBlock(block, src, null); |
| 20468 | 20468 | return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref); |
| ... | ... | @@ -20484,7 +20484,7 @@ fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) |
| 20484 | 20484 | const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); |
| 20485 | 20485 | const src = block.nodeOffset(src_node); |
| 20486 | 20486 | |
| 20487 | | const va_list_ty = try sema.getBuiltinType(src, .VaList); |
| 20487 | const va_list_ty = try sema.getStdLangType(src, .VaList); |
| 20488 | 20488 | try sema.requireRuntimeBlock(block, src, null); |
| 20489 | 20489 | return block.addInst(.{ |
| 20490 | 20490 | .tag = .c_va_start, |
| ... | ... | @@ -22373,7 +22373,7 @@ fn resolveExportOptions( |
| 22373 | 22373 | const io = comp.io; |
| 22374 | 22374 | const ip = &zcu.intern_pool; |
| 22375 | 22375 | |
| 22376 | | const export_options_ty = try sema.getBuiltinType(src, .ExportOptions); |
| 22376 | const export_options_ty = try sema.getStdLangType(src, .ExportOptions); |
| 22377 | 22377 | const air_ref = sema.resolveInst(zir_ref); |
| 22378 | 22378 | const options = try sema.coerce(block, export_options_ty, air_ref, src); |
| 22379 | 22379 | |
| ... | ... | @@ -22387,7 +22387,7 @@ fn resolveExportOptions( |
| 22387 | 22387 | |
| 22388 | 22388 | const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src); |
| 22389 | 22389 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options }); |
| 22390 | | const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 22390 | const linkage = try sema.interpretStdLangType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 22391 | 22391 | |
| 22392 | 22392 | const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "section", .no_embedded_nulls), section_src); |
| 22393 | 22393 | const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options }); |
| ... | ... | @@ -22398,7 +22398,7 @@ fn resolveExportOptions( |
| 22398 | 22398 | |
| 22399 | 22399 | const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src); |
| 22400 | 22400 | const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options }); |
| 22401 | | const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility); |
| 22401 | const visibility = try sema.interpretStdLangType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility); |
| 22402 | 22402 | |
| 22403 | 22403 | if (name.len < 1) { |
| 22404 | 22404 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); |
| ... | ... | @@ -22418,19 +22418,19 @@ fn resolveExportOptions( |
| 22418 | 22418 | }; |
| 22419 | 22419 | } |
| 22420 | 22420 | |
| 22421 | | fn resolveBuiltinEnum( |
| 22421 | fn resolveStdLangEnum( |
| 22422 | 22422 | sema: *Sema, |
| 22423 | 22423 | block: *Block, |
| 22424 | 22424 | src: LazySrcLoc, |
| 22425 | 22425 | zir_ref: Zir.Inst.Ref, |
| 22426 | | comptime name: Zcu.BuiltinDecl, |
| 22426 | comptime name: Zcu.StdLangDecl, |
| 22427 | 22427 | reason: ComptimeReason, |
| 22428 | 22428 | ) CompileError!@field(std.builtin, @tagName(name)) { |
| 22429 | | const ty = try sema.getBuiltinType(src, name); |
| 22429 | const ty = try sema.getStdLangType(src, name); |
| 22430 | 22430 | const air_ref = sema.resolveInst(zir_ref); |
| 22431 | 22431 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 22432 | 22432 | const val = try sema.resolveConstDefinedValue(block, src, coerced, reason); |
| 22433 | | return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name))); |
| 22433 | return sema.interpretStdLangType(block, src, val, @field(std.builtin, @tagName(name))); |
| 22434 | 22434 | } |
| 22435 | 22435 | |
| 22436 | 22436 | fn resolveAtomicOrder( |
| ... | ... | @@ -22440,7 +22440,7 @@ fn resolveAtomicOrder( |
| 22440 | 22440 | zir_ref: Zir.Inst.Ref, |
| 22441 | 22441 | reason: ComptimeReason, |
| 22442 | 22442 | ) CompileError!std.builtin.AtomicOrder { |
| 22443 | | return sema.resolveBuiltinEnum(block, src, zir_ref, .AtomicOrder, reason); |
| 22443 | return sema.resolveStdLangEnum(block, src, zir_ref, .AtomicOrder, reason); |
| 22444 | 22444 | } |
| 22445 | 22445 | |
| 22446 | 22446 | fn resolveAtomicRmwOp( |
| ... | ... | @@ -22449,7 +22449,7 @@ fn resolveAtomicRmwOp( |
| 22449 | 22449 | src: LazySrcLoc, |
| 22450 | 22450 | zir_ref: Zir.Inst.Ref, |
| 22451 | 22451 | ) CompileError!std.builtin.AtomicRmwOp { |
| 22452 | | return sema.resolveBuiltinEnum(block, src, zir_ref, .AtomicRmwOp, .{ .simple = .operand_atomicRmw_operation }); |
| 22452 | return sema.resolveStdLangEnum(block, src, zir_ref, .AtomicRmwOp, .{ .simple = .operand_atomicRmw_operation }); |
| 22453 | 22453 | } |
| 22454 | 22454 | |
| 22455 | 22455 | fn zirCmpxchg( |
| ... | ... | @@ -22609,7 +22609,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 22609 | 22609 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 22610 | 22610 | const op_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 22611 | 22611 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| 22612 | | const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation }); |
| 22612 | const operation = try sema.resolveStdLangEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation }); |
| 22613 | 22613 | const operand = sema.resolveInst(extra.rhs); |
| 22614 | 22614 | const operand_ty = sema.typeOf(operand); |
| 22615 | 22615 | const pt = sema.pt; |
| ... | ... | @@ -23196,11 +23196,11 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 23196 | 23196 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 23197 | 23197 | const func = sema.resolveInst(extra.callee); |
| 23198 | 23198 | |
| 23199 | | const modifier_ty = try sema.getBuiltinType(call_src, .CallModifier); |
| 23199 | const modifier_ty = try sema.getStdLangType(call_src, .CallModifier); |
| 23200 | 23200 | const air_ref = sema.resolveInst(extra.modifier); |
| 23201 | 23201 | const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src); |
| 23202 | 23202 | const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier }); |
| 23203 | | var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier); |
| 23203 | var modifier = try sema.interpretStdLangType(block, modifier_src, modifier_val, std.builtin.CallModifier); |
| 23204 | 23204 | switch (modifier) { |
| 23205 | 23205 | // These can be upgraded to comptime or nosuspend calls. |
| 23206 | 23206 | .auto, .never_tail, .no_suspend => { |
| ... | ... | @@ -24256,13 +24256,13 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24256 | 24256 | const body = sema.code.bodySlice(extra_index, body_len); |
| 24257 | 24257 | extra_index += body.len; |
| 24258 | 24258 | |
| 24259 | | const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention); |
| 24259 | const cc_ty = try sema.getStdLangType(cc_src, .CallingConvention); |
| 24260 | 24260 | const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ .simple = .@"callconv" }); |
| 24261 | 24261 | break :blk try sema.analyzeValueAsCallconv(block, cc_src, val); |
| 24262 | 24262 | } else if (extra.data.bits.has_cc_ref) blk: { |
| 24263 | 24263 | const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24264 | 24264 | extra_index += 1; |
| 24265 | | const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention); |
| 24265 | const cc_ty = try sema.getStdLangType(cc_src, .CallingConvention); |
| 24266 | 24266 | const uncoerced_cc = sema.resolveInst(cc_ref); |
| 24267 | 24267 | const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src); |
| 24268 | 24268 | const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" }); |
| ... | ... | @@ -24275,10 +24275,10 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24275 | 24275 | if (zir_decl.linkage == .@"export") { |
| 24276 | 24276 | break :cc target.cCallingConvention() orelse { |
| 24277 | 24277 | // This target has no default C calling convention. We sometimes trigger a similar |
| 24278 | | // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency, |
| 24278 | // error by trying to evaluate `std.lang.CallingConvention.c`, so for consistency, |
| 24279 | 24279 | // let's eval that now and just get the transitive error. (It's guaranteed to error |
| 24280 | 24280 | // because it does the exact `cCallingConvention` call we just did.) |
| 24281 | | const cc_type = try sema.getBuiltinType(cc_src, .CallingConvention); |
| 24281 | const cc_type = try sema.getStdLangType(cc_src, .CallingConvention); |
| 24282 | 24282 | _ = try sema.namespaceLookupVal( |
| 24283 | 24283 | block, |
| 24284 | 24284 | LazySrcLoc.unneeded, |
| ... | ... | @@ -24286,7 +24286,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24286 | 24286 | try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls), |
| 24287 | 24287 | ); |
| 24288 | 24288 | // The above should have errored. |
| 24289 | | @panic("std.builtin is corrupt"); |
| 24289 | @panic("std.lang is corrupt"); |
| 24290 | 24290 | }; |
| 24291 | 24291 | } |
| 24292 | 24292 | } |
| ... | ... | @@ -24406,7 +24406,7 @@ fn resolvePrefetchOptions( |
| 24406 | 24406 | const io = comp.io; |
| 24407 | 24407 | const ip = &zcu.intern_pool; |
| 24408 | 24408 | |
| 24409 | | const options_ty = try sema.getBuiltinType(src, .PrefetchOptions); |
| 24409 | const options_ty = try sema.getStdLangType(src, .PrefetchOptions); |
| 24410 | 24410 | const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src); |
| 24411 | 24411 | |
| 24412 | 24412 | const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | ... | @@ -24423,9 +24423,9 @@ fn resolvePrefetchOptions( |
| 24423 | 24423 | const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options }); |
| 24424 | 24424 | |
| 24425 | 24425 | return std.builtin.PrefetchOptions{ |
| 24426 | | .rw = try sema.interpretBuiltinType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw), |
| 24426 | .rw = try sema.interpretStdLangType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw), |
| 24427 | 24427 | .locality = @intCast(locality_val.toUnsignedInt(zcu)), |
| 24428 | | .cache = try sema.interpretBuiltinType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache), |
| 24428 | .cache = try sema.interpretStdLangType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache), |
| 24429 | 24429 | }; |
| 24430 | 24430 | } |
| 24431 | 24431 | |
| ... | ... | @@ -24480,7 +24480,7 @@ fn resolveExternOptions( |
| 24480 | 24480 | const ip = &zcu.intern_pool; |
| 24481 | 24481 | |
| 24482 | 24482 | const options_inst = sema.resolveInst(zir_ref); |
| 24483 | | const extern_options_ty = try sema.getBuiltinType(src, .ExternOptions); |
| 24483 | const extern_options_ty = try sema.getStdLangType(src, .ExternOptions); |
| 24484 | 24484 | const options = try sema.coerce(block, extern_options_ty, options_inst, src); |
| 24485 | 24485 | |
| 24486 | 24486 | const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| ... | ... | @@ -24500,11 +24500,11 @@ fn resolveExternOptions( |
| 24500 | 24500 | |
| 24501 | 24501 | const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src); |
| 24502 | 24502 | const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options }); |
| 24503 | | const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 24503 | const linkage = try sema.interpretStdLangType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage); |
| 24504 | 24504 | |
| 24505 | 24505 | const visibility_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src); |
| 24506 | 24506 | const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_ref, .{ .simple = .extern_options }); |
| 24507 | | const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility); |
| 24507 | const visibility = try sema.interpretStdLangType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility); |
| 24508 | 24508 | |
| 24509 | 24509 | const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "is_thread_local", .no_embedded_nulls), thread_local_src); |
| 24510 | 24510 | const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options }); |
| ... | ... | @@ -24523,11 +24523,11 @@ fn resolveExternOptions( |
| 24523 | 24523 | |
| 24524 | 24524 | const relocation_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "relocation", .no_embedded_nulls), relocation_src); |
| 24525 | 24525 | const relocation_val = try sema.resolveConstDefinedValue(block, relocation_src, relocation_ref, .{ .simple = .extern_options }); |
| 24526 | | const relocation = try sema.interpretBuiltinType(block, relocation_src, relocation_val, std.builtin.ExternOptions.Relocation); |
| 24526 | const relocation = try sema.interpretStdLangType(block, relocation_src, relocation_val, std.builtin.ExternOptions.Relocation); |
| 24527 | 24527 | |
| 24528 | 24528 | const decoration_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "decoration", .no_embedded_nulls), decoration_src); |
| 24529 | 24529 | const decoration_val = try sema.resolveConstDefinedValue(block, decoration_src, decoration_ref, .{ .simple = .extern_options }); |
| 24530 | | const decoration = try sema.interpretBuiltinType(block, decoration_src, decoration_val, ?std.builtin.ExternOptions.Decoration); |
| 24530 | const decoration = try sema.interpretStdLangType(block, decoration_src, decoration_val, ?std.builtin.ExternOptions.Decoration); |
| 24531 | 24531 | |
| 24532 | 24532 | if (name.len == 0) { |
| 24533 | 24533 | return sema.fail(block, name_src, "extern symbol name cannot be empty", .{}); |
| ... | ... | @@ -24696,7 +24696,7 @@ fn zirInComptime( |
| 24696 | 24696 | return if (block.isComptime()) .bool_true else .bool_false; |
| 24697 | 24697 | } |
| 24698 | 24698 | |
| 24699 | | fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 24699 | fn zirStdLangValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 24700 | 24700 | const pt = sema.pt; |
| 24701 | 24701 | const zcu = pt.zcu; |
| 24702 | 24702 | const comp = zcu.comp; |
| ... | ... | @@ -24706,9 +24706,9 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 24706 | 24706 | |
| 24707 | 24707 | const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); |
| 24708 | 24708 | const src = block.nodeOffset(src_node); |
| 24709 | | const value: Zir.Inst.BuiltinValue = @enumFromInt(extended.small); |
| 24709 | const value: Zir.Inst.StdLangValue = @enumFromInt(extended.small); |
| 24710 | 24710 | |
| 24711 | | const builtin_type: Zcu.BuiltinDecl = switch (value) { |
| 24711 | const std_lang_type: Zcu.StdLangDecl = switch (value) { |
| 24712 | 24712 | // zig fmt: off |
| 24713 | 24713 | .atomic_order => .AtomicOrder, |
| 24714 | 24714 | .atomic_rmw_op => .AtomicRmwOp, |
| ... | ... | @@ -24732,28 +24732,28 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 24732 | 24732 | |
| 24733 | 24733 | // Values are handled here. |
| 24734 | 24734 | .calling_convention_c => { |
| 24735 | | const callconv_ty = try sema.getBuiltinType(src, .CallingConvention); |
| 24735 | const callconv_ty = try sema.getStdLangType(src, .CallingConvention); |
| 24736 | 24736 | // Cannot use `Value.uninterpret` because `c` is a *declaration* whose value depends on the target. |
| 24737 | 24737 | return try sema.namespaceLookupVal( |
| 24738 | 24738 | block, |
| 24739 | 24739 | src, |
| 24740 | 24740 | callconv_ty.getNamespaceIndex(zcu), |
| 24741 | 24741 | try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls), |
| 24742 | | ) orelse @panic("std.builtin is corrupt"); |
| 24742 | ) orelse @panic("std.lang is corrupt"); |
| 24743 | 24743 | }, |
| 24744 | 24744 | .calling_convention_inline => { |
| 24745 | | const callconv_ty = try sema.getBuiltinType(src, .CallingConvention); |
| 24745 | const callconv_ty = try sema.getStdLangType(src, .CallingConvention); |
| 24746 | 24746 | return .fromValue(Value.uninterpret( |
| 24747 | 24747 | @as(std.builtin.CallingConvention, .@"inline"), |
| 24748 | 24748 | callconv_ty, |
| 24749 | 24749 | pt, |
| 24750 | 24750 | ) catch |err| switch (err) { |
| 24751 | | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| 24751 | error.TypeMismatch => @panic("std.lang is corrupt"), |
| 24752 | 24752 | error.OutOfMemory => |e| return e, |
| 24753 | 24753 | }); |
| 24754 | 24754 | }, |
| 24755 | 24755 | }; |
| 24756 | | return .fromType(try sema.getBuiltinType(src, builtin_type)); |
| 24756 | return .fromType(try sema.getStdLangType(src, std_lang_type)); |
| 24757 | 24757 | } |
| 24758 | 24758 | |
| 24759 | 24759 | fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -24788,14 +24788,14 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 24788 | 24788 | const uncoerced_hint = sema.resolveInst(extra.operand); |
| 24789 | 24789 | const operand_src = block.builtinCallArgSrc(extra.node, 0); |
| 24790 | 24790 | |
| 24791 | | const hint_ty = try sema.getBuiltinType(operand_src, .BranchHint); |
| 24791 | const hint_ty = try sema.getStdLangType(operand_src, .BranchHint); |
| 24792 | 24792 | const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src); |
| 24793 | 24793 | const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{ .simple = .operand_branchHint }); |
| 24794 | 24794 | |
| 24795 | 24795 | // We only apply the first hint in a branch. |
| 24796 | 24796 | // This allows user-provided hints to override implicit cold hints. |
| 24797 | 24797 | if (sema.branch_hint == null) { |
| 24798 | | sema.branch_hint = try sema.interpretBuiltinType(block, operand_src, hint_val, std.builtin.BranchHint); |
| 24798 | sema.branch_hint = try sema.interpretStdLangType(block, operand_src, hint_val, std.builtin.BranchHint); |
| 24799 | 24799 | } |
| 24800 | 24800 | } |
| 24801 | 24801 | |
| ... | ... | @@ -25148,7 +25148,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In |
| 25148 | 25148 | const zcu = sema.pt.zcu; |
| 25149 | 25149 | const io = zcu.comp.io; |
| 25150 | 25150 | try sema.ensureMemoizedStateResolved(src, .panic); |
| 25151 | | const panic_fn_index = zcu.builtin_decl_values.get(panic_id.toBuiltin()); |
| 25151 | const panic_fn_index = zcu.std_lang_decl_values.get(panic_id.toStdLangDecl()); |
| 25152 | 25152 | switch (sema.owner.unwrap()) { |
| 25153 | 25153 | .@"comptime", |
| 25154 | 25154 | .nav_ty, |
| ... | ... | @@ -25292,7 +25292,7 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air. |
| 25292 | 25292 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 25293 | 25293 | _ = try block.addNoOp(.trap); |
| 25294 | 25294 | } else { |
| 25295 | | const panic_fn = try getBuiltin(sema, src, .@"panic.unwrapError"); |
| 25295 | const panic_fn = try getStdLangValue(sema, src, .@"panic.unwrapError"); |
| 25296 | 25296 | try sema.callBuiltin(block, src, Air.internedToRef(panic_fn), .auto, &.{err}, .@"safety check"); |
| 25297 | 25297 | } |
| 25298 | 25298 | } |
| ... | ... | @@ -25382,7 +25382,7 @@ fn addSafetyCheckCall( |
| 25382 | 25382 | parent_block: *Block, |
| 25383 | 25383 | src: LazySrcLoc, |
| 25384 | 25384 | ok: Air.Inst.Ref, |
| 25385 | | comptime func_decl: Zcu.BuiltinDecl, |
| 25385 | comptime func_decl: Zcu.StdLangDecl, |
| 25386 | 25386 | args: []const Air.Inst.Ref, |
| 25387 | 25387 | ) !void { |
| 25388 | 25388 | assert(!parent_block.isComptime()); |
| ... | ... | @@ -25406,7 +25406,7 @@ fn addSafetyCheckCall( |
| 25406 | 25406 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 25407 | 25407 | _ = try fail_block.addNoOp(.trap); |
| 25408 | 25408 | } else { |
| 25409 | | const panic_fn = try getBuiltin(sema, src, func_decl); |
| 25409 | const panic_fn = try getStdLangValue(sema, src, func_decl); |
| 25410 | 25410 | try sema.callBuiltin(&fail_block, src, Air.internedToRef(panic_fn), .auto, args, .@"safety check"); |
| 25411 | 25411 | } |
| 25412 | 25412 | |
| ... | ... | @@ -33114,10 +33114,10 @@ pub fn analyzeAsAddressSpace( |
| 33114 | 33114 | ctx: std.Target.AddressSpaceContext, |
| 33115 | 33115 | ) !std.builtin.AddressSpace { |
| 33116 | 33116 | const pt = sema.pt; |
| 33117 | | const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace); |
| 33117 | const addrspace_ty = try sema.getStdLangType(src, .AddressSpace); |
| 33118 | 33118 | const coerced = try sema.coerce(block, addrspace_ty, air_ref, src); |
| 33119 | 33119 | const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" }); |
| 33120 | | const address_space = try sema.interpretBuiltinType(block, src, addrspace_val, std.builtin.AddressSpace); |
| 33120 | const address_space = try sema.interpretStdLangType(block, src, addrspace_val, std.builtin.AddressSpace); |
| 33121 | 33121 | const target = pt.zcu.getTarget(); |
| 33122 | 33122 | |
| 33123 | 33123 | if (!target.supportsAddressSpace(address_space, ctx)) { |
| ... | ... | @@ -33819,15 +33819,15 @@ pub const type_resolution = @import("Sema/type_resolution.zig"); |
| 33819 | 33819 | pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved; |
| 33820 | 33820 | pub const ensureStructDefaultsResolved = type_resolution.ensureStructDefaultsResolved; |
| 33821 | 33821 | |
| 33822 | | pub fn getBuiltinType(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!Type { |
| 33822 | pub fn getStdLangType(sema: *Sema, src: LazySrcLoc, decl: Zcu.StdLangDecl) SemaError!Type { |
| 33823 | 33823 | assert(decl.kind() == .type); |
| 33824 | 33824 | try sema.ensureMemoizedStateResolved(src, decl.stage()); |
| 33825 | | return .fromInterned(sema.pt.zcu.builtin_decl_values.get(decl)); |
| 33825 | return .fromInterned(sema.pt.zcu.std_lang_decl_values.get(decl)); |
| 33826 | 33826 | } |
| 33827 | | pub fn getBuiltin(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!InternPool.Index { |
| 33827 | pub fn getStdLangValue(sema: *Sema, src: LazySrcLoc, decl: Zcu.StdLangDecl) SemaError!InternPool.Index { |
| 33828 | 33828 | assert(decl.kind() != .type); |
| 33829 | 33829 | try sema.ensureMemoizedStateResolved(src, decl.stage()); |
| 33830 | | return sema.pt.zcu.builtin_decl_values.get(decl); |
| 33830 | return sema.pt.zcu.std_lang_decl_values.get(decl); |
| 33831 | 33831 | } |
| 33832 | 33832 | |
| 33833 | 33833 | pub const NavPtrModifiers = struct { |
| ... | ... | @@ -33928,30 +33928,30 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C |
| 33928 | 33928 | }; |
| 33929 | 33929 | defer block.instructions.deinit(gpa); |
| 33930 | 33930 | |
| 33931 | | const std_builtin_ty: Type = ty: { |
| 33931 | const std_lang_ty: Type = ty: { |
| 33932 | 33932 | const std_src = block.nodeOffset(.zero); |
| 33933 | | const decl_name = try ip.getOrPutString(gpa, io, pt.tid, "builtin", .no_embedded_nulls); |
| 33933 | const decl_name = try ip.getOrPutString(gpa, io, pt.tid, "lang", .no_embedded_nulls); |
| 33934 | 33934 | const nav = try sema.namespaceLookup(&block, std_src, block.namespace, decl_name) orelse { |
| 33935 | | return sema.fail(&block, std_src, "'std' missing 'builtin'", .{}); |
| 33935 | return sema.fail(&block, std_src, "'std' missing 'lang'", .{}); |
| 33936 | 33936 | }; |
| 33937 | 33937 | const uncoerced_val = try sema.analyzeNavVal(&block, std_src, nav); |
| 33938 | 33938 | const decl_src: LazySrcLoc = .{ |
| 33939 | 33939 | .base_node_inst = ip.getNav(nav).srcInst(ip), |
| 33940 | 33940 | .offset = .nodeOffset(.zero), |
| 33941 | 33941 | }; |
| 33942 | | break :ty try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val); |
| 33942 | break :ty try sema.analyzeAsType(&block, decl_src, .std_lang_decl, uncoerced_val); |
| 33943 | 33943 | }; |
| 33944 | 33944 | |
| 33945 | 33945 | var any_changed = false; |
| 33946 | 33946 | |
| 33947 | | inline for (comptime std.enums.values(Zcu.BuiltinDecl)) |builtin_decl| { |
| 33948 | | if (stage == comptime builtin_decl.stage()) { |
| 33949 | | const parent_ns_ty: Type, const parent_name: []const u8, const name: []const u8 = switch (comptime builtin_decl.access()) { |
| 33950 | | .direct => |name| .{ std_builtin_ty, "std.builtin", name }, |
| 33947 | inline for (comptime std.enums.values(Zcu.StdLangDecl)) |std_lang_decl| { |
| 33948 | if (stage == comptime std_lang_decl.stage()) { |
| 33949 | const parent_ns_ty: Type, const parent_name: []const u8, const name: []const u8 = switch (comptime std_lang_decl.access()) { |
| 33950 | .direct => |name| .{ std_lang_ty, "std.lang", name }, |
| 33951 | 33951 | .nested => |nested| access: { |
| 33952 | 33952 | const parent_decl, const name = nested; |
| 33953 | | const parent_ty: Type = .fromInterned(zcu.builtin_decl_values.get(parent_decl)); |
| 33954 | | break :access .{ parent_ty, "std.builtin." ++ @tagName(parent_decl), name }; |
| 33953 | const parent_ty: Type = .fromInterned(zcu.std_lang_decl_values.get(parent_decl)); |
| 33954 | break :access .{ parent_ty, "std.lang." ++ @tagName(parent_decl), name }; |
| 33955 | 33955 | }, |
| 33956 | 33956 | }; |
| 33957 | 33957 | |
| ... | ... | @@ -33970,25 +33970,25 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C |
| 33970 | 33970 | .offset = .nodeOffset(.zero), |
| 33971 | 33971 | }; |
| 33972 | 33972 | |
| 33973 | | const val: Value = switch (builtin_decl.kind()) { |
| 33973 | const val: Value = switch (std_lang_decl.kind()) { |
| 33974 | 33974 | .type => val: { |
| 33975 | | const ty = try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val); |
| 33976 | | try sema.ensureLayoutResolved(ty, decl_src, .builtin_type); |
| 33975 | const ty = try sema.analyzeAsType(&block, decl_src, .std_lang_decl, uncoerced_val); |
| 33976 | try sema.ensureLayoutResolved(ty, decl_src, .std_lang_type); |
| 33977 | 33977 | break :val ty.toValue(); |
| 33978 | 33978 | }, |
| 33979 | 33979 | .func => val: { |
| 33980 | | const func_ty = try sema.getExpectedBuiltinFnType(builtin_decl); |
| 33980 | const func_ty = try sema.getExpectedBuiltinFnType(std_lang_decl); |
| 33981 | 33981 | const coerced = try sema.coerce(&block, func_ty, uncoerced_val, decl_src); |
| 33982 | | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl }); |
| 33982 | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_lang_decl }); |
| 33983 | 33983 | }, |
| 33984 | 33984 | .string => val: { |
| 33985 | 33985 | const coerced = try sema.coerce(&block, .slice_const_u8, uncoerced_val, decl_src); |
| 33986 | | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl }); |
| 33986 | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_lang_decl }); |
| 33987 | 33987 | }, |
| 33988 | 33988 | }; |
| 33989 | 33989 | |
| 33990 | | if (zcu.builtin_decl_values.get(builtin_decl) != val.toIntern()) { |
| 33991 | | zcu.builtin_decl_values.set(builtin_decl, val.toIntern()); |
| 33990 | if (zcu.std_lang_decl_values.get(std_lang_decl) != val.toIntern()) { |
| 33991 | zcu.std_lang_decl_values.set(std_lang_decl, val.toIntern()); |
| 33992 | 33992 | any_changed = true; |
| 33993 | 33993 | } |
| 33994 | 33994 | } |
| ... | ... | @@ -33998,7 +33998,7 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C |
| 33998 | 33998 | } |
| 33999 | 33999 | |
| 34000 | 34000 | /// Given that `decl.kind() == .func`, get the type expected of the function. |
| 34001 | | fn getExpectedBuiltinFnType(sema: *Sema, decl: Zcu.BuiltinDecl) CompileError!Type { |
| 34001 | fn getExpectedBuiltinFnType(sema: *Sema, decl: Zcu.StdLangDecl) CompileError!Type { |
| 34002 | 34002 | const pt = sema.pt; |
| 34003 | 34003 | return switch (decl) { |
| 34004 | 34004 | // `noinline fn () void` |