mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Just segmenting out a chunk of logic while I'm thinking about function parameters.
53 lines
1.8 KiB
C++
53 lines
1.8 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/check/context.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
auto HandleImplicitParamListStart(Context& context,
|
|
Parse::ImplicitParamListStartId parse_node)
|
|
-> bool {
|
|
context.node_stack().Push(parse_node);
|
|
context.param_and_arg_refs_stack().Push();
|
|
return true;
|
|
}
|
|
|
|
auto HandleImplicitParamList(Context& context,
|
|
Parse::ImplicitParamListId parse_node) -> bool {
|
|
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
|
|
Parse::NodeKind::ImplicitParamListStart);
|
|
context.node_stack()
|
|
.PopAndDiscardSoloParseNode<Parse::NodeKind::ImplicitParamListStart>();
|
|
context.node_stack().Push(parse_node, refs_id);
|
|
// The implicit parameter list's scope extends to the end of the following
|
|
// parameter list.
|
|
return true;
|
|
}
|
|
|
|
auto HandleTuplePatternStart(Context& context,
|
|
Parse::TuplePatternStartId parse_node) -> bool {
|
|
context.node_stack().Push(parse_node);
|
|
context.param_and_arg_refs_stack().Push();
|
|
return true;
|
|
}
|
|
|
|
auto HandlePatternListComma(Context& context,
|
|
Parse::PatternListCommaId /*parse_node*/) -> bool {
|
|
context.param_and_arg_refs_stack().ApplyComma();
|
|
return true;
|
|
}
|
|
|
|
auto HandleTuplePattern(Context& context, Parse::TuplePatternId parse_node)
|
|
-> bool {
|
|
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
|
|
Parse::NodeKind::TuplePatternStart);
|
|
context.node_stack()
|
|
.PopAndDiscardSoloParseNode<Parse::NodeKind::TuplePatternStart>();
|
|
context.node_stack().Push(parse_node, refs_id);
|
|
return true;
|
|
}
|
|
|
|
} // namespace Carbon::Check
|