member_access.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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`. Returns the result of the access.
  11. auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
  12. SemIR::InstId base_id, SemIR::NameId name_id)
  13. -> SemIR::InstId;
  14. // Creates SemIR to perform a compound member access with base expression
  15. // `base_id` and member name expression `member_expr_id`. Returns the result of
  16. // the access. If specified, `missing_impl_diagnoser()` is used to build an
  17. // error diagnostic when impl binding fails due to a missing `impl`.
  18. auto PerformCompoundMemberAccess(
  19. Context& context, SemIR::LocId loc_id, SemIR::InstId base_id,
  20. SemIR::InstId member_expr_id,
  21. MakeDiagnosticBuilderFn missing_impl_diagnoser = nullptr) -> SemIR::InstId;
  22. // Finds the value of an associated entity (given by assoc_entity_inst_id, a
  23. // member of the interface given by interface_type_id) associated with a type or
  24. // facet (given by base_id). Never does instance binding.
  25. auto GetAssociatedValue(Context& context, SemIR::LocId loc_id,
  26. SemIR::InstId base_id,
  27. SemIR::InstId assoc_entity_inst_id,
  28. SemIR::TypeId interface_type_id) -> SemIR::InstId;
  29. // Creates SemIR to perform a tuple index with base expression `tuple_inst_id`
  30. // and index expression `index_inst_id`. Returns the result of the access.
  31. auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
  32. SemIR::InstId tuple_inst_id,
  33. SemIR::InstId index_inst_id) -> SemIR::InstId;
  34. } // namespace Carbon::Check
  35. #endif // CARBON_TOOLCHAIN_CHECK_MEMBER_ACCESS_H_