type-hints.h 1.64 KB
Newer Older
1 2 3 4
// Copyright 2015 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.

5 6
#ifndef V8_OBJECTS_TYPE_HINTS_H_
#define V8_OBJECTS_TYPE_HINTS_H_
7

8
#include "src/base/flags.h"
9
#include "src/utils/utils.h"
10 11 12 13 14

namespace v8 {
namespace internal {

// Type hints for an binary operation.
15 16 17
enum class BinaryOperationHint : uint8_t {
  kNone,
  kSignedSmall,
18
  kSignedSmallInputs,
19
  kSigned32,
20
  kNumber,
21
  kNumberOrOddball,
22
  kString,
23
  kBigInt,
24
  kAny
25 26
};

27 28 29
inline size_t hash_value(BinaryOperationHint hint) {
  return static_cast<unsigned>(hint);
}
30

31 32 33 34 35 36 37
std::ostream& operator<<(std::ostream&, BinaryOperationHint);

// Type hints for an compare operation.
enum class CompareOperationHint : uint8_t {
  kNone,
  kSignedSmall,
  kNumber,
38
  kNumberOrBoolean,
39
  kNumberOrOddball,
40
  kInternalizedString,
41
  kString,
42
  kSymbol,
43
  kBigInt,
44
  kReceiver,
45
  kReceiverOrNullOrUndefined,
46
  kAny
47 48
};

49 50 51 52 53
inline size_t hash_value(CompareOperationHint hint) {
  return static_cast<unsigned>(hint);
}

std::ostream& operator<<(std::ostream&, CompareOperationHint);
54

55 56 57 58 59 60 61 62 63 64
// Type hints for for..in statements.
enum class ForInHint : uint8_t {
  kNone,
  kEnumCacheKeysAndIndices,
  kEnumCacheKeys,
  kAny
};

std::ostream& operator<<(std::ostream&, ForInHint);

65 66
enum StringAddFlags {
  // Omit both parameter checks.
67
  STRING_ADD_CHECK_NONE,
68
  // Convert parameters when check fails (instead of throwing an exception).
69 70
  STRING_ADD_CONVERT_LEFT,
  STRING_ADD_CONVERT_RIGHT,
71 72 73 74
};

std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);

75 76 77
}  // namespace internal
}  // namespace v8

78
#endif  // V8_OBJECTS_TYPE_HINTS_H_