Skip to content

Commit 42389cb

Browse files
autodoc: Reimplement array_mul after ZIR changes. Change some vars to const where possible. (#17939)
1 parent 04ac028 commit 42389cb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/Autodoc.zig

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,56 @@ fn walkInstruction(
16061606
.expr = .{ .binOpIndex = binop_index },
16071607
};
16081608
},
1609+
.array_mul => {
1610+
const pl_node = data[@intFromEnum(inst)].pl_node;
1611+
const extra = file.zir.extraData(Zir.Inst.ArrayMul, pl_node.payload_index);
1612+
1613+
const binop_index = self.exprs.items.len;
1614+
try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
1615+
1616+
const lhs: DocData.WalkResult = try self.walkRef(
1617+
file,
1618+
parent_scope,
1619+
parent_src,
1620+
extra.data.lhs,
1621+
false,
1622+
call_ctx,
1623+
);
1624+
const rhs: DocData.WalkResult = try self.walkRef(
1625+
file,
1626+
parent_scope,
1627+
parent_src,
1628+
extra.data.rhs,
1629+
false,
1630+
call_ctx,
1631+
);
1632+
const res_ty: ?DocData.WalkResult = if (extra.data.res_ty != .none)
1633+
try self.walkRef(
1634+
file,
1635+
parent_scope,
1636+
parent_src,
1637+
extra.data.res_ty,
1638+
false,
1639+
call_ctx,
1640+
)
1641+
else
1642+
null;
1643+
1644+
const lhs_index = self.exprs.items.len;
1645+
try self.exprs.append(self.arena, lhs.expr);
1646+
const rhs_index = self.exprs.items.len;
1647+
try self.exprs.append(self.arena, rhs.expr);
1648+
self.exprs.items[binop_index] = .{ .binOp = .{
1649+
.name = @tagName(tags[@intFromEnum(inst)]),
1650+
.lhs = lhs_index,
1651+
.rhs = rhs_index,
1652+
} };
1653+
1654+
return DocData.WalkResult{
1655+
.typeRef = if (res_ty) |rt| rt.expr else null,
1656+
.expr = .{ .binOpIndex = binop_index },
1657+
};
1658+
},
16091659
// compare operators
16101660
.cmp_eq,
16111661
.cmp_neq,

0 commit comments

Comments
 (0)