OLD | NEW |
---|---|
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 // ------------------------------------------------------------------- | 5 // ------------------------------------------------------------------- |
6 | 6 |
7 (function(global, utils) { | 7 (function(global, utils) { |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 if (IS_UNDEFINED(new.target)) { | 563 if (IS_UNDEFINED(new.target)) { |
564 return new CallSite(receiver, fun, pos, strict_mode); | 564 return new CallSite(receiver, fun, pos, strict_mode); |
565 } | 565 } |
566 | 566 |
567 SET_PRIVATE(this, callSiteReceiverSymbol, receiver); | 567 SET_PRIVATE(this, callSiteReceiverSymbol, receiver); |
568 SET_PRIVATE(this, callSiteFunctionSymbol, fun); | 568 SET_PRIVATE(this, callSiteFunctionSymbol, fun); |
569 SET_PRIVATE(this, callSitePositionSymbol, TO_INT32(pos)); | 569 SET_PRIVATE(this, callSitePositionSymbol, TO_INT32(pos)); |
570 SET_PRIVATE(this, callSiteStrictSymbol, TO_BOOLEAN(strict_mode)); | 570 SET_PRIVATE(this, callSiteStrictSymbol, TO_BOOLEAN(strict_mode)); |
571 } | 571 } |
572 | 572 |
573 function CheckCallSite(obj, name) { | |
574 if (!IS_RECEIVER(obj) || !HAS_PRIVATE(obj, callSiteFunctionSymbol)) { | |
adamk
2016/03/24 21:03:11
Remind me, does HAS_PRIVATE always return false fo
Dan Ehrenberg
2016/03/24 21:39:07
Private symbols don't forward through Proxies. I a
| |
575 throw MakeTypeError(kCallSiteMethod, name); | |
576 } | |
577 } | |
578 | |
573 function CallSiteGetThis() { | 579 function CallSiteGetThis() { |
580 CheckCallSite(this, "getThis"); | |
574 return GET_PRIVATE(this, callSiteStrictSymbol) | 581 return GET_PRIVATE(this, callSiteStrictSymbol) |
575 ? UNDEFINED : GET_PRIVATE(this, callSiteReceiverSymbol); | 582 ? UNDEFINED : GET_PRIVATE(this, callSiteReceiverSymbol); |
576 } | 583 } |
577 | 584 |
578 function CallSiteGetFunction() { | 585 function CallSiteGetFunction() { |
586 CheckCallSite(this, "getFunction"); | |
579 return GET_PRIVATE(this, callSiteStrictSymbol) | 587 return GET_PRIVATE(this, callSiteStrictSymbol) |
580 ? UNDEFINED : GET_PRIVATE(this, callSiteFunctionSymbol); | 588 ? UNDEFINED : GET_PRIVATE(this, callSiteFunctionSymbol); |
581 } | 589 } |
582 | 590 |
583 function CallSiteGetPosition() { | 591 function CallSiteGetPosition() { |
592 CheckCallSite(this, "getPosition"); | |
584 return GET_PRIVATE(this, callSitePositionSymbol); | 593 return GET_PRIVATE(this, callSitePositionSymbol); |
585 } | 594 } |
586 | 595 |
587 function CallSiteGetTypeName() { | 596 function CallSiteGetTypeName() { |
597 CheckCallSite(this, "getTypeName"); | |
588 return GetTypeName(GET_PRIVATE(this, callSiteReceiverSymbol), false); | 598 return GetTypeName(GET_PRIVATE(this, callSiteReceiverSymbol), false); |
589 } | 599 } |
590 | 600 |
591 function CallSiteIsToplevel() { | 601 function CallSiteIsToplevel() { |
602 CheckCallSite(this, "isTopLevel"); | |
592 return %CallSiteIsToplevelRT(this); | 603 return %CallSiteIsToplevelRT(this); |
593 } | 604 } |
594 | 605 |
595 function CallSiteIsEval() { | 606 function CallSiteIsEval() { |
607 CheckCallSite(this, "isEval"); | |
596 return %CallSiteIsEvalRT(this); | 608 return %CallSiteIsEvalRT(this); |
597 } | 609 } |
598 | 610 |
599 function CallSiteGetEvalOrigin() { | 611 function CallSiteGetEvalOrigin() { |
612 CheckCallSite(this, "getEvalOrigin"); | |
600 var script = %FunctionGetScript(GET_PRIVATE(this, callSiteFunctionSymbol)); | 613 var script = %FunctionGetScript(GET_PRIVATE(this, callSiteFunctionSymbol)); |
601 return FormatEvalOrigin(script); | 614 return FormatEvalOrigin(script); |
602 } | 615 } |
603 | 616 |
604 function CallSiteGetScriptNameOrSourceURL() { | 617 function CallSiteGetScriptNameOrSourceURL() { |
618 CheckCallSite(this, "getScriptNameOrSourceURL"); | |
605 return %CallSiteGetScriptNameOrSourceUrlRT(this); | 619 return %CallSiteGetScriptNameOrSourceUrlRT(this); |
606 } | 620 } |
607 | 621 |
608 function CallSiteGetFunctionName() { | 622 function CallSiteGetFunctionName() { |
609 // See if the function knows its own name | 623 // See if the function knows its own name |
624 CheckCallSite(this, "getFunctionName"); | |
610 return %CallSiteGetFunctionNameRT(this); | 625 return %CallSiteGetFunctionNameRT(this); |
611 } | 626 } |
612 | 627 |
613 function CallSiteGetMethodName() { | 628 function CallSiteGetMethodName() { |
614 // See if we can find a unique property on the receiver that holds | 629 // See if we can find a unique property on the receiver that holds |
615 // this function. | 630 // this function. |
631 CheckCallSite(this, "getMethodName"); | |
616 return %CallSiteGetMethodNameRT(this); | 632 return %CallSiteGetMethodNameRT(this); |
617 } | 633 } |
618 | 634 |
619 function CallSiteGetFileName() { | 635 function CallSiteGetFileName() { |
636 CheckCallSite(this, "getFileName"); | |
620 return %CallSiteGetFileNameRT(this); | 637 return %CallSiteGetFileNameRT(this); |
621 } | 638 } |
622 | 639 |
623 function CallSiteGetLineNumber() { | 640 function CallSiteGetLineNumber() { |
641 CheckCallSite(this, "getLineNumber"); | |
624 return %CallSiteGetLineNumberRT(this); | 642 return %CallSiteGetLineNumberRT(this); |
625 } | 643 } |
626 | 644 |
627 function CallSiteGetColumnNumber() { | 645 function CallSiteGetColumnNumber() { |
646 CheckCallSite(this, "getColumnNumber"); | |
628 return %CallSiteGetColumnNumberRT(this); | 647 return %CallSiteGetColumnNumberRT(this); |
629 } | 648 } |
630 | 649 |
631 function CallSiteIsNative() { | 650 function CallSiteIsNative() { |
651 CheckCallSite(this, "isNative"); | |
632 return %CallSiteIsNativeRT(this); | 652 return %CallSiteIsNativeRT(this); |
633 } | 653 } |
634 | 654 |
635 function CallSiteIsConstructor() { | 655 function CallSiteIsConstructor() { |
656 CheckCallSite(this, "isConstructor"); | |
636 return %CallSiteIsConstructorRT(this); | 657 return %CallSiteIsConstructorRT(this); |
637 } | 658 } |
638 | 659 |
639 function CallSiteToString() { | 660 function CallSiteToString() { |
640 var fileName; | 661 var fileName; |
641 var fileLocation = ""; | 662 var fileLocation = ""; |
642 if (this.isNative()) { | 663 if (this.isNative()) { |
643 fileLocation = "native"; | 664 fileLocation = "native"; |
644 } else { | 665 } else { |
645 fileName = this.getScriptNameOrSourceURL(); | 666 fileName = this.getScriptNameOrSourceURL(); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
997 utils.Export(function(to) { | 1018 utils.Export(function(to) { |
998 to.ErrorToString = ErrorToString; | 1019 to.ErrorToString = ErrorToString; |
999 to.MakeError = MakeError; | 1020 to.MakeError = MakeError; |
1000 to.MakeRangeError = MakeRangeError; | 1021 to.MakeRangeError = MakeRangeError; |
1001 to.MakeSyntaxError = MakeSyntaxError; | 1022 to.MakeSyntaxError = MakeSyntaxError; |
1002 to.MakeTypeError = MakeTypeError; | 1023 to.MakeTypeError = MakeTypeError; |
1003 to.MakeURIError = MakeURIError; | 1024 to.MakeURIError = MakeURIError; |
1004 }); | 1025 }); |
1005 | 1026 |
1006 }); | 1027 }); |
OLD | NEW |