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

Side by Side Diff: src/js/array.js

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GetIterator; 14 var GetIterator;
15 var GetMethod; 15 var GetMethod;
16 var GlobalArray = global.Array; 16 var GlobalArray = global.Array;
17 var InternalArray = utils.InternalArray; 17 var InternalArray = utils.InternalArray;
18 var InternalPackedArray = utils.InternalPackedArray; 18 var InternalPackedArray = utils.InternalPackedArray;
19 var MakeTypeError;
20 var MaxSimple; 19 var MaxSimple;
21 var MinSimple; 20 var MinSimple;
22 var ObjectHasOwnProperty; 21 var ObjectHasOwnProperty;
23 var ObjectToString = utils.ImportNow("object_to_string"); 22 var ObjectToString = utils.ImportNow("object_to_string");
24 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 23 var iteratorSymbol = utils.ImportNow("iterator_symbol");
25 var speciesSymbol = utils.ImportNow("species_symbol"); 24 var speciesSymbol = utils.ImportNow("species_symbol");
26 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); 25 var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
27 26
28 utils.Import(function(from) { 27 utils.Import(function(from) {
29 GetIterator = from.GetIterator; 28 GetIterator = from.GetIterator;
30 GetMethod = from.GetMethod; 29 GetMethod = from.GetMethod;
31 MakeTypeError = from.MakeTypeError;
32 MaxSimple = from.MaxSimple; 30 MaxSimple = from.MaxSimple;
33 MinSimple = from.MinSimple; 31 MinSimple = from.MinSimple;
34 ObjectHasOwnProperty = from.ObjectHasOwnProperty; 32 ObjectHasOwnProperty = from.ObjectHasOwnProperty;
35 }); 33 });
36 34
37 // ------------------------------------------------------------------- 35 // -------------------------------------------------------------------
38 36
39 37
40 function ArraySpeciesCreate(array, length) { 38 function ArraySpeciesCreate(array, length) {
41 length = INVERT_NEG_ZERO(length); 39 length = INVERT_NEG_ZERO(length);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 function ArrayPush() { 415 function ArrayPush() {
418 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); 416 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push");
419 417
420 var array = TO_OBJECT(this); 418 var array = TO_OBJECT(this);
421 var n = TO_LENGTH(array.length); 419 var n = TO_LENGTH(array.length);
422 var m = arguments.length; 420 var m = arguments.length;
423 421
424 // Subtract n from kMaxSafeInteger rather than testing m + n > 422 // Subtract n from kMaxSafeInteger rather than testing m + n >
425 // kMaxSafeInteger. n may already be kMaxSafeInteger. In that case adding 423 // kMaxSafeInteger. n may already be kMaxSafeInteger. In that case adding
426 // e.g., 1 would not be safe. 424 // e.g., 1 would not be safe.
427 if (m > kMaxSafeInteger - n) throw MakeTypeError(kPushPastSafeLength, m, n); 425 if (m > kMaxSafeInteger - n) throw %make_type_error(kPushPastSafeLength, m, n) ;
428 426
429 for (var i = 0; i < m; i++) { 427 for (var i = 0; i < m; i++) {
430 array[i+n] = arguments[i]; 428 array[i+n] = arguments[i];
431 } 429 }
432 430
433 var new_length = n + m; 431 var new_length = n + m;
434 array.length = new_length; 432 array.length = new_length;
435 return new_length; 433 return new_length;
436 } 434 }
437 435
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift"); 537 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift");
540 538
541 var array = TO_OBJECT(this); 539 var array = TO_OBJECT(this);
542 var len = TO_LENGTH(array.length); 540 var len = TO_LENGTH(array.length);
543 541
544 if (len === 0) { 542 if (len === 0) {
545 array.length = 0; 543 array.length = 0;
546 return; 544 return;
547 } 545 }
548 546
549 if (%object_is_sealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed); 547 if (%object_is_sealed(array)) throw %make_type_error(kArrayFunctionsOnSealed);
550 548
551 var first = array[0]; 549 var first = array[0];
552 550
553 if (UseSparseVariant(array, len, IS_ARRAY(array), len)) { 551 if (UseSparseVariant(array, len, IS_ARRAY(array), len)) {
554 SparseMove(array, 0, 1, len, 0); 552 SparseMove(array, 0, 1, len, 0);
555 } else { 553 } else {
556 SimpleMove(array, 0, 1, len, 0); 554 SimpleMove(array, 0, 1, len, 0);
557 } 555 }
558 556
559 array.length = len - 1; 557 array.length = len - 1;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 var array = TO_OBJECT(this); 664 var array = TO_OBJECT(this);
667 var len = TO_LENGTH(array.length); 665 var len = TO_LENGTH(array.length);
668 var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len); 666 var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
669 var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len, 667 var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len,
670 start_i); 668 start_i);
671 var deleted_elements = ArraySpeciesCreate(array, del_count); 669 var deleted_elements = ArraySpeciesCreate(array, del_count);
672 deleted_elements.length = del_count; 670 deleted_elements.length = del_count;
673 var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0; 671 var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
674 672
675 if (del_count != num_elements_to_add && %object_is_sealed(array)) { 673 if (del_count != num_elements_to_add && %object_is_sealed(array)) {
676 throw MakeTypeError(kArrayFunctionsOnSealed); 674 throw %make_type_error(kArrayFunctionsOnSealed);
677 } else if (del_count > 0 && %object_is_frozen(array)) { 675 } else if (del_count > 0 && %object_is_frozen(array)) {
678 throw MakeTypeError(kArrayFunctionsOnFrozen); 676 throw %make_type_error(kArrayFunctionsOnFrozen);
679 } 677 }
680 678
681 var changed_elements = del_count; 679 var changed_elements = del_count;
682 if (num_elements_to_add != del_count) { 680 if (num_elements_to_add != del_count) {
683 // If the slice needs to do a actually move elements after the insertion 681 // If the slice needs to do a actually move elements after the insertion
684 // point, then include those in the estimate of changed elements. 682 // point, then include those in the estimate of changed elements.
685 changed_elements += len - start_i - del_count; 683 changed_elements += len - start_i - del_count;
686 } 684 }
687 if (UseSparseVariant(array, len, IS_ARRAY(array), changed_elements)) { 685 if (UseSparseVariant(array, len, IS_ARRAY(array), changed_elements)) {
688 %NormalizeElements(array); 686 %NormalizeElements(array);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1022
1025 1023
1026 1024
1027 function ArrayFilter(f, receiver) { 1025 function ArrayFilter(f, receiver) {
1028 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); 1026 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter");
1029 1027
1030 // Pull out the length so that modifications to the length in the 1028 // Pull out the length so that modifications to the length in the
1031 // loop will not affect the looping and side effects are visible. 1029 // loop will not affect the looping and side effects are visible.
1032 var array = TO_OBJECT(this); 1030 var array = TO_OBJECT(this);
1033 var length = TO_LENGTH(array.length); 1031 var length = TO_LENGTH(array.length);
1034 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1032 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
1035 var result = ArraySpeciesCreate(array, 0); 1033 var result = ArraySpeciesCreate(array, 0);
1036 return InnerArrayFilter(f, receiver, array, length, result); 1034 return InnerArrayFilter(f, receiver, array, length, result);
1037 } 1035 }
1038 1036
1039 1037
1040 function InnerArrayForEach(f, receiver, array, length) { 1038 function InnerArrayForEach(f, receiver, array, length) {
1041 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1039 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
1042 1040
1043 if (IS_UNDEFINED(receiver)) { 1041 if (IS_UNDEFINED(receiver)) {
1044 for (var i = 0; i < length; i++) { 1042 for (var i = 0; i < length; i++) {
1045 if (i in array) { 1043 if (i in array) {
1046 var element = array[i]; 1044 var element = array[i];
1047 f(element, i, array); 1045 f(element, i, array);
1048 } 1046 }
1049 } 1047 }
1050 } else { 1048 } else {
1051 for (var i = 0; i < length; i++) { 1049 for (var i = 0; i < length; i++) {
(...skipping 11 matching lines...) Expand all
1063 1061
1064 // Pull out the length so that modifications to the length in the 1062 // Pull out the length so that modifications to the length in the
1065 // loop will not affect the looping and side effects are visible. 1063 // loop will not affect the looping and side effects are visible.
1066 var array = TO_OBJECT(this); 1064 var array = TO_OBJECT(this);
1067 var length = TO_LENGTH(array.length); 1065 var length = TO_LENGTH(array.length);
1068 InnerArrayForEach(f, receiver, array, length); 1066 InnerArrayForEach(f, receiver, array, length);
1069 } 1067 }
1070 1068
1071 1069
1072 function InnerArraySome(f, receiver, array, length) { 1070 function InnerArraySome(f, receiver, array, length) {
1073 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1071 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
1074 1072
1075 for (var i = 0; i < length; i++) { 1073 for (var i = 0; i < length; i++) {
1076 if (i in array) { 1074 if (i in array) {
1077 var element = array[i]; 1075 var element = array[i];
1078 if (%_Call(f, receiver, element, i, array)) return true; 1076 if (%_Call(f, receiver, element, i, array)) return true;
1079 } 1077 }
1080 } 1078 }
1081 return false; 1079 return false;
1082 } 1080 }
1083 1081
1084 1082
1085 // Executes the function once for each element present in the 1083 // Executes the function once for each element present in the
1086 // array until it finds one where callback returns true. 1084 // array until it finds one where callback returns true.
1087 function ArraySome(f, receiver) { 1085 function ArraySome(f, receiver) {
1088 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); 1086 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
1089 1087
1090 // Pull out the length so that modifications to the length in the 1088 // Pull out the length so that modifications to the length in the
1091 // loop will not affect the looping and side effects are visible. 1089 // loop will not affect the looping and side effects are visible.
1092 var array = TO_OBJECT(this); 1090 var array = TO_OBJECT(this);
1093 var length = TO_LENGTH(array.length); 1091 var length = TO_LENGTH(array.length);
1094 return InnerArraySome(f, receiver, array, length); 1092 return InnerArraySome(f, receiver, array, length);
1095 } 1093 }
1096 1094
1097 1095
1098 function InnerArrayEvery(f, receiver, array, length) { 1096 function InnerArrayEvery(f, receiver, array, length) {
1099 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1097 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
1100 1098
1101 for (var i = 0; i < length; i++) { 1099 for (var i = 0; i < length; i++) {
1102 if (i in array) { 1100 if (i in array) {
1103 var element = array[i]; 1101 var element = array[i];
1104 if (!%_Call(f, receiver, element, i, array)) return false; 1102 if (!%_Call(f, receiver, element, i, array)) return false;
1105 } 1103 }
1106 } 1104 }
1107 return true; 1105 return true;
1108 } 1106 }
1109 1107
1110 function ArrayEvery(f, receiver) { 1108 function ArrayEvery(f, receiver) {
1111 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); 1109 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
1112 1110
1113 // Pull out the length so that modifications to the length in the 1111 // Pull out the length so that modifications to the length in the
1114 // loop will not affect the looping and side effects are visible. 1112 // loop will not affect the looping and side effects are visible.
1115 var array = TO_OBJECT(this); 1113 var array = TO_OBJECT(this);
1116 var length = TO_LENGTH(array.length); 1114 var length = TO_LENGTH(array.length);
1117 return InnerArrayEvery(f, receiver, array, length); 1115 return InnerArrayEvery(f, receiver, array, length);
1118 } 1116 }
1119 1117
1120 1118
1121 function ArrayMap(f, receiver) { 1119 function ArrayMap(f, receiver) {
1122 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); 1120 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map");
1123 1121
1124 // Pull out the length so that modifications to the length in the 1122 // Pull out the length so that modifications to the length in the
1125 // loop will not affect the looping and side effects are visible. 1123 // loop will not affect the looping and side effects are visible.
1126 var array = TO_OBJECT(this); 1124 var array = TO_OBJECT(this);
1127 var length = TO_LENGTH(array.length); 1125 var length = TO_LENGTH(array.length);
1128 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); 1126 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
1129 var result = ArraySpeciesCreate(array, length); 1127 var result = ArraySpeciesCreate(array, length);
1130 for (var i = 0; i < length; i++) { 1128 for (var i = 0; i < length; i++) {
1131 if (i in array) { 1129 if (i in array) {
1132 var element = array[i]; 1130 var element = array[i];
1133 %CreateDataProperty(result, i, %_Call(f, receiver, element, i, array)); 1131 %CreateDataProperty(result, i, %_Call(f, receiver, element, i, array));
1134 } 1132 }
1135 } 1133 }
1136 return result; 1134 return result;
1137 } 1135 }
1138 1136
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf"); 1255 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf");
1258 1256
1259 var length = TO_LENGTH(this.length); 1257 var length = TO_LENGTH(this.length);
1260 return InnerArrayLastIndexOf(this, element, index, length, 1258 return InnerArrayLastIndexOf(this, element, index, length,
1261 arguments.length); 1259 arguments.length);
1262 } 1260 }
1263 1261
1264 1262
1265 function InnerArrayReduce(callback, current, array, length, argumentsLength) { 1263 function InnerArrayReduce(callback, current, array, length, argumentsLength) {
1266 if (!IS_CALLABLE(callback)) { 1264 if (!IS_CALLABLE(callback)) {
1267 throw MakeTypeError(kCalledNonCallable, callback); 1265 throw %make_type_error(kCalledNonCallable, callback);
1268 } 1266 }
1269 1267
1270 var i = 0; 1268 var i = 0;
1271 find_initial: if (argumentsLength < 2) { 1269 find_initial: if (argumentsLength < 2) {
1272 for (; i < length; i++) { 1270 for (; i < length; i++) {
1273 if (i in array) { 1271 if (i in array) {
1274 current = array[i++]; 1272 current = array[i++];
1275 break find_initial; 1273 break find_initial;
1276 } 1274 }
1277 } 1275 }
1278 throw MakeTypeError(kReduceNoInitial); 1276 throw %make_type_error(kReduceNoInitial);
1279 } 1277 }
1280 1278
1281 for (; i < length; i++) { 1279 for (; i < length; i++) {
1282 if (i in array) { 1280 if (i in array) {
1283 var element = array[i]; 1281 var element = array[i];
1284 current = callback(current, element, i, array); 1282 current = callback(current, element, i, array);
1285 } 1283 }
1286 } 1284 }
1287 return current; 1285 return current;
1288 } 1286 }
1289 1287
1290 1288
1291 function ArrayReduce(callback, current) { 1289 function ArrayReduce(callback, current) {
1292 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); 1290 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce");
1293 1291
1294 // Pull out the length so that modifications to the length in the 1292 // Pull out the length so that modifications to the length in the
1295 // loop will not affect the looping and side effects are visible. 1293 // loop will not affect the looping and side effects are visible.
1296 var array = TO_OBJECT(this); 1294 var array = TO_OBJECT(this);
1297 var length = TO_LENGTH(array.length); 1295 var length = TO_LENGTH(array.length);
1298 return InnerArrayReduce(callback, current, array, length, 1296 return InnerArrayReduce(callback, current, array, length,
1299 arguments.length); 1297 arguments.length);
1300 } 1298 }
1301 1299
1302 1300
1303 function InnerArrayReduceRight(callback, current, array, length, 1301 function InnerArrayReduceRight(callback, current, array, length,
1304 argumentsLength) { 1302 argumentsLength) {
1305 if (!IS_CALLABLE(callback)) { 1303 if (!IS_CALLABLE(callback)) {
1306 throw MakeTypeError(kCalledNonCallable, callback); 1304 throw %make_type_error(kCalledNonCallable, callback);
1307 } 1305 }
1308 1306
1309 var i = length - 1; 1307 var i = length - 1;
1310 find_initial: if (argumentsLength < 2) { 1308 find_initial: if (argumentsLength < 2) {
1311 for (; i >= 0; i--) { 1309 for (; i >= 0; i--) {
1312 if (i in array) { 1310 if (i in array) {
1313 current = array[i--]; 1311 current = array[i--];
1314 break find_initial; 1312 break find_initial;
1315 } 1313 }
1316 } 1314 }
1317 throw MakeTypeError(kReduceNoInitial); 1315 throw %make_type_error(kReduceNoInitial);
1318 } 1316 }
1319 1317
1320 for (; i >= 0; i--) { 1318 for (; i >= 0; i--) {
1321 if (i in array) { 1319 if (i in array) {
1322 var element = array[i]; 1320 var element = array[i];
1323 current = callback(current, element, i, array); 1321 current = callback(current, element, i, array);
1324 } 1322 }
1325 } 1323 }
1326 return current; 1324 return current;
1327 } 1325 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 1391
1394 var array = TO_OBJECT(this); 1392 var array = TO_OBJECT(this);
1395 var length = TO_LENGTH(array.length); 1393 var length = TO_LENGTH(array.length);
1396 1394
1397 return InnerArrayCopyWithin(target, start, end, array, length); 1395 return InnerArrayCopyWithin(target, start, end, array, length);
1398 } 1396 }
1399 1397
1400 1398
1401 function InnerArrayFind(predicate, thisArg, array, length) { 1399 function InnerArrayFind(predicate, thisArg, array, length) {
1402 if (!IS_CALLABLE(predicate)) { 1400 if (!IS_CALLABLE(predicate)) {
1403 throw MakeTypeError(kCalledNonCallable, predicate); 1401 throw %make_type_error(kCalledNonCallable, predicate);
1404 } 1402 }
1405 1403
1406 for (var i = 0; i < length; i++) { 1404 for (var i = 0; i < length; i++) {
1407 var element = array[i]; 1405 var element = array[i];
1408 if (%_Call(predicate, thisArg, element, i, array)) { 1406 if (%_Call(predicate, thisArg, element, i, array)) {
1409 return element; 1407 return element;
1410 } 1408 }
1411 } 1409 }
1412 1410
1413 return; 1411 return;
1414 } 1412 }
1415 1413
1416 1414
1417 // ES6 draft 07-15-13, section 15.4.3.23 1415 // ES6 draft 07-15-13, section 15.4.3.23
1418 function ArrayFind(predicate, thisArg) { 1416 function ArrayFind(predicate, thisArg) {
1419 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); 1417 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
1420 1418
1421 var array = TO_OBJECT(this); 1419 var array = TO_OBJECT(this);
1422 var length = TO_INTEGER(array.length); 1420 var length = TO_INTEGER(array.length);
1423 1421
1424 return InnerArrayFind(predicate, thisArg, array, length); 1422 return InnerArrayFind(predicate, thisArg, array, length);
1425 } 1423 }
1426 1424
1427 1425
1428 function InnerArrayFindIndex(predicate, thisArg, array, length) { 1426 function InnerArrayFindIndex(predicate, thisArg, array, length) {
1429 if (!IS_CALLABLE(predicate)) { 1427 if (!IS_CALLABLE(predicate)) {
1430 throw MakeTypeError(kCalledNonCallable, predicate); 1428 throw %make_type_error(kCalledNonCallable, predicate);
1431 } 1429 }
1432 1430
1433 for (var i = 0; i < length; i++) { 1431 for (var i = 0; i < length; i++) {
1434 var element = array[i]; 1432 var element = array[i];
1435 if (%_Call(predicate, thisArg, element, i, array)) { 1433 if (%_Call(predicate, thisArg, element, i, array)) {
1436 return i; 1434 return i;
1437 } 1435 }
1438 } 1436 }
1439 1437
1440 return -1; 1438 return -1;
(...skipping 24 matching lines...) Expand all
1465 } 1463 }
1466 1464
1467 if (end < 0) { 1465 if (end < 0) {
1468 end += length; 1466 end += length;
1469 if (end < 0) end = 0; 1467 if (end < 0) end = 0;
1470 } else { 1468 } else {
1471 if (end > length) end = length; 1469 if (end > length) end = length;
1472 } 1470 }
1473 1471
1474 if ((end - i) > 0 && %object_is_frozen(array)) { 1472 if ((end - i) > 0 && %object_is_frozen(array)) {
1475 throw MakeTypeError(kArrayFunctionsOnFrozen); 1473 throw %make_type_error(kArrayFunctionsOnFrozen);
1476 } 1474 }
1477 1475
1478 for (; i < end; i++) 1476 for (; i < end; i++)
1479 array[i] = value; 1477 array[i] = value;
1480 return array; 1478 return array;
1481 } 1479 }
1482 1480
1483 1481
1484 // ES6, draft 04-05-14, section 22.1.3.6 1482 // ES6, draft 04-05-14, section 22.1.3.6
1485 function ArrayFill(value, start, end) { 1483 function ArrayFill(value, start, end) {
1486 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); 1484 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill");
1487 1485
1488 var array = TO_OBJECT(this); 1486 var array = TO_OBJECT(this);
1489 var length = TO_LENGTH(array.length); 1487 var length = TO_LENGTH(array.length);
1490 1488
1491 return InnerArrayFill(value, start, end, array, length); 1489 return InnerArrayFill(value, start, end, array, length);
1492 } 1490 }
1493 1491
1494 1492
1495 // ES6, draft 10-14-14, section 22.1.2.1 1493 // ES6, draft 10-14-14, section 22.1.2.1
1496 function ArrayFrom(arrayLike, mapfn, receiver) { 1494 function ArrayFrom(arrayLike, mapfn, receiver) {
1497 var items = TO_OBJECT(arrayLike); 1495 var items = TO_OBJECT(arrayLike);
1498 var mapping = !IS_UNDEFINED(mapfn); 1496 var mapping = !IS_UNDEFINED(mapfn);
1499 1497
1500 if (mapping) { 1498 if (mapping) {
1501 if (!IS_CALLABLE(mapfn)) { 1499 if (!IS_CALLABLE(mapfn)) {
1502 throw MakeTypeError(kCalledNonCallable, mapfn); 1500 throw %make_type_error(kCalledNonCallable, mapfn);
1503 } 1501 }
1504 } 1502 }
1505 1503
1506 var iterable = GetMethod(items, iteratorSymbol); 1504 var iterable = GetMethod(items, iteratorSymbol);
1507 var k; 1505 var k;
1508 var result; 1506 var result;
1509 var mappedValue; 1507 var mappedValue;
1510 var nextValue; 1508 var nextValue;
1511 1509
1512 if (!IS_UNDEFINED(iterable)) { 1510 if (!IS_UNDEFINED(iterable)) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 %InstallToContext([ 1702 %InstallToContext([
1705 "array_pop", ArrayPop, 1703 "array_pop", ArrayPop,
1706 "array_push", ArrayPush, 1704 "array_push", ArrayPush,
1707 "array_shift", ArrayShift, 1705 "array_shift", ArrayShift,
1708 "array_splice", ArraySplice, 1706 "array_splice", ArraySplice,
1709 "array_slice", ArraySlice, 1707 "array_slice", ArraySlice,
1710 "array_unshift", ArrayUnshift, 1708 "array_unshift", ArrayUnshift,
1711 ]); 1709 ]);
1712 1710
1713 }); 1711 });
OLDNEW
« src/bootstrapper.cc ('K') | « src/debug/mirrors.js ('k') | src/js/array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698