| ... | @@ -195,10 +195,14 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -195,10 +195,14 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 195 | ); | 195 | ); |
| 196 | } | 196 | } |
| 197 | | 197 | |
| 198 | var root_scope = Scope{ .parent = null, .enclosing_type = main_type_index }; | 198 | var root_scope = Scope{ |
| | 199 | .parent = null, |
| | 200 | .enclosing_type = main_type_index, |
| | 201 | }; |
| | 202 | |
| 199 | try self.ast_nodes.append(self.arena, .{ .name = "(root)" }); | 203 | try self.ast_nodes.append(self.arena, .{ .name = "(root)" }); |
| 200 | try self.files.put(self.arena, file, main_type_index); | 204 | try self.files.put(self.arena, file, main_type_index); |
| 201 | _ = try self.walkInstruction(file, &root_scope, Zir.main_struct_inst, false); | 205 | _ = try self.walkInstruction(file, &root_scope, 1, Zir.main_struct_inst, false); |
| 202 | | 206 | |
| 203 | if (self.ref_paths_pending_on_decls.count() > 0) { | 207 | if (self.ref_paths_pending_on_decls.count() > 0) { |
| 204 | @panic("some decl paths were never fully analized (pending on decls)"); | 208 | @panic("some decl paths were never fully analized (pending on decls)"); |
| ... | @@ -769,6 +773,7 @@ fn walkInstruction( | ... | @@ -769,6 +773,7 @@ fn walkInstruction( |
| 769 | self: *Autodoc, | 773 | self: *Autodoc, |
| 770 | file: *File, | 774 | file: *File, |
| 771 | parent_scope: *Scope, | 775 | parent_scope: *Scope, |
| | 776 | parent_line: usize, |
| 772 | inst_index: usize, | 777 | inst_index: usize, |
| 773 | need_type: bool, // true if the caller needs us to provide also a typeRef | 778 | need_type: bool, // true if the caller needs us to provide also a typeRef |
| 774 | ) AutodocErrors!DocData.WalkResult { | 779 | ) AutodocErrors!DocData.WalkResult { |
| ... | @@ -851,12 +856,16 @@ fn walkInstruction( | ... | @@ -851,12 +856,16 @@ fn walkInstruction( |
| 851 | | 856 | |
| 852 | const new_file = self.module.import_table.get(abs_root_src_path).?; | 857 | const new_file = self.module.import_table.get(abs_root_src_path).?; |
| 853 | | 858 | |
| 854 | var root_scope = Scope{ .parent = null, .enclosing_type = main_type_index }; | 859 | var root_scope = Scope{ |
| | 860 | .parent = null, |
| | 861 | .enclosing_type = main_type_index, |
| | 862 | }; |
| 855 | try self.ast_nodes.append(self.arena, .{ .name = "(root)" }); | 863 | try self.ast_nodes.append(self.arena, .{ .name = "(root)" }); |
| 856 | try self.files.put(self.arena, new_file, main_type_index); | 864 | try self.files.put(self.arena, new_file, main_type_index); |
| 857 | return self.walkInstruction( | 865 | return self.walkInstruction( |
| 858 | new_file, | 866 | new_file, |
| 859 | &root_scope, | 867 | &root_scope, |
| | 868 | 1, |
| 860 | Zir.main_struct_inst, | 869 | Zir.main_struct_inst, |
| 861 | false, | 870 | false, |
| 862 | ); | 871 | ); |
| ... | @@ -881,13 +890,14 @@ fn walkInstruction( | ... | @@ -881,13 +890,14 @@ fn walkInstruction( |
| 881 | return self.walkInstruction( | 890 | return self.walkInstruction( |
| 882 | new_file.file, | 891 | new_file.file, |
| 883 | &new_scope, | 892 | &new_scope, |
| | 893 | 1, |
| 884 | Zir.main_struct_inst, | 894 | Zir.main_struct_inst, |
| 885 | need_type, | 895 | need_type, |
| 886 | ); | 896 | ); |
| 887 | }, | 897 | }, |
| 888 | .ret_node => { | 898 | .ret_node => { |
| 889 | const un_node = data[inst_index].un_node; | 899 | const un_node = data[inst_index].un_node; |
| 890 | return self.walkRef(file, parent_scope, un_node.operand, false); | 900 | return self.walkRef(file, parent_scope, parent_line, un_node.operand, false); |
| 891 | }, | 901 | }, |
| 892 | .ret_load => { | 902 | .ret_load => { |
| 893 | const un_node = data[inst_index].un_node; | 903 | const un_node = data[inst_index].un_node; |
| ... | @@ -918,7 +928,7 @@ fn walkInstruction( | ... | @@ -918,7 +928,7 @@ fn walkInstruction( |
| 918 | } | 928 | } |
| 919 | | 929 | |
| 920 | if (result_ref) |rr| { | 930 | if (result_ref) |rr| { |
| 921 | return self.walkRef(file, parent_scope, rr, need_type); | 931 | return self.walkRef(file, parent_scope, parent_line, rr, need_type); |
| 922 | } | 932 | } |
| 923 | | 933 | |
| 924 | return DocData.WalkResult{ | 934 | return DocData.WalkResult{ |
| ... | @@ -927,11 +937,11 @@ fn walkInstruction( | ... | @@ -927,11 +937,11 @@ fn walkInstruction( |
| 927 | }, | 937 | }, |
| 928 | .closure_get => { | 938 | .closure_get => { |
| 929 | const inst_node = data[inst_index].inst_node; | 939 | const inst_node = data[inst_index].inst_node; |
| 930 | return try self.walkInstruction(file, parent_scope, inst_node.inst, need_type); | 940 | return try self.walkInstruction(file, parent_scope, parent_line, inst_node.inst, need_type); |
| 931 | }, | 941 | }, |
| 932 | .closure_capture => { | 942 | .closure_capture => { |
| 933 | const un_tok = data[inst_index].un_tok; | 943 | const un_tok = data[inst_index].un_tok; |
| 934 | return try self.walkRef(file, parent_scope, un_tok.operand, need_type); | 944 | return try self.walkRef(file, parent_scope, parent_line, un_tok.operand, need_type); |
| 935 | }, | 945 | }, |
| 936 | .cmpxchg_strong, .cmpxchg_weak => { | 946 | .cmpxchg_strong, .cmpxchg_weak => { |
| 937 | const pl_node = data[inst_index].pl_node; | 947 | const pl_node = data[inst_index].pl_node; |
| ... | @@ -946,6 +956,7 @@ fn walkInstruction( | ... | @@ -946,6 +956,7 @@ fn walkInstruction( |
| 946 | var ptr: DocData.WalkResult = try self.walkRef( | 956 | var ptr: DocData.WalkResult = try self.walkRef( |
| 947 | file, | 957 | file, |
| 948 | parent_scope, | 958 | parent_scope, |
| | 959 | parent_line, |
| 949 | extra.data.ptr, | 960 | extra.data.ptr, |
| 950 | false, | 961 | false, |
| 951 | ); | 962 | ); |
| ... | @@ -955,6 +966,7 @@ fn walkInstruction( | ... | @@ -955,6 +966,7 @@ fn walkInstruction( |
| 955 | var expected_value: DocData.WalkResult = try self.walkRef( | 966 | var expected_value: DocData.WalkResult = try self.walkRef( |
| 956 | file, | 967 | file, |
| 957 | parent_scope, | 968 | parent_scope, |
| | 969 | parent_line, |
| 958 | extra.data.expected_value, | 970 | extra.data.expected_value, |
| 959 | false, | 971 | false, |
| 960 | ); | 972 | ); |
| ... | @@ -964,6 +976,7 @@ fn walkInstruction( | ... | @@ -964,6 +976,7 @@ fn walkInstruction( |
| 964 | var new_value: DocData.WalkResult = try self.walkRef( | 976 | var new_value: DocData.WalkResult = try self.walkRef( |
| 965 | file, | 977 | file, |
| 966 | parent_scope, | 978 | parent_scope, |
| | 979 | parent_line, |
| 967 | extra.data.new_value, | 980 | extra.data.new_value, |
| 968 | false, | 981 | false, |
| 969 | ); | 982 | ); |
| ... | @@ -973,6 +986,7 @@ fn walkInstruction( | ... | @@ -973,6 +986,7 @@ fn walkInstruction( |
| 973 | var success_order: DocData.WalkResult = try self.walkRef( | 986 | var success_order: DocData.WalkResult = try self.walkRef( |
| 974 | file, | 987 | file, |
| 975 | parent_scope, | 988 | parent_scope, |
| | 989 | parent_line, |
| 976 | extra.data.success_order, | 990 | extra.data.success_order, |
| 977 | false, | 991 | false, |
| 978 | ); | 992 | ); |
| ... | @@ -982,6 +996,7 @@ fn walkInstruction( | ... | @@ -982,6 +996,7 @@ fn walkInstruction( |
| 982 | var failure_order: DocData.WalkResult = try self.walkRef( | 996 | var failure_order: DocData.WalkResult = try self.walkRef( |
| 983 | file, | 997 | file, |
| 984 | parent_scope, | 998 | parent_scope, |
| | 999 | parent_line, |
| 985 | extra.data.failure_order, | 1000 | extra.data.failure_order, |
| 986 | false, | 1001 | false, |
| 987 | ); | 1002 | ); |
| ... | @@ -1035,6 +1050,7 @@ fn walkInstruction( | ... | @@ -1035,6 +1050,7 @@ fn walkInstruction( |
| 1035 | var operand: DocData.WalkResult = try self.walkRef( | 1050 | var operand: DocData.WalkResult = try self.walkRef( |
| 1036 | file, | 1051 | file, |
| 1037 | parent_scope, | 1052 | parent_scope, |
| | 1053 | parent_line, |
| 1038 | un_node.operand, | 1054 | un_node.operand, |
| 1039 | false, | 1055 | false, |
| 1040 | ); | 1056 | ); |
| ... | @@ -1089,12 +1105,14 @@ fn walkInstruction( | ... | @@ -1089,12 +1105,14 @@ fn walkInstruction( |
| 1089 | var lhs: DocData.WalkResult = try self.walkRef( | 1105 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1090 | file, | 1106 | file, |
| 1091 | parent_scope, | 1107 | parent_scope, |
| | 1108 | parent_line, |
| 1092 | extra.data.lhs, | 1109 | extra.data.lhs, |
| 1093 | false, | 1110 | false, |
| 1094 | ); | 1111 | ); |
| 1095 | var start: DocData.WalkResult = try self.walkRef( | 1112 | var start: DocData.WalkResult = try self.walkRef( |
| 1096 | file, | 1113 | file, |
| 1097 | parent_scope, | 1114 | parent_scope, |
| | 1115 | parent_line, |
| 1098 | extra.data.start, | 1116 | extra.data.start, |
| 1099 | false, | 1117 | false, |
| 1100 | ); | 1118 | ); |
| ... | @@ -1120,18 +1138,21 @@ fn walkInstruction( | ... | @@ -1120,18 +1138,21 @@ fn walkInstruction( |
| 1120 | var lhs: DocData.WalkResult = try self.walkRef( | 1138 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1121 | file, | 1139 | file, |
| 1122 | parent_scope, | 1140 | parent_scope, |
| | 1141 | parent_line, |
| 1123 | extra.data.lhs, | 1142 | extra.data.lhs, |
| 1124 | false, | 1143 | false, |
| 1125 | ); | 1144 | ); |
| 1126 | var start: DocData.WalkResult = try self.walkRef( | 1145 | var start: DocData.WalkResult = try self.walkRef( |
| 1127 | file, | 1146 | file, |
| 1128 | parent_scope, | 1147 | parent_scope, |
| | 1148 | parent_line, |
| 1129 | extra.data.start, | 1149 | extra.data.start, |
| 1130 | false, | 1150 | false, |
| 1131 | ); | 1151 | ); |
| 1132 | var end: DocData.WalkResult = try self.walkRef( | 1152 | var end: DocData.WalkResult = try self.walkRef( |
| 1133 | file, | 1153 | file, |
| 1134 | parent_scope, | 1154 | parent_scope, |
| | 1155 | parent_line, |
| 1135 | extra.data.end, | 1156 | extra.data.end, |
| 1136 | false, | 1157 | false, |
| 1137 | ); | 1158 | ); |
| ... | @@ -1159,24 +1180,28 @@ fn walkInstruction( | ... | @@ -1159,24 +1180,28 @@ fn walkInstruction( |
| 1159 | var lhs: DocData.WalkResult = try self.walkRef( | 1180 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1160 | file, | 1181 | file, |
| 1161 | parent_scope, | 1182 | parent_scope, |
| | 1183 | parent_line, |
| 1162 | extra.data.lhs, | 1184 | extra.data.lhs, |
| 1163 | false, | 1185 | false, |
| 1164 | ); | 1186 | ); |
| 1165 | var start: DocData.WalkResult = try self.walkRef( | 1187 | var start: DocData.WalkResult = try self.walkRef( |
| 1166 | file, | 1188 | file, |
| 1167 | parent_scope, | 1189 | parent_scope, |
| | 1190 | parent_line, |
| 1168 | extra.data.start, | 1191 | extra.data.start, |
| 1169 | false, | 1192 | false, |
| 1170 | ); | 1193 | ); |
| 1171 | var end: DocData.WalkResult = try self.walkRef( | 1194 | var end: DocData.WalkResult = try self.walkRef( |
| 1172 | file, | 1195 | file, |
| 1173 | parent_scope, | 1196 | parent_scope, |
| | 1197 | parent_line, |
| 1174 | extra.data.end, | 1198 | extra.data.end, |
| 1175 | false, | 1199 | false, |
| 1176 | ); | 1200 | ); |
| 1177 | var sentinel: DocData.WalkResult = try self.walkRef( | 1201 | var sentinel: DocData.WalkResult = try self.walkRef( |
| 1178 | file, | 1202 | file, |
| 1179 | parent_scope, | 1203 | parent_scope, |
| | 1204 | parent_line, |
| 1180 | extra.data.sentinel, | 1205 | extra.data.sentinel, |
| 1181 | false, | 1206 | false, |
| 1182 | ); | 1207 | ); |
| ... | @@ -1226,12 +1251,14 @@ fn walkInstruction( | ... | @@ -1226,12 +1251,14 @@ fn walkInstruction( |
| 1226 | var lhs: DocData.WalkResult = try self.walkRef( | 1251 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1227 | file, | 1252 | file, |
| 1228 | parent_scope, | 1253 | parent_scope, |
| | 1254 | parent_line, |
| 1229 | extra.data.lhs, | 1255 | extra.data.lhs, |
| 1230 | false, | 1256 | false, |
| 1231 | ); | 1257 | ); |
| 1232 | var rhs: DocData.WalkResult = try self.walkRef( | 1258 | var rhs: DocData.WalkResult = try self.walkRef( |
| 1233 | file, | 1259 | file, |
| 1234 | parent_scope, | 1260 | parent_scope, |
| | 1261 | parent_line, |
| 1235 | extra.data.rhs, | 1262 | extra.data.rhs, |
| 1236 | false, | 1263 | false, |
| 1237 | ); | 1264 | ); |
| ... | @@ -1292,7 +1319,7 @@ fn walkInstruction( | ... | @@ -1292,7 +1319,7 @@ fn walkInstruction( |
| 1292 | const un_node = data[inst_index].un_node; | 1319 | const un_node = data[inst_index].un_node; |
| 1293 | const bin_index = self.exprs.items.len; | 1320 | const bin_index = self.exprs.items.len; |
| 1294 | try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } }); | 1321 | try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } }); |
| 1295 | const param = try self.walkRef(file, parent_scope, un_node.operand, false); | 1322 | const param = try self.walkRef(file, parent_scope, parent_line, un_node.operand, false); |
| 1296 | | 1323 | |
| 1297 | const param_index = self.exprs.items.len; | 1324 | const param_index = self.exprs.items.len; |
| 1298 | try self.exprs.append(self.arena, param.expr); | 1325 | try self.exprs.append(self.arena, param.expr); |
| ... | @@ -1341,12 +1368,14 @@ fn walkInstruction( | ... | @@ -1341,12 +1368,14 @@ fn walkInstruction( |
| 1341 | var lhs: DocData.WalkResult = try self.walkRef( | 1368 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1342 | file, | 1369 | file, |
| 1343 | parent_scope, | 1370 | parent_scope, |
| | 1371 | parent_line, |
| 1344 | extra.data.lhs, | 1372 | extra.data.lhs, |
| 1345 | false, | 1373 | false, |
| 1346 | ); | 1374 | ); |
| 1347 | var rhs: DocData.WalkResult = try self.walkRef( | 1375 | var rhs: DocData.WalkResult = try self.walkRef( |
| 1348 | file, | 1376 | file, |
| 1349 | parent_scope, | 1377 | parent_scope, |
| | 1378 | parent_line, |
| 1350 | extra.data.rhs, | 1379 | extra.data.rhs, |
| 1351 | false, | 1380 | false, |
| 1352 | ); | 1381 | ); |
| ... | @@ -1369,12 +1398,14 @@ fn walkInstruction( | ... | @@ -1369,12 +1398,14 @@ fn walkInstruction( |
| 1369 | var lhs: DocData.WalkResult = try self.walkRef( | 1398 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1370 | file, | 1399 | file, |
| 1371 | parent_scope, | 1400 | parent_scope, |
| | 1401 | parent_line, |
| 1372 | extra.data.lhs, | 1402 | extra.data.lhs, |
| 1373 | false, | 1403 | false, |
| 1374 | ); | 1404 | ); |
| 1375 | var rhs: DocData.WalkResult = try self.walkRef( | 1405 | var rhs: DocData.WalkResult = try self.walkRef( |
| 1376 | file, | 1406 | file, |
| 1377 | parent_scope, | 1407 | parent_scope, |
| | 1408 | parent_line, |
| 1378 | extra.data.rhs, | 1409 | extra.data.rhs, |
| 1379 | false, | 1410 | false, |
| 1380 | ); | 1411 | ); |
| ... | @@ -1397,12 +1428,14 @@ fn walkInstruction( | ... | @@ -1397,12 +1428,14 @@ fn walkInstruction( |
| 1397 | var lhs: DocData.WalkResult = try self.walkRef( | 1428 | var lhs: DocData.WalkResult = try self.walkRef( |
| 1398 | file, | 1429 | file, |
| 1399 | parent_scope, | 1430 | parent_scope, |
| | 1431 | parent_line, |
| 1400 | extra.data.lhs, | 1432 | extra.data.lhs, |
| 1401 | false, | 1433 | false, |
| 1402 | ); | 1434 | ); |
| 1403 | var rhs: DocData.WalkResult = try self.walkRef( | 1435 | var rhs: DocData.WalkResult = try self.walkRef( |
| 1404 | file, | 1436 | file, |
| 1405 | parent_scope, | 1437 | parent_scope, |
| | 1438 | parent_line, |
| 1406 | extra.data.rhs, | 1439 | extra.data.rhs, |
| 1407 | false, | 1440 | false, |
| 1408 | ); | 1441 | ); |
| ... | @@ -1422,7 +1455,7 @@ fn walkInstruction( | ... | @@ -1422,7 +1455,7 @@ fn walkInstruction( |
| 1422 | | 1455 | |
| 1423 | // var operand: DocData.WalkResult = try self.walkRef( | 1456 | // var operand: DocData.WalkResult = try self.walkRef( |
| 1424 | // file, | 1457 | // file, |
| 1425 | // parent_scope, | 1458 | // parent_scope, parent_line, |
| 1426 | // un_node.operand, | 1459 | // un_node.operand, |
| 1427 | // false, | 1460 | // false, |
| 1428 | // ); | 1461 | // ); |
| ... | @@ -1431,7 +1464,7 @@ fn walkInstruction( | ... | @@ -1431,7 +1464,7 @@ fn walkInstruction( |
| 1431 | // }, | 1464 | // }, |
| 1432 | .overflow_arithmetic_ptr => { | 1465 | .overflow_arithmetic_ptr => { |
| 1433 | const un_node = data[inst_index].un_node; | 1466 | const un_node = data[inst_index].un_node; |
| 1434 | const elem_type_ref = try self.walkRef(file, parent_scope, un_node.operand, false); | 1467 | const elem_type_ref = try self.walkRef(file, parent_scope, parent_line, un_node.operand, false); |
| 1435 | const type_slot_index = self.types.items.len; | 1468 | const type_slot_index = self.types.items.len; |
| 1436 | try self.types.append(self.arena, .{ | 1469 | try self.types.append(self.arena, .{ |
| 1437 | .Pointer = .{ | 1470 | .Pointer = .{ |
| ... | @@ -1456,6 +1489,7 @@ fn walkInstruction( | ... | @@ -1456,6 +1489,7 @@ fn walkInstruction( |
| 1456 | const elem_type_ref = try self.walkRef( | 1489 | const elem_type_ref = try self.walkRef( |
| 1457 | file, | 1490 | file, |
| 1458 | parent_scope, | 1491 | parent_scope, |
| | 1492 | parent_line, |
| 1459 | extra.data.elem_type, | 1493 | extra.data.elem_type, |
| 1460 | false, | 1494 | false, |
| 1461 | ); | 1495 | ); |
| ... | @@ -1465,7 +1499,7 @@ fn walkInstruction( | ... | @@ -1465,7 +1499,7 @@ fn walkInstruction( |
| 1465 | var sentinel: ?DocData.Expr = null; | 1499 | var sentinel: ?DocData.Expr = null; |
| 1466 | if (ptr.flags.has_sentinel) { | 1500 | if (ptr.flags.has_sentinel) { |
| 1467 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 1501 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 1468 | const ref_result = try self.walkRef(file, parent_scope, ref, false); | 1502 | const ref_result = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 1469 | sentinel = ref_result.expr; | 1503 | sentinel = ref_result.expr; |
| 1470 | extra_index += 1; | 1504 | extra_index += 1; |
| 1471 | } | 1505 | } |
| ... | @@ -1473,21 +1507,21 @@ fn walkInstruction( | ... | @@ -1473,21 +1507,21 @@ fn walkInstruction( |
| 1473 | var @"align": ?DocData.Expr = null; | 1507 | var @"align": ?DocData.Expr = null; |
| 1474 | if (ptr.flags.has_align) { | 1508 | if (ptr.flags.has_align) { |
| 1475 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 1509 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 1476 | const ref_result = try self.walkRef(file, parent_scope, ref, false); | 1510 | const ref_result = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 1477 | @"align" = ref_result.expr; | 1511 | @"align" = ref_result.expr; |
| 1478 | extra_index += 1; | 1512 | extra_index += 1; |
| 1479 | } | 1513 | } |
| 1480 | var address_space: ?DocData.Expr = null; | 1514 | var address_space: ?DocData.Expr = null; |
| 1481 | if (ptr.flags.has_addrspace) { | 1515 | if (ptr.flags.has_addrspace) { |
| 1482 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 1516 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 1483 | const ref_result = try self.walkRef(file, parent_scope, ref, false); | 1517 | const ref_result = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 1484 | address_space = ref_result.expr; | 1518 | address_space = ref_result.expr; |
| 1485 | extra_index += 1; | 1519 | extra_index += 1; |
| 1486 | } | 1520 | } |
| 1487 | var bit_start: ?DocData.Expr = null; | 1521 | var bit_start: ?DocData.Expr = null; |
| 1488 | if (ptr.flags.has_bit_range) { | 1522 | if (ptr.flags.has_bit_range) { |
| 1489 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 1523 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 1490 | const ref_result = try self.walkRef(file, parent_scope, ref, false); | 1524 | const ref_result = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 1491 | address_space = ref_result.expr; | 1525 | address_space = ref_result.expr; |
| 1492 | extra_index += 1; | 1526 | extra_index += 1; |
| 1493 | } | 1527 | } |
| ... | @@ -1495,7 +1529,7 @@ fn walkInstruction( | ... | @@ -1495,7 +1529,7 @@ fn walkInstruction( |
| 1495 | var host_size: ?DocData.Expr = null; | 1529 | var host_size: ?DocData.Expr = null; |
| 1496 | if (ptr.flags.has_bit_range) { | 1530 | if (ptr.flags.has_bit_range) { |
| 1497 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 1531 | const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 1498 | const ref_result = try self.walkRef(file, parent_scope, ref, false); | 1532 | const ref_result = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 1499 | host_size = ref_result.expr; | 1533 | host_size = ref_result.expr; |
| 1500 | } | 1534 | } |
| 1501 | | 1535 | |
| ... | @@ -1525,8 +1559,8 @@ fn walkInstruction( | ... | @@ -1525,8 +1559,8 @@ fn walkInstruction( |
| 1525 | .array_type => { | 1559 | .array_type => { |
| 1526 | const pl_node = data[inst_index].pl_node; | 1560 | const pl_node = data[inst_index].pl_node; |
| 1527 | const bin = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index).data; | 1561 | const bin = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index).data; |
| 1528 | const len = try self.walkRef(file, parent_scope, bin.lhs, false); | 1562 | const len = try self.walkRef(file, parent_scope, parent_line, bin.lhs, false); |
| 1529 | const child = try self.walkRef(file, parent_scope, bin.rhs, false); | 1563 | const child = try self.walkRef(file, parent_scope, parent_line, bin.rhs, false); |
| 1530 | | 1564 | |
| 1531 | const type_slot_index = self.types.items.len; | 1565 | const type_slot_index = self.types.items.len; |
| 1532 | try self.types.append(self.arena, .{ | 1566 | try self.types.append(self.arena, .{ |
| ... | @@ -1544,9 +1578,9 @@ fn walkInstruction( | ... | @@ -1544,9 +1578,9 @@ fn walkInstruction( |
| 1544 | .array_type_sentinel => { | 1578 | .array_type_sentinel => { |
| 1545 | const pl_node = data[inst_index].pl_node; | 1579 | const pl_node = data[inst_index].pl_node; |
| 1546 | const extra = file.zir.extraData(Zir.Inst.ArrayTypeSentinel, pl_node.payload_index); | 1580 | const extra = file.zir.extraData(Zir.Inst.ArrayTypeSentinel, pl_node.payload_index); |
| 1547 | const len = try self.walkRef(file, parent_scope, extra.data.len, false); | 1581 | const len = try self.walkRef(file, parent_scope, parent_line, extra.data.len, false); |
| 1548 | const sentinel = try self.walkRef(file, parent_scope, extra.data.sentinel, false); | 1582 | const sentinel = try self.walkRef(file, parent_scope, parent_line, extra.data.sentinel, false); |
| 1549 | const elem_type = try self.walkRef(file, parent_scope, extra.data.elem_type, false); | 1583 | const elem_type = try self.walkRef(file, parent_scope, parent_line, extra.data.elem_type, false); |
| 1550 | | 1584 | |
| 1551 | const type_slot_index = self.types.items.len; | 1585 | const type_slot_index = self.types.items.len; |
| 1552 | try self.types.append(self.arena, .{ | 1586 | try self.types.append(self.arena, .{ |
| ... | @@ -1568,10 +1602,10 @@ fn walkInstruction( | ... | @@ -1568,10 +1602,10 @@ fn walkInstruction( |
| 1568 | const array_data = try self.arena.alloc(usize, operands.len - 1); | 1602 | const array_data = try self.arena.alloc(usize, operands.len - 1); |
| 1569 | | 1603 | |
| 1570 | std.debug.assert(operands.len > 0); | 1604 | std.debug.assert(operands.len > 0); |
| 1571 | var array_type = try self.walkRef(file, parent_scope, operands[0], false); | 1605 | var array_type = try self.walkRef(file, parent_scope, parent_line, operands[0], false); |
| 1572 | | 1606 | |
| 1573 | for (operands[1..]) |op, idx| { | 1607 | for (operands[1..]) |op, idx| { |
| 1574 | const wr = try self.walkRef(file, parent_scope, op, false); | 1608 | const wr = try self.walkRef(file, parent_scope, parent_line, op, false); |
| 1575 | const expr_index = self.exprs.items.len; | 1609 | const expr_index = self.exprs.items.len; |
| 1576 | try self.exprs.append(self.arena, wr.expr); | 1610 | try self.exprs.append(self.arena, wr.expr); |
| 1577 | array_data[idx] = expr_index; | 1611 | array_data[idx] = expr_index; |
| ... | @@ -1589,7 +1623,7 @@ fn walkInstruction( | ... | @@ -1589,7 +1623,7 @@ fn walkInstruction( |
| 1589 | const array_data = try self.arena.alloc(usize, operands.len); | 1623 | const array_data = try self.arena.alloc(usize, operands.len); |
| 1590 | | 1624 | |
| 1591 | for (operands) |op, idx| { | 1625 | for (operands) |op, idx| { |
| 1592 | const wr = try self.walkRef(file, parent_scope, op, false); | 1626 | const wr = try self.walkRef(file, parent_scope, parent_line, op, false); |
| 1593 | const expr_index = self.exprs.items.len; | 1627 | const expr_index = self.exprs.items.len; |
| 1594 | try self.exprs.append(self.arena, wr.expr); | 1628 | try self.exprs.append(self.arena, wr.expr); |
| 1595 | array_data[idx] = expr_index; | 1629 | array_data[idx] = expr_index; |
| ... | @@ -1607,10 +1641,10 @@ fn walkInstruction( | ... | @@ -1607,10 +1641,10 @@ fn walkInstruction( |
| 1607 | const array_data = try self.arena.alloc(usize, operands.len - 1); | 1641 | const array_data = try self.arena.alloc(usize, operands.len - 1); |
| 1608 | | 1642 | |
| 1609 | std.debug.assert(operands.len > 0); | 1643 | std.debug.assert(operands.len > 0); |
| 1610 | var array_type = try self.walkRef(file, parent_scope, operands[0], false); | 1644 | var array_type = try self.walkRef(file, parent_scope, parent_line, operands[0], false); |
| 1611 | | 1645 | |
| 1612 | for (operands[1..]) |op, idx| { | 1646 | for (operands[1..]) |op, idx| { |
| 1613 | const wr = try self.walkRef(file, parent_scope, op, false); | 1647 | const wr = try self.walkRef(file, parent_scope, parent_line, op, false); |
| 1614 | const expr_index = self.exprs.items.len; | 1648 | const expr_index = self.exprs.items.len; |
| 1615 | try self.exprs.append(self.arena, wr.expr); | 1649 | try self.exprs.append(self.arena, wr.expr); |
| 1616 | array_data[idx] = expr_index; | 1650 | array_data[idx] = expr_index; |
| ... | @@ -1639,7 +1673,7 @@ fn walkInstruction( | ... | @@ -1639,7 +1673,7 @@ fn walkInstruction( |
| 1639 | const array_data = try self.arena.alloc(usize, operands.len); | 1673 | const array_data = try self.arena.alloc(usize, operands.len); |
| 1640 | | 1674 | |
| 1641 | for (operands) |op, idx| { | 1675 | for (operands) |op, idx| { |
| 1642 | const wr = try self.walkRef(file, parent_scope, op, false); | 1676 | const wr = try self.walkRef(file, parent_scope, parent_line, op, false); |
| 1643 | const expr_index = self.exprs.items.len; | 1677 | const expr_index = self.exprs.items.len; |
| 1644 | try self.exprs.append(self.arena, wr.expr); | 1678 | try self.exprs.append(self.arena, wr.expr); |
| 1645 | array_data[idx] = expr_index; | 1679 | array_data[idx] = expr_index; |
| ... | @@ -1674,6 +1708,7 @@ fn walkInstruction( | ... | @@ -1674,6 +1708,7 @@ fn walkInstruction( |
| 1674 | var operand: DocData.WalkResult = try self.walkRef( | 1708 | var operand: DocData.WalkResult = try self.walkRef( |
| 1675 | file, | 1709 | file, |
| 1676 | parent_scope, | 1710 | parent_scope, |
| | 1711 | parent_line, |
| 1677 | un_node.operand, | 1712 | un_node.operand, |
| 1678 | need_type, | 1713 | need_type, |
| 1679 | ); | 1714 | ); |
| ... | @@ -1695,6 +1730,7 @@ fn walkInstruction( | ... | @@ -1695,6 +1730,7 @@ fn walkInstruction( |
| 1695 | const operand = try self.walkRef( | 1730 | const operand = try self.walkRef( |
| 1696 | file, | 1731 | file, |
| 1697 | parent_scope, | 1732 | parent_scope, |
| | 1733 | parent_line, |
| 1698 | un_node.operand, | 1734 | un_node.operand, |
| 1699 | false, | 1735 | false, |
| 1700 | ); | 1736 | ); |
| ... | @@ -1711,6 +1747,7 @@ fn walkInstruction( | ... | @@ -1711,6 +1747,7 @@ fn walkInstruction( |
| 1711 | const operand = try self.walkRef( | 1747 | const operand = try self.walkRef( |
| 1712 | file, | 1748 | file, |
| 1713 | parent_scope, | 1749 | parent_scope, |
| | 1750 | parent_line, |
| 1714 | un_node.operand, | 1751 | un_node.operand, |
| 1715 | need_type, | 1752 | need_type, |
| 1716 | ); | 1753 | ); |
| ... | @@ -1728,6 +1765,7 @@ fn walkInstruction( | ... | @@ -1728,6 +1765,7 @@ fn walkInstruction( |
| 1728 | const operand = try self.walkRef( | 1765 | const operand = try self.walkRef( |
| 1729 | file, | 1766 | file, |
| 1730 | parent_scope, | 1767 | parent_scope, |
| | 1768 | parent_line, |
| 1731 | un_node.operand, | 1769 | un_node.operand, |
| 1732 | false, | 1770 | false, |
| 1733 | ); | 1771 | ); |
| ... | @@ -1744,7 +1782,7 @@ fn walkInstruction( | ... | @@ -1744,7 +1782,7 @@ fn walkInstruction( |
| 1744 | const pl_node = data[inst_index].pl_node; | 1782 | const pl_node = data[inst_index].pl_node; |
| 1745 | const extra = file.zir.extraData(Zir.Inst.SwitchBlock, pl_node.payload_index); | 1783 | const extra = file.zir.extraData(Zir.Inst.SwitchBlock, pl_node.payload_index); |
| 1746 | const cond_index = self.exprs.items.len; | 1784 | const cond_index = self.exprs.items.len; |
| 1747 | _ = try self.walkRef(file, parent_scope, extra.data.operand, false); | 1785 | _ = try self.walkRef(file, parent_scope, parent_line, extra.data.operand, false); |
| 1748 | | 1786 | |
| 1749 | const ast_index = self.ast_nodes.items.len; | 1787 | const ast_index = self.ast_nodes.items.len; |
| 1750 | const type_index = self.types.items.len - 1; | 1788 | const type_index = self.types.items.len - 1; |
| ... | @@ -1772,6 +1810,7 @@ fn walkInstruction( | ... | @@ -1772,6 +1810,7 @@ fn walkInstruction( |
| 1772 | const operand = try self.walkRef( | 1810 | const operand = try self.walkRef( |
| 1773 | file, | 1811 | file, |
| 1774 | parent_scope, | 1812 | parent_scope, |
| | 1813 | parent_line, |
| 1775 | un_node.operand, | 1814 | un_node.operand, |
| 1776 | need_type, | 1815 | need_type, |
| 1777 | ); | 1816 | ); |
| ... | @@ -1797,6 +1836,7 @@ fn walkInstruction( | ... | @@ -1797,6 +1836,7 @@ fn walkInstruction( |
| 1797 | const operand = try self.walkRef( | 1836 | const operand = try self.walkRef( |
| 1798 | file, | 1837 | file, |
| 1799 | parent_scope, | 1838 | parent_scope, |
| | 1839 | parent_line, |
| 1800 | un_node.operand, | 1840 | un_node.operand, |
| 1801 | need_type, | 1841 | need_type, |
| 1802 | ); | 1842 | ); |
| ... | @@ -1816,6 +1856,7 @@ fn walkInstruction( | ... | @@ -1816,6 +1856,7 @@ fn walkInstruction( |
| 1816 | var operand: DocData.WalkResult = try self.walkRef( | 1856 | var operand: DocData.WalkResult = try self.walkRef( |
| 1817 | file, | 1857 | file, |
| 1818 | parent_scope, | 1858 | parent_scope, |
| | 1859 | parent_line, |
| 1819 | data[body].@"break".operand, | 1860 | data[body].@"break".operand, |
| 1820 | false, | 1861 | false, |
| 1821 | ); | 1862 | ); |
| ... | @@ -1834,6 +1875,7 @@ fn walkInstruction( | ... | @@ -1834,6 +1875,7 @@ fn walkInstruction( |
| 1834 | const operand = try self.walkRef( | 1875 | const operand = try self.walkRef( |
| 1835 | file, | 1876 | file, |
| 1836 | parent_scope, | 1877 | parent_scope, |
| | 1878 | parent_line, |
| 1837 | un_node.operand, | 1879 | un_node.operand, |
| 1838 | need_type, | 1880 | need_type, |
| 1839 | ); | 1881 | ); |
| ... | @@ -1852,6 +1894,7 @@ fn walkInstruction( | ... | @@ -1852,6 +1894,7 @@ fn walkInstruction( |
| 1852 | const dest_type_walk = try self.walkRef( | 1894 | const dest_type_walk = try self.walkRef( |
| 1853 | file, | 1895 | file, |
| 1854 | parent_scope, | 1896 | parent_scope, |
| | 1897 | parent_line, |
| 1855 | extra.data.dest_type, | 1898 | extra.data.dest_type, |
| 1856 | false, | 1899 | false, |
| 1857 | ); | 1900 | ); |
| ... | @@ -1859,6 +1902,7 @@ fn walkInstruction( | ... | @@ -1859,6 +1902,7 @@ fn walkInstruction( |
| 1859 | const operand = try self.walkRef( | 1902 | const operand = try self.walkRef( |
| 1860 | file, | 1903 | file, |
| 1861 | parent_scope, | 1904 | parent_scope, |
| | 1905 | parent_line, |
| 1862 | extra.data.operand, | 1906 | extra.data.operand, |
| 1863 | false, | 1907 | false, |
| 1864 | ); | 1908 | ); |
| ... | @@ -1886,6 +1930,7 @@ fn walkInstruction( | ... | @@ -1886,6 +1930,7 @@ fn walkInstruction( |
| 1886 | const operand: DocData.WalkResult = try self.walkRef( | 1930 | const operand: DocData.WalkResult = try self.walkRef( |
| 1887 | file, | 1931 | file, |
| 1888 | parent_scope, | 1932 | parent_scope, |
| | 1933 | parent_line, |
| 1889 | un_node.operand, | 1934 | un_node.operand, |
| 1890 | false, | 1935 | false, |
| 1891 | ); | 1936 | ); |
| ... | @@ -1969,7 +2014,7 @@ fn walkInstruction( | ... | @@ -1969,7 +2014,7 @@ fn walkInstruction( |
| 1969 | } | 2014 | } |
| 1970 | } | 2015 | } |
| 1971 | | 2016 | |
| 1972 | break :blk try self.walkRef(file, parent_scope, lhs_ref, false); | 2017 | break :blk try self.walkRef(file, parent_scope, parent_line, lhs_ref, false); |
| 1973 | }; | 2018 | }; |
| 1974 | try path.append(self.arena, wr.expr); | 2019 | try path.append(self.arena, wr.expr); |
| 1975 | | 2020 | |
| ... | @@ -2020,6 +2065,7 @@ fn walkInstruction( | ... | @@ -2020,6 +2065,7 @@ fn walkInstruction( |
| 2020 | return self.walkRef( | 2065 | return self.walkRef( |
| 2021 | file, | 2066 | file, |
| 2022 | parent_scope, | 2067 | parent_scope, |
| | 2068 | parent_line, |
| 2023 | getBlockInlineBreak(file.zir, inst_index), | 2069 | getBlockInlineBreak(file.zir, inst_index), |
| 2024 | need_type, | 2070 | need_type, |
| 2025 | ); | 2071 | ); |
| ... | @@ -2052,6 +2098,7 @@ fn walkInstruction( | ... | @@ -2052,6 +2098,7 @@ fn walkInstruction( |
| 2052 | const wr = try self.walkRef( | 2098 | const wr = try self.walkRef( |
| 2053 | file, | 2099 | file, |
| 2054 | parent_scope, | 2100 | parent_scope, |
| | 2101 | parent_line, |
| 2055 | field_extra.data.container_type, | 2102 | field_extra.data.container_type, |
| 2056 | false, | 2103 | false, |
| 2057 | ); | 2104 | ); |
| ... | @@ -2062,6 +2109,7 @@ fn walkInstruction( | ... | @@ -2062,6 +2109,7 @@ fn walkInstruction( |
| 2062 | const value = try self.walkRef( | 2109 | const value = try self.walkRef( |
| 2063 | file, | 2110 | file, |
| 2064 | parent_scope, | 2111 | parent_scope, |
| | 2112 | parent_line, |
| 2065 | init_extra.data.init, | 2113 | init_extra.data.init, |
| 2066 | need_type, | 2114 | need_type, |
| 2067 | ); | 2115 | ); |
| ... | @@ -2078,6 +2126,7 @@ fn walkInstruction( | ... | @@ -2078,6 +2126,7 @@ fn walkInstruction( |
| 2078 | var operand: DocData.WalkResult = try self.walkRef( | 2126 | var operand: DocData.WalkResult = try self.walkRef( |
| 2079 | file, | 2127 | file, |
| 2080 | parent_scope, | 2128 | parent_scope, |
| | 2129 | parent_line, |
| 2081 | un_node.operand, | 2130 | un_node.operand, |
| 2082 | false, | 2131 | false, |
| 2083 | ); | 2132 | ); |
| ... | @@ -2110,6 +2159,7 @@ fn walkInstruction( | ... | @@ -2110,6 +2159,7 @@ fn walkInstruction( |
| 2110 | const value = try self.walkRef( | 2159 | const value = try self.walkRef( |
| 2111 | file, | 2160 | file, |
| 2112 | parent_scope, | 2161 | parent_scope, |
| | 2162 | parent_line, |
| 2113 | init_extra.data.init, | 2163 | init_extra.data.init, |
| 2114 | need_type, | 2164 | need_type, |
| 2115 | ); | 2165 | ); |
| ... | @@ -2185,7 +2235,7 @@ fn walkInstruction( | ... | @@ -2185,7 +2235,7 @@ fn walkInstruction( |
| 2185 | const pl_node = data[inst_index].pl_node; | 2235 | const pl_node = data[inst_index].pl_node; |
| 2186 | const extra = file.zir.extraData(Zir.Inst.Call, pl_node.payload_index); | 2236 | const extra = file.zir.extraData(Zir.Inst.Call, pl_node.payload_index); |
| 2187 | | 2237 | |
| 2188 | const callee = try self.walkRef(file, parent_scope, extra.data.callee, need_type); | 2238 | const callee = try self.walkRef(file, parent_scope, parent_line, extra.data.callee, need_type); |
| 2189 | | 2239 | |
| 2190 | const args_len = extra.data.flags.args_len; | 2240 | const args_len = extra.data.flags.args_len; |
| 2191 | var args = try self.arena.alloc(DocData.Expr, args_len); | 2241 | var args = try self.arena.alloc(DocData.Expr, args_len); |
| ... | @@ -2200,7 +2250,7 @@ fn walkInstruction( | ... | @@ -2200,7 +2250,7 @@ fn walkInstruction( |
| 2200 | // to show discrepancies between the types of provided | 2250 | // to show discrepancies between the types of provided |
| 2201 | // arguments and the types declared in the function | 2251 | // arguments and the types declared in the function |
| 2202 | // signature for its parameters. | 2252 | // signature for its parameters. |
| 2203 | const wr = try self.walkRef(file, parent_scope, ref, false); | 2253 | const wr = try self.walkRef(file, parent_scope, parent_line, ref, false); |
| 2204 | args[i] = wr.expr; | 2254 | args[i] = wr.expr; |
| 2205 | } | 2255 | } |
| 2206 | | 2256 | |
| ... | @@ -2231,6 +2281,7 @@ fn walkInstruction( | ... | @@ -2231,6 +2281,7 @@ fn walkInstruction( |
| 2231 | const result = self.analyzeFunction( | 2281 | const result = self.analyzeFunction( |
| 2232 | file, | 2282 | file, |
| 2233 | parent_scope, | 2283 | parent_scope, |
| | 2284 | parent_line, |
| 2234 | inst_index, | 2285 | inst_index, |
| 2235 | self_ast_node_index, | 2286 | self_ast_node_index, |
| 2236 | type_slot_index, | 2287 | type_slot_index, |
| ... | @@ -2246,6 +2297,7 @@ fn walkInstruction( | ... | @@ -2246,6 +2297,7 @@ fn walkInstruction( |
| 2246 | const result = self.analyzeFancyFunction( | 2297 | const result = self.analyzeFancyFunction( |
| 2247 | file, | 2298 | file, |
| 2248 | parent_scope, | 2299 | parent_scope, |
| | 2300 | parent_line, |
| 2249 | inst_index, | 2301 | inst_index, |
| 2250 | self_ast_node_index, | 2302 | self_ast_node_index, |
| 2251 | type_slot_index, | 2303 | type_slot_index, |
| ... | @@ -2273,7 +2325,7 @@ fn walkInstruction( | ... | @@ -2273,7 +2325,7 @@ fn walkInstruction( |
| 2273 | | 2325 | |
| 2274 | var array_type: ?DocData.Expr = null; | 2326 | var array_type: ?DocData.Expr = null; |
| 2275 | for (args) |arg, idx| { | 2327 | for (args) |arg, idx| { |
| 2276 | const wr = try self.walkRef(file, parent_scope, arg, idx == 0); | 2328 | const wr = try self.walkRef(file, parent_scope, parent_line, arg, idx == 0); |
| 2277 | if (idx == 0) { | 2329 | if (idx == 0) { |
| 2278 | array_type = wr.typeRef; | 2330 | array_type = wr.typeRef; |
| 2279 | } | 2331 | } |
| ... | @@ -2418,6 +2470,7 @@ fn walkInstruction( | ... | @@ -2418,6 +2470,7 @@ fn walkInstruction( |
| 2418 | extra_index = try self.walkDecls( | 2470 | extra_index = try self.walkDecls( |
| 2419 | file, | 2471 | file, |
| 2420 | &scope, | 2472 | &scope, |
| | 2473 | parent_line, |
| 2421 | decls_first_index, | 2474 | decls_first_index, |
| 2422 | decls_len, | 2475 | decls_len, |
| 2423 | &decl_indexes, | 2476 | &decl_indexes, |
| ... | @@ -2438,6 +2491,7 @@ fn walkInstruction( | ... | @@ -2438,6 +2491,7 @@ fn walkInstruction( |
| 2438 | try self.collectUnionFieldInfo( | 2491 | try self.collectUnionFieldInfo( |
| 2439 | file, | 2492 | file, |
| 2440 | &scope, | 2493 | &scope, |
| | 2494 | parent_line, |
| 2441 | fields_len, | 2495 | fields_len, |
| 2442 | &field_type_refs, | 2496 | &field_type_refs, |
| 2443 | &field_name_indexes, | 2497 | &field_name_indexes, |
| ... | @@ -2538,6 +2592,7 @@ fn walkInstruction( | ... | @@ -2538,6 +2592,7 @@ fn walkInstruction( |
| 2538 | extra_index = try self.walkDecls( | 2592 | extra_index = try self.walkDecls( |
| 2539 | file, | 2593 | file, |
| 2540 | &scope, | 2594 | &scope, |
| | 2595 | parent_line, |
| 2541 | decls_first_index, | 2596 | decls_first_index, |
| 2542 | decls_len, | 2597 | decls_len, |
| 2543 | &decl_indexes, | 2598 | &decl_indexes, |
| ... | @@ -2681,6 +2736,7 @@ fn walkInstruction( | ... | @@ -2681,6 +2736,7 @@ fn walkInstruction( |
| 2681 | extra_index = try self.walkDecls( | 2736 | extra_index = try self.walkDecls( |
| 2682 | file, | 2737 | file, |
| 2683 | &scope, | 2738 | &scope, |
| | 2739 | parent_line, |
| 2684 | decls_first_index, | 2740 | decls_first_index, |
| 2685 | decls_len, | 2741 | decls_len, |
| 2686 | &decl_indexes, | 2742 | &decl_indexes, |
| ... | @@ -2693,6 +2749,7 @@ fn walkInstruction( | ... | @@ -2693,6 +2749,7 @@ fn walkInstruction( |
| 2693 | try self.collectStructFieldInfo( | 2749 | try self.collectStructFieldInfo( |
| 2694 | file, | 2750 | file, |
| 2695 | &scope, | 2751 | &scope, |
| | 2752 | parent_line, |
| 2696 | fields_len, | 2753 | fields_len, |
| 2697 | &field_type_refs, | 2754 | &field_type_refs, |
| 2698 | &field_name_indexes, | 2755 | &field_name_indexes, |
| ... | @@ -2736,7 +2793,7 @@ fn walkInstruction( | ... | @@ -2736,7 +2793,7 @@ fn walkInstruction( |
| 2736 | const extra = file.zir.extraData(Zir.Inst.UnNode, extended.operand).data; | 2793 | const extra = file.zir.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 2737 | const bin_index = self.exprs.items.len; | 2794 | const bin_index = self.exprs.items.len; |
| 2738 | try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } }); | 2795 | try self.exprs.append(self.arena, .{ .builtin = .{ .param = 0 } }); |
| 2739 | const param = try self.walkRef(file, parent_scope, extra.operand, false); | 2796 | const param = try self.walkRef(file, parent_scope, parent_line, extra.operand, false); |
| 2740 | | 2797 | |
| 2741 | const param_index = self.exprs.items.len; | 2798 | const param_index = self.exprs.items.len; |
| 2742 | try self.exprs.append(self.arena, param.expr); | 2799 | try self.exprs.append(self.arena, param.expr); |
| ... | @@ -2764,6 +2821,7 @@ fn walkDecls( | ... | @@ -2764,6 +2821,7 @@ fn walkDecls( |
| 2764 | self: *Autodoc, | 2821 | self: *Autodoc, |
| 2765 | file: *File, | 2822 | file: *File, |
| 2766 | scope: *Scope, | 2823 | scope: *Scope, |
| | 2824 | parent_line: usize, |
| 2767 | decls_first_index: usize, | 2825 | decls_first_index: usize, |
| 2768 | decls_len: u32, | 2826 | decls_len: u32, |
| 2769 | decl_indexes: *std.ArrayListUnmanaged(usize), | 2827 | decl_indexes: *std.ArrayListUnmanaged(usize), |
| ... | @@ -2796,7 +2854,7 @@ fn walkDecls( | ... | @@ -2796,7 +2854,7 @@ fn walkDecls( |
| 2796 | | 2854 | |
| 2797 | // const hash_u32s = file.zir.extra[extra_index..][0..4]; | 2855 | // const hash_u32s = file.zir.extra[extra_index..][0..4]; |
| 2798 | extra_index += 4; | 2856 | extra_index += 4; |
| 2799 | const line = file.zir.extra[extra_index]; | 2857 | const line = parent_line + file.zir.extra[extra_index]; |
| 2800 | extra_index += 1; | 2858 | extra_index += 1; |
| 2801 | const decl_name_index = file.zir.extra[extra_index]; | 2859 | const decl_name_index = file.zir.extra[extra_index]; |
| 2802 | extra_index += 1; | 2860 | extra_index += 1; |
| ... | @@ -2936,7 +2994,7 @@ fn walkDecls( | ... | @@ -2936,7 +2994,7 @@ fn walkDecls( |
| 2936 | const idx = self.ast_nodes.items.len; | 2994 | const idx = self.ast_nodes.items.len; |
| 2937 | try self.ast_nodes.append(self.arena, .{ | 2995 | try self.ast_nodes.append(self.arena, .{ |
| 2938 | .file = self.files.getIndex(file) orelse unreachable, | 2996 | .file = self.files.getIndex(file) orelse unreachable, |
| 2939 | .line = line, // TODO: calculate absolute line | 2997 | .line = line, |
| 2940 | .col = 0, | 2998 | .col = 0, |
| 2941 | .docs = doc_comment, | 2999 | .docs = doc_comment, |
| 2942 | .fields = null, // walkInstruction will fill `fields` if necessary | 3000 | .fields = null, // walkInstruction will fill `fields` if necessary |
| ... | @@ -2947,7 +3005,7 @@ fn walkDecls( | ... | @@ -2947,7 +3005,7 @@ fn walkDecls( |
| 2947 | const walk_result = if (is_test) // TODO: decide if tests should show up at all | 3005 | const walk_result = if (is_test) // TODO: decide if tests should show up at all |
| 2948 | DocData.WalkResult{ .expr = .{ .void = .{} } } | 3006 | DocData.WalkResult{ .expr = .{ .void = .{} } } |
| 2949 | else | 3007 | else |
| 2950 | try self.walkInstruction(file, scope, value_index, true); | 3008 | try self.walkInstruction(file, scope, line, value_index, true); |
| 2951 | | 3009 | |
| 2952 | if (is_pub) { | 3010 | if (is_pub) { |
| 2953 | try decl_indexes.append(self.arena, decls_slot_index); | 3011 | try decl_indexes.append(self.arena, decls_slot_index); |
| ... | @@ -3343,6 +3401,7 @@ fn analyzeFancyFunction( | ... | @@ -3343,6 +3401,7 @@ fn analyzeFancyFunction( |
| 3343 | self: *Autodoc, | 3401 | self: *Autodoc, |
| 3344 | file: *File, | 3402 | file: *File, |
| 3345 | scope: *Scope, | 3403 | scope: *Scope, |
| | 3404 | parent_line: usize, |
| 3346 | inst_index: usize, | 3405 | inst_index: usize, |
| 3347 | self_ast_node_index: usize, | 3406 | self_ast_node_index: usize, |
| 3348 | type_slot_index: usize, | 3407 | type_slot_index: usize, |
| ... | @@ -3407,7 +3466,7 @@ fn analyzeFancyFunction( | ... | @@ -3407,7 +3466,7 @@ fn analyzeFancyFunction( |
| 3407 | | 3466 | |
| 3408 | const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1]; | 3467 | const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1]; |
| 3409 | const break_operand = data[break_index].@"break".operand; | 3468 | const break_operand = data[break_index].@"break".operand; |
| 3410 | const param_type_ref = try self.walkRef(file, scope, break_operand, false); | 3469 | const param_type_ref = try self.walkRef(file, scope, parent_line, break_operand, false); |
| 3411 | | 3470 | |
| 3412 | param_type_refs.appendAssumeCapacity(param_type_ref.expr); | 3471 | param_type_refs.appendAssumeCapacity(param_type_ref.expr); |
| 3413 | }, | 3472 | }, |
| ... | @@ -3431,7 +3490,7 @@ fn analyzeFancyFunction( | ... | @@ -3431,7 +3490,7 @@ fn analyzeFancyFunction( |
| 3431 | if (extra.data.bits.has_align_ref) { | 3490 | if (extra.data.bits.has_align_ref) { |
| 3432 | const align_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 3491 | const align_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 3433 | align_index = self.exprs.items.len; | 3492 | align_index = self.exprs.items.len; |
| 3434 | _ = try self.walkRef(file, scope, align_ref, false); | 3493 | _ = try self.walkRef(file, scope, parent_line, align_ref, false); |
| 3435 | extra_index += 1; | 3494 | extra_index += 1; |
| 3436 | } else if (extra.data.bits.has_align_body) { | 3495 | } else if (extra.data.bits.has_align_body) { |
| 3437 | const align_body_len = file.zir.extra[extra_index]; | 3496 | const align_body_len = file.zir.extra[extra_index]; |
| ... | @@ -3448,7 +3507,7 @@ fn analyzeFancyFunction( | ... | @@ -3448,7 +3507,7 @@ fn analyzeFancyFunction( |
| 3448 | if (extra.data.bits.has_addrspace_ref) { | 3507 | if (extra.data.bits.has_addrspace_ref) { |
| 3449 | const addrspace_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 3508 | const addrspace_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 3450 | addrspace_index = self.exprs.items.len; | 3509 | addrspace_index = self.exprs.items.len; |
| 3451 | _ = try self.walkRef(file, scope, addrspace_ref, false); | 3510 | _ = try self.walkRef(file, scope, parent_line, addrspace_ref, false); |
| 3452 | extra_index += 1; | 3511 | extra_index += 1; |
| 3453 | } else if (extra.data.bits.has_addrspace_body) { | 3512 | } else if (extra.data.bits.has_addrspace_body) { |
| 3454 | const addrspace_body_len = file.zir.extra[extra_index]; | 3513 | const addrspace_body_len = file.zir.extra[extra_index]; |
| ... | @@ -3465,7 +3524,7 @@ fn analyzeFancyFunction( | ... | @@ -3465,7 +3524,7 @@ fn analyzeFancyFunction( |
| 3465 | if (extra.data.bits.has_section_ref) { | 3524 | if (extra.data.bits.has_section_ref) { |
| 3466 | const section_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 3525 | const section_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 3467 | section_index = self.exprs.items.len; | 3526 | section_index = self.exprs.items.len; |
| 3468 | _ = try self.walkRef(file, scope, section_ref, false); | 3527 | _ = try self.walkRef(file, scope, parent_line, section_ref, false); |
| 3469 | extra_index += 1; | 3528 | extra_index += 1; |
| 3470 | } else if (extra.data.bits.has_section_body) { | 3529 | } else if (extra.data.bits.has_section_body) { |
| 3471 | const section_body_len = file.zir.extra[extra_index]; | 3530 | const section_body_len = file.zir.extra[extra_index]; |
| ... | @@ -3482,7 +3541,7 @@ fn analyzeFancyFunction( | ... | @@ -3482,7 +3541,7 @@ fn analyzeFancyFunction( |
| 3482 | if (extra.data.bits.has_cc_ref) { | 3541 | if (extra.data.bits.has_cc_ref) { |
| 3483 | const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 3542 | const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| 3484 | cc_index = self.exprs.items.len; | 3543 | cc_index = self.exprs.items.len; |
| 3485 | _ = try self.walkRef(file, scope, cc_ref, false); | 3544 | _ = try self.walkRef(file, scope, parent_line, cc_ref, false); |
| 3486 | extra_index += 1; | 3545 | extra_index += 1; |
| 3487 | } else if (extra.data.bits.has_cc_body) { | 3546 | } else if (extra.data.bits.has_cc_body) { |
| 3488 | const cc_body_len = file.zir.extra[extra_index]; | 3547 | const cc_body_len = file.zir.extra[extra_index]; |
| ... | @@ -3501,14 +3560,14 @@ fn analyzeFancyFunction( | ... | @@ -3501,14 +3560,14 @@ fn analyzeFancyFunction( |
| 3501 | .none => DocData.Expr{ .void = .{} }, | 3560 | .none => DocData.Expr{ .void = .{} }, |
| 3502 | else => blk: { | 3561 | else => blk: { |
| 3503 | const ref = fn_info.ret_ty_ref; | 3562 | const ref = fn_info.ret_ty_ref; |
| 3504 | const wr = try self.walkRef(file, scope, ref, false); | 3563 | const wr = try self.walkRef(file, scope, parent_line, ref, false); |
| 3505 | break :blk wr.expr; | 3564 | break :blk wr.expr; |
| 3506 | }, | 3565 | }, |
| 3507 | }, | 3566 | }, |
| 3508 | else => blk: { | 3567 | else => blk: { |
| 3509 | const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1]; | 3568 | const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1]; |
| 3510 | const break_operand = data[last_instr_index].@"break".operand; | 3569 | const break_operand = data[last_instr_index].@"break".operand; |
| 3511 | const wr = try self.walkRef(file, scope, break_operand, false); | 3570 | const wr = try self.walkRef(file, scope, parent_line, break_operand, false); |
| 3512 | break :blk wr.expr; | 3571 | break :blk wr.expr; |
| 3513 | }, | 3572 | }, |
| 3514 | }; | 3573 | }; |
| ... | @@ -3523,6 +3582,7 @@ fn analyzeFancyFunction( | ... | @@ -3523,6 +3582,7 @@ fn analyzeFancyFunction( |
| 3523 | break :blk try self.getGenericReturnType( | 3582 | break :blk try self.getGenericReturnType( |
| 3524 | file, | 3583 | file, |
| 3525 | scope, | 3584 | scope, |
| | 3585 | parent_line, |
| 3526 | fn_info.body[fn_info.body.len - 1], | 3586 | fn_info.body[fn_info.body.len - 1], |
| 3527 | ); | 3587 | ); |
| 3528 | } else { | 3588 | } else { |
| ... | @@ -3559,6 +3619,7 @@ fn analyzeFunction( | ... | @@ -3559,6 +3619,7 @@ fn analyzeFunction( |
| 3559 | self: *Autodoc, | 3619 | self: *Autodoc, |
| 3560 | file: *File, | 3620 | file: *File, |
| 3561 | scope: *Scope, | 3621 | scope: *Scope, |
| | 3622 | parent_line: usize, |
| 3562 | inst_index: usize, | 3623 | inst_index: usize, |
| 3563 | self_ast_node_index: usize, | 3624 | self_ast_node_index: usize, |
| 3564 | type_slot_index: usize, | 3625 | type_slot_index: usize, |
| ... | @@ -3624,7 +3685,7 @@ fn analyzeFunction( | ... | @@ -3624,7 +3685,7 @@ fn analyzeFunction( |
| 3624 | | 3685 | |
| 3625 | const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1]; | 3686 | const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1]; |
| 3626 | const break_operand = data[break_index].@"break".operand; | 3687 | const break_operand = data[break_index].@"break".operand; |
| 3627 | const param_type_ref = try self.walkRef(file, scope, break_operand, false); | 3688 | const param_type_ref = try self.walkRef(file, scope, parent_line, break_operand, false); |
| 3628 | | 3689 | |
| 3629 | param_type_refs.appendAssumeCapacity(param_type_ref.expr); | 3690 | param_type_refs.appendAssumeCapacity(param_type_ref.expr); |
| 3630 | }, | 3691 | }, |
| ... | @@ -3637,14 +3698,14 @@ fn analyzeFunction( | ... | @@ -3637,14 +3698,14 @@ fn analyzeFunction( |
| 3637 | .none => DocData.Expr{ .void = .{} }, | 3698 | .none => DocData.Expr{ .void = .{} }, |
| 3638 | else => blk: { | 3699 | else => blk: { |
| 3639 | const ref = fn_info.ret_ty_ref; | 3700 | const ref = fn_info.ret_ty_ref; |
| 3640 | const wr = try self.walkRef(file, scope, ref, false); | 3701 | const wr = try self.walkRef(file, scope, parent_line, ref, false); |
| 3641 | break :blk wr.expr; | 3702 | break :blk wr.expr; |
| 3642 | }, | 3703 | }, |
| 3643 | }, | 3704 | }, |
| 3644 | else => blk: { | 3705 | else => blk: { |
| 3645 | const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1]; | 3706 | const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1]; |
| 3646 | const break_operand = data[last_instr_index].@"break".operand; | 3707 | const break_operand = data[last_instr_index].@"break".operand; |
| 3647 | const wr = try self.walkRef(file, scope, break_operand, false); | 3708 | const wr = try self.walkRef(file, scope, parent_line, break_operand, false); |
| 3648 | break :blk wr.expr; | 3709 | break :blk wr.expr; |
| 3649 | }, | 3710 | }, |
| 3650 | }; | 3711 | }; |
| ... | @@ -3659,6 +3720,7 @@ fn analyzeFunction( | ... | @@ -3659,6 +3720,7 @@ fn analyzeFunction( |
| 3659 | break :blk try self.getGenericReturnType( | 3720 | break :blk try self.getGenericReturnType( |
| 3660 | file, | 3721 | file, |
| 3661 | scope, | 3722 | scope, |
| | 3723 | parent_line, |
| 3662 | fn_info.body[fn_info.body.len - 1], | 3724 | fn_info.body[fn_info.body.len - 1], |
| 3663 | ); | 3725 | ); |
| 3664 | } else { | 3726 | } else { |
| ... | @@ -3699,9 +3761,11 @@ fn getGenericReturnType( | ... | @@ -3699,9 +3761,11 @@ fn getGenericReturnType( |
| 3699 | self: *Autodoc, | 3761 | self: *Autodoc, |
| 3700 | file: *File, | 3762 | file: *File, |
| 3701 | scope: *Scope, | 3763 | scope: *Scope, |
| | 3764 | parent_line: usize, // function decl line |
| 3702 | body_end: usize, | 3765 | body_end: usize, |
| 3703 | ) !DocData.Expr { | 3766 | ) !DocData.Expr { |
| 3704 | const wr = try self.walkInstruction(file, scope, body_end, false); | 3767 | // TODO: compute the correct line offset |
| | 3768 | const wr = try self.walkInstruction(file, scope, parent_line, body_end, false); |
| 3705 | return wr.expr; | 3769 | return wr.expr; |
| 3706 | } | 3770 | } |
| 3707 | | 3771 | |
| ... | @@ -3709,6 +3773,7 @@ fn collectUnionFieldInfo( | ... | @@ -3709,6 +3773,7 @@ fn collectUnionFieldInfo( |
| 3709 | self: *Autodoc, | 3773 | self: *Autodoc, |
| 3710 | file: *File, | 3774 | file: *File, |
| 3711 | scope: *Scope, | 3775 | scope: *Scope, |
| | 3776 | parent_line: usize, |
| 3712 | fields_len: usize, | 3777 | fields_len: usize, |
| 3713 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), | 3778 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), |
| 3714 | field_name_indexes: *std.ArrayListUnmanaged(usize), | 3779 | field_name_indexes: *std.ArrayListUnmanaged(usize), |
| ... | @@ -3755,7 +3820,7 @@ fn collectUnionFieldInfo( | ... | @@ -3755,7 +3820,7 @@ fn collectUnionFieldInfo( |
| 3755 | | 3820 | |
| 3756 | // type | 3821 | // type |
| 3757 | { | 3822 | { |
| 3758 | const walk_result = try self.walkRef(file, scope, field_type, false); | 3823 | const walk_result = try self.walkRef(file, scope, parent_line, field_type, false); |
| 3759 | try field_type_refs.append(self.arena, walk_result.expr); | 3824 | try field_type_refs.append(self.arena, walk_result.expr); |
| 3760 | } | 3825 | } |
| 3761 | | 3826 | |
| ... | @@ -3778,6 +3843,7 @@ fn collectStructFieldInfo( | ... | @@ -3778,6 +3843,7 @@ fn collectStructFieldInfo( |
| 3778 | self: *Autodoc, | 3843 | self: *Autodoc, |
| 3779 | file: *File, | 3844 | file: *File, |
| 3780 | scope: *Scope, | 3845 | scope: *Scope, |
| | 3846 | parent_line: usize, |
| 3781 | fields_len: usize, | 3847 | fields_len: usize, |
| 3782 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), | 3848 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), |
| 3783 | field_name_indexes: *std.ArrayListUnmanaged(usize), | 3849 | field_name_indexes: *std.ArrayListUnmanaged(usize), |
| ... | @@ -3851,7 +3917,7 @@ fn collectStructFieldInfo( | ... | @@ -3851,7 +3917,7 @@ fn collectStructFieldInfo( |
| 3851 | for (fields) |field| { | 3917 | for (fields) |field| { |
| 3852 | const type_expr = expr: { | 3918 | const type_expr = expr: { |
| 3853 | if (field.type_ref != .none) { | 3919 | if (field.type_ref != .none) { |
| 3854 | const walk_result = try self.walkRef(file, scope, field.type_ref, false); | 3920 | const walk_result = try self.walkRef(file, scope, parent_line, field.type_ref, false); |
| 3855 | break :expr walk_result.expr; | 3921 | break :expr walk_result.expr; |
| 3856 | } | 3922 | } |
| 3857 | | 3923 | |
| ... | @@ -3861,7 +3927,7 @@ fn collectStructFieldInfo( | ... | @@ -3861,7 +3927,7 @@ fn collectStructFieldInfo( |
| 3861 | | 3927 | |
| 3862 | const break_inst = body[body.len - 1]; | 3928 | const break_inst = body[body.len - 1]; |
| 3863 | const operand = data[break_inst].@"break".operand; | 3929 | const operand = data[break_inst].@"break".operand; |
| 3864 | const walk_result = try self.walkRef(file, scope, operand, false); | 3930 | const walk_result = try self.walkRef(file, scope, parent_line, operand, false); |
| 3865 | break :expr walk_result.expr; | 3931 | break :expr walk_result.expr; |
| 3866 | }; | 3932 | }; |
| 3867 | | 3933 | |
| ... | @@ -3891,6 +3957,7 @@ fn walkRef( | ... | @@ -3891,6 +3957,7 @@ fn walkRef( |
| 3891 | self: *Autodoc, | 3957 | self: *Autodoc, |
| 3892 | file: *File, | 3958 | file: *File, |
| 3893 | parent_scope: *Scope, | 3959 | parent_scope: *Scope, |
| | 3960 | parent_line: usize, |
| 3894 | ref: Ref, | 3961 | ref: Ref, |
| 3895 | need_type: bool, // true when the caller needs also a typeRef for the return value | 3962 | need_type: bool, // true when the caller needs also a typeRef for the return value |
| 3896 | ) AutodocErrors!DocData.WalkResult { | 3963 | ) AutodocErrors!DocData.WalkResult { |
| ... | @@ -4002,7 +4069,7 @@ fn walkRef( | ... | @@ -4002,7 +4069,7 @@ fn walkRef( |
| 4002 | } | 4069 | } |
| 4003 | } else { | 4070 | } else { |
| 4004 | const zir_index = enum_value - Ref.typed_value_map.len; | 4071 | const zir_index = enum_value - Ref.typed_value_map.len; |
| 4005 | return self.walkInstruction(file, parent_scope, zir_index, need_type); | 4072 | return self.walkInstruction(file, parent_scope, parent_line, zir_index, need_type); |
| 4006 | } | 4073 | } |
| 4007 | } | 4074 | } |
| 4008 | | 4075 | |