| ... | @@ -1808,6 +1808,34 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { | ... | @@ -1808,6 +1808,34 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { |
| 1808 | return self.fail("TODO implement int genTypedValue of > 64 bits", .{}); | 1808 | return self.fail("TODO implement int genTypedValue of > 64 bits", .{}); |
| 1809 | } | 1809 | } |
| 1810 | }, | 1810 | }, |
| | 1811 | .ErrorSet => { |
| | 1812 | const err_name = typed_value.val.castTag(.@"error").?.data.name; |
| | 1813 | const module = self.bin_file.options.module.?; |
| | 1814 | const global_error_set = module.global_error_set; |
| | 1815 | const error_index = global_error_set.get(err_name).?; |
| | 1816 | return MCValue{ .immediate = error_index }; |
| | 1817 | }, |
| | 1818 | .ErrorUnion => { |
| | 1819 | const error_type = typed_value.ty.errorUnionSet(); |
| | 1820 | const payload_type = typed_value.ty.errorUnionPayload(); |
| | 1821 | |
| | 1822 | if (typed_value.val.castTag(.eu_payload)) |pl| { |
| | 1823 | if (!payload_type.hasRuntimeBits()) { |
| | 1824 | // We use the error type directly as the type. |
| | 1825 | return MCValue{ .immediate = 0 }; |
| | 1826 | } |
| | 1827 | |
| | 1828 | _ = pl; |
| | 1829 | return self.fail("TODO implement error union const of type '{}' (non-error)", .{typed_value.ty.fmtDebug()}); |
| | 1830 | } else { |
| | 1831 | if (!payload_type.hasRuntimeBits()) { |
| | 1832 | // We use the error type directly as the type. |
| | 1833 | return self.genTypedValue(.{ .ty = error_type, .val = typed_value.val }); |
| | 1834 | } |
| | 1835 | |
| | 1836 | return self.fail("TODO implement error union const of type '{}' (error)", .{typed_value.ty.fmtDebug()}); |
| | 1837 | } |
| | 1838 | }, |
| 1811 | .ComptimeInt => unreachable, // semantic analysis prevents this | 1839 | .ComptimeInt => unreachable, // semantic analysis prevents this |
| 1812 | .ComptimeFloat => unreachable, // semantic analysis prevents this | 1840 | .ComptimeFloat => unreachable, // semantic analysis prevents this |
| 1813 | else => return self.fail("TODO implement const of type '{}'", .{typed_value.ty.fmtDebug()}), | 1841 | else => return self.fail("TODO implement const of type '{}'", .{typed_value.ty.fmtDebug()}), |