| author | |
| committer | |
| log | c6f3e9d79cf849623e6c4f25e02e17cdfab07b7c |
| tree | 0efc0142dd23a67509015113b9e1a3aaa2d6c15a |
| parent | 341857e5cd4fd4453cf9c7d1a6679feb66710d84 |
| signature |
`Decl` can no longer store un-interned values, so this field is now
unnecessary. The type can instead be fetched with the new `typeOf`
helper method, which just gets the type of the Decl's `Value`.23 files changed, 120 insertions(+), 123 deletions(-)
src/InternPool.zig-4| ... | ... | @@ -6581,7 +6581,6 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey) |
| 6581 | 6581 | generic_owner, |
| 6582 | 6582 | func_index, |
| 6583 | 6583 | func_extra_index, |
| 6584 | func_ty, | |
| 6585 | 6584 | arg.alignment, |
| 6586 | 6585 | arg.section, |
| 6587 | 6586 | ); |
| ... | ... | @@ -6711,7 +6710,6 @@ pub fn getFuncInstanceIes( |
| 6711 | 6710 | generic_owner, |
| 6712 | 6711 | func_index, |
| 6713 | 6712 | func_extra_index, |
| 6714 | func_ty, | |
| 6715 | 6713 | arg.alignment, |
| 6716 | 6714 | arg.section, |
| 6717 | 6715 | ); |
| ... | ... | @@ -6723,7 +6721,6 @@ fn finishFuncInstance( |
| 6723 | 6721 | generic_owner: Index, |
| 6724 | 6722 | func_index: Index, |
| 6725 | 6723 | func_extra_index: u32, |
| 6726 | func_ty: Index, | |
| 6727 | 6724 | alignment: Alignment, |
| 6728 | 6725 | section: OptionalNullTerminatedString, |
| 6729 | 6726 | ) Allocator.Error!Index { |
| ... | ... | @@ -6735,7 +6732,6 @@ fn finishFuncInstance( |
| 6735 | 6732 | .src_line = fn_owner_decl.src_line, |
| 6736 | 6733 | .has_tv = true, |
| 6737 | 6734 | .owns_tv = true, |
| 6738 | .ty = @import("type.zig").Type.fromInterned(func_ty), | |
| 6739 | 6735 | .val = @import("Value.zig").fromInterned(func_index), |
| 6740 | 6736 | .alignment = alignment, |
| 6741 | 6737 | .@"linksection" = section, |
src/Module.zig+25-26| ... | ... | @@ -330,9 +330,6 @@ const ValueArena = struct { |
| 330 | 330 | |
| 331 | 331 | pub const Decl = struct { |
| 332 | 332 | name: InternPool.NullTerminatedString, |
| 333 | /// The most recent Type of the Decl after a successful semantic analysis. | |
| 334 | /// Populated when `has_tv`. | |
| 335 | ty: Type, | |
| 336 | 333 | /// The most recent Value of the Decl after a successful semantic analysis. |
| 337 | 334 | /// Populated when `has_tv`. |
| 338 | 335 | val: Value, |
| ... | ... | @@ -487,20 +484,28 @@ pub const Decl = struct { |
| 487 | 484 | zcu.namespacePtr(decl.src_namespace).fullyQualifiedName(zcu, decl.name); |
| 488 | 485 | } |
| 489 | 486 | |
| 490 | pub fn typedValue(decl: Decl) error{AnalysisFail}!TypedValue { | |
| 487 | pub fn typeOf(decl: Decl, zcu: *const Zcu) Type { | |
| 488 | assert(decl.has_tv); | |
| 489 | return Type.fromInterned(zcu.intern_pool.typeOf(decl.val.toIntern())); | |
| 490 | } | |
| 491 | ||
| 492 | pub fn typedValue(decl: Decl, zcu: *const Zcu) error{AnalysisFail}!TypedValue { | |
| 491 | 493 | if (!decl.has_tv) return error.AnalysisFail; |
| 492 | return TypedValue{ .ty = decl.ty, .val = decl.val }; | |
| 494 | return .{ | |
| 495 | .ty = decl.typeOf(zcu), | |
| 496 | .val = decl.val, | |
| 497 | }; | |
| 493 | 498 | } |
| 494 | 499 | |
| 495 | 500 | pub fn internValue(decl: *Decl, zcu: *Zcu) Allocator.Error!InternPool.Index { |
| 496 | 501 | assert(decl.has_tv); |
| 497 | const ip_index = try decl.val.intern(decl.ty, zcu); | |
| 502 | const ip_index = try decl.val.intern(decl.typeOf(zcu), zcu); | |
| 498 | 503 | decl.val = Value.fromInterned(ip_index); |
| 499 | 504 | return ip_index; |
| 500 | 505 | } |
| 501 | 506 | |
| 502 | 507 | pub fn isFunction(decl: Decl, zcu: *const Zcu) !bool { |
| 503 | const tv = try decl.typedValue(); | |
| 508 | const tv = try decl.typedValue(zcu); | |
| 504 | 509 | return tv.ty.zigTypeTag(zcu) == .Fn; |
| 505 | 510 | } |
| 506 | 511 | |
| ... | ... | @@ -590,7 +595,7 @@ pub const Decl = struct { |
| 590 | 595 | @tagName(decl.analysis), |
| 591 | 596 | }); |
| 592 | 597 | if (decl.has_tv) { |
| 593 | std.debug.print(" ty={} val={}", .{ decl.ty, decl.val }); | |
| 598 | std.debug.print(" val={}", .{decl.val}); | |
| 594 | 599 | } |
| 595 | 600 | std.debug.print("\n", .{}); |
| 596 | 601 | } |
| ... | ... | @@ -615,7 +620,7 @@ pub const Decl = struct { |
| 615 | 620 | pub fn getAlignment(decl: Decl, zcu: *Zcu) Alignment { |
| 616 | 621 | assert(decl.has_tv); |
| 617 | 622 | if (decl.alignment != .none) return decl.alignment; |
| 618 | return decl.ty.abiAlignment(zcu); | |
| 623 | return decl.typeOf(zcu).abiAlignment(zcu); | |
| 619 | 624 | } |
| 620 | 625 | |
| 621 | 626 | /// Upgrade a `LazySrcLoc` to a `SrcLoc` based on the `Decl` provided. |
| ... | ... | @@ -3525,7 +3530,6 @@ fn semaFile(mod: *Module, file: *File) SemaError!void { |
| 3525 | 3530 | new_decl.src_line = 0; |
| 3526 | 3531 | new_decl.is_pub = true; |
| 3527 | 3532 | new_decl.is_exported = false; |
| 3528 | new_decl.ty = Type.type; | |
| 3529 | 3533 | new_decl.alignment = .none; |
| 3530 | 3534 | new_decl.@"linksection" = .none; |
| 3531 | 3535 | new_decl.alive = true; // This Decl corresponds to a File and is therefore always alive. |
| ... | ... | @@ -3594,7 +3598,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult { |
| 3594 | 3598 | |
| 3595 | 3599 | const old_has_tv = decl.has_tv; |
| 3596 | 3600 | // The following values are ignored if `!old_has_tv` |
| 3597 | const old_ty = decl.ty; | |
| 3601 | const old_ty = decl.typeOf(mod); | |
| 3598 | 3602 | const old_val = decl.val; |
| 3599 | 3603 | const old_align = decl.alignment; |
| 3600 | 3604 | const old_linksection = decl.@"linksection"; |
| ... | ... | @@ -3716,7 +3720,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult { |
| 3716 | 3720 | return sema.fail(&block_scope, ty_src, "type {} has no namespace", .{ty.fmt(mod)}); |
| 3717 | 3721 | } |
| 3718 | 3722 | |
| 3719 | decl.ty = Type.fromInterned(InternPool.Index.type_type); | |
| 3720 | 3723 | decl.val = ty.toValue(); |
| 3721 | 3724 | decl.alignment = .none; |
| 3722 | 3725 | decl.@"linksection" = .none; |
| ... | ... | @@ -3760,7 +3763,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult { |
| 3760 | 3763 | }, |
| 3761 | 3764 | } |
| 3762 | 3765 | |
| 3763 | decl.ty = decl_tv.ty; | |
| 3764 | 3766 | decl.val = Value.fromInterned((try decl_tv.val.intern(decl_tv.ty, mod))); |
| 3765 | 3767 | // Function linksection, align, and addrspace were already set by Sema |
| 3766 | 3768 | if (!is_func) { |
| ... | ... | @@ -3806,10 +3808,10 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult { |
| 3806 | 3808 | decl.analysis = .complete; |
| 3807 | 3809 | |
| 3808 | 3810 | const result: SemaDeclResult = if (old_has_tv) .{ |
| 3809 | .invalidate_decl_val = !decl.ty.eql(old_ty, mod) or | |
| 3810 | !decl.val.eql(old_val, decl.ty, mod) or | |
| 3811 | .invalidate_decl_val = !decl_tv.ty.eql(old_ty, mod) or | |
| 3812 | !decl.val.eql(old_val, decl_tv.ty, mod) or | |
| 3811 | 3813 | is_inline != old_is_inline, |
| 3812 | .invalidate_decl_ref = !decl.ty.eql(old_ty, mod) or | |
| 3814 | .invalidate_decl_ref = !decl_tv.ty.eql(old_ty, mod) or | |
| 3813 | 3815 | decl.alignment != old_align or |
| 3814 | 3816 | decl.@"linksection" != old_linksection or |
| 3815 | 3817 | decl.@"addrspace" != old_addrspace or |
| ... | ... | @@ -3819,11 +3821,11 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult { |
| 3819 | 3821 | .invalidate_decl_ref = true, |
| 3820 | 3822 | }; |
| 3821 | 3823 | |
| 3822 | const has_runtime_bits = queue_linker_work and (is_func or try sema.typeHasRuntimeBits(decl.ty)); | |
| 3824 | const has_runtime_bits = queue_linker_work and (is_func or try sema.typeHasRuntimeBits(decl_tv.ty)); | |
| 3823 | 3825 | if (has_runtime_bits) { |
| 3824 | 3826 | // Needed for codegen_decl which will call updateDecl and then the |
| 3825 | 3827 | // codegen backend wants full access to the Decl Type. |
| 3826 | try sema.resolveTypeFully(decl.ty); | |
| 3828 | try sema.resolveTypeFully(decl_tv.ty); | |
| 3827 | 3829 | |
| 3828 | 3830 | try mod.comp.work_queue.writeItem(.{ .codegen_decl = decl_index }); |
| 3829 | 3831 | |
| ... | ... | @@ -3850,7 +3852,7 @@ fn semaAnonOwnerDecl(zcu: *Zcu, decl_index: Decl.Index) !SemaDeclResult { |
| 3850 | 3852 | |
| 3851 | 3853 | log.debug("semaAnonOwnerDecl '{d}'", .{@intFromEnum(decl_index)}); |
| 3852 | 3854 | |
| 3853 | switch (decl.ty.zigTypeTag(zcu)) { | |
| 3855 | switch (decl.typeOf(zcu).zigTypeTag(zcu)) { | |
| 3854 | 3856 | .Fn => @panic("TODO: update fn instance"), |
| 3855 | 3857 | .Type => {}, |
| 3856 | 3858 | else => unreachable, |
| ... | ... | @@ -4479,7 +4481,7 @@ pub fn finalizeAnonDecl(mod: *Module, decl_index: Decl.Index) Allocator.Error!vo |
| 4479 | 4481 | // if the Decl is referenced by an instruction or another constant. Otherwise, |
| 4480 | 4482 | // the Decl will be garbage collected by the `codegen_decl` task instead of sent |
| 4481 | 4483 | // to the linker. |
| 4482 | if (mod.declPtr(decl_index).ty.isFnOrHasRuntimeBits(mod)) { | |
| 4484 | if (mod.declPtr(decl_index).typeOf(mod).isFnOrHasRuntimeBits(mod)) { | |
| 4483 | 4485 | try mod.comp.anon_work_queue.writeItem(.{ .codegen_decl = decl_index }); |
| 4484 | 4486 | } |
| 4485 | 4487 | } |
| ... | ... | @@ -4563,7 +4565,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato |
| 4563 | 4565 | // the runtime-known parameters only, not to be confused with the |
| 4564 | 4566 | // generic_owner function type, which potentially has more parameters, |
| 4565 | 4567 | // including comptime parameters. |
| 4566 | const fn_ty = decl.ty; | |
| 4568 | const fn_ty = decl.typeOf(mod); | |
| 4567 | 4569 | const fn_ty_info = mod.typeToFunc(fn_ty).?; |
| 4568 | 4570 | |
| 4569 | 4571 | var sema: Sema = .{ |
| ... | ... | @@ -4812,7 +4814,6 @@ pub fn allocateNewDecl( |
| 4812 | 4814 | .src_line = undefined, |
| 4813 | 4815 | .has_tv = false, |
| 4814 | 4816 | .owns_tv = false, |
| 4815 | .ty = undefined, | |
| 4816 | 4817 | .val = undefined, |
| 4817 | 4818 | .alignment = undefined, |
| 4818 | 4819 | .@"linksection" = .none, |
| ... | ... | @@ -4889,7 +4890,6 @@ pub fn initNewAnonDecl( |
| 4889 | 4890 | |
| 4890 | 4891 | new_decl.name = name; |
| 4891 | 4892 | new_decl.src_line = src_line; |
| 4892 | new_decl.ty = typed_value.ty; | |
| 4893 | 4893 | new_decl.val = typed_value.val; |
| 4894 | 4894 | new_decl.alignment = .none; |
| 4895 | 4895 | new_decl.@"linksection" = .none; |
| ... | ... | @@ -5419,7 +5419,7 @@ pub fn populateTestFunctions( |
| 5419 | 5419 | try mod.ensureDeclAnalyzed(decl_index); |
| 5420 | 5420 | } |
| 5421 | 5421 | const decl = mod.declPtr(decl_index); |
| 5422 | const test_fn_ty = decl.ty.slicePtrFieldType(mod).childType(mod); | |
| 5422 | const test_fn_ty = decl.typeOf(mod).slicePtrFieldType(mod).childType(mod); | |
| 5423 | 5423 | |
| 5424 | 5424 | const array_decl_index = d: { |
| 5425 | 5425 | // Add mod.test_functions to an array decl then make the test_functions |
| ... | ... | @@ -5463,7 +5463,7 @@ pub fn populateTestFunctions( |
| 5463 | 5463 | // func |
| 5464 | 5464 | try mod.intern(.{ .ptr = .{ |
| 5465 | 5465 | .ty = try mod.intern(.{ .ptr_type = .{ |
| 5466 | .child = test_decl.ty.toIntern(), | |
| 5466 | .child = test_decl.typeOf(mod).toIntern(), | |
| 5467 | 5467 | .flags = .{ |
| 5468 | 5468 | .is_const = true, |
| 5469 | 5469 | }, |
| ... | ... | @@ -5515,7 +5515,6 @@ pub fn populateTestFunctions( |
| 5515 | 5515 | |
| 5516 | 5516 | // Since we are replacing the Decl's value we must perform cleanup on the |
| 5517 | 5517 | // previous value. |
| 5518 | decl.ty = new_ty; | |
| 5519 | 5518 | decl.val = new_val; |
| 5520 | 5519 | decl.has_tv = true; |
| 5521 | 5520 | } |
src/Sema.zig+16-17| ... | ... | @@ -6425,16 +6425,17 @@ pub fn analyzeExport( |
| 6425 | 6425 | |
| 6426 | 6426 | try mod.ensureDeclAnalyzed(exported_decl_index); |
| 6427 | 6427 | const exported_decl = mod.declPtr(exported_decl_index); |
| 6428 | const export_ty = exported_decl.typeOf(mod); | |
| 6428 | 6429 | |
| 6429 | if (!try sema.validateExternType(exported_decl.ty, .other)) { | |
| 6430 | if (!try sema.validateExternType(export_ty, .other)) { | |
| 6430 | 6431 | const msg = msg: { |
| 6431 | const msg = try sema.errMsg(block, src, "unable to export type '{}'", .{exported_decl.ty.fmt(mod)}); | |
| 6432 | const msg = try sema.errMsg(block, src, "unable to export type '{}'", .{export_ty.fmt(mod)}); | |
| 6432 | 6433 | errdefer msg.destroy(gpa); |
| 6433 | 6434 | |
| 6434 | 6435 | const src_decl = mod.declPtr(block.src_decl); |
| 6435 | try sema.explainWhyTypeIsNotExtern(msg, src_decl.toSrcLoc(src, mod), exported_decl.ty, .other); | |
| 6436 | try sema.explainWhyTypeIsNotExtern(msg, src_decl.toSrcLoc(src, mod), export_ty, .other); | |
| 6436 | 6437 | |
| 6437 | try sema.addDeclaredHereNote(msg, exported_decl.ty); | |
| 6438 | try sema.addDeclaredHereNote(msg, export_ty); | |
| 6438 | 6439 | break :msg msg; |
| 6439 | 6440 | }; |
| 6440 | 6441 | return sema.failWithOwnedErrorMsg(block, msg); |
| ... | ... | @@ -6503,7 +6504,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 6503 | 6504 | } |
| 6504 | 6505 | |
| 6505 | 6506 | const fn_owner_decl = mod.funcOwnerDeclPtr(sema.func_index); |
| 6506 | switch (fn_owner_decl.ty.fnCallingConvention(mod)) { | |
| 6507 | switch (fn_owner_decl.typeOf(mod).fnCallingConvention(mod)) { | |
| 6507 | 6508 | .Naked => return sema.fail(block, src, "@setAlignStack in naked function", .{}), |
| 6508 | 6509 | .Inline => return sema.fail(block, src, "@setAlignStack in inline function", .{}), |
| 6509 | 6510 | else => if (block.inlining != null) { |
| ... | ... | @@ -7692,7 +7693,7 @@ fn analyzeCall( |
| 7692 | 7693 | // comptime memory is mutated. |
| 7693 | 7694 | const memoized_arg_values = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len); |
| 7694 | 7695 | |
| 7695 | const owner_info = mod.typeToFunc(fn_owner_decl.ty).?; | |
| 7696 | const owner_info = mod.typeToFunc(fn_owner_decl.typeOf(mod)).?; | |
| 7696 | 7697 | const new_param_types = try sema.arena.alloc(InternPool.Index, owner_info.param_types.len); |
| 7697 | 7698 | var new_fn_info: InternPool.GetFuncTypeKey = .{ |
| 7698 | 7699 | .param_types = new_param_types, |
| ... | ... | @@ -7960,9 +7961,9 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ |
| 7960 | 7961 | }); |
| 7961 | 7962 | } |
| 7962 | 7963 | const func_decl = mod.funcOwnerDeclPtr(sema.owner_func_index); |
| 7963 | if (!func_ty.eql(func_decl.ty, mod)) { | |
| 7964 | if (!func_ty.eql(func_decl.typeOf(mod), mod)) { | |
| 7964 | 7965 | return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{}' does not match type of calling function '{}'", .{ |
| 7965 | func_ty.fmt(mod), func_decl.ty.fmt(mod), | |
| 7966 | func_ty.fmt(mod), func_decl.typeOf(mod).fmt(mod), | |
| 7966 | 7967 | }); |
| 7967 | 7968 | } |
| 7968 | 7969 | _ = try block.addUnOp(.ret, result); |
| ... | ... | @@ -26641,7 +26642,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { |
| 26641 | 26642 | // decl_index may be an alias; we must find the decl that actually |
| 26642 | 26643 | // owns the function. |
| 26643 | 26644 | try sema.ensureDeclAnalyzed(decl_index); |
| 26644 | const tv = try mod.declPtr(decl_index).typedValue(); | |
| 26645 | const tv = try mod.declPtr(decl_index).typedValue(mod); | |
| 26645 | 26646 | try sema.declareDependency(.{ .decl_val = decl_index }); |
| 26646 | 26647 | assert(tv.ty.zigTypeTag(mod) == .Fn); |
| 26647 | 26648 | assert(try sema.fnHasRuntimeBits(tv.ty)); |
| ... | ... | @@ -31374,16 +31375,16 @@ fn beginComptimePtrLoad( |
| 31374 | 31375 | .ptr => |ptr| switch (ptr.addr) { |
| 31375 | 31376 | .decl => |decl_index| blk: { |
| 31376 | 31377 | const decl = mod.declPtr(decl_index); |
| 31377 | const decl_tv = try decl.typedValue(); | |
| 31378 | const decl_tv = try decl.typedValue(mod); | |
| 31378 | 31379 | try sema.declareDependency(.{ .decl_val = decl_index }); |
| 31379 | 31380 | if (decl.val.getVariable(mod) != null) return error.RuntimeLoad; |
| 31380 | 31381 | |
| 31381 | const layout_defined = decl.ty.hasWellDefinedLayout(mod); | |
| 31382 | const layout_defined = decl.typeOf(mod).hasWellDefinedLayout(mod); | |
| 31382 | 31383 | break :blk ComptimePtrLoadKit{ |
| 31383 | 31384 | .parent = if (layout_defined) .{ .tv = decl_tv, .byte_offset = 0 } else null, |
| 31384 | 31385 | .pointee = decl_tv, |
| 31385 | 31386 | .is_mutable = false, |
| 31386 | .ty_without_well_defined_layout = if (!layout_defined) decl.ty else null, | |
| 31387 | .ty_without_well_defined_layout = if (!layout_defined) decl.typeOf(mod) else null, | |
| 31387 | 31388 | }; |
| 31388 | 31389 | }, |
| 31389 | 31390 | .comptime_alloc => |alloc_index| kit: { |
| ... | ... | @@ -32668,7 +32669,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: InternPool.DeclIndex, analyze_fn |
| 32668 | 32669 | const mod = sema.mod; |
| 32669 | 32670 | try sema.ensureDeclAnalyzed(decl_index); |
| 32670 | 32671 | |
| 32671 | const decl_tv = try mod.declPtr(decl_index).typedValue(); | |
| 32672 | const decl_tv = try mod.declPtr(decl_index).typedValue(mod); | |
| 32672 | 32673 | const owner_decl = mod.declPtr(switch (mod.intern_pool.indexToKey(decl_tv.val.toIntern())) { |
| 32673 | 32674 | .variable => |variable| variable.decl, |
| 32674 | 32675 | .extern_func => |extern_func| extern_func.decl, |
| ... | ... | @@ -32697,7 +32698,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: InternPool.DeclIndex, analyze_fn |
| 32697 | 32698 | fn maybeQueueFuncBodyAnalysis(sema: *Sema, decl_index: InternPool.DeclIndex) !void { |
| 32698 | 32699 | const mod = sema.mod; |
| 32699 | 32700 | const decl = mod.declPtr(decl_index); |
| 32700 | const tv = try decl.typedValue(); | |
| 32701 | const tv = try decl.typedValue(mod); | |
| 32701 | 32702 | if (tv.ty.zigTypeTag(mod) != .Fn) return; |
| 32702 | 32703 | if (!try sema.fnHasRuntimeBits(tv.ty)) return; |
| 32703 | 32704 | const func_index = tv.val.toIntern(); |
| ... | ... | @@ -36611,7 +36612,7 @@ fn resolveInferredErrorSet( |
| 36611 | 36612 | // inferred error sets, each call gets an adhoc InferredErrorSet object, which |
| 36612 | 36613 | // has no corresponding function body. |
| 36613 | 36614 | const ies_func_owner_decl = mod.declPtr(func.owner_decl); |
| 36614 | const ies_func_info = mod.typeToFunc(ies_func_owner_decl.ty).?; | |
| 36615 | const ies_func_info = mod.typeToFunc(ies_func_owner_decl.typeOf(mod)).?; | |
| 36615 | 36616 | // if ies declared by a inline function with generic return type, the return_type should be generic_poison, |
| 36616 | 36617 | // because inline function does not create a new declaration, and the ies has been filled with analyzeCall, |
| 36617 | 36618 | // so here we can simply skip this case. |
| ... | ... | @@ -37629,7 +37630,6 @@ fn generateUnionTagTypeNumbered( |
| 37629 | 37630 | .tag_mode = .explicit, |
| 37630 | 37631 | }); |
| 37631 | 37632 | |
| 37632 | new_decl.ty = Type.type; | |
| 37633 | 37633 | new_decl.val = Value.fromInterned(enum_ty); |
| 37634 | 37634 | |
| 37635 | 37635 | try mod.finalizeAnonDecl(new_decl_index); |
| ... | ... | @@ -37675,7 +37675,6 @@ fn generateUnionTagTypeSimple( |
| 37675 | 37675 | |
| 37676 | 37676 | const new_decl = mod.declPtr(new_decl_index); |
| 37677 | 37677 | new_decl.owns_tv = true; |
| 37678 | new_decl.ty = Type.type; | |
| 37679 | 37678 | new_decl.val = Value.fromInterned(enum_ty); |
| 37680 | 37679 | |
| 37681 | 37680 | try mod.finalizeAnonDecl(new_decl_index); |
src/TypedValue.zig+1-1| ... | ... | @@ -315,7 +315,7 @@ pub fn print( |
| 315 | 315 | const decl = mod.declPtr(decl_index); |
| 316 | 316 | if (level == 0) return writer.print("(decl '{}')", .{decl.name.fmt(ip)}); |
| 317 | 317 | return print(.{ |
| 318 | .ty = decl.ty, | |
| 318 | .ty = decl.typeOf(mod), | |
| 319 | 319 | .val = decl.val, |
| 320 | 320 | }, writer, level - 1, mod); |
| 321 | 321 | }, |
src/Value.zig+1-1| ... | ... | @@ -1585,7 +1585,7 @@ pub fn sliceLen(val: Value, mod: *Module) u64 { |
| 1585 | 1585 | const ip = &mod.intern_pool; |
| 1586 | 1586 | return switch (ip.indexToKey(val.toIntern())) { |
| 1587 | 1587 | .ptr => |ptr| switch (ip.indexToKey(switch (ptr.addr) { |
| 1588 | .decl => |decl| mod.declPtr(decl).ty.toIntern(), | |
| 1588 | .decl => |decl| mod.declPtr(decl).typeOf(mod).toIntern(), | |
| 1589 | 1589 | .comptime_alloc => @panic("TODO"), |
| 1590 | 1590 | .anon_decl => |anon_decl| ip.typeOf(anon_decl.val), |
| 1591 | 1591 | .comptime_field => |comptime_field| ip.typeOf(comptime_field), |
src/arch/aarch64/CodeGen.zig+1-1| ... | ... | @@ -342,7 +342,7 @@ pub fn generate( |
| 342 | 342 | const func = zcu.funcInfo(func_index); |
| 343 | 343 | const fn_owner_decl = zcu.declPtr(func.owner_decl); |
| 344 | 344 | assert(fn_owner_decl.has_tv); |
| 345 | const fn_type = fn_owner_decl.ty; | |
| 345 | const fn_type = fn_owner_decl.typeOf(zcu); | |
| 346 | 346 | const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace); |
| 347 | 347 | const target = &namespace.file_scope.mod.resolved_target.result; |
| 348 | 348 |
src/arch/arm/CodeGen.zig+1-1| ... | ... | @@ -349,7 +349,7 @@ pub fn generate( |
| 349 | 349 | const func = zcu.funcInfo(func_index); |
| 350 | 350 | const fn_owner_decl = zcu.declPtr(func.owner_decl); |
| 351 | 351 | assert(fn_owner_decl.has_tv); |
| 352 | const fn_type = fn_owner_decl.ty; | |
| 352 | const fn_type = fn_owner_decl.typeOf(zcu); | |
| 353 | 353 | const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace); |
| 354 | 354 | const target = &namespace.file_scope.mod.resolved_target.result; |
| 355 | 355 |
src/arch/riscv64/CodeGen.zig+1-1| ... | ... | @@ -230,7 +230,7 @@ pub fn generate( |
| 230 | 230 | const func = zcu.funcInfo(func_index); |
| 231 | 231 | const fn_owner_decl = zcu.declPtr(func.owner_decl); |
| 232 | 232 | assert(fn_owner_decl.has_tv); |
| 233 | const fn_type = fn_owner_decl.ty; | |
| 233 | const fn_type = fn_owner_decl.typeOf(zcu); | |
| 234 | 234 | const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace); |
| 235 | 235 | const target = &namespace.file_scope.mod.resolved_target.result; |
| 236 | 236 |
src/arch/sparc64/CodeGen.zig+1-1| ... | ... | @@ -273,7 +273,7 @@ pub fn generate( |
| 273 | 273 | const func = zcu.funcInfo(func_index); |
| 274 | 274 | const fn_owner_decl = zcu.declPtr(func.owner_decl); |
| 275 | 275 | assert(fn_owner_decl.has_tv); |
| 276 | const fn_type = fn_owner_decl.ty; | |
| 276 | const fn_type = fn_owner_decl.typeOf(zcu); | |
| 277 | 277 | const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace); |
| 278 | 278 | const target = &namespace.file_scope.mod.resolved_target.result; |
| 279 | 279 |
src/arch/wasm/CodeGen.zig+11-10| ... | ... | @@ -1243,12 +1243,12 @@ pub fn generate( |
| 1243 | 1243 | fn genFunc(func: *CodeGen) InnerError!void { |
| 1244 | 1244 | const mod = func.bin_file.base.comp.module.?; |
| 1245 | 1245 | const ip = &mod.intern_pool; |
| 1246 | const fn_info = mod.typeToFunc(func.decl.ty).?; | |
| 1246 | const fn_info = mod.typeToFunc(func.decl.typeOf(mod)).?; | |
| 1247 | 1247 | var func_type = try genFunctype(func.gpa, fn_info.cc, fn_info.param_types.get(ip), Type.fromInterned(fn_info.return_type), mod); |
| 1248 | 1248 | defer func_type.deinit(func.gpa); |
| 1249 | 1249 | _ = try func.bin_file.storeDeclType(func.decl_index, func_type); |
| 1250 | 1250 | |
| 1251 | var cc_result = try func.resolveCallingConventionValues(func.decl.ty); | |
| 1251 | var cc_result = try func.resolveCallingConventionValues(func.decl.typeOf(mod)); | |
| 1252 | 1252 | defer cc_result.deinit(func.gpa); |
| 1253 | 1253 | |
| 1254 | 1254 | func.args = cc_result.args; |
| ... | ... | @@ -2087,7 +2087,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2087 | 2087 | const mod = func.bin_file.base.comp.module.?; |
| 2088 | 2088 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 2089 | 2089 | const operand = try func.resolveInst(un_op); |
| 2090 | const fn_info = mod.typeToFunc(func.decl.ty).?; | |
| 2090 | const fn_info = mod.typeToFunc(func.decl.typeOf(mod)).?; | |
| 2091 | 2091 | const ret_ty = Type.fromInterned(fn_info.return_type); |
| 2092 | 2092 | |
| 2093 | 2093 | // result must be stored in the stack and we return a pointer |
| ... | ... | @@ -2135,7 +2135,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2135 | 2135 | break :result try func.allocStack(Type.usize); // create pointer to void |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | const fn_info = mod.typeToFunc(func.decl.ty).?; | |
| 2138 | const fn_info = mod.typeToFunc(func.decl.typeOf(mod)).?; | |
| 2139 | 2139 | if (firstParamSRet(fn_info.cc, Type.fromInterned(fn_info.return_type), mod)) { |
| 2140 | 2140 | break :result func.return_value; |
| 2141 | 2141 | } |
| ... | ... | @@ -2152,7 +2152,7 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2152 | 2152 | const operand = try func.resolveInst(un_op); |
| 2153 | 2153 | const ret_ty = func.typeOf(un_op).childType(mod); |
| 2154 | 2154 | |
| 2155 | const fn_info = mod.typeToFunc(func.decl.ty).?; | |
| 2155 | const fn_info = mod.typeToFunc(func.decl.typeOf(mod)).?; | |
| 2156 | 2156 | if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 2157 | 2157 | if (ret_ty.isError(mod)) { |
| 2158 | 2158 | try func.addImm32(0); |
| ... | ... | @@ -2193,7 +2193,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 2193 | 2193 | break :blk function.owner_decl; |
| 2194 | 2194 | } else if (func_val.getExternFunc(mod)) |extern_func| { |
| 2195 | 2195 | const ext_decl = mod.declPtr(extern_func.decl); |
| 2196 | const ext_info = mod.typeToFunc(ext_decl.ty).?; | |
| 2196 | const ext_info = mod.typeToFunc(ext_decl.typeOf(mod)).?; | |
| 2197 | 2197 | var func_type = try genFunctype(func.gpa, ext_info.cc, ext_info.param_types.get(ip), Type.fromInterned(ext_info.return_type), mod); |
| 2198 | 2198 | defer func_type.deinit(func.gpa); |
| 2199 | 2199 | const atom_index = try func.bin_file.getOrCreateAtomForDecl(extern_func.decl); |
| ... | ... | @@ -2530,7 +2530,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2530 | 2530 | const mod = func.bin_file.base.comp.module.?; |
| 2531 | 2531 | const arg_index = func.arg_index; |
| 2532 | 2532 | const arg = func.args[arg_index]; |
| 2533 | const cc = mod.typeToFunc(func.decl.ty).?.cc; | |
| 2533 | const cc = mod.typeToFunc(func.decl.typeOf(mod)).?.cc; | |
| 2534 | 2534 | const arg_ty = func.typeOfIndex(inst); |
| 2535 | 2535 | if (cc == .C) { |
| 2536 | 2536 | const arg_classes = abi.classifyType(arg_ty, mod); |
| ... | ... | @@ -3122,7 +3122,7 @@ fn lowerParentPtrDecl(func: *CodeGen, ptr_val: Value, decl_index: InternPool.Dec |
| 3122 | 3122 | const mod = func.bin_file.base.comp.module.?; |
| 3123 | 3123 | const decl = mod.declPtr(decl_index); |
| 3124 | 3124 | try mod.markDeclAlive(decl); |
| 3125 | const ptr_ty = try mod.singleMutPtrType(decl.ty); | |
| 3125 | const ptr_ty = try mod.singleMutPtrType(decl.typeOf(mod)); | |
| 3126 | 3126 | return func.lowerDeclRefValue(.{ .ty = ptr_ty, .val = ptr_val }, decl_index, offset); |
| 3127 | 3127 | } |
| 3128 | 3128 | |
| ... | ... | @@ -3173,7 +3173,8 @@ fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: InternPool.Decl |
| 3173 | 3173 | return func.lowerDeclRefValue(tv, func_val.decl, offset); |
| 3174 | 3174 | } |
| 3175 | 3175 | } |
| 3176 | if (decl.ty.zigTypeTag(mod) != .Fn and !decl.ty.hasRuntimeBitsIgnoreComptime(mod)) { | |
| 3176 | const decl_ty = decl.typeOf(mod); | |
| 3177 | if (decl_ty.zigTypeTag(mod) != .Fn and !decl_ty.hasRuntimeBitsIgnoreComptime(mod)) { | |
| 3177 | 3178 | return WValue{ .imm32 = 0xaaaaaaaa }; |
| 3178 | 3179 | } |
| 3179 | 3180 | |
| ... | ... | @@ -3182,7 +3183,7 @@ fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: InternPool.Decl |
| 3182 | 3183 | const atom = func.bin_file.getAtom(atom_index); |
| 3183 | 3184 | |
| 3184 | 3185 | const target_sym_index = @intFromEnum(atom.sym_index); |
| 3185 | if (decl.ty.zigTypeTag(mod) == .Fn) { | |
| 3186 | if (decl_ty.zigTypeTag(mod) == .Fn) { | |
| 3186 | 3187 | return WValue{ .function_index = target_sym_index }; |
| 3187 | 3188 | } else if (offset == 0) { |
| 3188 | 3189 | return WValue{ .memory = target_sym_index }; |
src/arch/x86_64/CodeGen.zig+1-1| ... | ... | @@ -808,7 +808,7 @@ pub fn generate( |
| 808 | 808 | const func = zcu.funcInfo(func_index); |
| 809 | 809 | const fn_owner_decl = zcu.declPtr(func.owner_decl); |
| 810 | 810 | assert(fn_owner_decl.has_tv); |
| 811 | const fn_type = fn_owner_decl.ty; | |
| 811 | const fn_type = fn_owner_decl.typeOf(zcu); | |
| 812 | 812 | const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace); |
| 813 | 813 | const mod = namespace.file_scope.mod; |
| 814 | 814 |
src/codegen.zig+3-3| ... | ... | @@ -829,8 +829,8 @@ fn lowerDeclRef( |
| 829 | 829 | const target = namespace.file_scope.mod.resolved_target.result; |
| 830 | 830 | |
| 831 | 831 | const ptr_width = target.ptrBitWidth(); |
| 832 | const is_fn_body = decl.ty.zigTypeTag(zcu) == .Fn; | |
| 833 | if (!is_fn_body and !decl.ty.hasRuntimeBits(zcu)) { | |
| 832 | const is_fn_body = decl.typeOf(zcu).zigTypeTag(zcu) == .Fn; | |
| 833 | if (!is_fn_body and !decl.typeOf(zcu).hasRuntimeBits(zcu)) { | |
| 834 | 834 | try code.appendNTimes(0xaa, @divExact(ptr_width, 8)); |
| 835 | 835 | return Result.ok; |
| 836 | 836 | } |
| ... | ... | @@ -932,7 +932,7 @@ fn genDeclRef( |
| 932 | 932 | }; |
| 933 | 933 | const decl = zcu.declPtr(decl_index); |
| 934 | 934 | |
| 935 | if (!decl.ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) { | |
| 935 | if (!decl.typeOf(zcu).isFnOrHasRuntimeBitsIgnoreComptime(zcu)) { | |
| 936 | 936 | const imm: u64 = switch (ptr_bytes) { |
| 937 | 937 | 1 => 0xaa, |
| 938 | 938 | 2 => 0xaaaa, |
src/codegen/c.zig+14-13| ... | ... | @@ -657,7 +657,7 @@ pub const DeclGen = struct { |
| 657 | 657 | assert(decl.has_tv); |
| 658 | 658 | |
| 659 | 659 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. |
| 660 | if (ty.isPtrAtRuntime(mod) and !decl.ty.isFnOrHasRuntimeBits(mod)) { | |
| 660 | if (ty.isPtrAtRuntime(mod) and !decl.typeOf(mod).isFnOrHasRuntimeBits(mod)) { | |
| 661 | 661 | return dg.writeCValue(writer, .{ .undef = ty }); |
| 662 | 662 | } |
| 663 | 663 | |
| ... | ... | @@ -673,7 +673,7 @@ pub const DeclGen = struct { |
| 673 | 673 | // them). The analysis until now should ensure that the C function |
| 674 | 674 | // pointers are compatible. If they are not, then there is a bug |
| 675 | 675 | // somewhere and we should let the C compiler tell us about it. |
| 676 | const need_typecast = if (ty.castPtrToFn(mod)) |_| false else !ty.childType(mod).eql(decl.ty, mod); | |
| 676 | const need_typecast = if (ty.castPtrToFn(mod)) |_| false else !ty.childType(mod).eql(decl.typeOf(mod), mod); | |
| 677 | 677 | if (need_typecast) { |
| 678 | 678 | try writer.writeAll("(("); |
| 679 | 679 | try dg.renderType(writer, ty); |
| ... | ... | @@ -1588,9 +1588,10 @@ pub const DeclGen = struct { |
| 1588 | 1588 | const ip = &mod.intern_pool; |
| 1589 | 1589 | |
| 1590 | 1590 | const fn_decl = mod.declPtr(fn_decl_index); |
| 1591 | const fn_cty_idx = try dg.typeToIndex(fn_decl.ty, kind); | |
| 1591 | const fn_ty = fn_decl.typeOf(mod); | |
| 1592 | const fn_cty_idx = try dg.typeToIndex(fn_ty, kind); | |
| 1592 | 1593 | |
| 1593 | const fn_info = mod.typeToFunc(fn_decl.ty).?; | |
| 1594 | const fn_info = mod.typeToFunc(fn_ty).?; | |
| 1594 | 1595 | if (fn_info.cc == .Naked) { |
| 1595 | 1596 | switch (kind) { |
| 1596 | 1597 | .forward => try w.writeAll("zig_naked_decl "), |
| ... | ... | @@ -1971,7 +1972,7 @@ pub const DeclGen = struct { |
| 1971 | 1972 | ) !void { |
| 1972 | 1973 | const decl = dg.module.declPtr(decl_index); |
| 1973 | 1974 | const fwd = dg.fwdDeclWriter(); |
| 1974 | const is_global = variable.is_extern or dg.declIsGlobal(.{ .ty = decl.ty, .val = decl.val }); | |
| 1975 | const is_global = variable.is_extern or dg.declIsGlobal(.{ .ty = decl.typeOf(dg.module), .val = decl.val }); | |
| 1975 | 1976 | try fwd.writeAll(if (is_global) "zig_extern " else "static "); |
| 1976 | 1977 | const maybe_exports = dg.module.decl_exports.get(decl_index); |
| 1977 | 1978 | const export_weak_linkage = if (maybe_exports) |exports| |
| ... | ... | @@ -1982,7 +1983,7 @@ pub const DeclGen = struct { |
| 1982 | 1983 | if (variable.is_threadlocal) try fwd.writeAll("zig_threadlocal "); |
| 1983 | 1984 | try dg.renderTypeAndName( |
| 1984 | 1985 | fwd, |
| 1985 | decl.ty, | |
| 1986 | decl.typeOf(dg.module), | |
| 1986 | 1987 | .{ .decl = decl_index }, |
| 1987 | 1988 | CQualifiers.init(.{ .@"const" = variable.is_const }), |
| 1988 | 1989 | decl.alignment, |
| ... | ... | @@ -2656,7 +2657,7 @@ fn genExports(o: *Object) !void { |
| 2656 | 2657 | .anon, .flush => return, |
| 2657 | 2658 | }; |
| 2658 | 2659 | const decl = mod.declPtr(decl_index); |
| 2659 | const tv: TypedValue = .{ .ty = decl.ty, .val = Value.fromInterned((try decl.internValue(mod))) }; | |
| 2660 | const tv: TypedValue = .{ .ty = decl.typeOf(mod), .val = Value.fromInterned((try decl.internValue(mod))) }; | |
| 2660 | 2661 | const fwd = o.dg.fwdDeclWriter(); |
| 2661 | 2662 | |
| 2662 | 2663 | const exports = mod.decl_exports.get(decl_index) orelse return; |
| ... | ... | @@ -2687,7 +2688,7 @@ fn genExports(o: *Object) !void { |
| 2687 | 2688 | const export_name = ip.stringToSlice(@"export".opts.name); |
| 2688 | 2689 | try o.dg.renderTypeAndName( |
| 2689 | 2690 | fwd, |
| 2690 | decl.ty, | |
| 2691 | decl.typeOf(mod), | |
| 2691 | 2692 | .{ .identifier = export_name }, |
| 2692 | 2693 | CQualifiers.init(.{ .@"const" = is_variable_const }), |
| 2693 | 2694 | decl.alignment, |
| ... | ... | @@ -2769,7 +2770,7 @@ pub fn genLazyFn(o: *Object, lazy_fn: LazyFnMap.Entry) !void { |
| 2769 | 2770 | }, |
| 2770 | 2771 | .never_tail, .never_inline => |fn_decl_index| { |
| 2771 | 2772 | const fn_decl = mod.declPtr(fn_decl_index); |
| 2772 | const fn_cty = try o.dg.typeToCType(fn_decl.ty, .complete); | |
| 2773 | const fn_cty = try o.dg.typeToCType(fn_decl.typeOf(mod), .complete); | |
| 2773 | 2774 | const fn_info = fn_cty.cast(CType.Payload.Function).?.data; |
| 2774 | 2775 | |
| 2775 | 2776 | const fwd_decl_writer = o.dg.fwdDeclWriter(); |
| ... | ... | @@ -2806,7 +2807,7 @@ pub fn genFunc(f: *Function) !void { |
| 2806 | 2807 | const decl_index = o.dg.pass.decl; |
| 2807 | 2808 | const decl = mod.declPtr(decl_index); |
| 2808 | 2809 | const tv: TypedValue = .{ |
| 2809 | .ty = decl.ty, | |
| 2810 | .ty = decl.typeOf(mod), | |
| 2810 | 2811 | .val = decl.val, |
| 2811 | 2812 | }; |
| 2812 | 2813 | |
| ... | ... | @@ -2893,7 +2894,7 @@ pub fn genDecl(o: *Object) !void { |
| 2893 | 2894 | const mod = o.dg.module; |
| 2894 | 2895 | const decl_index = o.dg.pass.decl; |
| 2895 | 2896 | const decl = mod.declPtr(decl_index); |
| 2896 | const tv: TypedValue = .{ .ty = decl.ty, .val = Value.fromInterned((try decl.internValue(mod))) }; | |
| 2897 | const tv: TypedValue = .{ .ty = decl.typeOf(mod), .val = Value.fromInterned((try decl.internValue(mod))) }; | |
| 2897 | 2898 | |
| 2898 | 2899 | if (!tv.ty.isFnOrHasRuntimeBitsIgnoreComptime(mod)) return; |
| 2899 | 2900 | if (tv.val.getExternFunc(mod)) |_| { |
| ... | ... | @@ -2979,7 +2980,7 @@ pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void { |
| 2979 | 2980 | const decl_index = dg.pass.decl; |
| 2980 | 2981 | const decl = mod.declPtr(decl_index); |
| 2981 | 2982 | const tv: TypedValue = .{ |
| 2982 | .ty = decl.ty, | |
| 2983 | .ty = decl.typeOf(mod), | |
| 2983 | 2984 | .val = decl.val, |
| 2984 | 2985 | }; |
| 2985 | 2986 | const writer = dg.fwdDeclWriter(); |
| ... | ... | @@ -7392,7 +7393,7 @@ fn airCVaStart(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7392 | 7393 | const inst_ty = f.typeOfIndex(inst); |
| 7393 | 7394 | const decl_index = f.object.dg.pass.decl; |
| 7394 | 7395 | const decl = mod.declPtr(decl_index); |
| 7395 | const fn_cty = try f.typeToCType(decl.ty, .complete); | |
| 7396 | const fn_cty = try f.typeToCType(decl.typeOf(mod), .complete); | |
| 7396 | 7397 | const param_len = fn_cty.castTag(.varargs_function).?.data.param_types.len; |
| 7397 | 7398 | |
| 7398 | 7399 | const writer = f.object.writer(); |
src/codegen/llvm.zig+14-13| ... | ... | @@ -1384,7 +1384,7 @@ pub const Object = struct { |
| 1384 | 1384 | const decl = zcu.declPtr(decl_index); |
| 1385 | 1385 | const namespace = zcu.namespacePtr(decl.src_namespace); |
| 1386 | 1386 | const owner_mod = namespace.file_scope.mod; |
| 1387 | const fn_info = zcu.typeToFunc(decl.ty).?; | |
| 1387 | const fn_info = zcu.typeToFunc(decl.typeOf(zcu)).?; | |
| 1388 | 1388 | const target = zcu.getTarget(); |
| 1389 | 1389 | const ip = &zcu.intern_pool; |
| 1390 | 1390 | |
| ... | ... | @@ -1659,7 +1659,7 @@ pub const Object = struct { |
| 1659 | 1659 | const line_number = decl.src_line + 1; |
| 1660 | 1660 | const is_internal_linkage = decl.val.getExternFunc(zcu) == null and |
| 1661 | 1661 | !zcu.decl_exports.contains(decl_index); |
| 1662 | const debug_decl_type = try o.lowerDebugType(decl.ty); | |
| 1662 | const debug_decl_type = try o.lowerDebugType(decl.typeOf(zcu)); | |
| 1663 | 1663 | |
| 1664 | 1664 | const subprogram = try o.builder.debugSubprogram( |
| 1665 | 1665 | file, |
| ... | ... | @@ -2881,7 +2881,7 @@ pub const Object = struct { |
| 2881 | 2881 | const decl = zcu.declPtr(decl_index); |
| 2882 | 2882 | const namespace = zcu.namespacePtr(decl.src_namespace); |
| 2883 | 2883 | const owner_mod = namespace.file_scope.mod; |
| 2884 | const zig_fn_type = decl.ty; | |
| 2884 | const zig_fn_type = decl.typeOf(zcu); | |
| 2885 | 2885 | const gop = try o.decl_map.getOrPut(gpa, decl_index); |
| 2886 | 2886 | if (gop.found_existing) return gop.value_ptr.ptr(&o.builder).kind.function; |
| 2887 | 2887 | |
| ... | ... | @@ -3112,7 +3112,7 @@ pub const Object = struct { |
| 3112 | 3112 | try o.builder.strtabString(mod.intern_pool.stringToSlice( |
| 3113 | 3113 | if (is_extern) decl.name else try decl.fullyQualifiedName(mod), |
| 3114 | 3114 | )), |
| 3115 | try o.lowerType(decl.ty), | |
| 3115 | try o.lowerType(decl.typeOf(mod)), | |
| 3116 | 3116 | toLlvmGlobalAddressSpace(decl.@"addrspace", mod.getTarget()), |
| 3117 | 3117 | ); |
| 3118 | 3118 | gop.value_ptr.* = variable_index.ptrConst(&o.builder).global; |
| ... | ... | @@ -4263,7 +4263,7 @@ pub const Object = struct { |
| 4263 | 4263 | const mod = o.module; |
| 4264 | 4264 | const decl = mod.declPtr(decl_index); |
| 4265 | 4265 | try mod.markDeclAlive(decl); |
| 4266 | const ptr_ty = try mod.singleMutPtrType(decl.ty); | |
| 4266 | const ptr_ty = try mod.singleMutPtrType(decl.typeOf(mod)); | |
| 4267 | 4267 | return o.lowerDeclRefValue(ptr_ty, decl_index); |
| 4268 | 4268 | } |
| 4269 | 4269 | |
| ... | ... | @@ -4450,9 +4450,10 @@ pub const Object = struct { |
| 4450 | 4450 | } |
| 4451 | 4451 | } |
| 4452 | 4452 | |
| 4453 | const is_fn_body = decl.ty.zigTypeTag(mod) == .Fn; | |
| 4454 | if ((!is_fn_body and !decl.ty.hasRuntimeBits(mod)) or | |
| 4455 | (is_fn_body and mod.typeToFunc(decl.ty).?.is_generic)) return o.lowerPtrToVoid(ty); | |
| 4453 | const decl_ty = decl.typeOf(mod); | |
| 4454 | const is_fn_body = decl_ty.zigTypeTag(mod) == .Fn; | |
| 4455 | if ((!is_fn_body and !decl_ty.hasRuntimeBits(mod)) or | |
| 4456 | (is_fn_body and mod.typeToFunc(decl_ty).?.is_generic)) return o.lowerPtrToVoid(ty); | |
| 4456 | 4457 | |
| 4457 | 4458 | try mod.markDeclAlive(decl); |
| 4458 | 4459 | |
| ... | ... | @@ -4740,7 +4741,7 @@ pub const DeclGen = struct { |
| 4740 | 4741 | debug_file, // File |
| 4741 | 4742 | debug_file, // Scope |
| 4742 | 4743 | line_number, |
| 4743 | try o.lowerDebugType(decl.ty), | |
| 4744 | try o.lowerDebugType(decl.typeOf(zcu)), | |
| 4744 | 4745 | variable_index, |
| 4745 | 4746 | .{ .local = is_internal_linkage }, |
| 4746 | 4747 | ); |
| ... | ... | @@ -5530,7 +5531,7 @@ pub const FuncGen = struct { |
| 5530 | 5531 | const mod = o.module; |
| 5531 | 5532 | const msg_decl_index = mod.panic_messages[@intFromEnum(panic_id)].unwrap().?; |
| 5532 | 5533 | const msg_decl = mod.declPtr(msg_decl_index); |
| 5533 | const msg_len = msg_decl.ty.childType(mod).arrayLen(mod); | |
| 5534 | const msg_len = msg_decl.typeOf(mod).childType(mod).arrayLen(mod); | |
| 5534 | 5535 | const msg_ptr = try o.lowerValue(try msg_decl.internValue(mod)); |
| 5535 | 5536 | const null_opt_addr_global = try fg.resolveNullOptUsize(); |
| 5536 | 5537 | const target = mod.getTarget(); |
| ... | ... | @@ -5544,7 +5545,7 @@ pub const FuncGen = struct { |
| 5544 | 5545 | // ) |
| 5545 | 5546 | const panic_func = mod.funcInfo(mod.panic_func_index); |
| 5546 | 5547 | const panic_decl = mod.declPtr(panic_func.owner_decl); |
| 5547 | const fn_info = mod.typeToFunc(panic_decl.ty).?; | |
| 5548 | const fn_info = mod.typeToFunc(panic_decl.typeOf(mod)).?; | |
| 5548 | 5549 | const panic_global = try o.resolveLlvmFunction(panic_func.owner_decl); |
| 5549 | 5550 | _ = try fg.wip.call( |
| 5550 | 5551 | .normal, |
| ... | ... | @@ -5612,7 +5613,7 @@ pub const FuncGen = struct { |
| 5612 | 5613 | _ = try self.wip.retVoid(); |
| 5613 | 5614 | return .none; |
| 5614 | 5615 | } |
| 5615 | const fn_info = mod.typeToFunc(self.dg.decl.ty).?; | |
| 5616 | const fn_info = mod.typeToFunc(self.dg.decl.typeOf(mod)).?; | |
| 5616 | 5617 | if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 5617 | 5618 | if (Type.fromInterned(fn_info.return_type).isError(mod)) { |
| 5618 | 5619 | // Functions with an empty error set are emitted with an error code |
| ... | ... | @@ -5674,7 +5675,7 @@ pub const FuncGen = struct { |
| 5674 | 5675 | const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 5675 | 5676 | const ptr_ty = self.typeOf(un_op); |
| 5676 | 5677 | const ret_ty = ptr_ty.childType(mod); |
| 5677 | const fn_info = mod.typeToFunc(self.dg.decl.ty).?; | |
| 5678 | const fn_info = mod.typeToFunc(self.dg.decl.typeOf(mod)).?; | |
| 5678 | 5679 | if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 5679 | 5680 | if (Type.fromInterned(fn_info.return_type).isError(mod)) { |
| 5680 | 5681 | // Functions with an empty error set are emitted with an error code |
src/codegen/spirv.zig+10-10| ... | ... | @@ -1221,7 +1221,7 @@ const DeclGen = struct { |
| 1221 | 1221 | else => {}, |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | if (!decl.ty.isFnOrHasRuntimeBitsIgnoreComptime(mod)) { | |
| 1224 | if (!decl.typeOf(mod).isFnOrHasRuntimeBitsIgnoreComptime(mod)) { | |
| 1225 | 1225 | // Pointer to nothing - return undefined. |
| 1226 | 1226 | return self.spv.constUndef(ty_ref); |
| 1227 | 1227 | } |
| ... | ... | @@ -1237,7 +1237,7 @@ const DeclGen = struct { |
| 1237 | 1237 | const final_storage_class = self.spvStorageClass(decl.@"addrspace"); |
| 1238 | 1238 | try self.addFunctionDep(spv_decl_index, final_storage_class); |
| 1239 | 1239 | |
| 1240 | const decl_ptr_ty_ref = try self.ptrType(decl.ty, final_storage_class); | |
| 1240 | const decl_ptr_ty_ref = try self.ptrType(decl.typeOf(mod), final_storage_class); | |
| 1241 | 1241 | |
| 1242 | 1242 | const ptr_id = switch (final_storage_class) { |
| 1243 | 1243 | .Generic => try self.castToGeneric(self.typeId(decl_ptr_ty_ref), decl_id), |
| ... | ... | @@ -2044,11 +2044,11 @@ const DeclGen = struct { |
| 2044 | 2044 | |
| 2045 | 2045 | switch (self.spv.declPtr(spv_decl_index).kind) { |
| 2046 | 2046 | .func => { |
| 2047 | assert(decl.ty.zigTypeTag(mod) == .Fn); | |
| 2048 | const fn_info = mod.typeToFunc(decl.ty).?; | |
| 2047 | assert(decl.typeOf(mod).zigTypeTag(mod) == .Fn); | |
| 2048 | const fn_info = mod.typeToFunc(decl.typeOf(mod)).?; | |
| 2049 | 2049 | const return_ty_ref = try self.resolveFnReturnType(Type.fromInterned(fn_info.return_type)); |
| 2050 | 2050 | |
| 2051 | const prototype_ty_ref = try self.resolveType(decl.ty, .direct); | |
| 2051 | const prototype_ty_ref = try self.resolveType(decl.typeOf(mod), .direct); | |
| 2052 | 2052 | try self.func.prologue.emit(self.spv.gpa, .OpFunction, .{ |
| 2053 | 2053 | .id_result_type = self.typeId(return_ty_ref), |
| 2054 | 2054 | .id_result = result_id, |
| ... | ... | @@ -2121,7 +2121,7 @@ const DeclGen = struct { |
| 2121 | 2121 | const final_storage_class = self.spvStorageClass(decl.@"addrspace"); |
| 2122 | 2122 | assert(final_storage_class != .Generic); // These should be instance globals |
| 2123 | 2123 | |
| 2124 | const ptr_ty_ref = try self.ptrType(decl.ty, final_storage_class); | |
| 2124 | const ptr_ty_ref = try self.ptrType(decl.typeOf(mod), final_storage_class); | |
| 2125 | 2125 | |
| 2126 | 2126 | try self.spv.sections.types_globals_constants.emit(self.spv.gpa, .OpVariable, .{ |
| 2127 | 2127 | .id_result_type = self.typeId(ptr_ty_ref), |
| ... | ... | @@ -2144,7 +2144,7 @@ const DeclGen = struct { |
| 2144 | 2144 | |
| 2145 | 2145 | try self.spv.declareDeclDeps(spv_decl_index, &.{}); |
| 2146 | 2146 | |
| 2147 | const ptr_ty_ref = try self.ptrType(decl.ty, .Function); | |
| 2147 | const ptr_ty_ref = try self.ptrType(decl.typeOf(mod), .Function); | |
| 2148 | 2148 | |
| 2149 | 2149 | if (maybe_init_val) |init_val| { |
| 2150 | 2150 | // TODO: Combine with resolveAnonDecl? |
| ... | ... | @@ -2168,7 +2168,7 @@ const DeclGen = struct { |
| 2168 | 2168 | }); |
| 2169 | 2169 | self.current_block_label = root_block_id; |
| 2170 | 2170 | |
| 2171 | const val_id = try self.constant(decl.ty, init_val, .indirect); | |
| 2171 | const val_id = try self.constant(decl.typeOf(mod), init_val, .indirect); | |
| 2172 | 2172 | try self.func.body.emit(self.spv.gpa, .OpStore, .{ |
| 2173 | 2173 | .pointer = result_id, |
| 2174 | 2174 | .object = val_id, |
| ... | ... | @@ -4785,7 +4785,7 @@ const DeclGen = struct { |
| 4785 | 4785 | const mod = self.module; |
| 4786 | 4786 | if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 4787 | 4787 | const decl = mod.declPtr(self.decl_index); |
| 4788 | const fn_info = mod.typeToFunc(decl.ty).?; | |
| 4788 | const fn_info = mod.typeToFunc(decl.typeOf(mod)).?; | |
| 4789 | 4789 | if (Type.fromInterned(fn_info.return_type).isError(mod)) { |
| 4790 | 4790 | // Functions with an empty error set are emitted with an error code |
| 4791 | 4791 | // return type and return zero so they can be function pointers coerced |
| ... | ... | @@ -4810,7 +4810,7 @@ const DeclGen = struct { |
| 4810 | 4810 | |
| 4811 | 4811 | if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 4812 | 4812 | const decl = mod.declPtr(self.decl_index); |
| 4813 | const fn_info = mod.typeToFunc(decl.ty).?; | |
| 4813 | const fn_info = mod.typeToFunc(decl.typeOf(mod)).?; | |
| 4814 | 4814 | if (Type.fromInterned(fn_info.return_type).isError(mod)) { |
| 4815 | 4815 | // Functions with an empty error set are emitted with an error code |
| 4816 | 4816 | // return type and return zero so they can be function pointers coerced |
src/link/C.zig+1-1| ... | ... | @@ -209,7 +209,7 @@ pub fn updateFunc( |
| 209 | 209 | .module = module, |
| 210 | 210 | .error_msg = null, |
| 211 | 211 | .pass = .{ .decl = decl_index }, |
| 212 | .is_naked_fn = decl.ty.fnCallingConvention(module) == .Naked, | |
| 212 | .is_naked_fn = decl.typeOf(module).fnCallingConvention(module) == .Naked, | |
| 213 | 213 | .fwd_decl = fwd_decl.toManaged(gpa), |
| 214 | 214 | .ctypes = ctypes.*, |
| 215 | 215 | .anon_decl_deps = self.anon_decls, |
src/link/Coff.zig+3-3| ... | ... | @@ -1272,7 +1272,7 @@ pub fn updateDecl( |
| 1272 | 1272 | |
| 1273 | 1273 | const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val; |
| 1274 | 1274 | const res = try codegen.generateSymbol(&self.base, decl.srcLoc(mod), .{ |
| 1275 | .ty = decl.ty, | |
| 1275 | .ty = decl.typeOf(mod), | |
| 1276 | 1276 | .val = decl_val, |
| 1277 | 1277 | }, &code_buffer, .none, .{ |
| 1278 | 1278 | .parent_atom_index = atom.getSymbolIndex().?, |
| ... | ... | @@ -1399,8 +1399,8 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: InternPool.DeclIndex) !At |
| 1399 | 1399 | |
| 1400 | 1400 | fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 { |
| 1401 | 1401 | const decl = self.base.comp.module.?.declPtr(decl_index); |
| 1402 | const ty = decl.ty; | |
| 1403 | 1402 | const mod = self.base.comp.module.?; |
| 1403 | const ty = decl.typeOf(mod); | |
| 1404 | 1404 | const zig_ty = ty.zigTypeTag(mod); |
| 1405 | 1405 | const val = decl.val; |
| 1406 | 1406 | const index: u16 = blk: { |
| ... | ... | @@ -1535,7 +1535,7 @@ pub fn updateExports( |
| 1535 | 1535 | .x86 => std.builtin.CallingConvention.Stdcall, |
| 1536 | 1536 | else => std.builtin.CallingConvention.C, |
| 1537 | 1537 | }; |
| 1538 | const decl_cc = exported_decl.ty.fnCallingConvention(mod); | |
| 1538 | const decl_cc = exported_decl.typeOf(mod).fnCallingConvention(mod); | |
| 1539 | 1539 | if (decl_cc == .C and ip.stringEqlSlice(exp.opts.name, "main") and |
| 1540 | 1540 | comp.config.link_libc) |
| 1541 | 1541 | { |
src/link/Dwarf.zig+3-3| ... | ... | @@ -1109,7 +1109,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclInde |
| 1109 | 1109 | |
| 1110 | 1110 | assert(decl.has_tv); |
| 1111 | 1111 | |
| 1112 | switch (decl.ty.zigTypeTag(mod)) { | |
| 1112 | switch (decl.typeOf(mod).zigTypeTag(mod)) { | |
| 1113 | 1113 | .Fn => { |
| 1114 | 1114 | _ = try self.getOrCreateAtomForDecl(.src_fn, decl_index); |
| 1115 | 1115 | |
| ... | ... | @@ -1162,7 +1162,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclInde |
| 1162 | 1162 | try dbg_info_buffer.ensureUnusedCapacity(1 + ptr_width_bytes + 4 + 4 + |
| 1163 | 1163 | (decl_name_slice.len + 1) + (decl_linkage_name_slice.len + 1)); |
| 1164 | 1164 | |
| 1165 | const fn_ret_type = decl.ty.fnReturnType(mod); | |
| 1165 | const fn_ret_type = decl.typeOf(mod).fnReturnType(mod); | |
| 1166 | 1166 | const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(mod); |
| 1167 | 1167 | dbg_info_buffer.appendAssumeCapacity(@intFromEnum( |
| 1168 | 1168 | @as(AbbrevCode, if (fn_ret_has_bits) .subprogram else .subprogram_retvoid), |
| ... | ... | @@ -1215,7 +1215,7 @@ pub fn commitDeclState( |
| 1215 | 1215 | var dbg_info_buffer = &decl_state.dbg_info; |
| 1216 | 1216 | |
| 1217 | 1217 | assert(decl.has_tv); |
| 1218 | switch (decl.ty.zigTypeTag(zcu)) { | |
| 1218 | switch (decl.typeOf(zcu).zigTypeTag(zcu)) { | |
| 1219 | 1219 | .Fn => { |
| 1220 | 1220 | try decl_state.setInlineFunc(decl.val.toIntern()); |
| 1221 | 1221 |
src/link/Elf/ZigObject.zig+3-3| ... | ... | @@ -846,7 +846,7 @@ fn getDeclShdrIndex( |
| 846 | 846 | _ = self; |
| 847 | 847 | const mod = elf_file.base.comp.module.?; |
| 848 | 848 | const any_non_single_threaded = elf_file.base.comp.config.any_non_single_threaded; |
| 849 | const shdr_index = switch (decl.ty.zigTypeTag(mod)) { | |
| 849 | const shdr_index = switch (decl.typeOf(mod).zigTypeTag(mod)) { | |
| 850 | 850 | .Fn => elf_file.zig_text_section_index.?, |
| 851 | 851 | else => blk: { |
| 852 | 852 | if (decl.getOwnedVariable(mod)) |variable| { |
| ... | ... | @@ -1158,7 +1158,7 @@ pub fn updateDecl( |
| 1158 | 1158 | const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val; |
| 1159 | 1159 | const res = if (decl_state) |*ds| |
| 1160 | 1160 | try codegen.generateSymbol(&elf_file.base, decl.srcLoc(mod), .{ |
| 1161 | .ty = decl.ty, | |
| 1161 | .ty = decl.typeOf(mod), | |
| 1162 | 1162 | .val = decl_val, |
| 1163 | 1163 | }, &code_buffer, .{ |
| 1164 | 1164 | .dwarf = ds, |
| ... | ... | @@ -1167,7 +1167,7 @@ pub fn updateDecl( |
| 1167 | 1167 | }) |
| 1168 | 1168 | else |
| 1169 | 1169 | try codegen.generateSymbol(&elf_file.base, decl.srcLoc(mod), .{ |
| 1170 | .ty = decl.ty, | |
| 1170 | .ty = decl.typeOf(mod), | |
| 1171 | 1171 | .val = decl_val, |
| 1172 | 1172 | }, &code_buffer, .none, .{ |
| 1173 | 1173 | .parent_atom_index = sym_index, |
src/link/MachO/ZigObject.zig+2-2| ... | ... | @@ -740,7 +740,7 @@ pub fn updateDecl( |
| 740 | 740 | const dio: codegen.DebugInfoOutput = if (decl_state) |*ds| .{ .dwarf = ds } else .none; |
| 741 | 741 | const res = |
| 742 | 742 | try codegen.generateSymbol(&macho_file.base, decl.srcLoc(mod), .{ |
| 743 | .ty = decl.ty, | |
| 743 | .ty = decl.typeOf(mod), | |
| 744 | 744 | .val = decl_val, |
| 745 | 745 | }, &code_buffer, dio, .{ |
| 746 | 746 | .parent_atom_index = sym_index, |
| ... | ... | @@ -1021,7 +1021,7 @@ fn getDeclOutputSection( |
| 1021 | 1021 | _ = self; |
| 1022 | 1022 | const mod = macho_file.base.comp.module.?; |
| 1023 | 1023 | const any_non_single_threaded = macho_file.base.comp.config.any_non_single_threaded; |
| 1024 | const sect_id: u8 = switch (decl.ty.zigTypeTag(mod)) { | |
| 1024 | const sect_id: u8 = switch (decl.typeOf(mod).zigTypeTag(mod)) { | |
| 1025 | 1025 | .Fn => macho_file.zig_text_sect_index.?, |
| 1026 | 1026 | else => blk: { |
| 1027 | 1027 | if (decl.getOwnedVariable(mod)) |variable| { |
src/link/Plan9.zig+3-3| ... | ... | @@ -177,7 +177,7 @@ pub const Atom = struct { |
| 177 | 177 | return if (self.code_ptr) |p| p[0..self.other.code_len] else blk: { |
| 178 | 178 | const decl_index = self.other.decl_index; |
| 179 | 179 | const decl = mod.declPtr(decl_index); |
| 180 | if (decl.ty.zigTypeTag(mod) == .Fn) { | |
| 180 | if (decl.typeOf(mod).zigTypeTag(mod) == .Fn) { | |
| 181 | 181 | const table = plan9.fn_decl_table.get(decl.getFileScope(mod)).?.functions; |
| 182 | 182 | const output = table.get(decl_index).?; |
| 183 | 183 | break :blk output.code; |
| ... | ... | @@ -540,7 +540,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex) |
| 540 | 540 | const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val; |
| 541 | 541 | // TODO we need the symbol index for symbol in the table of locals for the containing atom |
| 542 | 542 | const res = try codegen.generateSymbol(&self.base, decl.srcLoc(mod), .{ |
| 543 | .ty = decl.ty, | |
| 543 | .ty = decl.typeOf(mod), | |
| 544 | 544 | .val = decl_val, |
| 545 | 545 | }, &code_buffer, .{ .none = {} }, .{ |
| 546 | 546 | .parent_atom_index = @as(Atom.Index, @intCast(atom_idx)), |
| ... | ... | @@ -566,7 +566,7 @@ fn updateFinish(self: *Plan9, decl_index: InternPool.DeclIndex) !void { |
| 566 | 566 | const gpa = self.base.comp.gpa; |
| 567 | 567 | const mod = self.base.comp.module.?; |
| 568 | 568 | const decl = mod.declPtr(decl_index); |
| 569 | const is_fn = (decl.ty.zigTypeTag(mod) == .Fn); | |
| 569 | const is_fn = (decl.typeOf(mod).zigTypeTag(mod) == .Fn); | |
| 570 | 570 | const sym_t: aout.Sym.Type = if (is_fn) .t else .d; |
| 571 | 571 | |
| 572 | 572 | const atom = self.getAtomPtr(self.decls.get(decl_index).?.index); |
src/link/SpirV.zig+1-1| ... | ... | @@ -163,7 +163,7 @@ pub fn updateExports( |
| 163 | 163 | if (decl.val.isFuncBody(mod)) { |
| 164 | 164 | const target = mod.getTarget(); |
| 165 | 165 | const spv_decl_index = try self.object.resolveDecl(mod, decl_index); |
| 166 | const execution_model = switch (decl.ty.fnCallingConvention(mod)) { | |
| 166 | const execution_model = switch (decl.typeOf(mod).fnCallingConvention(mod)) { | |
| 167 | 167 | .Vertex => spec.ExecutionModel.Vertex, |
| 168 | 168 | .Fragment => spec.ExecutionModel.Fragment, |
| 169 | 169 | .Kernel => spec.ExecutionModel.Kernel, |
src/link/Wasm/ZigObject.zig+4-4| ... | ... | @@ -270,7 +270,7 @@ pub fn updateDecl( |
| 270 | 270 | const res = try codegen.generateSymbol( |
| 271 | 271 | &wasm_file.base, |
| 272 | 272 | decl.srcLoc(mod), |
| 273 | .{ .ty = decl.ty, .val = val }, | |
| 273 | .{ .ty = decl.typeOf(mod), .val = val }, | |
| 274 | 274 | &code_writer, |
| 275 | 275 | .none, |
| 276 | 276 | .{ .parent_atom_index = @intFromEnum(atom.sym_index) }, |
| ... | ... | @@ -346,7 +346,7 @@ fn finishUpdateDecl( |
| 346 | 346 | try atom.code.appendSlice(gpa, code); |
| 347 | 347 | atom.size = @intCast(code.len); |
| 348 | 348 | |
| 349 | switch (decl.ty.zigTypeTag(mod)) { | |
| 349 | switch (decl.typeOf(mod).zigTypeTag(mod)) { | |
| 350 | 350 | .Fn => { |
| 351 | 351 | sym.index = try zig_object.appendFunction(gpa, .{ .type_index = zig_object.atom_types.get(atom_index).? }); |
| 352 | 352 | sym.tag = .function; |
| ... | ... | @@ -764,7 +764,7 @@ pub fn getDeclVAddr( |
| 764 | 764 | const atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; |
| 765 | 765 | const atom = wasm_file.getAtomPtr(atom_index); |
| 766 | 766 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 767 | if (decl.ty.zigTypeTag(mod) == .Fn) { | |
| 767 | if (decl.typeOf(mod).zigTypeTag(mod) == .Fn) { | |
| 768 | 768 | std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations |
| 769 | 769 | try atom.relocs.append(gpa, .{ |
| 770 | 770 | .index = target_symbol_index, |
| ... | ... | @@ -964,7 +964,7 @@ pub fn freeDecl(zig_object: *ZigObject, wasm_file: *Wasm, decl_index: InternPool |
| 964 | 964 | if (sym.isGlobal()) { |
| 965 | 965 | std.debug.assert(zig_object.global_syms.remove(atom.sym_index)); |
| 966 | 966 | } |
| 967 | switch (decl.ty.zigTypeTag(mod)) { | |
| 967 | switch (decl.typeOf(mod).zigTypeTag(mod)) { | |
| 968 | 968 | .Fn => { |
| 969 | 969 | zig_object.functions_free_list.append(gpa, sym.index) catch {}; |
| 970 | 970 | std.debug.assert(zig_object.atom_types.remove(atom_index)); |