mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:06:21 +01:00
Model function calls as initializing expressions (#3089)
Start treating function calls as initializing expressions instead of as value expressions. This required adding support for expression categories. Value bindings and temporary materialization conversions are created where necessary to transition between expression categories. For a function call with a return slot, we speculatively create a materialized temporary before the call and either commit to it or replace it with something else later, once we see how the function call expression is actually used. This change follows the direction suggested in #3133 for initializing expressions: depending on the return type of a function, the return value will either be initialized in-place or returned directly. This is visible in the semantics IR, which is a little unfortunate but is probably necessary as this is part of the semantics of the program. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
f790a27ace
commit
1013d1773c
@@ -48,6 +48,11 @@ auto HandleStructFieldValue(Context& context, ParseTree::Node parse_node)
|
||||
context.node_stack().PopExpressionWithParseNode();
|
||||
SemIR::StringId name_id = context.node_stack().Pop<ParseNodeKind::Name>();
|
||||
|
||||
// Convert the operand to a value.
|
||||
// TODO: We need to decide how struct literals interact with expression
|
||||
// categories.
|
||||
value_node_id = context.ConvertToValueExpression(value_node_id);
|
||||
|
||||
// Store the name for the type.
|
||||
auto type_block_id = context.args_type_info_stack().PeekForAdd();
|
||||
context.semantics_ir().AddNode(
|
||||
|
||||
Reference in New Issue
Block a user