Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 | 759 |
| 760 // ---------------------------------------------------------------------------- | 760 // ---------------------------------------------------------------------------- |
| 761 // Error implementation | 761 // Error implementation |
| 762 | 762 |
| 763 // Defines accessors for a property that is calculated the first time | 763 // Defines accessors for a property that is calculated the first time |
| 764 // the property is read. | 764 // the property is read. |
| 765 function DefineOneShotAccessor(obj, name, fun) { | 765 function DefineOneShotAccessor(obj, name, fun) { |
| 766 // Note that the accessors consistently operate on 'obj', not 'this'. | 766 // Note that the accessors consistently operate on 'obj', not 'this'. |
| 767 // Since the object may occur in someone else's prototype chain we | 767 // Since the object may occur in someone else's prototype chain we |
| 768 // can't rely on 'this' being the same as 'obj'. | 768 // can't rely on 'this' being the same as 'obj'. |
| 769 var hasBeenSet = false; | |
| 770 var value; | 769 var value; |
| 770 var getter_function = fun; | |
|
Vyacheslav Egorov (Google)
2012/08/28 16:43:43
Is there any reason why you can't simply use fun w
| |
| 771 var getter = function() { | 771 var getter = function() { |
| 772 if (hasBeenSet) { | 772 if (getter_function == null) { |
| 773 return value; | 773 return value; |
| 774 } | 774 } |
| 775 hasBeenSet = true; | 775 value = getter_function(obj); |
| 776 value = fun(obj); | 776 getter_function = null; |
| 777 return value; | 777 return value; |
| 778 }; | 778 }; |
| 779 var setter = function(v) { | 779 var setter = function(v) { |
| 780 hasBeenSet = true; | 780 getter_function = null; |
| 781 value = v; | 781 value = v; |
| 782 }; | 782 }; |
| 783 %DefineOrRedefineAccessorProperty(obj, name, getter, setter, DONT_ENUM); | 783 %DefineOrRedefineAccessorProperty(obj, name, getter, setter, DONT_ENUM); |
| 784 } | 784 } |
| 785 | 785 |
| 786 function CallSite(receiver, fun, pos) { | 786 function CallSite(receiver, fun, pos) { |
| 787 this.receiver = receiver; | 787 this.receiver = receiver; |
| 788 this.fun = fun; | 788 this.fun = fun; |
| 789 this.pos = pos; | 789 this.pos = pos; |
| 790 } | 790 } |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1259 throw e; | 1259 throw e; |
| 1260 } | 1260 } |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 | 1263 |
| 1264 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); | 1264 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); |
| 1265 | 1265 |
| 1266 // Boilerplate for exceptions for stack overflows. Used from | 1266 // Boilerplate for exceptions for stack overflows. Used from |
| 1267 // Isolate::StackOverflow(). | 1267 // Isolate::StackOverflow(). |
| 1268 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1268 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |