| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PROPERTY_DESCRIPTOR_H_ | 5 #ifndef V8_PROPERTY_DESCRIPTOR_H_ |
| 6 #define V8_PROPERTY_DESCRIPTOR_H_ | 6 #define V8_PROPERTY_DESCRIPTOR_H_ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/property-details.h" | 10 #include "src/property-details.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // ES6 6.2.4.2 | 34 // ES6 6.2.4.2 |
| 35 static bool IsDataDescriptor(PropertyDescriptor* desc) { | 35 static bool IsDataDescriptor(PropertyDescriptor* desc) { |
| 36 return desc->has_value() || desc->has_writable(); | 36 return desc->has_value() || desc->has_writable(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // ES6 6.2.4.3 | 39 // ES6 6.2.4.3 |
| 40 static bool IsGenericDescriptor(PropertyDescriptor* desc) { | 40 static bool IsGenericDescriptor(PropertyDescriptor* desc) { |
| 41 return !IsAccessorDescriptor(desc) && !IsDataDescriptor(desc); | 41 return !IsAccessorDescriptor(desc) && !IsDataDescriptor(desc); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // ES6 6.2.4.4 |
| 45 Handle<Object> ToObject(Isolate* isolate); |
| 46 |
| 47 // ES6 6.2.4.5 |
| 48 static bool ToPropertyDescriptor(Isolate* isolate, Handle<Object> obj, |
| 49 PropertyDescriptor* desc); |
| 50 |
| 51 // ES6 6.2.4.6 |
| 52 static void CompletePropertyDescriptor(Isolate* isolate, |
| 53 PropertyDescriptor* desc); |
| 54 |
| 44 bool is_empty() const { | 55 bool is_empty() const { |
| 45 return !has_enumerable() && !has_configurable() && !has_writable() && | 56 return !has_enumerable() && !has_configurable() && !has_writable() && |
| 46 !has_value() && !has_get() && !has_set(); | 57 !has_value() && !has_get() && !has_set(); |
| 47 } | 58 } |
| 48 | 59 |
| 49 bool enumerable() const { return enumerable_; } | 60 bool enumerable() const { return enumerable_; } |
| 50 void set_enumerable(bool enumerable) { | 61 void set_enumerable(bool enumerable) { |
| 51 enumerable_ = enumerable; | 62 enumerable_ = enumerable; |
| 52 has_enumerable_ = true; | 63 has_enumerable_ = true; |
| 53 } | 64 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 82 Handle<Object> name() const { return name_; } | 93 Handle<Object> name() const { return name_; } |
| 83 void set_name(Handle<Object> name) { name_ = name; } | 94 void set_name(Handle<Object> name) { name_ = name; } |
| 84 | 95 |
| 85 PropertyAttributes ToAttributes() { | 96 PropertyAttributes ToAttributes() { |
| 86 return static_cast<PropertyAttributes>( | 97 return static_cast<PropertyAttributes>( |
| 87 (has_enumerable() && !enumerable() ? DONT_ENUM : NONE) | | 98 (has_enumerable() && !enumerable() ? DONT_ENUM : NONE) | |
| 88 (has_configurable() && !configurable() ? DONT_DELETE : NONE) | | 99 (has_configurable() && !configurable() ? DONT_DELETE : NONE) | |
| 89 (has_writable() && !writable() ? READ_ONLY : NONE)); | 100 (has_writable() && !writable() ? READ_ONLY : NONE)); |
| 90 } | 101 } |
| 91 | 102 |
| 92 Handle<Object> ToObject(Isolate* isolate); | |
| 93 | |
| 94 static bool ToPropertyDescriptor(Isolate* isolate, Handle<Object> obj, | |
| 95 PropertyDescriptor* desc); | |
| 96 | |
| 97 private: | 103 private: |
| 98 bool enumerable_ : 1; | 104 bool enumerable_ : 1; |
| 99 bool has_enumerable_ : 1; | 105 bool has_enumerable_ : 1; |
| 100 bool configurable_ : 1; | 106 bool configurable_ : 1; |
| 101 bool has_configurable_ : 1; | 107 bool has_configurable_ : 1; |
| 102 bool writable_ : 1; | 108 bool writable_ : 1; |
| 103 bool has_writable_ : 1; | 109 bool has_writable_ : 1; |
| 104 Handle<Object> value_; | 110 Handle<Object> value_; |
| 105 Handle<Object> get_; | 111 Handle<Object> get_; |
| 106 Handle<Object> set_; | 112 Handle<Object> set_; |
| 107 Handle<Object> name_; | 113 Handle<Object> name_; |
| 108 | 114 |
| 109 // Some compilers (Xcode 5.1, ARM GCC 4.9) insist on having a copy | 115 // Some compilers (Xcode 5.1, ARM GCC 4.9) insist on having a copy |
| 110 // constructor for std::vector<PropertyDescriptor>, so we can't | 116 // constructor for std::vector<PropertyDescriptor>, so we can't |
| 111 // DISALLOW_COPY_AND_ASSIGN(PropertyDescriptor); here. | 117 // DISALLOW_COPY_AND_ASSIGN(PropertyDescriptor); here. |
| 112 }; | 118 }; |
| 113 | 119 |
| 114 } // namespace internal | 120 } // namespace internal |
| 115 } // namespace v8 | 121 } // namespace v8 |
| 116 | 122 |
| 117 #endif // V8_PROPERTY_DESCRIPTOR_H_ | 123 #endif // V8_PROPERTY_DESCRIPTOR_H_ |
| OLD | NEW |