summaryrefslogtreecommitdiff
path: root/deps/v8/src/common/operation.h
blob: dc243fe0a56bb4dd53a52e8f4f90243bed4a984f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMMON_OPERATION_H_
#define V8_COMMON_OPERATION_H_

#include <ostream>

#define ARITHMETIC_OPERATION_LIST(V) \
  V(Add)                             \
  V(Subtract)                        \
  V(Multiply)                        \
  V(Divide)                          \
  V(Modulus)                         \
  V(Exponentiate)                    \
  V(BitwiseAnd)                      \
  V(BitwiseOr)                       \
  V(BitwiseXor)                      \
  V(ShiftLeft)                       \
  V(ShiftRight)                      \
  V(ShiftRightLogical)

#define UNARY_OPERATION_LIST(V) \
  V(BitwiseNot)                 \
  V(Negate)                     \
  V(Increment)                  \
  V(Decrement)

#define COMPARISON_OPERATION_LIST(V) \
  V(Equal)                           \
  V(StrictEqual)                     \
  V(LessThan)                        \
  V(LessThanOrEqual)                 \
  V(GreaterThan)                     \
  V(GreaterThanOrEqual)

#define OPERATION_LIST(V)      \
  ARITHMETIC_OPERATION_LIST(V) \
  UNARY_OPERATION_LIST(V)      \
  COMPARISON_OPERATION_LIST(V)

enum class Operation : uint8_t {
#define DEFINE_OP(name) k##name,
  OPERATION_LIST(DEFINE_OP)
#undef DEFINE_OP
};

inline std::ostream& operator<<(std::ostream& os, const Operation& operation) {
  switch (operation) {
#define CASE(name)         \
  case Operation::k##name: \
    return os << #name;
    OPERATION_LIST(CASE)
#undef CASE
  }
}

#endif  // V8_COMMON_OPERATION_H_