OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 }; | 316 }; |
317 | 317 |
318 // These functions are key for safe meta-programming: | 318 // These functions are key for safe meta-programming: |
319 // http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming | 319 // http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming |
320 // | 320 // |
321 // Technically they could all be derived from combinations of | 321 // Technically they could all be derived from combinations of |
322 // Function.prototype.{bind,call,apply} but that introduces lots of layers of | 322 // Function.prototype.{bind,call,apply} but that introduces lots of layers of |
323 // indirection and slowness given how un-optimized bind is. | 323 // indirection and slowness given how un-optimized bind is. |
324 | 324 |
325 extrasUtils.simpleBind = function simpleBind(func, thisArg) { | 325 extrasUtils.simpleBind = function simpleBind(func, thisArg) { |
326 return function() { | 326 return function(...args) { |
327 return %Apply(func, thisArg, arguments, 0, arguments.length); | 327 return %reflect_apply(func, thisArg, args); |
328 }; | 328 }; |
329 }; | 329 }; |
330 | 330 |
331 extrasUtils.uncurryThis = function uncurryThis(func) { | 331 extrasUtils.uncurryThis = function uncurryThis(func) { |
332 return function(thisArg) { | 332 return function(thisArg, ...args) { |
333 return %Apply(func, thisArg, arguments, 1, arguments.length - 1); | 333 return %reflect_apply(func, thisArg, args); |
334 }; | 334 }; |
335 }; | 335 }; |
336 | 336 |
337 %ToFastProperties(extrasUtils); | 337 %ToFastProperties(extrasUtils); |
338 | 338 |
339 }) | 339 }) |
OLD | NEW |