| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 // ES6, draft 04-05-14, section 22.1.3.6 | 
|  | 107 function ArrayFill(value /* [, start [, end ] ] */) {  // length == 1 | 
|  | 108   CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); | 
|  | 109 | 
|  | 110   var array = ToObject(this); | 
|  | 111   var length = TO_UINT32(array.length); | 
|  | 112 | 
|  | 113   var i = 0; | 
|  | 114   var end = length; | 
|  | 115 | 
|  | 116   if (%_ArgumentsLength() > 1) { | 
|  | 117     i = %_Arguments(1); | 
|  | 118     i = IS_UNDEFINED(i) ? 0 : TO_INTEGER(i); | 
|  | 119     if (%_ArgumentsLength() > 2) { | 
|  | 120       end = %_Arguments(2); | 
|  | 121       end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); | 
|  | 122     } | 
|  | 123   } | 
|  | 124 | 
|  | 125   if (i < 0) { | 
|  | 126     i += length; | 
|  | 127     if (i < 0) i = 0; | 
|  | 128   } else { | 
|  | 129     if (i > length) i = length; | 
|  | 130   } | 
|  | 131 | 
|  | 132   if (end < 0) { | 
|  | 133     end += length; | 
|  | 134     if (end < 0) end = 0; | 
|  | 135   } else { | 
|  | 136     if (end > length) end = length; | 
|  | 137   } | 
|  | 138 | 
|  | 139   if ((end - i) > 0 && ObjectIsFrozen(array)) { | 
|  | 140     throw MakeTypeError("array_functions_on_frozen", | 
|  | 141                         ["Array.prototype.fill"]); | 
|  | 142   } | 
|  | 143 | 
|  | 144   for (; i < end; i++) | 
|  | 145     array[i] = value; | 
|  | 146   return array; | 
|  | 147 } | 
|  | 148 | 
| 106 // ------------------------------------------------------------------- | 149 // ------------------------------------------------------------------- | 
| 107 | 150 | 
| 108 function HarmonyArrayExtendArrayPrototype() { | 151 function HarmonyArrayExtendArrayPrototype() { | 
| 109   %CheckIsBootstrapping(); | 152   %CheckIsBootstrapping(); | 
| 110 | 153 | 
| 111   // Set up the non-enumerable functions on the Array prototype object. | 154   // Set up the non-enumerable functions on the Array prototype object. | 
| 112   InstallFunctions($Array.prototype, DONT_ENUM, $Array( | 155   InstallFunctions($Array.prototype, DONT_ENUM, $Array( | 
| 113     "find", ArrayFind, | 156     "find", ArrayFind, | 
| 114     "findIndex", ArrayFindIndex | 157     "findIndex", ArrayFindIndex, | 
|  | 158     "fill", ArrayFill | 
| 115   )); | 159   )); | 
| 116 } | 160 } | 
| 117 | 161 | 
| 118 HarmonyArrayExtendArrayPrototype(); | 162 HarmonyArrayExtendArrayPrototype(); | 
| OLD | NEW | 
|---|