| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 var key = functions[i]; | 53 var key = functions[i]; |
| 54 var f = functions[i + 1]; | 54 var f = functions[i + 1]; |
| 55 %FunctionSetName(f, key); | 55 %FunctionSetName(f, key); |
| 56 %FunctionRemovePrototype(f); | 56 %FunctionRemovePrototype(f); |
| 57 %SetProperty(object, key, f, attributes); | 57 %SetProperty(object, key, f, attributes); |
| 58 %SetNativeFlag(f); | 58 %SetNativeFlag(f); |
| 59 } | 59 } |
| 60 %ToFastProperties(object); | 60 %ToFastProperties(object); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Emulates JSC by installing functions on a hidden prototype that | |
| 64 // lies above the current object/prototype. This lets you override | |
| 65 // functions on String.prototype etc. and then restore the old function | |
| 66 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 | |
| 67 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | |
| 68 %CheckIsBootstrapping(); | |
| 69 var hidden_prototype = new $Object(); | |
| 70 %SetHiddenPrototype(object, hidden_prototype); | |
| 71 InstallFunctions(hidden_prototype, attributes, functions); | |
| 72 } | |
| 73 | |
| 74 | |
| 75 // Prevents changes to the prototype of a built-infunction. | 63 // Prevents changes to the prototype of a built-infunction. |
| 76 // The "prototype" property of the function object is made non-configurable, | 64 // The "prototype" property of the function object is made non-configurable, |
| 77 // and the prototype object is made non-extensible. The latter prevents | 65 // and the prototype object is made non-extensible. The latter prevents |
| 78 // changing the __proto__ property. | 66 // changing the __proto__ property. |
| 79 function SetUpLockedPrototype(constructor, fields, methods) { | 67 function SetUpLockedPrototype(constructor, fields, methods) { |
| 80 %CheckIsBootstrapping(); | 68 %CheckIsBootstrapping(); |
| 81 var prototype = constructor.prototype; | 69 var prototype = constructor.prototype; |
| 82 // Install functions first, because this function is used to initialize | 70 // Install functions first, because this function is used to initialize |
| 83 // PropertyDescriptor itself. | 71 // PropertyDescriptor itself. |
| 84 var property_count = (methods.length >> 1) + (fields ? fields.length : 0); | 72 var property_count = (methods.length >> 1) + (fields ? fields.length : 0); |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 | 1537 |
| 1550 function SetUpFunction() { | 1538 function SetUpFunction() { |
| 1551 %CheckIsBootstrapping(); | 1539 %CheckIsBootstrapping(); |
| 1552 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1540 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1553 "bind", FunctionBind, | 1541 "bind", FunctionBind, |
| 1554 "toString", FunctionToString | 1542 "toString", FunctionToString |
| 1555 )); | 1543 )); |
| 1556 } | 1544 } |
| 1557 | 1545 |
| 1558 SetUpFunction(); | 1546 SetUpFunction(); |
| OLD | NEW |