OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 | 823 |
824 function CallSiteGetFunction() { | 824 function CallSiteGetFunction() { |
825 return this.fun; | 825 return this.fun; |
826 } | 826 } |
827 | 827 |
828 function CallSiteGetFunctionName() { | 828 function CallSiteGetFunctionName() { |
829 // See if the function knows its own name | 829 // See if the function knows its own name |
830 var name = this.fun.name; | 830 var name = this.fun.name; |
831 if (name) { | 831 if (name) { |
832 return name; | 832 return name; |
833 } else { | |
834 return %FunctionGetInferredName(this.fun); | |
835 } | 833 } |
836 // Maybe this is an evaluation? | 834 return %FunctionGetInferredName(this.fun); |
Christian Plesner Hansen
2012/05/24 02:15:18
I wonder if the eval case should have been reached
marja
2012/05/24 08:38:16
Done.
| |
837 var script = %FunctionGetScript(this.fun); | |
838 if (script && script.compilation_type == COMPILATION_TYPE_EVAL) { | |
839 return "eval"; | |
840 } | |
841 return null; | |
842 } | 835 } |
843 | 836 |
844 function CallSiteGetMethodName() { | 837 function CallSiteGetMethodName() { |
845 // See if we can find a unique property on the receiver that holds | 838 // See if we can find a unique property on the receiver that holds |
846 // this function. | 839 // this function. |
847 var ownName = this.fun.name; | 840 var ownName = this.fun.name; |
848 if (ownName && this.receiver && | 841 if (ownName && this.receiver && |
849 (%_CallFunction(this.receiver, | 842 (%_CallFunction(this.receiver, |
850 ownName, | 843 ownName, |
851 ObjectLookupGetter) === this.fun || | 844 ObjectLookupGetter) === this.fun || |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 if (columnNumber) { | 938 if (columnNumber) { |
946 fileLocation += ":" + columnNumber; | 939 fileLocation += ":" + columnNumber; |
947 } | 940 } |
948 } | 941 } |
949 } | 942 } |
950 | 943 |
951 if (!fileLocation) { | 944 if (!fileLocation) { |
952 fileLocation = "unknown source"; | 945 fileLocation = "unknown source"; |
953 } | 946 } |
954 var line = ""; | 947 var line = ""; |
955 var functionName = this.getFunction().name; | 948 var functionName = this.getFunctionName(); |
956 var addPrefix = true; | 949 var addSuffix = true; |
Christian Plesner Hansen
2012/05/24 02:15:18
I always get suffix and prefix mixed up. I do the
| |
957 var isConstructor = this.isConstructor(); | 950 var isConstructor = this.isConstructor(); |
958 var isMethodCall = !(this.isToplevel() || isConstructor); | 951 var isMethodCall = !(this.isToplevel() || isConstructor); |
959 if (isMethodCall) { | 952 if (isMethodCall) { |
953 var typeNamePrefix = this.getTypeName() + "."; | |
960 var methodName = this.getMethodName(); | 954 var methodName = this.getMethodName(); |
961 line += this.getTypeName() + "."; | |
962 if (functionName) { | 955 if (functionName) { |
956 if (typeNamePrefix[0] != '[' && | |
Christian Plesner Hansen
2012/05/24 02:15:18
Something to consider to make this case easier to
marja
2012/05/24 08:38:16
Done.
| |
957 functionName.indexOf(typeNamePrefix) != 0) { | |
958 line += typeNamePrefix; | |
959 } | |
963 line += functionName; | 960 line += functionName; |
964 if (methodName && (methodName != functionName)) { | 961 if (methodName && functionName.indexOf("." + methodName) != |
Christian Plesner Hansen
2012/05/24 02:15:18
Is this equivalent to (methodName != this.getFunct
marja
2012/05/24 08:38:16
Not equivalent; kept this, but fixed indexof -> la
| |
962 functionName.length - methodName.length - 1) { | |
965 line += " [as " + methodName + "]"; | 963 line += " [as " + methodName + "]"; |
966 } | 964 } |
967 } else { | 965 } else { |
968 line += methodName || "<anonymous>"; | 966 line += (typeNamePrefix + (methodName || "<anonymous>")); |
969 } | 967 } |
970 } else if (isConstructor) { | 968 } else if (isConstructor) { |
971 line += "new " + (functionName || "<anonymous>"); | 969 line += "new " + (functionName || "<anonymous>"); |
972 } else if (functionName) { | 970 } else if (functionName) { |
973 line += functionName; | 971 line += functionName; |
974 } else { | 972 } else { |
975 line += fileLocation; | 973 line += fileLocation; |
976 addPrefix = false; | 974 addSuffix = false; |
977 } | 975 } |
978 if (addPrefix) { | 976 if (addSuffix) { |
979 line += " (" + fileLocation + ")"; | 977 line += " (" + fileLocation + ")"; |
980 } | 978 } |
981 return line; | 979 return line; |
982 } | 980 } |
983 | 981 |
984 SetUpLockedPrototype(CallSite, $Array("receiver", "fun", "pos"), $Array( | 982 SetUpLockedPrototype(CallSite, $Array("receiver", "fun", "pos"), $Array( |
985 "getThis", CallSiteGetThis, | 983 "getThis", CallSiteGetThis, |
986 "getTypeName", CallSiteGetTypeName, | 984 "getTypeName", CallSiteGetTypeName, |
987 "isToplevel", CallSiteIsToplevel, | 985 "isToplevel", CallSiteIsToplevel, |
988 "isEval", CallSiteIsEval, | 986 "isEval", CallSiteIsEval, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 throw e; | 1235 throw e; |
1238 } | 1236 } |
1239 } | 1237 } |
1240 | 1238 |
1241 | 1239 |
1242 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); | 1240 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); |
1243 | 1241 |
1244 // Boilerplate for exceptions for stack overflows. Used from | 1242 // Boilerplate for exceptions for stack overflows. Used from |
1245 // Isolate::StackOverflow(). | 1243 // Isolate::StackOverflow(). |
1246 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1244 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |