• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_PROPERTY_H_
6 #define V8_PROPERTY_H_
7 
8 #include <iosfwd>
9 
10 #include "src/globals.h"
11 #include "src/handles.h"
12 #include "src/maybe-handles.h"
13 #include "src/objects.h"
14 #include "src/objects/name.h"
15 #include "src/property-details.h"
16 
17 namespace v8 {
18 namespace internal {
19 
20 // Abstraction for elements in instance-descriptor arrays.
21 //
22 // Each descriptor has a key, property attributes, property type,
23 // property index (in the actual instance-descriptor array) and
24 // optionally a piece of data.
25 class Descriptor final BASE_EMBEDDED {
26  public:
27   Descriptor();
28 
GetKey()29   Handle<Name> GetKey() const { return key_; }
GetValue()30   MaybeObjectHandle GetValue() const { return value_; }
GetDetails()31   PropertyDetails GetDetails() const { return details_; }
32 
SetSortedKeyIndex(int index)33   void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
34 
35   static Descriptor DataField(Isolate* isolate, Handle<Name> key,
36                               int field_index, PropertyAttributes attributes,
37                               Representation representation);
38 
39   static Descriptor DataField(Handle<Name> key, int field_index,
40                               PropertyAttributes attributes,
41                               PropertyConstness constness,
42                               Representation representation,
43                               MaybeObjectHandle wrapped_field_type);
44 
45   static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
46                                  PropertyAttributes attributes);
47 
48   static Descriptor DataConstant(Isolate* isolate, Handle<Name> key,
49                                  int field_index, Handle<Object> value,
50                                  PropertyAttributes attributes);
51 
52   static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign,
53                                      PropertyAttributes attributes);
54 
55  private:
56   Handle<Name> key_;
57   MaybeObjectHandle value_;
58   PropertyDetails details_;
59 
60  protected:
61   Descriptor(Handle<Name> key, MaybeObjectHandle value,
62              PropertyDetails details);
63 
64   Descriptor(Handle<Name> key, MaybeObjectHandle value, PropertyKind kind,
65              PropertyAttributes attributes, PropertyLocation location,
66              PropertyConstness constness, Representation representation,
67              int field_index);
68 
69   friend class MapUpdater;
70 };
71 
72 }  // namespace internal
73 }  // namespace v8
74 
75 #endif  // V8_PROPERTY_H_
76