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

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: See comment. 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..0600697ff018933ccaca2f581144695ca548eee8 100644
--- a/src/property-descriptor.cc
+++ b/src/property-descriptor.cc
@@ -101,6 +101,40 @@ bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj,
}
+static void CreateDataProperty(Isolate* isolate, Handle<JSObject> object,
+ const char* name, Handle<Object> value) {
+ LookupIterator it(object,
+ isolate->factory()->NewStringFromAsciiChecked(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)));
+ Handle<JSObject> result =
+ isolate->factory()->NewJSObject(isolate->object_function());
+ if (has_value()) CreateDataProperty(isolate, result, "value", value());
Jakob Kummerow 2015/10/29 18:06:02 Instead of "value", please use isolate->factory()-
neis 2015/10/30 08:41:30 Done.
+ if (has_writable()) {
+ CreateDataProperty(isolate, result, "writable",
+ isolate->factory()->ToBoolean(writable()));
+ }
+ if (has_get()) CreateDataProperty(isolate, result, "get", get());
+ if (has_set()) CreateDataProperty(isolate, result, "set", set());
+ if (has_enumerable()) {
+ CreateDataProperty(isolate, result, "enumerable",
+ isolate->factory()->ToBoolean(enumerable()));
+ }
+ if (has_configurable()) {
+ CreateDataProperty(isolate, result, "configurable",
+ isolate->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