mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Switch decl_state to an arg for modifier functions (#4027)
With private modifiers, we'll want to start checking modifiers later, e.g. after a name conflict is detected (and potentially merged). I think we've agreed to be more explicit about whether the modifier functions are manipulating state, versus trying to keep the state on the stack a little longer (moving Pop to the end of these functions). Removing FileScope from the stack and renaming it to DeclIntroducerStack to better reflect the usage and behavior. The FileScope mostly reflects an approach that wasn't ultimately adopted.
This commit is contained in:
@@ -19,7 +19,7 @@ auto HandleInterfaceIntroducer(Context& context,
|
||||
// Push the bracketing node.
|
||||
context.node_stack().Push(node_id);
|
||||
// Optional modifiers and the name follow.
|
||||
context.decl_state_stack().Push(DeclState::Interface);
|
||||
context.decl_introducer_state_stack().Push(DeclIntroducerState::Interface);
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
@@ -39,18 +39,17 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
// Process modifiers.
|
||||
auto [_, parent_scope_inst] =
|
||||
context.name_scopes().GetInstIfValid(name_context.parent_scope_id);
|
||||
CheckAccessModifiersOnDecl(context, Lex::TokenKind::Interface,
|
||||
auto introducer =
|
||||
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Interface);
|
||||
CheckAccessModifiersOnDecl(context, introducer, Lex::TokenKind::Interface,
|
||||
parent_scope_inst);
|
||||
LimitModifiersOnDecl(context, KeywordModifierSet::Access,
|
||||
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Access,
|
||||
Lex::TokenKind::Interface);
|
||||
|
||||
auto modifiers = context.decl_state_stack().innermost().modifier_set;
|
||||
if (modifiers.HasAnyOf(KeywordModifierSet::Access)) {
|
||||
context.TODO(context.decl_state_stack().innermost().modifier_node_id(
|
||||
ModifierOrder::Access),
|
||||
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Access)) {
|
||||
context.TODO(introducer.modifier_node_id(ModifierOrder::Access),
|
||||
"access modifier");
|
||||
}
|
||||
context.decl_state_stack().Pop(DeclState::Interface);
|
||||
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user