mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 10:10:12 +01:00
This adds a distinction between Unused and SoloParseNode, rather than equating the two. This is intended to help identify nodes which are getting pushed but maybe don't need to be. Not totally done because I want to adjust declaration name handling due to a quirk with how it mixes Name with Expression, but almost done. Once that's done the type punning will be completely gone.
47 lines
1.7 KiB
C++
47 lines
1.7 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.
|
|
auto storage_id =
|
|
context.AddNode(SemanticsNode::VarStorage::Make(name_node, cast_type_id));
|
|
|
|
// Bind the name to storage.
|
|
context.AddNodeAndPush(parse_node,
|
|
SemanticsNode::BindName::Make(name_node, cast_type_id,
|
|
name_id, storage_id));
|
|
return true;
|
|
}
|
|
|
|
auto SemanticsHandleTemplate(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
return context.TODO(parse_node, "HandleTemplate");
|
|
}
|
|
|
|
} // namespace Carbon
|