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

Side by Side Diff: src/js/v8natives.js

Issue 1527583002: [proxies] Improve error messages. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. Created 5 years 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
« no previous file with comments | « src/js/proxy.js ('k') | src/messages.h » ('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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 468
469 return desc; 469 return desc;
470 } 470 }
471 471
472 472
473 // For Harmony proxies. 473 // For Harmony proxies.
474 function GetTrap(handler, name, defaultTrap) { 474 function GetTrap(handler, name, defaultTrap) {
475 var trap = handler[name]; 475 var trap = handler[name];
476 if (IS_UNDEFINED(trap)) { 476 if (IS_UNDEFINED(trap)) {
477 if (IS_UNDEFINED(defaultTrap)) { 477 if (IS_UNDEFINED(defaultTrap)) {
478 throw MakeTypeError(kProxyHandlerTrapMissing, handler, name); 478 throw MakeTypeError(kIllegalInvocation);
479 } 479 }
480 trap = defaultTrap; 480 trap = defaultTrap;
481 } else if (!IS_CALLABLE(trap)) { 481 } else if (!IS_CALLABLE(trap)) {
482 throw MakeTypeError(kProxyHandlerTrapMustBeCallable, handler, name); 482 throw MakeTypeError(kIllegalInvocation);
483 } 483 }
484 return trap; 484 return trap;
485 } 485 }
486 486
487 487
488 function CallTrap1(handler, name, defaultTrap, x) { 488 function CallTrap1(handler, name, defaultTrap, x) {
489 return %_Call(GetTrap(handler, name, defaultTrap), handler, x); 489 return %_Call(GetTrap(handler, name, defaultTrap), handler, x);
490 } 490 }
491 491
492 492
(...skipping 10 matching lines...) Expand all
503 if (%_IsJSProxy(obj)) { 503 if (%_IsJSProxy(obj)) {
504 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 504 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
505 if (IS_SYMBOL(v)) return UNDEFINED; 505 if (IS_SYMBOL(v)) return UNDEFINED;
506 506
507 var handler = %GetHandler(obj); 507 var handler = %GetHandler(obj);
508 var descriptor = CallTrap1( 508 var descriptor = CallTrap1(
509 handler, "getOwnPropertyDescriptor", UNDEFINED, p); 509 handler, "getOwnPropertyDescriptor", UNDEFINED, p);
510 if (IS_UNDEFINED(descriptor)) return descriptor; 510 if (IS_UNDEFINED(descriptor)) return descriptor;
511 var desc = ToCompletePropertyDescriptor(descriptor); 511 var desc = ToCompletePropertyDescriptor(descriptor);
512 if (!desc.isConfigurable()) { 512 if (!desc.isConfigurable()) {
513 throw MakeTypeError(kProxyPropNotConfigurable, 513 throw MakeTypeError(kIllegalInvocation);
514 handler, p, "getOwnPropertyDescriptor");
515 } 514 }
516 return desc; 515 return desc;
517 } 516 }
518 517
519 // GetOwnProperty returns an array indexed by the constants 518 // GetOwnProperty returns an array indexed by the constants
520 // defined in macros.py. 519 // defined in macros.py.
521 // If p is not a property on obj undefined is returned. 520 // If p is not a property on obj undefined is returned.
522 var props = %GetOwnProperty_Legacy(TO_OBJECT(obj), p); 521 var props = %GetOwnProperty_Legacy(TO_OBJECT(obj), p);
523 522
524 return ConvertDescriptorArrayToDescriptor(props); 523 return ConvertDescriptorArrayToDescriptor(props);
(...skipping 11 matching lines...) Expand all
536 535
537 // Harmony proxies. 536 // Harmony proxies.
538 function DefineProxyProperty(obj, p, attributes, should_throw) { 537 function DefineProxyProperty(obj, p, attributes, should_throw) {
539 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 538 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
540 if (IS_SYMBOL(p)) return false; 539 if (IS_SYMBOL(p)) return false;
541 540
542 var handler = %GetHandler(obj); 541 var handler = %GetHandler(obj);
543 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes); 542 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
544 if (!result) { 543 if (!result) {
545 if (should_throw) { 544 if (should_throw) {
546 throw MakeTypeError(kProxyTrapReturned, 545 throw MakeTypeError(kIllegalInvocation);
547 handler, "false", "defineProperty");
548 } else { 546 } else {
549 return false; 547 return false;
550 } 548 }
551 } 549 }
552 return true; 550 return true;
553 } 551 }
554 552
555 553
556 // ES6 9.1.6 [[DefineOwnProperty]](P, Desc) 554 // ES6 9.1.6 [[DefineOwnProperty]](P, Desc)
557 function DefineObjectProperty(obj, p, desc, should_throw) { 555 function DefineObjectProperty(obj, p, desc, should_throw) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 return DefineObjectProperty(obj, p, desc, should_throw); 773 return DefineObjectProperty(obj, p, desc, should_throw);
776 } 774 }
777 } 775 }
778 776
779 777
780 // ES6 section 19.1.2.9 778 // ES6 section 19.1.2.9
781 function ObjectGetPrototypeOf(obj) { 779 function ObjectGetPrototypeOf(obj) {
782 return %_GetPrototype(TO_OBJECT(obj)); 780 return %_GetPrototype(TO_OBJECT(obj));
783 } 781 }
784 782
785 // ES6 section 19.1.2.19. 783 // ES6 section 19.1.2.18.
786 function ObjectSetPrototypeOf(obj, proto) { 784 function ObjectSetPrototypeOf(obj, proto) {
787 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); 785 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
788 786
789 if (proto !== null && !IS_SPEC_OBJECT(proto)) { 787 if (proto !== null && !IS_SPEC_OBJECT(proto)) {
790 throw MakeTypeError(kProtoObjectOrNull, proto); 788 throw MakeTypeError(kProtoObjectOrNull, proto);
791 } 789 }
792 790
793 if (IS_SPEC_OBJECT(obj)) { 791 if (IS_SPEC_OBJECT(obj)) {
794 %SetPrototype(obj, proto); 792 %SetPrototype(obj, proto);
795 } 793 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 to.ObjectIsSealed = ObjectIsSealed; 1452 to.ObjectIsSealed = ObjectIsSealed;
1455 to.ObjectKeys = ObjectKeys; 1453 to.ObjectKeys = ObjectKeys;
1456 }); 1454 });
1457 1455
1458 %InstallToContext([ 1456 %InstallToContext([
1459 "global_eval_fun", GlobalEval, 1457 "global_eval_fun", GlobalEval,
1460 "object_value_of", ObjectValueOf, 1458 "object_value_of", ObjectValueOf,
1461 ]); 1459 ]);
1462 1460
1463 }) 1461 })
OLDNEW
« no previous file with comments | « src/js/proxy.js ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698