mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
autodoc: fix support for slice_length ZIR instruction
This commit is contained in:
parent
5bb8e9cd97
commit
2c5924c59a
@ -1093,6 +1093,23 @@ const NAV_MODES = {
|
||||
payloadHtml += decl + "[" + start + ".." + end + sentinel + "]";
|
||||
return payloadHtml;
|
||||
}
|
||||
case "sliceLength": {
|
||||
let payloadHtml = "";
|
||||
const lhsExpr = zigAnalysis.exprs[expr.sliceLength.lhs];
|
||||
const startExpr = zigAnalysis.exprs[expr.sliceLength.start];
|
||||
const lenExpr = zigAnalysis.exprs[expr.sliceLength.len];
|
||||
let decl = exprName(lhsExpr, opts);
|
||||
let start = exprName(startExpr, opts);
|
||||
let len = exprName(lenExpr, opts);
|
||||
let sentinel = "";
|
||||
if (expr.sliceLength["sentinel"]) {
|
||||
const sentinelExpr = zigAnalysis.exprs[expr.sliceLength.sentinel];
|
||||
let sentinel_ = exprName(sentinelExpr, options);
|
||||
sentinel += " :" + sentinel_;
|
||||
}
|
||||
payloadHtml += decl + "[" + start + "..][0.." + len + sentinel + "]";
|
||||
return payloadHtml;
|
||||
}
|
||||
case "sliceIndex": {
|
||||
const sliceIndex = zigAnalysis.exprs[expr.sliceIndex];
|
||||
return exprName(sliceIndex, opts, opts);
|
||||
@ -4850,4 +4867,4 @@ function RadixTree() {
|
||||
|
||||
// BUT!
|
||||
|
||||
// We want to be able to search "Hash", for example!
|
||||
// We want to be able to search "Hash", for example!
|
||||
|
||||
@ -755,6 +755,7 @@ const DocData = struct {
|
||||
string: []const u8, // direct value
|
||||
sliceIndex: usize,
|
||||
slice: Slice,
|
||||
sliceLength: SliceLength,
|
||||
cmpxchgIndex: usize,
|
||||
cmpxchg: Cmpxchg,
|
||||
builtin: Builtin,
|
||||
@ -791,6 +792,12 @@ const DocData = struct {
|
||||
end: ?usize = null,
|
||||
sentinel: ?usize = null, // index in `exprs`
|
||||
};
|
||||
const SliceLength = struct {
|
||||
lhs: usize,
|
||||
start: usize,
|
||||
len: usize,
|
||||
sentinel: ?usize = null,
|
||||
};
|
||||
const Cmpxchg = struct {
|
||||
name: []const u8,
|
||||
type: usize,
|
||||
@ -1337,7 +1344,12 @@ fn walkInstruction(
|
||||
try self.exprs.append(self.arena, sentinel.expr);
|
||||
break :sentinel_index index;
|
||||
} else null;
|
||||
self.exprs.items[slice_index] = .{ .slice = .{ .lhs = lhs_index, .start = start_index, .end = len_index, .sentinel = sentinel_index } };
|
||||
self.exprs.items[slice_index] = .{ .sliceLength = .{
|
||||
.lhs = lhs_index,
|
||||
.start = start_index,
|
||||
.len = len_index,
|
||||
.sentinel = sentinel_index,
|
||||
} };
|
||||
|
||||
return DocData.WalkResult{
|
||||
.typeRef = self.decls.items[lhs.expr.declRef.Analyzed].value.typeRef,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user