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

Unified Diff: src/runtime/runtime-object.cc

Issue 2620943002: [ESnext] Implement Object Rest (Closed)
Patch Set: add todo and test Created 3 years, 11 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
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index d1e57c00dd93577db40e91c9bcd8bc0ab086c896..0c3e1069db9edf41b5358528a71f964ba11ad21a 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -768,7 +768,7 @@ RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) {
RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
HandleScope scope(isolate);
- DCHECK(args.length() == 2);
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, source, 1);
@@ -777,12 +777,32 @@ RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
return isolate->heap()->undefined_value();
}
- MAYBE_RETURN(
- JSReceiver::SetOrCopyDataProperties(isolate, target, source, false),
- isolate->heap()->exception());
+ MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
+ nullptr, false),
+ isolate->heap()->exception());
return isolate->heap()->undefined_value();
}
+RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
+ HandleScope scope(isolate);
+ DCHECK_LE(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, source, 0);
+
+ Arguments excluded_properties(1, args.arguments() - 1);
adamk 2017/01/12 22:43:08 Passing 1 for length here seems wrong, how does th
gsathya 2017/01/17 19:28:59 Done.
+
+ // 2. If source is undefined or null, let keys be an empty List.
+ if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
+ return isolate->heap()->undefined_value();
+ }
+
+ Handle<JSObject> target =
+ isolate->factory()->NewJSObject(isolate->object_function());
+ MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
+ &excluded_properties, false),
+ isolate->heap()->exception());
+ return *target;
+}
+
RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
HandleScope scope(isolate);
DCHECK_EQ(4, args.length());

Powered by Google App Engine
This is Rietveld 408576698