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