Use abbreviation "decl" instead of "declaration" (#3382)

Part of switching to the [abbreviations we've decided to
use](https://docs.google.com/document/d/1RRYMm42osyqhI2LyjrjockYCutQ5dOf8Abu50kTrkX0/edit?resourcekey=0-kHyqOESbOHmzZphUbtLrTw#heading=h.pph7i5m5un7q).

I will rename files in a follow-up PR.
This commit is contained in:
josh11b
2023-11-10 10:43:25 +00:00
committed by GitHub
parent 11ca083855
commit 5020fdb3be
229 changed files with 565 additions and 601 deletions
+18 -21
View File
@@ -8,10 +8,10 @@
namespace Carbon::Check {
// Build a FunctionDeclaration describing the signature of a function. This
// 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 BuildFunctionDeclaration(Context& context, bool is_definition)
static auto BuildFunctionDecl(Context& context, 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
@@ -55,25 +55,23 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
context.node_stack()
.PopIf<Parse::NodeKind::ImplicitParameterList>()
.value_or(SemIR::InstBlockId::Empty);
auto name_context = context.declaration_name_stack().FinishName();
auto name_context = context.decl_name_stack().FinishName();
auto fn_node =
context.node_stack()
.PopForSoloParseNode<Parse::NodeKind::FunctionIntroducer>();
// Add the function declaration.
auto function_decl = SemIR::FunctionDeclaration{
auto function_decl = SemIR::FunctionDecl{
fn_node, context.GetBuiltinType(SemIR::BuiltinKind::FunctionType),
SemIR::FunctionId::Invalid};
auto function_decl_id = context.AddInst(function_decl);
// Check whether this is a redeclaration.
auto existing_id = context.declaration_name_stack().LookupOrAddName(
name_context, function_decl_id);
auto existing_id =
context.decl_name_stack().LookupOrAddName(name_context, function_decl_id);
if (existing_id.is_valid()) {
if (auto existing_function_decl =
context.insts()
.Get(existing_id)
.TryAs<SemIR::FunctionDeclaration>()) {
context.insts().Get(existing_id).TryAs<SemIR::FunctionDecl>()) {
// This is a redeclaration of an existing function.
function_decl.function_id = existing_function_decl->function_id;
@@ -98,17 +96,17 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
// Create a new function if this isn't a valid redeclaration.
if (!function_decl.function_id.is_valid()) {
function_decl.function_id = context.functions().Add(
{.name_id = name_context.state ==
DeclarationNameStack::NameContext::State::Unresolved
? name_context.unresolved_name_id
: SemIR::NameId::Invalid,
{.name_id =
name_context.state == DeclNameStack::NameContext::State::Unresolved
? name_context.unresolved_name_id
: SemIR::NameId::Invalid,
.implicit_param_refs_id = implicit_param_refs_id,
.param_refs_id = param_refs_id,
.return_type_id = return_type_id,
.return_slot_id = return_slot_id});
}
// Write the function ID into the FunctionDeclaration.
// Write the function ID into the FunctionDecl.
context.insts().Set(function_decl_id, function_decl);
if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
@@ -129,10 +127,9 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
return {function_decl.function_id, function_decl_id};
}
auto HandleFunctionDeclaration(Context& context, Parse::Node /*parse_node*/)
-> bool {
BuildFunctionDeclaration(context, /*is_definition=*/false);
context.declaration_name_stack().PopScope();
auto HandleFunctionDecl(Context& context, Parse::Node /*parse_node*/) -> bool {
BuildFunctionDecl(context, /*is_definition=*/false);
context.decl_name_stack().PopScope();
return true;
}
@@ -157,7 +154,7 @@ auto HandleFunctionDefinition(Context& context, Parse::Node parse_node)
context.PopScope();
context.inst_block_stack().Pop();
context.return_scope_stack().pop_back();
context.declaration_name_stack().PopScope();
context.decl_name_stack().PopScope();
return true;
}
@@ -165,7 +162,7 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::Node parse_node)
-> bool {
// Process the declaration portion of the function.
auto [function_id, decl_id] =
BuildFunctionDeclaration(context, /*is_definition=*/true);
BuildFunctionDecl(context, /*is_definition=*/true);
auto& function = context.functions().Get(function_id);
// Track that this declaration is the definition.
@@ -231,7 +228,7 @@ auto HandleFunctionIntroducer(Context& context, Parse::Node parse_node)
// Push the bracketing node.
context.node_stack().Push(parse_node);
// A name should always follow.
context.declaration_name_stack().PushScopeAndStartName();
context.decl_name_stack().PushScopeAndStartName();
return true;
}