1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/type-hints.h"
6 
7 namespace v8 {
8 namespace internal {
9 
operator <<(std::ostream & os,BinaryOperationHint hint)10 std::ostream& operator<<(std::ostream& os, BinaryOperationHint hint) {
11   switch (hint) {
12     case BinaryOperationHint::kNone:
13       return os << "None";
14     case BinaryOperationHint::kSignedSmall:
15       return os << "SignedSmall";
16     case BinaryOperationHint::kSigned32:
17       return os << "Signed32";
18     case BinaryOperationHint::kNumberOrOddball:
19       return os << "NumberOrOddball";
20     case BinaryOperationHint::kString:
21       return os << "String";
22     case BinaryOperationHint::kAny:
23       return os << "Any";
24   }
25   UNREACHABLE();
26   return os;
27 }
28 
operator <<(std::ostream & os,CompareOperationHint hint)29 std::ostream& operator<<(std::ostream& os, CompareOperationHint hint) {
30   switch (hint) {
31     case CompareOperationHint::kNone:
32       return os << "None";
33     case CompareOperationHint::kSignedSmall:
34       return os << "SignedSmall";
35     case CompareOperationHint::kNumber:
36       return os << "Number";
37     case CompareOperationHint::kNumberOrOddball:
38       return os << "NumberOrOddball";
39     case CompareOperationHint::kAny:
40       return os << "Any";
41   }
42   UNREACHABLE();
43   return os;
44 }
45 
operator <<(std::ostream & os,ToBooleanHint hint)46 std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) {
47   switch (hint) {
48     case ToBooleanHint::kNone:
49       return os << "None";
50     case ToBooleanHint::kUndefined:
51       return os << "Undefined";
52     case ToBooleanHint::kBoolean:
53       return os << "Boolean";
54     case ToBooleanHint::kNull:
55       return os << "Null";
56     case ToBooleanHint::kSmallInteger:
57       return os << "SmallInteger";
58     case ToBooleanHint::kReceiver:
59       return os << "Receiver";
60     case ToBooleanHint::kString:
61       return os << "String";
62     case ToBooleanHint::kSymbol:
63       return os << "Symbol";
64     case ToBooleanHint::kHeapNumber:
65       return os << "HeapNumber";
66     case ToBooleanHint::kSimdValue:
67       return os << "SimdValue";
68     case ToBooleanHint::kAny:
69       return os << "Any";
70     case ToBooleanHint::kNeedsMap:
71       return os << "NeedsMap";
72   }
73   UNREACHABLE();
74   return os;
75 }
76 
operator <<(std::ostream & os,ToBooleanHints hints)77 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) {
78   if (hints == ToBooleanHint::kAny) return os << "Any";
79   if (hints == ToBooleanHint::kNone) return os << "None";
80   bool first = true;
81   for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) {
82     ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i);
83     if (hints & hint) {
84       if (!first) os << "|";
85       first = false;
86       os << hint;
87     }
88   }
89   return os;
90 }
91 
operator <<(std::ostream & os,const StringAddFlags & flags)92 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) {
93   switch (flags) {
94     case STRING_ADD_CHECK_NONE:
95       return os << "CheckNone";
96     case STRING_ADD_CHECK_LEFT:
97       return os << "CheckLeft";
98     case STRING_ADD_CHECK_RIGHT:
99       return os << "CheckRight";
100     case STRING_ADD_CHECK_BOTH:
101       return os << "CheckBoth";
102     case STRING_ADD_CONVERT_LEFT:
103       return os << "ConvertLeft";
104     case STRING_ADD_CONVERT_RIGHT:
105       return os << "ConvertRight";
106     case STRING_ADD_CONVERT:
107       break;
108   }
109   UNREACHABLE();
110   return os;
111 }
112 
113 }  // namespace internal
114 }  // namespace v8
115