| author | |
| committer | |
| log | e7476fd81c9a4c95aa3f136c25b69e78ac53d803 |
| tree | cb8f03a9146b7aaa2f6994d940c48b74e8c7ea9d |
| parent | 81147dd1010644da0e61991561988d0e39de729c |
2 files changed, 51 insertions(+), 27 deletions(-)
lib/docs/main.js+33-11| ... | @@ -892,8 +892,8 @@ var zigAnalysis; | ... | @@ -892,8 +892,8 @@ var zigAnalysis; |
| 892 | let outer_decl_index = expr.switchOp.outer_decl; | 892 | let outer_decl_index = expr.switchOp.outer_decl; |
| 893 | let outer_decl = zigAnalysis.types[outer_decl_index]; | 893 | let outer_decl = zigAnalysis.types[outer_decl_index]; |
| 894 | let line = 0; | 894 | let line = 0; |
| 895 | console.log(expr.switchOp) | 895 | // console.log(expr.switchOp) |
| 896 | console.log(outer_decl) | 896 | // console.log(outer_decl) |
| 897 | while (outer_decl_index !== 0 && outer_decl.line_number > 0) { | 897 | while (outer_decl_index !== 0 && outer_decl.line_number > 0) { |
| 898 | line += outer_decl.line_number; | 898 | line += outer_decl.line_number; |
| 899 | outer_decl_index = outer_decl.outer_decl; | 899 | outer_decl_index = outer_decl.outer_decl; |
| ... | @@ -912,14 +912,24 @@ var zigAnalysis; | ... | @@ -912,14 +912,24 @@ var zigAnalysis; |
| 912 | const switchIndex = zigAnalysis.exprs[expr.switchIndex]; | 912 | const switchIndex = zigAnalysis.exprs[expr.switchIndex]; |
| 913 | return exprName(switchIndex, opts); | 913 | return exprName(switchIndex, opts); |
| 914 | } | 914 | } |
| 915 | case "fieldRef" : { | 915 | case "refPath" : { |
| 916 | // const fieldRef = zigAnalysis.decls[expr.fieldRef.index]; | 916 | // const fieldRef = zigAnalysis.decls[expr.fieldRef.index]; |
| 917 | // const struct_name = zigAnalysis.decls[expr.struct[0].val.typeRef.refPath[0].declRef].name; | 917 | const declRef = expr.refPath[0].declRef; |
| 918 | console.log(expr) | 918 | let name = zigAnalysis.decls[declRef].name; |
| 919 | // console.log(fieldRef) | 919 | console.log("refPath") |
| 920 | // return "@enumToInt(" + exprName(enumToInt, opts) + ")"; | 920 | console.log(expr.refPath) |
| 921 | // return exprName(fieldRef,opts); | 921 | console.log(declRef) |
| 922 | return "WIP" | 922 | for (let i = 1; i < expr.refPath.length; i++) { |
| 923 | name += "." + exprName(expr.refPath[i]); | ||
| 924 | } | ||
| 925 | return name; | ||
| 926 | } | ||
| 927 | case "fieldRef" : { | ||
| 928 | const fieldRef = zigAnalysis.decls[expr.fieldRef.index]; | ||
| 929 | const enumObj = exprName({"type":expr.fieldRef.type} ,opts); | ||
| 930 | // const name = zigAnalysis.astNodes[enumObj.ast + expr.fieldRef.index].name; | ||
| 931 | const name = zigAnalysis.astNodes[enumObj.ast + expr.fieldRef.index + 1].name; | ||
| 932 | return name | ||
| 923 | } | 933 | } |
| 924 | case "enumToInt" : { | 934 | case "enumToInt" : { |
| 925 | const enumToInt = zigAnalysis.exprs[expr.enumToInt]; | 935 | const enumToInt = zigAnalysis.exprs[expr.enumToInt]; |
| ... | @@ -1457,6 +1467,12 @@ var zigAnalysis; | ... | @@ -1457,6 +1467,12 @@ var zigAnalysis; |
| 1457 | if (typeof typeObj === 'number') typeObj = zigAnalysis.types[typeObj]; | 1467 | if (typeof typeObj === 'number') typeObj = zigAnalysis.types[typeObj]; |
| 1458 | switch (typeObj.kind) { | 1468 | switch (typeObj.kind) { |
| 1459 | default: throw "TODO"; | 1469 | default: throw "TODO"; |
| 1470 | case typeKinds.Enum: | ||
| 1471 | { | ||
| 1472 | let enumObj = (typeObj); | ||
| 1473 | |||
| 1474 | return enumObj; | ||
| 1475 | } | ||
| 1460 | case typeKinds.Opaque: | 1476 | case typeKinds.Opaque: |
| 1461 | { | 1477 | { |
| 1462 | let opaqueObj = (typeObj); | 1478 | let opaqueObj = (typeObj); |
| ... | @@ -2011,9 +2027,15 @@ var zigAnalysis; | ... | @@ -2011,9 +2027,15 @@ var zigAnalysis; |
| 2011 | function renderValue(decl) { | 2027 | function renderValue(decl) { |
| 2012 | let resolvedValue = resolveValue(decl.value) | 2028 | let resolvedValue = resolveValue(decl.value) |
| 2013 | 2029 | ||
| 2030 | if (resolvedValue.expr.fieldRef) { | ||
| 2014 | domFnProtoCode.innerHTML = '<span class="tok-kw">const</span> ' + | 2031 | domFnProtoCode.innerHTML = '<span class="tok-kw">const</span> ' + |
| 2015 | escapeHtml(decl.name) + ': ' + exprName(resolvedValue.typeRef, {wantHtml: true, wantLink:true}) + | 2032 | escapeHtml(decl.name) + ': ' + exprName(resolvedValue.expr.fieldRef, {wantHtml: true, wantLink:true}) + |
| 2016 | " = " + exprName(decl.value.expr, {wantHtml: true, wantLink:true}) + ";"; | 2033 | " = " + exprName(decl.value.expr, {wantHtml: true, wantLink:true}) + ";"; |
| 2034 | } else { | ||
| 2035 | domFnProtoCode.innerHTML = '<span class="tok-kw">const</span> ' + | ||
| 2036 | escapeHtml(decl.name) + ': ' + exprName(resolvedValue.typeRef, {wantHtml: true, wantLink:true}) + | ||
| 2037 | " = " + exprName(decl.value.expr, {wantHtml: true, wantLink:true}) + ";"; | ||
| 2038 | } | ||
| 2017 | 2039 | ||
| 2018 | let docs = zigAnalysis.astNodes[decl.src].docs; | 2040 | let docs = zigAnalysis.astNodes[decl.src].docs; |
| 2019 | if (docs != null) { | 2041 | if (docs != null) { |
src/Autodoc.zig+18-16| ... | @@ -1760,15 +1760,15 @@ fn walkInstruction( | ... | @@ -1760,15 +1760,15 @@ fn walkInstruction( |
| 1760 | const ast_index = self.ast_nodes.items.len; | 1760 | const ast_index = self.ast_nodes.items.len; |
| 1761 | const type_index = self.types.items.len - 1; | 1761 | const type_index = self.types.items.len - 1; |
| 1762 | 1762 | ||
| 1763 | const ast_line = self.ast_nodes.items[ast_index - 1]; | 1763 | // const ast_line = self.ast_nodes.items[ast_index - 1]; |
| 1764 | 1764 | ||
| 1765 | const sep = "=" ** 200; | 1765 | // const sep = "=" ** 200; |
| 1766 | std.debug.print("{s}\n", .{sep}); | 1766 | // std.debug.print("{s}\n", .{sep}); |
| 1767 | std.debug.print("SWITCH BLOCK\n", .{}); | 1767 | // std.debug.print("SWITCH BLOCK\n", .{}); |
| 1768 | std.debug.print("extra = {any}\n", .{extra}); | 1768 | // std.debug.print("extra = {any}\n", .{extra}); |
| 1769 | std.debug.print("outer_decl = {any}\n", .{self.types.items[type_index]}); | 1769 | // std.debug.print("outer_decl = {any}\n", .{self.types.items[type_index]}); |
| 1770 | std.debug.print("ast_lines = {}\n", .{ast_line}); | 1770 | // std.debug.print("ast_lines = {}\n", .{ast_line}); |
| 1771 | std.debug.print("{s}\n", .{sep}); | 1771 | // std.debug.print("{s}\n", .{sep}); |
| 1772 | 1772 | ||
| 1773 | const switch_index = self.exprs.items.len; | 1773 | const switch_index = self.exprs.items.len; |
| 1774 | try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .file_name = file.sub_file_path, .ast = ast_index, .outer_decl = type_index } }); | 1774 | try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .file_name = file.sub_file_path, .ast = ast_index, .outer_decl = type_index } }); |
| ... | @@ -1789,13 +1789,13 @@ fn walkInstruction( | ... | @@ -1789,13 +1789,13 @@ fn walkInstruction( |
| 1789 | const operand_index = self.exprs.items.len; | 1789 | const operand_index = self.exprs.items.len; |
| 1790 | try self.exprs.append(self.arena, operand.expr); | 1790 | try self.exprs.append(self.arena, operand.expr); |
| 1791 | 1791 | ||
| 1792 | const ast_index = self.ast_nodes.items.len; | 1792 | // const ast_index = self.ast_nodes.items.len; |
| 1793 | const sep = "=" ** 200; | 1793 | // const sep = "=" ** 200; |
| 1794 | std.debug.print("{s}\n", .{sep}); | 1794 | // std.debug.print("{s}\n", .{sep}); |
| 1795 | std.debug.print("SWITCH COND\n", .{}); | 1795 | // std.debug.print("SWITCH COND\n", .{}); |
| 1796 | std.debug.print("ast index = {}\n", .{ast_index}); | 1796 | // std.debug.print("ast index = {}\n", .{ast_index}); |
| 1797 | std.debug.print("ast previous = {}\n", .{self.ast_nodes.items[ast_index - 1]}); | 1797 | // std.debug.print("ast previous = {}\n", .{self.ast_nodes.items[ast_index - 1]}); |
| 1798 | std.debug.print("{s}\n", .{sep}); | 1798 | // std.debug.print("{s}\n", .{sep}); |
| 1799 | 1799 | ||
| 1800 | return DocData.WalkResult{ | 1800 | return DocData.WalkResult{ |
| 1801 | .typeRef = operand.typeRef, | 1801 | .typeRef = operand.typeRef, |
| ... | @@ -1917,7 +1917,9 @@ fn walkInstruction( | ... | @@ -1917,7 +1917,9 @@ fn walkInstruction( |
| 1917 | // While it would make sense to grab the original decl's typeRef info, | 1917 | // While it would make sense to grab the original decl's typeRef info, |
| 1918 | // that decl might not have been analyzed yet! The frontend will have | 1918 | // that decl might not have been analyzed yet! The frontend will have |
| 1919 | // to navigate through all declRefs to find the underlying type. | 1919 | // to navigate through all declRefs to find the underlying type. |
| 1920 | return DocData.WalkResult{ .expr = .{ .declRef = decls_slot_index } }; | 1920 | return DocData.WalkResult{ |
| 1921 | .expr = .{ .declRef = decls_slot_index }, | ||
| 1922 | }; | ||
| 1921 | }, | 1923 | }, |
| 1922 | .field_val, .field_call_bind, .field_ptr, .field_type => { | 1924 | .field_val, .field_call_bind, .field_ptr, .field_type => { |
| 1923 | // TODO: field type uses Zir.Inst.FieldType, it just happens to have the | 1925 | // TODO: field type uses Zir.Inst.FieldType, it just happens to have the |