mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 15:10:10 +01:00
This removes BindName, putting name information directly on VarStorage.
As a side-effect of updating semantics_ir_test for this change, I also
noted that function bodies were being generated as invalid YAML so am
fixing that (just `{}` to `[]` bracketing, otherwise the test wouldn't
work anymore).
Because names are now available, I've updated lowering to use them for
vars.
In the SemIR formatter, the name is now repeated because it's a
parameter to VarStorage. I believe this is just default behavior, and
we'd have to special-case VarStorage to remove it because it's automatic
argument printing in action. On the balance, it felt like letting it
print was reasonable.
I've noted in places that the name on VarStorage is expected to be
optional, but am not adding support because I'd have no way of testing
it at present.
42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/semantics/semantics_context.h"
|
|
#include "toolchain/semantics/semantics_node.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto SemanticsHandleAddress(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
return context.TODO(parse_node, "HandleAddress");
|
|
}
|
|
|
|
auto SemanticsHandleGenericPatternBinding(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
return context.TODO(parse_node, "GenericPatternBinding");
|
|
}
|
|
|
|
auto SemanticsHandlePatternBinding(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
auto [type_node, parsed_type_id] =
|
|
context.node_stack().PopExpressionWithParseNode();
|
|
auto cast_type_id = context.ExpressionAsType(type_node, parsed_type_id);
|
|
|
|
// Get the name.
|
|
auto [name_node, name_id] =
|
|
context.node_stack().PopWithParseNode<ParseNodeKind::Name>();
|
|
|
|
// Allocate storage, linked to the name for error locations.
|
|
context.AddNodeAndPush(parse_node, SemanticsNode::VarStorage::Make(
|
|
name_node, cast_type_id, name_id));
|
|
return true;
|
|
}
|
|
|
|
auto SemanticsHandleTemplate(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
return context.TODO(parse_node, "HandleTemplate");
|
|
}
|
|
|
|
} // namespace Carbon
|