diff options
| author | Vallahor <vallahor91@gmail.com> | 2022-05-30 15:45:57 -0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-07-19 19:10:12 -0700 |
| commit | f07534069deaa500df075ca6424f4bce29dcd7f8 (patch) | |
| tree | a32dc7bf80163bbc2e8dc4f21f1a2f2bbaade0d1 /lib/docs | |
| parent | 9be9e4d02c059e55c476fd98e789bbc02c08730a (diff) | |
| download | zig-f07534069deaa500df075ca6424f4bce29dcd7f8.tar.gz zig-f07534069deaa500df075ca6424f4bce29dcd7f8.zip | |
WIP: switch_block tag
Diffstat (limited to 'lib/docs')
| -rw-r--r-- | lib/docs/main.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/docs/main.js b/lib/docs/main.js index 12161b80d3..520457c3d1 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1062,6 +1062,36 @@ var zigAnalysis; function exprName(expr, opts) { switch (Object.keys(expr)[0]) { default: throw "oh no"; + case "enumLiteral": { + let literal = expr.enumLiteral; + return literal; + } + case "switchOp":{ + let payloadHtml = "switch() {</br>"; + for (let i = 0; i < expr.switchOp.cases.length; i++) { + const caseIndex = expr.switchOp.cases[i]; + const item = zigAnalysis.exprs[caseIndex]; + console.log(caseIndex); + console.log(item); + if (item['enumLiteral']) { + payloadHtml += " " + " ." + exprName(item, opts) + " = " + "</br>"; + continue; + } + payloadHtml += " " + exprName(item, opts) + " = " + "</br>"; + } + if (expr.switchOp.else_index !== 0) { + const else_index = expr.switchOp.else_index; + const item = zigAnalysis.exprs[else_index]; + console.log(item); + payloadHtml += " " + "else" + " = " + "</br>"; + } + payloadHtml += "}"; + return payloadHtml; + } + case "switchIndex": { + const switchIndex = zigAnalysis.exprs[expr.switchIndex]; + return exprName(switchIndex, opts); + } case "fieldRef" : { // const fieldRef = zigAnalysis.decls[expr.fieldRef.index]; // const struct_name = zigAnalysis.decls[expr.struct[0].val.typeRef.refPath[0].declRef].name; |
