field-type.h 1.59 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_OBJECTS_FIELD_TYPE_H_
#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 13 14

namespace v8 {
namespace internal {

marja's avatar
marja committed
15 16 17
template <typename T>
class Handle;

18
class FieldType : public Object {
19
 public:
20 21
  static FieldType None();
  static FieldType Any();
22 23 24 25 26 27
  V8_EXPORT_PRIVATE static Handle<FieldType> None(Isolate* isolate);
  V8_EXPORT_PRIVATE static Handle<FieldType> Any(Isolate* isolate);
  V8_EXPORT_PRIVATE static FieldType Class(Map map);
  V8_EXPORT_PRIVATE static Handle<FieldType> Class(Handle<Map> map,
                                                   Isolate* isolate);
  V8_EXPORT_PRIVATE static FieldType cast(Object object);
28
  static FieldType unchecked_cast(Object object) {
29 30
    return FieldType(object.ptr());
  }
31

32
  bool NowContains(Object value) const;
33

34
  bool NowContains(Handle<Object> value) const { return NowContains(*value); }
35

36
  bool IsClass() const;
37
  Map AsClass() const;
38 39 40 41 42
  bool IsNone() const { return *this == None(); }
  bool IsAny() const { return *this == Any(); }
  bool NowStable() const;
  bool NowIs(FieldType other) const;
  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:
48
  explicit constexpr FieldType(Address ptr) : Object(ptr) {}
49 50 51 52 53
};

}  // namespace internal
}  // namespace v8

54
#endif  // V8_OBJECTS_FIELD_TYPE_H_