property.h 2.49 KB
Newer Older
1 2 3
// Copyright 2014 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.
4 5 6 7

#ifndef V8_PROPERTY_H_
#define V8_PROPERTY_H_

8 9
#include <iosfwd>

10 11
#include "src/globals.h"
#include "src/handles.h"
12
#include "src/maybe-handles.h"
13 14 15
#include "src/objects.h"
#include "src/objects/name.h"
#include "src/property-details.h"
16

17 18
namespace v8 {
namespace internal {
19 20 21 22 23 24

// Abstraction for elements in instance-descriptor arrays.
//
// Each descriptor has a key, property attributes, property type,
// property index (in the actual instance-descriptor array) and
// optionally a piece of data.
25
class Descriptor final {
26
 public:
27
  Descriptor();
28

29
  Handle<Name> GetKey() const { return key_; }
30
  MaybeObjectHandle GetValue() const { return value_; }
31
  PropertyDetails GetDetails() const { return details_; }
32

33
  void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
34

35 36
  static Descriptor DataField(Isolate* isolate, Handle<Name> key,
                              int field_index, PropertyAttributes attributes,
37 38 39 40
                              Representation representation);

  static Descriptor DataField(Handle<Name> key, int field_index,
                              PropertyAttributes attributes,
41 42
                              PropertyConstness constness,
                              Representation representation,
43
                              const MaybeObjectHandle& wrapped_field_type);
44 45

  static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
46
                                 PropertyAttributes attributes);
47

48 49
  static Descriptor DataConstant(Isolate* isolate, Handle<Name> key,
                                 int field_index, Handle<Object> value,
50 51
                                 PropertyAttributes attributes);

52
  static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign,
53
                                     PropertyAttributes attributes);
54

55
 private:
56
  Handle<Name> key_;
57
  MaybeObjectHandle value_;
58 59 60
  PropertyDetails details_;

 protected:
61
  Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
62
             PropertyDetails details);
63

64 65 66 67
  Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
             PropertyKind kind, PropertyAttributes attributes,
             PropertyLocation location, PropertyConstness constness,
             Representation representation, int field_index);
68

69
  friend class MapUpdater;
70 71
};

72 73
}  // namespace internal
}  // namespace v8
74 75

#endif  // V8_PROPERTY_H_