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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Helper function used to install functions on objects. | 48 // Helper function used to install functions on objects. |
49 function InstallFunctions(object, attributes, functions) { | 49 function InstallFunctions(object, attributes, functions) { |
50 if (functions.length >= 8) { | 50 if (functions.length >= 8) { |
51 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 51 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
52 } | 52 } |
53 for (var i = 0; i < functions.length; i += 2) { | 53 for (var i = 0; i < functions.length; i += 2) { |
54 var key = functions[i]; | 54 var key = functions[i]; |
55 var f = functions[i + 1]; | 55 var f = functions[i + 1]; |
56 %FunctionSetName(f, key); | 56 %FunctionSetName(f, key); |
| 57 %FunctionRemovePrototype(f); |
57 %SetProperty(object, key, f, attributes); | 58 %SetProperty(object, key, f, attributes); |
58 } | 59 } |
59 %ToFastProperties(object); | 60 %ToFastProperties(object); |
60 } | 61 } |
61 | 62 |
62 // Emulates JSC by installing functions on a hidden prototype that | 63 // Emulates JSC by installing functions on a hidden prototype that |
63 // lies above the current object/prototype. This lets you override | 64 // lies above the current object/prototype. This lets you override |
64 // functions on String.prototype etc. and then restore the old function | 65 // functions on String.prototype etc. and then restore the old function |
65 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 | 66 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 |
66 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | 67 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 | 1002 |
1002 // ---------------------------------------------------------------------------- | 1003 // ---------------------------------------------------------------------------- |
1003 | 1004 |
1004 function SetupFunction() { | 1005 function SetupFunction() { |
1005 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1006 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1006 "toString", FunctionToString | 1007 "toString", FunctionToString |
1007 )); | 1008 )); |
1008 } | 1009 } |
1009 | 1010 |
1010 SetupFunction(); | 1011 SetupFunction(); |
OLD | NEW |