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

Unified Diff: src/lookup.h

Issue 1368753003: Add C++ implementation of Object.defineProperties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: preview -- needs refactoring 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/heap/heap.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lookup.h
diff --git a/src/lookup.h b/src/lookup.h
index 3888ed624057231fd1d8266363ed6abf888849be..197987d684d73b901dee6582aaeab850f247f532 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -133,16 +133,31 @@ class LookupIterator final BASE_EMBEDDED {
}
static LookupIterator PropertyOrElement(
- Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
+ Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
Configuration configuration = DEFAULT) {
- name = Name::Flatten(name);
+ DCHECK(name->IsName() || name->IsNumber());
+
uint32_t index;
- LookupIterator it =
- name->AsArrayIndex(&index)
- ? LookupIterator(isolate, receiver, index, configuration)
- : LookupIterator(receiver, name, configuration);
- it.name_ = name;
- return it;
+ bool is_index = false;
+ if (name->IsNumber()) {
+ if (name->ToArrayIndex(&index)) {
+ is_index = true;
+ } else {
+ name = isolate->factory()->NumberToString(name);
+ }
+ } else {
+ DCHECK(name->IsName());
+ name = Name::Flatten(Handle<Name>::cast(name));
+ is_index = Handle<Name>::cast(name)->AsArrayIndex(&index);
+ }
+ 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);
+ return it;
+ }
}
static LookupIterator PropertyOrElement(
« no previous file with comments | « src/heap/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698