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 var $errorToString; | 7 var $errorToString; |
8 var $formatMessage; | 8 var $formatMessage; |
9 var $getStackTraceLine; | 9 var $getStackTraceLine; |
10 var $messageGetPositionInLine; | 10 var $messageGetPositionInLine; |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 764 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
765 var pos = GET_PRIVATE(this, CallSitePositionKey); | 765 var pos = GET_PRIVATE(this, CallSitePositionKey); |
766 return %CallSiteGetFunctionNameRT(receiver, fun, pos); | 766 return %CallSiteGetFunctionNameRT(receiver, fun, pos); |
767 } | 767 } |
768 | 768 |
769 function CallSiteGetMethodName() { | 769 function CallSiteGetMethodName() { |
770 // See if we can find a unique property on the receiver that holds | 770 // See if we can find a unique property on the receiver that holds |
771 // this function. | 771 // this function. |
772 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 772 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
773 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 773 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
774 var ownName = fun.name; | 774 var pos = GET_PRIVATE(this, CallSitePositionKey); |
775 if (ownName && receiver && | 775 return %CallSiteGetMethodNameRT(receiver, fun, pos); |
776 (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun || | |
777 %_CallFunction(receiver, ownName, ObjectLookupSetter) === fun || | |
778 (IS_OBJECT(receiver) && %GetDataProperty(receiver, ownName) === fun))) { | |
779 // To handle DontEnum properties we guess that the method has | |
780 // the same name as the function. | |
781 return ownName; | |
782 } | |
783 var name = null; | |
784 for (var prop in receiver) { | |
785 if (%_CallFunction(receiver, prop, ObjectLookupGetter) === fun || | |
786 %_CallFunction(receiver, prop, ObjectLookupSetter) === fun || | |
787 (IS_OBJECT(receiver) && %GetDataProperty(receiver, prop) === fun)) { | |
788 // If we find more than one match bail out to avoid confusion. | |
789 if (name) { | |
790 return null; | |
791 } | |
792 name = prop; | |
793 } | |
794 } | |
795 if (name) { | |
796 return name; | |
797 } | |
798 return null; | |
799 } | 776 } |
800 | 777 |
801 function CallSiteGetFileName() { | 778 function CallSiteGetFileName() { |
802 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 779 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
803 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 780 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
804 var pos = GET_PRIVATE(this, CallSitePositionKey); | 781 var pos = GET_PRIVATE(this, CallSitePositionKey); |
805 return %CallSiteGetFileNameRT(receiver, fun, pos); | 782 return %CallSiteGetFileNameRT(receiver, fun, pos); |
806 } | 783 } |
807 | 784 |
808 function CallSiteGetLineNumber() { | 785 function CallSiteGetLineNumber() { |
(...skipping 12 matching lines...) Expand all Loading... |
821 | 798 |
822 function CallSiteIsNative() { | 799 function CallSiteIsNative() { |
823 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 800 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
824 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 801 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
825 var pos = GET_PRIVATE(this, CallSitePositionKey); | 802 var pos = GET_PRIVATE(this, CallSitePositionKey); |
826 return %CallSiteIsNativeRT(receiver, fun, pos); | 803 return %CallSiteIsNativeRT(receiver, fun, pos); |
827 } | 804 } |
828 | 805 |
829 function CallSiteIsConstructor() { | 806 function CallSiteIsConstructor() { |
830 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 807 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
831 var constructor = (receiver != null && IS_OBJECT(receiver)) | 808 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
832 ? %GetDataProperty(receiver, "constructor") : null; | 809 var pos = GET_PRIVATE(this, CallSitePositionKey); |
833 if (!constructor) return false; | 810 return %CallSiteIsConstructorRT(receiver, fun, pos); |
834 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor; | |
835 } | 811 } |
836 | 812 |
837 function CallSiteToString() { | 813 function CallSiteToString() { |
838 var fileName; | 814 var fileName; |
839 var fileLocation = ""; | 815 var fileLocation = ""; |
840 if (this.isNative()) { | 816 if (this.isNative()) { |
841 fileLocation = "native"; | 817 fileLocation = "native"; |
842 } else { | 818 } else { |
843 fileName = this.getScriptNameOrSourceURL(); | 819 fileName = this.getScriptNameOrSourceURL(); |
844 if (!fileName && this.isEval()) { | 820 if (!fileName && this.isEval()) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 return MakeGenericError(GlobalTypeError, type, [arg]); | 1251 return MakeGenericError(GlobalTypeError, type, [arg]); |
1276 } | 1252 } |
1277 | 1253 |
1278 //Boilerplate for exceptions for stack overflows. Used from | 1254 //Boilerplate for exceptions for stack overflows. Used from |
1279 //Isolate::StackOverflow(). | 1255 //Isolate::StackOverflow(). |
1280 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); | 1256 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); |
1281 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', | 1257 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', |
1282 StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1258 StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1283 | 1259 |
1284 })(); | 1260 })(); |
OLD | NEW |