mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 00:35:10 +00:00
autodoc: Implement various missing expressions in ex (#17129)
Co-authored-by: Loris Cro <kappaloris@gmail.com>
This commit is contained in:
parent
f2026e7dd6
commit
2651363c9d
115
lib/docs/main.js
115
lib/docs/main.js
@ -1348,7 +1348,12 @@ Happy writing!
|
||||
yield { src: "false", tag: Tag.identifier };
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
case "unreachable": {
|
||||
yield { src: "unreachable", tag: Tag.identifier };
|
||||
return;
|
||||
}
|
||||
|
||||
case "&": {
|
||||
yield { src: "&", tag: Tag.ampersand };
|
||||
yield* ex(zigAnalysis.exprs[expr["&"]], opts);
|
||||
@ -1490,6 +1495,59 @@ Happy writing!
|
||||
yield Tok.r_bracket;
|
||||
return;
|
||||
}
|
||||
|
||||
case "sliceIndex": {
|
||||
const slice = zigAnalysis.exprs[expr.sliceIndex];
|
||||
yield* ex(slice, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
case "slice": {
|
||||
const slice = expr.slice;
|
||||
const lhs = zigAnalysis.exprs[slice.lhs];
|
||||
const start = zigAnalysis.exprs[slice.start];
|
||||
yield* ex(lhs, opts);
|
||||
yield Tok.l_bracket;
|
||||
yield* ex(start, opts);
|
||||
yield Tok.period;
|
||||
yield Tok.period;
|
||||
if (slice.end !== null) {
|
||||
const end = zigAnalysis.exprs[slice.end];
|
||||
yield* ex(end, opts);
|
||||
}
|
||||
if (slice.sentinel !== null) {
|
||||
yield Tok.colon;
|
||||
const sent = zigAnalysis.exprs[slice.sentinel];
|
||||
yield* ex(sent, opts);
|
||||
}
|
||||
yield Tok.r_brace;
|
||||
return;
|
||||
}
|
||||
|
||||
case "sliceLength": {
|
||||
const slice = expr.sliceLength;
|
||||
const lhs = zigAnalysis.exprs[slice.lhs];
|
||||
const start = zigAnalysis.exprs[slice.start];
|
||||
const len = zigAnalysis.exprs[slice.len];
|
||||
yield* ex(lhs, opts);
|
||||
yield Tok.l_bracket;
|
||||
yield* ex(start, opts);
|
||||
yield Tok.period;
|
||||
yield Tok.period;
|
||||
yield Tok.r_bracket;
|
||||
yield Tok.l_bracket;
|
||||
yield { src: "0", tag: Tag.number_literal };
|
||||
yield Tok.period;
|
||||
yield Tok.period;
|
||||
yield* ex(len, opts);
|
||||
if (slice.sentinel !== null) {
|
||||
yield Tok.colon;
|
||||
const sent = zigAnalysis.exprs[slice.sentinel];
|
||||
yield* ex(sent, opts);
|
||||
}
|
||||
yield Tok.r_brace;
|
||||
return;
|
||||
}
|
||||
|
||||
case "string": {
|
||||
yield { src: '"' + expr.string + '"', tag: Tag.string_literal };
|
||||
@ -1952,6 +2010,55 @@ Happy writing!
|
||||
return;
|
||||
}
|
||||
|
||||
case "cmpxchgIndex": {
|
||||
const cmpxchg = zigAnalysis.exprs[expr.cmpxchgIndex];
|
||||
yield* ex(cmpxchg, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
case "cmpxchg": {
|
||||
const type = zigAnalysis.exprs[expr.cmpxchg.type];
|
||||
const ptr = zigAnalysis.exprs[expr.cmpxchg.ptr];
|
||||
const expectedValue = zigAnalysis.exprs[expr.cmpxchg.expected_value];
|
||||
const newValue = zigAnalysis.exprs[expr.cmpxchg.new_value];
|
||||
const successOrder = zigAnalysis.exprs[expr.cmpxchg.success_order];
|
||||
const failureOrder = zigAnalysis.exprs[expr.cmpxchg.failure_order];
|
||||
|
||||
let fnName = "@";
|
||||
switch (expr.cmpxchg.name) {
|
||||
case "cmpxchg_strong": {
|
||||
fnName += "cmpxchgStrong";
|
||||
break;
|
||||
}
|
||||
case "cmpxchg_weak": {
|
||||
fnName += "cmpxchgWeak";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw "Unexpected cmpxchg name: `" + expr.cmpxchg.name + "`!";
|
||||
}
|
||||
yield { src: fnName, tag: Tag.builtin };
|
||||
yield Tok.l_paren;
|
||||
yield* ex(type, opts);
|
||||
yield Tok.comma;
|
||||
yield Tok.space;
|
||||
yield* ex(ptr, opts);
|
||||
yield Tok.comma;
|
||||
yield Tok.space;
|
||||
yield* ex(expectedValue, opts);
|
||||
yield Tok.comma;
|
||||
yield Tok.space;
|
||||
yield* ex(newValue, opts);
|
||||
yield Tok.comma;
|
||||
yield Tok.space;
|
||||
yield* ex(successOrder, opts);
|
||||
yield Tok.comma;
|
||||
yield Tok.space;
|
||||
yield* ex(failureOrder, opts);
|
||||
yield Tok.r_paren;
|
||||
return;
|
||||
}
|
||||
|
||||
case "enumLiteral": {
|
||||
let literal = expr.enumLiteral;
|
||||
yield Tok.period;
|
||||
@ -2565,6 +2672,7 @@ Happy writing!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case "typeOf": {
|
||||
const typeRefArg = zigAnalysis.exprs[expr.typeOf];
|
||||
yield { src: "@TypeOf", tag: Tag.builtin };
|
||||
@ -2573,6 +2681,11 @@ Happy writing!
|
||||
yield Tok.r_paren;
|
||||
return;
|
||||
}
|
||||
|
||||
case "builtinField": {
|
||||
yield { src: expr.builtinField, tag: Tag.identifier };
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user