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

Side by Side Diff: src/messages.js

Issue 10565002: Print correct line number for Error thrown inside eval. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix whitespace Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/eval-stack-trace.js » ('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 // 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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 return false; 914 return false;
915 } 915 }
916 return this.fun === constructor; 916 return this.fun === constructor;
917 } 917 }
918 918
919 function CallSiteToString() { 919 function CallSiteToString() {
920 var fileName; 920 var fileName;
921 var fileLocation = ""; 921 var fileLocation = "";
922 if (this.isNative()) { 922 if (this.isNative()) {
923 fileLocation = "native"; 923 fileLocation = "native";
924 } else if (this.isEval()) { 924 } else {
925 fileName = this.getScriptNameOrSourceURL(); 925 if (this.isEval()) {
926 if (!fileName) { 926 fileName = this.getScriptNameOrSourceURL();
927 fileLocation = this.getEvalOrigin(); 927 if (!fileName) {
928 fileLocation = this.getEvalOrigin();
929 fileLocation += ", "; // Expecting source position to follow.
930 }
931 } else {
932 fileName = this.getFileName();
928 } 933 }
929 } else {
930 fileName = this.getFileName();
931 }
932 934
933 if (fileName) { 935 if (fileName) {
934 fileLocation += fileName; 936 fileLocation += fileName;
937 } else {
938 // Source code does not originate from a file and is not native, but we
939 // can still get the source position inside the source string, e.g. in
940 // an eval string.
941 fileLocation += "<anonymous>";
942 }
935 var lineNumber = this.getLineNumber(); 943 var lineNumber = this.getLineNumber();
936 if (lineNumber != null) { 944 if (lineNumber != null) {
937 fileLocation += ":" + lineNumber; 945 fileLocation += ":" + lineNumber;
938 var columnNumber = this.getColumnNumber(); 946 var columnNumber = this.getColumnNumber();
939 if (columnNumber) { 947 if (columnNumber) {
940 fileLocation += ":" + columnNumber; 948 fileLocation += ":" + columnNumber;
941 } 949 }
942 } 950 }
943 } 951 }
944 952
945 if (!fileLocation) {
946 fileLocation = "unknown source";
947 }
948 var line = ""; 953 var line = "";
949 var functionName = this.getFunctionName(); 954 var functionName = this.getFunctionName();
950 var addSuffix = true; 955 var addSuffix = true;
951 var isConstructor = this.isConstructor(); 956 var isConstructor = this.isConstructor();
952 var isMethodCall = !(this.isToplevel() || isConstructor); 957 var isMethodCall = !(this.isToplevel() || isConstructor);
953 if (isMethodCall) { 958 if (isMethodCall) {
954 var typeName = GetTypeName(this, true); 959 var typeName = GetTypeName(this, true);
955 var methodName = this.getMethodName(); 960 var methodName = this.getMethodName();
956 if (functionName) { 961 if (functionName) {
957 if (typeName && functionName.indexOf(typeName) != 0) { 962 if (typeName && functionName.indexOf(typeName) != 0) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 throw e; 1253 throw e;
1249 } 1254 }
1250 } 1255 }
1251 1256
1252 1257
1253 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); 1258 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]);
1254 1259
1255 // Boilerplate for exceptions for stack overflows. Used from 1260 // Boilerplate for exceptions for stack overflows. Used from
1256 // Isolate::StackOverflow(). 1261 // Isolate::StackOverflow().
1257 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 1262 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/eval-stack-trace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698