| ... | ... | @@ -147,10 +147,10 @@ |
| 147 | 147 | curNav.pkgObjs.push(pkg); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | | var decl = zigAnalysis.types[pkg.main]; |
| 151 | | curNav.declObjs = [decl]; |
| 150 | var currentType = zigAnalysis.types[pkg.main]; |
| 151 | curNav.declObjs = [currentType]; |
| 152 | 152 | for (var i = 0; i < curNav.declNames.length; i += 1) { |
| 153 | | var childDecl = findSubDecl(decl, curNav.declNames[i]); |
| 153 | var childDecl = findSubDecl(currentType, curNav.declNames[i]); |
| 154 | 154 | if (childDecl == null) { |
| 155 | 155 | return render404(); |
| 156 | 156 | } |
| ... | ... | @@ -163,29 +163,29 @@ |
| 163 | 163 | return render404(); |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | | decl = container; |
| 167 | | curNav.declObjs.push(decl); |
| 166 | currentType = container; |
| 167 | curNav.declObjs.push(currentType); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | renderNav(); |
| 171 | 171 | |
| 172 | | var lastDecl = curNav.declObjs[curNav.declObjs.length - 1]; |
| 173 | | if (lastDecl.pubDecls != null) { |
| 174 | | renderContainer(lastDecl); |
| 172 | var lastDeclType = curNav.declObjs[curNav.declObjs.length - 1]; |
| 173 | if (lastDeclType.pubDecls != null) { |
| 174 | renderContainer(lastDeclType); |
| 175 | 175 | } |
| 176 | | if (lastDecl.kind == null) { |
| 177 | | return renderUnknownDecl(lastDecl); |
| 178 | | } else if (lastDecl.kind === 'var') { |
| 179 | | return renderVar(lastDecl); |
| 180 | | } else if (lastDecl.kind === 'const' && lastDecl.type != null) { |
| 181 | | var typeObj = zigAnalysis.types[lastDecl.type]; |
| 176 | if (lastDeclType.kind == null) { |
| 177 | return renderUnknownDecl(lastDeclType); |
| 178 | } else if (lastDeclType.kind === 'var') { |
| 179 | return renderVar(lastDeclType); |
| 180 | } else if (lastDeclType.kind === 'const' && lastDeclType.type != null) { |
| 181 | var typeObj = zigAnalysis.types[lastDeclType.type]; |
| 182 | 182 | if (typeObj.kind === typeKinds.Fn) { |
| 183 | | return renderFn(lastDecl); |
| 183 | return renderFn(lastDeclType); |
| 184 | 184 | } else { |
| 185 | | return renderValue(lastDecl); |
| 185 | return renderValue(lastDeclType); |
| 186 | 186 | } |
| 187 | 187 | } else { |
| 188 | | renderType(lastDecl); |
| 188 | renderType(lastDeclType); |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| ... | ... | @@ -994,15 +994,18 @@ |
| 994 | 994 | |
| 995 | 995 | for (var i = 0; i < container.pubDecls.length; i += 1) { |
| 996 | 996 | var decl = zigAnalysis.decls[container.pubDecls[i]]; |
| 997 | var declValTypeId = getDeclValTypeId(decl); |
| 997 | 998 | |
| 998 | 999 | if (decl.kind === 'var') { |
| 999 | 1000 | varsList.push(decl); |
| 1000 | 1001 | continue; |
| 1001 | 1002 | } else if (decl.kind === 'const' && decl.type != null) { |
| 1002 | 1003 | if (decl.type === typeTypeId) { |
| 1003 | | if (typeIsErrSet(decl.value)) { |
| 1004 | // todo: this actually makes sense for decl_vals too |
| 1005 | // the problem is, how should we get to the final type though? |
| 1006 | if (typeIsErrSet(declValTypeId)) { |
| 1004 | 1007 | errSetsList.push(decl); |
| 1005 | | } else if (typeIsStructWithNoFields(decl.value)) { |
| 1008 | } else if (typeIsStructWithNoFields(declValTypeId)) { |
| 1006 | 1009 | namespacesList.push(decl); |
| 1007 | 1010 | } else { |
| 1008 | 1011 | typesList.push(decl); |
| ... | ... | @@ -1010,7 +1013,7 @@ |
| 1010 | 1013 | } else { |
| 1011 | 1014 | var typeKind = zigAnalysis.types[decl.type].kind; |
| 1012 | 1015 | if (typeKind === typeKinds.Fn) { |
| 1013 | | if (allCompTimeFnCallsHaveTypeResult(decl.type, decl.value)) { |
| 1016 | if (allCompTimeFnCallsHaveTypeResult(decl.type, declValTypeId)) { |
| 1014 | 1017 | typesList.push(decl); |
| 1015 | 1018 | } else { |
| 1016 | 1019 | fnsList.push(decl); |
| ... | ... | @@ -1111,10 +1114,20 @@ |
| 1111 | 1114 | if (field.failure === true) { |
| 1112 | 1115 | html += '<span class="tok-kw" style="color:red;">#FAILURE#</span>'; |
| 1113 | 1116 | } else if ("decl_ref" in field) { |
| 1114 | | var name = zigAnalysis.decls[field.decl_ref].name; |
| 1115 | | html += '<a href="'+navLinkDecl(name)+'">'; |
| 1116 | | html += '<span class="tok-kw" style="color:lightblue;">'+ name +'</span>'; |
| 1117 | var decl = zigAnalysis.decls[field.decl_ref]; |
| 1118 | var valType = zigAnalysis.types[getDeclValTypeId(decl)]; |
| 1119 | var valTypeName = valType.name; |
| 1120 | if (valType.kind === typeKinds.Struct) { |
| 1121 | valTypeName = "struct"; |
| 1122 | } |
| 1123 | |
| 1124 | html += '<a href="'+navLinkDecl(decl.name)+'">'; |
| 1125 | html += '<span class="tok-kw" style="color:lightblue;">' + decl.name + '</span>'; |
| 1117 | 1126 | html += '</a>'; |
| 1127 | html += ' ('+ valTypeName +')'; |
| 1128 | } else if ("type" in field) { |
| 1129 | var name = zigAnalysis.types[field.type].name; |
| 1130 | html += '<span class="tok-kw">' + name + '</span>'; |
| 1118 | 1131 | } else { |
| 1119 | 1132 | html += '<span class="tok-kw">var</span>'; |
| 1120 | 1133 | } |
| ... | ... | @@ -1291,7 +1304,7 @@ |
| 1291 | 1304 | |
| 1292 | 1305 | function getDeclContainerType(decl) { |
| 1293 | 1306 | if (decl.type === typeTypeId) { |
| 1294 | | return zigAnalysis.types[decl.value]; |
| 1307 | return zigAnalysis.types[getDeclValTypeId(decl)]; |
| 1295 | 1308 | } |
| 1296 | 1309 | return null; |
| 1297 | 1310 | } |
| ... | ... | @@ -1334,6 +1347,14 @@ |
| 1334 | 1347 | return typeKind === typeKinds.ErrorSet || typeKindIsContainer(typeKind); |
| 1335 | 1348 | } |
| 1336 | 1349 | |
| 1350 | function getDeclValTypeId(decl) { |
| 1351 | while ( "decl_ref" in decl.value) { |
| 1352 | decl = zigAnalysis.decls[decl.value.decl_ref]; |
| 1353 | } |
| 1354 | console.assert("type" in decl.value); |
| 1355 | return decl.value.type; |
| 1356 | } |
| 1357 | |
| 1337 | 1358 | function computeCanonDeclPaths() { |
| 1338 | 1359 | var list = new Array(zigAnalysis.decls.length); |
| 1339 | 1360 | canonTypeDecls = new Array(zigAnalysis.types.length); |
| ... | ... | @@ -1355,10 +1376,11 @@ |
| 1355 | 1376 | if (list[mainDeclIndex] != null) continue; |
| 1356 | 1377 | |
| 1357 | 1378 | var decl = zigAnalysis.decls[mainDeclIndex]; |
| 1379 | var declValTypeId = getDeclValTypeId(decl); |
| 1358 | 1380 | if (decl.type === typeTypeId && |
| 1359 | | declCanRepresentTypeKind(zigAnalysis.types[decl.value].kind)) |
| 1381 | declCanRepresentTypeKind(zigAnalysis.types[declValTypeId].kind)) |
| 1360 | 1382 | { |
| 1361 | | canonTypeDecls[decl.value] = mainDeclIndex; |
| 1383 | canonTypeDecls[declValTypeId] = mainDeclIndex; |
| 1362 | 1384 | } |
| 1363 | 1385 | var declNames = item.declNames.concat([decl.name]); |
| 1364 | 1386 | list[mainDeclIndex] = { |