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

Unified Diff: src/property-descriptor.cc

Issue 1408163005: [es6] Partially implement Reflect.getOwnPropertyDescriptor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/property-descriptor.h ('k') | test/mjsunit/harmony/reflect.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/property-descriptor.cc
diff --git a/src/property-descriptor.cc b/src/property-descriptor.cc
index 2ecf75a74e593f37587ffb337d81bbe4e8b3dd68..8c8dfa4f4ac74445c3336b095fe0c9cb26957439 100644
--- a/src/property-descriptor.cc
+++ b/src/property-descriptor.cc
@@ -101,6 +101,45 @@ bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj,
}
+static void CreateDataProperty(Isolate* isolate, Handle<JSObject> object,
+ Handle<String> name, Handle<Object> value) {
+ LookupIterator it(object, name);
+ Maybe<bool> result = JSObject::CreateDataProperty(&it, value);
+ CHECK(result.IsJust() && result.FromJust());
+}
+
+
+// ES6 6.2.4.4 "FromPropertyDescriptor"
+Handle<Object> PropertyDescriptor::ToObject(Isolate* isolate) {
+ DCHECK(!(PropertyDescriptor::IsAccessorDescriptor(this) &&
+ PropertyDescriptor::IsDataDescriptor(this)));
+ Factory* factory = isolate->factory();
+ Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
+ if (has_value()) {
+ CreateDataProperty(isolate, result, factory->value_string(), value());
+ }
+ if (has_writable()) {
+ CreateDataProperty(isolate, result, factory->writable_string(),
+ factory->ToBoolean(writable()));
+ }
+ if (has_get()) {
+ CreateDataProperty(isolate, result, factory->get_string(), get());
+ }
+ if (has_set()) {
+ CreateDataProperty(isolate, result, factory->set_string(), set());
+ }
+ if (has_enumerable()) {
+ CreateDataProperty(isolate, result, factory->enumerable_string(),
+ factory->ToBoolean(enumerable()));
+ }
+ if (has_configurable()) {
+ CreateDataProperty(isolate, result, factory->configurable_string(),
+ factory->ToBoolean(configurable()));
+ }
+ return result;
+}
+
+
// ES6 6.2.4.5
// Returns false in case of exception.
// static
« no previous file with comments | « src/property-descriptor.h ('k') | test/mjsunit/harmony/reflect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698