operator.h 1.5 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. #ifndef CARBON_TOOLCHAIN_CHECK_OPERATOR_H_
  5. #define CARBON_TOOLCHAIN_CHECK_OPERATOR_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/check/core_identifier.h"
  8. #include "toolchain/parse/node_ids.h"
  9. #include "toolchain/sem_ir/ids.h"
  10. namespace Carbon::Check {
  11. struct Operator {
  12. CoreIdentifier interface_name;
  13. llvm::ArrayRef<SemIR::InstId> interface_args_ref = {};
  14. CoreIdentifier op_name = CoreIdentifier::Op;
  15. };
  16. // Checks and builds SemIR for a unary operator expression. For example,
  17. // `*operand` or `operand*`. If specified, `missing_impl_diagnoser` is used to
  18. // build a custom error diagnostic for the case where impl lookup for the
  19. // operator fails.
  20. auto BuildUnaryOperator(
  21. Context& context, SemIR::LocId loc_id, Operator op,
  22. SemIR::InstId operand_id,
  23. MakeDiagnosticBuilderFn missing_impl_diagnoser = nullptr) -> SemIR::InstId;
  24. // Checks and builds SemIR for a binary operator expression. For example,
  25. // `lhs_id * rhs_id`. If specified, `missing_impl_diagnoser` is used to build a
  26. // custom error diagnostic for the case where impl lookup for the operator
  27. // fails.
  28. auto BuildBinaryOperator(
  29. Context& context, SemIR::LocId loc_id, Operator op, SemIR::InstId lhs_id,
  30. SemIR::InstId rhs_id,
  31. MakeDiagnosticBuilderFn missing_impl_diagnoser = nullptr) -> SemIR::InstId;
  32. } // namespace Carbon::Check
  33. #endif // CARBON_TOOLCHAIN_CHECK_OPERATOR_H_