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

Unified Diff: src/lookup.cc

Issue 1375943002: Add LookupIterator constructor for arbitrary Object keys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/lookup.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index 809c35e4a5339354bc9dd1bc7cb3e2e9530cbbfc..e545063172d498312a2d77c646599d68b20d29c8 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -13,6 +13,43 @@ namespace v8 {
namespace internal {
+// static
+LookupIterator LookupIterator::PropertyOrElement(Isolate* isolate,
+ Handle<Object> receiver,
+ Handle<Object> name,
Toon Verwaest 2015/09/30 13:02:33 What about calling this key?
Jakob Kummerow 2015/09/30 14:27:32 Done.
+ bool* success,
+ Configuration configuration) {
+ uint32_t index = 0;
+ bool is_index = false;
+ if (name->IsNumber()) {
Toon Verwaest 2015/09/30 13:02:34 What about a slightly less branchy version: uint3
Jakob Kummerow 2015/09/30 14:27:31 Nice simplification. Done.
+ if (name->ToArrayIndex(&index)) {
+ is_index = true;
+ } else {
+ name = isolate->factory()->NumberToString(name);
+ }
+ } else {
+ if (!Object::ToName(isolate, name).ToHandle(&name)) {
+ DCHECK(isolate->has_pending_exception());
+ *success = false;
+ // Return an unusable dummy.
+ return LookupIterator(receiver, isolate->factory()->empty_string());
+ }
+ DCHECK(name->IsName());
+ name = Name::Flatten(Handle<Name>::cast(name));
+ is_index = Handle<Name>::cast(name)->AsArrayIndex(&index);
+ }
+ *success = true;
+ if (is_index) {
+ return LookupIterator(isolate, receiver, index, configuration);
+ } else {
+ DCHECK(name->IsName());
+ LookupIterator it(receiver, Handle<Name>::cast(name), configuration);
+ it.name_ = Handle<Name>::cast(name);
Toon Verwaest 2015/09/30 13:02:33 You don't need to set the .name_ if you know it's
Jakob Kummerow 2015/09/30 14:27:32 Done. (Not sure why that was there... probably an
+ return it;
+ }
+}
+
+
void LookupIterator::Next() {
DCHECK_NE(JSPROXY, state_);
DCHECK_NE(TRANSITION, state_);
« no previous file with comments | « src/lookup.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698