From a02215795639294a723f8e5c5aa1d39a089962f3 Mon Sep 17 00:00:00 2001 From: Der Teufel Date: Sun, 21 Aug 2022 05:29:39 +0200 Subject: [PATCH 1/2] autodoc: compileError now uses index into `exprs` instead of a `[]const u8` --- lib/docs/main.js | 2 +- src/Autodoc.zig | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index 28f8fb1a70..b6131f4bb3 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -866,7 +866,7 @@ var zigAnalysis; } case "compileError": { let compileError = expr.compileError; - return compileError; + return "@compileError(" + exprName(zigAnalysis.exprs[compileError]) + ")"; } case "enumLiteral": { let literal = expr.enumLiteral; diff --git a/src/Autodoc.zig b/src/Autodoc.zig index bc1b1beebb..f983bdfdf0 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -632,7 +632,7 @@ const DocData = struct { sizeOf: usize, // index in `exprs` bitSizeOf: usize, // index in `exprs` enumToInt: usize, // index in `exprs` - compileError: []const u8, + compileError: usize, //index in `exprs` errorSets: usize, string: []const u8, // direct value sliceIndex: usize, @@ -1027,13 +1027,11 @@ fn walkInstruction( false, ); + const operand_index = self.exprs.items.len; + try self.exprs.append(self.arena, operand.expr); + return DocData.WalkResult{ - .expr = .{ - .compileError = switch (operand.expr) { - .string => |s| s, - else => "TODO: non-string @compileError arguments", - }, - }, + .expr = .{ .compileError = operand_index }, }; }, .enum_literal => { From 76c9ee9b303937aef62f5ad10eab7ff56d607e34 Mon Sep 17 00:00:00 2001 From: Der Teufel Date: Sun, 21 Aug 2022 06:32:26 +0200 Subject: [PATCH 2/2] autodoc: Fixed compileError case in exprName --- lib/docs/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index b6131f4bb3..90701b4509 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -866,7 +866,7 @@ var zigAnalysis; } case "compileError": { let compileError = expr.compileError; - return "@compileError(" + exprName(zigAnalysis.exprs[compileError]) + ")"; + return "@compileError(" + exprName(zigAnalysis.exprs[compileError], opts) + ")"; } case "enumLiteral": { let literal = expr.enumLiteral;