From 270e2c18bf4dde537361f40819fb8d3991249586 Mon Sep 17 00:00:00 2001 From: Vallahor Date: Thu, 26 May 2022 16:47:16 -0300 Subject: [PATCH] fix: @TypeOf() now rendering --- lib/docs/main.js | 5 +++++ src/Autodoc.zig | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index 4964496b53..4f4d68f7b0 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1083,6 +1083,11 @@ var zigAnalysis; struct_body += "}"; return struct_body; } + case "typeOf": { + const typeRefArg = zigAnalysis.exprs[expr.typeOf]; + let payloadHtml = "@TypeOf(" + exprName(typeRefArg) + ")"; + return payloadHtml; + } case "null": { return "null"; } diff --git a/src/Autodoc.zig b/src/Autodoc.zig index 9a90d03c2c..6302abccf2 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -1242,10 +1242,6 @@ fn walkInstruction( }; }, .typeof_builtin => { - // @check: @TypeOf(T) - // right now it's only showing the T - // a way to solve it could be creating a .call - // another way is with a flag to handle it on Frontend const pl_node = data[inst_index].pl_node; const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index); const body = file.zir.extra[extra.end..][extra.data.body_len - 1]; @@ -1257,7 +1253,13 @@ fn walkInstruction( false, ); - return operand; + const operand_index = self.exprs.items.len; + try self.exprs.append(self.arena, operand.expr); + + return DocData.WalkResult{ + .typeRef = operand.typeRef, + .expr = .{ .typeOf = operand_index }, + }; }, .type_info => { // @check