| author | |
| committer | |
| log | 35a8e8a06c0cb0a5a0c6ddcca3b70be05dc4d035 |
| tree | c43865cf9e619f2fa7aaec7e7be1a4876fa4cb93 |
| parent | f571438fc0010c0c45f79a2f709161a324c5a164 |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
* fixed autodoc rendering of @trucate builtin
* Changed to LHS for typeRef
* autodoc: fix typeref for `truncate`
---------
Co-authored-by: Loris Cro <kappaloris@gmail.com>2 files changed, 38 insertions(+), 2 deletions(-)
lib/docs/main.js+3-1| ... | @@ -1419,6 +1419,9 @@ const NAV_MODES = { | ... | @@ -1419,6 +1419,9 @@ const NAV_MODES = { |
| 1419 | case "bit_reverse": { | 1419 | case "bit_reverse": { |
| 1420 | return "@bitReverse(T" + ", " + param + ")"; | 1420 | return "@bitReverse(T" + ", " + param + ")"; |
| 1421 | } | 1421 | } |
| 1422 | case "truncate": { | ||
| 1423 | return "@truncate(" + param + ")"; | ||
| 1424 | } | ||
| 1422 | default: | 1425 | default: |
| 1423 | console.log("builtin function not handled yet or doesn't exist!"); | 1426 | console.log("builtin function not handled yet or doesn't exist!"); |
| 1424 | } | 1427 | } |
| ... | @@ -2622,7 +2625,6 @@ const NAV_MODES = { | ... | @@ -2622,7 +2625,6 @@ const NAV_MODES = { |
| 2622 | 2625 | ||
| 2623 | function renderValue(decl) { | 2626 | function renderValue(decl) { |
| 2624 | let resolvedValue = resolveValue(decl.value); | 2627 | let resolvedValue = resolveValue(decl.value); |
| 2625 | |||
| 2626 | if (resolvedValue.expr.fieldRef) { | 2628 | if (resolvedValue.expr.fieldRef) { |
| 2627 | const declRef = decl.value.expr.refPath[0].declRef; | 2629 | const declRef = decl.value.expr.refPath[0].declRef; |
| 2628 | const type = getDecl(declRef); | 2630 | const type = getDecl(declRef); |
src/Autodoc.zig+35-1| ... | @@ -1601,7 +1601,42 @@ fn walkInstruction( | ... | @@ -1601,7 +1601,42 @@ fn walkInstruction( |
| 1601 | .expr = .{ .builtinIndex = bin_index }, | 1601 | .expr = .{ .builtinIndex = bin_index }, |
| 1602 | }; | 1602 | }; |
| 1603 | }, | 1603 | }, |
| 1604 | .truncate => { | ||
| 1605 | // in the ZIR this node is a builtin `bin` but we want send it as a `un` builtin | ||
| 1606 | const pl_node = data[inst_index].pl_node; | ||
| 1607 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); | ||
| 1604 | 1608 | ||
| 1609 | var rhs: DocData.WalkResult = try self.walkRef( | ||
| 1610 | file, | ||
| 1611 | parent_scope, | ||
| 1612 | parent_src, | ||
| 1613 | extra.data.rhs, | ||
| 1614 | false, | ||
| 1615 | ); | ||
| 1616 | |||
| 1617 | const bin_index = self.exprs.items.len; | ||
| 1618 | try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } }); | ||
| 1619 | |||
| 1620 | const rhs_index = self.exprs.items.len; | ||
| 1621 | try self.exprs.append(self.arena, rhs.expr); | ||
| 1622 | |||
| 1623 | var lhs: DocData.WalkResult = try self.walkRef( | ||
| 1624 | file, | ||
| 1625 | parent_scope, | ||
| 1626 | parent_src, | ||
| 1627 | extra.data.lhs, | ||
| 1628 | false, | ||
| 1629 | ); | ||
| 1630 | |||
| 1631 | self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = rhs_index } }; | ||
| 1632 | |||
| 1633 | std.debug.print("lhs: {any}\n\n", .{lhs}); | ||
| 1634 | std.debug.print("lhs typeref: {any}\n\n", .{lhs.typeRef}); | ||
| 1635 | return DocData.WalkResult{ | ||
| 1636 | .typeRef = lhs.expr, | ||
| 1637 | .expr = .{ .builtinIndex = bin_index }, | ||
| 1638 | }; | ||
| 1639 | }, | ||
| 1605 | .int_from_float, | 1640 | .int_from_float, |
| 1606 | .float_from_int, | 1641 | .float_from_int, |
| 1607 | .ptr_from_int, | 1642 | .ptr_from_int, |
| ... | @@ -1609,7 +1644,6 @@ fn walkInstruction( | ... | @@ -1609,7 +1644,6 @@ fn walkInstruction( |
| 1609 | .float_cast, | 1644 | .float_cast, |
| 1610 | .int_cast, | 1645 | .int_cast, |
| 1611 | .ptr_cast, | 1646 | .ptr_cast, |
| 1612 | .truncate, | ||
| 1613 | .has_decl, | 1647 | .has_decl, |
| 1614 | .has_field, | 1648 | .has_field, |
| 1615 | .div_exact, | 1649 | .div_exact, |