field-type.h 1.45 KB
Newer Older
1 2 3 4 5 6 7 8
// 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.

#ifndef V8_FIELD_TYPE_H_
#define V8_FIELD_TYPE_H_

#include "src/objects.h"
9
#include "src/objects/heap-object.h"
10
#include "src/objects/map.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
  static Handle<FieldType> None(Isolate* isolate);
  static Handle<FieldType> Any(Isolate* isolate);
24
  static FieldType Class(Map map);
25
  static Handle<FieldType> Class(Handle<Map> map, Isolate* isolate);
26
  static FieldType cast(Object object);
27
  static FieldType unchecked_cast(Object object) {
28 29
    return FieldType(object.ptr());
  }
30

31
  bool NowContains(Object value) const;
32

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

35
  bool IsClass() const;
36
  Map AsClass() const;
37 38 39 40 41
  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;
42

43 44 45 46 47 48
  void PrintTo(std::ostream& os) const;

  FieldType* operator->() { return this; }
  const FieldType* operator->() const { return this; }

 private:
49
  explicit constexpr FieldType(Address ptr) : Object(ptr) {}
50 51 52 53 54 55
};

}  // namespace internal
}  // namespace v8

#endif  // V8_FIELD_TYPE_H_