| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/field-type.h" | 5 #include "src/field-type.h" |
| 6 | 6 |
| 7 #include "src/ast/ast-types.h" |
| 7 #include "src/handles-inl.h" | 8 #include "src/handles-inl.h" |
| 8 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 9 #include "src/types.h" | |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 FieldType* FieldType::None() { | 15 FieldType* FieldType::None() { |
| 16 // Do not Smi::FromInt(0) here or for Any(), as that may translate | 16 // Do not Smi::FromInt(0) here or for Any(), as that may translate |
| 17 // as `nullptr` which is not a valid value for `this`. | 17 // as `nullptr` which is not a valid value for `this`. |
| 18 return reinterpret_cast<FieldType*>(Smi::FromInt(2)); | 18 return reinterpret_cast<FieldType*>(Smi::FromInt(2)); |
| 19 } | 19 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (IsNone()) return true; | 64 if (IsNone()) return true; |
| 65 if (other->IsNone()) return false; | 65 if (other->IsNone()) return false; |
| 66 if (IsAny()) return false; | 66 if (IsAny()) return false; |
| 67 DCHECK(IsClass()); | 67 DCHECK(IsClass()); |
| 68 DCHECK(other->IsClass()); | 68 DCHECK(other->IsClass()); |
| 69 return this == other; | 69 return this == other; |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); } | 72 bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); } |
| 73 | 73 |
| 74 Type* FieldType::Convert(Zone* zone) { | 74 AstType* FieldType::Convert(Zone* zone) { |
| 75 if (IsAny()) return Type::NonInternal(); | 75 if (IsAny()) return AstType::NonInternal(); |
| 76 if (IsNone()) return Type::None(); | 76 if (IsNone()) return AstType::None(); |
| 77 DCHECK(IsClass()); | 77 DCHECK(IsClass()); |
| 78 return Type::Class(AsClass(), zone); | 78 return AstType::Class(AsClass(), zone); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void FieldType::PrintTo(std::ostream& os) { | 81 void FieldType::PrintTo(std::ostream& os) { |
| 82 if (IsAny()) { | 82 if (IsAny()) { |
| 83 os << "Any"; | 83 os << "Any"; |
| 84 } else if (IsNone()) { | 84 } else if (IsNone()) { |
| 85 os << "None"; | 85 os << "None"; |
| 86 } else { | 86 } else { |
| 87 DCHECK(IsClass()); | 87 DCHECK(IsClass()); |
| 88 os << "Class(" << static_cast<void*>(*AsClass()) << ")"; | 88 os << "Class(" << static_cast<void*>(*AsClass()) << ")"; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace internal | 92 } // namespace internal |
| 93 } // namespace v8 | 93 } // namespace v8 |
| OLD | NEW |