zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5fcf0b056544c32f30c4aa3bfe884fc3a9c675f1 (tree)
parent a529d747c9e4b2064fa3e399025c804e05e5fdf5
Author: Vallahor <vallahor91@gmail.com>
Date:   Sun, 29 May 2022 13:31:47 -0300

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

Diffstat:
Mlib/docs/main.js | 4++++
Msrc/Autodoc.zig | 22++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/lib/docs/main.js b/lib/docs/main.js @@ -1062,6 +1062,10 @@ var zigAnalysis; function exprName(expr, opts) { switch (Object.keys(expr)[0]) { default: throw "oh no"; + case "bitSizeOf" : { + const bitSizeOf = zigAnalysis.exprs[expr.bitSizeOf]; + return "@bitSizeOf(" + exprName(bitSizeOf, opts) + ")"; + } case "sizeOf" : { const sizeOf = zigAnalysis.exprs[expr.sizeOf]; return "sizeOf(" + exprName(sizeOf, opts) + ")"; diff --git a/src/Autodoc.zig b/src/Autodoc.zig @@ -655,6 +655,7 @@ const DocData = struct { errorUnion: usize, // index in `exprs` as: As, sizeOf: usize, // index in `exprs` + bitSizeOf: usize, // index in `exprs` compileError: []const u8, string: []const u8, // direct value // Index a `type` like struct with expressions @@ -730,6 +731,11 @@ const DocData = struct { \\{{ "sizeOf":{} }} , .{v}); }, + .bitSizeOf => |v| { + try w.print( + \\{{ "bitSizeOf":{} }} + , .{v}); + }, .fieldRef => |v| try std.json.stringify( struct { fieldRef: FieldRef }{ .fieldRef = v }, options, @@ -2151,6 +2157,22 @@ fn walkInstruction( .expr = .{ .sizeOf = operand_index }, }; }, + .bit_size_of => { + // not working correctly with `align()` + const un_node = data[inst_index].un_node; + const operand = try self.walkRef( + file, + parent_scope, + un_node.operand, + false, + ); + const operand_index = self.exprs.items.len; + try self.exprs.append(self.arena, operand.expr); + return DocData.WalkResult{ + .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .expr = .{ .bitSizeOf = operand_index }, + }; + }, .typeof => { const un_node = data[inst_index].un_node;