bitwise.carbon 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. package Core library "prelude/operators/bitwise";
  5. // Bit complement: `^a`.
  6. interface BitComplement {
  7. fn Op[self: Self]() -> Self;
  8. }
  9. // Bitwise AND: `a & b`.
  10. interface BitAnd {
  11. fn Op[self: Self](other: Self) -> Self;
  12. }
  13. // Bitwise AND with assignment: `a &= b`.
  14. interface BitAndAssign {
  15. fn Op[addr self: Self*](other: Self);
  16. }
  17. // Bitwise OR: `a | b`.
  18. interface BitOr {
  19. fn Op[self: Self](other: Self) -> Self;
  20. }
  21. // Bitwise OR with assignment: `a |= b`.
  22. interface BitOrAssign {
  23. fn Op[addr self: Self*](other: Self);
  24. }
  25. // Bitwise XOR: `a ^ b`.
  26. interface BitXor {
  27. fn Op[self: Self](other: Self) -> Self;
  28. }
  29. // Bitwise XOR with assignment: `a ^= b`.
  30. interface BitXorAssign {
  31. fn Op[addr self: Self*](other: Self);
  32. }
  33. // Left shift: `a << b`.
  34. interface LeftShift {
  35. fn Op[self: Self](other: Self) -> Self;
  36. }
  37. // Left shift with assignment: `a <<= b`.
  38. interface LeftShiftAssign {
  39. fn Op[addr self: Self*](other: Self);
  40. }
  41. // Right shift: `a >> b`.
  42. interface RightShift {
  43. fn Op[self: Self](other: Self) -> Self;
  44. }
  45. // Right shift with assignment: `a >>= b`.
  46. interface RightShiftAssign {
  47. fn Op[addr self: Self*](other: Self);
  48. }