authorgravatar for vallahor91@gmail.comVallahor <vallahor91@gmail.com> 2022-05-29 13:31:47-03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:12-07:00
log5fcf0b056544c32f30c4aa3bfe884fc3a9c675f1
tree5d2cdc2a775d288fecd7b50b8ddb64ef5e9bd98f
parenta529d747c9e4b2064fa3e399025c804e05e5fdf5

add: handling @bitSizeOf() need to check why not working correctly with `align()`


2 files changed, 26 insertions(+), 0 deletions(-)

lib/docs/main.js+4
......@@ -1062,6 +1062,10 @@ var zigAnalysis;
10621062 function exprName(expr, opts) {
10631063 switch (Object.keys(expr)[0]) {
10641064 default: throw "oh no";
1065 case "bitSizeOf" : {
1066 const bitSizeOf = zigAnalysis.exprs[expr.bitSizeOf];
1067 return "@bitSizeOf(" + exprName(bitSizeOf, opts) + ")";
1068 }
10651069 case "sizeOf" : {
10661070 const sizeOf = zigAnalysis.exprs[expr.sizeOf];
10671071 return "sizeOf(" + exprName(sizeOf, opts) + ")";
src/Autodoc.zig+22
......@@ -655,6 +655,7 @@ const DocData = struct {
655655 errorUnion: usize, // index in `exprs`
656656 as: As,
657657 sizeOf: usize, // index in `exprs`
658 bitSizeOf: usize, // index in `exprs`
658659 compileError: []const u8,
659660 string: []const u8, // direct value
660661 // Index a `type` like struct with expressions
......@@ -730,6 +731,11 @@ const DocData = struct {
730731 \\{{ "sizeOf":{} }}
731732 , .{v});
732733 },
734 .bitSizeOf => |v| {
735 try w.print(
736 \\{{ "bitSizeOf":{} }}
737 , .{v});
738 },
733739 .fieldRef => |v| try std.json.stringify(
734740 struct { fieldRef: FieldRef }{ .fieldRef = v },
735741 options,
......@@ -2151,6 +2157,22 @@ fn walkInstruction(
21512157 .expr = .{ .sizeOf = operand_index },
21522158 };
21532159 },
2160 .bit_size_of => {
2161 // not working correctly with `align()`
2162 const un_node = data[inst_index].un_node;
2163 const operand = try self.walkRef(
2164 file,
2165 parent_scope,
2166 un_node.operand,
2167 false,
2168 );
2169 const operand_index = self.exprs.items.len;
2170 try self.exprs.append(self.arena, operand.expr);
2171 return DocData.WalkResult{
2172 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
2173 .expr = .{ .bitSizeOf = operand_index },
2174 };
2175 },
21542176
21552177 .typeof => {
21562178 const un_node = data[inst_index].un_node;