| ... | @@ -639,7 +639,7 @@ const DocData = struct { | ... | @@ -639,7 +639,7 @@ const DocData = struct { |
| 639 | negated: bool = false, | 639 | negated: bool = false, |
| 640 | }, | 640 | }, |
| 641 | int_big: struct { | 641 | int_big: struct { |
| 642 | value: []const u8, // direct value | 642 | value: []const u8, // string representation |
| 643 | negated: bool = false, | 643 | negated: bool = false, |
| 644 | }, | 644 | }, |
| 645 | float: f64, // direct value | 645 | float: f64, // direct value |
| ... | @@ -726,12 +726,6 @@ const DocData = struct { | ... | @@ -726,12 +726,6 @@ const DocData = struct { |
| 726 | if (self.int.negated) try w.writeAll("-"); | 726 | if (self.int.negated) try w.writeAll("-"); |
| 727 | try jsw.emitNumber(self.int.value); | 727 | try jsw.emitNumber(self.int.value); |
| 728 | }, | 728 | }, |
| 729 | .int_big => { | | |
| 730 | | | |
| 731 | //@panic("TODO: json serialization of big ints!"); | | |
| 732 | //if (v.negated) try w.writeAll("-"); | | |
| 733 | //try jsw.emitNumber(v.value); | | |
| 734 | }, | | |
| 735 | .builtinField => { | 729 | .builtinField => { |
| 736 | try jsw.emitString(@tagName(self.builtinField)); | 730 | try jsw.emitString(@tagName(self.builtinField)); |
| 737 | }, | 731 | }, |
| ... | @@ -1099,15 +1093,24 @@ fn walkInstruction( | ... | @@ -1099,15 +1093,24 @@ fn walkInstruction( |
| 1099 | }, | 1093 | }, |
| 1100 | .int_big => { | 1094 | .int_big => { |
| 1101 | // @check | 1095 | // @check |
| 1102 | const str = data[inst_index].str.get(file.zir); | 1096 | const str = data[inst_index].str; //.get(file.zir); |
| 1103 | _ = str; | 1097 | const byte_count = str.len * @sizeOf(std.math.big.Limb); |
| 1104 | printWithContext( | 1098 | const limb_bytes = file.zir.string_bytes[str.start..][0..byte_count]; |
| 1105 | file, | 1099 | |
| 1106 | inst_index, | 1100 | var limbs = try self.arena.alloc(std.math.big.Limb, str.len); |
| 1107 | "TODO: implement `{s}` for walkInstruction\n\n", | 1101 | std.mem.copy(u8, std.mem.sliceAsBytes(limbs), limb_bytes); |
| 1108 | .{@tagName(tags[inst_index])}, | 1102 | |
| 1109 | ); | 1103 | const big_int = std.math.big.int.Const{ |
| 1110 | return self.cteTodo(@tagName(tags[inst_index])); | 1104 | .limbs = limbs, |
| | 1105 | .positive = true, |
| | 1106 | }; |
| | 1107 | |
| | 1108 | const as_string = try big_int.toStringAlloc(self.arena, 10, .lower); |
| | 1109 | |
| | 1110 | return DocData.WalkResult{ |
| | 1111 | .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, |
| | 1112 | .expr = .{ .int_big = .{ .value = as_string } }, |
| | 1113 | }; |
| 1111 | }, | 1114 | }, |
| 1112 | | 1115 | |
| 1113 | .slice_start => { | 1116 | .slice_start => { |
| ... | @@ -1776,6 +1779,7 @@ fn walkInstruction( | ... | @@ -1776,6 +1779,7 @@ fn walkInstruction( |
| 1776 | ); | 1779 | ); |
| 1777 | switch (operand.expr) { | 1780 | switch (operand.expr) { |
| 1778 | .int => |*int| int.negated = true, | 1781 | .int => |*int| int.negated = true, |
| | 1782 | .int_big => |*int_big| int_big.negated = true, |
| 1779 | else => { | 1783 | else => { |
| 1780 | printWithContext( | 1784 | printWithContext( |
| 1781 | file, | 1785 | file, |