handle_call_expr.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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/call.h"
  5. #include "toolchain/check/context.h"
  6. #include "toolchain/check/handle.h"
  7. #include "toolchain/sem_ir/inst.h"
  8. namespace Carbon::Check {
  9. auto HandleParseNode(Context& context, Parse::CallExprStartId node_id) -> bool {
  10. auto name_id = context.node_stack().PopExpr();
  11. context.node_stack().Push(node_id, name_id);
  12. context.param_and_arg_refs_stack().Push();
  13. return true;
  14. }
  15. auto HandleParseNode(Context& context, Parse::CallExprCommaId /*node_id*/)
  16. -> bool {
  17. context.param_and_arg_refs_stack().ApplyComma();
  18. return true;
  19. }
  20. auto HandleParseNode(Context& context, Parse::CallExprId node_id) -> bool {
  21. // Process the final explicit call argument now, but leave the arguments
  22. // block on the stack until the end of this function.
  23. context.param_and_arg_refs_stack().EndNoPop(Parse::NodeKind::CallExprStart);
  24. auto callee_id = context.node_stack().Pop<Parse::NodeKind::CallExprStart>();
  25. auto call_id = PerformCall(
  26. context, node_id, callee_id,
  27. context.param_and_arg_refs_stack().PeekCurrentBlockContents());
  28. context.param_and_arg_refs_stack().PopAndDiscard();
  29. context.node_stack().Push(node_id, call_id);
  30. return true;
  31. }
  32. } // namespace Carbon::Check