| author | |
| committer | |
| log | 9be9e4d02c059e55c476fd98e789bbc02c08730a |
| tree | 88f1171f06898cc8263d5c1c4fef85ec2397f670 |
| parent | 5fcf0b056544c32f30c4aa3bfe884fc3a9c675f1 |
2 files changed, 41 insertions(+), 1 deletions(-)
lib/docs/main.js+15-1| ... | ... | @@ -1062,13 +1062,27 @@ var zigAnalysis; |
| 1062 | 1062 | function exprName(expr, opts) { |
| 1063 | 1063 | switch (Object.keys(expr)[0]) { |
| 1064 | 1064 | default: throw "oh no"; |
| 1065 | case "fieldRef" : { | |
| 1066 | // const fieldRef = zigAnalysis.decls[expr.fieldRef.index]; | |
| 1067 | // const struct_name = zigAnalysis.decls[expr.struct[0].val.typeRef.refPath[0].declRef].name; | |
| 1068 | console.log(expr) | |
| 1069 | console.log(fieldRef) | |
| 1070 | // return "@enumToInt(" + exprName(enumToInt, opts) + ")"; | |
| 1071 | // return exprName(fieldRef,opts); | |
| 1072 | return "WIP" | |
| 1073 | } | |
| 1074 | case "enumToInt" : { | |
| 1075 | console.log(expr); | |
| 1076 | const enumToInt = zigAnalysis.exprs[expr.enumToInt]; | |
| 1077 | return "@enumToInt(" + exprName(enumToInt, opts) + ")"; | |
| 1078 | } | |
| 1065 | 1079 | case "bitSizeOf" : { |
| 1066 | 1080 | const bitSizeOf = zigAnalysis.exprs[expr.bitSizeOf]; |
| 1067 | 1081 | return "@bitSizeOf(" + exprName(bitSizeOf, opts) + ")"; |
| 1068 | 1082 | } |
| 1069 | 1083 | case "sizeOf" : { |
| 1070 | 1084 | const sizeOf = zigAnalysis.exprs[expr.sizeOf]; |
| 1071 | return "sizeOf(" + exprName(sizeOf, opts) + ")"; | |
| 1085 | return "@sizeOf(" + exprName(sizeOf, opts) + ")"; | |
| 1072 | 1086 | } |
| 1073 | 1087 | case "binOpIndex" : { |
| 1074 | 1088 | const binOpIndex = zigAnalysis.exprs[expr.binOpIndex]; |
src/Autodoc.zig+26| ... | ... | @@ -656,6 +656,7 @@ const DocData = struct { |
| 656 | 656 | as: As, |
| 657 | 657 | sizeOf: usize, // index in `exprs` |
| 658 | 658 | bitSizeOf: usize, // index in `exprs` |
| 659 | enumToInt: usize, // index in `exprs` | |
| 659 | 660 | compileError: []const u8, |
| 660 | 661 | string: []const u8, // direct value |
| 661 | 662 | // Index a `type` like struct with expressions |
| ... | ... | @@ -736,6 +737,11 @@ const DocData = struct { |
| 736 | 737 | \\{{ "bitSizeOf":{} }} |
| 737 | 738 | , .{v}); |
| 738 | 739 | }, |
| 740 | .enumToInt => |v| { | |
| 741 | try w.print( | |
| 742 | \\{{ "enumToInt":{} }} | |
| 743 | , .{v}); | |
| 744 | }, | |
| 739 | 745 | .fieldRef => |v| try std.json.stringify( |
| 740 | 746 | struct { fieldRef: FieldRef }{ .fieldRef = v }, |
| 741 | 747 | options, |
| ... | ... | @@ -2173,6 +2179,26 @@ fn walkInstruction( |
| 2173 | 2179 | .expr = .{ .bitSizeOf = operand_index }, |
| 2174 | 2180 | }; |
| 2175 | 2181 | }, |
| 2182 | .enum_to_int => { | |
| 2183 | // not working correctly with `align()` | |
| 2184 | const un_node = data[inst_index].un_node; | |
| 2185 | const operand = try self.walkRef( | |
| 2186 | file, | |
| 2187 | parent_scope, | |
| 2188 | un_node.operand, | |
| 2189 | false, | |
| 2190 | ); | |
| 2191 | const operand_index = self.exprs.items.len; | |
| 2192 | try self.exprs.append(self.arena, operand.expr); | |
| 2193 | ||
| 2194 | std.debug.print("un_node = {any}\n", .{un_node}); | |
| 2195 | std.debug.print("operand = {any}\n", .{operand}); | |
| 2196 | std.debug.print("operand_expr = {any}\n", .{operand.expr}); | |
| 2197 | return DocData.WalkResult{ | |
| 2198 | .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, | |
| 2199 | .expr = .{ .enumToInt = operand_index }, | |
| 2200 | }; | |
| 2201 | }, | |
| 2176 | 2202 | |
| 2177 | 2203 | .typeof => { |
| 2178 | 2204 | const un_node = data[inst_index].un_node; |