| ... | @@ -147,10 +147,10 @@ | ... | @@ -147,10 +147,10 @@ |
| 147 | curNav.pkgObjs.push(pkg); | 147 | curNav.pkgObjs.push(pkg); |
| 148 | } | 148 | } |
| 149 | | 149 | |
| 150 | var decl = zigAnalysis.types[pkg.main]; | 150 | var currentType = zigAnalysis.types[pkg.main]; |
| 151 | curNav.declObjs = [decl]; | 151 | curNav.declObjs = [currentType]; |
| 152 | for (var i = 0; i < curNav.declNames.length; i += 1) { | 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 | if (childDecl == null) { | 154 | if (childDecl == null) { |
| 155 | return render404(); | 155 | return render404(); |
| 156 | } | 156 | } |
| ... | @@ -163,29 +163,29 @@ | ... | @@ -163,29 +163,29 @@ |
| 163 | return render404(); | 163 | return render404(); |
| 164 | } | 164 | } |
| 165 | } | 165 | } |
| 166 | decl = container; | 166 | currentType = container; |
| 167 | curNav.declObjs.push(decl); | 167 | curNav.declObjs.push(currentType); |
| 168 | } | 168 | } |
| 169 | | 169 | |
| 170 | renderNav(); | 170 | renderNav(); |
| 171 | | 171 | |
| 172 | var lastDecl = curNav.declObjs[curNav.declObjs.length - 1]; | 172 | var lastDeclType = curNav.declObjs[curNav.declObjs.length - 1]; |
| 173 | if (lastDecl.pubDecls != null) { | 173 | if (lastDeclType.pubDecls != null) { |
| 174 | renderContainer(lastDecl); | 174 | renderContainer(lastDeclType); |
| 175 | } | 175 | } |
| 176 | if (lastDecl.kind == null) { | 176 | if (lastDeclType.kind == null) { |
| 177 | return renderUnknownDecl(lastDecl); | 177 | return renderUnknownDecl(lastDeclType); |
| 178 | } else if (lastDecl.kind === 'var') { | 178 | } else if (lastDeclType.kind === 'var') { |
| 179 | return renderVar(lastDecl); | 179 | return renderVar(lastDeclType); |
| 180 | } else if (lastDecl.kind === 'const' && lastDecl.type != null) { | 180 | } else if (lastDeclType.kind === 'const' && lastDeclType.type != null) { |
| 181 | var typeObj = zigAnalysis.types[lastDecl.type]; | 181 | var typeObj = zigAnalysis.types[lastDeclType.type]; |
| 182 | if (typeObj.kind === typeKinds.Fn) { | 182 | if (typeObj.kind === typeKinds.Fn) { |
| 183 | return renderFn(lastDecl); | 183 | return renderFn(lastDeclType); |
| 184 | } else { | 184 | } else { |
| 185 | return renderValue(lastDecl); | 185 | return renderValue(lastDeclType); |
| 186 | } | 186 | } |
| 187 | } else { | 187 | } else { |
| 188 | renderType(lastDecl); | 188 | renderType(lastDeclType); |
| 189 | } | 189 | } |
| 190 | } | 190 | } |
| 191 | | 191 | |
| ... | @@ -994,15 +994,18 @@ | ... | @@ -994,15 +994,18 @@ |
| 994 | | 994 | |
| 995 | for (var i = 0; i < container.pubDecls.length; i += 1) { | 995 | for (var i = 0; i < container.pubDecls.length; i += 1) { |
| 996 | var decl = zigAnalysis.decls[container.pubDecls[i]]; | 996 | var decl = zigAnalysis.decls[container.pubDecls[i]]; |
| | 997 | var declValTypeId = getDeclValTypeId(decl); |
| 997 | | 998 | |
| 998 | if (decl.kind === 'var') { | 999 | if (decl.kind === 'var') { |
| 999 | varsList.push(decl); | 1000 | varsList.push(decl); |
| 1000 | continue; | 1001 | continue; |
| 1001 | } else if (decl.kind === 'const' && decl.type != null) { | 1002 | } else if (decl.kind === 'const' && decl.type != null) { |
| 1002 | if (decl.type === typeTypeId) { | 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 | errSetsList.push(decl); | 1007 | errSetsList.push(decl); |
| 1005 | } else if (typeIsStructWithNoFields(decl.value)) { | 1008 | } else if (typeIsStructWithNoFields(declValTypeId)) { |
| 1006 | namespacesList.push(decl); | 1009 | namespacesList.push(decl); |
| 1007 | } else { | 1010 | } else { |
| 1008 | typesList.push(decl); | 1011 | typesList.push(decl); |
| ... | @@ -1010,7 +1013,7 @@ | ... | @@ -1010,7 +1013,7 @@ |
| 1010 | } else { | 1013 | } else { |
| 1011 | var typeKind = zigAnalysis.types[decl.type].kind; | 1014 | var typeKind = zigAnalysis.types[decl.type].kind; |
| 1012 | if (typeKind === typeKinds.Fn) { | 1015 | if (typeKind === typeKinds.Fn) { |
| 1013 | if (allCompTimeFnCallsHaveTypeResult(decl.type, decl.value)) { | 1016 | if (allCompTimeFnCallsHaveTypeResult(decl.type, declValTypeId)) { |
| 1014 | typesList.push(decl); | 1017 | typesList.push(decl); |
| 1015 | } else { | 1018 | } else { |
| 1016 | fnsList.push(decl); | 1019 | fnsList.push(decl); |
| ... | @@ -1111,10 +1114,20 @@ | ... | @@ -1111,10 +1114,20 @@ |
| 1111 | if (field.failure === true) { | 1114 | if (field.failure === true) { |
| 1112 | html += '<span class="tok-kw" style="color:red;">#FAILURE#</span>'; | 1115 | html += '<span class="tok-kw" style="color:red;">#FAILURE#</span>'; |
| 1113 | } else if ("decl_ref" in field) { | 1116 | } else if ("decl_ref" in field) { |
| 1114 | var name = zigAnalysis.decls[field.decl_ref].name; | 1117 | var decl = zigAnalysis.decls[field.decl_ref]; |
| 1115 | html += '<a href="'+navLinkDecl(name)+'">'; | 1118 | var valType = zigAnalysis.types[getDeclValTypeId(decl)]; |
| 1116 | html += '<span class="tok-kw" style="color:lightblue;">'+ name +'</span>'; | 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 | html += '</a>'; | 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 | } else { | 1131 | } else { |
| 1119 | html += '<span class="tok-kw">var</span>'; | 1132 | html += '<span class="tok-kw">var</span>'; |
| 1120 | } | 1133 | } |
| ... | @@ -1291,7 +1304,7 @@ | ... | @@ -1291,7 +1304,7 @@ |
| 1291 | | 1304 | |
| 1292 | function getDeclContainerType(decl) { | 1305 | function getDeclContainerType(decl) { |
| 1293 | if (decl.type === typeTypeId) { | 1306 | if (decl.type === typeTypeId) { |
| 1294 | return zigAnalysis.types[decl.value]; | 1307 | return zigAnalysis.types[getDeclValTypeId(decl)]; |
| 1295 | } | 1308 | } |
| 1296 | return null; | 1309 | return null; |
| 1297 | } | 1310 | } |
| ... | @@ -1334,6 +1347,14 @@ | ... | @@ -1334,6 +1347,14 @@ |
| 1334 | return typeKind === typeKinds.ErrorSet || typeKindIsContainer(typeKind); | 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 | function computeCanonDeclPaths() { | 1358 | function computeCanonDeclPaths() { |
| 1338 | var list = new Array(zigAnalysis.decls.length); | 1359 | var list = new Array(zigAnalysis.decls.length); |
| 1339 | canonTypeDecls = new Array(zigAnalysis.types.length); | 1360 | canonTypeDecls = new Array(zigAnalysis.types.length); |
| ... | @@ -1355,10 +1376,11 @@ | ... | @@ -1355,10 +1376,11 @@ |
| 1355 | if (list[mainDeclIndex] != null) continue; | 1376 | if (list[mainDeclIndex] != null) continue; |
| 1356 | | 1377 | |
| 1357 | var decl = zigAnalysis.decls[mainDeclIndex]; | 1378 | var decl = zigAnalysis.decls[mainDeclIndex]; |
| | 1379 | var declValTypeId = getDeclValTypeId(decl); |
| 1358 | if (decl.type === typeTypeId && | 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 | var declNames = item.declNames.concat([decl.name]); | 1385 | var declNames = item.declNames.concat([decl.name]); |
| 1364 | list[mainDeclIndex] = { | 1386 | list[mainDeclIndex] = { |