| ... | ... | @@ -761,21 +761,25 @@ pub const DeclGen = struct { |
| 761 | 761 | dg.context.intType(8); |
| 762 | 762 | return llvm_elem_ty.pointerType(llvm_addrspace); |
| 763 | 763 | }, |
| 764 | | .Opaque => { |
| 765 | | const gop = try dg.object.type_map.getOrPut(gpa, t); |
| 766 | | if (gop.found_existing) return gop.value_ptr.*; |
| 764 | .Opaque => switch (t.tag()) { |
| 765 | .@"opaque" => { |
| 766 | const gop = try dg.object.type_map.getOrPut(gpa, t); |
| 767 | if (gop.found_existing) return gop.value_ptr.*; |
| 767 | 768 | |
| 768 | | // The Type memory is ephemeral; since we want to store a longer-lived |
| 769 | | // reference, we need to copy it here. |
| 770 | | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); |
| 769 | // The Type memory is ephemeral; since we want to store a longer-lived |
| 770 | // reference, we need to copy it here. |
| 771 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); |
| 771 | 772 | |
| 772 | | const opaque_obj = t.castTag(.@"opaque").?.data; |
| 773 | | const name = try opaque_obj.getFullyQualifiedName(gpa); |
| 774 | | defer gpa.free(name); |
| 773 | const opaque_obj = t.castTag(.@"opaque").?.data; |
| 774 | const name = try opaque_obj.getFullyQualifiedName(gpa); |
| 775 | defer gpa.free(name); |
| 775 | 776 | |
| 776 | | const llvm_struct_ty = dg.context.structCreateNamed(name); |
| 777 | | gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls |
| 778 | | return llvm_struct_ty; |
| 777 | const llvm_struct_ty = dg.context.structCreateNamed(name); |
| 778 | gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls |
| 779 | return llvm_struct_ty; |
| 780 | }, |
| 781 | .anyopaque => return dg.context.intType(8), |
| 782 | else => unreachable, |
| 779 | 783 | }, |
| 780 | 784 | .Array => { |
| 781 | 785 | const elem_type = try dg.llvmType(t.childType()); |