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/compiler/type-hints.h" 6 7 namespace v8 { 8 namespace internal { 9 namespace compiler { 10 operator <<(std::ostream & os,BinaryOperationHints::Hint hint)11std::ostream& operator<<(std::ostream& os, BinaryOperationHints::Hint hint) { 12 switch (hint) { 13 case BinaryOperationHints::kNone: 14 return os << "None"; 15 case BinaryOperationHints::kSignedSmall: 16 return os << "SignedSmall"; 17 case BinaryOperationHints::kSigned32: 18 return os << "Signed32"; 19 case BinaryOperationHints::kNumber: 20 return os << "Number"; 21 case BinaryOperationHints::kString: 22 return os << "String"; 23 case BinaryOperationHints::kAny: 24 return os << "Any"; 25 } 26 UNREACHABLE(); 27 return os; 28 } 29 30 operator <<(std::ostream & os,BinaryOperationHints hints)31std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { 32 return os << hints.left() << "*" << hints.right() << "->" << hints.result(); 33 } 34 35 operator <<(std::ostream & os,ToBooleanHint hint)36std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) { 37 switch (hint) { 38 case ToBooleanHint::kNone: 39 return os << "None"; 40 case ToBooleanHint::kUndefined: 41 return os << "Undefined"; 42 case ToBooleanHint::kBoolean: 43 return os << "Boolean"; 44 case ToBooleanHint::kNull: 45 return os << "Null"; 46 case ToBooleanHint::kSmallInteger: 47 return os << "SmallInteger"; 48 case ToBooleanHint::kReceiver: 49 return os << "Receiver"; 50 case ToBooleanHint::kString: 51 return os << "String"; 52 case ToBooleanHint::kSymbol: 53 return os << "Symbol"; 54 case ToBooleanHint::kHeapNumber: 55 return os << "HeapNumber"; 56 case ToBooleanHint::kSimdValue: 57 return os << "SimdValue"; 58 case ToBooleanHint::kAny: 59 return os << "Any"; 60 } 61 UNREACHABLE(); 62 return os; 63 } 64 65 operator <<(std::ostream & os,ToBooleanHints hints)66std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { 67 if (hints == ToBooleanHint::kAny) return os << "Any"; 68 if (hints == ToBooleanHint::kNone) return os << "None"; 69 bool first = true; 70 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * CHAR_BIT; ++i) { 71 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); 72 if (hints & hint) { 73 if (!first) os << "|"; 74 first = false; 75 os << hint; 76 } 77 } 78 return os; 79 } 80 81 } // namespace compiler 82 } // namespace internal 83 } // namespace v8 84