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

Side by Side Diff: src/v8natives.js

Issue 6677076: Merge up to bleeding_edge r7201 to isolates branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/isolates
Patch Set: Fix lint. Created 9 years, 9 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/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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 245
246 // Extensions for providing property getters and setters. 246 // Extensions for providing property getters and setters.
247 function ObjectDefineGetter(name, fun) { 247 function ObjectDefineGetter(name, fun) {
248 if (this == null && !IS_UNDETECTABLE(this)) { 248 if (this == null && !IS_UNDETECTABLE(this)) {
249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); 249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null');
250 } 250 }
251 if (!IS_FUNCTION(fun)) { 251 if (!IS_FUNCTION(fun)) {
252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' ); 252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' );
253 } 253 }
254 return %DefineAccessor(ToObject(this), ToString(name), GETTER, fun); 254 var desc = new PropertyDescriptor();
255 desc.setGet(fun);
256 desc.setEnumerable(true);
257 desc.setConfigurable(true);
258 DefineOwnProperty(ToObject(this), ToString(name), desc, false);
255 } 259 }
256 260
257 261
258 function ObjectLookupGetter(name) { 262 function ObjectLookupGetter(name) {
259 if (this == null && !IS_UNDETECTABLE(this)) { 263 if (this == null && !IS_UNDETECTABLE(this)) {
260 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); 264 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null');
261 } 265 }
262 return %LookupAccessor(ToObject(this), ToString(name), GETTER); 266 return %LookupAccessor(ToObject(this), ToString(name), GETTER);
263 } 267 }
264 268
265 269
266 function ObjectDefineSetter(name, fun) { 270 function ObjectDefineSetter(name, fun) {
267 if (this == null && !IS_UNDETECTABLE(this)) { 271 if (this == null && !IS_UNDETECTABLE(this)) {
268 throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); 272 throw new $TypeError('Object.prototype.__defineSetter__: this is Null');
269 } 273 }
270 if (!IS_FUNCTION(fun)) { 274 if (!IS_FUNCTION(fun)) {
271 throw new $TypeError( 275 throw new $TypeError(
272 'Object.prototype.__defineSetter__: Expecting function'); 276 'Object.prototype.__defineSetter__: Expecting function');
273 } 277 }
274 return %DefineAccessor(ToObject(this), ToString(name), SETTER, fun); 278 var desc = new PropertyDescriptor();
279 desc.setSet(fun);
280 desc.setEnumerable(true);
281 desc.setConfigurable(true);
282 DefineOwnProperty(ToObject(this), ToString(name), desc, false);
275 } 283 }
276 284
277 285
278 function ObjectLookupSetter(name) { 286 function ObjectLookupSetter(name) {
279 if (this == null && !IS_UNDETECTABLE(this)) { 287 if (this == null && !IS_UNDETECTABLE(this)) {
280 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); 288 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null');
281 } 289 }
282 return %LookupAccessor(ToObject(this), ToString(name), SETTER); 290 return %LookupAccessor(ToObject(this), ToString(name), SETTER);
283 } 291 }
284 292
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 this.enumerable_ = false; 395 this.enumerable_ = false;
388 this.hasEnumerable_ = false; 396 this.hasEnumerable_ = false;
389 this.configurable_ = false; 397 this.configurable_ = false;
390 this.hasConfigurable_ = false; 398 this.hasConfigurable_ = false;
391 this.get_ = void 0; 399 this.get_ = void 0;
392 this.hasGetter_ = false; 400 this.hasGetter_ = false;
393 this.set_ = void 0; 401 this.set_ = void 0;
394 this.hasSetter_ = false; 402 this.hasSetter_ = false;
395 } 403 }
396 404
405 PropertyDescriptor.prototype.__proto__ = null;
406 PropertyDescriptor.prototype.toString = function() {
407 return "[object PropertyDescriptor]";
408 };
397 409
398 PropertyDescriptor.prototype.setValue = function(value) { 410 PropertyDescriptor.prototype.setValue = function(value) {
399 this.value_ = value; 411 this.value_ = value;
400 this.hasValue_ = true; 412 this.hasValue_ = true;
401 } 413 }
402 414
403 415
404 PropertyDescriptor.prototype.getValue = function() { 416 PropertyDescriptor.prototype.getValue = function() {
405 return this.value_; 417 return this.value_;
406 } 418 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 function DefineOwnProperty(obj, p, desc, should_throw) { 566 function DefineOwnProperty(obj, p, desc, should_throw) {
555 var current_or_access = %GetOwnProperty(ToObject(obj), ToString(p)); 567 var current_or_access = %GetOwnProperty(ToObject(obj), ToString(p));
556 // A false value here means that access checks failed. 568 // A false value here means that access checks failed.
557 if (current_or_access === false) return void 0; 569 if (current_or_access === false) return void 0;
558 570
559 var current = ConvertDescriptorArrayToDescriptor(current_or_access); 571 var current = ConvertDescriptorArrayToDescriptor(current_or_access);
560 var extensible = %IsExtensible(ToObject(obj)); 572 var extensible = %IsExtensible(ToObject(obj));
561 573
562 // Error handling according to spec. 574 // Error handling according to spec.
563 // Step 3 575 // Step 3
564 if (IS_UNDEFINED(current) && !extensible) 576 if (IS_UNDEFINED(current) && !extensible) {
565 throw MakeTypeError("define_disallowed", ["defineProperty"]); 577 if (should_throw) {
578 throw MakeTypeError("define_disallowed", ["defineProperty"]);
579 } else {
580 return;
581 }
582 }
566 583
567 if (!IS_UNDEFINED(current)) { 584 if (!IS_UNDEFINED(current)) {
568 // Step 5 and 6 585 // Step 5 and 6
569 if ((IsGenericDescriptor(desc) || 586 if ((IsGenericDescriptor(desc) ||
570 IsDataDescriptor(desc) == IsDataDescriptor(current)) && 587 IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
571 (!desc.hasEnumerable() || 588 (!desc.hasEnumerable() ||
572 SameValue(desc.isEnumerable(), current.isEnumerable())) && 589 SameValue(desc.isEnumerable(), current.isEnumerable())) &&
573 (!desc.hasConfigurable() || 590 (!desc.hasConfigurable() ||
574 SameValue(desc.isConfigurable(), current.isConfigurable())) && 591 SameValue(desc.isConfigurable(), current.isConfigurable())) &&
575 (!desc.hasWritable() || 592 (!desc.hasWritable() ||
576 SameValue(desc.isWritable(), current.isWritable())) && 593 SameValue(desc.isWritable(), current.isWritable())) &&
577 (!desc.hasValue() || 594 (!desc.hasValue() ||
578 SameValue(desc.getValue(), current.getValue())) && 595 SameValue(desc.getValue(), current.getValue())) &&
579 (!desc.hasGetter() || 596 (!desc.hasGetter() ||
580 SameValue(desc.getGet(), current.getGet())) && 597 SameValue(desc.getGet(), current.getGet())) &&
581 (!desc.hasSetter() || 598 (!desc.hasSetter() ||
582 SameValue(desc.getSet(), current.getSet()))) { 599 SameValue(desc.getSet(), current.getSet()))) {
583 return true; 600 return true;
584 } 601 }
585 if (!current.isConfigurable()) { 602 if (!current.isConfigurable()) {
586 // Step 7 603 // Step 7
587 if (desc.isConfigurable() || 604 if (desc.isConfigurable() ||
588 (desc.hasEnumerable() && 605 (desc.hasEnumerable() &&
589 desc.isEnumerable() != current.isEnumerable())) { 606 desc.isEnumerable() != current.isEnumerable())) {
590 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 607 if (should_throw) {
608 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
609 } else {
610 return;
611 }
591 } 612 }
592 // Step 8 613 // Step 8
593 if (!IsGenericDescriptor(desc)) { 614 if (!IsGenericDescriptor(desc)) {
594 // Step 9a 615 // Step 9a
595 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { 616 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
596 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 617 if (should_throw) {
618 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
619 } else {
620 return;
621 }
597 } 622 }
598 // Step 10a 623 // Step 10a
599 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 624 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
600 if (!current.isWritable() && desc.isWritable()) { 625 if (!current.isWritable() && desc.isWritable()) {
601 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 626 if (should_throw) {
627 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
628 } else {
629 return;
630 }
602 } 631 }
603 if (!current.isWritable() && desc.hasValue() && 632 if (!current.isWritable() && desc.hasValue() &&
604 !SameValue(desc.getValue(), current.getValue())) { 633 !SameValue(desc.getValue(), current.getValue())) {
605 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 634 if (should_throw) {
635 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
636 } else {
637 return;
638 }
606 } 639 }
607 } 640 }
608 // Step 11 641 // Step 11
609 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { 642 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
610 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { 643 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) {
611 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 644 if (should_throw) {
645 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
646 } else {
647 return;
648 }
612 } 649 }
613 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { 650 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) {
614 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 651 if (should_throw) {
652 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
653 } else {
654 return;
655 }
615 } 656 }
616 } 657 }
617 } 658 }
618 } 659 }
619 } 660 }
620 661
621 // Send flags - enumerable and configurable are common - writable is 662 // Send flags - enumerable and configurable are common - writable is
622 // only send to the data descriptor. 663 // only send to the data descriptor.
623 // Take special care if enumerable and configurable is not defined on 664 // Take special care if enumerable and configurable is not defined on
624 // desc (we need to preserve the existing values from current). 665 // desc (we need to preserve the existing values from current).
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 // ---------------------------------------------------------------------------- 1284 // ----------------------------------------------------------------------------
1244 1285
1245 function SetupFunction() { 1286 function SetupFunction() {
1246 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1287 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1247 "bind", FunctionBind, 1288 "bind", FunctionBind,
1248 "toString", FunctionToString 1289 "toString", FunctionToString
1249 )); 1290 ));
1250 } 1291 }
1251 1292
1252 SetupFunction(); 1293 SetupFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698