Commit 35a8e8a06c
Changed files (2)
lib
docs
src
lib/docs/main.js
@@ -1419,6 +1419,9 @@ const NAV_MODES = {
case "bit_reverse": {
return "@bitReverse(T" + ", " + param + ")";
}
+ case "truncate": {
+ return "@truncate(" + param + ")";
+ }
default:
console.log("builtin function not handled yet or doesn't exist!");
}
@@ -2622,7 +2625,6 @@ const NAV_MODES = {
function renderValue(decl) {
let resolvedValue = resolveValue(decl.value);
-
if (resolvedValue.expr.fieldRef) {
const declRef = decl.value.expr.refPath[0].declRef;
const type = getDecl(declRef);
src/Autodoc.zig
@@ -1601,7 +1601,42 @@ fn walkInstruction(
.expr = .{ .builtinIndex = bin_index },
};
},
+ .truncate => {
+ // in the ZIR this node is a builtin `bin` but we want send it as a `un` builtin
+ const pl_node = data[inst_index].pl_node;
+ const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
+ var rhs: DocData.WalkResult = try self.walkRef(
+ file,
+ parent_scope,
+ parent_src,
+ extra.data.rhs,
+ false,
+ );
+
+ const bin_index = self.exprs.items.len;
+ try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } });
+
+ const rhs_index = self.exprs.items.len;
+ try self.exprs.append(self.arena, rhs.expr);
+
+ var lhs: DocData.WalkResult = try self.walkRef(
+ file,
+ parent_scope,
+ parent_src,
+ extra.data.lhs,
+ false,
+ );
+
+ self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = rhs_index } };
+
+ std.debug.print("lhs: {any}\n\n", .{lhs});
+ std.debug.print("lhs typeref: {any}\n\n", .{lhs.typeRef});
+ return DocData.WalkResult{
+ .typeRef = lhs.expr,
+ .expr = .{ .builtinIndex = bin_index },
+ };
+ },
.int_from_float,
.float_from_int,
.ptr_from_int,
@@ -1609,7 +1644,6 @@ fn walkInstruction(
.float_cast,
.int_cast,
.ptr_cast,
- .truncate,
.has_decl,
.has_field,
.div_exact,