| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 throw MakeTypeError('called_non_callable', [predicate]); | 44 throw MakeTypeError('called_non_callable', [predicate]); |
| 45 } | 45 } |
| 46 | 46 |
| 47 var thisArg; | 47 var thisArg; |
| 48 if (%_ArgumentsLength() > 1) { | 48 if (%_ArgumentsLength() > 1) { |
| 49 thisArg = %_Arguments(1); | 49 thisArg = %_Arguments(1); |
| 50 } | 50 } |
| 51 | 51 |
| 52 if (IS_NULL_OR_UNDEFINED(thisArg)) { | 52 if (IS_NULL_OR_UNDEFINED(thisArg)) { |
| 53 thisArg = %GetDefaultReceiver(predicate) || thisArg; | 53 thisArg = %GetDefaultReceiver(predicate) || thisArg; |
| 54 } else if (!IS_SPEC_OBJECT(thisArg) && %IsClassicModeFunction(predicate)) { | 54 } else if (!IS_SPEC_OBJECT(thisArg) && %IsSloppyModeFunction(predicate)) { |
| 55 thisArg = ToObject(thisArg); | 55 thisArg = ToObject(thisArg); |
| 56 } | 56 } |
| 57 | 57 |
| 58 for (var i = 0; i < length; i++) { | 58 for (var i = 0; i < length; i++) { |
| 59 if (i in array) { | 59 if (i in array) { |
| 60 var element = array[i]; | 60 var element = array[i]; |
| 61 if (%_CallFunction(thisArg, element, i, array, predicate)) { | 61 if (%_CallFunction(thisArg, element, i, array, predicate)) { |
| 62 return element; | 62 return element; |
| 63 } | 63 } |
| 64 } | 64 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 throw MakeTypeError('called_non_callable', [predicate]); | 79 throw MakeTypeError('called_non_callable', [predicate]); |
| 80 } | 80 } |
| 81 | 81 |
| 82 var thisArg; | 82 var thisArg; |
| 83 if (%_ArgumentsLength() > 1) { | 83 if (%_ArgumentsLength() > 1) { |
| 84 thisArg = %_Arguments(1); | 84 thisArg = %_Arguments(1); |
| 85 } | 85 } |
| 86 | 86 |
| 87 if (IS_NULL_OR_UNDEFINED(thisArg)) { | 87 if (IS_NULL_OR_UNDEFINED(thisArg)) { |
| 88 thisArg = %GetDefaultReceiver(predicate) || thisArg; | 88 thisArg = %GetDefaultReceiver(predicate) || thisArg; |
| 89 } else if (!IS_SPEC_OBJECT(thisArg) && %IsClassicModeFunction(predicate)) { | 89 } else if (!IS_SPEC_OBJECT(thisArg) && %IsSloppyModeFunction(predicate)) { |
| 90 thisArg = ToObject(thisArg); | 90 thisArg = ToObject(thisArg); |
| 91 } | 91 } |
| 92 | 92 |
| 93 for (var i = 0; i < length; i++) { | 93 for (var i = 0; i < length; i++) { |
| 94 if (i in array) { | 94 if (i in array) { |
| 95 var element = array[i]; | 95 var element = array[i]; |
| 96 if (%_CallFunction(thisArg, element, i, array, predicate)) { | 96 if (%_CallFunction(thisArg, element, i, array, predicate)) { |
| 97 return i; | 97 return i; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 return -1; | 102 return -1; |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 // ------------------------------------------------------------------- | 106 // ------------------------------------------------------------------- |
| 107 | 107 |
| 108 function HarmonyArrayExtendArrayPrototype() { | 108 function HarmonyArrayExtendArrayPrototype() { |
| 109 %CheckIsBootstrapping(); | 109 %CheckIsBootstrapping(); |
| 110 | 110 |
| 111 // Set up the non-enumerable functions on the Array prototype object. | 111 // Set up the non-enumerable functions on the Array prototype object. |
| 112 InstallFunctions($Array.prototype, DONT_ENUM, $Array( | 112 InstallFunctions($Array.prototype, DONT_ENUM, $Array( |
| 113 "find", ArrayFind, | 113 "find", ArrayFind, |
| 114 "findIndex", ArrayFindIndex | 114 "findIndex", ArrayFindIndex |
| 115 )); | 115 )); |
| 116 } | 116 } |
| 117 | 117 |
| 118 HarmonyArrayExtendArrayPrototype(); | 118 HarmonyArrayExtendArrayPrototype(); |
| OLD | NEW |