handle_call_expr.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/check/inst.h"
  8. #include "toolchain/sem_ir/expr_info.h"
  9. #include "toolchain/sem_ir/inst.h"
  10. namespace Carbon::Check {
  11. auto HandleParseNode(Context& context, Parse::CallExprStartId node_id) -> bool {
  12. auto name_id = context.node_stack().PopExpr();
  13. context.node_stack().Push(node_id, name_id);
  14. context.param_and_arg_refs_stack().Push();
  15. return true;
  16. }
  17. auto HandleParseNode(Context& context, Parse::CallExprId node_id) -> bool {
  18. // Process the final explicit call argument now, but leave the arguments
  19. // block on the stack until the end of this function.
  20. context.param_and_arg_refs_stack().EndNoPop(Parse::NodeKind::CallExprStart);
  21. auto callee_id = context.node_stack().Pop<Parse::NodeKind::CallExprStart>();
  22. auto call_id = PerformCall(
  23. context, node_id, callee_id,
  24. context.param_and_arg_refs_stack().PeekCurrentBlockContents());
  25. context.param_and_arg_refs_stack().PopAndDiscard();
  26. context.node_stack().Push(node_id, call_id);
  27. return true;
  28. }
  29. auto HandleParseNode(Context& context, Parse::RefTagId node_id) -> bool {
  30. auto expr_id = context.node_stack().Peek<Parse::NodeCategory::Expr>();
  31. if (SemIR::GetExprCategory(context.sem_ir(), expr_id) !=
  32. SemIR::ExprCategory::DurableRef) {
  33. CARBON_DIAGNOSTIC(
  34. RefTagNotDurableRef, Error,
  35. "expression tagged with `ref` is not a durable reference");
  36. context.emitter().Emit(node_id, RefTagNotDurableRef);
  37. }
  38. context.ref_tags().Insert(expr_id, Context::RefTag::Present);
  39. return true;
  40. }
  41. } // namespace Carbon::Check