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/handles-inl.h" | 7 #include "src/handles-inl.h" |
8 #include "src/ostreams.h" | 8 #include "src/ostreams.h" |
9 #include "src/types.h" | 9 #include "src/types.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) { | 38 Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) { |
39 return handle(Class(*map), isolate); | 39 return handle(Class(*map), isolate); |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
43 FieldType* FieldType::cast(Object* object) { | 43 FieldType* FieldType::cast(Object* object) { |
44 DCHECK(object == None() || object == Any() || object->IsMap()); | 44 DCHECK(object == None() || object == Any() || object->IsMap()); |
45 return reinterpret_cast<FieldType*>(object); | 45 return reinterpret_cast<FieldType*>(object); |
46 } | 46 } |
47 | 47 |
48 bool FieldType::NowContains(Object* value) { | |
49 if (this == Any()) return true; | |
50 if (this == None()) return false; | |
51 if (!value->IsHeapObject()) return false; | |
52 return HeapObject::cast(value)->map() == Map::cast(this); | |
53 } | |
54 | |
55 bool FieldType::NowContains(Handle<Object> value) { | |
56 return NowContains(*value); | |
57 } | |
58 | |
59 bool FieldType::IsClass() { return this->IsMap(); } | 48 bool FieldType::IsClass() { return this->IsMap(); } |
60 | 49 |
61 Handle<i::Map> FieldType::AsClass() { | 50 Handle<i::Map> FieldType::AsClass() { |
62 DCHECK(IsClass()); | 51 DCHECK(IsClass()); |
63 i::Map* map = Map::cast(this); | 52 i::Map* map = Map::cast(this); |
64 return handle(map, map->GetIsolate()); | 53 return handle(map, map->GetIsolate()); |
65 } | 54 } |
66 | 55 |
67 bool FieldType::NowStable() { | 56 bool FieldType::NowStable() { |
68 return !this->IsClass() || this->AsClass()->is_stable(); | 57 return !this->IsClass() || this->AsClass()->is_stable(); |
(...skipping 24 matching lines...) Expand all Loading... |
93 } else if (IsNone()) { | 82 } else if (IsNone()) { |
94 os << "None"; | 83 os << "None"; |
95 } else { | 84 } else { |
96 DCHECK(IsClass()); | 85 DCHECK(IsClass()); |
97 os << "Class(" << static_cast<void*>(*AsClass()) << ")"; | 86 os << "Class(" << static_cast<void*>(*AsClass()) << ")"; |
98 } | 87 } |
99 } | 88 } |
100 | 89 |
101 } // namespace internal | 90 } // namespace internal |
102 } // namespace v8 | 91 } // namespace v8 |
OLD | NEW |