| ... | ... | @@ -341,14 +341,20 @@ pub fn generateSymbol( |
| 341 | 341 | } |
| 342 | 342 | return Result.ok; |
| 343 | 343 | }, |
| 344 | | .variable => { |
| 345 | | const decl = typed_value.val.castTag(.variable).?.data.owner_decl; |
| 346 | | return lowerDeclRef(bin_file, src_loc, typed_value, decl, code, debug_output, reloc_info); |
| 347 | | }, |
| 348 | | .decl_ref => { |
| 349 | | const decl = typed_value.val.castTag(.decl_ref).?.data; |
| 350 | | return lowerDeclRef(bin_file, src_loc, typed_value, decl, code, debug_output, reloc_info); |
| 351 | | }, |
| 344 | .variable, .decl_ref, .decl_ref_mut => |tag| return lowerDeclRef( |
| 345 | bin_file, |
| 346 | src_loc, |
| 347 | typed_value, |
| 348 | switch (tag) { |
| 349 | .variable => typed_value.val.castTag(.variable).?.data.owner_decl, |
| 350 | .decl_ref => typed_value.val.castTag(.decl_ref).?.data, |
| 351 | .decl_ref_mut => typed_value.val.castTag(.decl_ref_mut).?.data.decl_index, |
| 352 | else => unreachable, |
| 353 | }, |
| 354 | code, |
| 355 | debug_output, |
| 356 | reloc_info, |
| 357 | ), |
| 352 | 358 | .slice => { |
| 353 | 359 | const slice = typed_value.val.castTag(.slice).?.data; |
| 354 | 360 | |
| ... | ... | @@ -787,11 +793,11 @@ pub fn generateSymbol( |
| 787 | 793 | }, |
| 788 | 794 | else => unreachable, |
| 789 | 795 | }, |
| 790 | | else => |t| return Result{ .fail = try ErrorMsg.create( |
| 796 | else => |tag| return Result{ .fail = try ErrorMsg.create( |
| 791 | 797 | bin_file.allocator, |
| 792 | 798 | src_loc, |
| 793 | 799 | "TODO implement generateSymbol for type '{s}'", |
| 794 | | .{@tagName(t)}, |
| 800 | .{@tagName(tag)}, |
| 795 | 801 | ) }, |
| 796 | 802 | } |
| 797 | 803 | } |
| ... | ... | @@ -852,28 +858,26 @@ fn lowerParentPtr( |
| 852 | 858 | reloc_info.offset(@intCast(u32, elem_ptr.index * elem_ptr.elem_ty.abiSize(target))), |
| 853 | 859 | ); |
| 854 | 860 | }, |
| 855 | | .decl_ref => { |
| 856 | | const decl_index = parent_ptr.castTag(.decl_ref).?.data; |
| 857 | | return lowerDeclRef( |
| 858 | | bin_file, |
| 859 | | src_loc, |
| 860 | | typed_value, |
| 861 | | decl_index, |
| 862 | | code, |
| 863 | | debug_output, |
| 864 | | reloc_info, |
| 865 | | ); |
| 866 | | }, |
| 867 | | else => |t| { |
| 868 | | return Result{ |
| 869 | | .fail = try ErrorMsg.create( |
| 870 | | bin_file.allocator, |
| 871 | | src_loc, |
| 872 | | "TODO implement lowerParentPtr for type '{s}'", |
| 873 | | .{@tagName(t)}, |
| 874 | | ), |
| 875 | | }; |
| 876 | | }, |
| 861 | .variable, .decl_ref, .decl_ref_mut => |tag| return lowerDeclRef( |
| 862 | bin_file, |
| 863 | src_loc, |
| 864 | typed_value, |
| 865 | switch (tag) { |
| 866 | .variable => parent_ptr.castTag(.variable).?.data.owner_decl, |
| 867 | .decl_ref => parent_ptr.castTag(.decl_ref).?.data, |
| 868 | .decl_ref_mut => parent_ptr.castTag(.decl_ref_mut).?.data.decl_index, |
| 869 | else => unreachable, |
| 870 | }, |
| 871 | code, |
| 872 | debug_output, |
| 873 | reloc_info, |
| 874 | ), |
| 875 | else => |tag| return Result{ .fail = try ErrorMsg.create( |
| 876 | bin_file.allocator, |
| 877 | src_loc, |
| 878 | "TODO implement lowerParentPtr for type '{s}'", |
| 879 | .{@tagName(tag)}, |
| 880 | ) }, |
| 877 | 881 | } |
| 878 | 882 | } |
| 879 | 883 | |
| ... | ... | @@ -1126,6 +1130,9 @@ pub fn genTypedValue( |
| 1126 | 1130 | const ptr_bits = target.cpu.arch.ptrBitWidth(); |
| 1127 | 1131 | |
| 1128 | 1132 | if (!typed_value.ty.isSlice()) { |
| 1133 | if (typed_value.val.castTag(.variable)) |payload| { |
| 1134 | return genDeclRef(bin_file, src_loc, typed_value, payload.data.owner_decl); |
| 1135 | } |
| 1129 | 1136 | if (typed_value.val.castTag(.decl_ref)) |payload| { |
| 1130 | 1137 | return genDeclRef(bin_file, src_loc, typed_value, payload.data); |
| 1131 | 1138 | } |