mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Define Any...DeclId aliases for brevity (#3562)
This commit is contained in:
@@ -21,10 +21,8 @@ auto HandleClassIntroducer(Context& context,
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto BuildClassDecl(
|
||||
Context& context,
|
||||
Parse::NodeIdOneOf<Parse::ClassDeclId, Parse::ClassDefinitionStartId>
|
||||
parse_node) -> std::tuple<SemIR::ClassId, SemIR::InstId> {
|
||||
static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId parse_node)
|
||||
-> std::tuple<SemIR::ClassId, SemIR::InstId> {
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::ClassIntroducer>();
|
||||
|
||||
@@ -43,11 +43,10 @@ static auto DiagnoseModifiers(Context& context) -> KeywordModifierSet {
|
||||
// Build a FunctionDecl describing the signature of a function. This
|
||||
// handles the common logic shared by function declaration syntax and function
|
||||
// definition syntax.
|
||||
static auto BuildFunctionDecl(
|
||||
Context& context,
|
||||
Parse::NodeIdOneOf<Parse::FunctionDeclId, Parse::FunctionDefinitionStartId>
|
||||
parse_node,
|
||||
bool is_definition) -> std::pair<SemIR::FunctionId, SemIR::InstId> {
|
||||
static auto BuildFunctionDecl(Context& context,
|
||||
Parse::AnyFunctionDeclId parse_node,
|
||||
bool is_definition)
|
||||
-> std::pair<SemIR::FunctionId, SemIR::InstId> {
|
||||
// TODO: This contains the IR block for the parameters and return type. At
|
||||
// present, it's just loose, but it's not strictly required for parameter
|
||||
// refs; we should either stop constructing it completely or, if it turns out
|
||||
|
||||
@@ -21,10 +21,8 @@ auto HandleInterfaceIntroducer(Context& context,
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto BuildInterfaceDecl(
|
||||
Context& context, Parse::NodeIdOneOf<Parse::InterfaceDeclId,
|
||||
Parse::InterfaceDefinitionStartId>
|
||||
parse_node)
|
||||
static auto BuildInterfaceDecl(Context& context,
|
||||
Parse::AnyInterfaceDeclId parse_node)
|
||||
-> std::tuple<SemIR::InterfaceId, SemIR::InstId> {
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
context.node_stack()
|
||||
|
||||
@@ -75,6 +75,12 @@ struct NodeIdOneOf : public NodeId {
|
||||
constexpr NodeIdOneOf(InvalidNodeId) : NodeId(NodeId::InvalidIndex) {}
|
||||
};
|
||||
|
||||
using AnyClassDeclId = NodeIdOneOf<ClassDeclId, ClassDefinitionStartId>;
|
||||
using AnyFunctionDeclId =
|
||||
NodeIdOneOf<FunctionDeclId, FunctionDefinitionStartId>;
|
||||
using AnyInterfaceDeclId =
|
||||
NodeIdOneOf<InterfaceDeclId, InterfaceDefinitionStartId>;
|
||||
|
||||
// NodeId with kind that is anything but T::Kind.
|
||||
template <typename T>
|
||||
struct NodeIdNot : public NodeId {
|
||||
|
||||
@@ -220,8 +220,7 @@ struct Call {
|
||||
struct ClassDecl {
|
||||
static constexpr auto Kind = InstKind::ClassDecl.Define("class_decl");
|
||||
|
||||
Parse::NodeIdOneOf<Parse::ClassDeclId, Parse::ClassDefinitionStartId>
|
||||
parse_node;
|
||||
Parse::AnyClassDeclId parse_node;
|
||||
// No type: a class declaration is not itself a value. The name of a class
|
||||
// declaration becomes a class type value.
|
||||
// TODO: For a generic class declaration, the name of the class declaration
|
||||
@@ -256,8 +255,7 @@ struct ClassInit {
|
||||
struct ClassType {
|
||||
static constexpr auto Kind = InstKind::ClassType.Define("class_type");
|
||||
|
||||
Parse::NodeIdOneOf<Parse::ClassDeclId, Parse::ClassDefinitionStartId>
|
||||
parse_node;
|
||||
Parse::AnyClassDeclId parse_node;
|
||||
TypeId type_id;
|
||||
ClassId class_id;
|
||||
// TODO: Once we support generic classes, include the class's arguments here.
|
||||
@@ -316,8 +314,7 @@ struct FieldDecl {
|
||||
struct FunctionDecl {
|
||||
static constexpr auto Kind = InstKind::FunctionDecl.Define("fn_decl");
|
||||
|
||||
Parse::NodeIdOneOf<Parse::FunctionDeclId, Parse::FunctionDefinitionStartId>
|
||||
parse_node;
|
||||
Parse::AnyFunctionDeclId parse_node;
|
||||
TypeId type_id;
|
||||
FunctionId function_id;
|
||||
};
|
||||
@@ -353,8 +350,7 @@ struct InitializeFrom {
|
||||
struct InterfaceDecl {
|
||||
static constexpr auto Kind = InstKind::InterfaceDecl.Define("interface_decl");
|
||||
|
||||
Parse::NodeIdOneOf<Parse::InterfaceDeclId, Parse::InterfaceDefinitionStartId>
|
||||
parse_node;
|
||||
Parse::AnyInterfaceDeclId parse_node;
|
||||
// No type: an interface declaration is not itself a value. The name of an
|
||||
// interface declaration becomes a facet type value.
|
||||
// TODO: For a generic interface declaration, the name of the interface
|
||||
|
||||
Reference in New Issue
Block a user