handle_call_expr.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 HandleCallExprStart(Context& context, Parse::CallExprStartId node_id)
  10. -> bool {
  11. auto name_id = context.node_stack().PopExpr();
  12. context.node_stack().Push(node_id, name_id);
  13. context.param_and_arg_refs_stack().Push();
  14. return true;
  15. }
  16. auto HandleCallExprComma(Context& context, Parse::CallExprCommaId /*node_id*/)
  17. -> bool {
  18. context.param_and_arg_refs_stack().ApplyComma();
  19. return true;
  20. }
  21. auto HandleCallExpr(Context& context, Parse::CallExprId node_id) -> bool {
  22. // Process the final explicit call argument now, but leave the arguments
  23. // block on the stack until the end of this function.
  24. context.param_and_arg_refs_stack().EndNoPop(Parse::NodeKind::CallExprStart);
  25. auto [call_expr_node_id, callee_id] =
  26. context.node_stack().PopWithNodeId<Parse::NodeKind::CallExprStart>();
  27. auto call_id = PerformCall(
  28. context, call_expr_node_id, callee_id,
  29. context.param_and_arg_refs_stack().PeekCurrentBlockContents());
  30. context.param_and_arg_refs_stack().PopAndDiscard();
  31. context.node_stack().Push(node_id, call_id);
  32. return true;
  33. }
  34. } // namespace Carbon::Check