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

8
#include "src/ast/ast-types.h"
9 10 11 12 13 14
#include "src/objects.h"
#include "src/ostreams.h"

namespace v8 {
namespace internal {

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

18 19 20 21 22 23 24 25 26 27
class FieldType : public Object {
 public:
  static FieldType* None();
  static FieldType* Any();
  static Handle<FieldType> None(Isolate* isolate);
  static Handle<FieldType> Any(Isolate* isolate);
  static FieldType* Class(i::Map* map);
  static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate);
  static FieldType* cast(Object* object);

28 29 30 31 32 33 34 35 36
  bool NowContains(Object* value) {
    if (this == Any()) return true;
    if (this == None()) return false;
    if (!value->IsHeapObject()) return false;
    return HeapObject::cast(value)->map() == Map::cast(this);
  }

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

37 38 39 40 41 42 43
  bool IsClass();
  Handle<i::Map> AsClass();
  bool IsNone() { return this == None(); }
  bool IsAny() { return this == Any(); }
  bool NowStable();
  bool NowIs(FieldType* other);
  bool NowIs(Handle<FieldType> other);
44
  AstType* Convert(Zone* zone);
45 46 47 48 49 50 51 52

  void PrintTo(std::ostream& os);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_FIELD_TYPE_H_