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

Unified Diff: src/objects-inl.h

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/objects.cc ('k') | src/property-descriptor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 9112702685a5a70c4821e22e764f29da967b5f62..cd47b5e62b0944d7fa7c12591de6b429721322a5 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1053,6 +1053,13 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
return GetProperty(&it);
}
+MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
+ Handle<Name> name) {
+ LookupIterator it(receiver, name, receiver);
+ if (!it.IsFound()) return it.factory()->undefined_value();
+ return Object::GetProperty(&it);
+}
+
MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
uint32_t index) {
LookupIterator it(isolate, object, index);
@@ -1060,6 +1067,14 @@ MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
return GetProperty(&it);
}
+MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
+ Handle<JSReceiver> receiver,
+ uint32_t index) {
+ LookupIterator it(isolate, receiver, index, receiver);
+ if (!it.IsFound()) return it.factory()->undefined_value();
+ return Object::GetProperty(&it);
+}
+
Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
Handle<Name> name) {
LookupIterator it(object, name, object,
@@ -1090,10 +1105,11 @@ MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
return PrototypeIterator::GetCurrent(iter);
}
-MaybeHandle<Object> Object::GetProperty(Isolate* isolate, Handle<Object> object,
- const char* name) {
+MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
+ Handle<JSReceiver> receiver,
+ const char* name) {
Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
- return GetProperty(object, str);
+ return GetProperty(receiver, str);
}
« no previous file with comments | « src/objects.cc ('k') | src/property-descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698