| ... | @@ -653,7 +653,12 @@ const DocData = struct { | ... | @@ -653,7 +653,12 @@ const DocData = struct { |
| 653 | value: usize, // direct value | 653 | value: usize, // direct value |
| 654 | negated: bool = false, | 654 | negated: bool = false, |
| 655 | }, | 655 | }, |
| | 656 | int_big: struct { |
| | 657 | value: []const u8, // direct value |
| | 658 | negated: bool = false, |
| | 659 | }, |
| 656 | float: f64, // direct value | 660 | float: f64, // direct value |
| | 661 | float128: f128, // direct value |
| 657 | array: []usize, // index in `exprs` | 662 | array: []usize, // index in `exprs` |
| 658 | call: usize, // index in `calls` | 663 | call: usize, // index in `calls` |
| 659 | enumLiteral: []const u8, // direct value | 664 | enumLiteral: []const u8, // direct value |
| ... | @@ -740,11 +745,22 @@ const DocData = struct { | ... | @@ -740,11 +745,22 @@ const DocData = struct { |
| 740 | \\{{ "int": {s}{} }} | 745 | \\{{ "int": {s}{} }} |
| 741 | , .{ neg, v.value }); | 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 | .float => |v| { | 754 | .float => |v| { |
| 744 | try w.print( | 755 | try w.print( |
| 745 | \\{{ "float": {} }} | 756 | \\{{ "float": {} }} |
| 746 | , .{v}); | 757 | , .{v}); |
| 747 | }, | 758 | }, |
| | 759 | .float128 => |v| { |
| | 760 | try w.print( |
| | 761 | \\{{ "float128": {} }} |
| | 762 | , .{v}); |
| | 763 | }, |
| 748 | .bool => |v| { | 764 | .bool => |v| { |
| 749 | try w.print( | 765 | try w.print( |
| 750 | \\{{ "bool":{} }} | 766 | \\{{ "bool":{} }} |
| ... | @@ -1048,6 +1064,18 @@ fn walkInstruction( | ... | @@ -1048,6 +1064,18 @@ fn walkInstruction( |
| 1048 | .expr = .{ .int = .{ .value = int } }, | 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 | .slice_start => { | 1080 | .slice_start => { |
| 1053 | const pl_node = data[inst_index].pl_node; | 1081 | const pl_node = data[inst_index].pl_node; |
| ... | @@ -1231,6 +1259,12 @@ fn walkInstruction( | ... | @@ -1231,6 +1259,12 @@ fn walkInstruction( |
| 1231 | .type_name, | 1259 | .type_name, |
| 1232 | .frame_type, | 1260 | .frame_type, |
| 1233 | .frame_size, | 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 | const un_node = data[inst_index].un_node; | 1269 | const un_node = data[inst_index].un_node; |
| 1236 | const bin_index = self.exprs.items.len; | 1270 | const bin_index = self.exprs.items.len; |
| ... | @@ -1247,8 +1281,7 @@ fn walkInstruction( | ... | @@ -1247,8 +1281,7 @@ fn walkInstruction( |
| 1247 | .expr = .{ .builtinIndex = bin_index }, | 1281 | .expr = .{ .builtinIndex = bin_index }, |
| 1248 | }; | 1282 | }; |
| 1249 | }, | 1283 | }, |
| 1250 | // @check | 1284 | |
| 1251 | // .clz, .ctz, .pop_count, .byte_swap, .bit_reverse | | |
| 1252 | .float_to_int, | 1285 | .float_to_int, |
| 1253 | .int_to_float, | 1286 | .int_to_float, |
| 1254 | .int_to_ptr, | 1287 | .int_to_ptr, |
| ... | @@ -1270,6 +1303,11 @@ fn walkInstruction( | ... | @@ -1270,6 +1303,11 @@ fn walkInstruction( |
| 1270 | .shr_exact, | 1303 | .shr_exact, |
| 1271 | .bitcast, | 1304 | .bitcast, |
| 1272 | .vector_type, | 1305 | .vector_type, |
| | 1306 | // @check |
| | 1307 | .bit_offset_of, |
| | 1308 | .offset_of, |
| | 1309 | .splat, |
| | 1310 | .reduce, |
| 1273 | => { | 1311 | => { |
| 1274 | const pl_node = data[inst_index].pl_node; | 1312 | const pl_node = data[inst_index].pl_node; |
| 1275 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); | 1313 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |
| ... | @@ -1518,14 +1556,6 @@ fn walkInstruction( | ... | @@ -1518,14 +1556,6 @@ fn walkInstruction( |
| 1518 | array_data[idx] = wr.expr.as.exprArg; | 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 | const type_slot_index = self.types.items.len; | 1559 | const type_slot_index = self.types.items.len; |
| 1530 | try self.types.append(self.arena, .{ .Pointer = .{ | 1560 | try self.types.append(self.arena, .{ .Pointer = .{ |
| 1531 | .size = .Slice, | 1561 | .size = .Slice, |
| ... | @@ -1721,6 +1751,15 @@ fn walkInstruction( | ... | @@ -1721,6 +1751,15 @@ fn walkInstruction( |
| 1721 | .expr = .{ .float = float }, | 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 | .negate => { | 1763 | .negate => { |
| 1725 | const un_node = data[inst_index].un_node; | 1764 | const un_node = data[inst_index].un_node; |
| 1726 | var operand: DocData.WalkResult = try self.walkRef( | 1765 | var operand: DocData.WalkResult = try self.walkRef( |
| ... | @@ -2018,23 +2057,6 @@ fn walkInstruction( | ... | @@ -2018,23 +2057,6 @@ fn walkInstruction( |
| 2018 | .expr = .{ .type = self.types.items.len - 1 }, | 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 | .block => { | 2060 | .block => { |
| 2039 | const res = DocData.WalkResult{ .expr = .{ | 2061 | const res = DocData.WalkResult{ .expr = .{ |
| 2040 | .comptimeExpr = self.comptime_exprs.items.len, | 2062 | .comptimeExpr = self.comptime_exprs.items.len, |