| ... | ... | @@ -653,7 +653,12 @@ const DocData = struct { |
| 653 | 653 | value: usize, // direct value |
| 654 | 654 | negated: bool = false, |
| 655 | 655 | }, |
| 656 | int_big: struct { |
| 657 | value: []const u8, // direct value |
| 658 | negated: bool = false, |
| 659 | }, |
| 656 | 660 | float: f64, // direct value |
| 661 | float128: f128, // direct value |
| 657 | 662 | array: []usize, // index in `exprs` |
| 658 | 663 | call: usize, // index in `calls` |
| 659 | 664 | enumLiteral: []const u8, // direct value |
| ... | ... | @@ -740,11 +745,22 @@ const DocData = struct { |
| 740 | 745 | \\{{ "int": {s}{} }} |
| 741 | 746 | , .{ neg, v.value }); |
| 742 | 747 | }, |
| 748 | .int_big => |v| { |
| 749 | const neg = if (v.negated) "-" else ""; |
| 750 | try w.print( |
| 751 | \\{{ "int_big": {s}{s} }} |
| 752 | , .{ neg, v.value }); |
| 753 | }, |
| 743 | 754 | .float => |v| { |
| 744 | 755 | try w.print( |
| 745 | 756 | \\{{ "float": {} }} |
| 746 | 757 | , .{v}); |
| 747 | 758 | }, |
| 759 | .float128 => |v| { |
| 760 | try w.print( |
| 761 | \\{{ "float128": {} }} |
| 762 | , .{v}); |
| 763 | }, |
| 748 | 764 | .bool => |v| { |
| 749 | 765 | try w.print( |
| 750 | 766 | \\{{ "bool":{} }} |
| ... | ... | @@ -1048,6 +1064,18 @@ fn walkInstruction( |
| 1048 | 1064 | .expr = .{ .int = .{ .value = int } }, |
| 1049 | 1065 | }; |
| 1050 | 1066 | }, |
| 1067 | .int_big => { |
| 1068 | // @check |
| 1069 | const str = data[inst_index].str.get(file.zir); |
| 1070 | _ = str; |
| 1071 | printWithContext( |
| 1072 | file, |
| 1073 | inst_index, |
| 1074 | "TODO: implement `{s}` for walkInstruction\n\n", |
| 1075 | .{@tagName(tags[inst_index])}, |
| 1076 | ); |
| 1077 | return self.cteTodo(@tagName(tags[inst_index])); |
| 1078 | }, |
| 1051 | 1079 | |
| 1052 | 1080 | .slice_start => { |
| 1053 | 1081 | const pl_node = data[inst_index].pl_node; |
| ... | ... | @@ -1231,6 +1259,12 @@ fn walkInstruction( |
| 1231 | 1259 | .type_name, |
| 1232 | 1260 | .frame_type, |
| 1233 | 1261 | .frame_size, |
| 1262 | .ptr_to_int, |
| 1263 | .error_to_int, |
| 1264 | .int_to_error, |
| 1265 | .minimum, |
| 1266 | .maximum, |
| 1267 | .bit_not, |
| 1234 | 1268 | => { |
| 1235 | 1269 | const un_node = data[inst_index].un_node; |
| 1236 | 1270 | const bin_index = self.exprs.items.len; |
| ... | ... | @@ -1247,8 +1281,7 @@ fn walkInstruction( |
| 1247 | 1281 | .expr = .{ .builtinIndex = bin_index }, |
| 1248 | 1282 | }; |
| 1249 | 1283 | }, |
| 1250 | | // @check |
| 1251 | | // .clz, .ctz, .pop_count, .byte_swap, .bit_reverse |
| 1284 | |
| 1252 | 1285 | .float_to_int, |
| 1253 | 1286 | .int_to_float, |
| 1254 | 1287 | .int_to_ptr, |
| ... | ... | @@ -1270,6 +1303,11 @@ fn walkInstruction( |
| 1270 | 1303 | .shr_exact, |
| 1271 | 1304 | .bitcast, |
| 1272 | 1305 | .vector_type, |
| 1306 | // @check |
| 1307 | .bit_offset_of, |
| 1308 | .offset_of, |
| 1309 | .splat, |
| 1310 | .reduce, |
| 1273 | 1311 | => { |
| 1274 | 1312 | const pl_node = data[inst_index].pl_node; |
| 1275 | 1313 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |
| ... | ... | @@ -1518,14 +1556,6 @@ fn walkInstruction( |
| 1518 | 1556 | array_data[idx] = wr.expr.as.exprArg; |
| 1519 | 1557 | } |
| 1520 | 1558 | |
| 1521 | | // @check |
| 1522 | | // not working with |
| 1523 | | // const value_slice_float = []f32{42.0}; |
| 1524 | | // const value_slice_float2: []f32 = .{42.0}; |
| 1525 | | // rendering [][]f32 |
| 1526 | | // the reason for that is it's initialized as a pointer |
| 1527 | | // in this case getting the last type index works fine |
| 1528 | | // but when it's not after a pointer it's thrown an error in js. |
| 1529 | 1559 | const type_slot_index = self.types.items.len; |
| 1530 | 1560 | try self.types.append(self.arena, .{ .Pointer = .{ |
| 1531 | 1561 | .size = .Slice, |
| ... | ... | @@ -1721,6 +1751,15 @@ fn walkInstruction( |
| 1721 | 1751 | .expr = .{ .float = float }, |
| 1722 | 1752 | }; |
| 1723 | 1753 | }, |
| 1754 | // @check: In frontend I'm handling float128 with `.toFixed(2)` |
| 1755 | .float128 => { |
| 1756 | const pl_node = data[inst_index].pl_node; |
| 1757 | const extra = file.zir.extraData(Zir.Inst.Float128, pl_node.payload_index); |
| 1758 | return DocData.WalkResult{ |
| 1759 | .typeRef = .{ .type = @enumToInt(Ref.comptime_float_type) }, |
| 1760 | .expr = .{ .float128 = extra.data.get() }, |
| 1761 | }; |
| 1762 | }, |
| 1724 | 1763 | .negate => { |
| 1725 | 1764 | const un_node = data[inst_index].un_node; |
| 1726 | 1765 | var operand: DocData.WalkResult = try self.walkRef( |
| ... | ... | @@ -2018,23 +2057,6 @@ fn walkInstruction( |
| 2018 | 2057 | .expr = .{ .type = self.types.items.len - 1 }, |
| 2019 | 2058 | }; |
| 2020 | 2059 | }, |
| 2021 | | .float128 => { |
| 2022 | | const pl_node = data[inst_index].pl_node; |
| 2023 | | const extra = file.zir.extraData(Zir.Inst.Float128, pl_node.payload_index); |
| 2024 | | _ = extra; |
| 2025 | | // const sep = "=" ** 200; |
| 2026 | | // std.debug.print("{s}\n", .{sep}); |
| 2027 | | // std.debug.print("pl_node = {any}\n", .{pl_node}); |
| 2028 | | // std.debug.print("extra = {any}\n", .{extra}); |
| 2029 | | // std.debug.print("{s}\n", .{sep}); |
| 2030 | | // printWithContext( |
| 2031 | | // file, |
| 2032 | | // inst_index, |
| 2033 | | // "TODO: implement `{s}` for walkInstruction\n\n", |
| 2034 | | // .{@tagName(tags[inst_index])}, |
| 2035 | | // ); |
| 2036 | | return self.cteTodo(@tagName(tags[inst_index])); |
| 2037 | | }, |
| 2038 | 2060 | .block => { |
| 2039 | 2061 | const res = DocData.WalkResult{ .expr = .{ |
| 2040 | 2062 | .comptimeExpr = self.comptime_exprs.items.len, |