| ... | ... | @@ -844,7 +844,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 844 | 844 | .@"switch", .switch_comma => return switchExpr(gz, scope, rl, node), |
| 845 | 845 | |
| 846 | 846 | .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), |
| 847 | | .@"suspend" => return suspendExpr(gz, scope, rl, node), |
| 847 | .@"suspend" => return suspendExpr(gz, scope, node), |
| 848 | 848 | .@"await" => return awaitExpr(gz, scope, rl, node), |
| 849 | 849 | .@"resume" => return resumeExpr(gz, scope, rl, node), |
| 850 | 850 | |
| ... | ... | @@ -922,10 +922,8 @@ fn nosuspendExpr( |
| 922 | 922 | fn suspendExpr( |
| 923 | 923 | gz: *GenZir, |
| 924 | 924 | scope: *Scope, |
| 925 | | rl: ResultLoc, |
| 926 | 925 | node: ast.Node.Index, |
| 927 | 926 | ) InnerError!Zir.Inst.Ref { |
| 928 | | _ = rl; |
| 929 | 927 | const astgen = gz.astgen; |
| 930 | 928 | const gpa = astgen.gpa; |
| 931 | 929 | const tree = astgen.tree; |
| ... | ... | @@ -1171,32 +1169,32 @@ fn arrayInitExpr( |
| 1171 | 1169 | }, |
| 1172 | 1170 | .ref => { |
| 1173 | 1171 | if (types.array != .none) { |
| 1174 | | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init_ref); |
| 1172 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init_ref); |
| 1175 | 1173 | } else { |
| 1176 | | return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon_ref); |
| 1174 | return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon_ref); |
| 1177 | 1175 | } |
| 1178 | 1176 | }, |
| 1179 | 1177 | .none, .none_or_ref => { |
| 1180 | 1178 | if (types.array != .none) { |
| 1181 | | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); |
| 1179 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); |
| 1182 | 1180 | } else { |
| 1183 | | return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon); |
| 1181 | return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon); |
| 1184 | 1182 | } |
| 1185 | 1183 | }, |
| 1186 | 1184 | .ty => |ty_inst| { |
| 1187 | 1185 | if (types.array != .none) { |
| 1188 | | const result = try arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); |
| 1186 | const result = try arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); |
| 1189 | 1187 | return rvalue(gz, scope, rl, result, node); |
| 1190 | 1188 | } else { |
| 1191 | 1189 | const elem_type = try gz.addUnNode(.elem_type, ty_inst, node); |
| 1192 | | return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, ty_inst, elem_type, .array_init); |
| 1190 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init); |
| 1193 | 1191 | } |
| 1194 | 1192 | }, |
| 1195 | 1193 | .ptr, .inferred_ptr => |ptr_inst| { |
| 1196 | | return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, ptr_inst); |
| 1194 | return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, ptr_inst); |
| 1197 | 1195 | }, |
| 1198 | 1196 | .block_ptr => |block_gz| { |
| 1199 | | return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, block_gz.rl_ptr); |
| 1197 | return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, block_gz.rl_ptr); |
| 1200 | 1198 | }, |
| 1201 | 1199 | } |
| 1202 | 1200 | } |
| ... | ... | @@ -1204,12 +1202,10 @@ fn arrayInitExpr( |
| 1204 | 1202 | fn arrayInitExprRlNone( |
| 1205 | 1203 | gz: *GenZir, |
| 1206 | 1204 | scope: *Scope, |
| 1207 | | rl: ResultLoc, |
| 1208 | 1205 | node: ast.Node.Index, |
| 1209 | 1206 | elements: []const ast.Node.Index, |
| 1210 | 1207 | tag: Zir.Inst.Tag, |
| 1211 | 1208 | ) InnerError!Zir.Inst.Ref { |
| 1212 | | _ = rl; |
| 1213 | 1209 | const astgen = gz.astgen; |
| 1214 | 1210 | const gpa = astgen.gpa; |
| 1215 | 1211 | const elem_list = try gpa.alloc(Zir.Inst.Ref, elements.len); |
| ... | ... | @@ -1228,16 +1224,11 @@ fn arrayInitExprRlNone( |
| 1228 | 1224 | fn arrayInitExprRlTy( |
| 1229 | 1225 | gz: *GenZir, |
| 1230 | 1226 | scope: *Scope, |
| 1231 | | rl: ResultLoc, |
| 1232 | 1227 | node: ast.Node.Index, |
| 1233 | 1228 | elements: []const ast.Node.Index, |
| 1234 | | array_ty_inst: Zir.Inst.Ref, |
| 1235 | 1229 | elem_ty_inst: Zir.Inst.Ref, |
| 1236 | 1230 | tag: Zir.Inst.Tag, |
| 1237 | 1231 | ) InnerError!Zir.Inst.Ref { |
| 1238 | | _ = rl; |
| 1239 | | _ = array_ty_inst; |
| 1240 | | _ = elem_ty_inst; |
| 1241 | 1232 | const astgen = gz.astgen; |
| 1242 | 1233 | const gpa = astgen.gpa; |
| 1243 | 1234 | |
| ... | ... | @@ -1259,12 +1250,10 @@ fn arrayInitExprRlTy( |
| 1259 | 1250 | fn arrayInitExprRlPtr( |
| 1260 | 1251 | gz: *GenZir, |
| 1261 | 1252 | scope: *Scope, |
| 1262 | | rl: ResultLoc, |
| 1263 | 1253 | node: ast.Node.Index, |
| 1264 | 1254 | elements: []const ast.Node.Index, |
| 1265 | 1255 | result_ptr: Zir.Inst.Ref, |
| 1266 | 1256 | ) InnerError!Zir.Inst.Ref { |
| 1267 | | _ = rl; |
| 1268 | 1257 | const astgen = gz.astgen; |
| 1269 | 1258 | const gpa = astgen.gpa; |
| 1270 | 1259 | |
| ... | ... | @@ -1340,41 +1329,39 @@ fn structInitExpr( |
| 1340 | 1329 | .ref => { |
| 1341 | 1330 | if (struct_init.ast.type_expr != 0) { |
| 1342 | 1331 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1343 | | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init_ref); |
| 1332 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init_ref); |
| 1344 | 1333 | } else { |
| 1345 | | return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon_ref); |
| 1334 | return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon_ref); |
| 1346 | 1335 | } |
| 1347 | 1336 | }, |
| 1348 | 1337 | .none, .none_or_ref => { |
| 1349 | 1338 | if (struct_init.ast.type_expr != 0) { |
| 1350 | 1339 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1351 | | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); |
| 1340 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); |
| 1352 | 1341 | } else { |
| 1353 | | return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon); |
| 1342 | return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon); |
| 1354 | 1343 | } |
| 1355 | 1344 | }, |
| 1356 | 1345 | .ty => |ty_inst| { |
| 1357 | 1346 | if (struct_init.ast.type_expr == 0) { |
| 1358 | | return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); |
| 1347 | return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); |
| 1359 | 1348 | } |
| 1360 | 1349 | const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1361 | | const result = try structInitExprRlTy(gz, scope, rl, node, struct_init, inner_ty_inst, .struct_init); |
| 1350 | const result = try structInitExprRlTy(gz, scope, node, struct_init, inner_ty_inst, .struct_init); |
| 1362 | 1351 | return rvalue(gz, scope, rl, result, node); |
| 1363 | 1352 | }, |
| 1364 | | .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, rl, node, struct_init, ptr_inst), |
| 1365 | | .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, rl, node, struct_init, block_gz.rl_ptr), |
| 1353 | .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst), |
| 1354 | .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr), |
| 1366 | 1355 | } |
| 1367 | 1356 | } |
| 1368 | 1357 | |
| 1369 | 1358 | fn structInitExprRlNone( |
| 1370 | 1359 | gz: *GenZir, |
| 1371 | 1360 | scope: *Scope, |
| 1372 | | rl: ResultLoc, |
| 1373 | 1361 | node: ast.Node.Index, |
| 1374 | 1362 | struct_init: ast.full.StructInit, |
| 1375 | 1363 | tag: Zir.Inst.Tag, |
| 1376 | 1364 | ) InnerError!Zir.Inst.Ref { |
| 1377 | | _ = rl; |
| 1378 | 1365 | const astgen = gz.astgen; |
| 1379 | 1366 | const gpa = astgen.gpa; |
| 1380 | 1367 | const tree = astgen.tree; |
| ... | ... | @@ -1405,12 +1392,10 @@ fn structInitExprRlNone( |
| 1405 | 1392 | fn structInitExprRlPtr( |
| 1406 | 1393 | gz: *GenZir, |
| 1407 | 1394 | scope: *Scope, |
| 1408 | | rl: ResultLoc, |
| 1409 | 1395 | node: ast.Node.Index, |
| 1410 | 1396 | struct_init: ast.full.StructInit, |
| 1411 | 1397 | result_ptr: Zir.Inst.Ref, |
| 1412 | 1398 | ) InnerError!Zir.Inst.Ref { |
| 1413 | | _ = rl; |
| 1414 | 1399 | const astgen = gz.astgen; |
| 1415 | 1400 | const gpa = astgen.gpa; |
| 1416 | 1401 | const tree = astgen.tree; |
| ... | ... | @@ -1441,13 +1426,11 @@ fn structInitExprRlPtr( |
| 1441 | 1426 | fn structInitExprRlTy( |
| 1442 | 1427 | gz: *GenZir, |
| 1443 | 1428 | scope: *Scope, |
| 1444 | | rl: ResultLoc, |
| 1445 | 1429 | node: ast.Node.Index, |
| 1446 | 1430 | struct_init: ast.full.StructInit, |
| 1447 | 1431 | ty_inst: Zir.Inst.Ref, |
| 1448 | 1432 | tag: Zir.Inst.Tag, |
| 1449 | 1433 | ) InnerError!Zir.Inst.Ref { |
| 1450 | | _ = rl; |
| 1451 | 1434 | const astgen = gz.astgen; |
| 1452 | 1435 | const gpa = astgen.gpa; |
| 1453 | 1436 | const tree = astgen.tree; |
| ... | ... | @@ -1667,7 +1650,7 @@ fn blockExpr( |
| 1667 | 1650 | return labeledBlockExpr(gz, scope, rl, block_node, statements, .block); |
| 1668 | 1651 | } |
| 1669 | 1652 | |
| 1670 | | try blockExprStmts(gz, scope, block_node, statements); |
| 1653 | try blockExprStmts(gz, scope, statements); |
| 1671 | 1654 | return rvalue(gz, scope, rl, .void_value, block_node); |
| 1672 | 1655 | } |
| 1673 | 1656 | |
| ... | ... | @@ -1742,7 +1725,7 @@ fn labeledBlockExpr( |
| 1742 | 1725 | defer block_scope.labeled_breaks.deinit(astgen.gpa); |
| 1743 | 1726 | defer block_scope.labeled_store_to_block_ptr_list.deinit(astgen.gpa); |
| 1744 | 1727 | |
| 1745 | | try blockExprStmts(&block_scope, &block_scope.base, block_node, statements); |
| 1728 | try blockExprStmts(&block_scope, &block_scope.base, statements); |
| 1746 | 1729 | |
| 1747 | 1730 | if (!block_scope.label.?.used) { |
| 1748 | 1731 | return astgen.failTok(label_token, "unused block label", .{}); |
| ... | ... | @@ -1784,13 +1767,7 @@ fn labeledBlockExpr( |
| 1784 | 1767 | } |
| 1785 | 1768 | } |
| 1786 | 1769 | |
| 1787 | | fn blockExprStmts( |
| 1788 | | gz: *GenZir, |
| 1789 | | parent_scope: *Scope, |
| 1790 | | node: ast.Node.Index, |
| 1791 | | statements: []const ast.Node.Index, |
| 1792 | | ) !void { |
| 1793 | | _ = node; |
| 1770 | fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Node.Index) !void { |
| 1794 | 1771 | const astgen = gz.astgen; |
| 1795 | 1772 | const tree = astgen.tree; |
| 1796 | 1773 | const node_tags = tree.nodes.items(.tag); |
| ... | ... | @@ -1807,8 +1784,8 @@ fn blockExprStmts( |
| 1807 | 1784 | .simple_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.simpleVarDecl(statement)), |
| 1808 | 1785 | .aligned_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.alignedVarDecl(statement)), |
| 1809 | 1786 | |
| 1810 | | .@"defer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_normal), |
| 1811 | | .@"errdefer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_error), |
| 1787 | .@"defer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_normal), |
| 1788 | .@"errdefer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_error), |
| 1812 | 1789 | |
| 1813 | 1790 | .assign => try assign(gz, scope, statement), |
| 1814 | 1791 | |
| ... | ... | @@ -2205,14 +2182,12 @@ fn checkUsed( |
| 2205 | 2182 | } |
| 2206 | 2183 | } |
| 2207 | 2184 | |
| 2208 | | fn deferStmt( |
| 2209 | | gz: *GenZir, |
| 2185 | fn makeDeferScope( |
| 2210 | 2186 | scope: *Scope, |
| 2211 | 2187 | node: ast.Node.Index, |
| 2212 | 2188 | block_arena: *Allocator, |
| 2213 | 2189 | scope_tag: Scope.Tag, |
| 2214 | 2190 | ) InnerError!*Scope { |
| 2215 | | _ = gz; |
| 2216 | 2191 | const defer_scope = try block_arena.create(Scope.Defer); |
| 2217 | 2192 | defer_scope.* = .{ |
| 2218 | 2193 | .base = .{ .tag = scope_tag }, |