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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 // Function | 1192 // Function |
1193 | 1193 |
1194 $Function.prototype.constructor = $Function; | 1194 $Function.prototype.constructor = $Function; |
1195 | 1195 |
1196 function FunctionSourceString(func) { | 1196 function FunctionSourceString(func) { |
1197 if (!IS_FUNCTION(func)) { | 1197 if (!IS_FUNCTION(func)) { |
1198 throw new $TypeError('Function.prototype.toString is not generic'); | 1198 throw new $TypeError('Function.prototype.toString is not generic'); |
1199 } | 1199 } |
1200 | 1200 |
1201 var source = %FunctionGetSourceCode(func); | 1201 var source = %FunctionGetSourceCode(func); |
1202 if (!IS_STRING(source)) return "NOT A string"; | |
1203 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { | 1202 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { |
1204 var name = %FunctionGetName(func); | 1203 var name = %FunctionGetName(func); |
1205 if (name) { | 1204 if (name) { |
1206 // Mimic what KJS does. | 1205 // Mimic what KJS does. |
1207 return 'function ' + name + '() { [native code] }'; | 1206 return 'function ' + name + '() { [native code] }'; |
1208 } else { | 1207 } else { |
1209 return 'function () { [native code] }'; | 1208 return 'function () { [native code] }'; |
1210 } | 1209 } |
1211 } | 1210 } |
1212 | 1211 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 // ---------------------------------------------------------------------------- | 1312 // ---------------------------------------------------------------------------- |
1314 | 1313 |
1315 function SetupFunction() { | 1314 function SetupFunction() { |
1316 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1315 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1317 "bind", FunctionBind, | 1316 "bind", FunctionBind, |
1318 "toString", FunctionToString | 1317 "toString", FunctionToString |
1319 )); | 1318 )); |
1320 } | 1319 } |
1321 | 1320 |
1322 SetupFunction(); | 1321 SetupFunction(); |
OLD | NEW |