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

Side by Side Diff: src/v8natives.js

Issue 214051: Pushed 1.3.12 to trunk. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 2 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/v8-counters.h ('k') | src/version.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 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 270
271 function ObjectLookupSetter(name) { 271 function ObjectLookupSetter(name) {
272 if (this == null) { 272 if (this == null) {
273 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); 273 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null');
274 } 274 }
275 return %LookupAccessor(ToObject(this), ToString(name), SETTER); 275 return %LookupAccessor(ToObject(this), ToString(name), SETTER);
276 } 276 }
277 277
278 278
279 function ObjectKeys(obj) {
280 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
281 throw MakeTypeError('object_keys_non_object', [obj]);
282 return %LocalKeys(obj);
283 }
284
285
279 %SetCode($Object, function(x) { 286 %SetCode($Object, function(x) {
280 if (%_IsConstructCall()) { 287 if (%_IsConstructCall()) {
281 if (x == null) return this; 288 if (x == null) return this;
282 return ToObject(x); 289 return ToObject(x);
283 } else { 290 } else {
284 if (x == null) return { }; 291 if (x == null) return { };
285 return ToObject(x); 292 return ToObject(x);
286 } 293 }
287 }); 294 });
288 295
289 296
290 // ---------------------------------------------------------------------------- 297 // ----------------------------------------------------------------------------
291 298
292 299
293 function SetupObject() { 300 function SetupObject() {
294 // Setup non-enumerable functions on the Object.prototype object. 301 // Setup non-enumerable functions on the Object.prototype object.
295 InstallFunctions($Object.prototype, DONT_ENUM, $Array( 302 InstallFunctions($Object.prototype, DONT_ENUM, $Array(
296 "toString", ObjectToString, 303 "toString", ObjectToString,
297 "toLocaleString", ObjectToLocaleString, 304 "toLocaleString", ObjectToLocaleString,
298 "valueOf", ObjectValueOf, 305 "valueOf", ObjectValueOf,
299 "hasOwnProperty", ObjectHasOwnProperty, 306 "hasOwnProperty", ObjectHasOwnProperty,
300 "isPrototypeOf", ObjectIsPrototypeOf, 307 "isPrototypeOf", ObjectIsPrototypeOf,
301 "propertyIsEnumerable", ObjectPropertyIsEnumerable, 308 "propertyIsEnumerable", ObjectPropertyIsEnumerable,
302 "__defineGetter__", ObjectDefineGetter, 309 "__defineGetter__", ObjectDefineGetter,
303 "__lookupGetter__", ObjectLookupGetter, 310 "__lookupGetter__", ObjectLookupGetter,
304 "__defineSetter__", ObjectDefineSetter, 311 "__defineSetter__", ObjectDefineSetter,
305 "__lookupSetter__", ObjectLookupSetter 312 "__lookupSetter__", ObjectLookupSetter
306 )); 313 ));
314 InstallFunctions($Object, DONT_ENUM, $Array(
315 "keys", ObjectKeys
316 ));
307 } 317 }
308 318
309 SetupObject(); 319 SetupObject();
310 320
311 321
312 // ---------------------------------------------------------------------------- 322 // ----------------------------------------------------------------------------
313 // Boolean 323 // Boolean
314 324
315 function BooleanToString() { 325 function BooleanToString() {
316 // NOTE: Both Boolean objects and values can enter here as 326 // NOTE: Both Boolean objects and values can enter here as
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // Function 517 // Function
508 518
509 $Function.prototype.constructor = $Function; 519 $Function.prototype.constructor = $Function;
510 520
511 function FunctionSourceString(func) { 521 function FunctionSourceString(func) {
512 if (!IS_FUNCTION(func)) { 522 if (!IS_FUNCTION(func)) {
513 throw new $TypeError('Function.prototype.toString is not generic'); 523 throw new $TypeError('Function.prototype.toString is not generic');
514 } 524 }
515 525
516 var source = %FunctionGetSourceCode(func); 526 var source = %FunctionGetSourceCode(func);
517 if (!IS_STRING(source)) { 527 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
518 var name = %FunctionGetName(func); 528 var name = %FunctionGetName(func);
519 if (name) { 529 if (name) {
520 // Mimic what KJS does. 530 // Mimic what KJS does.
521 return 'function ' + name + '() { [native code] }'; 531 return 'function ' + name + '() { [native code] }';
522 } else { 532 } else {
523 return 'function () { [native code] }'; 533 return 'function () { [native code] }';
524 } 534 }
525 } 535 }
526 536
527 // Censor occurrences of internal calls. We do that for all
528 // functions and don't cache under the assumption that people rarly
529 // convert functions to strings. Note that we (apparently) can't
530 // use regular expression literals in natives files.
531 var regexp = ORIGINAL_REGEXP("%(\\w+\\()", "gm");
532 if (source.match(regexp)) source = source.replace(regexp, "$1");
533 var name = %FunctionGetName(func); 537 var name = %FunctionGetName(func);
534 return 'function ' + name + source; 538 return 'function ' + name + source;
535 } 539 }
536 540
537 541
538 function FunctionToString() { 542 function FunctionToString() {
539 return FunctionSourceString(this); 543 return FunctionSourceString(this);
540 } 544 }
541 545
542 546
(...skipping 26 matching lines...) Expand all
569 573
570 // ---------------------------------------------------------------------------- 574 // ----------------------------------------------------------------------------
571 575
572 function SetupFunction() { 576 function SetupFunction() {
573 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 577 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
574 "toString", FunctionToString 578 "toString", FunctionToString
575 )); 579 ));
576 } 580 }
577 581
578 SetupFunction(); 582 SetupFunction();
OLDNEW
« no previous file with comments | « src/v8-counters.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698