• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_OBJECTS_FIELD_TYPE_H_
6 #define V8_OBJECTS_FIELD_TYPE_H_
7 
8 #include "src/objects/heap-object.h"
9 #include "src/objects/map.h"
10 #include "src/objects/objects.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 template <typename T>
16 class Handle;
17 
18 class FieldType : public Object {
19  public:
20   static FieldType None();
21   static FieldType Any();
22   V8_EXPORT_PRIVATE static Handle<FieldType> None(Isolate* isolate);
23   V8_EXPORT_PRIVATE static Handle<FieldType> Any(Isolate* isolate);
24   V8_EXPORT_PRIVATE static FieldType Class(Map map);
25   V8_EXPORT_PRIVATE static Handle<FieldType> Class(Handle<Map> map,
26                                                    Isolate* isolate);
27   V8_EXPORT_PRIVATE static FieldType cast(Object object);
unchecked_cast(Object object)28   static FieldType unchecked_cast(Object object) {
29     return FieldType(object.ptr());
30   }
31 
32   bool NowContains(Object value) const;
33 
NowContains(Handle<Object> value)34   bool NowContains(Handle<Object> value) const { return NowContains(*value); }
35 
36   bool IsClass() const;
37   Map AsClass() const;
IsNone()38   bool IsNone() const { return *this == None(); }
IsAny()39   bool IsAny() const { return *this == Any(); }
40   bool NowStable() const;
41   bool NowIs(FieldType other) const;
42   bool NowIs(Handle<FieldType> other) const;
43 
44   V8_EXPORT_PRIVATE bool Equals(FieldType other) const;
45   V8_EXPORT_PRIVATE void PrintTo(std::ostream& os) const;
46 
47  private:
FieldType(Address ptr)48   explicit constexpr FieldType(Address ptr) : Object(ptr) {}
49 };
50 
51 }  // namespace internal
52 }  // namespace v8
53 
54 #endif  // V8_OBJECTS_FIELD_TYPE_H_
55