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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/runtime/runtime-utils.h" | 8 #include "src/runtime/runtime-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 * The visitor argument called for each existing element in the array | 446 * The visitor argument called for each existing element in the array |
447 * with the element index and the element's value. | 447 * with the element index and the element's value. |
448 * Afterwards it increments the base-index of the visitor by the array | 448 * Afterwards it increments the base-index of the visitor by the array |
449 * length. | 449 * length. |
450 * Returns false if any access threw an exception, otherwise true. | 450 * Returns false if any access threw an exception, otherwise true. |
451 */ | 451 */ |
452 static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver, | 452 static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver, |
453 ArrayConcatVisitor* visitor) { | 453 ArrayConcatVisitor* visitor) { |
454 uint32_t length = 0; | 454 uint32_t length = 0; |
455 | 455 |
456 if (receiver->IsJSValue()) { | |
457 Handle<Object> value(Handle<JSValue>::cast(receiver)->value(), isolate); | |
458 if (value->IsString()) { | |
459 receiver = | |
460 i::Runtime::StringToArray(isolate, Handle<String>::cast(value)); | |
461 } else { | |
462 // Other wrapped types are not array-like. | |
caitp (gmail)
2014/12/16 06:16:25
I don't think this is really the right thing to do
Dmitry Lomov (no reviews)
2014/12/16 07:27:30
The following needs to be made to work:
Number.pro
| |
463 return true; | |
464 } | |
465 } | |
466 | |
456 if (receiver->IsJSArray()) { | 467 if (receiver->IsJSArray()) { |
457 Handle<JSArray> array(Handle<JSArray>::cast(receiver)); | 468 Handle<JSArray> array(Handle<JSArray>::cast(receiver)); |
458 length = static_cast<uint32_t>(array->length()->Number()); | 469 length = static_cast<uint32_t>(array->length()->Number()); |
459 } else { | 470 } else { |
460 Handle<Object> val; | 471 Handle<Object> val; |
461 Handle<Object> key(isolate->heap()->length_string(), isolate); | 472 Handle<Object> key(isolate->heap()->length_string(), isolate); |
462 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, val, | 473 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, val, |
463 Runtime::GetObjectProperty(isolate, receiver, key), false); | 474 Runtime::GetObjectProperty(isolate, receiver, key), false); |
464 // TODO(caitp): Support larger element indexes (up to 2^53-1). | 475 // TODO(caitp): Support larger element indexes (up to 2^53-1). |
465 if (!val->ToUint32(&length)) { | 476 if (!val->ToUint32(&length)) { |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 } | 1294 } |
1284 | 1295 |
1285 | 1296 |
1286 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { | 1297 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { |
1287 SealHandleScope shs(isolate); | 1298 SealHandleScope shs(isolate); |
1288 DCHECK(args.length() == 2); | 1299 DCHECK(args.length() == 2); |
1289 return isolate->heap()->undefined_value(); | 1300 return isolate->heap()->undefined_value(); |
1290 } | 1301 } |
1291 } | 1302 } |
1292 } // namespace v8::internal | 1303 } // namespace v8::internal |
OLD | NEW |