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

Side by Side Diff: src/v8natives.js

Issue 546032: Enabled es5conform tests for new array methods and corrected errors that was ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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') | test/es5conform/es5conform.status » ('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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // ES5 8.10.3. 298 // ES5 8.10.3.
299 function IsGenericDescriptor(desc) { 299 function IsGenericDescriptor(desc) {
300 return !(IsAccessorDescriptor(desc) || IsDataDescriptor(desc)); 300 return !(IsAccessorDescriptor(desc) || IsDataDescriptor(desc));
301 } 301 }
302 302
303 303
304 function IsInconsistentDescriptor(desc) { 304 function IsInconsistentDescriptor(desc) {
305 return IsAccessorDescriptor(desc) && IsDataDescriptor(desc); 305 return IsAccessorDescriptor(desc) && IsDataDescriptor(desc);
306 } 306 }
307 307
308 // ES5 8.10.4
309 function FromPropertyDescriptor(desc) {
310 if(IS_UNDEFINED(desc)) return desc;
311 var obj = new $Object();
312 if (IsDataDescriptor(desc)) {
313 obj.value = desc.getValue();
314 obj.writable = desc.isWritable();
315 }
316 if (IsAccessorDescriptor(desc)) {
317 obj.get = desc.getGet();
318 obj.set = desc.getSet();
319 }
320 obj.enumerable = desc.isEnumerable();
321 obj.configurable = desc.isConfigurable();
322 return obj;
323 }
308 324
309 // ES5 8.10.5. 325 // ES5 8.10.5.
310 function ToPropertyDescriptor(obj) { 326 function ToPropertyDescriptor(obj) {
311 if (!IS_OBJECT(obj)) { 327 if (!IS_OBJECT(obj)) {
312 throw MakeTypeError("property_desc_object", [obj]); 328 throw MakeTypeError("property_desc_object", [obj]);
313 } 329 }
314 var desc = new PropertyDescriptor(); 330 var desc = new PropertyDescriptor();
315 331
316 if ("enumerable" in obj) { 332 if ("enumerable" in obj) {
317 desc.setEnumerable(ToBoolean(obj.enumerable)); 333 desc.setEnumerable(ToBoolean(obj.enumerable));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 this.set_ = set; 442 this.set_ = set;
427 this.hasSetter_ = true; 443 this.hasSetter_ = true;
428 } 444 }
429 445
430 446
431 PropertyDescriptor.prototype.getSet = function() { 447 PropertyDescriptor.prototype.getSet = function() {
432 return this.set_; 448 return this.set_;
433 } 449 }
434 450
435 451
452 // ES5 section 8.12.1.
453 function GetOwnProperty(obj, p) {
454 var desc = new PropertyDescriptor();
455
456 // An array with:
457 // obj is a data property [false, value, Writeable, Enumerable, Configurable]
458 // obj is an accessor [true, Get, Set, Enumerable, Configurable]
459 var props = %GetOwnProperty(ToObject(obj), ToString(p));
460
461 if (IS_UNDEFINED(props))
462 return void 0;
463
464 // This is an accessor
465 if (props[0]) {
466 desc.setGet(props[1]);
467 desc.setSet(props[2]);
468 } else {
469 desc.setValue(props[1]);
470 desc.setWritable(props[2]);
471 }
472 desc.setEnumerable(props[3]);
473 desc.setConfigurable(props[4]);
474
475 return desc;
476 }
477
478
436 // ES5 8.12.9. This version cannot cope with the property p already 479 // ES5 8.12.9. This version cannot cope with the property p already
437 // being present on obj. 480 // being present on obj.
438 function DefineOwnProperty(obj, p, desc, should_throw) { 481 function DefineOwnProperty(obj, p, desc, should_throw) {
439 var flag = desc.isEnumerable() ? 0 : DONT_ENUM; 482 var flag = desc.isEnumerable() ? 0 : DONT_ENUM;
440 if (IsDataDescriptor(desc)) { 483 if (IsDataDescriptor(desc)) {
441 flag |= desc.isWritable() ? 0 : (DONT_DELETE | READ_ONLY); 484 flag |= desc.isWritable() ? 0 : (DONT_DELETE | READ_ONLY);
442 %SetProperty(obj, p, desc.getValue(), flag); 485 %SetProperty(obj, p, desc.getValue(), flag);
443 } else { 486 } else {
444 if (IS_FUNCTION(desc.getGet())) %DefineAccessor(obj, p, GETTER, desc.getGet( ), flag); 487 if (IS_FUNCTION(desc.getGet())) %DefineAccessor(obj, p, GETTER, desc.getGet( ), flag);
445 if (IS_FUNCTION(desc.getSet())) %DefineAccessor(obj, p, SETTER, desc.getSet( ), flag); 488 if (IS_FUNCTION(desc.getSet())) %DefineAccessor(obj, p, SETTER, desc.getSet( ), flag);
446 } 489 }
447 return true; 490 return true;
448 } 491 }
449 492
450 493
451 // ES5 section 15.2.3.2. 494 // ES5 section 15.2.3.2.
452 function ObjectGetPrototypeOf(obj) { 495 function ObjectGetPrototypeOf(obj) {
453 if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) { 496 if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) {
454 throw MakeTypeError("object_get_prototype_non_object", [obj]); 497 throw MakeTypeError("object_get_prototype_non_object", [obj]);
455 } 498 }
456 return obj.__proto__; 499 return obj.__proto__;
457 } 500 }
458 501
459 502
503 // ES5 section 15.2.3.3
504 function ObjectGetOwnPropertyDescriptor(obj, p) {
505 if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) {
506 throw MakeTypeError("object_get_prototype_non_object", [obj]);
507 }
508 var desc = GetOwnProperty(obj, p);
509 return FromPropertyDescriptor(desc);
510 }
511
512
460 // ES5 section 15.2.3.5. 513 // ES5 section 15.2.3.5.
461 function ObjectCreate(proto, properties) { 514 function ObjectCreate(proto, properties) {
462 if (!IS_OBJECT(proto) && !IS_NULL(proto)) { 515 if (!IS_OBJECT(proto) && !IS_NULL(proto)) {
463 throw MakeTypeError("proto_object_or_null", [proto]); 516 throw MakeTypeError("proto_object_or_null", [proto]);
464 } 517 }
465 var obj = new $Object(); 518 var obj = new $Object();
466 obj.__proto__ = proto; 519 obj.__proto__ = proto;
467 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties); 520 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties);
468 return obj; 521 return obj;
469 } 522 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 "isPrototypeOf", ObjectIsPrototypeOf, 568 "isPrototypeOf", ObjectIsPrototypeOf,
516 "propertyIsEnumerable", ObjectPropertyIsEnumerable, 569 "propertyIsEnumerable", ObjectPropertyIsEnumerable,
517 "__defineGetter__", ObjectDefineGetter, 570 "__defineGetter__", ObjectDefineGetter,
518 "__lookupGetter__", ObjectLookupGetter, 571 "__lookupGetter__", ObjectLookupGetter,
519 "__defineSetter__", ObjectDefineSetter, 572 "__defineSetter__", ObjectDefineSetter,
520 "__lookupSetter__", ObjectLookupSetter 573 "__lookupSetter__", ObjectLookupSetter
521 )); 574 ));
522 InstallFunctions($Object, DONT_ENUM, $Array( 575 InstallFunctions($Object, DONT_ENUM, $Array(
523 "keys", ObjectKeys, 576 "keys", ObjectKeys,
524 "create", ObjectCreate, 577 "create", ObjectCreate,
525 "getPrototypeOf", ObjectGetPrototypeOf 578 "getPrototypeOf", ObjectGetPrototypeOf,
579 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor
526 )); 580 ));
527 } 581 }
528 582
529 SetupObject(); 583 SetupObject();
530 584
531 585
532 // ---------------------------------------------------------------------------- 586 // ----------------------------------------------------------------------------
533 // Boolean 587 // Boolean
534 588
535 function BooleanToString() { 589 function BooleanToString() {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 837
784 // ---------------------------------------------------------------------------- 838 // ----------------------------------------------------------------------------
785 839
786 function SetupFunction() { 840 function SetupFunction() {
787 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 841 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
788 "toString", FunctionToString 842 "toString", FunctionToString
789 )); 843 ));
790 } 844 }
791 845
792 SetupFunction(); 846 SetupFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/es5conform/es5conform.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698