Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index d22e94d85ee5416bfdab7d48ae5e23b469084858..510b0359bcd2288dcb9d9d54f2c9827aacbf3f0e 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -132,8 +132,11 @@ function GlobalParseFloat(string) { |
| function GlobalEval(x) { |
| if (!IS_STRING(x)) return x; |
| + var receiver = this; |
| + if (receiver == null) receiver = %GlobalReceiver(global); |
|
Lasse Reichstein
2011/05/26 08:26:55
Also if undetectable?
Mads Ager (chromium)
2011/05/26 10:14:07
No, you are right.
|
| + |
| var global_receiver = %GlobalReceiver(global); |
|
Lasse Reichstein
2011/05/26 08:26:55
Duplicate call to runtime function %GlobalReceiver
Mads Ager (chromium)
2011/05/26 10:14:07
Done.
|
| - var this_is_global_receiver = (this === global_receiver); |
| + var this_is_global_receiver = (receiver === global_receiver); |
| var global_is_detached = (global === global_receiver); |
| if (!this_is_global_receiver || global_is_detached) { |
|
Lasse Reichstein
2011/05/26 08:26:55
Could we make a comment that this test is jsut to
Mads Ager (chromium)
2011/05/26 10:14:07
Done.
|
| @@ -144,7 +147,7 @@ function GlobalEval(x) { |
| var f = %CompileString(x); |
| if (!IS_FUNCTION(f)) return f; |
| - return %_CallFunction(this, f); |
| + return %_CallFunction(receiver, f); |
| } |
| @@ -246,8 +249,9 @@ function ObjectPropertyIsEnumerable(V) { |
| // Extensions for providing property getters and setters. |
| function ObjectDefineGetter(name, fun) { |
| - if (this == null && !IS_UNDETECTABLE(this)) { |
| - throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); |
| + var receiver = this; |
| + if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
| + receiver = %GlobalReceiver(global); |
| } |
| if (!IS_FUNCTION(fun)) { |
| throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'); |
| @@ -256,21 +260,23 @@ function ObjectDefineGetter(name, fun) { |
| desc.setGet(fun); |
| desc.setEnumerable(true); |
| desc.setConfigurable(true); |
| - DefineOwnProperty(ToObject(this), ToString(name), desc, false); |
| + DefineOwnProperty(ToObject(receiver), ToString(name), desc, false); |
| } |
| function ObjectLookupGetter(name) { |
| - if (this == null && !IS_UNDETECTABLE(this)) { |
| - throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); |
| + var receiver = this; |
| + if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
| + receiver = %GlobalReceiver(global); |
| } |
| - return %LookupAccessor(ToObject(this), ToString(name), GETTER); |
| + return %LookupAccessor(ToObject(receiver), ToString(name), GETTER); |
| } |
| function ObjectDefineSetter(name, fun) { |
| - if (this == null && !IS_UNDETECTABLE(this)) { |
| - throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); |
| + var receiver = this; |
| + if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
| + receiver = %GlobalReceiver(global); |
| } |
| if (!IS_FUNCTION(fun)) { |
| throw new $TypeError( |
| @@ -280,15 +286,16 @@ function ObjectDefineSetter(name, fun) { |
| desc.setSet(fun); |
| desc.setEnumerable(true); |
| desc.setConfigurable(true); |
| - DefineOwnProperty(ToObject(this), ToString(name), desc, false); |
| + DefineOwnProperty(ToObject(receiver), ToString(name), desc, false); |
| } |
| function ObjectLookupSetter(name) { |
| - if (this == null && !IS_UNDETECTABLE(this)) { |
| - throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); |
| + var receiver = this; |
| + if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
| + receiver = %GlobalReceiver(global); |
| } |
| - return %LookupAccessor(ToObject(this), ToString(name), SETTER); |
| + return %LookupAccessor(ToObject(receiver), ToString(name), SETTER); |
| } |