OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LOOKUP_H_ | 5 #ifndef V8_LOOKUP_H_ |
6 #define V8_LOOKUP_H_ | 6 #define V8_LOOKUP_H_ |
7 | 7 |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 holder_(holder), | 126 holder_(holder), |
127 holder_map_(holder_->map(), isolate_), | 127 holder_map_(holder_->map(), isolate_), |
128 initial_holder_(holder_), | 128 initial_holder_(holder_), |
129 number_(DescriptorArray::kNotFound) { | 129 number_(DescriptorArray::kNotFound) { |
130 // kMaxUInt32 isn't a valid index. | 130 // kMaxUInt32 isn't a valid index. |
131 DCHECK_NE(kMaxUInt32, index_); | 131 DCHECK_NE(kMaxUInt32, index_); |
132 Next(); | 132 Next(); |
133 } | 133 } |
134 | 134 |
135 static LookupIterator PropertyOrElement( | 135 static LookupIterator PropertyOrElement( |
136 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, | 136 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, |
137 Configuration configuration = DEFAULT) { | 137 Configuration configuration = DEFAULT) { |
138 name = Name::Flatten(name); | 138 DCHECK(name->IsName() || name->IsNumber()); |
| 139 |
139 uint32_t index; | 140 uint32_t index; |
140 LookupIterator it = | 141 bool is_index = false; |
141 name->AsArrayIndex(&index) | 142 if (name->IsNumber()) { |
142 ? LookupIterator(isolate, receiver, index, configuration) | 143 if (name->ToArrayIndex(&index)) { |
143 : LookupIterator(receiver, name, configuration); | 144 is_index = true; |
144 it.name_ = name; | 145 } else { |
145 return it; | 146 name = isolate->factory()->NumberToString(name); |
| 147 } |
| 148 } else { |
| 149 DCHECK(name->IsName()); |
| 150 name = Name::Flatten(Handle<Name>::cast(name)); |
| 151 is_index = Handle<Name>::cast(name)->AsArrayIndex(&index); |
| 152 } |
| 153 if (is_index) { |
| 154 return LookupIterator(isolate, receiver, index, configuration); |
| 155 } else { |
| 156 DCHECK(name->IsName()); |
| 157 LookupIterator it(receiver, Handle<Name>::cast(name), configuration); |
| 158 it.name_ = Handle<Name>::cast(name); |
| 159 return it; |
| 160 } |
146 } | 161 } |
147 | 162 |
148 static LookupIterator PropertyOrElement( | 163 static LookupIterator PropertyOrElement( |
149 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, | 164 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, |
150 Handle<JSReceiver> holder, Configuration configuration = DEFAULT) { | 165 Handle<JSReceiver> holder, Configuration configuration = DEFAULT) { |
151 name = Name::Flatten(name); | 166 name = Name::Flatten(name); |
152 uint32_t index; | 167 uint32_t index; |
153 LookupIterator it = | 168 LookupIterator it = |
154 name->AsArrayIndex(&index) | 169 name->AsArrayIndex(&index) |
155 ? LookupIterator(isolate, receiver, index, holder, configuration) | 170 ? LookupIterator(isolate, receiver, index, holder, configuration) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 Handle<JSReceiver> holder_; | 327 Handle<JSReceiver> holder_; |
313 Handle<Map> holder_map_; | 328 Handle<Map> holder_map_; |
314 const Handle<JSReceiver> initial_holder_; | 329 const Handle<JSReceiver> initial_holder_; |
315 uint32_t number_; | 330 uint32_t number_; |
316 }; | 331 }; |
317 | 332 |
318 | 333 |
319 } } // namespace v8::internal | 334 } } // namespace v8::internal |
320 | 335 |
321 #endif // V8_LOOKUP_H_ | 336 #endif // V8_LOOKUP_H_ |
OLD | NEW |