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/objects.h"
9#include "src/objects/heap-object.h"
10#include "src/objects/map.h"
11
12namespace v8 {
13namespace internal {
14
15template <typename T>
16class Handle;
17
18class 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);
28 static FieldType unchecked_cast(Object object) {
29 return FieldType(object.ptr());
30 }
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 bool IsNone() const { return *this == None(); }
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 void PrintTo(std::ostream& os) const;
45
46 FieldType* operator->() { return this; }
47 const FieldType* operator->() const { return this; }
48
49 private:
50 explicit constexpr FieldType(Address ptr) : Object(ptr) {}
51};
52
53} // namespace internal
54} // namespace v8
55
56#endif // V8_FIELD_TYPE_H_
57