member_access.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef CARBON_TOOLCHAIN_CHECK_MEMBER_ACCESS_H_
  5. #define CARBON_TOOLCHAIN_CHECK_MEMBER_ACCESS_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::Check {
  9. // Creates SemIR to perform a member access with base expression `base_id` and
  10. // member name `name_id`. When `required`, failing to find the name is a
  11. // diagnosed error; otherwise, `None` is returned. Returns the result of the
  12. // access.
  13. auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
  14. SemIR::InstId base_id, SemIR::NameId name_id,
  15. bool required = true) -> SemIR::InstId;
  16. // Creates SemIR to perform a compound member access with base expression
  17. // `base_id` and member name expression `member_expr_id`. Returns the result of
  18. // the access. If specified, `missing_impl_diagnoser()` is used to build an
  19. // error diagnostic when impl binding fails due to a missing `impl`.
  20. auto PerformCompoundMemberAccess(
  21. Context& context, SemIR::LocId loc_id, SemIR::InstId base_id,
  22. SemIR::InstId member_expr_id,
  23. MakeDiagnosticBuilderFn missing_impl_diagnoser = nullptr) -> SemIR::InstId;
  24. // Finds the value of an associated entity (given by assoc_entity_inst_id, a
  25. // member of the interface given by interface_type_id) associated with a type or
  26. // facet (given by base_id). Never does instance binding.
  27. auto GetAssociatedValue(Context& context, SemIR::LocId loc_id,
  28. SemIR::InstId base_id,
  29. SemIR::InstId assoc_entity_inst_id,
  30. SemIR::SpecificInterface interface) -> SemIR::InstId;
  31. // Creates SemIR to perform a tuple index with base expression `tuple_inst_id`
  32. // and index expression `index_inst_id`. Returns the result of the access.
  33. auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
  34. SemIR::InstId tuple_inst_id,
  35. SemIR::InstId index_inst_id) -> SemIR::InstId;
  36. } // namespace Carbon::Check
  37. #endif // CARBON_TOOLCHAIN_CHECK_MEMBER_ACCESS_H_