class.cpp 861 B

12345678910111213141516171819202122232425262728
  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/sem_ir/class.h"
  5. #include "toolchain/sem_ir/file.h"
  6. #include "toolchain/sem_ir/generic.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::SemIR {
  9. auto Class::GetObjectRepr(const File& file, SpecificId specific_id) const
  10. -> TypeId {
  11. if (!complete_type_witness_id.is_valid()) {
  12. return TypeId::Invalid;
  13. }
  14. auto witness_id =
  15. GetConstantValueInSpecific(file, specific_id, complete_type_witness_id);
  16. if (witness_id == ConstantId::Error) {
  17. return TypeId::Error;
  18. }
  19. return file.insts()
  20. .GetAs<CompleteTypeWitness>(file.constant_values().GetInstId(witness_id))
  21. .object_repr_id;
  22. }
  23. } // namespace Carbon::SemIR