Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Unified Diff: src/messages.js

Issue 11368136: Fix behavior of oneshot accessors of error objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/error-accessors.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 7d0c6bda42f1931e01c787959395caf64cae3b50..81619b32c9019150a7472c4e14c8b30956dc3660 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -768,23 +768,18 @@ function GetStackTraceLine(recv, fun, pos, isGlobal) {
// Defines accessors for a property that is calculated the first time
// the property is read.
-function DefineOneShotAccessor(obj, name, fun) {
- // Note that the accessors consistently operate on 'obj', not 'this'.
- // Since the object may occur in someone else's prototype chain we
- // can't rely on 'this' being the same as 'obj'.
- var value;
- var value_factory = fun;
+function DefineOneShotAccessor(obj, name, value_factory) {
+ // Note that 'obj' may be different than 'this' since obj may be on the
+ // prototype chain of 'this'.
var getter = function() {
- if (value_factory == null) {
- return value;
- }
- value = value_factory(obj);
- value_factory = null;
+ var value = value_factory(obj);
+ delete obj[name];
+ obj[name] = value;
return value;
};
var setter = function(v) {
- value_factory = null;
- value = v;
+ // Set the property for 'this', ignoring this setter.
+ %DefineOrRedefineDataProperty(this, name, v, NONE);
};
%DefineOrRedefineAccessorProperty(obj, name, getter, setter, DONT_ENUM);
}
« no previous file with comments | « no previous file | test/mjsunit/error-accessors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698