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