operator.h 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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/parse/node_ids.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. namespace Carbon::Check {
  10. struct Operator {
  11. llvm::StringLiteral interface_name;
  12. llvm::StringLiteral op_name = "Op";
  13. };
  14. // Checks and builds SemIR for a unary operator expression. For example,
  15. // `$operand` or `operand$`.
  16. auto BuildUnaryOperator(Context& context, Parse::AnyExprId node_id, Operator op,
  17. SemIR::InstId operand_id) -> SemIR::InstId;
  18. // Checks and builds SemIR for a binary operator expression. For example,
  19. // `lhs_id $ rhs_id`.
  20. auto BuildBinaryOperator(Context& context, Parse::AnyExprId node_id,
  21. Operator op, SemIR::InstId lhs_id,
  22. SemIR::InstId rhs_id) -> SemIR::InstId;
  23. } // namespace Carbon::Check
  24. #endif // CARBON_TOOLCHAIN_CHECK_OPERATOR_H_