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

Side by Side Diff: src/v8natives.js

Issue 7068009: Pass undefined to JS builtins when called with implicit receiver. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 function GlobalParseFloat(string) { 125 function GlobalParseFloat(string) {
126 string = TO_STRING_INLINE(string); 126 string = TO_STRING_INLINE(string);
127 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); 127 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string);
128 return %StringParseFloat(string); 128 return %StringParseFloat(string);
129 } 129 }
130 130
131 131
132 function GlobalEval(x) { 132 function GlobalEval(x) {
133 if (!IS_STRING(x)) return x; 133 if (!IS_STRING(x)) return x;
134 134
135 var receiver = this;
136 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.
137
135 var global_receiver = %GlobalReceiver(global); 138 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.
136 var this_is_global_receiver = (this === global_receiver); 139 var this_is_global_receiver = (receiver === global_receiver);
137 var global_is_detached = (global === global_receiver); 140 var global_is_detached = (global === global_receiver);
138 141
139 if (!this_is_global_receiver || global_is_detached) { 142 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.
140 throw new $EvalError('The "this" object passed to eval must ' + 143 throw new $EvalError('The "this" object passed to eval must ' +
141 'be the global object from which eval originated'); 144 'be the global object from which eval originated');
142 } 145 }
143 146
144 var f = %CompileString(x); 147 var f = %CompileString(x);
145 if (!IS_FUNCTION(f)) return f; 148 if (!IS_FUNCTION(f)) return f;
146 149
147 return %_CallFunction(this, f); 150 return %_CallFunction(receiver, f);
148 } 151 }
149 152
150 153
151 // ---------------------------------------------------------------------------- 154 // ----------------------------------------------------------------------------
152 155
153 156
154 function SetupGlobal() { 157 function SetupGlobal() {
155 // ECMA 262 - 15.1.1.1. 158 // ECMA 262 - 15.1.1.1.
156 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); 159 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE);
157 160
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 242
240 243
241 // ECMA-262 - 15.2.4.6 244 // ECMA-262 - 15.2.4.6
242 function ObjectPropertyIsEnumerable(V) { 245 function ObjectPropertyIsEnumerable(V) {
243 return %IsPropertyEnumerable(ToObject(this), ToString(V)); 246 return %IsPropertyEnumerable(ToObject(this), ToString(V));
244 } 247 }
245 248
246 249
247 // Extensions for providing property getters and setters. 250 // Extensions for providing property getters and setters.
248 function ObjectDefineGetter(name, fun) { 251 function ObjectDefineGetter(name, fun) {
249 if (this == null && !IS_UNDETECTABLE(this)) { 252 var receiver = this;
250 throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); 253 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
254 receiver = %GlobalReceiver(global);
251 } 255 }
252 if (!IS_FUNCTION(fun)) { 256 if (!IS_FUNCTION(fun)) {
253 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' ); 257 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' );
254 } 258 }
255 var desc = new PropertyDescriptor(); 259 var desc = new PropertyDescriptor();
256 desc.setGet(fun); 260 desc.setGet(fun);
257 desc.setEnumerable(true); 261 desc.setEnumerable(true);
258 desc.setConfigurable(true); 262 desc.setConfigurable(true);
259 DefineOwnProperty(ToObject(this), ToString(name), desc, false); 263 DefineOwnProperty(ToObject(receiver), ToString(name), desc, false);
260 } 264 }
261 265
262 266
263 function ObjectLookupGetter(name) { 267 function ObjectLookupGetter(name) {
264 if (this == null && !IS_UNDETECTABLE(this)) { 268 var receiver = this;
265 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); 269 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
270 receiver = %GlobalReceiver(global);
266 } 271 }
267 return %LookupAccessor(ToObject(this), ToString(name), GETTER); 272 return %LookupAccessor(ToObject(receiver), ToString(name), GETTER);
268 } 273 }
269 274
270 275
271 function ObjectDefineSetter(name, fun) { 276 function ObjectDefineSetter(name, fun) {
272 if (this == null && !IS_UNDETECTABLE(this)) { 277 var receiver = this;
273 throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); 278 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
279 receiver = %GlobalReceiver(global);
274 } 280 }
275 if (!IS_FUNCTION(fun)) { 281 if (!IS_FUNCTION(fun)) {
276 throw new $TypeError( 282 throw new $TypeError(
277 'Object.prototype.__defineSetter__: Expecting function'); 283 'Object.prototype.__defineSetter__: Expecting function');
278 } 284 }
279 var desc = new PropertyDescriptor(); 285 var desc = new PropertyDescriptor();
280 desc.setSet(fun); 286 desc.setSet(fun);
281 desc.setEnumerable(true); 287 desc.setEnumerable(true);
282 desc.setConfigurable(true); 288 desc.setConfigurable(true);
283 DefineOwnProperty(ToObject(this), ToString(name), desc, false); 289 DefineOwnProperty(ToObject(receiver), ToString(name), desc, false);
284 } 290 }
285 291
286 292
287 function ObjectLookupSetter(name) { 293 function ObjectLookupSetter(name) {
288 if (this == null && !IS_UNDETECTABLE(this)) { 294 var receiver = this;
289 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); 295 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
296 receiver = %GlobalReceiver(global);
290 } 297 }
291 return %LookupAccessor(ToObject(this), ToString(name), SETTER); 298 return %LookupAccessor(ToObject(receiver), ToString(name), SETTER);
292 } 299 }
293 300
294 301
295 function ObjectKeys(obj) { 302 function ObjectKeys(obj) {
296 if (!IS_SPEC_OBJECT(obj)) 303 if (!IS_SPEC_OBJECT(obj))
297 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); 304 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]);
298 return %LocalKeys(obj); 305 return %LocalKeys(obj);
299 } 306 }
300 307
301 308
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 // ---------------------------------------------------------------------------- 1308 // ----------------------------------------------------------------------------
1302 1309
1303 function SetupFunction() { 1310 function SetupFunction() {
1304 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1311 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1305 "bind", FunctionBind, 1312 "bind", FunctionBind,
1306 "toString", FunctionToString 1313 "toString", FunctionToString
1307 )); 1314 ));
1308 } 1315 }
1309 1316
1310 SetupFunction(); 1317 SetupFunction();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698