| ... | @@ -577,6 +577,12 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr | ... | @@ -577,6 +577,12 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 577 | const node_datas = tree.nodes.items(.data); | 577 | const node_datas = tree.nodes.items(.data); |
| 578 | const node_tags = tree.nodes.items(.tag); | 578 | const node_tags = tree.nodes.items(.tag); |
| 579 | | 579 | |
| | 580 | const prev_anon_name_strategy = gz.anon_name_strategy; |
| | 581 | defer gz.anon_name_strategy = prev_anon_name_strategy; |
| | 582 | if (!nodeUsesAnonNameStrategy(tree, node)) { |
| | 583 | gz.anon_name_strategy = .anon; |
| | 584 | } |
| | 585 | |
| 580 | switch (node_tags[node]) { | 586 | switch (node_tags[node]) { |
| 581 | .root => unreachable, // Top-level declaration. | 587 | .root => unreachable, // Top-level declaration. |
| 582 | .@"usingnamespace" => unreachable, // Top-level declaration. | 588 | .@"usingnamespace" => unreachable, // Top-level declaration. |
| ... | @@ -9344,6 +9350,32 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { | ... | @@ -9344,6 +9350,32 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { |
| 9344 | } | 9350 | } |
| 9345 | } | 9351 | } |
| 9346 | | 9352 | |
| | 9353 | /// Returns `true` if the node uses `gz.anon_name_strategy`. |
| | 9354 | fn nodeUsesAnonNameStrategy(tree: *const Ast, node: Ast.Node.Index) bool { |
| | 9355 | const node_tags = tree.nodes.items(.tag); |
| | 9356 | switch (node_tags[node]) { |
| | 9357 | .container_decl, |
| | 9358 | .container_decl_trailing, |
| | 9359 | .container_decl_two, |
| | 9360 | .container_decl_two_trailing, |
| | 9361 | .container_decl_arg, |
| | 9362 | .container_decl_arg_trailing, |
| | 9363 | .tagged_union, |
| | 9364 | .tagged_union_trailing, |
| | 9365 | .tagged_union_two, |
| | 9366 | .tagged_union_two_trailing, |
| | 9367 | .tagged_union_enum_tag, |
| | 9368 | .tagged_union_enum_tag_trailing, |
| | 9369 | => return true, |
| | 9370 | .builtin_call_two, .builtin_call_two_comma, .builtin_call, .builtin_call_comma => { |
| | 9371 | const builtin_token = tree.nodes.items(.main_token)[node]; |
| | 9372 | const builtin_name = tree.tokenSlice(builtin_token); |
| | 9373 | return std.mem.eql(u8, builtin_name, "@Type"); |
| | 9374 | }, |
| | 9375 | else => return false, |
| | 9376 | } |
| | 9377 | } |
| | 9378 | |
| 9347 | /// Applies `rl` semantics to `result`. Expressions which do not do their own handling of | 9379 | /// Applies `rl` semantics to `result`. Expressions which do not do their own handling of |
| 9348 | /// result locations must call this function on their result. | 9380 | /// result locations must call this function on their result. |
| 9349 | /// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer. | 9381 | /// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer. |