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