| author | |
| committer | |
| log | 1f8f79cd53d2fbe96af7e7583fd3905c434f5543 |
| tree | 122be3aedbd43b09cf69284a893ff9cd85638e98 |
| parent | fcee1bf9930ad48300863d1b85b1f0a7ee924fbc |
| signature |
5 files changed, 475 insertions(+), 789 deletions(-)
lib/std/zig/Ast.zig+205-72| ... | @@ -1243,7 +1243,7 @@ pub fn globalVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | ... | @@ -1243,7 +1243,7 @@ pub fn globalVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1243 | assert(tree.nodes.items(.tag)[node] == .global_var_decl); | 1243 | assert(tree.nodes.items(.tag)[node] == .global_var_decl); |
| 1244 | const data = tree.nodes.items(.data)[node]; | 1244 | const data = tree.nodes.items(.data)[node]; |
| 1245 | const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); | 1245 | const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); |
| 1246 | return tree.fullVarDecl(.{ | 1246 | return tree.fullVarDeclComponents(.{ |
| 1247 | .type_node = extra.type_node, | 1247 | .type_node = extra.type_node, |
| 1248 | .align_node = extra.align_node, | 1248 | .align_node = extra.align_node, |
| 1249 | .addrspace_node = extra.addrspace_node, | 1249 | .addrspace_node = extra.addrspace_node, |
| ... | @@ -1257,7 +1257,7 @@ pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | ... | @@ -1257,7 +1257,7 @@ pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1257 | assert(tree.nodes.items(.tag)[node] == .local_var_decl); | 1257 | assert(tree.nodes.items(.tag)[node] == .local_var_decl); |
| 1258 | const data = tree.nodes.items(.data)[node]; | 1258 | const data = tree.nodes.items(.data)[node]; |
| 1259 | const extra = tree.extraData(data.lhs, Node.LocalVarDecl); | 1259 | const extra = tree.extraData(data.lhs, Node.LocalVarDecl); |
| 1260 | return tree.fullVarDecl(.{ | 1260 | return tree.fullVarDeclComponents(.{ |
| 1261 | .type_node = extra.type_node, | 1261 | .type_node = extra.type_node, |
| 1262 | .align_node = extra.align_node, | 1262 | .align_node = extra.align_node, |
| 1263 | .addrspace_node = 0, | 1263 | .addrspace_node = 0, |
| ... | @@ -1270,7 +1270,7 @@ pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | ... | @@ -1270,7 +1270,7 @@ pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1270 | pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | 1270 | pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1271 | assert(tree.nodes.items(.tag)[node] == .simple_var_decl); | 1271 | assert(tree.nodes.items(.tag)[node] == .simple_var_decl); |
| 1272 | const data = tree.nodes.items(.data)[node]; | 1272 | const data = tree.nodes.items(.data)[node]; |
| 1273 | return tree.fullVarDecl(.{ | 1273 | return tree.fullVarDeclComponents(.{ |
| 1274 | .type_node = data.lhs, | 1274 | .type_node = data.lhs, |
| 1275 | .align_node = 0, | 1275 | .align_node = 0, |
| 1276 | .addrspace_node = 0, | 1276 | .addrspace_node = 0, |
| ... | @@ -1283,7 +1283,7 @@ pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | ... | @@ -1283,7 +1283,7 @@ pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1283 | pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | 1283 | pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1284 | assert(tree.nodes.items(.tag)[node] == .aligned_var_decl); | 1284 | assert(tree.nodes.items(.tag)[node] == .aligned_var_decl); |
| 1285 | const data = tree.nodes.items(.data)[node]; | 1285 | const data = tree.nodes.items(.data)[node]; |
| 1286 | return tree.fullVarDecl(.{ | 1286 | return tree.fullVarDeclComponents(.{ |
| 1287 | .type_node = 0, | 1287 | .type_node = 0, |
| 1288 | .align_node = data.lhs, | 1288 | .align_node = data.lhs, |
| 1289 | .addrspace_node = 0, | 1289 | .addrspace_node = 0, |
| ... | @@ -1296,7 +1296,7 @@ pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl { | ... | @@ -1296,7 +1296,7 @@ pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl { |
| 1296 | pub fn ifSimple(tree: Ast, node: Node.Index) full.If { | 1296 | pub fn ifSimple(tree: Ast, node: Node.Index) full.If { |
| 1297 | assert(tree.nodes.items(.tag)[node] == .if_simple); | 1297 | assert(tree.nodes.items(.tag)[node] == .if_simple); |
| 1298 | const data = tree.nodes.items(.data)[node]; | 1298 | const data = tree.nodes.items(.data)[node]; |
| 1299 | return tree.fullIf(.{ | 1299 | return tree.fullIfComponents(.{ |
| 1300 | .cond_expr = data.lhs, | 1300 | .cond_expr = data.lhs, |
| 1301 | .then_expr = data.rhs, | 1301 | .then_expr = data.rhs, |
| 1302 | .else_expr = 0, | 1302 | .else_expr = 0, |
| ... | @@ -1308,7 +1308,7 @@ pub fn ifFull(tree: Ast, node: Node.Index) full.If { | ... | @@ -1308,7 +1308,7 @@ pub fn ifFull(tree: Ast, node: Node.Index) full.If { |
| 1308 | assert(tree.nodes.items(.tag)[node] == .@"if"); | 1308 | assert(tree.nodes.items(.tag)[node] == .@"if"); |
| 1309 | const data = tree.nodes.items(.data)[node]; | 1309 | const data = tree.nodes.items(.data)[node]; |
| 1310 | const extra = tree.extraData(data.rhs, Node.If); | 1310 | const extra = tree.extraData(data.rhs, Node.If); |
| 1311 | return tree.fullIf(.{ | 1311 | return tree.fullIfComponents(.{ |
| 1312 | .cond_expr = data.lhs, | 1312 | .cond_expr = data.lhs, |
| 1313 | .then_expr = extra.then_expr, | 1313 | .then_expr = extra.then_expr, |
| 1314 | .else_expr = extra.else_expr, | 1314 | .else_expr = extra.else_expr, |
| ... | @@ -1321,7 +1321,7 @@ pub fn containerField(tree: Ast, node: Node.Index) full.ContainerField { | ... | @@ -1321,7 +1321,7 @@ pub fn containerField(tree: Ast, node: Node.Index) full.ContainerField { |
| 1321 | const data = tree.nodes.items(.data)[node]; | 1321 | const data = tree.nodes.items(.data)[node]; |
| 1322 | const extra = tree.extraData(data.rhs, Node.ContainerField); | 1322 | const extra = tree.extraData(data.rhs, Node.ContainerField); |
| 1323 | const main_token = tree.nodes.items(.main_token)[node]; | 1323 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1324 | return tree.fullContainerField(.{ | 1324 | return tree.fullContainerFieldComponents(.{ |
| 1325 | .main_token = main_token, | 1325 | .main_token = main_token, |
| 1326 | .type_expr = data.lhs, | 1326 | .type_expr = data.lhs, |
| 1327 | .value_expr = extra.value_expr, | 1327 | .value_expr = extra.value_expr, |
| ... | @@ -1334,7 +1334,7 @@ pub fn containerFieldInit(tree: Ast, node: Node.Index) full.ContainerField { | ... | @@ -1334,7 +1334,7 @@ pub fn containerFieldInit(tree: Ast, node: Node.Index) full.ContainerField { |
| 1334 | assert(tree.nodes.items(.tag)[node] == .container_field_init); | 1334 | assert(tree.nodes.items(.tag)[node] == .container_field_init); |
| 1335 | const data = tree.nodes.items(.data)[node]; | 1335 | const data = tree.nodes.items(.data)[node]; |
| 1336 | const main_token = tree.nodes.items(.main_token)[node]; | 1336 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1337 | return tree.fullContainerField(.{ | 1337 | return tree.fullContainerFieldComponents(.{ |
| 1338 | .main_token = main_token, | 1338 | .main_token = main_token, |
| 1339 | .type_expr = data.lhs, | 1339 | .type_expr = data.lhs, |
| 1340 | .value_expr = data.rhs, | 1340 | .value_expr = data.rhs, |
| ... | @@ -1347,7 +1347,7 @@ pub fn containerFieldAlign(tree: Ast, node: Node.Index) full.ContainerField { | ... | @@ -1347,7 +1347,7 @@ pub fn containerFieldAlign(tree: Ast, node: Node.Index) full.ContainerField { |
| 1347 | assert(tree.nodes.items(.tag)[node] == .container_field_align); | 1347 | assert(tree.nodes.items(.tag)[node] == .container_field_align); |
| 1348 | const data = tree.nodes.items(.data)[node]; | 1348 | const data = tree.nodes.items(.data)[node]; |
| 1349 | const main_token = tree.nodes.items(.main_token)[node]; | 1349 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1350 | return tree.fullContainerField(.{ | 1350 | return tree.fullContainerFieldComponents(.{ |
| 1351 | .main_token = main_token, | 1351 | .main_token = main_token, |
| 1352 | .type_expr = data.lhs, | 1352 | .type_expr = data.lhs, |
| 1353 | .value_expr = 0, | 1353 | .value_expr = 0, |
| ... | @@ -1361,7 +1361,7 @@ pub fn fnProtoSimple(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.F | ... | @@ -1361,7 +1361,7 @@ pub fn fnProtoSimple(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.F |
| 1361 | const data = tree.nodes.items(.data)[node]; | 1361 | const data = tree.nodes.items(.data)[node]; |
| 1362 | buffer[0] = data.lhs; | 1362 | buffer[0] = data.lhs; |
| 1363 | const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1]; | 1363 | const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1]; |
| 1364 | return tree.fullFnProto(.{ | 1364 | return tree.fullFnProtoComponents(.{ |
| 1365 | .proto_node = node, | 1365 | .proto_node = node, |
| 1366 | .fn_token = tree.nodes.items(.main_token)[node], | 1366 | .fn_token = tree.nodes.items(.main_token)[node], |
| 1367 | .return_type = data.rhs, | 1367 | .return_type = data.rhs, |
| ... | @@ -1378,7 +1378,7 @@ pub fn fnProtoMulti(tree: Ast, node: Node.Index) full.FnProto { | ... | @@ -1378,7 +1378,7 @@ pub fn fnProtoMulti(tree: Ast, node: Node.Index) full.FnProto { |
| 1378 | const data = tree.nodes.items(.data)[node]; | 1378 | const data = tree.nodes.items(.data)[node]; |
| 1379 | const params_range = tree.extraData(data.lhs, Node.SubRange); | 1379 | const params_range = tree.extraData(data.lhs, Node.SubRange); |
| 1380 | const params = tree.extra_data[params_range.start..params_range.end]; | 1380 | const params = tree.extra_data[params_range.start..params_range.end]; |
| 1381 | return tree.fullFnProto(.{ | 1381 | return tree.fullFnProtoComponents(.{ |
| 1382 | .proto_node = node, | 1382 | .proto_node = node, |
| 1383 | .fn_token = tree.nodes.items(.main_token)[node], | 1383 | .fn_token = tree.nodes.items(.main_token)[node], |
| 1384 | .return_type = data.rhs, | 1384 | .return_type = data.rhs, |
| ... | @@ -1396,7 +1396,7 @@ pub fn fnProtoOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnPr | ... | @@ -1396,7 +1396,7 @@ pub fn fnProtoOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnPr |
| 1396 | const extra = tree.extraData(data.lhs, Node.FnProtoOne); | 1396 | const extra = tree.extraData(data.lhs, Node.FnProtoOne); |
| 1397 | buffer[0] = extra.param; | 1397 | buffer[0] = extra.param; |
| 1398 | const params = if (extra.param == 0) buffer[0..0] else buffer[0..1]; | 1398 | const params = if (extra.param == 0) buffer[0..0] else buffer[0..1]; |
| 1399 | return tree.fullFnProto(.{ | 1399 | return tree.fullFnProtoComponents(.{ |
| 1400 | .proto_node = node, | 1400 | .proto_node = node, |
| 1401 | .fn_token = tree.nodes.items(.main_token)[node], | 1401 | .fn_token = tree.nodes.items(.main_token)[node], |
| 1402 | .return_type = data.rhs, | 1402 | .return_type = data.rhs, |
| ... | @@ -1413,7 +1413,7 @@ pub fn fnProto(tree: Ast, node: Node.Index) full.FnProto { | ... | @@ -1413,7 +1413,7 @@ pub fn fnProto(tree: Ast, node: Node.Index) full.FnProto { |
| 1413 | const data = tree.nodes.items(.data)[node]; | 1413 | const data = tree.nodes.items(.data)[node]; |
| 1414 | const extra = tree.extraData(data.lhs, Node.FnProto); | 1414 | const extra = tree.extraData(data.lhs, Node.FnProto); |
| 1415 | const params = tree.extra_data[extra.params_start..extra.params_end]; | 1415 | const params = tree.extra_data[extra.params_start..extra.params_end]; |
| 1416 | return tree.fullFnProto(.{ | 1416 | return tree.fullFnProtoComponents(.{ |
| 1417 | .proto_node = node, | 1417 | .proto_node = node, |
| 1418 | .fn_token = tree.nodes.items(.main_token)[node], | 1418 | .fn_token = tree.nodes.items(.main_token)[node], |
| 1419 | .return_type = data.rhs, | 1419 | .return_type = data.rhs, |
| ... | @@ -1431,11 +1431,13 @@ pub fn structInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.S | ... | @@ -1431,11 +1431,13 @@ pub fn structInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.S |
| 1431 | const data = tree.nodes.items(.data)[node]; | 1431 | const data = tree.nodes.items(.data)[node]; |
| 1432 | buffer[0] = data.rhs; | 1432 | buffer[0] = data.rhs; |
| 1433 | const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; | 1433 | const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; |
| 1434 | return tree.fullStructInit(.{ | 1434 | return .{ |
| 1435 | .lbrace = tree.nodes.items(.main_token)[node], | 1435 | .ast = .{ |
| 1436 | .fields = fields, | 1436 | .lbrace = tree.nodes.items(.main_token)[node], |
| 1437 | .type_expr = data.lhs, | 1437 | .fields = fields, |
| 1438 | }); | 1438 | .type_expr = data.lhs, |
| 1439 | }, | ||
| 1440 | }; | ||
| 1439 | } | 1441 | } |
| 1440 | 1442 | ||
| 1441 | pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { | 1443 | pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { |
| ... | @@ -1449,22 +1451,26 @@ pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) ful | ... | @@ -1449,22 +1451,26 @@ pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) ful |
| 1449 | buffer[0..1] | 1451 | buffer[0..1] |
| 1450 | else | 1452 | else |
| 1451 | buffer[0..0]; | 1453 | buffer[0..0]; |
| 1452 | return tree.fullStructInit(.{ | 1454 | return .{ |
| 1453 | .lbrace = tree.nodes.items(.main_token)[node], | 1455 | .ast = .{ |
| 1454 | .fields = fields, | 1456 | .lbrace = tree.nodes.items(.main_token)[node], |
| 1455 | .type_expr = 0, | 1457 | .fields = fields, |
| 1456 | }); | 1458 | .type_expr = 0, |
| 1459 | }, | ||
| 1460 | }; | ||
| 1457 | } | 1461 | } |
| 1458 | 1462 | ||
| 1459 | pub fn structInitDot(tree: Ast, node: Node.Index) full.StructInit { | 1463 | pub fn structInitDot(tree: Ast, node: Node.Index) full.StructInit { |
| 1460 | assert(tree.nodes.items(.tag)[node] == .struct_init_dot or | 1464 | assert(tree.nodes.items(.tag)[node] == .struct_init_dot or |
| 1461 | tree.nodes.items(.tag)[node] == .struct_init_dot_comma); | 1465 | tree.nodes.items(.tag)[node] == .struct_init_dot_comma); |
| 1462 | const data = tree.nodes.items(.data)[node]; | 1466 | const data = tree.nodes.items(.data)[node]; |
| 1463 | return tree.fullStructInit(.{ | 1467 | return .{ |
| 1464 | .lbrace = tree.nodes.items(.main_token)[node], | 1468 | .ast = .{ |
| 1465 | .fields = tree.extra_data[data.lhs..data.rhs], | 1469 | .lbrace = tree.nodes.items(.main_token)[node], |
| 1466 | .type_expr = 0, | 1470 | .fields = tree.extra_data[data.lhs..data.rhs], |
| 1467 | }); | 1471 | .type_expr = 0, |
| 1472 | }, | ||
| 1473 | }; | ||
| 1468 | } | 1474 | } |
| 1469 | 1475 | ||
| 1470 | pub fn structInit(tree: Ast, node: Node.Index) full.StructInit { | 1476 | pub fn structInit(tree: Ast, node: Node.Index) full.StructInit { |
| ... | @@ -1472,11 +1478,13 @@ pub fn structInit(tree: Ast, node: Node.Index) full.StructInit { | ... | @@ -1472,11 +1478,13 @@ pub fn structInit(tree: Ast, node: Node.Index) full.StructInit { |
| 1472 | tree.nodes.items(.tag)[node] == .struct_init_comma); | 1478 | tree.nodes.items(.tag)[node] == .struct_init_comma); |
| 1473 | const data = tree.nodes.items(.data)[node]; | 1479 | const data = tree.nodes.items(.data)[node]; |
| 1474 | const fields_range = tree.extraData(data.rhs, Node.SubRange); | 1480 | const fields_range = tree.extraData(data.rhs, Node.SubRange); |
| 1475 | return tree.fullStructInit(.{ | 1481 | return .{ |
| 1476 | .lbrace = tree.nodes.items(.main_token)[node], | 1482 | .ast = .{ |
| 1477 | .fields = tree.extra_data[fields_range.start..fields_range.end], | 1483 | .lbrace = tree.nodes.items(.main_token)[node], |
| 1478 | .type_expr = data.lhs, | 1484 | .fields = tree.extra_data[fields_range.start..fields_range.end], |
| 1479 | }); | 1485 | .type_expr = data.lhs, |
| 1486 | }, | ||
| 1487 | }; | ||
| 1480 | } | 1488 | } |
| 1481 | 1489 | ||
| 1482 | pub fn arrayInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { | 1490 | pub fn arrayInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { |
| ... | @@ -1572,7 +1580,7 @@ pub fn arrayTypeSentinel(tree: Ast, node: Node.Index) full.ArrayType { | ... | @@ -1572,7 +1580,7 @@ pub fn arrayTypeSentinel(tree: Ast, node: Node.Index) full.ArrayType { |
| 1572 | pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType { | 1580 | pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType { |
| 1573 | assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned); | 1581 | assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned); |
| 1574 | const data = tree.nodes.items(.data)[node]; | 1582 | const data = tree.nodes.items(.data)[node]; |
| 1575 | return tree.fullPtrType(.{ | 1583 | return tree.fullPtrTypeComponents(.{ |
| 1576 | .main_token = tree.nodes.items(.main_token)[node], | 1584 | .main_token = tree.nodes.items(.main_token)[node], |
| 1577 | .align_node = data.lhs, | 1585 | .align_node = data.lhs, |
| 1578 | .addrspace_node = 0, | 1586 | .addrspace_node = 0, |
| ... | @@ -1586,7 +1594,7 @@ pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType { | ... | @@ -1586,7 +1594,7 @@ pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType { |
| 1586 | pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType { | 1594 | pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType { |
| 1587 | assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel); | 1595 | assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel); |
| 1588 | const data = tree.nodes.items(.data)[node]; | 1596 | const data = tree.nodes.items(.data)[node]; |
| 1589 | return tree.fullPtrType(.{ | 1597 | return tree.fullPtrTypeComponents(.{ |
| 1590 | .main_token = tree.nodes.items(.main_token)[node], | 1598 | .main_token = tree.nodes.items(.main_token)[node], |
| 1591 | .align_node = 0, | 1599 | .align_node = 0, |
| 1592 | .addrspace_node = 0, | 1600 | .addrspace_node = 0, |
| ... | @@ -1601,7 +1609,7 @@ pub fn ptrType(tree: Ast, node: Node.Index) full.PtrType { | ... | @@ -1601,7 +1609,7 @@ pub fn ptrType(tree: Ast, node: Node.Index) full.PtrType { |
| 1601 | assert(tree.nodes.items(.tag)[node] == .ptr_type); | 1609 | assert(tree.nodes.items(.tag)[node] == .ptr_type); |
| 1602 | const data = tree.nodes.items(.data)[node]; | 1610 | const data = tree.nodes.items(.data)[node]; |
| 1603 | const extra = tree.extraData(data.lhs, Node.PtrType); | 1611 | const extra = tree.extraData(data.lhs, Node.PtrType); |
| 1604 | return tree.fullPtrType(.{ | 1612 | return tree.fullPtrTypeComponents(.{ |
| 1605 | .main_token = tree.nodes.items(.main_token)[node], | 1613 | .main_token = tree.nodes.items(.main_token)[node], |
| 1606 | .align_node = extra.align_node, | 1614 | .align_node = extra.align_node, |
| 1607 | .addrspace_node = extra.addrspace_node, | 1615 | .addrspace_node = extra.addrspace_node, |
| ... | @@ -1616,7 +1624,7 @@ pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType { | ... | @@ -1616,7 +1624,7 @@ pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType { |
| 1616 | assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range); | 1624 | assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range); |
| 1617 | const data = tree.nodes.items(.data)[node]; | 1625 | const data = tree.nodes.items(.data)[node]; |
| 1618 | const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); | 1626 | const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); |
| 1619 | return tree.fullPtrType(.{ | 1627 | return tree.fullPtrTypeComponents(.{ |
| 1620 | .main_token = tree.nodes.items(.main_token)[node], | 1628 | .main_token = tree.nodes.items(.main_token)[node], |
| 1621 | .align_node = extra.align_node, | 1629 | .align_node = extra.align_node, |
| 1622 | .addrspace_node = extra.addrspace_node, | 1630 | .addrspace_node = extra.addrspace_node, |
| ... | @@ -1682,7 +1690,7 @@ pub fn containerDeclTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) ful | ... | @@ -1682,7 +1690,7 @@ pub fn containerDeclTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) ful |
| 1682 | buffer[0..1] | 1690 | buffer[0..1] |
| 1683 | else | 1691 | else |
| 1684 | buffer[0..0]; | 1692 | buffer[0..0]; |
| 1685 | return tree.fullContainerDecl(.{ | 1693 | return tree.fullContainerDeclComponents(.{ |
| 1686 | .main_token = tree.nodes.items(.main_token)[node], | 1694 | .main_token = tree.nodes.items(.main_token)[node], |
| 1687 | .enum_token = null, | 1695 | .enum_token = null, |
| 1688 | .members = members, | 1696 | .members = members, |
| ... | @@ -1694,7 +1702,7 @@ pub fn containerDecl(tree: Ast, node: Node.Index) full.ContainerDecl { | ... | @@ -1694,7 +1702,7 @@ pub fn containerDecl(tree: Ast, node: Node.Index) full.ContainerDecl { |
| 1694 | assert(tree.nodes.items(.tag)[node] == .container_decl or | 1702 | assert(tree.nodes.items(.tag)[node] == .container_decl or |
| 1695 | tree.nodes.items(.tag)[node] == .container_decl_trailing); | 1703 | tree.nodes.items(.tag)[node] == .container_decl_trailing); |
| 1696 | const data = tree.nodes.items(.data)[node]; | 1704 | const data = tree.nodes.items(.data)[node]; |
| 1697 | return tree.fullContainerDecl(.{ | 1705 | return tree.fullContainerDeclComponents(.{ |
| 1698 | .main_token = tree.nodes.items(.main_token)[node], | 1706 | .main_token = tree.nodes.items(.main_token)[node], |
| 1699 | .enum_token = null, | 1707 | .enum_token = null, |
| 1700 | .members = tree.extra_data[data.lhs..data.rhs], | 1708 | .members = tree.extra_data[data.lhs..data.rhs], |
| ... | @@ -1707,7 +1715,7 @@ pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl { | ... | @@ -1707,7 +1715,7 @@ pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl { |
| 1707 | tree.nodes.items(.tag)[node] == .container_decl_arg_trailing); | 1715 | tree.nodes.items(.tag)[node] == .container_decl_arg_trailing); |
| 1708 | const data = tree.nodes.items(.data)[node]; | 1716 | const data = tree.nodes.items(.data)[node]; |
| 1709 | const members_range = tree.extraData(data.rhs, Node.SubRange); | 1717 | const members_range = tree.extraData(data.rhs, Node.SubRange); |
| 1710 | return tree.fullContainerDecl(.{ | 1718 | return tree.fullContainerDeclComponents(.{ |
| 1711 | .main_token = tree.nodes.items(.main_token)[node], | 1719 | .main_token = tree.nodes.items(.main_token)[node], |
| 1712 | .enum_token = null, | 1720 | .enum_token = null, |
| 1713 | .members = tree.extra_data[members_range.start..members_range.end], | 1721 | .members = tree.extra_data[members_range.start..members_range.end], |
| ... | @@ -1739,7 +1747,7 @@ pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full. | ... | @@ -1739,7 +1747,7 @@ pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full. |
| 1739 | else | 1747 | else |
| 1740 | buffer[0..0]; | 1748 | buffer[0..0]; |
| 1741 | const main_token = tree.nodes.items(.main_token)[node]; | 1749 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1742 | return tree.fullContainerDecl(.{ | 1750 | return tree.fullContainerDeclComponents(.{ |
| 1743 | .main_token = main_token, | 1751 | .main_token = main_token, |
| 1744 | .enum_token = main_token + 2, // union lparen enum | 1752 | .enum_token = main_token + 2, // union lparen enum |
| 1745 | .members = members, | 1753 | .members = members, |
| ... | @@ -1752,7 +1760,7 @@ pub fn taggedUnion(tree: Ast, node: Node.Index) full.ContainerDecl { | ... | @@ -1752,7 +1760,7 @@ pub fn taggedUnion(tree: Ast, node: Node.Index) full.ContainerDecl { |
| 1752 | tree.nodes.items(.tag)[node] == .tagged_union_trailing); | 1760 | tree.nodes.items(.tag)[node] == .tagged_union_trailing); |
| 1753 | const data = tree.nodes.items(.data)[node]; | 1761 | const data = tree.nodes.items(.data)[node]; |
| 1754 | const main_token = tree.nodes.items(.main_token)[node]; | 1762 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1755 | return tree.fullContainerDecl(.{ | 1763 | return tree.fullContainerDeclComponents(.{ |
| 1756 | .main_token = main_token, | 1764 | .main_token = main_token, |
| 1757 | .enum_token = main_token + 2, // union lparen enum | 1765 | .enum_token = main_token + 2, // union lparen enum |
| 1758 | .members = tree.extra_data[data.lhs..data.rhs], | 1766 | .members = tree.extra_data[data.lhs..data.rhs], |
| ... | @@ -1766,7 +1774,7 @@ pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl { | ... | @@ -1766,7 +1774,7 @@ pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl { |
| 1766 | const data = tree.nodes.items(.data)[node]; | 1774 | const data = tree.nodes.items(.data)[node]; |
| 1767 | const members_range = tree.extraData(data.rhs, Node.SubRange); | 1775 | const members_range = tree.extraData(data.rhs, Node.SubRange); |
| 1768 | const main_token = tree.nodes.items(.main_token)[node]; | 1776 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1769 | return tree.fullContainerDecl(.{ | 1777 | return tree.fullContainerDeclComponents(.{ |
| 1770 | .main_token = main_token, | 1778 | .main_token = main_token, |
| 1771 | .enum_token = main_token + 2, // union lparen enum | 1779 | .enum_token = main_token + 2, // union lparen enum |
| 1772 | .members = tree.extra_data[members_range.start..members_range.end], | 1780 | .members = tree.extra_data[members_range.start..members_range.end], |
| ... | @@ -1777,7 +1785,7 @@ pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl { | ... | @@ -1777,7 +1785,7 @@ pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl { |
| 1777 | pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase { | 1785 | pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase { |
| 1778 | const data = &tree.nodes.items(.data)[node]; | 1786 | const data = &tree.nodes.items(.data)[node]; |
| 1779 | const values: *[1]Node.Index = &data.lhs; | 1787 | const values: *[1]Node.Index = &data.lhs; |
| 1780 | return tree.fullSwitchCase(.{ | 1788 | return tree.fullSwitchCaseComponents(.{ |
| 1781 | .values = if (data.lhs == 0) values[0..0] else values[0..1], | 1789 | .values = if (data.lhs == 0) values[0..0] else values[0..1], |
| 1782 | .arrow_token = tree.nodes.items(.main_token)[node], | 1790 | .arrow_token = tree.nodes.items(.main_token)[node], |
| 1783 | .target_expr = data.rhs, | 1791 | .target_expr = data.rhs, |
| ... | @@ -1787,7 +1795,7 @@ pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase { | ... | @@ -1787,7 +1795,7 @@ pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase { |
| 1787 | pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase { | 1795 | pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase { |
| 1788 | const data = tree.nodes.items(.data)[node]; | 1796 | const data = tree.nodes.items(.data)[node]; |
| 1789 | const extra = tree.extraData(data.lhs, Node.SubRange); | 1797 | const extra = tree.extraData(data.lhs, Node.SubRange); |
| 1790 | return tree.fullSwitchCase(.{ | 1798 | return tree.fullSwitchCaseComponents(.{ |
| 1791 | .values = tree.extra_data[extra.start..extra.end], | 1799 | .values = tree.extra_data[extra.start..extra.end], |
| 1792 | .arrow_token = tree.nodes.items(.main_token)[node], | 1800 | .arrow_token = tree.nodes.items(.main_token)[node], |
| 1793 | .target_expr = data.rhs, | 1801 | .target_expr = data.rhs, |
| ... | @@ -1796,7 +1804,7 @@ pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase { | ... | @@ -1796,7 +1804,7 @@ pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase { |
| 1796 | 1804 | ||
| 1797 | pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { | 1805 | pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { |
| 1798 | const data = tree.nodes.items(.data)[node]; | 1806 | const data = tree.nodes.items(.data)[node]; |
| 1799 | return tree.fullAsm(.{ | 1807 | return tree.fullAsmComponents(.{ |
| 1800 | .asm_token = tree.nodes.items(.main_token)[node], | 1808 | .asm_token = tree.nodes.items(.main_token)[node], |
| 1801 | .template = data.lhs, | 1809 | .template = data.lhs, |
| 1802 | .items = &.{}, | 1810 | .items = &.{}, |
| ... | @@ -1807,7 +1815,7 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { | ... | @@ -1807,7 +1815,7 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { |
| 1807 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { | 1815 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { |
| 1808 | const data = tree.nodes.items(.data)[node]; | 1816 | const data = tree.nodes.items(.data)[node]; |
| 1809 | const extra = tree.extraData(data.rhs, Node.Asm); | 1817 | const extra = tree.extraData(data.rhs, Node.Asm); |
| 1810 | return tree.fullAsm(.{ | 1818 | return tree.fullAsmComponents(.{ |
| 1811 | .asm_token = tree.nodes.items(.main_token)[node], | 1819 | .asm_token = tree.nodes.items(.main_token)[node], |
| 1812 | .template = data.lhs, | 1820 | .template = data.lhs, |
| 1813 | .items = tree.extra_data[extra.items_start..extra.items_end], | 1821 | .items = tree.extra_data[extra.items_start..extra.items_end], |
| ... | @@ -1817,7 +1825,7 @@ pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { | ... | @@ -1817,7 +1825,7 @@ pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { |
| 1817 | 1825 | ||
| 1818 | pub fn whileSimple(tree: Ast, node: Node.Index) full.While { | 1826 | pub fn whileSimple(tree: Ast, node: Node.Index) full.While { |
| 1819 | const data = tree.nodes.items(.data)[node]; | 1827 | const data = tree.nodes.items(.data)[node]; |
| 1820 | return tree.fullWhile(.{ | 1828 | return tree.fullWhileComponents(.{ |
| 1821 | .while_token = tree.nodes.items(.main_token)[node], | 1829 | .while_token = tree.nodes.items(.main_token)[node], |
| 1822 | .cond_expr = data.lhs, | 1830 | .cond_expr = data.lhs, |
| 1823 | .cont_expr = 0, | 1831 | .cont_expr = 0, |
| ... | @@ -1829,7 +1837,7 @@ pub fn whileSimple(tree: Ast, node: Node.Index) full.While { | ... | @@ -1829,7 +1837,7 @@ pub fn whileSimple(tree: Ast, node: Node.Index) full.While { |
| 1829 | pub fn whileCont(tree: Ast, node: Node.Index) full.While { | 1837 | pub fn whileCont(tree: Ast, node: Node.Index) full.While { |
| 1830 | const data = tree.nodes.items(.data)[node]; | 1838 | const data = tree.nodes.items(.data)[node]; |
| 1831 | const extra = tree.extraData(data.rhs, Node.WhileCont); | 1839 | const extra = tree.extraData(data.rhs, Node.WhileCont); |
| 1832 | return tree.fullWhile(.{ | 1840 | return tree.fullWhileComponents(.{ |
| 1833 | .while_token = tree.nodes.items(.main_token)[node], | 1841 | .while_token = tree.nodes.items(.main_token)[node], |
| 1834 | .cond_expr = data.lhs, | 1842 | .cond_expr = data.lhs, |
| 1835 | .cont_expr = extra.cont_expr, | 1843 | .cont_expr = extra.cont_expr, |
| ... | @@ -1841,7 +1849,7 @@ pub fn whileCont(tree: Ast, node: Node.Index) full.While { | ... | @@ -1841,7 +1849,7 @@ pub fn whileCont(tree: Ast, node: Node.Index) full.While { |
| 1841 | pub fn whileFull(tree: Ast, node: Node.Index) full.While { | 1849 | pub fn whileFull(tree: Ast, node: Node.Index) full.While { |
| 1842 | const data = tree.nodes.items(.data)[node]; | 1850 | const data = tree.nodes.items(.data)[node]; |
| 1843 | const extra = tree.extraData(data.rhs, Node.While); | 1851 | const extra = tree.extraData(data.rhs, Node.While); |
| 1844 | return tree.fullWhile(.{ | 1852 | return tree.fullWhileComponents(.{ |
| 1845 | .while_token = tree.nodes.items(.main_token)[node], | 1853 | .while_token = tree.nodes.items(.main_token)[node], |
| 1846 | .cond_expr = data.lhs, | 1854 | .cond_expr = data.lhs, |
| 1847 | .cont_expr = extra.cont_expr, | 1855 | .cont_expr = extra.cont_expr, |
| ... | @@ -1852,7 +1860,7 @@ pub fn whileFull(tree: Ast, node: Node.Index) full.While { | ... | @@ -1852,7 +1860,7 @@ pub fn whileFull(tree: Ast, node: Node.Index) full.While { |
| 1852 | 1860 | ||
| 1853 | pub fn forSimple(tree: Ast, node: Node.Index) full.While { | 1861 | pub fn forSimple(tree: Ast, node: Node.Index) full.While { |
| 1854 | const data = tree.nodes.items(.data)[node]; | 1862 | const data = tree.nodes.items(.data)[node]; |
| 1855 | return tree.fullWhile(.{ | 1863 | return tree.fullWhileComponents(.{ |
| 1856 | .while_token = tree.nodes.items(.main_token)[node], | 1864 | .while_token = tree.nodes.items(.main_token)[node], |
| 1857 | .cond_expr = data.lhs, | 1865 | .cond_expr = data.lhs, |
| 1858 | .cont_expr = 0, | 1866 | .cont_expr = 0, |
| ... | @@ -1864,7 +1872,7 @@ pub fn forSimple(tree: Ast, node: Node.Index) full.While { | ... | @@ -1864,7 +1872,7 @@ pub fn forSimple(tree: Ast, node: Node.Index) full.While { |
| 1864 | pub fn forFull(tree: Ast, node: Node.Index) full.While { | 1872 | pub fn forFull(tree: Ast, node: Node.Index) full.While { |
| 1865 | const data = tree.nodes.items(.data)[node]; | 1873 | const data = tree.nodes.items(.data)[node]; |
| 1866 | const extra = tree.extraData(data.rhs, Node.If); | 1874 | const extra = tree.extraData(data.rhs, Node.If); |
| 1867 | return tree.fullWhile(.{ | 1875 | return tree.fullWhileComponents(.{ |
| 1868 | .while_token = tree.nodes.items(.main_token)[node], | 1876 | .while_token = tree.nodes.items(.main_token)[node], |
| 1869 | .cond_expr = data.lhs, | 1877 | .cond_expr = data.lhs, |
| 1870 | .cont_expr = 0, | 1878 | .cont_expr = 0, |
| ... | @@ -1877,7 +1885,7 @@ pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call { | ... | @@ -1877,7 +1885,7 @@ pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call { |
| 1877 | const data = tree.nodes.items(.data)[node]; | 1885 | const data = tree.nodes.items(.data)[node]; |
| 1878 | buffer.* = .{data.rhs}; | 1886 | buffer.* = .{data.rhs}; |
| 1879 | const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0]; | 1887 | const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0]; |
| 1880 | return tree.fullCall(.{ | 1888 | return tree.fullCallComponents(.{ |
| 1881 | .lparen = tree.nodes.items(.main_token)[node], | 1889 | .lparen = tree.nodes.items(.main_token)[node], |
| 1882 | .fn_expr = data.lhs, | 1890 | .fn_expr = data.lhs, |
| 1883 | .params = params, | 1891 | .params = params, |
| ... | @@ -1887,14 +1895,14 @@ pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call { | ... | @@ -1887,14 +1895,14 @@ pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call { |
| 1887 | pub fn callFull(tree: Ast, node: Node.Index) full.Call { | 1895 | pub fn callFull(tree: Ast, node: Node.Index) full.Call { |
| 1888 | const data = tree.nodes.items(.data)[node]; | 1896 | const data = tree.nodes.items(.data)[node]; |
| 1889 | const extra = tree.extraData(data.rhs, Node.SubRange); | 1897 | const extra = tree.extraData(data.rhs, Node.SubRange); |
| 1890 | return tree.fullCall(.{ | 1898 | return tree.fullCallComponents(.{ |
| 1891 | .lparen = tree.nodes.items(.main_token)[node], | 1899 | .lparen = tree.nodes.items(.main_token)[node], |
| 1892 | .fn_expr = data.lhs, | 1900 | .fn_expr = data.lhs, |
| 1893 | .params = tree.extra_data[extra.start..extra.end], | 1901 | .params = tree.extra_data[extra.start..extra.end], |
| 1894 | }); | 1902 | }); |
| 1895 | } | 1903 | } |
| 1896 | 1904 | ||
| 1897 | fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl { | 1905 | fn fullVarDeclComponents(tree: Ast, info: full.VarDecl.Components) full.VarDecl { |
| 1898 | const token_tags = tree.tokens.items(.tag); | 1906 | const token_tags = tree.tokens.items(.tag); |
| 1899 | var result: full.VarDecl = .{ | 1907 | var result: full.VarDecl = .{ |
| 1900 | .ast = info, | 1908 | .ast = info, |
| ... | @@ -1919,7 +1927,7 @@ fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl { | ... | @@ -1919,7 +1927,7 @@ fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl { |
| 1919 | return result; | 1927 | return result; |
| 1920 | } | 1928 | } |
| 1921 | 1929 | ||
| 1922 | fn fullIf(tree: Ast, info: full.If.Components) full.If { | 1930 | fn fullIfComponents(tree: Ast, info: full.If.Components) full.If { |
| 1923 | const token_tags = tree.tokens.items(.tag); | 1931 | const token_tags = tree.tokens.items(.tag); |
| 1924 | var result: full.If = .{ | 1932 | var result: full.If = .{ |
| 1925 | .ast = info, | 1933 | .ast = info, |
| ... | @@ -1944,7 +1952,7 @@ fn fullIf(tree: Ast, info: full.If.Components) full.If { | ... | @@ -1944,7 +1952,7 @@ fn fullIf(tree: Ast, info: full.If.Components) full.If { |
| 1944 | return result; | 1952 | return result; |
| 1945 | } | 1953 | } |
| 1946 | 1954 | ||
| 1947 | fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.ContainerField { | 1955 | fn fullContainerFieldComponents(tree: Ast, info: full.ContainerField.Components) full.ContainerField { |
| 1948 | const token_tags = tree.tokens.items(.tag); | 1956 | const token_tags = tree.tokens.items(.tag); |
| 1949 | var result: full.ContainerField = .{ | 1957 | var result: full.ContainerField = .{ |
| 1950 | .ast = info, | 1958 | .ast = info, |
| ... | @@ -1962,7 +1970,7 @@ fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.Cont | ... | @@ -1962,7 +1970,7 @@ fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.Cont |
| 1962 | return result; | 1970 | return result; |
| 1963 | } | 1971 | } |
| 1964 | 1972 | ||
| 1965 | fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto { | 1973 | fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto { |
| 1966 | const token_tags = tree.tokens.items(.tag); | 1974 | const token_tags = tree.tokens.items(.tag); |
| 1967 | var result: full.FnProto = .{ | 1975 | var result: full.FnProto = .{ |
| 1968 | .ast = info, | 1976 | .ast = info, |
| ... | @@ -1998,15 +2006,7 @@ fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto { | ... | @@ -1998,15 +2006,7 @@ fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto { |
| 1998 | return result; | 2006 | return result; |
| 1999 | } | 2007 | } |
| 2000 | 2008 | ||
| 2001 | fn fullStructInit(tree: Ast, info: full.StructInit.Components) full.StructInit { | 2009 | fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType { |
| 2002 | _ = tree; | ||
| 2003 | var result: full.StructInit = .{ | ||
| 2004 | .ast = info, | ||
| 2005 | }; | ||
| 2006 | return result; | ||
| 2007 | } | ||
| 2008 | |||
| 2009 | fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType { | ||
| 2010 | const token_tags = tree.tokens.items(.tag); | 2010 | const token_tags = tree.tokens.items(.tag); |
| 2011 | const Size = std.builtin.Type.Pointer.Size; | 2011 | const Size = std.builtin.Type.Pointer.Size; |
| 2012 | const size: Size = switch (token_tags[info.main_token]) { | 2012 | const size: Size = switch (token_tags[info.main_token]) { |
| ... | @@ -2053,7 +2053,7 @@ fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType { | ... | @@ -2053,7 +2053,7 @@ fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType { |
| 2053 | return result; | 2053 | return result; |
| 2054 | } | 2054 | } |
| 2055 | 2055 | ||
| 2056 | fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.ContainerDecl { | 2056 | fn fullContainerDeclComponents(tree: Ast, info: full.ContainerDecl.Components) full.ContainerDecl { |
| 2057 | const token_tags = tree.tokens.items(.tag); | 2057 | const token_tags = tree.tokens.items(.tag); |
| 2058 | var result: full.ContainerDecl = .{ | 2058 | var result: full.ContainerDecl = .{ |
| 2059 | .ast = info, | 2059 | .ast = info, |
| ... | @@ -2069,7 +2069,7 @@ fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.Contai | ... | @@ -2069,7 +2069,7 @@ fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.Contai |
| 2069 | return result; | 2069 | return result; |
| 2070 | } | 2070 | } |
| 2071 | 2071 | ||
| 2072 | fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components, node: Node.Index) full.SwitchCase { | 2072 | fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: Node.Index) full.SwitchCase { |
| 2073 | const token_tags = tree.tokens.items(.tag); | 2073 | const token_tags = tree.tokens.items(.tag); |
| 2074 | const node_tags = tree.nodes.items(.tag); | 2074 | const node_tags = tree.nodes.items(.tag); |
| 2075 | var result: full.SwitchCase = .{ | 2075 | var result: full.SwitchCase = .{ |
| ... | @@ -2087,7 +2087,7 @@ fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components, node: Node.Index) | ... | @@ -2087,7 +2087,7 @@ fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components, node: Node.Index) |
| 2087 | return result; | 2087 | return result; |
| 2088 | } | 2088 | } |
| 2089 | 2089 | ||
| 2090 | fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm { | 2090 | fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { |
| 2091 | const token_tags = tree.tokens.items(.tag); | 2091 | const token_tags = tree.tokens.items(.tag); |
| 2092 | const node_tags = tree.nodes.items(.tag); | 2092 | const node_tags = tree.nodes.items(.tag); |
| 2093 | var result: full.Asm = .{ | 2093 | var result: full.Asm = .{ |
| ... | @@ -2150,7 +2150,7 @@ fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm { | ... | @@ -2150,7 +2150,7 @@ fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm { |
| 2150 | return result; | 2150 | return result; |
| 2151 | } | 2151 | } |
| 2152 | 2152 | ||
| 2153 | fn fullWhile(tree: Ast, info: full.While.Components) full.While { | 2153 | fn fullWhileComponents(tree: Ast, info: full.While.Components) full.While { |
| 2154 | const token_tags = tree.tokens.items(.tag); | 2154 | const token_tags = tree.tokens.items(.tag); |
| 2155 | var result: full.While = .{ | 2155 | var result: full.While = .{ |
| 2156 | .ast = info, | 2156 | .ast = info, |
| ... | @@ -2185,7 +2185,7 @@ fn fullWhile(tree: Ast, info: full.While.Components) full.While { | ... | @@ -2185,7 +2185,7 @@ fn fullWhile(tree: Ast, info: full.While.Components) full.While { |
| 2185 | return result; | 2185 | return result; |
| 2186 | } | 2186 | } |
| 2187 | 2187 | ||
| 2188 | fn fullCall(tree: Ast, info: full.Call.Components) full.Call { | 2188 | fn fullCallComponents(tree: Ast, info: full.Call.Components) full.Call { |
| 2189 | const token_tags = tree.tokens.items(.tag); | 2189 | const token_tags = tree.tokens.items(.tag); |
| 2190 | var result: full.Call = .{ | 2190 | var result: full.Call = .{ |
| 2191 | .ast = info, | 2191 | .ast = info, |
| ... | @@ -2198,6 +2198,139 @@ fn fullCall(tree: Ast, info: full.Call.Components) full.Call { | ... | @@ -2198,6 +2198,139 @@ fn fullCall(tree: Ast, info: full.Call.Components) full.Call { |
| 2198 | return result; | 2198 | return result; |
| 2199 | } | 2199 | } |
| 2200 | 2200 | ||
| 2201 | pub fn fullVarDecl(tree: Ast, node: Node.Index) ?full.VarDecl { | ||
| 2202 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2203 | .global_var_decl => tree.globalVarDecl(node), | ||
| 2204 | .local_var_decl => tree.localVarDecl(node), | ||
| 2205 | .aligned_var_decl => tree.alignedVarDecl(node), | ||
| 2206 | .simple_var_decl => tree.simpleVarDecl(node), | ||
| 2207 | else => null, | ||
| 2208 | }; | ||
| 2209 | } | ||
| 2210 | |||
| 2211 | pub fn fullIf(tree: Ast, node: Node.Index) ?full.If { | ||
| 2212 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2213 | .if_simple => tree.ifSimple(node), | ||
| 2214 | .@"if" => tree.ifFull(node), | ||
| 2215 | else => null, | ||
| 2216 | }; | ||
| 2217 | } | ||
| 2218 | |||
| 2219 | pub fn fullWhile(tree: Ast, node: Node.Index) ?full.While { | ||
| 2220 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2221 | .while_simple => tree.whileSimple(node), | ||
| 2222 | .while_cont => tree.whileCont(node), | ||
| 2223 | .@"while" => tree.whileFull(node), | ||
| 2224 | .for_simple => tree.forSimple(node), | ||
| 2225 | .@"for" => tree.forFull(node), | ||
| 2226 | else => null, | ||
| 2227 | }; | ||
| 2228 | } | ||
| 2229 | |||
| 2230 | pub fn fullContainerField(tree: Ast, node: Node.Index) ?full.ContainerField { | ||
| 2231 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2232 | .container_field_init => tree.containerFieldInit(node), | ||
| 2233 | .container_field_align => tree.containerFieldAlign(node), | ||
| 2234 | .container_field => tree.containerField(node), | ||
| 2235 | else => null, | ||
| 2236 | }; | ||
| 2237 | } | ||
| 2238 | |||
| 2239 | pub fn fullFnProto(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.FnProto { | ||
| 2240 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2241 | .fn_proto => tree.fnProto(node), | ||
| 2242 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2243 | .fn_proto_one => tree.fnProtoOne(buffer, node), | ||
| 2244 | .fn_proto_simple => tree.fnProtoSimple(buffer, node), | ||
| 2245 | .fn_decl => tree.fullFnProto(buffer, tree.nodes.items(.data)[node].lhs), | ||
| 2246 | else => null, | ||
| 2247 | }; | ||
| 2248 | } | ||
| 2249 | |||
| 2250 | pub fn fullStructInit(tree: Ast, buffer: *[2]Ast.Node.Index, node: Node.Index) ?full.StructInit { | ||
| 2251 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2252 | .struct_init_one, .struct_init_one_comma => tree.structInitOne(buffer[0..1], node), | ||
| 2253 | .struct_init_dot_two, .struct_init_dot_two_comma => tree.structInitDotTwo(buffer, node), | ||
| 2254 | .struct_init_dot, .struct_init_dot_comma => tree.structInitDot(node), | ||
| 2255 | .struct_init, .struct_init_comma => tree.structInit(node), | ||
| 2256 | else => null, | ||
| 2257 | }; | ||
| 2258 | } | ||
| 2259 | |||
| 2260 | pub fn fullArrayInit(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) ?full.ArrayInit { | ||
| 2261 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2262 | .array_init_one, .array_init_one_comma => tree.arrayInitOne(buffer[0..1], node), | ||
| 2263 | .array_init_dot_two, .array_init_dot_two_comma => tree.arrayInitDotTwo(buffer, node), | ||
| 2264 | .array_init_dot, .array_init_dot_comma => tree.arrayInitDot(node), | ||
| 2265 | .array_init, .array_init_comma => tree.arrayInit(node), | ||
| 2266 | else => null, | ||
| 2267 | }; | ||
| 2268 | } | ||
| 2269 | |||
| 2270 | pub fn fullArrayType(tree: Ast, node: Node.Index) ?full.ArrayType { | ||
| 2271 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2272 | .array_type => tree.arrayType(node), | ||
| 2273 | .array_type_sentinel => tree.arrayTypeSentinel(node), | ||
| 2274 | else => null, | ||
| 2275 | }; | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | pub fn fullPtrType(tree: Ast, node: Node.Index) ?full.PtrType { | ||
| 2279 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2280 | .ptr_type_aligned => tree.ptrTypeAligned(node), | ||
| 2281 | .ptr_type_sentinel => tree.ptrTypeSentinel(node), | ||
| 2282 | .ptr_type => tree.ptrType(node), | ||
| 2283 | .ptr_type_bit_range => tree.ptrTypeBitRange(node), | ||
| 2284 | else => null, | ||
| 2285 | }; | ||
| 2286 | } | ||
| 2287 | |||
| 2288 | pub fn fullSlice(tree: Ast, node: Node.Index) ?full.Slice { | ||
| 2289 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2290 | .slice_open => tree.sliceOpen(node), | ||
| 2291 | .slice => tree.slice(node), | ||
| 2292 | .slice_sentinel => tree.sliceSentinel(node), | ||
| 2293 | else => null, | ||
| 2294 | }; | ||
| 2295 | } | ||
| 2296 | |||
| 2297 | pub fn fullContainerDecl(tree: Ast, buffer: *[2]Ast.Node.Index, node: Node.Index) ?full.ContainerDecl { | ||
| 2298 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2299 | .root => tree.containerDeclRoot(), | ||
| 2300 | .container_decl, .container_decl_trailing => tree.containerDecl(node), | ||
| 2301 | .container_decl_arg, .container_decl_arg_trailing => tree.containerDeclArg(node), | ||
| 2302 | .container_decl_two, .container_decl_two_trailing => tree.containerDeclTwo(buffer, node), | ||
| 2303 | .tagged_union, .tagged_union_trailing => tree.taggedUnion(node), | ||
| 2304 | .tagged_union_enum_tag, .tagged_union_enum_tag_trailing => tree.taggedUnionEnumTag(node), | ||
| 2305 | .tagged_union_two, .tagged_union_two_trailing => tree.taggedUnionTwo(buffer, node), | ||
| 2306 | else => null, | ||
| 2307 | }; | ||
| 2308 | } | ||
| 2309 | |||
| 2310 | pub fn fullSwitchCase(tree: Ast, node: Node.Index) ?full.SwitchCase { | ||
| 2311 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2312 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(node), | ||
| 2313 | .switch_case, .switch_case_inline => tree.switchCase(node), | ||
| 2314 | else => null, | ||
| 2315 | }; | ||
| 2316 | } | ||
| 2317 | |||
| 2318 | pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { | ||
| 2319 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2320 | .asm_simple => tree.asmSimple(node), | ||
| 2321 | .@"asm" => tree.asmFull(node), | ||
| 2322 | else => null, | ||
| 2323 | }; | ||
| 2324 | } | ||
| 2325 | |||
| 2326 | pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { | ||
| 2327 | return switch (tree.nodes.items(.tag)[node]) { | ||
| 2328 | .call, .call_comma, .async_call, .async_call_comma => tree.callFull(node), | ||
| 2329 | .call_one, .call_one_comma, .async_call_one, .async_call_one_comma => tree.callOne(buffer, node), | ||
| 2330 | else => null, | ||
| 2331 | }; | ||
| 2332 | } | ||
| 2333 | |||
| 2201 | /// Fully assembled AST node information. | 2334 | /// Fully assembled AST node information. |
| 2202 | pub const full = struct { | 2335 | pub const full = struct { |
| 2203 | pub const VarDecl = struct { | 2336 | pub const VarDecl = struct { |
lib/std/zig/render.zig+84-96| ... | @@ -42,13 +42,8 @@ fn renderMembers(gpa: Allocator, ais: *Ais, tree: Ast, members: []const Ast.Node | ... | @@ -42,13 +42,8 @@ fn renderMembers(gpa: Allocator, ais: *Ais, tree: Ast, members: []const Ast.Node |
| 42 | if (members.len == 0) return; | 42 | if (members.len == 0) return; |
| 43 | var is_tuple = true; | 43 | var is_tuple = true; |
| 44 | for (members) |member| { | 44 | for (members) |member| { |
| 45 | const tuple_like = switch (tree.nodes.items(.tag)[member]) { | 45 | const container_field = tree.fullContainerField(member) orelse continue; |
| 46 | .container_field_init => tree.containerFieldInit(member).ast.tuple_like, | 46 | if (!container_field.ast.tuple_like) { |
| 47 | .container_field_align => tree.containerFieldAlign(member).ast.tuple_like, | ||
| 48 | .container_field => tree.containerField(member).ast.tuple_like, | ||
| 49 | else => continue, | ||
| 50 | }; | ||
| 51 | if (!tuple_like) { | ||
| 52 | is_tuple = false; | 47 | is_tuple = false; |
| 53 | break; | 48 | break; |
| 54 | } | 49 | } |
| ... | @@ -164,10 +159,11 @@ fn renderMember( | ... | @@ -164,10 +159,11 @@ fn renderMember( |
| 164 | return renderToken(ais, tree, tree.lastToken(expr) + 1, space); // ; | 159 | return renderToken(ais, tree, tree.lastToken(expr) + 1, space); // ; |
| 165 | }, | 160 | }, |
| 166 | 161 | ||
| 167 | .global_var_decl => return renderVarDecl(gpa, ais, tree, tree.globalVarDecl(decl)), | 162 | .global_var_decl, |
| 168 | .local_var_decl => return renderVarDecl(gpa, ais, tree, tree.localVarDecl(decl)), | 163 | .local_var_decl, |
| 169 | .simple_var_decl => return renderVarDecl(gpa, ais, tree, tree.simpleVarDecl(decl)), | 164 | .simple_var_decl, |
| 170 | .aligned_var_decl => return renderVarDecl(gpa, ais, tree, tree.alignedVarDecl(decl)), | 165 | .aligned_var_decl, |
| 166 | => return renderVarDecl(gpa, ais, tree, tree.fullVarDecl(decl).?), | ||
| 171 | 167 | ||
| 172 | .test_decl => { | 168 | .test_decl => { |
| 173 | const test_token = main_tokens[decl]; | 169 | const test_token = main_tokens[decl]; |
| ... | @@ -181,9 +177,11 @@ fn renderMember( | ... | @@ -181,9 +177,11 @@ fn renderMember( |
| 181 | try renderExpression(gpa, ais, tree, datas[decl].rhs, space); | 177 | try renderExpression(gpa, ais, tree, datas[decl].rhs, space); |
| 182 | }, | 178 | }, |
| 183 | 179 | ||
| 184 | .container_field_init => return renderContainerField(gpa, ais, tree, tree.containerFieldInit(decl), is_tuple, space), | 180 | .container_field_init, |
| 185 | .container_field_align => return renderContainerField(gpa, ais, tree, tree.containerFieldAlign(decl), is_tuple, space), | 181 | .container_field_align, |
| 186 | .container_field => return renderContainerField(gpa, ais, tree, tree.containerField(decl), is_tuple, space), | 182 | .container_field, |
| 183 | => return renderContainerField(gpa, ais, tree, tree.fullContainerField(decl).?, is_tuple, space), | ||
| 184 | |||
| 187 | .@"comptime" => return renderExpression(gpa, ais, tree, decl, space), | 185 | .@"comptime" => return renderExpression(gpa, ais, tree, decl, space), |
| 188 | 186 | ||
| 189 | .root => unreachable, | 187 | .root => unreachable, |
| ... | @@ -437,54 +435,54 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, | ... | @@ -437,54 +435,54 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 437 | return renderExpression(gpa, ais, tree, datas[node].lhs, space); | 435 | return renderExpression(gpa, ais, tree, datas[node].lhs, space); |
| 438 | }, | 436 | }, |
| 439 | 437 | ||
| 440 | .array_type => return renderArrayType(gpa, ais, tree, tree.arrayType(node), space), | 438 | .array_type, |
| 441 | .array_type_sentinel => return renderArrayType(gpa, ais, tree, tree.arrayTypeSentinel(node), space), | 439 | .array_type_sentinel, |
| 440 | => return renderArrayType(gpa, ais, tree, tree.fullArrayType(node).?, space), | ||
| 442 | 441 | ||
| 443 | .ptr_type_aligned => return renderPtrType(gpa, ais, tree, tree.ptrTypeAligned(node), space), | 442 | .ptr_type_aligned, |
| 444 | .ptr_type_sentinel => return renderPtrType(gpa, ais, tree, tree.ptrTypeSentinel(node), space), | 443 | .ptr_type_sentinel, |
| 445 | .ptr_type => return renderPtrType(gpa, ais, tree, tree.ptrType(node), space), | 444 | .ptr_type, |
| 446 | .ptr_type_bit_range => return renderPtrType(gpa, ais, tree, tree.ptrTypeBitRange(node), space), | 445 | .ptr_type_bit_range, |
| 446 | => return renderPtrType(gpa, ais, tree, tree.fullPtrType(node).?, space), | ||
| 447 | 447 | ||
| 448 | .array_init_one, .array_init_one_comma => { | 448 | .array_init_one, |
| 449 | var elements: [1]Ast.Node.Index = undefined; | 449 | .array_init_one_comma, |
| 450 | return renderArrayInit(gpa, ais, tree, tree.arrayInitOne(&elements, node), space); | 450 | .array_init_dot_two, |
| 451 | }, | 451 | .array_init_dot_two_comma, |
| 452 | .array_init_dot_two, .array_init_dot_two_comma => { | ||
| 453 | var elements: [2]Ast.Node.Index = undefined; | ||
| 454 | return renderArrayInit(gpa, ais, tree, tree.arrayInitDotTwo(&elements, node), space); | ||
| 455 | }, | ||
| 456 | .array_init_dot, | 452 | .array_init_dot, |
| 457 | .array_init_dot_comma, | 453 | .array_init_dot_comma, |
| 458 | => return renderArrayInit(gpa, ais, tree, tree.arrayInitDot(node), space), | ||
| 459 | .array_init, | 454 | .array_init, |
| 460 | .array_init_comma, | 455 | .array_init_comma, |
| 461 | => return renderArrayInit(gpa, ais, tree, tree.arrayInit(node), space), | 456 | => { |
| 462 | 457 | var elements: [2]Ast.Node.Index = undefined; | |
| 463 | .struct_init_one, .struct_init_one_comma => { | 458 | return renderArrayInit(gpa, ais, tree, tree.fullArrayInit(&elements, node).?, space); |
| 464 | var fields: [1]Ast.Node.Index = undefined; | ||
| 465 | return renderStructInit(gpa, ais, tree, node, tree.structInitOne(&fields, node), space); | ||
| 466 | }, | ||
| 467 | .struct_init_dot_two, .struct_init_dot_two_comma => { | ||
| 468 | var fields: [2]Ast.Node.Index = undefined; | ||
| 469 | return renderStructInit(gpa, ais, tree, node, tree.structInitDotTwo(&fields, node), space); | ||
| 470 | }, | 459 | }, |
| 460 | |||
| 461 | .struct_init_one, | ||
| 462 | .struct_init_one_comma, | ||
| 463 | .struct_init_dot_two, | ||
| 464 | .struct_init_dot_two_comma, | ||
| 471 | .struct_init_dot, | 465 | .struct_init_dot, |
| 472 | .struct_init_dot_comma, | 466 | .struct_init_dot_comma, |
| 473 | => return renderStructInit(gpa, ais, tree, node, tree.structInitDot(node), space), | ||
| 474 | .struct_init, | 467 | .struct_init, |
| 475 | .struct_init_comma, | 468 | .struct_init_comma, |
| 476 | => return renderStructInit(gpa, ais, tree, node, tree.structInit(node), space), | 469 | => { |
| 477 | 470 | var buf: [2]Ast.Node.Index = undefined; | |
| 478 | .call_one, .call_one_comma, .async_call_one, .async_call_one_comma => { | 471 | return renderStructInit(gpa, ais, tree, node, tree.fullStructInit(&buf, node).?, space); |
| 479 | var params: [1]Ast.Node.Index = undefined; | ||
| 480 | return renderCall(gpa, ais, tree, tree.callOne(&params, node), space); | ||
| 481 | }, | 472 | }, |
| 482 | 473 | ||
| 474 | .call_one, | ||
| 475 | .call_one_comma, | ||
| 476 | .async_call_one, | ||
| 477 | .async_call_one_comma, | ||
| 483 | .call, | 478 | .call, |
| 484 | .call_comma, | 479 | .call_comma, |
| 485 | .async_call, | 480 | .async_call, |
| 486 | .async_call_comma, | 481 | .async_call_comma, |
| 487 | => return renderCall(gpa, ais, tree, tree.callFull(node), space), | 482 | => { |
| 483 | var buf: [1]Ast.Node.Index = undefined; | ||
| 484 | return renderCall(gpa, ais, tree, tree.fullCall(&buf, node).?, space); | ||
| 485 | }, | ||
| 488 | 486 | ||
| 489 | .array_access => { | 487 | .array_access => { |
| 490 | const suffix = datas[node]; | 488 | const suffix = datas[node]; |
| ... | @@ -500,9 +498,7 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, | ... | @@ -500,9 +498,7 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 500 | return renderToken(ais, tree, rbracket, space); // ] | 498 | return renderToken(ais, tree, rbracket, space); // ] |
| 501 | }, | 499 | }, |
| 502 | 500 | ||
| 503 | .slice_open => return renderSlice(gpa, ais, tree, node, tree.sliceOpen(node), space), | 501 | .slice_open, .slice, .slice_sentinel => return renderSlice(gpa, ais, tree, node, tree.fullSlice(node).?, space), |
| 504 | .slice => return renderSlice(gpa, ais, tree, node, tree.slice(node), space), | ||
| 505 | .slice_sentinel => return renderSlice(gpa, ais, tree, node, tree.sliceSentinel(node), space), | ||
| 506 | 502 | ||
| 507 | .deref => { | 503 | .deref => { |
| 508 | try renderExpression(gpa, ais, tree, datas[node].lhs, .none); | 504 | try renderExpression(gpa, ais, tree, datas[node].lhs, .none); |
| ... | @@ -566,27 +562,20 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, | ... | @@ -566,27 +562,20 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 566 | 562 | ||
| 567 | .container_decl, | 563 | .container_decl, |
| 568 | .container_decl_trailing, | 564 | .container_decl_trailing, |
| 569 | => return renderContainerDecl(gpa, ais, tree, node, tree.containerDecl(node), space), | ||
| 570 | |||
| 571 | .container_decl_two, .container_decl_two_trailing => { | ||
| 572 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 573 | return renderContainerDecl(gpa, ais, tree, node, tree.containerDeclTwo(&buffer, node), space); | ||
| 574 | }, | ||
| 575 | .container_decl_arg, | 565 | .container_decl_arg, |
| 576 | .container_decl_arg_trailing, | 566 | .container_decl_arg_trailing, |
| 577 | => return renderContainerDecl(gpa, ais, tree, node, tree.containerDeclArg(node), space), | 567 | .container_decl_two, |
| 578 | 568 | .container_decl_two_trailing, | |
| 579 | .tagged_union, | 569 | .tagged_union, |
| 580 | .tagged_union_trailing, | 570 | .tagged_union_trailing, |
| 581 | => return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnion(node), space), | ||
| 582 | |||
| 583 | .tagged_union_two, .tagged_union_two_trailing => { | ||
| 584 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 585 | return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnionTwo(&buffer, node), space); | ||
| 586 | }, | ||
| 587 | .tagged_union_enum_tag, | 571 | .tagged_union_enum_tag, |
| 588 | .tagged_union_enum_tag_trailing, | 572 | .tagged_union_enum_tag_trailing, |
| 589 | => return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnionEnumTag(node), space), | 573 | .tagged_union_two, |
| 574 | .tagged_union_two_trailing, | ||
| 575 | => { | ||
| 576 | var buf: [2]Ast.Node.Index = undefined; | ||
| 577 | return renderContainerDecl(gpa, ais, tree, node, tree.fullContainerDecl(&buf, node).?, space); | ||
| 578 | }, | ||
| 590 | 579 | ||
| 591 | .error_set_decl => { | 580 | .error_set_decl => { |
| 592 | const error_token = main_tokens[node]; | 581 | const error_token = main_tokens[node]; |
| ... | @@ -651,16 +640,14 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, | ... | @@ -651,16 +640,14 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 651 | return renderBuiltinCall(gpa, ais, tree, main_tokens[node], params, space); | 640 | return renderBuiltinCall(gpa, ais, tree, main_tokens[node], params, space); |
| 652 | }, | 641 | }, |
| 653 | 642 | ||
| 654 | .fn_proto_simple => { | 643 | .fn_proto_simple, |
| 655 | var params: [1]Ast.Node.Index = undefined; | 644 | .fn_proto_multi, |
| 656 | return renderFnProto(gpa, ais, tree, tree.fnProtoSimple(&params, node), space); | 645 | .fn_proto_one, |
| 657 | }, | 646 | .fn_proto, |
| 658 | .fn_proto_multi => return renderFnProto(gpa, ais, tree, tree.fnProtoMulti(node), space), | 647 | => { |
| 659 | .fn_proto_one => { | 648 | var buf: [1]Ast.Node.Index = undefined; |
| 660 | var params: [1]Ast.Node.Index = undefined; | 649 | return renderFnProto(gpa, ais, tree, tree.fullFnProto(&buf, node).?, space); |
| 661 | return renderFnProto(gpa, ais, tree, tree.fnProtoOne(&params, node), space); | ||
| 662 | }, | 650 | }, |
| 663 | .fn_proto => return renderFnProto(gpa, ais, tree, tree.fnProto(node), space), | ||
| 664 | 651 | ||
| 665 | .anyframe_type => { | 652 | .anyframe_type => { |
| 666 | const main_token = main_tokens[node]; | 653 | const main_token = main_tokens[node]; |
| ... | @@ -698,20 +685,26 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, | ... | @@ -698,20 +685,26 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 698 | return renderToken(ais, tree, tree.lastToken(node), space); // rbrace | 685 | return renderToken(ais, tree, tree.lastToken(node), space); // rbrace |
| 699 | }, | 686 | }, |
| 700 | 687 | ||
| 701 | .switch_case_one, .switch_case_inline_one => return renderSwitchCase(gpa, ais, tree, tree.switchCaseOne(node), space), | 688 | .switch_case_one, |
| 702 | .switch_case, .switch_case_inline => return renderSwitchCase(gpa, ais, tree, tree.switchCase(node), space), | 689 | .switch_case_inline_one, |
| 690 | .switch_case, | ||
| 691 | .switch_case_inline, | ||
| 692 | => return renderSwitchCase(gpa, ais, tree, tree.fullSwitchCase(node).?, space), | ||
| 703 | 693 | ||
| 704 | .while_simple => return renderWhile(gpa, ais, tree, tree.whileSimple(node), space), | 694 | .while_simple, |
| 705 | .while_cont => return renderWhile(gpa, ais, tree, tree.whileCont(node), space), | 695 | .while_cont, |
| 706 | .@"while" => return renderWhile(gpa, ais, tree, tree.whileFull(node), space), | 696 | .@"while", |
| 707 | .for_simple => return renderWhile(gpa, ais, tree, tree.forSimple(node), space), | 697 | .for_simple, |
| 708 | .@"for" => return renderWhile(gpa, ais, tree, tree.forFull(node), space), | 698 | .@"for", |
| 699 | => return renderWhile(gpa, ais, tree, tree.fullWhile(node).?, space), | ||
| 709 | 700 | ||
| 710 | .if_simple => return renderIf(gpa, ais, tree, tree.ifSimple(node), space), | 701 | .if_simple, |
| 711 | .@"if" => return renderIf(gpa, ais, tree, tree.ifFull(node), space), | 702 | .@"if", |
| 703 | => return renderIf(gpa, ais, tree, tree.fullIf(node).?, space), | ||
| 712 | 704 | ||
| 713 | .asm_simple => return renderAsm(gpa, ais, tree, tree.asmSimple(node), space), | 705 | .asm_simple, |
| 714 | .@"asm" => return renderAsm(gpa, ais, tree, tree.asmFull(node), space), | 706 | .@"asm", |
| 707 | => return renderAsm(gpa, ais, tree, tree.fullAsm(node).?, space), | ||
| 715 | 708 | ||
| 716 | .enum_literal => { | 709 | .enum_literal => { |
| 717 | try renderToken(ais, tree, main_tokens[node] - 1, .none); // . | 710 | try renderToken(ais, tree, main_tokens[node] - 1, .none); // . |
| ... | @@ -1632,10 +1625,11 @@ fn renderBlock( | ... | @@ -1632,10 +1625,11 @@ fn renderBlock( |
| 1632 | for (statements) |stmt, i| { | 1625 | for (statements) |stmt, i| { |
| 1633 | if (i != 0) try renderExtraNewline(ais, tree, stmt); | 1626 | if (i != 0) try renderExtraNewline(ais, tree, stmt); |
| 1634 | switch (node_tags[stmt]) { | 1627 | switch (node_tags[stmt]) { |
| 1635 | .global_var_decl => try renderVarDecl(gpa, ais, tree, tree.globalVarDecl(stmt)), | 1628 | .global_var_decl, |
| 1636 | .local_var_decl => try renderVarDecl(gpa, ais, tree, tree.localVarDecl(stmt)), | 1629 | .local_var_decl, |
| 1637 | .simple_var_decl => try renderVarDecl(gpa, ais, tree, tree.simpleVarDecl(stmt)), | 1630 | .simple_var_decl, |
| 1638 | .aligned_var_decl => try renderVarDecl(gpa, ais, tree, tree.alignedVarDecl(stmt)), | 1631 | .aligned_var_decl, |
| 1632 | => try renderVarDecl(gpa, ais, tree, tree.fullVarDecl(stmt).?), | ||
| 1639 | else => try renderExpression(gpa, ais, tree, stmt, .semicolon), | 1633 | else => try renderExpression(gpa, ais, tree, stmt, .semicolon), |
| 1640 | } | 1634 | } |
| 1641 | } | 1635 | } |
| ... | @@ -1938,7 +1932,6 @@ fn renderContainerDecl( | ... | @@ -1938,7 +1932,6 @@ fn renderContainerDecl( |
| 1938 | space: Space, | 1932 | space: Space, |
| 1939 | ) Error!void { | 1933 | ) Error!void { |
| 1940 | const token_tags = tree.tokens.items(.tag); | 1934 | const token_tags = tree.tokens.items(.tag); |
| 1941 | const node_tags = tree.nodes.items(.tag); | ||
| 1942 | 1935 | ||
| 1943 | if (container_decl.layout_token) |layout_token| { | 1936 | if (container_decl.layout_token) |layout_token| { |
| 1944 | try renderToken(ais, tree, layout_token, .space); | 1937 | try renderToken(ais, tree, layout_token, .space); |
| ... | @@ -1946,13 +1939,8 @@ fn renderContainerDecl( | ... | @@ -1946,13 +1939,8 @@ fn renderContainerDecl( |
| 1946 | 1939 | ||
| 1947 | var is_tuple = token_tags[container_decl.ast.main_token] == .keyword_struct; | 1940 | var is_tuple = token_tags[container_decl.ast.main_token] == .keyword_struct; |
| 1948 | if (is_tuple) for (container_decl.ast.members) |member| { | 1941 | if (is_tuple) for (container_decl.ast.members) |member| { |
| 1949 | const tuple_like = switch (tree.nodes.items(.tag)[member]) { | 1942 | const container_field = tree.fullContainerField(member) orelse continue; |
| 1950 | .container_field_init => tree.containerFieldInit(member).ast.tuple_like, | 1943 | if (!container_field.ast.tuple_like) { |
| 1951 | .container_field_align => tree.containerFieldAlign(member).ast.tuple_like, | ||
| 1952 | .container_field => tree.containerField(member).ast.tuple_like, | ||
| 1953 | else => continue, | ||
| 1954 | }; | ||
| 1955 | if (!tuple_like) { | ||
| 1956 | is_tuple = false; | 1944 | is_tuple = false; |
| 1957 | break; | 1945 | break; |
| 1958 | } | 1946 | } |
| ... | @@ -2018,7 +2006,7 @@ fn renderContainerDecl( | ... | @@ -2018,7 +2006,7 @@ fn renderContainerDecl( |
| 2018 | 2006 | ||
| 2019 | // 4. The container has non-field members. | 2007 | // 4. The container has non-field members. |
| 2020 | for (container_decl.ast.members) |member| { | 2008 | for (container_decl.ast.members) |member| { |
| 2021 | if (!node_tags[member].isContainerField()) break :one_line; | 2009 | if (tree.fullContainerField(member) == null) break :one_line; |
| 2022 | } | 2010 | } |
| 2023 | 2011 | ||
| 2024 | // Print all the declarations on the same line. | 2012 | // Print all the declarations on the same line. |
src/AstGen.zig+104-194| ... | @@ -771,8 +771,9 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -771,8 +771,9 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 771 | 771 | ||
| 772 | .identifier => return identifier(gz, scope, ri, node), | 772 | .identifier => return identifier(gz, scope, ri, node), |
| 773 | 773 | ||
| 774 | .asm_simple => return asmExpr(gz, scope, ri, node, tree.asmSimple(node)), | 774 | .asm_simple, |
| 775 | .@"asm" => return asmExpr(gz, scope, ri, node, tree.asmFull(node)), | 775 | .@"asm", |
| 776 | => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), | ||
| 776 | 777 | ||
| 777 | .string_literal => return stringLiteral(gz, ri, node), | 778 | .string_literal => return stringLiteral(gz, ri, node), |
| 778 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), | 779 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), |
| ... | @@ -797,12 +798,17 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -797,12 +798,17 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 797 | return builtinCall(gz, scope, ri, node, params); | 798 | return builtinCall(gz, scope, ri, node, params); |
| 798 | }, | 799 | }, |
| 799 | 800 | ||
| 800 | .call_one, .call_one_comma, .async_call_one, .async_call_one_comma => { | 801 | .call_one, |
| 801 | var params: [1]Ast.Node.Index = undefined; | 802 | .call_one_comma, |
| 802 | return callExpr(gz, scope, ri, node, tree.callOne(&params, node)); | 803 | .async_call_one, |
| 803 | }, | 804 | .async_call_one_comma, |
| 804 | .call, .call_comma, .async_call, .async_call_comma => { | 805 | .call, |
| 805 | return callExpr(gz, scope, ri, node, tree.callFull(node)); | 806 | .call_comma, |
| 807 | .async_call, | ||
| 808 | .async_call_comma, | ||
| 809 | => { | ||
| 810 | var buf: [1]Ast.Node.Index = undefined; | ||
| 811 | return callExpr(gz, scope, ri, node, tree.fullCall(&buf, node).?); | ||
| 806 | }, | 812 | }, |
| 807 | 813 | ||
| 808 | .unreachable_literal => { | 814 | .unreachable_literal => { |
| ... | @@ -819,15 +825,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -819,15 +825,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 819 | .@"return" => return ret(gz, scope, node), | 825 | .@"return" => return ret(gz, scope, node), |
| 820 | .field_access => return fieldAccess(gz, scope, ri, node), | 826 | .field_access => return fieldAccess(gz, scope, ri, node), |
| 821 | 827 | ||
| 822 | .if_simple => return ifExpr(gz, scope, ri.br(), node, tree.ifSimple(node)), | 828 | .if_simple, |
| 823 | .@"if" => return ifExpr(gz, scope, ri.br(), node, tree.ifFull(node)), | 829 | .@"if", |
| 830 | => return ifExpr(gz, scope, ri.br(), node, tree.fullIf(node).?), | ||
| 824 | 831 | ||
| 825 | .while_simple => return whileExpr(gz, scope, ri.br(), node, tree.whileSimple(node), false), | 832 | .while_simple, |
| 826 | .while_cont => return whileExpr(gz, scope, ri.br(), node, tree.whileCont(node), false), | 833 | .while_cont, |
| 827 | .@"while" => return whileExpr(gz, scope, ri.br(), node, tree.whileFull(node), false), | 834 | .@"while", |
| 835 | => return whileExpr(gz, scope, ri.br(), node, tree.fullWhile(node).?, false), | ||
| 828 | 836 | ||
| 829 | .for_simple => return forExpr(gz, scope, ri.br(), node, tree.forSimple(node), false), | 837 | .for_simple, .@"for" => return forExpr(gz, scope, ri.br(), node, tree.fullWhile(node).?, false), |
| 830 | .@"for" => return forExpr(gz, scope, ri.br(), node, tree.forFull(node), false), | ||
| 831 | 838 | ||
| 832 | .slice_open => { | 839 | .slice_open => { |
| 833 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); | 840 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| ... | @@ -1012,32 +1019,28 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -1012,32 +1019,28 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 1012 | ), | 1019 | ), |
| 1013 | }, | 1020 | }, |
| 1014 | 1021 | ||
| 1015 | .ptr_type_aligned => return ptrType(gz, scope, ri, node, tree.ptrTypeAligned(node)), | 1022 | .ptr_type_aligned, |
| 1016 | .ptr_type_sentinel => return ptrType(gz, scope, ri, node, tree.ptrTypeSentinel(node)), | 1023 | .ptr_type_sentinel, |
| 1017 | .ptr_type => return ptrType(gz, scope, ri, node, tree.ptrType(node)), | 1024 | .ptr_type, |
| 1018 | .ptr_type_bit_range => return ptrType(gz, scope, ri, node, tree.ptrTypeBitRange(node)), | 1025 | .ptr_type_bit_range, |
| 1026 | => return ptrType(gz, scope, ri, node, tree.fullPtrType(node).?), | ||
| 1019 | 1027 | ||
| 1020 | .container_decl, | 1028 | .container_decl, |
| 1021 | .container_decl_trailing, | 1029 | .container_decl_trailing, |
| 1022 | => return containerDecl(gz, scope, ri, node, tree.containerDecl(node)), | ||
| 1023 | .container_decl_two, .container_decl_two_trailing => { | ||
| 1024 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1025 | return containerDecl(gz, scope, ri, node, tree.containerDeclTwo(&buffer, node)); | ||
| 1026 | }, | ||
| 1027 | .container_decl_arg, | 1030 | .container_decl_arg, |
| 1028 | .container_decl_arg_trailing, | 1031 | .container_decl_arg_trailing, |
| 1029 | => return containerDecl(gz, scope, ri, node, tree.containerDeclArg(node)), | 1032 | .container_decl_two, |
| 1030 | 1033 | .container_decl_two_trailing, | |
| 1031 | .tagged_union, | 1034 | .tagged_union, |
| 1032 | .tagged_union_trailing, | 1035 | .tagged_union_trailing, |
| 1033 | => return containerDecl(gz, scope, ri, node, tree.taggedUnion(node)), | ||
| 1034 | .tagged_union_two, .tagged_union_two_trailing => { | ||
| 1035 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1036 | return containerDecl(gz, scope, ri, node, tree.taggedUnionTwo(&buffer, node)); | ||
| 1037 | }, | ||
| 1038 | .tagged_union_enum_tag, | 1036 | .tagged_union_enum_tag, |
| 1039 | .tagged_union_enum_tag_trailing, | 1037 | .tagged_union_enum_tag_trailing, |
| 1040 | => return containerDecl(gz, scope, ri, node, tree.taggedUnionEnumTag(node)), | 1038 | .tagged_union_two, |
| 1039 | .tagged_union_two_trailing, | ||
| 1040 | => { | ||
| 1041 | var buf: [2]Ast.Node.Index = undefined; | ||
| 1042 | return containerDecl(gz, scope, ri, node, tree.fullContainerDecl(&buf, node).?); | ||
| 1043 | }, | ||
| 1041 | 1044 | ||
| 1042 | .@"break" => return breakExpr(gz, scope, node), | 1045 | .@"break" => return breakExpr(gz, scope, node), |
| 1043 | .@"continue" => return continueExpr(gz, scope, node), | 1046 | .@"continue" => return continueExpr(gz, scope, node), |
| ... | @@ -1057,49 +1060,39 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -1057,49 +1060,39 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 1057 | 1060 | ||
| 1058 | .@"try" => return tryExpr(gz, scope, ri, node, node_datas[node].lhs), | 1061 | .@"try" => return tryExpr(gz, scope, ri, node, node_datas[node].lhs), |
| 1059 | 1062 | ||
| 1060 | .array_init_one, .array_init_one_comma => { | 1063 | .array_init_one, |
| 1061 | var elements: [1]Ast.Node.Index = undefined; | 1064 | .array_init_one_comma, |
| 1062 | return arrayInitExpr(gz, scope, ri, node, tree.arrayInitOne(&elements, node)); | 1065 | .array_init_dot_two, |
| 1063 | }, | 1066 | .array_init_dot_two_comma, |
| 1064 | .array_init_dot_two, .array_init_dot_two_comma => { | ||
| 1065 | var elements: [2]Ast.Node.Index = undefined; | ||
| 1066 | return arrayInitExpr(gz, scope, ri, node, tree.arrayInitDotTwo(&elements, node)); | ||
| 1067 | }, | ||
| 1068 | .array_init_dot, | 1067 | .array_init_dot, |
| 1069 | .array_init_dot_comma, | 1068 | .array_init_dot_comma, |
| 1070 | => return arrayInitExpr(gz, scope, ri, node, tree.arrayInitDot(node)), | ||
| 1071 | .array_init, | 1069 | .array_init, |
| 1072 | .array_init_comma, | 1070 | .array_init_comma, |
| 1073 | => return arrayInitExpr(gz, scope, ri, node, tree.arrayInit(node)), | 1071 | => { |
| 1074 | 1072 | var buf: [2]Ast.Node.Index = undefined; | |
| 1075 | .struct_init_one, .struct_init_one_comma => { | 1073 | return arrayInitExpr(gz, scope, ri, node, tree.fullArrayInit(&buf, node).?); |
| 1076 | var fields: [1]Ast.Node.Index = undefined; | ||
| 1077 | return structInitExpr(gz, scope, ri, node, tree.structInitOne(&fields, node)); | ||
| 1078 | }, | ||
| 1079 | .struct_init_dot_two, .struct_init_dot_two_comma => { | ||
| 1080 | var fields: [2]Ast.Node.Index = undefined; | ||
| 1081 | return structInitExpr(gz, scope, ri, node, tree.structInitDotTwo(&fields, node)); | ||
| 1082 | }, | 1074 | }, |
| 1075 | |||
| 1076 | .struct_init_one, | ||
| 1077 | .struct_init_one_comma, | ||
| 1078 | .struct_init_dot_two, | ||
| 1079 | .struct_init_dot_two_comma, | ||
| 1083 | .struct_init_dot, | 1080 | .struct_init_dot, |
| 1084 | .struct_init_dot_comma, | 1081 | .struct_init_dot_comma, |
| 1085 | => return structInitExpr(gz, scope, ri, node, tree.structInitDot(node)), | ||
| 1086 | .struct_init, | 1082 | .struct_init, |
| 1087 | .struct_init_comma, | 1083 | .struct_init_comma, |
| 1088 | => return structInitExpr(gz, scope, ri, node, tree.structInit(node)), | 1084 | => { |
| 1089 | 1085 | var buf: [2]Ast.Node.Index = undefined; | |
| 1090 | .fn_proto_simple => { | 1086 | return structInitExpr(gz, scope, ri, node, tree.fullStructInit(&buf, node).?); |
| 1091 | var params: [1]Ast.Node.Index = undefined; | ||
| 1092 | return fnProtoExpr(gz, scope, ri, node, tree.fnProtoSimple(&params, node)); | ||
| 1093 | }, | ||
| 1094 | .fn_proto_multi => { | ||
| 1095 | return fnProtoExpr(gz, scope, ri, node, tree.fnProtoMulti(node)); | ||
| 1096 | }, | ||
| 1097 | .fn_proto_one => { | ||
| 1098 | var params: [1]Ast.Node.Index = undefined; | ||
| 1099 | return fnProtoExpr(gz, scope, ri, node, tree.fnProtoOne(&params, node)); | ||
| 1100 | }, | 1087 | }, |
| 1101 | .fn_proto => { | 1088 | |
| 1102 | return fnProtoExpr(gz, scope, ri, node, tree.fnProto(node)); | 1089 | .fn_proto_simple, |
| 1090 | .fn_proto_multi, | ||
| 1091 | .fn_proto_one, | ||
| 1092 | .fn_proto, | ||
| 1093 | => { | ||
| 1094 | var buf: [1]Ast.Node.Index = undefined; | ||
| 1095 | return fnProtoExpr(gz, scope, ri, node, tree.fullFnProto(&buf, node).?); | ||
| 1103 | }, | 1096 | }, |
| 1104 | } | 1097 | } |
| 1105 | } | 1098 | } |
| ... | @@ -1374,11 +1367,7 @@ fn arrayInitExpr( | ... | @@ -1374,11 +1367,7 @@ fn arrayInitExpr( |
| 1374 | }; | 1367 | }; |
| 1375 | 1368 | ||
| 1376 | infer: { | 1369 | infer: { |
| 1377 | const array_type: Ast.full.ArrayType = switch (node_tags[array_init.ast.type_expr]) { | 1370 | const array_type: Ast.full.ArrayType = tree.fullArrayType(array_init.ast.type_expr) orelse break :infer; |
| 1378 | .array_type => tree.arrayType(array_init.ast.type_expr), | ||
| 1379 | .array_type_sentinel => tree.arrayTypeSentinel(array_init.ast.type_expr), | ||
| 1380 | else => break :infer, | ||
| 1381 | }; | ||
| 1382 | // This intentionally does not support `@"_"` syntax. | 1371 | // This intentionally does not support `@"_"` syntax. |
| 1383 | if (node_tags[array_type.ast.elem_count] == .identifier and | 1372 | if (node_tags[array_type.ast.elem_count] == .identifier and |
| 1384 | mem.eql(u8, tree.tokenSlice(main_tokens[array_type.ast.elem_count]), "_")) | 1373 | mem.eql(u8, tree.tokenSlice(main_tokens[array_type.ast.elem_count]), "_")) |
| ... | @@ -1606,17 +1595,13 @@ fn structInitExpr( | ... | @@ -1606,17 +1595,13 @@ fn structInitExpr( |
| 1606 | } else array: { | 1595 | } else array: { |
| 1607 | const node_tags = tree.nodes.items(.tag); | 1596 | const node_tags = tree.nodes.items(.tag); |
| 1608 | const main_tokens = tree.nodes.items(.main_token); | 1597 | const main_tokens = tree.nodes.items(.main_token); |
| 1609 | const array_type: Ast.full.ArrayType = switch (node_tags[struct_init.ast.type_expr]) { | 1598 | const array_type: Ast.full.ArrayType = tree.fullArrayType(struct_init.ast.type_expr) orelse { |
| 1610 | .array_type => tree.arrayType(struct_init.ast.type_expr), | 1599 | if (struct_init.ast.fields.len == 0) { |
| 1611 | .array_type_sentinel => tree.arrayTypeSentinel(struct_init.ast.type_expr), | 1600 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1612 | else => { | 1601 | const result = try gz.addUnNode(.struct_init_empty, ty_inst, node); |
| 1613 | if (struct_init.ast.fields.len == 0) { | 1602 | return rvalue(gz, ri, result, node); |
| 1614 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); | 1603 | } |
| 1615 | const result = try gz.addUnNode(.struct_init_empty, ty_inst, node); | 1604 | break :array; |
| 1616 | return rvalue(gz, ri, result, node); | ||
| 1617 | } | ||
| 1618 | break :array; | ||
| 1619 | }, | ||
| 1620 | }; | 1605 | }; |
| 1621 | const is_inferred_array_len = node_tags[array_type.ast.elem_count] == .identifier and | 1606 | const is_inferred_array_len = node_tags[array_type.ast.elem_count] == .identifier and |
| 1622 | // This intentionally does not support `@"_"` syntax. | 1607 | // This intentionally does not support `@"_"` syntax. |
| ... | @@ -2321,10 +2306,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod | ... | @@ -2321,10 +2306,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod |
| 2321 | while (true) { | 2306 | while (true) { |
| 2322 | switch (node_tags[inner_node]) { | 2307 | switch (node_tags[inner_node]) { |
| 2323 | // zig fmt: off | 2308 | // zig fmt: off |
| 2324 | .global_var_decl => scope = try varDecl(gz, scope, statement, block_arena_allocator, tree.globalVarDecl(statement)), | 2309 | .global_var_decl, |
| 2325 | .local_var_decl => scope = try varDecl(gz, scope, statement, block_arena_allocator, tree.localVarDecl(statement)), | 2310 | .local_var_decl, |
| 2326 | .simple_var_decl => scope = try varDecl(gz, scope, statement, block_arena_allocator, tree.simpleVarDecl(statement)), | 2311 | .simple_var_decl, |
| 2327 | .aligned_var_decl => scope = try varDecl(gz, scope, statement, block_arena_allocator, tree.alignedVarDecl(statement)), | 2312 | .aligned_var_decl, => scope = try varDecl(gz, scope, statement, block_arena_allocator, tree.fullVarDecl(statement).?), |
| 2328 | 2313 | ||
| 2329 | .@"defer" => scope = try deferStmt(gz, scope, statement, block_arena_allocator, .defer_normal), | 2314 | .@"defer" => scope = try deferStmt(gz, scope, statement, block_arena_allocator, .defer_normal), |
| 2330 | .@"errdefer" => scope = try deferStmt(gz, scope, statement, block_arena_allocator, .defer_error), | 2315 | .@"errdefer" => scope = try deferStmt(gz, scope, statement, block_arena_allocator, .defer_error), |
| ... | @@ -2351,12 +2336,12 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod | ... | @@ -2351,12 +2336,12 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod |
| 2351 | continue; | 2336 | continue; |
| 2352 | }, | 2337 | }, |
| 2353 | 2338 | ||
| 2354 | .while_simple => _ = try whileExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.whileSimple(inner_node), true), | 2339 | .while_simple, |
| 2355 | .while_cont => _ = try whileExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.whileCont(inner_node), true), | 2340 | .while_cont, |
| 2356 | .@"while" => _ = try whileExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.whileFull(inner_node), true), | 2341 | .@"while", => _ = try whileExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.fullWhile(inner_node).?, true), |
| 2357 | 2342 | ||
| 2358 | .for_simple => _ = try forExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.forSimple(inner_node), true), | 2343 | .for_simple, |
| 2359 | .@"for" => _ = try forExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.forFull(inner_node), true), | 2344 | .@"for", => _ = try forExpr(gz, scope, .{ .rl = .discard }, inner_node, tree.fullWhile(inner_node).?, true), |
| 2360 | 2345 | ||
| 2361 | else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node), | 2346 | else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node), |
| 2362 | // zig fmt: on | 2347 | // zig fmt: on |
| ... | @@ -4491,12 +4476,8 @@ fn structDeclInner( | ... | @@ -4491,12 +4476,8 @@ fn structDeclInner( |
| 4491 | var is_tuple = false; | 4476 | var is_tuple = false; |
| 4492 | const node_tags = tree.nodes.items(.tag); | 4477 | const node_tags = tree.nodes.items(.tag); |
| 4493 | for (container_decl.ast.members) |member_node| { | 4478 | for (container_decl.ast.members) |member_node| { |
| 4494 | switch (node_tags[member_node]) { | 4479 | const container_field = tree.fullContainerField(member_node) orelse continue; |
| 4495 | .container_field_init => is_tuple = tree.containerFieldInit(member_node).ast.tuple_like, | 4480 | is_tuple = container_field.ast.tuple_like; |
| 4496 | .container_field_align => is_tuple = tree.containerFieldAlign(member_node).ast.tuple_like, | ||
| 4497 | .container_field => is_tuple = tree.containerField(member_node).ast.tuple_like, | ||
| 4498 | else => continue, | ||
| 4499 | } | ||
| 4500 | if (is_tuple) break; | 4481 | if (is_tuple) break; |
| 4501 | } | 4482 | } |
| 4502 | if (is_tuple) for (container_decl.ast.members) |member_node| { | 4483 | if (is_tuple) for (container_decl.ast.members) |member_node| { |
| ... | @@ -4802,7 +4783,6 @@ fn containerDecl( | ... | @@ -4802,7 +4783,6 @@ fn containerDecl( |
| 4802 | const gpa = astgen.gpa; | 4783 | const gpa = astgen.gpa; |
| 4803 | const tree = astgen.tree; | 4784 | const tree = astgen.tree; |
| 4804 | const token_tags = tree.tokens.items(.tag); | 4785 | const token_tags = tree.tokens.items(.tag); |
| 4805 | const node_tags = tree.nodes.items(.tag); | ||
| 4806 | 4786 | ||
| 4807 | const prev_fn_block = astgen.fn_block; | 4787 | const prev_fn_block = astgen.fn_block; |
| 4808 | astgen.fn_block = null; | 4788 | astgen.fn_block = null; |
| ... | @@ -4844,14 +4824,9 @@ fn containerDecl( | ... | @@ -4844,14 +4824,9 @@ fn containerDecl( |
| 4844 | var nonexhaustive_node: Ast.Node.Index = 0; | 4824 | var nonexhaustive_node: Ast.Node.Index = 0; |
| 4845 | var nonfinal_nonexhaustive = false; | 4825 | var nonfinal_nonexhaustive = false; |
| 4846 | for (container_decl.ast.members) |member_node| { | 4826 | for (container_decl.ast.members) |member_node| { |
| 4847 | var member = switch (node_tags[member_node]) { | 4827 | var member = tree.fullContainerField(member_node) orelse { |
| 4848 | .container_field_init => tree.containerFieldInit(member_node), | 4828 | decls += 1; |
| 4849 | .container_field_align => tree.containerFieldAlign(member_node), | 4829 | continue; |
| 4850 | .container_field => tree.containerField(member_node), | ||
| 4851 | else => { | ||
| 4852 | decls += 1; | ||
| 4853 | continue; | ||
| 4854 | }, | ||
| 4855 | }; | 4830 | }; |
| 4856 | member.convertToNonTupleLike(astgen.tree.nodes); | 4831 | member.convertToNonTupleLike(astgen.tree.nodes); |
| 4857 | if (member.ast.tuple_like) { | 4832 | if (member.ast.tuple_like) { |
| ... | @@ -5114,90 +5089,33 @@ fn containerMember( | ... | @@ -5114,90 +5089,33 @@ fn containerMember( |
| 5114 | const node_tags = tree.nodes.items(.tag); | 5089 | const node_tags = tree.nodes.items(.tag); |
| 5115 | const node_datas = tree.nodes.items(.data); | 5090 | const node_datas = tree.nodes.items(.data); |
| 5116 | switch (node_tags[member_node]) { | 5091 | switch (node_tags[member_node]) { |
| 5117 | .container_field_init => return ContainerMemberResult{ .field = tree.containerFieldInit(member_node) }, | 5092 | .container_field_init, |
| 5118 | .container_field_align => return ContainerMemberResult{ .field = tree.containerFieldAlign(member_node) }, | 5093 | .container_field_align, |
| 5119 | .container_field => return ContainerMemberResult{ .field = tree.containerField(member_node) }, | 5094 | .container_field, |
| 5120 | 5095 | => return ContainerMemberResult{ .field = tree.fullContainerField(member_node).? }, | |
| 5121 | .fn_decl => { | ||
| 5122 | const fn_proto = node_datas[member_node].lhs; | ||
| 5123 | const body = node_datas[member_node].rhs; | ||
| 5124 | switch (node_tags[fn_proto]) { | ||
| 5125 | .fn_proto_simple => { | ||
| 5126 | var params: [1]Ast.Node.Index = undefined; | ||
| 5127 | astgen.fnDecl(gz, scope, wip_members, member_node, body, tree.fnProtoSimple(&params, fn_proto)) catch |err| switch (err) { | ||
| 5128 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5129 | error.AnalysisFail => {}, | ||
| 5130 | }; | ||
| 5131 | }, | ||
| 5132 | .fn_proto_multi => { | ||
| 5133 | astgen.fnDecl(gz, scope, wip_members, member_node, body, tree.fnProtoMulti(fn_proto)) catch |err| switch (err) { | ||
| 5134 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5135 | error.AnalysisFail => {}, | ||
| 5136 | }; | ||
| 5137 | }, | ||
| 5138 | .fn_proto_one => { | ||
| 5139 | var params: [1]Ast.Node.Index = undefined; | ||
| 5140 | astgen.fnDecl(gz, scope, wip_members, member_node, body, tree.fnProtoOne(&params, fn_proto)) catch |err| switch (err) { | ||
| 5141 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5142 | error.AnalysisFail => {}, | ||
| 5143 | }; | ||
| 5144 | }, | ||
| 5145 | .fn_proto => { | ||
| 5146 | astgen.fnDecl(gz, scope, wip_members, member_node, body, tree.fnProto(fn_proto)) catch |err| switch (err) { | ||
| 5147 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5148 | error.AnalysisFail => {}, | ||
| 5149 | }; | ||
| 5150 | }, | ||
| 5151 | else => unreachable, | ||
| 5152 | } | ||
| 5153 | }, | ||
| 5154 | .fn_proto_simple => { | ||
| 5155 | var params: [1]Ast.Node.Index = undefined; | ||
| 5156 | astgen.fnDecl(gz, scope, wip_members, member_node, 0, tree.fnProtoSimple(&params, member_node)) catch |err| switch (err) { | ||
| 5157 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5158 | error.AnalysisFail => {}, | ||
| 5159 | }; | ||
| 5160 | }, | ||
| 5161 | .fn_proto_multi => { | ||
| 5162 | astgen.fnDecl(gz, scope, wip_members, member_node, 0, tree.fnProtoMulti(member_node)) catch |err| switch (err) { | ||
| 5163 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5164 | error.AnalysisFail => {}, | ||
| 5165 | }; | ||
| 5166 | }, | ||
| 5167 | .fn_proto_one => { | ||
| 5168 | var params: [1]Ast.Node.Index = undefined; | ||
| 5169 | astgen.fnDecl(gz, scope, wip_members, member_node, 0, tree.fnProtoOne(&params, member_node)) catch |err| switch (err) { | ||
| 5170 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5171 | error.AnalysisFail => {}, | ||
| 5172 | }; | ||
| 5173 | }, | ||
| 5174 | .fn_proto => { | ||
| 5175 | astgen.fnDecl(gz, scope, wip_members, member_node, 0, tree.fnProto(member_node)) catch |err| switch (err) { | ||
| 5176 | error.OutOfMemory => return error.OutOfMemory, | ||
| 5177 | error.AnalysisFail => {}, | ||
| 5178 | }; | ||
| 5179 | }, | ||
| 5180 | 5096 | ||
| 5181 | .global_var_decl => { | 5097 | .fn_proto, |
| 5182 | astgen.globalVarDecl(gz, scope, wip_members, member_node, tree.globalVarDecl(member_node)) catch |err| switch (err) { | 5098 | .fn_proto_multi, |
| 5183 | error.OutOfMemory => return error.OutOfMemory, | 5099 | .fn_proto_one, |
| 5184 | error.AnalysisFail => {}, | 5100 | .fn_proto_simple, |
| 5185 | }; | 5101 | .fn_decl, |
| 5186 | }, | 5102 | => { |
| 5187 | .local_var_decl => { | 5103 | var buf: [1]Ast.Node.Index = undefined; |
| 5188 | astgen.globalVarDecl(gz, scope, wip_members, member_node, tree.localVarDecl(member_node)) catch |err| switch (err) { | 5104 | const full = tree.fullFnProto(&buf, member_node).?; |
| 5189 | error.OutOfMemory => return error.OutOfMemory, | 5105 | const body = if (node_tags[member_node] == .fn_decl) node_datas[member_node].rhs else 0; |
| 5190 | error.AnalysisFail => {}, | 5106 | |
| 5191 | }; | 5107 | astgen.fnDecl(gz, scope, wip_members, member_node, body, full) catch |err| switch (err) { |
| 5192 | }, | ||
| 5193 | .simple_var_decl => { | ||
| 5194 | astgen.globalVarDecl(gz, scope, wip_members, member_node, tree.simpleVarDecl(member_node)) catch |err| switch (err) { | ||
| 5195 | error.OutOfMemory => return error.OutOfMemory, | 5108 | error.OutOfMemory => return error.OutOfMemory, |
| 5196 | error.AnalysisFail => {}, | 5109 | error.AnalysisFail => {}, |
| 5197 | }; | 5110 | }; |
| 5198 | }, | 5111 | }, |
| 5199 | .aligned_var_decl => { | 5112 | |
| 5200 | astgen.globalVarDecl(gz, scope, wip_members, member_node, tree.alignedVarDecl(member_node)) catch |err| switch (err) { | 5113 | .global_var_decl, |
| 5114 | .local_var_decl, | ||
| 5115 | .simple_var_decl, | ||
| 5116 | .aligned_var_decl, | ||
| 5117 | => { | ||
| 5118 | astgen.globalVarDecl(gz, scope, wip_members, member_node, tree.fullVarDecl(member_node).?) catch |err| switch (err) { | ||
| 5201 | error.OutOfMemory => return error.OutOfMemory, | 5119 | error.OutOfMemory => return error.OutOfMemory, |
| 5202 | error.AnalysisFail => {}, | 5120 | error.AnalysisFail => {}, |
| 5203 | }; | 5121 | }; |
| ... | @@ -6538,11 +6456,7 @@ fn switchExpr( | ... | @@ -6538,11 +6456,7 @@ fn switchExpr( |
| 6538 | var else_src: ?Ast.TokenIndex = null; | 6456 | var else_src: ?Ast.TokenIndex = null; |
| 6539 | var underscore_src: ?Ast.TokenIndex = null; | 6457 | var underscore_src: ?Ast.TokenIndex = null; |
| 6540 | for (case_nodes) |case_node| { | 6458 | for (case_nodes) |case_node| { |
| 6541 | const case = switch (node_tags[case_node]) { | 6459 | const case = tree.fullSwitchCase(case_node).?; |
| 6542 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 6543 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 6544 | else => unreachable, | ||
| 6545 | }; | ||
| 6546 | if (case.payload_token) |payload_token| { | 6460 | if (case.payload_token) |payload_token| { |
| 6547 | if (token_tags[payload_token] == .asterisk) { | 6461 | if (token_tags[payload_token] == .asterisk) { |
| 6548 | any_payload_is_ref = true; | 6462 | any_payload_is_ref = true; |
| ... | @@ -6689,11 +6603,7 @@ fn switchExpr( | ... | @@ -6689,11 +6603,7 @@ fn switchExpr( |
| 6689 | var multi_case_index: u32 = 0; | 6603 | var multi_case_index: u32 = 0; |
| 6690 | var scalar_case_index: u32 = 0; | 6604 | var scalar_case_index: u32 = 0; |
| 6691 | for (case_nodes) |case_node| { | 6605 | for (case_nodes) |case_node| { |
| 6692 | const case = switch (node_tags[case_node]) { | 6606 | const case = tree.fullSwitchCase(case_node).?; |
| 6693 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 6694 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 6695 | else => unreachable, | ||
| 6696 | }; | ||
| 6697 | 6607 | ||
| 6698 | const is_multi_case = case.ast.values.len > 1 or | 6608 | const is_multi_case = case.ast.values.len > 1 or |
| 6699 | (case.ast.values.len == 1 and node_tags[case.ast.values[0]] == .switch_range); | 6609 | (case.ast.values.len == 1 and node_tags[case.ast.values[0]] == .switch_range); |
src/Module.zig+80-404| ... | @@ -1040,34 +1040,13 @@ pub const Struct = struct { | ... | @@ -1040,34 +1040,13 @@ pub const Struct = struct { |
| 1040 | return s.srcLoc(mod); | 1040 | return s.srcLoc(mod); |
| 1041 | }; | 1041 | }; |
| 1042 | const node = owner_decl.relativeToNodeIndex(0); | 1042 | const node = owner_decl.relativeToNodeIndex(0); |
| 1043 | const node_tags = tree.nodes.items(.tag); | ||
| 1044 | switch (node_tags[node]) { | ||
| 1045 | .container_decl, | ||
| 1046 | .container_decl_trailing, | ||
| 1047 | => return queryFieldSrc(tree.*, query, file, tree.containerDecl(node)), | ||
| 1048 | .container_decl_two, .container_decl_two_trailing => { | ||
| 1049 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1050 | return queryFieldSrc(tree.*, query, file, tree.containerDeclTwo(&buffer, node)); | ||
| 1051 | }, | ||
| 1052 | .container_decl_arg, | ||
| 1053 | .container_decl_arg_trailing, | ||
| 1054 | => return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)), | ||
| 1055 | |||
| 1056 | .tagged_union, | ||
| 1057 | .tagged_union_trailing, | ||
| 1058 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnion(node)), | ||
| 1059 | .tagged_union_two, .tagged_union_two_trailing => { | ||
| 1060 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1061 | return queryFieldSrc(tree.*, query, file, tree.taggedUnionTwo(&buffer, node)); | ||
| 1062 | }, | ||
| 1063 | .tagged_union_enum_tag, | ||
| 1064 | .tagged_union_enum_tag_trailing, | ||
| 1065 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)), | ||
| 1066 | |||
| 1067 | .root => return queryFieldSrc(tree.*, query, file, tree.containerDeclRoot()), | ||
| 1068 | 1043 | ||
| 1044 | var buf: [2]Ast.Node.Index = undefined; | ||
| 1045 | if (tree.fullContainerDecl(&buf, node)) |container_decl| { | ||
| 1046 | return queryFieldSrc(tree.*, query, file, container_decl); | ||
| 1047 | } else { | ||
| 1069 | // This struct was generated using @Type | 1048 | // This struct was generated using @Type |
| 1070 | else => return s.srcLoc(mod), | 1049 | return s.srcLoc(mod); |
| 1071 | } | 1050 | } |
| 1072 | } | 1051 | } |
| 1073 | 1052 | ||
| ... | @@ -1207,34 +1186,12 @@ pub const EnumFull = struct { | ... | @@ -1207,34 +1186,12 @@ pub const EnumFull = struct { |
| 1207 | return e.srcLoc(mod); | 1186 | return e.srcLoc(mod); |
| 1208 | }; | 1187 | }; |
| 1209 | const node = owner_decl.relativeToNodeIndex(0); | 1188 | const node = owner_decl.relativeToNodeIndex(0); |
| 1210 | const node_tags = tree.nodes.items(.tag); | 1189 | var buf: [2]Ast.Node.Index = undefined; |
| 1211 | switch (node_tags[node]) { | 1190 | if (tree.fullContainerDecl(&buf, node)) |container_decl| { |
| 1212 | .container_decl, | 1191 | return queryFieldSrc(tree.*, query, file, container_decl); |
| 1213 | .container_decl_trailing, | 1192 | } else { |
| 1214 | => return queryFieldSrc(tree.*, query, file, tree.containerDecl(node)), | 1193 | // This enum was generated using @Type |
| 1215 | .container_decl_two, .container_decl_two_trailing => { | 1194 | return e.srcLoc(mod); |
| 1216 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1217 | return queryFieldSrc(tree.*, query, file, tree.containerDeclTwo(&buffer, node)); | ||
| 1218 | }, | ||
| 1219 | .container_decl_arg, | ||
| 1220 | .container_decl_arg_trailing, | ||
| 1221 | => return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)), | ||
| 1222 | |||
| 1223 | .tagged_union, | ||
| 1224 | .tagged_union_trailing, | ||
| 1225 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnion(node)), | ||
| 1226 | .tagged_union_two, .tagged_union_two_trailing => { | ||
| 1227 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1228 | return queryFieldSrc(tree.*, query, file, tree.taggedUnionTwo(&buffer, node)); | ||
| 1229 | }, | ||
| 1230 | .tagged_union_enum_tag, | ||
| 1231 | .tagged_union_enum_tag_trailing, | ||
| 1232 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)), | ||
| 1233 | |||
| 1234 | .root => return queryFieldSrc(tree.*, query, file, tree.containerDeclRoot()), | ||
| 1235 | |||
| 1236 | // This struct was generated using @Type | ||
| 1237 | else => return e.srcLoc(mod), | ||
| 1238 | } | 1195 | } |
| 1239 | } | 1196 | } |
| 1240 | }; | 1197 | }; |
| ... | @@ -1315,30 +1272,13 @@ pub const Union = struct { | ... | @@ -1315,30 +1272,13 @@ pub const Union = struct { |
| 1315 | return u.srcLoc(mod); | 1272 | return u.srcLoc(mod); |
| 1316 | }; | 1273 | }; |
| 1317 | const node = owner_decl.relativeToNodeIndex(0); | 1274 | const node = owner_decl.relativeToNodeIndex(0); |
| 1318 | const node_tags = tree.nodes.items(.tag); | 1275 | |
| 1319 | var buf: [2]Ast.Node.Index = undefined; | 1276 | var buf: [2]Ast.Node.Index = undefined; |
| 1320 | switch (node_tags[node]) { | 1277 | if (tree.fullContainerDecl(&buf, node)) |container_decl| { |
| 1321 | .container_decl, | 1278 | return queryFieldSrc(tree.*, query, file, container_decl); |
| 1322 | .container_decl_trailing, | 1279 | } else { |
| 1323 | => return queryFieldSrc(tree.*, query, file, tree.containerDecl(node)), | ||
| 1324 | .container_decl_two, .container_decl_two_trailing => { | ||
| 1325 | var buffer: [2]Ast.Node.Index = undefined; | ||
| 1326 | return queryFieldSrc(tree.*, query, file, tree.containerDeclTwo(&buffer, node)); | ||
| 1327 | }, | ||
| 1328 | .container_decl_arg, | ||
| 1329 | .container_decl_arg_trailing, | ||
| 1330 | => return queryFieldSrc(tree.*, query, file, tree.containerDeclArg(node)), | ||
| 1331 | .tagged_union, | ||
| 1332 | .tagged_union_trailing, | ||
| 1333 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnion(node)), | ||
| 1334 | .tagged_union_two, | ||
| 1335 | .tagged_union_two_trailing, | ||
| 1336 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionTwo(&buf, node)), | ||
| 1337 | .tagged_union_enum_tag, | ||
| 1338 | .tagged_union_enum_tag_trailing, | ||
| 1339 | => return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)), | ||
| 1340 | // This union was generated using @Type | 1280 | // This union was generated using @Type |
| 1341 | else => return u.srcLoc(mod), | 1281 | return u.srcLoc(mod); |
| 1342 | } | 1282 | } |
| 1343 | } | 1283 | } |
| 1344 | 1284 | ||
| ... | @@ -2304,10 +2244,11 @@ pub const SrcLoc = struct { | ... | @@ -2304,10 +2244,11 @@ pub const SrcLoc = struct { |
| 2304 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2244 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2305 | const node_tags = tree.nodes.items(.tag); | 2245 | const node_tags = tree.nodes.items(.tag); |
| 2306 | const full = switch (node_tags[node]) { | 2246 | const full = switch (node_tags[node]) { |
| 2307 | .global_var_decl => tree.globalVarDecl(node), | 2247 | .global_var_decl, |
| 2308 | .local_var_decl => tree.localVarDecl(node), | 2248 | .local_var_decl, |
| 2309 | .simple_var_decl => tree.simpleVarDecl(node), | 2249 | .simple_var_decl, |
| 2310 | .aligned_var_decl => tree.alignedVarDecl(node), | 2250 | .aligned_var_decl, |
| 2251 | => tree.fullVarDecl(node).?, | ||
| 2311 | .@"usingnamespace" => { | 2252 | .@"usingnamespace" => { |
| 2312 | const node_data = tree.nodes.items(.data); | 2253 | const node_data = tree.nodes.items(.data); |
| 2313 | return nodeToSpan(tree, node_data[node].lhs); | 2254 | return nodeToSpan(tree, node_data[node].lhs); |
| ... | @@ -2325,53 +2266,25 @@ pub const SrcLoc = struct { | ... | @@ -2325,53 +2266,25 @@ pub const SrcLoc = struct { |
| 2325 | .node_offset_var_decl_align => |node_off| { | 2266 | .node_offset_var_decl_align => |node_off| { |
| 2326 | const tree = try src_loc.file_scope.getTree(gpa); | 2267 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2327 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2268 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2328 | const node_tags = tree.nodes.items(.tag); | 2269 | const full = tree.fullVarDecl(node).?; |
| 2329 | const full: Ast.full.VarDecl = switch (node_tags[node]) { | ||
| 2330 | .global_var_decl => tree.globalVarDecl(node), | ||
| 2331 | .local_var_decl => tree.localVarDecl(node), | ||
| 2332 | .simple_var_decl => tree.simpleVarDecl(node), | ||
| 2333 | .aligned_var_decl => tree.alignedVarDecl(node), | ||
| 2334 | else => unreachable, | ||
| 2335 | }; | ||
| 2336 | return nodeToSpan(tree, full.ast.align_node); | 2270 | return nodeToSpan(tree, full.ast.align_node); |
| 2337 | }, | 2271 | }, |
| 2338 | .node_offset_var_decl_section => |node_off| { | 2272 | .node_offset_var_decl_section => |node_off| { |
| 2339 | const tree = try src_loc.file_scope.getTree(gpa); | 2273 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2340 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2274 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2341 | const node_tags = tree.nodes.items(.tag); | 2275 | const full = tree.fullVarDecl(node).?; |
| 2342 | const full: Ast.full.VarDecl = switch (node_tags[node]) { | ||
| 2343 | .global_var_decl => tree.globalVarDecl(node), | ||
| 2344 | .local_var_decl => tree.localVarDecl(node), | ||
| 2345 | .simple_var_decl => tree.simpleVarDecl(node), | ||
| 2346 | .aligned_var_decl => tree.alignedVarDecl(node), | ||
| 2347 | else => unreachable, | ||
| 2348 | }; | ||
| 2349 | return nodeToSpan(tree, full.ast.section_node); | 2276 | return nodeToSpan(tree, full.ast.section_node); |
| 2350 | }, | 2277 | }, |
| 2351 | .node_offset_var_decl_addrspace => |node_off| { | 2278 | .node_offset_var_decl_addrspace => |node_off| { |
| 2352 | const tree = try src_loc.file_scope.getTree(gpa); | 2279 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2353 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2280 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2354 | const node_tags = tree.nodes.items(.tag); | 2281 | const full = tree.fullVarDecl(node).?; |
| 2355 | const full: Ast.full.VarDecl = switch (node_tags[node]) { | ||
| 2356 | .global_var_decl => tree.globalVarDecl(node), | ||
| 2357 | .local_var_decl => tree.localVarDecl(node), | ||
| 2358 | .simple_var_decl => tree.simpleVarDecl(node), | ||
| 2359 | .aligned_var_decl => tree.alignedVarDecl(node), | ||
| 2360 | else => unreachable, | ||
| 2361 | }; | ||
| 2362 | return nodeToSpan(tree, full.ast.addrspace_node); | 2282 | return nodeToSpan(tree, full.ast.addrspace_node); |
| 2363 | }, | 2283 | }, |
| 2364 | .node_offset_var_decl_init => |node_off| { | 2284 | .node_offset_var_decl_init => |node_off| { |
| 2365 | const tree = try src_loc.file_scope.getTree(gpa); | 2285 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2366 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2286 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2367 | const node_tags = tree.nodes.items(.tag); | 2287 | const full = tree.fullVarDecl(node).?; |
| 2368 | const full: Ast.full.VarDecl = switch (node_tags[node]) { | ||
| 2369 | .global_var_decl => tree.globalVarDecl(node), | ||
| 2370 | .local_var_decl => tree.localVarDecl(node), | ||
| 2371 | .simple_var_decl => tree.simpleVarDecl(node), | ||
| 2372 | .aligned_var_decl => tree.alignedVarDecl(node), | ||
| 2373 | else => unreachable, | ||
| 2374 | }; | ||
| 2375 | return nodeToSpan(tree, full.ast.init_node); | 2288 | return nodeToSpan(tree, full.ast.init_node); |
| 2376 | }, | 2289 | }, |
| 2377 | .node_offset_builtin_call_arg0 => |n| return src_loc.byteOffsetBuiltinCallArg(gpa, n, 0), | 2290 | .node_offset_builtin_call_arg0 => |n| return src_loc.byteOffsetBuiltinCallArg(gpa, n, 0), |
| ... | @@ -2392,14 +2305,8 @@ pub const SrcLoc = struct { | ... | @@ -2392,14 +2305,8 @@ pub const SrcLoc = struct { |
| 2392 | .node_offset_slice_sentinel, | 2305 | .node_offset_slice_sentinel, |
| 2393 | => |node_off| { | 2306 | => |node_off| { |
| 2394 | const tree = try src_loc.file_scope.getTree(gpa); | 2307 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2395 | const node_tags = tree.nodes.items(.tag); | ||
| 2396 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2308 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2397 | const full = switch (node_tags[node]) { | 2309 | const full = tree.fullSlice(node).?; |
| 2398 | .slice_open => tree.sliceOpen(node), | ||
| 2399 | .slice => tree.slice(node), | ||
| 2400 | .slice_sentinel => tree.sliceSentinel(node), | ||
| 2401 | else => unreachable, | ||
| 2402 | }; | ||
| 2403 | const part_node = switch (src_loc.lazy) { | 2310 | const part_node = switch (src_loc.lazy) { |
| 2404 | .node_offset_slice_ptr => full.ast.sliced, | 2311 | .node_offset_slice_ptr => full.ast.sliced, |
| 2405 | .node_offset_slice_start => full.ast.start, | 2312 | .node_offset_slice_start => full.ast.start, |
| ... | @@ -2411,24 +2318,9 @@ pub const SrcLoc = struct { | ... | @@ -2411,24 +2318,9 @@ pub const SrcLoc = struct { |
| 2411 | }, | 2318 | }, |
| 2412 | .node_offset_call_func => |node_off| { | 2319 | .node_offset_call_func => |node_off| { |
| 2413 | const tree = try src_loc.file_scope.getTree(gpa); | 2320 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2414 | const node_tags = tree.nodes.items(.tag); | ||
| 2415 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2321 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2416 | var params: [1]Ast.Node.Index = undefined; | 2322 | var buf: [1]Ast.Node.Index = undefined; |
| 2417 | const full = switch (node_tags[node]) { | 2323 | const full = tree.fullCall(&buf, node).?; |
| 2418 | .call_one, | ||
| 2419 | .call_one_comma, | ||
| 2420 | .async_call_one, | ||
| 2421 | .async_call_one_comma, | ||
| 2422 | => tree.callOne(&params, node), | ||
| 2423 | |||
| 2424 | .call, | ||
| 2425 | .call_comma, | ||
| 2426 | .async_call, | ||
| 2427 | .async_call_comma, | ||
| 2428 | => tree.callFull(node), | ||
| 2429 | |||
| 2430 | else => unreachable, | ||
| 2431 | }; | ||
| 2432 | return nodeToSpan(tree, full.ast.fn_expr); | 2324 | return nodeToSpan(tree, full.ast.fn_expr); |
| 2433 | }, | 2325 | }, |
| 2434 | .node_offset_field_name => |node_off| { | 2326 | .node_offset_field_name => |node_off| { |
| ... | @@ -2451,24 +2343,14 @@ pub const SrcLoc = struct { | ... | @@ -2451,24 +2343,14 @@ pub const SrcLoc = struct { |
| 2451 | }, | 2343 | }, |
| 2452 | .node_offset_asm_source => |node_off| { | 2344 | .node_offset_asm_source => |node_off| { |
| 2453 | const tree = try src_loc.file_scope.getTree(gpa); | 2345 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2454 | const node_tags = tree.nodes.items(.tag); | ||
| 2455 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2346 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2456 | const full = switch (node_tags[node]) { | 2347 | const full = tree.fullAsm(node).?; |
| 2457 | .asm_simple => tree.asmSimple(node), | ||
| 2458 | .@"asm" => tree.asmFull(node), | ||
| 2459 | else => unreachable, | ||
| 2460 | }; | ||
| 2461 | return nodeToSpan(tree, full.ast.template); | 2348 | return nodeToSpan(tree, full.ast.template); |
| 2462 | }, | 2349 | }, |
| 2463 | .node_offset_asm_ret_ty => |node_off| { | 2350 | .node_offset_asm_ret_ty => |node_off| { |
| 2464 | const tree = try src_loc.file_scope.getTree(gpa); | 2351 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2465 | const node_tags = tree.nodes.items(.tag); | ||
| 2466 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2352 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2467 | const full = switch (node_tags[node]) { | 2353 | const full = tree.fullAsm(node).?; |
| 2468 | .asm_simple => tree.asmSimple(node), | ||
| 2469 | .@"asm" => tree.asmFull(node), | ||
| 2470 | else => unreachable, | ||
| 2471 | }; | ||
| 2472 | const asm_output = full.outputs[0]; | 2354 | const asm_output = full.outputs[0]; |
| 2473 | const node_datas = tree.nodes.items(.data); | 2355 | const node_datas = tree.nodes.items(.data); |
| 2474 | return nodeToSpan(tree, node_datas[asm_output].lhs); | 2356 | return nodeToSpan(tree, node_datas[asm_output].lhs); |
| ... | @@ -2479,13 +2361,17 @@ pub const SrcLoc = struct { | ... | @@ -2479,13 +2361,17 @@ pub const SrcLoc = struct { |
| 2479 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2361 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2480 | const node_tags = tree.nodes.items(.tag); | 2362 | const node_tags = tree.nodes.items(.tag); |
| 2481 | const src_node = switch (node_tags[node]) { | 2363 | const src_node = switch (node_tags[node]) { |
| 2482 | .if_simple => tree.ifSimple(node).ast.cond_expr, | 2364 | .if_simple, |
| 2483 | .@"if" => tree.ifFull(node).ast.cond_expr, | 2365 | .@"if", |
| 2484 | .while_simple => tree.whileSimple(node).ast.cond_expr, | 2366 | => tree.fullIf(node).?.ast.cond_expr, |
| 2485 | .while_cont => tree.whileCont(node).ast.cond_expr, | 2367 | |
| 2486 | .@"while" => tree.whileFull(node).ast.cond_expr, | 2368 | .while_simple, |
| 2487 | .for_simple => tree.forSimple(node).ast.cond_expr, | 2369 | .while_cont, |
| 2488 | .@"for" => tree.forFull(node).ast.cond_expr, | 2370 | .@"while", |
| 2371 | .for_simple, | ||
| 2372 | .@"for", | ||
| 2373 | => tree.fullWhile(node).?.ast.cond_expr, | ||
| 2374 | |||
| 2489 | .@"orelse" => node, | 2375 | .@"orelse" => node, |
| 2490 | .@"catch" => node, | 2376 | .@"catch" => node, |
| 2491 | else => unreachable, | 2377 | else => unreachable, |
| ... | @@ -2521,11 +2407,7 @@ pub const SrcLoc = struct { | ... | @@ -2521,11 +2407,7 @@ pub const SrcLoc = struct { |
| 2521 | const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange); | 2407 | const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange); |
| 2522 | const case_nodes = tree.extra_data[extra.start..extra.end]; | 2408 | const case_nodes = tree.extra_data[extra.start..extra.end]; |
| 2523 | for (case_nodes) |case_node| { | 2409 | for (case_nodes) |case_node| { |
| 2524 | const case = switch (node_tags[case_node]) { | 2410 | const case = tree.fullSwitchCase(case_node).?; |
| 2525 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 2526 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 2527 | else => unreachable, | ||
| 2528 | }; | ||
| 2529 | const is_special = (case.ast.values.len == 0) or | 2411 | const is_special = (case.ast.values.len == 0) or |
| 2530 | (case.ast.values.len == 1 and | 2412 | (case.ast.values.len == 1 and |
| 2531 | node_tags[case.ast.values[0]] == .identifier and | 2413 | node_tags[case.ast.values[0]] == .identifier and |
| ... | @@ -2545,11 +2427,7 @@ pub const SrcLoc = struct { | ... | @@ -2545,11 +2427,7 @@ pub const SrcLoc = struct { |
| 2545 | const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange); | 2427 | const extra = tree.extraData(node_datas[switch_node].rhs, Ast.Node.SubRange); |
| 2546 | const case_nodes = tree.extra_data[extra.start..extra.end]; | 2428 | const case_nodes = tree.extra_data[extra.start..extra.end]; |
| 2547 | for (case_nodes) |case_node| { | 2429 | for (case_nodes) |case_node| { |
| 2548 | const case = switch (node_tags[case_node]) { | 2430 | const case = tree.fullSwitchCase(case_node).?; |
| 2549 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 2550 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 2551 | else => unreachable, | ||
| 2552 | }; | ||
| 2553 | const is_special = (case.ast.values.len == 0) or | 2431 | const is_special = (case.ast.values.len == 0) or |
| 2554 | (case.ast.values.len == 1 and | 2432 | (case.ast.values.len == 1 and |
| 2555 | node_tags[case.ast.values[0]] == .identifier and | 2433 | node_tags[case.ast.values[0]] == .identifier and |
| ... | @@ -2566,12 +2444,7 @@ pub const SrcLoc = struct { | ... | @@ -2566,12 +2444,7 @@ pub const SrcLoc = struct { |
| 2566 | .node_offset_switch_prong_capture => |node_off| { | 2444 | .node_offset_switch_prong_capture => |node_off| { |
| 2567 | const tree = try src_loc.file_scope.getTree(gpa); | 2445 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2568 | const case_node = src_loc.declRelativeToNodeIndex(node_off); | 2446 | const case_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2569 | const node_tags = tree.nodes.items(.tag); | 2447 | const case = tree.fullSwitchCase(case_node).?; |
| 2570 | const case = switch (node_tags[case_node]) { | ||
| 2571 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 2572 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 2573 | else => unreachable, | ||
| 2574 | }; | ||
| 2575 | const start_tok = case.payload_token.?; | 2448 | const start_tok = case.payload_token.?; |
| 2576 | const token_tags = tree.tokens.items(.tag); | 2449 | const token_tags = tree.tokens.items(.tag); |
| 2577 | const end_tok = switch (token_tags[start_tok]) { | 2450 | const end_tok = switch (token_tags[start_tok]) { |
| ... | @@ -2585,116 +2458,38 @@ pub const SrcLoc = struct { | ... | @@ -2585,116 +2458,38 @@ pub const SrcLoc = struct { |
| 2585 | }, | 2458 | }, |
| 2586 | .node_offset_fn_type_align => |node_off| { | 2459 | .node_offset_fn_type_align => |node_off| { |
| 2587 | const tree = try src_loc.file_scope.getTree(gpa); | 2460 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2588 | const node_datas = tree.nodes.items(.data); | ||
| 2589 | const node_tags = tree.nodes.items(.tag); | ||
| 2590 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2461 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2591 | var params: [1]Ast.Node.Index = undefined; | 2462 | var buf: [1]Ast.Node.Index = undefined; |
| 2592 | const full = switch (node_tags[node]) { | 2463 | const full = tree.fullFnProto(&buf, node).?; |
| 2593 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 2594 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2595 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 2596 | .fn_proto => tree.fnProto(node), | ||
| 2597 | .fn_decl => switch (node_tags[node_datas[node].lhs]) { | ||
| 2598 | .fn_proto_simple => tree.fnProtoSimple(&params, node_datas[node].lhs), | ||
| 2599 | .fn_proto_multi => tree.fnProtoMulti(node_datas[node].lhs), | ||
| 2600 | .fn_proto_one => tree.fnProtoOne(&params, node_datas[node].lhs), | ||
| 2601 | .fn_proto => tree.fnProto(node_datas[node].lhs), | ||
| 2602 | else => unreachable, | ||
| 2603 | }, | ||
| 2604 | else => unreachable, | ||
| 2605 | }; | ||
| 2606 | return nodeToSpan(tree, full.ast.align_expr); | 2464 | return nodeToSpan(tree, full.ast.align_expr); |
| 2607 | }, | 2465 | }, |
| 2608 | .node_offset_fn_type_addrspace => |node_off| { | 2466 | .node_offset_fn_type_addrspace => |node_off| { |
| 2609 | const tree = try src_loc.file_scope.getTree(gpa); | 2467 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2610 | const node_datas = tree.nodes.items(.data); | ||
| 2611 | const node_tags = tree.nodes.items(.tag); | ||
| 2612 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2468 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2613 | var params: [1]Ast.Node.Index = undefined; | 2469 | var buf: [1]Ast.Node.Index = undefined; |
| 2614 | const full = switch (node_tags[node]) { | 2470 | const full = tree.fullFnProto(&buf, node).?; |
| 2615 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 2616 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2617 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 2618 | .fn_proto => tree.fnProto(node), | ||
| 2619 | .fn_decl => switch (node_tags[node_datas[node].lhs]) { | ||
| 2620 | .fn_proto_simple => tree.fnProtoSimple(&params, node_datas[node].lhs), | ||
| 2621 | .fn_proto_multi => tree.fnProtoMulti(node_datas[node].lhs), | ||
| 2622 | .fn_proto_one => tree.fnProtoOne(&params, node_datas[node].lhs), | ||
| 2623 | .fn_proto => tree.fnProto(node_datas[node].lhs), | ||
| 2624 | else => unreachable, | ||
| 2625 | }, | ||
| 2626 | else => unreachable, | ||
| 2627 | }; | ||
| 2628 | return nodeToSpan(tree, full.ast.addrspace_expr); | 2471 | return nodeToSpan(tree, full.ast.addrspace_expr); |
| 2629 | }, | 2472 | }, |
| 2630 | .node_offset_fn_type_section => |node_off| { | 2473 | .node_offset_fn_type_section => |node_off| { |
| 2631 | const tree = try src_loc.file_scope.getTree(gpa); | 2474 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2632 | const node_datas = tree.nodes.items(.data); | ||
| 2633 | const node_tags = tree.nodes.items(.tag); | ||
| 2634 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2475 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2635 | var params: [1]Ast.Node.Index = undefined; | 2476 | var buf: [1]Ast.Node.Index = undefined; |
| 2636 | const full = switch (node_tags[node]) { | 2477 | const full = tree.fullFnProto(&buf, node).?; |
| 2637 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 2638 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2639 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 2640 | .fn_proto => tree.fnProto(node), | ||
| 2641 | .fn_decl => switch (node_tags[node_datas[node].lhs]) { | ||
| 2642 | .fn_proto_simple => tree.fnProtoSimple(&params, node_datas[node].lhs), | ||
| 2643 | .fn_proto_multi => tree.fnProtoMulti(node_datas[node].lhs), | ||
| 2644 | .fn_proto_one => tree.fnProtoOne(&params, node_datas[node].lhs), | ||
| 2645 | .fn_proto => tree.fnProto(node_datas[node].lhs), | ||
| 2646 | else => unreachable, | ||
| 2647 | }, | ||
| 2648 | else => unreachable, | ||
| 2649 | }; | ||
| 2650 | return nodeToSpan(tree, full.ast.section_expr); | 2478 | return nodeToSpan(tree, full.ast.section_expr); |
| 2651 | }, | 2479 | }, |
| 2652 | .node_offset_fn_type_cc => |node_off| { | 2480 | .node_offset_fn_type_cc => |node_off| { |
| 2653 | const tree = try src_loc.file_scope.getTree(gpa); | 2481 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2654 | const node_datas = tree.nodes.items(.data); | ||
| 2655 | const node_tags = tree.nodes.items(.tag); | ||
| 2656 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2482 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2657 | var params: [1]Ast.Node.Index = undefined; | 2483 | var buf: [1]Ast.Node.Index = undefined; |
| 2658 | const full = switch (node_tags[node]) { | 2484 | const full = tree.fullFnProto(&buf, node).?; |
| 2659 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 2660 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2661 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 2662 | .fn_proto => tree.fnProto(node), | ||
| 2663 | .fn_decl => switch (node_tags[node_datas[node].lhs]) { | ||
| 2664 | .fn_proto_simple => tree.fnProtoSimple(&params, node_datas[node].lhs), | ||
| 2665 | .fn_proto_multi => tree.fnProtoMulti(node_datas[node].lhs), | ||
| 2666 | .fn_proto_one => tree.fnProtoOne(&params, node_datas[node].lhs), | ||
| 2667 | .fn_proto => tree.fnProto(node_datas[node].lhs), | ||
| 2668 | else => unreachable, | ||
| 2669 | }, | ||
| 2670 | else => unreachable, | ||
| 2671 | }; | ||
| 2672 | return nodeToSpan(tree, full.ast.callconv_expr); | 2485 | return nodeToSpan(tree, full.ast.callconv_expr); |
| 2673 | }, | 2486 | }, |
| 2674 | 2487 | ||
| 2675 | .node_offset_fn_type_ret_ty => |node_off| { | 2488 | .node_offset_fn_type_ret_ty => |node_off| { |
| 2676 | const tree = try src_loc.file_scope.getTree(gpa); | 2489 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2677 | const node_datas = tree.nodes.items(.data); | ||
| 2678 | const node_tags = tree.nodes.items(.tag); | ||
| 2679 | const node = src_loc.declRelativeToNodeIndex(node_off); | 2490 | const node = src_loc.declRelativeToNodeIndex(node_off); |
| 2680 | var params: [1]Ast.Node.Index = undefined; | 2491 | var buf: [1]Ast.Node.Index = undefined; |
| 2681 | const full = switch (node_tags[node]) { | 2492 | const full = tree.fullFnProto(&buf, node).?; |
| 2682 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 2683 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 2684 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 2685 | .fn_proto => tree.fnProto(node), | ||
| 2686 | .fn_decl => blk: { | ||
| 2687 | const fn_proto = node_datas[node].lhs; | ||
| 2688 | break :blk switch (node_tags[fn_proto]) { | ||
| 2689 | .fn_proto_simple => tree.fnProtoSimple(&params, fn_proto), | ||
| 2690 | .fn_proto_multi => tree.fnProtoMulti(fn_proto), | ||
| 2691 | .fn_proto_one => tree.fnProtoOne(&params, fn_proto), | ||
| 2692 | .fn_proto => tree.fnProto(fn_proto), | ||
| 2693 | else => unreachable, | ||
| 2694 | }; | ||
| 2695 | }, | ||
| 2696 | else => unreachable, | ||
| 2697 | }; | ||
| 2698 | return nodeToSpan(tree, full.ast.return_type); | 2493 | return nodeToSpan(tree, full.ast.return_type); |
| 2699 | }, | 2494 | }, |
| 2700 | .node_offset_param => |node_off| { | 2495 | .node_offset_param => |node_off| { |
| ... | @@ -2742,27 +2537,9 @@ pub const SrcLoc = struct { | ... | @@ -2742,27 +2537,9 @@ pub const SrcLoc = struct { |
| 2742 | 2537 | ||
| 2743 | .node_offset_lib_name => |node_off| { | 2538 | .node_offset_lib_name => |node_off| { |
| 2744 | const tree = try src_loc.file_scope.getTree(gpa); | 2539 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2745 | const node_datas = tree.nodes.items(.data); | ||
| 2746 | const node_tags = tree.nodes.items(.tag); | ||
| 2747 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2540 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2748 | var params: [1]Ast.Node.Index = undefined; | 2541 | var buf: [1]Ast.Node.Index = undefined; |
| 2749 | const full = switch (node_tags[parent_node]) { | 2542 | const full = tree.fullFnProto(&buf, parent_node).?; |
| 2750 | .fn_proto_simple => tree.fnProtoSimple(&params, parent_node), | ||
| 2751 | .fn_proto_multi => tree.fnProtoMulti(parent_node), | ||
| 2752 | .fn_proto_one => tree.fnProtoOne(&params, parent_node), | ||
| 2753 | .fn_proto => tree.fnProto(parent_node), | ||
| 2754 | .fn_decl => blk: { | ||
| 2755 | const fn_proto = node_datas[parent_node].lhs; | ||
| 2756 | break :blk switch (node_tags[fn_proto]) { | ||
| 2757 | .fn_proto_simple => tree.fnProtoSimple(&params, fn_proto), | ||
| 2758 | .fn_proto_multi => tree.fnProtoMulti(fn_proto), | ||
| 2759 | .fn_proto_one => tree.fnProtoOne(&params, fn_proto), | ||
| 2760 | .fn_proto => tree.fnProto(fn_proto), | ||
| 2761 | else => unreachable, | ||
| 2762 | }; | ||
| 2763 | }, | ||
| 2764 | else => unreachable, | ||
| 2765 | }; | ||
| 2766 | const tok_index = full.lib_name.?; | 2543 | const tok_index = full.lib_name.?; |
| 2767 | const start = tree.tokens.items(.start)[tok_index]; | 2544 | const start = tree.tokens.items(.start)[tok_index]; |
| 2768 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); | 2545 | const end = start + @intCast(u32, tree.tokenSlice(tok_index).len); |
| ... | @@ -2771,38 +2548,23 @@ pub const SrcLoc = struct { | ... | @@ -2771,38 +2548,23 @@ pub const SrcLoc = struct { |
| 2771 | 2548 | ||
| 2772 | .node_offset_array_type_len => |node_off| { | 2549 | .node_offset_array_type_len => |node_off| { |
| 2773 | const tree = try src_loc.file_scope.getTree(gpa); | 2550 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2774 | const node_tags = tree.nodes.items(.tag); | ||
| 2775 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2551 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2776 | 2552 | ||
| 2777 | const full: Ast.full.ArrayType = switch (node_tags[parent_node]) { | 2553 | const full = tree.fullArrayType(parent_node).?; |
| 2778 | .array_type => tree.arrayType(parent_node), | ||
| 2779 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), | ||
| 2780 | else => unreachable, | ||
| 2781 | }; | ||
| 2782 | return nodeToSpan(tree, full.ast.elem_count); | 2554 | return nodeToSpan(tree, full.ast.elem_count); |
| 2783 | }, | 2555 | }, |
| 2784 | .node_offset_array_type_sentinel => |node_off| { | 2556 | .node_offset_array_type_sentinel => |node_off| { |
| 2785 | const tree = try src_loc.file_scope.getTree(gpa); | 2557 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2786 | const node_tags = tree.nodes.items(.tag); | ||
| 2787 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2558 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2788 | 2559 | ||
| 2789 | const full: Ast.full.ArrayType = switch (node_tags[parent_node]) { | 2560 | const full = tree.fullArrayType(parent_node).?; |
| 2790 | .array_type => tree.arrayType(parent_node), | ||
| 2791 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), | ||
| 2792 | else => unreachable, | ||
| 2793 | }; | ||
| 2794 | return nodeToSpan(tree, full.ast.sentinel); | 2561 | return nodeToSpan(tree, full.ast.sentinel); |
| 2795 | }, | 2562 | }, |
| 2796 | .node_offset_array_type_elem => |node_off| { | 2563 | .node_offset_array_type_elem => |node_off| { |
| 2797 | const tree = try src_loc.file_scope.getTree(gpa); | 2564 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2798 | const node_tags = tree.nodes.items(.tag); | ||
| 2799 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2565 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2800 | 2566 | ||
| 2801 | const full: Ast.full.ArrayType = switch (node_tags[parent_node]) { | 2567 | const full = tree.fullArrayType(parent_node).?; |
| 2802 | .array_type => tree.arrayType(parent_node), | ||
| 2803 | .array_type_sentinel => tree.arrayTypeSentinel(parent_node), | ||
| 2804 | else => unreachable, | ||
| 2805 | }; | ||
| 2806 | return nodeToSpan(tree, full.ast.elem_type); | 2568 | return nodeToSpan(tree, full.ast.elem_type); |
| 2807 | }, | 2569 | }, |
| 2808 | .node_offset_un_op => |node_off| { | 2570 | .node_offset_un_op => |node_off| { |
| ... | @@ -2814,86 +2576,44 @@ pub const SrcLoc = struct { | ... | @@ -2814,86 +2576,44 @@ pub const SrcLoc = struct { |
| 2814 | }, | 2576 | }, |
| 2815 | .node_offset_ptr_elem => |node_off| { | 2577 | .node_offset_ptr_elem => |node_off| { |
| 2816 | const tree = try src_loc.file_scope.getTree(gpa); | 2578 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2817 | const node_tags = tree.nodes.items(.tag); | ||
| 2818 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2579 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2819 | 2580 | ||
| 2820 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2581 | const full = tree.fullPtrType(parent_node).?; |
| 2821 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2822 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2823 | .ptr_type => tree.ptrType(parent_node), | ||
| 2824 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2825 | else => unreachable, | ||
| 2826 | }; | ||
| 2827 | return nodeToSpan(tree, full.ast.child_type); | 2582 | return nodeToSpan(tree, full.ast.child_type); |
| 2828 | }, | 2583 | }, |
| 2829 | .node_offset_ptr_sentinel => |node_off| { | 2584 | .node_offset_ptr_sentinel => |node_off| { |
| 2830 | const tree = try src_loc.file_scope.getTree(gpa); | 2585 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2831 | const node_tags = tree.nodes.items(.tag); | ||
| 2832 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2586 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2833 | 2587 | ||
| 2834 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2588 | const full = tree.fullPtrType(parent_node).?; |
| 2835 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2836 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2837 | .ptr_type => tree.ptrType(parent_node), | ||
| 2838 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2839 | else => unreachable, | ||
| 2840 | }; | ||
| 2841 | return nodeToSpan(tree, full.ast.sentinel); | 2589 | return nodeToSpan(tree, full.ast.sentinel); |
| 2842 | }, | 2590 | }, |
| 2843 | .node_offset_ptr_align => |node_off| { | 2591 | .node_offset_ptr_align => |node_off| { |
| 2844 | const tree = try src_loc.file_scope.getTree(gpa); | 2592 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2845 | const node_tags = tree.nodes.items(.tag); | ||
| 2846 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2593 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2847 | 2594 | ||
| 2848 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2595 | const full = tree.fullPtrType(parent_node).?; |
| 2849 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2850 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2851 | .ptr_type => tree.ptrType(parent_node), | ||
| 2852 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2853 | else => unreachable, | ||
| 2854 | }; | ||
| 2855 | return nodeToSpan(tree, full.ast.align_node); | 2596 | return nodeToSpan(tree, full.ast.align_node); |
| 2856 | }, | 2597 | }, |
| 2857 | .node_offset_ptr_addrspace => |node_off| { | 2598 | .node_offset_ptr_addrspace => |node_off| { |
| 2858 | const tree = try src_loc.file_scope.getTree(gpa); | 2599 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2859 | const node_tags = tree.nodes.items(.tag); | ||
| 2860 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2600 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2861 | 2601 | ||
| 2862 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2602 | const full = tree.fullPtrType(parent_node).?; |
| 2863 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2864 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2865 | .ptr_type => tree.ptrType(parent_node), | ||
| 2866 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2867 | else => unreachable, | ||
| 2868 | }; | ||
| 2869 | return nodeToSpan(tree, full.ast.addrspace_node); | 2603 | return nodeToSpan(tree, full.ast.addrspace_node); |
| 2870 | }, | 2604 | }, |
| 2871 | .node_offset_ptr_bitoffset => |node_off| { | 2605 | .node_offset_ptr_bitoffset => |node_off| { |
| 2872 | const tree = try src_loc.file_scope.getTree(gpa); | 2606 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2873 | const node_tags = tree.nodes.items(.tag); | ||
| 2874 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2607 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2875 | 2608 | ||
| 2876 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2609 | const full = tree.fullPtrType(parent_node).?; |
| 2877 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2878 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2879 | .ptr_type => tree.ptrType(parent_node), | ||
| 2880 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2881 | else => unreachable, | ||
| 2882 | }; | ||
| 2883 | return nodeToSpan(tree, full.ast.bit_range_start); | 2610 | return nodeToSpan(tree, full.ast.bit_range_start); |
| 2884 | }, | 2611 | }, |
| 2885 | .node_offset_ptr_hostsize => |node_off| { | 2612 | .node_offset_ptr_hostsize => |node_off| { |
| 2886 | const tree = try src_loc.file_scope.getTree(gpa); | 2613 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2887 | const node_tags = tree.nodes.items(.tag); | ||
| 2888 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2614 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2889 | 2615 | ||
| 2890 | const full: Ast.full.PtrType = switch (node_tags[parent_node]) { | 2616 | const full = tree.fullPtrType(parent_node).?; |
| 2891 | .ptr_type_aligned => tree.ptrTypeAligned(parent_node), | ||
| 2892 | .ptr_type_sentinel => tree.ptrTypeSentinel(parent_node), | ||
| 2893 | .ptr_type => tree.ptrType(parent_node), | ||
| 2894 | .ptr_type_bit_range => tree.ptrTypeBitRange(parent_node), | ||
| 2895 | else => unreachable, | ||
| 2896 | }; | ||
| 2897 | return nodeToSpan(tree, full.ast.bit_range_end); | 2617 | return nodeToSpan(tree, full.ast.bit_range_end); |
| 2898 | }, | 2618 | }, |
| 2899 | .node_offset_container_tag => |node_off| { | 2619 | .node_offset_container_tag => |node_off| { |
| ... | @@ -2933,17 +2653,10 @@ pub const SrcLoc = struct { | ... | @@ -2933,17 +2653,10 @@ pub const SrcLoc = struct { |
| 2933 | }, | 2653 | }, |
| 2934 | .node_offset_init_ty => |node_off| { | 2654 | .node_offset_init_ty => |node_off| { |
| 2935 | const tree = try src_loc.file_scope.getTree(gpa); | 2655 | const tree = try src_loc.file_scope.getTree(gpa); |
| 2936 | const node_tags = tree.nodes.items(.tag); | ||
| 2937 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); | 2656 | const parent_node = src_loc.declRelativeToNodeIndex(node_off); |
| 2938 | 2657 | ||
| 2939 | var buf: [2]Ast.Node.Index = undefined; | 2658 | var buf: [2]Ast.Node.Index = undefined; |
| 2940 | const full: Ast.full.ArrayInit = switch (node_tags[parent_node]) { | 2659 | const full = tree.fullArrayInit(&buf, parent_node).?; |
| 2941 | .array_init_one, .array_init_one_comma => tree.arrayInitOne(buf[0..1], parent_node), | ||
| 2942 | .array_init_dot_two, .array_init_dot_two_comma => tree.arrayInitDotTwo(&buf, parent_node), | ||
| 2943 | .array_init_dot, .array_init_dot_comma => tree.arrayInitDot(parent_node), | ||
| 2944 | .array_init, .array_init_comma => tree.arrayInit(parent_node), | ||
| 2945 | else => unreachable, | ||
| 2946 | }; | ||
| 2947 | return nodeToSpan(tree, full.ast.type_expr); | 2660 | return nodeToSpan(tree, full.ast.type_expr); |
| 2948 | }, | 2661 | }, |
| 2949 | .node_offset_store_ptr => |node_off| { | 2662 | .node_offset_store_ptr => |node_off| { |
| ... | @@ -6097,11 +5810,7 @@ pub const SwitchProngSrc = union(enum) { | ... | @@ -6097,11 +5810,7 @@ pub const SwitchProngSrc = union(enum) { |
| 6097 | var multi_i: u32 = 0; | 5810 | var multi_i: u32 = 0; |
| 6098 | var scalar_i: u32 = 0; | 5811 | var scalar_i: u32 = 0; |
| 6099 | for (case_nodes) |case_node| { | 5812 | for (case_nodes) |case_node| { |
| 6100 | const case = switch (node_tags[case_node]) { | 5813 | const case = tree.fullSwitchCase(case_node).?; |
| 6101 | .switch_case_one, .switch_case_inline_one => tree.switchCaseOne(case_node), | ||
| 6102 | .switch_case, .switch_case_inline => tree.switchCase(case_node), | ||
| 6103 | else => unreachable, | ||
| 6104 | }; | ||
| 6105 | if (case.ast.values.len == 0) | 5814 | if (case.ast.values.len == 0) |
| 6106 | continue; | 5815 | continue; |
| 6107 | if (case.ast.values.len == 1 and | 5816 | if (case.ast.values.len == 1 and |
| ... | @@ -6223,15 +5932,9 @@ fn queryFieldSrc( | ... | @@ -6223,15 +5932,9 @@ fn queryFieldSrc( |
| 6223 | file_scope: *File, | 5932 | file_scope: *File, |
| 6224 | container_decl: Ast.full.ContainerDecl, | 5933 | container_decl: Ast.full.ContainerDecl, |
| 6225 | ) SrcLoc { | 5934 | ) SrcLoc { |
| 6226 | const node_tags = tree.nodes.items(.tag); | ||
| 6227 | var field_index: usize = 0; | 5935 | var field_index: usize = 0; |
| 6228 | for (container_decl.ast.members) |member_node| { | 5936 | for (container_decl.ast.members) |member_node| { |
| 6229 | const field = switch (node_tags[member_node]) { | 5937 | const field = tree.fullContainerField(member_node) orelse continue; |
| 6230 | .container_field_init => tree.containerFieldInit(member_node), | ||
| 6231 | .container_field_align => tree.containerFieldAlign(member_node), | ||
| 6232 | .container_field => tree.containerField(member_node), | ||
| 6233 | else => continue, | ||
| 6234 | }; | ||
| 6235 | if (field_index == query.index) { | 5938 | if (field_index == query.index) { |
| 6236 | return switch (query.range) { | 5939 | return switch (query.range) { |
| 6237 | .name => .{ | 5940 | .name => .{ |
| ... | @@ -6275,24 +5978,9 @@ pub fn paramSrc( | ... | @@ -6275,24 +5978,9 @@ pub fn paramSrc( |
| 6275 | }); | 5978 | }); |
| 6276 | return LazySrcLoc.nodeOffset(0); | 5979 | return LazySrcLoc.nodeOffset(0); |
| 6277 | }; | 5980 | }; |
| 6278 | const node_datas = tree.nodes.items(.data); | ||
| 6279 | const node_tags = tree.nodes.items(.tag); | ||
| 6280 | const node = decl.relativeToNodeIndex(func_node_offset); | 5981 | const node = decl.relativeToNodeIndex(func_node_offset); |
| 6281 | var params: [1]Ast.Node.Index = undefined; | 5982 | var buf: [1]Ast.Node.Index = undefined; |
| 6282 | const full = switch (node_tags[node]) { | 5983 | const full = tree.fullFnProto(&buf, node).?; |
| 6283 | .fn_proto_simple => tree.fnProtoSimple(&params, node), | ||
| 6284 | .fn_proto_multi => tree.fnProtoMulti(node), | ||
| 6285 | .fn_proto_one => tree.fnProtoOne(&params, node), | ||
| 6286 | .fn_proto => tree.fnProto(node), | ||
| 6287 | .fn_decl => switch (node_tags[node_datas[node].lhs]) { | ||
| 6288 | .fn_proto_simple => tree.fnProtoSimple(&params, node_datas[node].lhs), | ||
| 6289 | .fn_proto_multi => tree.fnProtoMulti(node_datas[node].lhs), | ||
| 6290 | .fn_proto_one => tree.fnProtoOne(&params, node_datas[node].lhs), | ||
| 6291 | .fn_proto => tree.fnProto(node_datas[node].lhs), | ||
| 6292 | else => unreachable, | ||
| 6293 | }, | ||
| 6294 | else => unreachable, | ||
| 6295 | }; | ||
| 6296 | var it = full.iterate(tree); | 5984 | var it = full.iterate(tree); |
| 6297 | var i: usize = 0; | 5985 | var i: usize = 0; |
| 6298 | while (it.next()) |param| : (i += 1) { | 5986 | while (it.next()) |param| : (i += 1) { |
| ... | @@ -6358,18 +6046,6 @@ pub fn initSrc( | ... | @@ -6358,18 +6046,6 @@ pub fn initSrc( |
| 6358 | const node_tags = tree.nodes.items(.tag); | 6046 | const node_tags = tree.nodes.items(.tag); |
| 6359 | const node = decl.relativeToNodeIndex(init_node_offset); | 6047 | const node = decl.relativeToNodeIndex(init_node_offset); |
| 6360 | var buf: [2]Ast.Node.Index = undefined; | 6048 | var buf: [2]Ast.Node.Index = undefined; |
| 6361 | const full = switch (node_tags[node]) { | ||
| 6362 | .array_init_one, .array_init_one_comma => tree.arrayInitOne(buf[0..1], node).ast.elements, | ||
| 6363 | .array_init_dot_two, .array_init_dot_two_comma => tree.arrayInitDotTwo(&buf, node).ast.elements, | ||
| 6364 | .array_init_dot, .array_init_dot_comma => tree.arrayInitDot(node).ast.elements, | ||
| 6365 | .array_init, .array_init_comma => tree.arrayInit(node).ast.elements, | ||
| 6366 | |||
| 6367 | .struct_init_one, .struct_init_one_comma => tree.structInitOne(buf[0..1], node).ast.fields, | ||
| 6368 | .struct_init_dot_two, .struct_init_dot_two_comma => tree.structInitDotTwo(&buf, node).ast.fields, | ||
| 6369 | .struct_init_dot, .struct_init_dot_comma => tree.structInitDot(node).ast.fields, | ||
| 6370 | .struct_init, .struct_init_comma => tree.structInit(node).ast.fields, | ||
| 6371 | else => return LazySrcLoc.nodeOffset(init_node_offset), | ||
| 6372 | }; | ||
| 6373 | switch (node_tags[node]) { | 6049 | switch (node_tags[node]) { |
| 6374 | .array_init_one, | 6050 | .array_init_one, |
| 6375 | .array_init_one_comma, | 6051 | .array_init_one_comma, |
| ... | @@ -6379,7 +6055,10 @@ pub fn initSrc( | ... | @@ -6379,7 +6055,10 @@ pub fn initSrc( |
| 6379 | .array_init_dot_comma, | 6055 | .array_init_dot_comma, |
| 6380 | .array_init, | 6056 | .array_init, |
| 6381 | .array_init_comma, | 6057 | .array_init_comma, |
| 6382 | => return LazySrcLoc.nodeOffset(decl.nodeIndexToRelative(full[init_index])), | 6058 | => { |
| 6059 | const full = tree.fullArrayInit(&buf, node).?.ast.elements; | ||
| 6060 | return LazySrcLoc.nodeOffset(decl.nodeIndexToRelative(full[init_index])); | ||
| 6061 | }, | ||
| 6383 | .struct_init_one, | 6062 | .struct_init_one, |
| 6384 | .struct_init_one_comma, | 6063 | .struct_init_one_comma, |
| 6385 | .struct_init_dot_two, | 6064 | .struct_init_dot_two, |
| ... | @@ -6388,8 +6067,11 @@ pub fn initSrc( | ... | @@ -6388,8 +6067,11 @@ pub fn initSrc( |
| 6388 | .struct_init_dot_comma, | 6067 | .struct_init_dot_comma, |
| 6389 | .struct_init, | 6068 | .struct_init, |
| 6390 | .struct_init_comma, | 6069 | .struct_init_comma, |
| 6391 | => return LazySrcLoc{ .node_offset_initializer = decl.nodeIndexToRelative(full[init_index]) }, | 6070 | => { |
| 6392 | else => unreachable, | 6071 | const full = tree.fullStructInit(&buf, node).?.ast.fields; |
| 6072 | return LazySrcLoc{ .node_offset_initializer = decl.nodeIndexToRelative(full[init_index]) }; | ||
| 6073 | }, | ||
| 6074 | else => return LazySrcLoc.nodeOffset(init_node_offset), | ||
| 6393 | } | 6075 | } |
| 6394 | } | 6076 | } |
| 6395 | 6077 | ||
| ... | @@ -6422,13 +6104,7 @@ pub fn optionsSrc(gpa: Allocator, decl: *Decl, base_src: LazySrcLoc, wanted: []c | ... | @@ -6422,13 +6104,7 @@ pub fn optionsSrc(gpa: Allocator, decl: *Decl, base_src: LazySrcLoc, wanted: []c |
| 6422 | else => unreachable, | 6104 | else => unreachable, |
| 6423 | }; | 6105 | }; |
| 6424 | var buf: [2]std.zig.Ast.Node.Index = undefined; | 6106 | var buf: [2]std.zig.Ast.Node.Index = undefined; |
| 6425 | const init_nodes = switch (node_tags[arg_node]) { | 6107 | const init_nodes = if (tree.fullStructInit(&buf, arg_node)) |struct_init| struct_init.ast.fields else return base_src; |
| 6426 | .struct_init_one, .struct_init_one_comma => tree.structInitOne(buf[0..1], arg_node).ast.fields, | ||
| 6427 | .struct_init_dot_two, .struct_init_dot_two_comma => tree.structInitDotTwo(&buf, arg_node).ast.fields, | ||
| 6428 | .struct_init_dot, .struct_init_dot_comma => tree.structInitDot(arg_node).ast.fields, | ||
| 6429 | .struct_init, .struct_init_comma => tree.structInit(arg_node).ast.fields, | ||
| 6430 | else => return base_src, | ||
| 6431 | }; | ||
| 6432 | for (init_nodes) |init_node| { | 6108 | for (init_nodes) |init_node| { |
| 6433 | // . IDENTIFIER = init_node | 6109 | // . IDENTIFIER = init_node |
| 6434 | const name_token = tree.firstToken(init_node) - 2; | 6110 | const name_token = tree.firstToken(init_node) - 2; |
src/Sema.zig+2-23| ... | @@ -2150,29 +2150,8 @@ fn addFieldErrNote( | ... | @@ -2150,29 +2150,8 @@ fn addFieldErrNote( |
| 2150 | 2150 | ||
| 2151 | const container_node = decl.relativeToNodeIndex(0); | 2151 | const container_node = decl.relativeToNodeIndex(0); |
| 2152 | const node_tags = tree.nodes.items(.tag); | 2152 | const node_tags = tree.nodes.items(.tag); |
| 2153 | var buffer: [2]std.zig.Ast.Node.Index = undefined; | 2153 | var buf: [2]std.zig.Ast.Node.Index = undefined; |
| 2154 | const container_decl = switch (node_tags[container_node]) { | 2154 | const container_decl = tree.fullContainerDecl(&buf, container_node) orelse break :blk decl.srcLoc(); |
| 2155 | .root => tree.containerDeclRoot(), | ||
| 2156 | .container_decl, | ||
| 2157 | .container_decl_trailing, | ||
| 2158 | => tree.containerDecl(container_node), | ||
| 2159 | .container_decl_two, | ||
| 2160 | .container_decl_two_trailing, | ||
| 2161 | => tree.containerDeclTwo(&buffer, container_node), | ||
| 2162 | .container_decl_arg, | ||
| 2163 | .container_decl_arg_trailing, | ||
| 2164 | => tree.containerDeclArg(container_node), | ||
| 2165 | .tagged_union, | ||
| 2166 | .tagged_union_trailing, | ||
| 2167 | => tree.taggedUnion(container_node), | ||
| 2168 | .tagged_union_two, | ||
| 2169 | .tagged_union_two_trailing, | ||
| 2170 | => tree.taggedUnionTwo(&buffer, container_node), | ||
| 2171 | .tagged_union_enum_tag, | ||
| 2172 | .tagged_union_enum_tag_trailing, | ||
| 2173 | => tree.taggedUnionEnumTag(container_node), | ||
| 2174 | else => break :blk decl.srcLoc(), | ||
| 2175 | }; | ||
| 2176 | 2155 | ||
| 2177 | var it_index: usize = 0; | 2156 | var it_index: usize = 0; |
| 2178 | for (container_decl.ast.members) |member_node| { | 2157 | for (container_decl.ast.members) |member_node| { |