| 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 771 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 772 var pos = GET_PRIVATE(this, CallSitePositionKey); | 772 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 773 return %CallSiteGetFunctionNameRT(receiver, fun, pos); | 773 return %CallSiteGetFunctionNameRT(receiver, fun, pos); |
| 774 } | 774 } |
| 775 | 775 |
| 776 function CallSiteGetMethodName() { | 776 function CallSiteGetMethodName() { |
| 777 // See if we can find a unique property on the receiver that holds | 777 // See if we can find a unique property on the receiver that holds |
| 778 // this function. | 778 // this function. |
| 779 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 779 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
| 780 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 780 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 781 var ownName = fun.name; | 781 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 782 if (ownName && receiver && | 782 return %CallSiteGetMethodNameRT(receiver, fun, pos); |
| 783 (%_CallFunction(receiver, ownName, $objectLookupGetter) === fun || | |
| 784 %_CallFunction(receiver, ownName, $objectLookupSetter) === fun || | |
| 785 (IS_OBJECT(receiver) && %GetDataProperty(receiver, ownName) === fun))) { | |
| 786 // To handle DontEnum properties we guess that the method has | |
| 787 // the same name as the function. | |
| 788 return ownName; | |
| 789 } | |
| 790 var name = null; | |
| 791 for (var prop in receiver) { | |
| 792 if (%_CallFunction(receiver, prop, $objectLookupGetter) === fun || | |
| 793 %_CallFunction(receiver, prop, $objectLookupSetter) === fun || | |
| 794 (IS_OBJECT(receiver) && %GetDataProperty(receiver, prop) === fun)) { | |
| 795 // If we find more than one match bail out to avoid confusion. | |
| 796 if (name) { | |
| 797 return null; | |
| 798 } | |
| 799 name = prop; | |
| 800 } | |
| 801 } | |
| 802 if (name) { | |
| 803 return name; | |
| 804 } | |
| 805 return null; | |
| 806 } | 783 } |
| 807 | 784 |
| 808 function CallSiteGetFileName() { | 785 function CallSiteGetFileName() { |
| 809 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 786 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
| 810 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 787 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 811 var pos = GET_PRIVATE(this, CallSitePositionKey); | 788 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 812 return %CallSiteGetFileNameRT(receiver, fun, pos); | 789 return %CallSiteGetFileNameRT(receiver, fun, pos); |
| 813 } | 790 } |
| 814 | 791 |
| 815 function CallSiteGetLineNumber() { | 792 function CallSiteGetLineNumber() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 828 | 805 |
| 829 function CallSiteIsNative() { | 806 function CallSiteIsNative() { |
| 830 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 807 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
| 831 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 808 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 832 var pos = GET_PRIVATE(this, CallSitePositionKey); | 809 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 833 return %CallSiteIsNativeRT(receiver, fun, pos); | 810 return %CallSiteIsNativeRT(receiver, fun, pos); |
| 834 } | 811 } |
| 835 | 812 |
| 836 function CallSiteIsConstructor() { | 813 function CallSiteIsConstructor() { |
| 837 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 814 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
| 838 var constructor = (receiver != null && IS_OBJECT(receiver)) | 815 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 839 ? %GetDataProperty(receiver, "constructor") : null; | 816 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 840 if (!constructor) return false; | 817 return %CallSiteIsConstructorRT(receiver, fun, pos); |
| 841 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor; | |
| 842 } | 818 } |
| 843 | 819 |
| 844 function CallSiteToString() { | 820 function CallSiteToString() { |
| 845 var fileName; | 821 var fileName; |
| 846 var fileLocation = ""; | 822 var fileLocation = ""; |
| 847 if (this.isNative()) { | 823 if (this.isNative()) { |
| 848 fileLocation = "native"; | 824 fileLocation = "native"; |
| 849 } else { | 825 } else { |
| 850 fileName = this.getScriptNameOrSourceURL(); | 826 fileName = this.getScriptNameOrSourceURL(); |
| 851 if (!fileName && this.isEval()) { | 827 if (!fileName && this.isEval()) { |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 return MakeGenericError(GlobalTypeError, type, [arg]); | 1259 return MakeGenericError(GlobalTypeError, type, [arg]); |
| 1284 } | 1260 } |
| 1285 | 1261 |
| 1286 //Boilerplate for exceptions for stack overflows. Used from | 1262 //Boilerplate for exceptions for stack overflows. Used from |
| 1287 //Isolate::StackOverflow(). | 1263 //Isolate::StackOverflow(). |
| 1288 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); | 1264 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); |
| 1289 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', | 1265 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', |
| 1290 StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1266 StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1291 | 1267 |
| 1292 })(); | 1268 })(); |
| OLD | NEW |