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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
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 global.print(argc_bound); | |
1116 var fn = this; | 1115 var fn = this; |
1117 var result = function() { | 1116 var result = function() { |
1118 // 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 |
1119 // given as argument to the invocation. | 1118 // given as argument to the invocation. |
1120 var argc = %_ArgumentsLength(); | 1119 var argc = %_ArgumentsLength(); |
1121 var args = new $Array(argc + argc_bound); | 1120 var args = new $Array(argc + argc_bound); |
1122 // Add bound arguments. | 1121 // Add bound arguments. |
1123 for (var i = 0; i < argc_bound; i++) { | 1122 for (var i = 0; i < argc_bound; i++) { |
1124 args[i] = bound_args[i]; | 1123 args[i] = bound_args[i]; |
1125 } | 1124 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 // ---------------------------------------------------------------------------- | 1179 // ---------------------------------------------------------------------------- |
1181 | 1180 |
1182 function SetupFunction() { | 1181 function SetupFunction() { |
1183 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1182 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1184 "bind", FunctionBind, | 1183 "bind", FunctionBind, |
1185 "toString", FunctionToString | 1184 "toString", FunctionToString |
1186 )); | 1185 )); |
1187 } | 1186 } |
1188 | 1187 |
1189 SetupFunction(); | 1188 SetupFunction(); |
OLD | NEW |