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 #ifndef V8_FIELD_TYPE_H_ | 5 #ifndef V8_FIELD_TYPE_H_ |
6 #define V8_FIELD_TYPE_H_ | 6 #define V8_FIELD_TYPE_H_ |
7 | 7 |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 #include "src/ostreams.h" | 10 #include "src/ostreams.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class FieldType : public Object { | 15 class FieldType : public Object { |
16 public: | 16 public: |
17 static FieldType* None(); | 17 static FieldType* None(); |
18 static FieldType* Any(); | 18 static FieldType* Any(); |
19 static Handle<FieldType> None(Isolate* isolate); | 19 static Handle<FieldType> None(Isolate* isolate); |
20 static Handle<FieldType> Any(Isolate* isolate); | 20 static Handle<FieldType> Any(Isolate* isolate); |
21 static FieldType* Class(i::Map* map); | 21 static FieldType* Class(i::Map* map); |
22 static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate); | 22 static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate); |
23 static FieldType* cast(Object* object); | 23 static FieldType* cast(Object* object); |
24 | 24 |
25 bool NowContains(Object* value); | 25 bool NowContains(Object* value) { |
26 bool NowContains(Handle<Object> value); | 26 if (this == Any()) return true; |
| 27 if (this == None()) return false; |
| 28 if (!value->IsHeapObject()) return false; |
| 29 return HeapObject::cast(value)->map() == Map::cast(this); |
| 30 } |
| 31 |
| 32 bool NowContains(Handle<Object> value) { return NowContains(*value); } |
| 33 |
27 bool IsClass(); | 34 bool IsClass(); |
28 Handle<i::Map> AsClass(); | 35 Handle<i::Map> AsClass(); |
29 bool IsNone() { return this == None(); } | 36 bool IsNone() { return this == None(); } |
30 bool IsAny() { return this == Any(); } | 37 bool IsAny() { return this == Any(); } |
31 bool NowStable(); | 38 bool NowStable(); |
32 bool NowIs(FieldType* other); | 39 bool NowIs(FieldType* other); |
33 bool NowIs(Handle<FieldType> other); | 40 bool NowIs(Handle<FieldType> other); |
34 Type* Convert(Zone* zone); | 41 Type* Convert(Zone* zone); |
35 | 42 |
36 void PrintTo(std::ostream& os); | 43 void PrintTo(std::ostream& os); |
37 }; | 44 }; |
38 | 45 |
39 } // namespace internal | 46 } // namespace internal |
40 } // namespace v8 | 47 } // namespace v8 |
41 | 48 |
42 #endif // V8_FIELD_TYPE_H_ | 49 #endif // V8_FIELD_TYPE_H_ |
OLD | NEW |