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