diff --git a/lib/docs/main.js b/lib/docs/main.js index 56c31d282d..4d8f88b30e 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1,322 +1,81 @@ 'use strict'; -/** - * @typedef { - | "Type" - | "Void" - | "Bool" - | "NoReturn" - | "Int" - | "Float" - | "Pointer" - | "Array" - | "Struct" - | "ComptimeFloat" - | "ComptimeInt" - | "Undefined" - | "Null" - | "Optional" - | "ErrorUnion" - | "ErrorSet" - | "Enum" - | "Union" - | "Fn" - | "BoundFn" - | "Opaque" - | "Frame" - | "AnyFrame" - | "Vector" - | "EnumLiteral" - | "ComptimeExpr" - | "Unanalyzed" - } TypeKind -*/ - -/** - * @typedef {{ - typeRef: Expr?, - expr: Expr, - }} WalkResult -*/ - -/** - * @typedef {{ - void: {}, - unreachable: {}, - anytype: {}, - type: number, - comptimeExpr: number, - call: number, - int: number, - float: number, - bool: boolean, - undefined: WalkResult, - null: WalkResult, - typeOf: WalkResult, - compileError: string - string: string, - struct: Expr[], - refPath: Expr[], - declRef: number, - array: ZigArray, - enumLiteral: string, - }} Expr -*/ - -/** - * @typedef {{ - kind: number, - name: string, - src: number, - privDecls: number[], - pubDecls: number[], - fields: WalkResult[] -}} ContainerType -*/ - -/** - * @typedef {{ - kind: number, - name: string, - src: number, - ret: WalkResult, - params: WalkResult[], - generic: boolean, - }} Fn -*/ - -/** -* @typedef {{ - kind: number, - name: string, - fields: { name: string, docs: string }[] - fn: number | undefined, -}} ErrSetType -*/ - -/** -* @typedef {{ - kind: number, - err: WalkResult, - payload: WalkResult, -}} ErrUnionType -*/ - -// Type, Void, Bool, NoReturn, Int, Float, ComptimeExpr, ComptimeFloat, ComptimeInt, Undefined, Null, ErrorUnion, BoundFn, Opaque, Frame, AnyFrame, Vector, EnumLiteral -/** -* @typedef {{ - kind: number, - name: string -}} NumberType -*/ - -/** -* @typedef {{ - kind: number, - size: number, - child: WalkResult - align: number, - bitOffsetInHost: number, - hostIntBytes: number, - volatile: boolean, - const: boolean, -}} PointerType -*/ - -/** -* @typedef {{ - kind: number, - len: WalkResult - child: WalkResult -}} ArrayType -*/ - -/** -* @typedef {{ - kind: number, - name: string, - child: Expr, -}} OptionalType -*/ - -/** - * @typedef { - | OptionalType - | ArrayType - | PointerType - | ContainerType - | Fn - | ErrSetType - | ErrUnionType - | NumberType - } Type -*/ - - -/** - * @typedef {{ - func: Expr, - args: Expr[], - ret: Expr, - }} Call -*/ - -/** - * @typedef {{ - file: number, - line: number, - col: number, - name?: string, - docs?: string, - fields?: number[], - comptime: boolean, - noalias: boolean, - varArgs: boolean, - }} AstNode -*/ - -/** - * @typedef {{ - name: string, - kind: string, - src: number, - value: WalkResult, - decltest?: number, - isTest: boolean, - }} Decl -*/ - -/** - * @typedef {{ - name: string, - file: number, - main: number, - table: Record, - }} Package -*/ - -/** - * @typedef {{ - typeRef: WalkResult, - data: WalkResult[], - }} ZigArray -*/ - -/** - * @typedef {{ - code: string, - typeRef: WalkResult, - }} ComptimeExpr -*/ - -/** - * @typedef {{ - typeKinds: TypeKind[]; - rootPkg: number; - params: { - zigId: string; - zigVersion: string; - target: string; - rootName: string; - builds: { target: string }; - }; - packages: Package[]; - errors: {}; - astNodes: AstNode[]; - calls: Call[]; - files: Record; - types: Type[]; - decls: Decl[]; - comptimeExprs: ComptimeExpr[]; - fns: Fn[]; - }} DocData -*/ - -/** @type {DocData} */ var zigAnalysis; (function() { - let domStatus = /** @type HTMLElement */(document.getElementById("status")); - let domSectNav = /** @type HTMLElement */(document.getElementById("sectNav")); - let domListNav = /** @type HTMLElement */(document.getElementById("listNav")); - let domSectMainPkg = /** @type HTMLElement */(document.getElementById("sectMainPkg")); - let domSectPkgs = /** @type HTMLElement */(document.getElementById("sectPkgs")); - let domListPkgs = /** @type HTMLElement */(document.getElementById("listPkgs")); - let domSectTypes = /** @type HTMLElement */(document.getElementById("sectTypes")); - let domListTypes = /** @type HTMLElement */(document.getElementById("listTypes")); - let domSectTests = /** @type HTMLElement */(document.getElementById("sectTests")); - let domListTests = /** @type HTMLElement */(document.getElementById("listTests")); - let domSectNamespaces = /** @type HTMLElement */(document.getElementById("sectNamespaces")); - let domListNamespaces = /** @type HTMLElement */(document.getElementById("listNamespaces")); - let domSectErrSets = /** @type HTMLElement */(document.getElementById("sectErrSets")); - let domListErrSets = /** @type HTMLElement */(document.getElementById("listErrSets")); - let domSectFns = /** @type HTMLElement */(document.getElementById("sectFns")); - let domListFns = /** @type HTMLElement */(document.getElementById("listFns")); - let domSectFields = /** @type HTMLElement */(document.getElementById("sectFields")); - let domListFields = /** @type HTMLElement */(document.getElementById("listFields")); - let domSectGlobalVars = /** @type HTMLElement */(document.getElementById("sectGlobalVars")); - let domListGlobalVars = /** @type HTMLElement */(document.getElementById("listGlobalVars")); - let domSectValues = /** @type HTMLElement */(document.getElementById("sectValues")); - let domListValues = /** @type HTMLElement */(document.getElementById("listValues")); - let domFnProto = /** @type HTMLElement */(document.getElementById("fnProto")); - let domFnProtoCode = /** @type HTMLElement */(document.getElementById("fnProtoCode")); - let domSectParams = /** @type HTMLElement */(document.getElementById("sectParams")); - let domListParams = /** @type HTMLElement */(document.getElementById("listParams")); - let domTldDocs = /** @type HTMLElement */(document.getElementById("tldDocs")); - let domSectFnErrors = /** @type HTMLElement */(document.getElementById("sectFnErrors")); - let domListFnErrors = /** @type HTMLElement */(document.getElementById("listFnErrors")); - let domTableFnErrors =/** @type HTMLElement */(document.getElementById("tableFnErrors")); - let domFnErrorsAnyError = /** @type HTMLElement */(document.getElementById("fnErrorsAnyError")); - let domFnExamples = /** @type HTMLElement */(document.getElementById("fnExamples")); - // let domListFnExamples = /** @type HTMLElement */(document.getElementById("listFnExamples")); - let domFnNoExamples = /** @type HTMLElement */(document.getElementById("fnNoExamples")); - let domDeclNoRef = /** @type HTMLElement */(document.getElementById("declNoRef")); - let domSearch = /** @type HTMLInputElement */(document.getElementById("search")); - let domSectSearchResults = /** @type HTMLElement */(document.getElementById("sectSearchResults")); + let domStatus = (document.getElementById("status")); + let domSectNav = (document.getElementById("sectNav")); + let domListNav = (document.getElementById("listNav")); + let domSectMainPkg = (document.getElementById("sectMainPkg")); + let domSectPkgs = (document.getElementById("sectPkgs")); + let domListPkgs = (document.getElementById("listPkgs")); + let domSectTypes = (document.getElementById("sectTypes")); + let domListTypes = (document.getElementById("listTypes")); + let domSectTests = (document.getElementById("sectTests")); + let domListTests = (document.getElementById("listTests")); + let domSectNamespaces = (document.getElementById("sectNamespaces")); + let domListNamespaces = (document.getElementById("listNamespaces")); + let domSectErrSets = (document.getElementById("sectErrSets")); + let domListErrSets = (document.getElementById("listErrSets")); + let domSectFns = (document.getElementById("sectFns")); + let domListFns = (document.getElementById("listFns")); + let domSectFields = (document.getElementById("sectFields")); + let domListFields = (document.getElementById("listFields")); + let domSectGlobalVars = (document.getElementById("sectGlobalVars")); + let domListGlobalVars = (document.getElementById("listGlobalVars")); + let domSectValues = (document.getElementById("sectValues")); + let domListValues = (document.getElementById("listValues")); + let domFnProto = (document.getElementById("fnProto")); + let domFnProtoCode = (document.getElementById("fnProtoCode")); + let domSectParams = (document.getElementById("sectParams")); + let domListParams = (document.getElementById("listParams")); + let domTldDocs = (document.getElementById("tldDocs")); + let domSectFnErrors = (document.getElementById("sectFnErrors")); + let domListFnErrors = (document.getElementById("listFnErrors")); + let domTableFnErrors =(document.getElementById("tableFnErrors")); + let domFnErrorsAnyError = (document.getElementById("fnErrorsAnyError")); + let domFnExamples = (document.getElementById("fnExamples")); + // let domListFnExamples = (document.getElementById("listFnExamples")); + let domFnNoExamples = (document.getElementById("fnNoExamples")); + let domDeclNoRef = (document.getElementById("declNoRef")); + let domSearch = (document.getElementById("search")); + let domSectSearchResults = (document.getElementById("sectSearchResults")); - let domListSearchResults = /** @type HTMLElement */(document.getElementById("listSearchResults")); - let domSectSearchNoResults = /** @type HTMLElement */(document.getElementById("sectSearchNoResults")); - let domSectInfo = /** @type HTMLElement */(document.getElementById("sectInfo")); - // let domTdTarget = /** @type HTMLElement */(document.getElementById("tdTarget")); - let domPrivDeclsBox = /** @type HTMLInputElement */(document.getElementById("privDeclsBox")); - let domTdZigVer = /** @type HTMLElement */(document.getElementById("tdZigVer")); - let domHdrName = /** @type HTMLElement */(document.getElementById("hdrName")); - let domHelpModal = /** @type HTMLElement */(document.getElementById("helpDialog")); + let domListSearchResults = (document.getElementById("listSearchResults")); + let domSectSearchNoResults = (document.getElementById("sectSearchNoResults")); + let domSectInfo = (document.getElementById("sectInfo")); + // let domTdTarget = (document.getElementById("tdTarget")); + let domPrivDeclsBox = (document.getElementById("privDeclsBox")); + let domTdZigVer = (document.getElementById("tdZigVer")); + let domHdrName = (document.getElementById("hdrName")); + let domHelpModal = (document.getElementById("helpDialog")); - /** @type number | null */ + let searchTimer = null; - /** @type Object */ + let escapeHtmlReplacements = { "&": "&", '"': """, "<": "<", ">": ">" }; - let typeKinds = /** @type {Record} */(indexTypeKinds()); - let typeTypeId = /** @type {number} */ (findTypeTypeId()); + let typeKinds = (indexTypeKinds()); + let typeTypeId = (findTypeTypeId()); let pointerSizeEnum = { One: 0, Many: 1, Slice: 2, C: 3 }; // for each package, is an array with packages to get to this one let canonPkgPaths = computeCanonicalPackagePaths(); - /** @typedef {{declNames: string[], pkgNames: string[]}} CanonDecl */ + // for each decl, is an array with {declNames, pkgNames} to get to this one - /** @type CanonDecl[] | null */ + let canonDeclPaths = null; // lazy; use getCanonDeclPath // for each type, is an array with {declNames, pkgNames} to get to this one - /** @type number[] | null */ + let canonTypeDecls = null; // lazy; use getCanonTypeDecl - /** @typedef {{ - * showPrivDecls: boolean, - * pkgNames: string[], - * pkgObjs: Package[], - * declNames: string[], - * declObjs: (Decl | Type)[], - * callName: any, - * }} CurNav - */ + - /** @type {CurNav} */ + let curNav = { showPrivDecls: false, // each element is a package name, e.g. @import("a") then within there @import("b") @@ -381,34 +140,34 @@ var zigAnalysis; } } - /** @param {Type | Decl} x */ + function isDecl(x) { return "value" in x; } - /** @param {Type | Decl} x */ + function isType(x) { return "kind" in x && !("value" in x); } - /** @param {Type | Decl} x */ + function isContainerType(x) { - return isType(x) && typeKindIsContainer(/** @type {Type} */(x).kind) ; + return isType(x) && typeKindIsContainer((x).kind) ; } - /** @param {Expr} expr */ + function typeShorthandName(expr) { let resolvedExpr = resolveValue({expr: expr}); if (!("type" in resolvedExpr)) { return null; } - let type = /** @type {Type} */(zigAnalysis.types[resolvedExpr.type]); + let type = (zigAnalysis.types[resolvedExpr.type]); outer: for (let i = 0; i < 10000; i += 1) { switch (type.kind) { case typeKinds.Optional: case typeKinds.Pointer: - let child = /** @type {PointerType | OptionalType} */(type).child; + let child = (type).child; let resolvedChild = resolveValue(child); if ("type" in resolvedChild) { type = zigAnalysis.types[resolvedChild.type]; @@ -440,22 +199,19 @@ var zigAnalysis; return escapeHtml(name); } - /** @param {number} typeKind */ + function typeKindIsContainer(typeKind) { return typeKind === typeKinds.Struct || typeKind === typeKinds.Union || typeKind === typeKinds.Enum; } - /** @param {number} typeKind */ + function declCanRepresentTypeKind(typeKind) { return typeKind === typeKinds.ErrorSet || typeKindIsContainer(typeKind); } - // /** - // * @param {WalkResult[]} path - // * @return {WalkResult | null} - // */ + // // function findCteInRefPath(path) { // for (let i = path.length - 1; i >= 0; i -= 1) { // const ref = path[i]; @@ -468,10 +224,7 @@ var zigAnalysis; // return null; // } - /** - * @param {WalkResult} value - * @return {WalkResult} - */ + function resolveValue(value) { let i = 0; while(i < 1000) { @@ -499,13 +252,10 @@ var zigAnalysis; } console.assert(false); - return /** @type {WalkResult} */({}); + return ({}); } - /** - * @param {Decl} decl - * @return {WalkResult} - */ + // function typeOfDecl(decl){ // return decl.value.typeRef; // @@ -514,18 +264,18 @@ var zigAnalysis; // i += 1; // console.assert(isDecl(decl)); // if ("type" in decl.value) { -// return /** @type {WalkResult} */({ type: typeTypeId }); +// return ({ type: typeTypeId }); // } // //// if ("string" in decl.value) { -//// return /** @type {WalkResult} */({ type: { +//// return ({ type: { //// kind: typeKinds.Pointer, //// size: pointerSizeEnum.One, //// child: }); //// } // // if ("refPath" in decl.value) { -// decl = /** @type {Decl} */({ +// decl = ({ // value: decl.value.refPath[decl.value.refPath.length -1] // }); // continue; @@ -569,17 +319,17 @@ var zigAnalysis; // // const fn_decl_value = resolveValue(fn_decl.value); // console.assert("type" in fn_decl_value); //TODO handle comptimeExpr -// const fn_type = /** @type {Fn} */(zigAnalysis.types[fn_decl_value.type]); +// const fn_type = (zigAnalysis.types[fn_decl_value.type]); // console.assert(fn_type.kind === typeKinds.Fn); // return fn_type.ret; // } // // if ("void" in decl.value) { -// return /** @type {WalkResult} */({ type: typeTypeId }); +// return ({ type: typeTypeId }); // } // // if ("bool" in decl.value) { -// return /** @type {WalkResult} */({ type: typeKinds.Bool }); +// return ({ type: typeKinds.Bool }); // } // // console.log("TODO: handle in `typeOfDecl` more cases: ", decl); @@ -587,7 +337,7 @@ var zigAnalysis; // throw {}; // } // console.assert(false); -// return /** @type {WalkResult} */({}); +// return ({}); // } function render() { @@ -639,18 +389,18 @@ var zigAnalysis; curNav.pkgObjs.push(pkg); } - /** @type {Decl | Type} */ + let currentType = zigAnalysis.types[pkg.main]; curNav.declObjs = [currentType]; for (let i = 0; i < curNav.declNames.length; i += 1) { - /** @type {Decl | Type | null} */ - let childDecl = findSubDecl(/** @type {ContainerType} */(currentType), curNav.declNames[i]); + + let childDecl = findSubDecl((currentType), curNav.declNames[i]); if (childDecl == null) { return render404(); } - let childDeclValue = resolveValue(/** @type {Decl} */(childDecl).value).expr; + let childDeclValue = resolveValue((childDecl).value).expr; if ("type" in childDeclValue) { const t = zigAnalysis.types[childDeclValue.type]; @@ -659,7 +409,7 @@ var zigAnalysis; } } - currentType = /** @type {Decl | Type} */(childDecl); + currentType = (childDecl); curNav.declObjs.push(currentType); } @@ -671,32 +421,32 @@ var zigAnalysis; let lastIsContainerType = isContainerType(last); if (lastIsContainerType) { - return renderContainer(/** @type {ContainerType} */(last)); + return renderContainer((last)); } if (!lastIsDecl && !lastIsType) { - return renderUnknownDecl(/** @type {Decl} */(last)); + return renderUnknownDecl((last)); } if (lastIsType) { - return renderType(/** @type {Type} */(last)); + return renderType((last)); } if (lastIsDecl && last.kind === 'var') { - return renderVar(/** @type {Decl} */(last)); + return renderVar((last)); } if (lastIsDecl && last.kind === 'const') { - let typeObj = zigAnalysis.types[resolveValue(/** @type {Decl} */(last).value).expr.type]; + let typeObj = zigAnalysis.types[resolveValue((last).value).expr.type]; if (typeObj && typeObj.kind === typeKinds.Fn) { - return renderFn(/** @type {Decl} */(last)); + return renderFn((last)); } - return renderValue(/** @type {Decl} */(last)); + return renderValue((last)); } } - /** @param {Decl} decl */ + function renderUnknownDecl(decl) { domDeclNoRef.classList.remove("hidden"); @@ -709,30 +459,30 @@ var zigAnalysis; domTldDocs.classList.remove("hidden"); } - /** @param {number} typeIndex */ + function typeIsErrSet(typeIndex) { let typeObj = zigAnalysis.types[typeIndex]; return typeObj.kind === typeKinds.ErrorSet; } - /** @param {number} typeIndex */ + function typeIsStructWithNoFields(typeIndex) { let typeObj = zigAnalysis.types[typeIndex]; if (typeObj.kind !== typeKinds.Struct) return false; - return /** @type {ContainerType} */(typeObj).fields.length == 0; + return (typeObj).fields.length == 0; } - /** @param {number} typeIndex */ + function typeIsGenericFn(typeIndex) { let typeObj = zigAnalysis.types[typeIndex]; if (typeObj.kind !== typeKinds.Fn) { return false; } - return /** @type {Fn} */(typeObj).generic_ret != null; + return (typeObj).generic_ret != null; } - /** @param {Decl} fnDecl */ + function renderFn(fnDecl) { if ("refPath" in fnDecl.value.expr) { let last = fnDecl.value.expr.refPath.length - 1; @@ -743,7 +493,7 @@ var zigAnalysis; let value = resolveValue(fnDecl.value); console.assert("type" in value.expr); - let typeObj = /** @type {Fn} */(zigAnalysis.types[value.expr.type]); + let typeObj = (zigAnalysis.types[value.expr.type]); domFnProtoCode.innerHTML = exprName(value.expr, { wantHtml: true, @@ -762,15 +512,15 @@ var zigAnalysis; let retExpr = resolveValue({expr:typeObj.ret}).expr; if ("type" in retExpr) { let retIndex = retExpr.type; - let errSetTypeIndex = /** @type {number | null} */(null); + let errSetTypeIndex = (null); let retType = zigAnalysis.types[retIndex]; if (retType.kind === typeKinds.ErrorSet) { errSetTypeIndex = retIndex; } else if (retType.kind === typeKinds.ErrorUnion) { - errSetTypeIndex = /** @type {ErrUnionType} */(retType).err.type; + errSetTypeIndex = (retType).err.type; } if (errSetTypeIndex != null) { - let errSetType = /** @type {ErrSetType} */(zigAnalysis.types[errSetTypeIndex]); + let errSetType = (zigAnalysis.types[errSetTypeIndex]); renderErrorSet(errSetType); } } @@ -833,15 +583,12 @@ var zigAnalysis; domFnProto.classList.remove("hidden"); } - /** - * @param {Decl} fnDecl - * @param {Fn} typeObj - */ + function renderFnParamDocs(fnDecl, typeObj) { let docCount = 0; let fnNode = zigAnalysis.astNodes[fnDecl.src]; - let fields = /** @type {number[]} */(fnNode.fields); + let fields = (fnNode.fields); let isVarArgs = fnNode.varArgs; for (let i = 0; i < fields.length; i += 1) { @@ -869,7 +616,7 @@ var zigAnalysis; let value = typeObj.params[i]; - let html = '
' + escapeHtml(/** @type {string} */(fieldNode.name)) + ": ";
+            let html = '
' + escapeHtml((fieldNode.name)) + ": ";
             if (isVarArgs && i === typeObj.params.length - 1) {
                 html += '...';
             } else {
@@ -893,7 +640,7 @@ var zigAnalysis;
         resizeDomList(domListNav, len, '
  • '); let list = []; let hrefPkgNames = []; - let hrefDeclNames = /** @type {string[]} */([]); + let hrefDeclNames = ([]); for (let i = 0; i < curNav.pkgNames.length; i += 1) { hrefPkgNames.push(curNav.pkgNames[i]); let name = curNav.pkgNames[i]; @@ -985,11 +732,7 @@ var zigAnalysis; } } - /** - * @param {string[]} pkgNames - * @param {string[]} declNames - * @param {string} [callName] - */ + function navLink(pkgNames, declNames, callName) { let base = '#'; @@ -1008,21 +751,21 @@ var zigAnalysis; } } - /** @param {number} pkgIndex */ + function navLinkPkg(pkgIndex) { console.log(canonPkgPaths); return navLink(canonPkgPaths[pkgIndex], []); } - /** @param {string} childName */ + function navLinkDecl(childName) { return navLink(curNav.pkgNames, curNav.declNames.concat([childName])); } - // /** @param {Call} callObj */ + // // function navLinkCall(callObj) { // let declNamesCopy = curNav.declNames.concat([]); - // let callName = /** @type {string} */(declNamesCopy.pop()); + // let callName = (declNamesCopy.pop()); // callName += '('; // for (let arg_i = 0; arg_i < callObj.args.length; arg_i += 1) { @@ -1036,10 +779,7 @@ var zigAnalysis; // return navLink(curNav.pkgNames, declNamesCopy); // } - /** - * @param {any} dlDom - * @param {number} desiredLen - */ + function resizeDomListDl(dlDom, desiredLen) { // add the missing dom entries for (let i = dlDom.childElementCount / 2; i < desiredLen; i += 1) { @@ -1052,11 +792,7 @@ var zigAnalysis; } } - /** - * @param {any} listDom - * @param {number} desiredLen - * @param {string} templateHtml - */ + function resizeDomList(listDom, desiredLen, templateHtml) { // add the missing dom entries for (let i = listDom.childElementCount; i < desiredLen; i += 1) { @@ -1067,10 +803,7 @@ var zigAnalysis; listDom.removeChild(listDom.lastChild); } } - /** - * @param {WalkResult} wr, - * @return {Expr} - */ + function walkResultTypeRef(wr) { if (wr.typeRef) return wr.typeRef; let resolved = resolveValue(wr); @@ -1079,14 +812,7 @@ var zigAnalysis; } return walkResultTypeRef(resolved); } - /** - * @typedef {{ - wantHtml: boolean, - }} RenderWrOptions - * @param {Expr} expr, - * @param {RenderWrOptions} opts, - * @return {string} - */ + function exprName(expr, opts) { switch (Object.keys(expr)[0]) { default: throw "oh no"; @@ -1737,7 +1463,7 @@ var zigAnalysis; } case typeKinds.Array: { - let arrayObj = /** @type {ArrayType} */ (typeObj); + let arrayObj = (typeObj); let name = "["; let lenName = exprName(arrayObj.len, opts); let sentinel = arrayObj.sentinel ? ":"+exprName(arrayObj.sentinel, opts) : ""; @@ -1755,10 +1481,10 @@ var zigAnalysis; return name; } case typeKinds.Optional: - return "?" + exprName(/**@type {OptionalType} */(typeObj).child, opts); + return "?" + exprName((typeObj).child, opts); case typeKinds.Pointer: { - let ptrObj = /** @type {PointerType} */(typeObj); + let ptrObj = (typeObj); let sentinel = ptrObj.sentinel ? ":"+exprName(ptrObj.sentinel, opts) : ""; let is_mutable = !ptrObj.is_mutable ? "const " : ""; let name = ""; @@ -1844,7 +1570,7 @@ var zigAnalysis; } case typeKinds.Float: { - let floatObj = /** @type {NumberType} */ (typeObj); + let floatObj = (typeObj); if (opts.wantHtml) { return '' + floatObj.name + ''; @@ -1854,7 +1580,7 @@ var zigAnalysis; } case typeKinds.Int: { - let intObj = /** @type {NumberType} */(typeObj); + let intObj = (typeObj); let name = intObj.name; if (opts.wantHtml) { return '' + name + ''; @@ -1906,7 +1632,7 @@ var zigAnalysis; } case typeKinds.ErrorSet: { - let errSetObj = /** @type {ErrSetType} */(typeObj); + let errSetObj = (typeObj); if (errSetObj.fields == null) { return 'anyerror'; } else { @@ -1918,14 +1644,14 @@ var zigAnalysis; case typeKinds.ErrorUnion: { - let errUnionObj = /** @type {ErrUnionType} */(typeObj); + let errUnionObj = (typeObj); let lhs = exprName(errUnionObj.lhs, opts); let rhs = exprName(errUnionObj.rhs, opts); return lhs + "!" + rhs; } case typeKinds.Fn: { - let fnObj = /** @type {Fn} */(typeObj); + let fnObj = (typeObj); let payloadHtml = ""; if (opts.wantHtml) { if (fnObj.is_extern) { @@ -2133,16 +1859,13 @@ var zigAnalysis; } - /** - * @param {Expr} typeRef - * @param {string} paramName - */ + function shouldSkipParamName(typeRef, paramName) { let resolvedTypeRef = resolveValue({expr: typeRef}); if ("type" in resolvedTypeRef) { let typeObj = zigAnalysis.types[resolvedTypeRef.type]; if (typeObj.kind === typeKinds.Pointer){ - let ptrObj = /** @type {PointerType} */(typeObj); + let ptrObj = (typeObj); if (getPtrSize(ptrObj) === pointerSizeEnum.One) { const value = resolveValue(ptrObj.child); return typeValueName(value, false, true).toLowerCase() === paramName; @@ -2152,12 +1875,12 @@ var zigAnalysis; return false; } - /** @param {PointerType} typeObj */ + function getPtrSize(typeObj) { return (typeObj.size == null) ? pointerSizeEnum.One : typeObj.size; } - /** @param {Type} typeObj */ + function renderType(typeObj) { let name; if (rootIsStd && typeObj === zigAnalysis.types[zigAnalysis.packages[zigAnalysis.rootPkg].main]) { @@ -2170,11 +1893,11 @@ var zigAnalysis; domHdrName.classList.remove("hidden"); } if (typeObj.kind == typeKinds.ErrorSet) { - renderErrorSet(/** @type {ErrSetType} */(typeObj)); + renderErrorSet((typeObj)); } } - /** @param {ErrSetType} errSetType */ + function renderErrorSet(errSetType) { if (errSetType.fields == null) { domFnErrorsAnyError.classList.remove("hidden"); @@ -2278,7 +2001,7 @@ var zigAnalysis; - /** @param {Decl} decl */ + function renderValue(decl) { let resolvedValue = resolveValue(decl.value) @@ -2295,7 +2018,7 @@ var zigAnalysis; domFnProto.classList.remove("hidden"); } - /** @param {Decl} decl */ + function renderVar(decl) { let declTypeRef = typeOfDecl(decl); domFnProtoCode.innerHTML = 'var ' + @@ -2311,16 +2034,7 @@ var zigAnalysis; } - /** - * @param {number[]} decls - * @param {Decl[]} typesList - * @param {Decl[]} namespacesList, - * @param {Decl[]} errSetsList, - * @param {Decl[]} fnsList, - * @param {Decl[]} varsList, - * @param {Decl[]} valsList, - * @param {Decl[]} testsList - */ + function categorizeDecls(decls, typesList, namespacesList, errSetsList, fnsList, varsList, valsList, testsList) { @@ -2345,7 +2059,7 @@ var zigAnalysis; const typeExpr = zigAnalysis.types[declValue.expr.type]; if (typeExpr.kind == typeKinds.Fn) { const funcRetExpr = resolveValue({ - expr: /** @type {Fn} */(typeExpr).ret + expr: (typeExpr).ret }); if ("type" in funcRetExpr.expr && funcRetExpr.expr.type == typeTypeId) { if (typeIsErrSet(declValue.expr.type)) { @@ -2381,23 +2095,21 @@ var zigAnalysis; } } - /** - * @param {ContainerType} container - */ + function renderContainer(container) { - /** @type {Decl[]} */ + let typesList = []; - /** @type {Decl[]} */ + let namespacesList = []; - /** @type {Decl[]} */ + let errSetsList = []; - /** @type {Decl[]} */ + let fnsList = []; - /** @type {Decl[]} */ + let varsList = []; - /** @type {Decl[]} */ + let valsList = []; - /** @type {Decl[]} */ + let testsList = []; categorizeDecls(container.pubDecls, @@ -2497,7 +2209,7 @@ var zigAnalysis; for (let i = 0; i < containerNode.fields.length; i += 1) { let fieldNode = zigAnalysis.astNodes[containerNode.fields[i]]; let divDom = domListFields.children[i]; - let fieldName = /** @type {string} */(fieldNode.name); + let fieldName = (fieldNode.name); let html = '
    ' + escapeHtml(fieldName);
     
    @@ -2611,10 +2323,7 @@ var zigAnalysis;
         }
     
     
    -    /**
    -    * @param {string | number} a
    -    * @param {string | number} b
    -    */
    +    
         function operatorCompare(a, b) {
             if (a === b) {
                 return 0;
    @@ -2637,7 +2346,7 @@ var zigAnalysis;
         }
     
         function indexTypeKinds() {
    -        let map = /** @type {Record} */({});
    +        let map = ({});
             for (let i = 0; i < zigAnalysis.typeKinds.length; i += 1) {
                 map[zigAnalysis.typeKinds[i]] = i;
             }
    @@ -2708,10 +2417,7 @@ var zigAnalysis;
             }
         }
     
    -    /**
    -    * @param {ContainerType} parentType
    -    * @param {string} childName
    -    */
    +    
         function findSubDecl(parentType, childName) {
             {
                 // Generic functions
    @@ -2758,11 +2464,11 @@ var zigAnalysis;
             let rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg];
             // Breadth-first to keep the path shortest possible.
             let stack = [{
    -            path: /** @type {string[]} */([]),
    +            path: ([]),
                 pkg: rootPkg,
             }];
             while (stack.length !== 0) {
    -            let item = /** @type {{path: string[], pkg: Package}} */(stack.shift());
    +            let item = (stack.shift());
                 for (let key in item.pkg.table) {
                     let childPkgIndex = item.pkg.table[key];
                     if (list[childPkgIndex] != null) continue;
    @@ -2781,7 +2487,7 @@ var zigAnalysis;
         }
     
     
    -    /** @return {CanonDecl[]} */
    +    
         function computeCanonDeclPaths() {
             let list = new Array(zigAnalysis.decls.length);
             canonTypeDecls = new Array(zigAnalysis.types.length);
    @@ -2791,14 +2497,14 @@ var zigAnalysis;
                 let pkg = zigAnalysis.packages[pkgI];
                 let pkgNames = canonPkgPaths[pkgI];
                 let stack = [{
    -                declNames: /** @type {string[]} */([]),
    +                declNames: ([]),
                     type: zigAnalysis.types[pkg.main],
                 }];
                 while (stack.length !== 0) {
    -                let item = /** @type {{declNames: string[], type: Type}} */(stack.shift());
    +                let item = (stack.shift());
     
                     if (isContainerType(item.type)) {
    -                    let t = /** @type {ContainerType} */(item.type);
    +                    let t = (item.type);
     
                         let len = t.pubDecls ? t.pubDecls.length : 0;
                         for (let declI = 0; declI < len; declI += 1) {
    @@ -2833,48 +2539,40 @@ var zigAnalysis;
             return list;
         }
     
    -    /** @param {number} index */
    +    
         function getCanonDeclPath(index) {
             if (canonDeclPaths == null) {
                 canonDeclPaths = computeCanonDeclPaths();
             }
    -        //let cd = /** @type {CanonDecl[]}*/(canonDeclPaths);
    +        //let cd = (canonDeclPaths);
             return canonDeclPaths[index];
         }
     
    -    /** @param {number} index */
    +    
         function getCanonTypeDecl(index) {
             getCanonDeclPath(0);
    -        //let ct = /** @type {number[]}*/(canonTypeDecls);
    +        //let ct = (canonTypeDecls);
             return canonTypeDecls[index];
         }
     
    -    /** @param {string} text */
    +    
         function escapeHtml(text) {
             return text.replace(/[&"<>]/g, function (m) {
                 return escapeHtmlReplacements[m];
             });
         }
     
    -    /** @param {string} docs */
    +    
         function shortDescMarkdown(docs) {
             let parts = docs.trim().split("\n");
             let firstLine = parts[0];
             return markdown(firstLine);
         }
     
    -    /** @param {string} input */
    +    
         function markdown(input) {
             const raw_lines = input.split('\n'); // zig allows no '\r', so we don't need to split on CR
    -        /**
    -        * @type Array<{
    -        *   indent: number,
    -        *   raw_text: string,
    -        *   text: string,
    -        *   type: string,
    -        *   ordered_number: number,
    -        * }>
    -        */
    +        
             const lines = [];
     
             // PHASE 1:
    @@ -2928,7 +2626,7 @@ var zigAnalysis;
                         line.text = line.text.substr(1);
                     }
                     else if (line.text.match(/^\d+\..*$/)) { // if line starts with {number}{dot}
    -                    const match = /** @type {RegExpMatchArray} */(line.text.match(/(\d+)\./));
    +                    const match = (line.text.match(/(\d+)\./));
                         line.type = "ul";
                         line.text = line.text.substr(match[0].length);
                         line.ordered_number = Number(match[1].length);
    @@ -2961,9 +2659,7 @@ var zigAnalysis;
             // Render HTML from markdown lines.
                 // Look at each line and emit fitting HTML code
     
    -        /**
    -        * @param {string } innerText
    -        */
    +        
             function markdownInlines(innerText) {
     
                 // inline types:
    @@ -2977,8 +2673,8 @@ var zigAnalysis;
                     // ![{TEXT}]({URL})   : 
                     // [[std;format.fmt]] :  (inner link)
     
    -            /** @typedef {{marker: string, tag: string}} Fmt*/
    -            /** @type {Array} */
    +            
    +            
                 const formats = [
                     {
                         marker: "**",
    @@ -2998,7 +2694,7 @@ var zigAnalysis;
                     }
                 ];
     
    -            /** @type {Array} */
    +            
                 const stack = [];
     
                 let innerHTML = "";
    @@ -3050,7 +2746,7 @@ var zigAnalysis;
                         in_code = true;
                     } else {
                         let any = false;
    -                    for (let idx = /** @type {number} */(stack.length > 0 ? -1 : 0); idx < formats.length; idx++) {
    +                    for (let idx = (stack.length > 0 ? -1 : 0); idx < formats.length; idx++) {
                             const fmt = idx >= 0 ? formats[idx] : stack[stack.length - 1];
                             if (innerText.substr(i, fmt.marker.length) == fmt.marker) {
                                 flushRun();
    @@ -3074,17 +2770,14 @@ var zigAnalysis;
                 flushRun();
     
                 while (stack.length > 0) {
    -                const fmt = /** @type {Fmt} */(stack.pop());
    +                const fmt = (stack.pop());
                     innerHTML += "";
                 }
     
                 return innerHTML;
             }
     
    -        /**
    -        * @param {string} type
    -        * @param {number} line_no
    -        */
    +        
             function previousLineIs(type, line_no) {
                 if (line_no > 0) {
                     return (lines[line_no - 1].type == type);
    @@ -3093,10 +2786,7 @@ var zigAnalysis;
                 }
             }
     
    -        /**
    -        * @param {string} type
    -        * @param {number} line_no
    -        */
    +        
             function nextLineIs(type, line_no) {
                 if (line_no < (lines.length - 1)) {
                     return (lines[line_no + 1].type == type);
    @@ -3105,7 +2795,7 @@ var zigAnalysis;
                 }
             }
     
    -        /** @param {number} line_no */
    +        
             function getPreviousLineIndent(line_no) {
                 if (line_no > 0) {
                     return lines[line_no - 1].indent;
    @@ -3114,7 +2804,7 @@ var zigAnalysis;
                 }
             }
     
    -        /** @param {number} line_no */
    +        
             function getNextLineIndent(line_no) {
                 if (line_no < (lines.length - 1)) {
                     return lines[line_no + 1].indent;
    @@ -3188,13 +2878,13 @@ var zigAnalysis;
             }
             if (liDom != null) {
                 let aDom = liDom.children[0];
    -            location.href = /** @type {string} */(aDom.getAttribute("href"));
    +            location.href = (aDom.getAttribute("href"));
                 curSearchIndex = -1;
             }
             domSearch.blur();
         }
     
    -    /** @param {KeyboardEvent} ev */
    +    
         function onSearchKeyDown(ev) {
             switch (getKeyString(ev)) {
                 case "Enter":
    @@ -3239,7 +2929,7 @@ var zigAnalysis;
         }
     
     
    -    /** @param {number} dir */
    +    
         function moveSearchCursor(dir) {
             if (curSearchIndex < 0 || curSearchIndex >= domListSearchResults.children.length) {
                 if (dir > 0) {
    @@ -3259,7 +2949,7 @@ var zigAnalysis;
             renderSearchCursor();
         }
     
    -    /** @param {KeyboardEvent} ev */
    +    
         function getKeyString(ev) {
             let name;
             let ignoreShift = false;
    @@ -3286,7 +2976,7 @@ var zigAnalysis;
             return name;
         }
     
    -    /** @param {KeyboardEvent} ev */
    +    
         function onWindowKeyDown(ev) {
             switch (getKeyString(ev)) {
                 case "Esc":
    @@ -3427,7 +3117,7 @@ function renderSearch() {
     
     function renderSearchCursor() {
         for (let i = 0; i < domListSearchResults.children.length; i += 1) {
    -        let liDom = /** @type HTMLElement */(domListSearchResults.children[i]);
    +        let liDom = (domListSearchResults.children[i]);
             if (curSearchIndex === i) {
                 liDom.classList.add("selected");
             } else {
    @@ -3453,10 +3143,7 @@ function renderSearchCursor() {
     // }
     
     
    -/**
    -* @param {{ name: string }} a
    -* @param {{ name: string }} b
    -*/
    +
     function byNameProperty(a, b) {
         return operatorCompare(a.name, b.name);
     }