| ... | ... | @@ -56,31 +56,39 @@ |
| 56 | 56 | */ |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | | * @typedef { |
| 60 | | | { kind: number, name: string; src: number; privDecls: number[]; pubDecls: number[]; fields: WalkResult[] } // Struct, Enum, Union |
| 61 | | } ContainerType |
| 59 | * @typedef {{ |
| 60 | kind: number, |
| 61 | name: string, |
| 62 | src: number, |
| 63 | privDecls: number[], |
| 64 | pubDecls: number[], |
| 65 | fields: WalkResult[] |
| 66 | }} ContainerType |
| 67 | */ |
| 68 | |
| 69 | /** |
| 70 | * @typedef {{ |
| 71 | kind: number, |
| 72 | name: string, |
| 73 | src: number, |
| 74 | ret: WalkResult, |
| 75 | params: WalkResult[] |
| 76 | }} Fn |
| 62 | 77 | */ |
| 63 | 78 | |
| 79 | |
| 64 | 80 | /** |
| 65 | 81 | * @typedef { |
| 66 | 82 | | { kind: number, name: string } // Type, Void, Bool, NoReturn, Int, Float, ComptimeExpr, ComptimeFloat, ComptimeInt, Undefined, Null, ErrorUnion, BoundFn, Opaque, Frame, AnyFrame, Vector, EnumLiteral |
| 67 | | | { kind: number, name: string; child: TypeRef } // Optional |
| 68 | | | { kind: number, len: WalkResult; child: TypeRef } // Array |
| 83 | | { kind: number, name: string; child: WalkResult } // Optional |
| 84 | | { kind: number, len: WalkResult; child: WalkResult } // Array |
| 69 | 85 | | { kind: number, name: string; fields: { name: string; docs: string }[] } // ErrorSet |
| 70 | | | { kind: number, size: "One" | "Many" | "Slice" | "C"; child: TypeRef } // Pointer |
| 86 | | { kind: number, size: "One" | "Many" | "Slice" | "C"; child: WalkResult } // Pointer |
| 71 | 87 | | ContainerType |
| 72 | | | { kind: number, name: string; src: number; ret: WalkResult; params: WalkResult[] } // Fn |
| 88 | | Fn |
| 73 | 89 | } Type |
| 74 | 90 | */ |
| 75 | 91 | |
| 76 | | /** |
| 77 | | * @typedef {{ |
| 78 | | name: string, |
| 79 | | src: number | null, |
| 80 | | ret: WalkResult, |
| 81 | | params: WalkResult[] | null, |
| 82 | | }} Fn |
| 83 | | */ |
| 84 | 92 | |
| 85 | 93 | /** |
| 86 | 94 | * @typedef {{ |
| ... | ... | @@ -109,6 +117,7 @@ |
| 109 | 117 | src: number, |
| 110 | 118 | value: WalkResult, |
| 111 | 119 | decltest?: number, |
| 120 | isTest: bool, |
| 112 | 121 | }} Decl |
| 113 | 122 | */ |
| 114 | 123 | |
| ... | ... | @@ -117,7 +126,7 @@ |
| 117 | 126 | name: string, |
| 118 | 127 | file: number, |
| 119 | 128 | main: number, |
| 120 | | table: { root: number }, |
| 129 | table: Record<string, number>, |
| 121 | 130 | }} Package |
| 122 | 131 | */ |
| 123 | 132 | |
| ... | ... | @@ -225,17 +234,34 @@ var zigAnalysis; |
| 225 | 234 | /** @type Object<string, string> */ |
| 226 | 235 | var escapeHtmlReplacements = { "&": "&amp;", '"': "&quot;", "<": "&lt;", ">": "&gt;" }; |
| 227 | 236 | |
| 228 | | var typeKinds = indexTypeKinds(); |
| 229 | | var typeTypeId = findTypeTypeId(); |
| 237 | var typeKinds = /** @type {Record<string, number>} */(indexTypeKinds()); |
| 238 | var typeTypeId = /** @type {number} */ (findTypeTypeId()); |
| 230 | 239 | var pointerSizeEnum = { One: 0, Many: 1, Slice: 2, C: 3 }; |
| 231 | 240 | |
| 232 | 241 | // for each package, is an array with packages to get to this one |
| 233 | 242 | var canonPkgPaths = computeCanonicalPackagePaths(); |
| 243 | |
| 244 | /** @typedef {{declNames: string[], pkgNames: string[]}} CanonDecl */ |
| 245 | |
| 234 | 246 | // for each decl, is an array with {declNames, pkgNames} to get to this one |
| 247 | /** @type CanonDecl[] | null */ |
| 235 | 248 | var canonDeclPaths = null; // lazy; use getCanonDeclPath |
| 249 | |
| 236 | 250 | // for each type, is an array with {declNames, pkgNames} to get to this one |
| 251 | /** @type number[] | null */ |
| 237 | 252 | var canonTypeDecls = null; // lazy; use getCanonTypeDecl |
| 238 | 253 | |
| 254 | /** @typedef {{ |
| 255 | * showPrivDecls: bool, |
| 256 | * pkgNames: string[], |
| 257 | * pkgObjs: Package[], |
| 258 | * declNames: string[], |
| 259 | * declObjs: Decl[], |
| 260 | * callName: any, |
| 261 | * }} CurNav |
| 262 | */ |
| 263 | |
| 264 | /** @type {CurNav} */ |
| 239 | 265 | var curNav = { |
| 240 | 266 | showPrivDecls: false, |
| 241 | 267 | // each element is a package name, e.g. @import("a") then within there @import("b") |
| ... | ... | @@ -252,6 +278,7 @@ var zigAnalysis; |
| 252 | 278 | // (a, b, c, d) comptime call; result is the value the docs refer to |
| 253 | 279 | callName: null, |
| 254 | 280 | }; |
| 281 | |
| 255 | 282 | var curNavSearch = ""; |
| 256 | 283 | var curSearchIndex = -1; |
| 257 | 284 | var imFeelingLucky = false; |
| ... | ... | @@ -606,7 +633,7 @@ var zigAnalysis; |
| 606 | 633 | if (instantiations == null && calls == null) { |
| 607 | 634 | domFnNoExamples.classList.remove("hidden"); |
| 608 | 635 | } else if (calls != null) { |
| 609 | | if (fnObj.combined === undefined) fnObj.combined = allCompTimeFnCallsResult(calls); |
| 636 | // if (fnObj.combined === undefined) fnObj.combined = allCompTimeFnCallsResult(calls); |
| 610 | 637 | if (fnObj.combined != null) renderContainer(fnObj.combined); |
| 611 | 638 | |
| 612 | 639 | resizeDomList(domListFnExamples, calls.length, '<li></li>'); |
| ... | ... | @@ -848,6 +875,14 @@ var zigAnalysis; |
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 878 | /** |
| 879 | * @param {WalkResult} typeValue, |
| 880 | * @param {boolean} wantHtml, |
| 881 | * @param {boolean} wantLink, |
| 882 | * @param {number} [fnDecl], |
| 883 | * @param {string} [linkFnNameDecl], |
| 884 | * @return {string} |
| 885 | */ |
| 851 | 886 | function typeValueName(typeValue, wantHtml, wantLink, fnDecl, linkFnNameDecl) { |
| 852 | 887 | |
| 853 | 888 | if ("int" in typeValue) { |
| ... | ... | @@ -984,6 +1019,14 @@ var zigAnalysis; |
| 984 | 1019 | } |
| 985 | 1020 | } |
| 986 | 1021 | |
| 1022 | /** |
| 1023 | * @param {Type} typeObj, |
| 1024 | * @param {boolean} wantHtml, |
| 1025 | * @param {boolean} wantSubLink, |
| 1026 | * @param {number} [fnDecl], |
| 1027 | * @param {string} [linkFnNameDecl], |
| 1028 | * @return {string} |
| 1029 | */ |
| 987 | 1030 | function typeName(typeObj, wantHtml, wantSubLink, fnDecl, linkFnNameDecl) { |
| 988 | 1031 | switch (typeObj.kind) { |
| 989 | 1032 | case typeKinds.Array: |
| ... | ... | @@ -1294,111 +1337,113 @@ var zigAnalysis; |
| 1294 | 1337 | domSectFnErrors.classList.remove("hidden"); |
| 1295 | 1338 | } |
| 1296 | 1339 | |
| 1297 | | function allCompTimeFnCallsHaveTypeResult(typeIndex, value) { |
| 1298 | | var srcIndex = zigAnalysis.fns[value].src; |
| 1299 | | var calls = nodesToCallsMap[srcIndex]; |
| 1300 | | if (calls == null) return false; |
| 1301 | | for (var i = 0; i < calls.length; i += 1) { |
| 1302 | | var call = zigAnalysis.calls[calls[i]]; |
| 1303 | | if (call.result.type !== typeTypeId) return false; |
| 1304 | | } |
| 1305 | | return true; |
| 1306 | | } |
| 1307 | | |
| 1308 | | function allCompTimeFnCallsResult(calls) { |
| 1309 | | var firstTypeObj = null; |
| 1310 | | var containerObj = { |
| 1311 | | privDecls: [], |
| 1312 | | }; |
| 1313 | | for (var callI = 0; callI < calls.length; callI += 1) { |
| 1314 | | var call = zigAnalysis.calls[calls[callI]]; |
| 1315 | | if (call.result.type !== typeTypeId) return null; |
| 1316 | | var typeObj = zigAnalysis.types[call.result.value]; |
| 1317 | | if (!typeKindIsContainer(typeObj.kind)) return null; |
| 1318 | | if (firstTypeObj == null) { |
| 1319 | | firstTypeObj = typeObj; |
| 1320 | | containerObj.src = typeObj.src; |
| 1321 | | } else if (firstTypeObj.src !== typeObj.src) { |
| 1322 | | return null; |
| 1323 | | } |
| 1324 | | |
| 1325 | | if (containerObj.fields == null) { |
| 1326 | | containerObj.fields = (typeObj.fields || []).concat([]); |
| 1327 | | } else for (var fieldI = 0; fieldI < typeObj.fields.length; fieldI += 1) { |
| 1328 | | var prev = containerObj.fields[fieldI]; |
| 1329 | | var next = typeObj.fields[fieldI]; |
| 1330 | | if (prev === next) continue; |
| 1331 | | if (typeof(prev) === 'object') { |
| 1332 | | if (prev[next] == null) prev[next] = typeObj; |
| 1333 | | } else { |
| 1334 | | containerObj.fields[fieldI] = {}; |
| 1335 | | containerObj.fields[fieldI][prev] = firstTypeObj; |
| 1336 | | containerObj.fields[fieldI][next] = typeObj; |
| 1337 | | } |
| 1338 | | } |
| 1339 | | |
| 1340 | | if (containerObj.pubDecls == null) { |
| 1341 | | containerObj.pubDecls = (typeObj.pubDecls || []).concat([]); |
| 1342 | | } else for (var declI = 0; declI < typeObj.pubDecls.length; declI += 1) { |
| 1343 | | var prev = containerObj.pubDecls[declI]; |
| 1344 | | var next = typeObj.pubDecls[declI]; |
| 1345 | | if (prev === next) continue; |
| 1346 | | // TODO instead of showing "examples" as the public declarations, |
| 1347 | | // do logic like this: |
| 1348 | | //if (typeof(prev) !== 'object') { |
| 1349 | | // var newDeclId = zigAnalysis.decls.length; |
| 1350 | | // prev = clone(zigAnalysis.decls[prev]); |
| 1351 | | // prev.id = newDeclId; |
| 1352 | | // zigAnalysis.decls.push(prev); |
| 1353 | | // containerObj.pubDecls[declI] = prev; |
| 1354 | | //} |
| 1355 | | //mergeDecls(prev, next, firstTypeObj, typeObj); |
| 1356 | | } |
| 1357 | | } |
| 1358 | | for (var declI = 0; declI < containerObj.pubDecls.length; declI += 1) { |
| 1359 | | var decl = containerObj.pubDecls[declI]; |
| 1360 | | if (typeof(decl) === 'object') { |
| 1361 | | containerObj.pubDecls[declI] = containerObj.pubDecls[declI].id; |
| 1362 | | } |
| 1363 | | } |
| 1364 | | return containerObj; |
| 1365 | | } |
| 1340 | // function allCompTimeFnCallsHaveTypeResult(typeIndex, value) { |
| 1341 | // var srcIndex = zigAnalysis.fns[value].src; |
| 1342 | // var calls = nodesToCallsMap[srcIndex]; |
| 1343 | // if (calls == null) return false; |
| 1344 | // for (var i = 0; i < calls.length; i += 1) { |
| 1345 | // var call = zigAnalysis.calls[calls[i]]; |
| 1346 | // if (call.result.type !== typeTypeId) return false; |
| 1347 | // } |
| 1348 | // return true; |
| 1349 | // } |
| 1350 | // |
| 1351 | // function allCompTimeFnCallsResult(calls) { |
| 1352 | // var firstTypeObj = null; |
| 1353 | // var containerObj = { |
| 1354 | // privDecls: [], |
| 1355 | // }; |
| 1356 | // for (var callI = 0; callI < calls.length; callI += 1) { |
| 1357 | // var call = zigAnalysis.calls[calls[callI]]; |
| 1358 | // if (call.result.type !== typeTypeId) return null; |
| 1359 | // var typeObj = zigAnalysis.types[call.result.value]; |
| 1360 | // if (!typeKindIsContainer(typeObj.kind)) return null; |
| 1361 | // if (firstTypeObj == null) { |
| 1362 | // firstTypeObj = typeObj; |
| 1363 | // containerObj.src = typeObj.src; |
| 1364 | // } else if (firstTypeObj.src !== typeObj.src) { |
| 1365 | // return null; |
| 1366 | // } |
| 1367 | // |
| 1368 | // if (containerObj.fields == null) { |
| 1369 | // containerObj.fields = (typeObj.fields || []).concat([]); |
| 1370 | // } else for (var fieldI = 0; fieldI < typeObj.fields.length; fieldI += 1) { |
| 1371 | // var prev = containerObj.fields[fieldI]; |
| 1372 | // var next = typeObj.fields[fieldI]; |
| 1373 | // if (prev === next) continue; |
| 1374 | // if (typeof(prev) === 'object') { |
| 1375 | // if (prev[next] == null) prev[next] = typeObj; |
| 1376 | // } else { |
| 1377 | // containerObj.fields[fieldI] = {}; |
| 1378 | // containerObj.fields[fieldI][prev] = firstTypeObj; |
| 1379 | // containerObj.fields[fieldI][next] = typeObj; |
| 1380 | // } |
| 1381 | // } |
| 1382 | // |
| 1383 | // if (containerObj.pubDecls == null) { |
| 1384 | // containerObj.pubDecls = (typeObj.pubDecls || []).concat([]); |
| 1385 | // } else for (var declI = 0; declI < typeObj.pubDecls.length; declI += 1) { |
| 1386 | // var prev = containerObj.pubDecls[declI]; |
| 1387 | // var next = typeObj.pubDecls[declI]; |
| 1388 | // if (prev === next) continue; |
| 1389 | // // TODO instead of showing "examples" as the public declarations, |
| 1390 | // // do logic like this: |
| 1391 | // //if (typeof(prev) !== 'object') { |
| 1392 | // // var newDeclId = zigAnalysis.decls.length; |
| 1393 | // // prev = clone(zigAnalysis.decls[prev]); |
| 1394 | // // prev.id = newDeclId; |
| 1395 | // // zigAnalysis.decls.push(prev); |
| 1396 | // // containerObj.pubDecls[declI] = prev; |
| 1397 | // //} |
| 1398 | // //mergeDecls(prev, next, firstTypeObj, typeObj); |
| 1399 | // } |
| 1400 | // } |
| 1401 | // for (var declI = 0; declI < containerObj.pubDecls.length; declI += 1) { |
| 1402 | // var decl = containerObj.pubDecls[declI]; |
| 1403 | // if (typeof(decl) === 'object') { |
| 1404 | // containerObj.pubDecls[declI] = containerObj.pubDecls[declI].id; |
| 1405 | // } |
| 1406 | // } |
| 1407 | // return containerObj; |
| 1408 | // } |
| 1366 | 1409 | |
| 1367 | | function mergeDecls(declObj, nextDeclIndex, firstTypeObj, typeObj) { |
| 1368 | | var nextDeclObj = zigAnalysis.decls[nextDeclIndex]; |
| 1369 | | if (declObj.type != null && nextDeclObj.type != null && declObj.type !== nextDeclObj.type) { |
| 1370 | | if (typeof(declObj.type) !== 'object') { |
| 1371 | | var prevType = declObj.type; |
| 1372 | | declObj.type = {}; |
| 1373 | | declObj.type[prevType] = firstTypeObj; |
| 1374 | | declObj.value = null; |
| 1375 | | } |
| 1376 | | declObj.type[nextDeclObj.type] = typeObj; |
| 1377 | | } else if (declObj.type == null && nextDeclObj != null) { |
| 1378 | | declObj.type = nextDeclObj.type; |
| 1379 | | } |
| 1380 | | if (declObj.value != null && nextDeclObj.value != null && declObj.value !== nextDeclObj.value) { |
| 1381 | | if (typeof(declObj.value) !== 'object') { |
| 1382 | | var prevValue = declObj.value; |
| 1383 | | declObj.value = {}; |
| 1384 | | declObj.value[prevValue] = firstTypeObj; |
| 1385 | | } |
| 1386 | | declObj.value[nextDeclObj.value] = typeObj; |
| 1387 | | } else if (declObj.value == null && nextDeclObj.value != null) { |
| 1388 | | declObj.value = nextDeclObj.value; |
| 1389 | | } |
| 1390 | | } |
| 1391 | 1410 | |
| 1411 | // function mergeDecls(declObj, nextDeclIndex, firstTypeObj, typeObj) { |
| 1412 | // var nextDeclObj = zigAnalysis.decls[nextDeclIndex]; |
| 1413 | // if (declObj.type != null && nextDeclObj.type != null && declObj.type !== nextDeclObj.type) { |
| 1414 | // if (typeof(declObj.type) !== 'object') { |
| 1415 | // var prevType = declObj.type; |
| 1416 | // declObj.type = {}; |
| 1417 | // declObj.type[prevType] = firstTypeObj; |
| 1418 | // declObj.value = null; |
| 1419 | // } |
| 1420 | // declObj.type[nextDeclObj.type] = typeObj; |
| 1421 | // } else if (declObj.type == null && nextDeclObj != null) { |
| 1422 | // declObj.type = nextDeclObj.type; |
| 1423 | // } |
| 1424 | // if (declObj.value != null && nextDeclObj.value != null && declObj.value !== nextDeclObj.value) { |
| 1425 | // if (typeof(declObj.value) !== 'object') { |
| 1426 | // var prevValue = declObj.value; |
| 1427 | // declObj.value = {}; |
| 1428 | // declObj.value[prevValue] = firstTypeObj; |
| 1429 | // } |
| 1430 | // declObj.value[nextDeclObj.value] = typeObj; |
| 1431 | // } else if (declObj.value == null && nextDeclObj.value != null) { |
| 1432 | // declObj.value = nextDeclObj.value; |
| 1433 | // } |
| 1434 | // } |
| 1435 | |
| 1436 | /** @param {Decl} decl */ |
| 1392 | 1437 | function renderValue(decl) { |
| 1393 | 1438 | |
| 1394 | 1439 | var declTypeRef = typeOfDecl(decl); |
| 1395 | 1440 | var declValueText = ""; |
| 1396 | 1441 | switch(Object.keys(decl.value)[0]) { |
| 1397 | 1442 | case "int": |
| 1398 | | declValueText += decl.value.int.value; |
| 1443 | declValueText += /** @type {{int: {value: number}}} */(decl.value).int.value; |
| 1399 | 1444 | break; |
| 1400 | 1445 | case "float": |
| 1401 | | declValueText += decl.value.float.value; |
| 1446 | declValueText += /** @type {{float: {value: number}}} */(decl.value).float.value; |
| 1402 | 1447 | break; |
| 1403 | 1448 | case "comptimeExpr": |
| 1404 | 1449 | declValueText += "[ComptimeExpr]"; |
| ... | ... | @@ -1421,6 +1466,7 @@ var zigAnalysis; |
| 1421 | 1466 | domFnProto.classList.remove("hidden"); |
| 1422 | 1467 | } |
| 1423 | 1468 | |
| 1469 | /** @param {Decl} decl */ |
| 1424 | 1470 | function renderVar(decl) { |
| 1425 | 1471 | var declTypeRef = typeOfDecl(decl); |
| 1426 | 1472 | domFnProtoCode.innerHTML = '<span class="tok-kw">var</span> ' + |
| ... | ... | @@ -1438,7 +1484,13 @@ var zigAnalysis; |
| 1438 | 1484 | |
| 1439 | 1485 | /** |
| 1440 | 1486 | * @param {number[]} decls |
| 1441 | | * @param {Decl[]} typesList, namespacesList, errSetsList, fnsList, varsList, valsList, testsList |
| 1487 | * @param {Decl[]} typesList |
| 1488 | * @param {Decl[]} namespacesList, |
| 1489 | * @param {Decl[]} errSetsList, |
| 1490 | * @param {Decl[]} fnsList, |
| 1491 | * @param {Decl[]} varsList, |
| 1492 | * @param {Decl[]} valsList, |
| 1493 | * @param {Decl[]} testsList |
| 1442 | 1494 | */ |
| 1443 | 1495 | function categorizeDecls(decls, |
| 1444 | 1496 | typesList, namespacesList, errSetsList, |
| ... | ... | @@ -1482,7 +1534,7 @@ var zigAnalysis; |
| 1482 | 1534 | var kind = value.kind; |
| 1483 | 1535 | if (kind === typeKinds.Fn) { |
| 1484 | 1536 | // TODO: handle CTE return types when we know their type. |
| 1485 | | const resVal = resolveValue(value.ret); |
| 1537 | const resVal = resolveValue(/** @type {Fn} */(value).ret); |
| 1486 | 1538 | if ("type" in resVal && resVal.type == typeTypeId) { |
| 1487 | 1539 | typesList.push(decl); |
| 1488 | 1540 | } else { |
| ... | ... | @@ -1610,20 +1662,17 @@ var zigAnalysis; |
| 1610 | 1662 | for (var i = 0; i < containerNode.fields.length; i += 1) { |
| 1611 | 1663 | var fieldNode = zigAnalysis.astNodes[containerNode.fields[i]]; |
| 1612 | 1664 | var divDom = domListFields.children[i]; |
| 1665 | let fieldName = /** @type {string} */(fieldNode.name); |
| 1613 | 1666 | |
| 1614 | | var html = '<div class="mobile-scroll-container"><pre class="scroll-item">' + escapeHtml(fieldNode.name); |
| 1667 | var html = '<div class="mobile-scroll-container"><pre class="scroll-item">' + escapeHtml(fieldName); |
| 1615 | 1668 | |
| 1616 | 1669 | if (container.kind === typeKinds.Enum) { |
| 1617 | | html += ' = <span class="tok-number">' + field + '</span>'; |
| 1670 | html += ' = <span class="tok-number">' + fieldName + '</span>'; |
| 1618 | 1671 | } else { |
| 1619 | 1672 | var field = container.fields[i]; |
| 1620 | 1673 | html += ": "; |
| 1621 | | if (field.failure === true) { |
| 1622 | | html += '<span class="tok-kw" style="color:red;">#FAILURE#</span>'; |
| 1623 | | } else { |
| 1624 | | var name = typeValueName(field); |
| 1625 | | html += '<span class="tok-kw">'+ name +'</span>'; |
| 1626 | | } |
| 1674 | var name = typeValueName(field); |
| 1675 | html += '<span class="tok-kw">'+ name +'</span>'; |
| 1627 | 1676 | } |
| 1628 | 1677 | |
| 1629 | 1678 | html += ',</pre></div>'; |
| ... | ... | @@ -1719,6 +1768,11 @@ var zigAnalysis; |
| 1719 | 1768 | } |
| 1720 | 1769 | } |
| 1721 | 1770 | |
| 1771 | |
| 1772 | /** |
| 1773 | * @param {string | number} a |
| 1774 | * @param {string | number} b |
| 1775 | */ |
| 1722 | 1776 | function operatorCompare(a, b) { |
| 1723 | 1777 | if (a === b) { |
| 1724 | 1778 | return 0; |
| ... | ... | @@ -1741,7 +1795,7 @@ var zigAnalysis; |
| 1741 | 1795 | } |
| 1742 | 1796 | |
| 1743 | 1797 | function indexTypeKinds() { |
| 1744 | | var map = {}; |
| 1798 | var map = /** @type {Record<string, number>} */({}); |
| 1745 | 1799 | for (var i = 0; i < zigAnalysis.typeKinds.length; i += 1) { |
| 1746 | 1800 | map[zigAnalysis.typeKinds[i]] = i; |
| 1747 | 1801 | } |
| ... | ... | @@ -1765,12 +1819,14 @@ var zigAnalysis; |
| 1765 | 1819 | } |
| 1766 | 1820 | |
| 1767 | 1821 | function updateCurNav() { |
| 1822 | |
| 1768 | 1823 | curNav = { |
| 1769 | 1824 | showPrivDecls: false, |
| 1770 | 1825 | pkgNames: [], |
| 1771 | 1826 | pkgObjs: [], |
| 1772 | 1827 | declNames: [], |
| 1773 | 1828 | declObjs: [], |
| 1829 | callName: null, |
| 1774 | 1830 | }; |
| 1775 | 1831 | curNavSearch = ""; |
| 1776 | 1832 | |
| ... | ... | @@ -1814,6 +1870,10 @@ var zigAnalysis; |
| 1814 | 1870 | } |
| 1815 | 1871 | } |
| 1816 | 1872 | |
| 1873 | /** |
| 1874 | * @param {ContainerType} parentType |
| 1875 | * @param {string} childName |
| 1876 | */ |
| 1817 | 1877 | function findSubDecl(parentType, childName) { |
| 1818 | 1878 | if (!parentType.pubDecls) return null; |
| 1819 | 1879 | for (var i = 0; i < parentType.pubDecls.length; i += 1) { |
| ... | ... | @@ -1843,11 +1903,11 @@ var zigAnalysis; |
| 1843 | 1903 | var rootPkg = zigAnalysis.packages[zigAnalysis.rootPkg]; |
| 1844 | 1904 | // Breadth-first to keep the path shortest possible. |
| 1845 | 1905 | var stack = [{ |
| 1846 | | path: [], |
| 1906 | path: /** @type {string[]} */([]), |
| 1847 | 1907 | pkg: rootPkg, |
| 1848 | 1908 | }]; |
| 1849 | 1909 | while (stack.length !== 0) { |
| 1850 | | var item = stack.shift(); |
| 1910 | var item = /** @type {{path: string[], pkg: Package}} */(stack.shift()); |
| 1851 | 1911 | for (var key in item.pkg.table) { |
| 1852 | 1912 | var childPkgIndex = item.pkg.table[key]; |
| 1853 | 1913 | if (list[childPkgIndex] != null) continue; |
| ... | ... | @@ -1866,6 +1926,7 @@ var zigAnalysis; |
| 1866 | 1926 | } |
| 1867 | 1927 | |
| 1868 | 1928 | |
| 1929 | /** @return {CanonDecl[]} */ |
| 1869 | 1930 | function computeCanonDeclPaths() { |
| 1870 | 1931 | var list = new Array(zigAnalysis.decls.length); |
| 1871 | 1932 | canonTypeDecls = new Array(zigAnalysis.types.length); |
| ... | ... | @@ -1875,16 +1936,18 @@ var zigAnalysis; |
| 1875 | 1936 | var pkg = zigAnalysis.packages[pkgI]; |
| 1876 | 1937 | var pkgNames = canonPkgPaths[pkgI]; |
| 1877 | 1938 | var stack = [{ |
| 1878 | | declNames: [], |
| 1939 | declNames: /** @type {string[]} */([]), |
| 1879 | 1940 | type: zigAnalysis.types[pkg.main], |
| 1880 | 1941 | }]; |
| 1881 | 1942 | while (stack.length !== 0) { |
| 1882 | | var item = stack.shift(); |
| 1943 | var item = /** @type {{declNames: string[], type: Type}} */(stack.shift()); |
| 1883 | 1944 | |
| 1884 | 1945 | if (isContainerType(item.type)) { |
| 1885 | | var len = item.type.pubDecls ? item.type.pubDecls.length : 0; |
| 1946 | let t = /** @type {ContainerType} */(item.type); |
| 1947 | |
| 1948 | var len = t.pubDecls ? t.pubDecls.length : 0; |
| 1886 | 1949 | for (var declI = 0; declI < len; declI += 1) { |
| 1887 | | var mainDeclIndex = item.type.pubDecls[declI]; |
| 1950 | var mainDeclIndex = t.pubDecls[declI]; |
| 1888 | 1951 | if (list[mainDeclIndex] != null) continue; |
| 1889 | 1952 | |
| 1890 | 1953 | var decl = zigAnalysis.decls[mainDeclIndex]; |
| ... | ... | @@ -1915,16 +1978,20 @@ var zigAnalysis; |
| 1915 | 1978 | return list; |
| 1916 | 1979 | } |
| 1917 | 1980 | |
| 1981 | /** @param {number} index */ |
| 1918 | 1982 | function getCanonDeclPath(index) { |
| 1919 | 1983 | if (canonDeclPaths == null) { |
| 1920 | 1984 | canonDeclPaths = computeCanonDeclPaths(); |
| 1921 | 1985 | } |
| 1922 | | return canonDeclPaths[index]; |
| 1986 | let cd = /** @type {CanonDecl[]}*/(canonDeclPaths); |
| 1987 | return cd[index]; |
| 1923 | 1988 | } |
| 1924 | 1989 | |
| 1990 | /** @param {number} index */ |
| 1925 | 1991 | function getCanonTypeDecl(index) { |
| 1926 | 1992 | getCanonDeclPath(0); |
| 1927 | | return canonTypeDecls[index]; |
| 1993 | let ct = /** @type {number[]}*/(canonTypeDecls); |
| 1994 | return ct[index]; |
| 1928 | 1995 | } |
| 1929 | 1996 | |
| 1930 | 1997 | /** @param {string} text */ |