| ... | ... | @@ -625,7 +625,7 @@ const DocData = struct { |
| 625 | 625 | negated: bool = false, |
| 626 | 626 | }, |
| 627 | 627 | int_big: struct { |
| 628 | | value: []const u8, // direct value |
| 628 | value: []const u8, // string representation |
| 629 | 629 | negated: bool = false, |
| 630 | 630 | }, |
| 631 | 631 | float: f64, // direct value |
| ... | ... | @@ -714,9 +714,12 @@ const DocData = struct { |
| 714 | 714 | }, |
| 715 | 715 | .int_big => { |
| 716 | 716 | |
| 717 | | //@panic("TODO: json serialization of big ints!"); |
| 718 | | //if (v.negated) try w.writeAll("-"); |
| 719 | | //try jsw.emitNumber(v.value); |
| 717 | try jsw.beginObject(); |
| 718 | try jsw.objectField("value"); |
| 719 | try jsw.emitString(self.int_big.value); |
| 720 | try jsw.objectField("negated"); |
| 721 | try jsw.emitBool(self.int_big.negated); |
| 722 | try jsw.endObject(); |
| 720 | 723 | }, |
| 721 | 724 | .builtinField => { |
| 722 | 725 | try jsw.emitString(@tagName(self.builtinField)); |
| ... | ... | @@ -1084,15 +1087,32 @@ fn walkInstruction( |
| 1084 | 1087 | }, |
| 1085 | 1088 | .int_big => { |
| 1086 | 1089 | // @check |
| 1087 | | const str = data[inst_index].str.get(file.zir); |
| 1088 | | _ = str; |
| 1089 | | printWithContext( |
| 1090 | | file, |
| 1091 | | inst_index, |
| 1092 | | "TODO: implement `{s}` for walkInstruction\n\n", |
| 1093 | | .{@tagName(tags[inst_index])}, |
| 1094 | | ); |
| 1095 | | return self.cteTodo(@tagName(tags[inst_index])); |
| 1090 | const str = data[inst_index].str; //.get(file.zir); |
| 1091 | const byte_count = str.len * @sizeOf(std.math.big.Limb); |
| 1092 | const limb_bytes = file.zir.string_bytes[str.start..][0..byte_count]; |
| 1093 | |
| 1094 | var limbs = try self.arena.alloc(std.math.big.Limb, str.len); |
| 1095 | std.mem.copy(u8, std.mem.sliceAsBytes(limbs), limb_bytes); |
| 1096 | |
| 1097 | const big_int = std.math.big.int.Const{ |
| 1098 | .limbs = limbs, |
| 1099 | .positive = true, |
| 1100 | }; |
| 1101 | |
| 1102 | const as_string = try big_int.toStringAlloc(self.arena, 10, .lower); |
| 1103 | |
| 1104 | return DocData.WalkResult{ |
| 1105 | .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, |
| 1106 | .expr = .{ .int_big = .{ .value = as_string } }, |
| 1107 | }; |
| 1108 | |
| 1109 | // printWithContext( |
| 1110 | // file, |
| 1111 | // inst_index, |
| 1112 | // "TODO: implement `{s}` for walkInstruction\n\n", |
| 1113 | // .{@tagName(tags[inst_index])}, |
| 1114 | // ); |
| 1115 | // return self.cteTodo(@tagName(tags[inst_index])); |
| 1096 | 1116 | }, |
| 1097 | 1117 | |
| 1098 | 1118 | .slice_start => { |
| ... | ... | @@ -1714,6 +1734,7 @@ fn walkInstruction( |
| 1714 | 1734 | ); |
| 1715 | 1735 | switch (operand.expr) { |
| 1716 | 1736 | .int => |*int| int.negated = true, |
| 1737 | .int_big => |*int_big| int_big.negated = true, |
| 1717 | 1738 | else => { |
| 1718 | 1739 | printWithContext( |
| 1719 | 1740 | file, |