Commit d707cd6e6d
Changed files (2)
lib
docs
src
lib/docs/main.js
@@ -1045,7 +1045,11 @@ var zigAnalysis;
*/
function walkResultTypeRef(wr) {
if (wr.typeRef) return wr.typeRef;
- return walkResultTypeRef(resolveValue(wr));
+ let resolved = resolveValue(wr);
+ if (wr === resolved) {
+ return {type: 0};
+ }
+ return walkResultTypeRef(resolved);
}
/**
* @typedef {{
@@ -1128,6 +1132,10 @@ var zigAnalysis;
switch (typeObj.kind) {
default: throw "TODO";
+ case typeKinds.ComptimeExpr:
+ {
+ return "[ComptimeExpr]";
+ }
case typeKinds.Array:
{
let arrayObj = /** @type {ArrayType} */ (typeObj);
@@ -1660,7 +1668,7 @@ var zigAnalysis;
const funcRetExpr = resolveValue({
expr: /** @type {Fn} */(typeExpr).ret
});
- if ("type" in funcRetExpr && funcRetExpr.type != typeTypeId) {
+ if ("type" in funcRetExpr.expr && funcRetExpr.expr.type == typeTypeId) {
if (typeIsErrSet(declValue.expr.type)) {
errSetsList.push(decl);
} else if (typeIsStructWithNoFields(declValue.expr.type)) {
@@ -1671,9 +1679,15 @@ var zigAnalysis;
} else {
fnsList.push(decl);
}
- } else {
- typesList.push(decl);
- }
+ } else {
+ if (typeIsErrSet(declValue.expr.type)) {
+ errSetsList.push(decl);
+ } else if (typeIsStructWithNoFields(declValue.expr.type)) {
+ namespacesList.push(decl);
+ } else {
+ typesList.push(decl);
+ }
+ }
} else if ("typeRef" in declValue) {
if ("type" in declValue.typeRef && declValue.typeRef == typeTypeId) {
// We don't know what the type expression is, but we know it's a type.
@@ -2098,14 +2112,14 @@ var zigAnalysis;
if (list[mainDeclIndex] != null) continue;
let decl = zigAnalysis.decls[mainDeclIndex];
- let declVal = resolveValue(decl.value);
+ let declVal = decl.value; //resolveValue(decl.value);
let declNames = item.declNames.concat([decl.name]);
list[mainDeclIndex] = {
pkgNames: pkgNames,
declNames: declNames,
};
- if ("type" in declVal) {
- let value = zigAnalysis.types[declVal.type];
+ if ("type" in declVal.expr) {
+ let value = zigAnalysis.types[declVal.expr.type];
if (declCanRepresentTypeKind(value.kind))
{
canonTypeDecls[declVal.type] = mainDeclIndex;
@@ -2130,15 +2144,15 @@ var zigAnalysis;
if (canonDeclPaths == null) {
canonDeclPaths = computeCanonDeclPaths();
}
- let cd = /** @type {CanonDecl[]}*/(canonDeclPaths);
- return cd[index];
+ //let cd = /** @type {CanonDecl[]}*/(canonDeclPaths);
+ return canonDeclPaths[index];
}
/** @param {number} index */
function getCanonTypeDecl(index) {
getCanonDeclPath(0);
- let ct = /** @type {number[]}*/(canonTypeDecls);
- return ct[index];
+ //let ct = /** @type {number[]}*/(canonTypeDecls);
+ return canonTypeDecls[index];
}
/** @param {string} text */
@@ -2646,7 +2660,9 @@ function renderSearch() {
let lastPkgName = canonPath.pkgNames[canonPath.pkgNames.length - 1];
let fullPathSearchText = lastPkgName + "." + canonPath.declNames.join('.');
let astNode = zigAnalysis.astNodes[decl.src];
- let fileAndDocs = zigAnalysis.files[astNode.file];
+ let fileAndDocs = "" //zigAnalysis.files[astNode.file];
+ // TODO: understand what this piece of code is trying to achieve
+ // also right now `files` are expressed as a hashmap.
if (astNode.docs != null) {
fileAndDocs += "\n" + astNode.docs;
}
src/Autodoc.zig
@@ -474,6 +474,7 @@ const DocData = struct {
.Int => |v| try printTypeBody(v, options, w),
.Float => |v| try printTypeBody(v, options, w),
.Type => |v| try printTypeBody(v, options, w),
+ .EnumLiteral => |v| try printTypeBody(v, options, w),
.Pointer => |v| {
if (options.whitespace) |ws| try ws.outputIndent(w);
try w.print(
@@ -807,7 +808,15 @@ fn walkInstruction(
.enum_literal => {
const str_tok = data[inst_index].str_tok;
const literal = file.zir.nullTerminatedString(str_tok.start);
- return DocData.WalkResult{ .expr = .{ .enumLiteral = literal } };
+ const type_index = self.types.items.len;
+ try self.types.append(self.arena, .{
+ .EnumLiteral = .{ .name = "todo enum literal" },
+ });
+
+ return DocData.WalkResult{
+ .typeRef = .{ .type = type_index },
+ .expr = .{ .enumLiteral = literal },
+ };
},
.int => {
const int = data[inst_index].int;
@@ -1019,6 +1028,15 @@ fn walkInstruction(
array_data[idx] = expr_index;
}
+ if (array_type == null) {
+ panicWithContext(
+ file,
+ inst_index,
+ "array_type was null!!",
+ .{},
+ );
+ }
+
const type_slot_index = self.types.items.len;
try self.types.append(self.arena, .{
.Array = .{