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

Side by Side Diff: src/v8natives.js

Issue 352173006: Clean up the global object naming madness. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 5 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
« no previous file with comments | « src/runtime.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Boolean = global.Boolean; 8 // var $Boolean = global.Boolean;
9 // var $Number = global.Number; 9 // var $Number = global.Number;
10 // var $Function = global.Function; 10 // var $Function = global.Function;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // For consistency with JSC we require the global object passed to 165 // For consistency with JSC we require the global object passed to
166 // eval to be the global object from which 'eval' originated. This 166 // eval to be the global object from which 'eval' originated. This
167 // is not mandated by the spec. 167 // is not mandated by the spec.
168 // We only throw if the global has been detached, since we need the 168 // We only throw if the global has been detached, since we need the
169 // receiver as this-value for the call. 169 // receiver as this-value for the call.
170 if (!%IsAttachedGlobal(global)) { 170 if (!%IsAttachedGlobal(global)) {
171 throw new $EvalError('The "this" value passed to eval must ' + 171 throw new $EvalError('The "this" value passed to eval must ' +
172 'be the global object from which eval originated'); 172 'be the global object from which eval originated');
173 } 173 }
174 174
175 var global_receiver = %GlobalReceiver(global); 175 var global_proxy = %GlobalProxy(global);
176 176
177 var f = %CompileString(x, false); 177 var f = %CompileString(x, false);
178 if (!IS_FUNCTION(f)) return f; 178 if (!IS_FUNCTION(f)) return f;
179 179
180 return %_CallFunction(global_receiver, f); 180 return %_CallFunction(global_proxy, f);
181 } 181 }
182 182
183 183
184 // ---------------------------------------------------------------------------- 184 // ----------------------------------------------------------------------------
185 185
186 // Set up global object. 186 // Set up global object.
187 function SetUpGlobal() { 187 function SetUpGlobal() {
188 %CheckIsBootstrapping(); 188 %CheckIsBootstrapping();
189 189
190 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; 190 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); 267 return IS_UNDEFINED(desc) ? false : desc.isEnumerable();
268 } 268 }
269 return %IsPropertyEnumerable(ToObject(this), P); 269 return %IsPropertyEnumerable(ToObject(this), P);
270 } 270 }
271 271
272 272
273 // Extensions for providing property getters and setters. 273 // Extensions for providing property getters and setters.
274 function ObjectDefineGetter(name, fun) { 274 function ObjectDefineGetter(name, fun) {
275 var receiver = this; 275 var receiver = this;
276 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 276 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
277 receiver = %GlobalReceiver(global); 277 receiver = %GlobalProxy(global);
278 } 278 }
279 if (!IS_SPEC_FUNCTION(fun)) { 279 if (!IS_SPEC_FUNCTION(fun)) {
280 throw new $TypeError( 280 throw new $TypeError(
281 'Object.prototype.__defineGetter__: Expecting function'); 281 'Object.prototype.__defineGetter__: Expecting function');
282 } 282 }
283 var desc = new PropertyDescriptor(); 283 var desc = new PropertyDescriptor();
284 desc.setGet(fun); 284 desc.setGet(fun);
285 desc.setEnumerable(true); 285 desc.setEnumerable(true);
286 desc.setConfigurable(true); 286 desc.setConfigurable(true);
287 DefineOwnProperty(ToObject(receiver), ToName(name), desc, false); 287 DefineOwnProperty(ToObject(receiver), ToName(name), desc, false);
288 } 288 }
289 289
290 290
291 function ObjectLookupGetter(name) { 291 function ObjectLookupGetter(name) {
292 var receiver = this; 292 var receiver = this;
293 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 293 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
294 receiver = %GlobalReceiver(global); 294 receiver = %GlobalProxy(global);
295 } 295 }
296 return %LookupAccessor(ToObject(receiver), ToName(name), GETTER); 296 return %LookupAccessor(ToObject(receiver), ToName(name), GETTER);
297 } 297 }
298 298
299 299
300 function ObjectDefineSetter(name, fun) { 300 function ObjectDefineSetter(name, fun) {
301 var receiver = this; 301 var receiver = this;
302 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 302 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
303 receiver = %GlobalReceiver(global); 303 receiver = %GlobalProxy(global);
304 } 304 }
305 if (!IS_SPEC_FUNCTION(fun)) { 305 if (!IS_SPEC_FUNCTION(fun)) {
306 throw new $TypeError( 306 throw new $TypeError(
307 'Object.prototype.__defineSetter__: Expecting function'); 307 'Object.prototype.__defineSetter__: Expecting function');
308 } 308 }
309 var desc = new PropertyDescriptor(); 309 var desc = new PropertyDescriptor();
310 desc.setSet(fun); 310 desc.setSet(fun);
311 desc.setEnumerable(true); 311 desc.setEnumerable(true);
312 desc.setConfigurable(true); 312 desc.setConfigurable(true);
313 DefineOwnProperty(ToObject(receiver), ToName(name), desc, false); 313 DefineOwnProperty(ToObject(receiver), ToName(name), desc, false);
314 } 314 }
315 315
316 316
317 function ObjectLookupSetter(name) { 317 function ObjectLookupSetter(name) {
318 var receiver = this; 318 var receiver = this;
319 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 319 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
320 receiver = %GlobalReceiver(global); 320 receiver = %GlobalProxy(global);
321 } 321 }
322 return %LookupAccessor(ToObject(receiver), ToName(name), SETTER); 322 return %LookupAccessor(ToObject(receiver), ToName(name), SETTER);
323 } 323 }
324 324
325 325
326 function ObjectKeys(obj) { 326 function ObjectKeys(obj) {
327 if (!IS_SPEC_OBJECT(obj)) { 327 if (!IS_SPEC_OBJECT(obj)) {
328 throw MakeTypeError("called_on_non_object", ["Object.keys"]); 328 throw MakeTypeError("called_on_non_object", ["Object.keys"]);
329 } 329 }
330 if (%IsJSProxy(obj)) { 330 if (%IsJSProxy(obj)) {
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 // comments we can include a trailing block comment to catch this. 1824 // comments we can include a trailing block comment to catch this.
1825 p += '\n/' + '**/'; 1825 p += '\n/' + '**/';
1826 } 1826 }
1827 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; 1827 var body = (n > 0) ? ToString(arguments[n - 1]) : '';
1828 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; 1828 return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
1829 } 1829 }
1830 1830
1831 1831
1832 function FunctionConstructor(arg1) { // length == 1 1832 function FunctionConstructor(arg1) { // length == 1
1833 var source = NewFunctionString(arguments, 'function'); 1833 var source = NewFunctionString(arguments, 'function');
1834 var global_receiver = %GlobalReceiver(global); 1834 var global_proxy = %GlobalProxy(global);
1835 // Compile the string in the constructor and not a helper so that errors 1835 // Compile the string in the constructor and not a helper so that errors
1836 // appear to come from here. 1836 // appear to come from here.
1837 var f = %CompileString(source, true); 1837 var f = %CompileString(source, true);
1838 if (!IS_FUNCTION(f)) return f; 1838 if (!IS_FUNCTION(f)) return f;
1839 f = %_CallFunction(global_receiver, f); 1839 f = %_CallFunction(global_proxy, f);
1840 %FunctionMarkNameShouldPrintAsAnonymous(f); 1840 %FunctionMarkNameShouldPrintAsAnonymous(f);
1841 return f; 1841 return f;
1842 } 1842 }
1843 1843
1844 1844
1845 // ---------------------------------------------------------------------------- 1845 // ----------------------------------------------------------------------------
1846 1846
1847 function SetUpFunction() { 1847 function SetUpFunction() {
1848 %CheckIsBootstrapping(); 1848 %CheckIsBootstrapping();
1849 1849
1850 %SetCode($Function, FunctionConstructor); 1850 %SetCode($Function, FunctionConstructor);
1851 %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1851 %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1852 1852
1853 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1853 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1854 "bind", FunctionBind, 1854 "bind", FunctionBind,
1855 "toString", FunctionToString 1855 "toString", FunctionToString
1856 )); 1856 ));
1857 } 1857 }
1858 1858
1859 SetUpFunction(); 1859 SetUpFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698