handle_pattern_list.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/check/context.h"
  5. #include "toolchain/check/handle.h"
  6. namespace Carbon::Check {
  7. auto HandleImplicitParamListStart(Context& context,
  8. Parse::ImplicitParamListStartId node_id)
  9. -> bool {
  10. context.node_stack().Push(node_id);
  11. context.param_and_arg_refs_stack().Push();
  12. return true;
  13. }
  14. auto HandleImplicitParamList(Context& context,
  15. Parse::ImplicitParamListId node_id) -> bool {
  16. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  17. Parse::NodeKind::ImplicitParamListStart);
  18. context.node_stack()
  19. .PopAndDiscardSoloNodeId<Parse::NodeKind::ImplicitParamListStart>();
  20. context.node_stack().Push(node_id, refs_id);
  21. // The implicit parameter list's scope extends to the end of the following
  22. // parameter list.
  23. return true;
  24. }
  25. auto HandleTuplePatternStart(Context& context,
  26. Parse::TuplePatternStartId node_id) -> bool {
  27. context.node_stack().Push(node_id);
  28. context.param_and_arg_refs_stack().Push();
  29. return true;
  30. }
  31. auto HandlePatternListComma(Context& context,
  32. Parse::PatternListCommaId /*node_id*/) -> bool {
  33. context.param_and_arg_refs_stack().ApplyComma();
  34. return true;
  35. }
  36. auto HandleTuplePattern(Context& context, Parse::TuplePatternId node_id)
  37. -> bool {
  38. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  39. Parse::NodeKind::TuplePatternStart);
  40. context.node_stack()
  41. .PopAndDiscardSoloNodeId<Parse::NodeKind::TuplePatternStart>();
  42. context.node_stack().Push(node_id, refs_id);
  43. return true;
  44. }
  45. } // namespace Carbon::Check