handle_call_expr.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 [call_expr_node_id, callee_id] =
  25. context.node_stack().PopWithNodeId<Parse::NodeKind::CallExprStart>();
  26. auto call_id = PerformCall(
  27. context, call_expr_node_id, callee_id,
  28. context.param_and_arg_refs_stack().PeekCurrentBlockContents());
  29. context.param_and_arg_refs_stack().PopAndDiscard();
  30. context.node_stack().Push(node_id, call_id);
  31. return true;
  32. }
  33. } // namespace Carbon::Check