Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: src/property-descriptor.h

Issue 1368753003: Add C++ implementation of Object.defineProperties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: refactored Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_DESCRIPTOR_H_
6 #define V8_PROPERTY_DESCRIPTOR_H_
7
8
9 #include "src/handles.h"
10 #include "src/objects.h"
11 #include "src/property-details.h"
Toon Verwaest 2015/10/06 15:55:19 Can we get away with including less (especially ob
Jakob Kummerow 2015/10/09 13:46:12 Done. I can forward-declare Isolate and Object, el
12
13
14 namespace v8 {
15 namespace internal {
16
17 class PropertyDescriptor {
18 public:
19 PropertyDescriptor()
20 : enumerable_(false),
21 has_enumerable_(false),
22 configurable_(false),
23 has_configurable_(false),
24 writable_(false),
25 has_writable_(false) {}
26
27 // ES6 6.2.4.1
28 static bool IsAccessorDescriptor(PropertyDescriptor* desc) {
29 return desc->has_get() || desc->has_set();
30 }
31
32 // ES6 6.2.4.2
33 static bool IsDataDescriptor(PropertyDescriptor* desc) {
34 return desc->has_value() || desc->has_writable();
35 }
36
37 // ES6 6.2.4.3
38 static bool IsGenericDescriptor(PropertyDescriptor* desc) {
39 return !IsAccessorDescriptor(desc) && !IsDataDescriptor(desc);
40 }
41
42 bool is_empty() const {
43 return !has_enumerable() && !has_configurable() && !has_writable() &&
44 !has_value() && !has_get() && !has_set();
45 }
46
47 bool enumerable() const { return enumerable_; }
48 void set_enumerable(bool enumerable) {
49 enumerable_ = enumerable;
50 has_enumerable_ = true;
51 }
52 bool has_enumerable() const { return has_enumerable_; }
53
54 bool configurable() const { return configurable_; }
55 void set_configurable(bool configurable) {
56 configurable_ = configurable;
57 has_configurable_ = true;
58 }
59 bool has_configurable() const { return has_configurable_; }
60
61 Handle<Object> value() const { return value_; }
62 void set_value(Handle<Object> value) { value_ = value; }
63 bool has_value() const { return !value_.is_null(); }
64
65 bool writable() const { return writable_; }
66 void set_writable(bool writable) {
67 writable_ = writable;
68 has_writable_ = true;
69 }
70 bool has_writable() const { return has_writable_; }
71
72 Handle<Object> get() const { return get_; }
73 void set_get(Handle<Object> get) { get_ = get; }
74 bool has_get() const { return !get_.is_null(); }
75
76 Handle<Object> set() const { return set_; }
77 void set_set(Handle<Object> set) { set_ = set; }
78 bool has_set() const { return !set_.is_null(); }
79
80 Handle<Object> name() const { return name_; }
81 void set_name(Handle<Object> name) { name_ = name; }
82
83 PropertyAttributes ToAttributes() {
84 return static_cast<PropertyAttributes>(
85 (has_enumerable() && !enumerable() ? DONT_ENUM : NONE) |
86 (has_configurable() && !configurable() ? DONT_DELETE : NONE) |
87 (has_writable() && !writable() ? READ_ONLY : NONE));
88 }
89
90 static bool ToPropertyDescriptor(Isolate* isolate, Handle<Object> obj,
91 PropertyDescriptor* desc);
92
93 private:
94 bool enumerable_ : 1;
95 bool has_enumerable_ : 1;
96 bool configurable_ : 1;
97 bool has_configurable_ : 1;
98 bool writable_ : 1;
99 bool has_writable_ : 1;
100 Handle<Object> value_;
101 Handle<Object> get_;
102 Handle<Object> set_;
103 Handle<Object> name_;
104
105 DISALLOW_COPY_AND_ASSIGN(PropertyDescriptor);
106 };
107
108 } // namespace internal
109 } // namespace v8
110
111 #endif // V8_PROPERTY_DESCRIPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698