| 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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 return FunctionSourceString(this); | 1098 return FunctionSourceString(this); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 | 1101 |
| 1102 // ES5 15.3.4.5 | 1102 // ES5 15.3.4.5 |
| 1103 function FunctionBind(this_arg) { // Length is 1. | 1103 function FunctionBind(this_arg) { // Length is 1. |
| 1104 if (!IS_FUNCTION(this)) { | 1104 if (!IS_FUNCTION(this)) { |
| 1105 throw new $TypeError('Bind must be called on a function'); | 1105 throw new $TypeError('Bind must be called on a function'); |
| 1106 } | 1106 } |
| 1107 // this_arg is not an argument that should be bound. | 1107 // this_arg is not an argument that should be bound. |
| 1108 var argc_bound = %_ArgumentsLength() - 1; | 1108 var argc_bound = (%_ArgumentsLength() || 1) - 1; |
| 1109 if (argc_bound > 0) { | 1109 if (argc_bound > 0) { |
| 1110 var bound_args = new $Array(argc_bound); | 1110 var bound_args = new $Array(argc_bound); |
| 1111 for(var i = 0; i < argc_bound; i++) { | 1111 for(var i = 0; i < argc_bound; i++) { |
| 1112 bound_args[i] = %_Arguments(i+1); | 1112 bound_args[i] = %_Arguments(i+1); |
| 1113 } | 1113 } |
| 1114 } | 1114 } |
| 1115 var fn = this; | 1115 var fn = this; |
| 1116 var result = function() { | 1116 var result = function() { |
| 1117 // Combine the args we got from the bind call with the args | 1117 // Combine the args we got from the bind call with the args |
| 1118 // given as argument to the invocation. | 1118 // given as argument to the invocation. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 // ---------------------------------------------------------------------------- | 1179 // ---------------------------------------------------------------------------- |
| 1180 | 1180 |
| 1181 function SetupFunction() { | 1181 function SetupFunction() { |
| 1182 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1182 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1183 "bind", FunctionBind, | 1183 "bind", FunctionBind, |
| 1184 "toString", FunctionToString | 1184 "toString", FunctionToString |
| 1185 )); | 1185 )); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 SetupFunction(); | 1188 SetupFunction(); |
| OLD | NEW |