mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:51:07 +01:00
Adjust handling of values in calls and structs (#2824)
Previously, IR for arguments in calls and struct values was separated out. This merges it back in. Additionally, parameters for functions and struct types had their own IR; the block is still there, but there's a TODO to decide what to do with it. In the LLVM IR, this has the consequence of emitting expressions that are inputs to a call or struct value within the scope of the function, which is pretty much where it should be. Importantly it happens before the call is encountered. This change also tinkers with the int and real literal lowering. I'm pretty sure both are still wrong, but was having trouble figuring out a "better" way to do it, and this seems like it'll work for now.
This commit is contained in:
@@ -154,8 +154,8 @@ auto SemanticsContext::PopScope() -> void {
|
||||
}
|
||||
|
||||
auto SemanticsContext::ImplicitAsForArgs(
|
||||
SemanticsNodeBlockId /*arg_ir_id*/, SemanticsNodeBlockId arg_refs_id,
|
||||
ParseTree::Node param_parse_node, SemanticsNodeBlockId param_refs_id,
|
||||
SemanticsNodeBlockId arg_refs_id, ParseTree::Node param_parse_node,
|
||||
SemanticsNodeBlockId param_refs_id,
|
||||
DiagnosticEmitter<ParseTree::Node>::DiagnosticBuilder* diagnostic) -> bool {
|
||||
// If both arguments and parameters are empty, return quickly. Otherwise,
|
||||
// we'll fetch both so that errors are consistent.
|
||||
@@ -292,10 +292,8 @@ auto SemanticsContext::CanImplicitAsStruct(SemanticsNode value_type,
|
||||
as_type.kind() != SemanticsNodeKind::StructType) {
|
||||
return false;
|
||||
}
|
||||
auto value_type_refs =
|
||||
semantics_->GetNodeBlock(value_type.GetAsStructType().second);
|
||||
auto as_type_refs =
|
||||
semantics_->GetNodeBlock(as_type.GetAsStructType().second);
|
||||
auto value_type_refs = semantics_->GetNodeBlock(value_type.GetAsStructType());
|
||||
auto as_type_refs = semantics_->GetNodeBlock(as_type.GetAsStructType());
|
||||
if (value_type_refs.size() != as_type_refs.size()) {
|
||||
return false;
|
||||
}
|
||||
@@ -314,7 +312,6 @@ auto SemanticsContext::CanImplicitAsStruct(SemanticsNode value_type,
|
||||
|
||||
auto SemanticsContext::ParamOrArgStart() -> void {
|
||||
params_or_args_stack_.Push();
|
||||
node_block_stack_.Push();
|
||||
}
|
||||
|
||||
auto SemanticsContext::ParamOrArgComma(bool for_args) -> void {
|
||||
@@ -322,11 +319,11 @@ auto SemanticsContext::ParamOrArgComma(bool for_args) -> void {
|
||||
}
|
||||
|
||||
auto SemanticsContext::ParamOrArgEnd(bool for_args, ParseNodeKind start_kind)
|
||||
-> std::pair<SemanticsNodeBlockId, SemanticsNodeBlockId> {
|
||||
-> SemanticsNodeBlockId {
|
||||
if (parse_tree_->node_kind(node_stack_.PeekParseNode()) != start_kind) {
|
||||
ParamOrArgSave(for_args);
|
||||
}
|
||||
return {node_block_stack_.Pop(), params_or_args_stack_.Pop()};
|
||||
return params_or_args_stack_.Pop();
|
||||
}
|
||||
|
||||
auto SemanticsContext::ParamOrArgSave(bool for_args) -> void {
|
||||
|
||||
Reference in New Issue
Block a user