Clean up interface of node block stack after recent changes. (#3229)

- `Peek()` no longer returns a useful value, because we often don't
allocate a `NodeBlockId` until we finish building the block. Remove it
and update both its callers.
- Rename `PeekForAdd()` to `PeekOrAdd()` since it's no longer used to
get a block ID to add elements into.
- `PushForAdd()` was unused. Remove it.
- Add `NodeBlockStack::AddNode` to combine the operations of adding a
node and inserting it into a block.
This commit is contained in:
Richard Smith
2023-09-14 16:05:05 +00:00
committed by GitHub
parent e81d171226
commit 85d5b40429
7 changed files with 50 additions and 52 deletions
+3 -5
View File
@@ -51,11 +51,9 @@ auto HandleStructFieldValue(Context& context, Parse::Node parse_node) -> bool {
value_node_id = context.ConvertToValueExpression(value_node_id);
// Store the name for the type.
context.args_type_info_stack().AddNodeId(
context.semantics_ir().AddNodeInNoBlock(
SemIR::Node::StructTypeField::Make(
parse_node, name_id,
context.semantics_ir().GetNode(value_node_id).type_id())));
context.args_type_info_stack().AddNode(SemIR::Node::StructTypeField::Make(
parse_node, name_id,
context.semantics_ir().GetNode(value_node_id).type_id()));
// Push the value back on the stack as an argument.
context.node_stack().Push(parse_node, value_node_id);