OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 // We already have caller and arguments properties on functions, | 1351 // We already have caller and arguments properties on functions, |
1352 // which are non-configurable. It therefore makes no sence to | 1352 // which are non-configurable. It therefore makes no sence to |
1353 // try to redefine these as defined by the spec. The spec says | 1353 // try to redefine these as defined by the spec. The spec says |
1354 // that bind should make these throw a TypeError if get or set | 1354 // that bind should make these throw a TypeError if get or set |
1355 // is called and make them non-enumerable and non-configurable. | 1355 // is called and make them non-enumerable and non-configurable. |
1356 // To be consistent with our normal functions we leave this as it is. | 1356 // To be consistent with our normal functions we leave this as it is. |
1357 | 1357 |
1358 // Set the correct length. | 1358 // Set the correct length. |
1359 var length = (this.length - argc_bound) > 0 ? this.length - argc_bound : 0; | 1359 var length = (this.length - argc_bound) > 0 ? this.length - argc_bound : 0; |
1360 %FunctionSetLength(result, length); | 1360 %FunctionSetLength(result, length); |
1361 | 1361 %FunctionRemovePrototype(result); |
| 1362 %FunctionSetBound(result); |
1362 return result; | 1363 return result; |
1363 } | 1364 } |
1364 | 1365 |
1365 | 1366 |
1366 function NewFunction(arg1) { // length == 1 | 1367 function NewFunction(arg1) { // length == 1 |
1367 var n = %_ArgumentsLength(); | 1368 var n = %_ArgumentsLength(); |
1368 var p = ''; | 1369 var p = ''; |
1369 if (n > 1) { | 1370 if (n > 1) { |
1370 p = new InternalArray(n - 1); | 1371 p = new InternalArray(n - 1); |
1371 for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i); | 1372 for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i); |
(...skipping 18 matching lines...) Expand all Loading... |
1390 // ---------------------------------------------------------------------------- | 1391 // ---------------------------------------------------------------------------- |
1391 | 1392 |
1392 function SetupFunction() { | 1393 function SetupFunction() { |
1393 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1394 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1394 "bind", FunctionBind, | 1395 "bind", FunctionBind, |
1395 "toString", FunctionToString | 1396 "toString", FunctionToString |
1396 )); | 1397 )); |
1397 } | 1398 } |
1398 | 1399 |
1399 SetupFunction(); | 1400 SetupFunction(); |
OLD | NEW |