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

Unified Diff: src/messages.js

Issue 3444011: Use //@ sourceURL when formatting stack trace (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/stack-traces.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
===================================================================
--- src/messages.js (revision 5497)
+++ src/messages.js (working copy)
@@ -684,6 +684,11 @@
return FormatEvalOrigin(script);
};
+CallSite.prototype.getScriptNameOrSourceURL = function () {
+ var script = %FunctionGetScript(this.fun);
+ return script ? script.nameOrSourceURL() : null;
+};
+
CallSite.prototype.getFunction = function () {
return this.fun;
};
@@ -775,7 +780,11 @@
};
function FormatEvalOrigin(script) {
- var eval_origin = "";
+ var sourceURL = script.nameOrSourceURL();
+ if (sourceURL)
+ return sourceURL;
+
+ var eval_origin = "eval at ";
if (script.eval_from_function_name) {
eval_origin += script.eval_from_function_name;
} else {
@@ -786,7 +795,7 @@
if (eval_from_script) {
if (eval_from_script.compilation_type == COMPILATION_TYPE_EVAL) {
// eval script originated from another eval.
- eval_origin += " (eval at " + FormatEvalOrigin(eval_from_script) + ")";
+ eval_origin += " (" + FormatEvalOrigin(eval_from_script) + ")";
} else {
// eval script originated from "real" scource.
if (eval_from_script.name) {
@@ -807,25 +816,30 @@
};
function FormatSourcePosition(frame) {
+ var fileName;
var fileLocation = "";
if (frame.isNative()) {
fileLocation = "native";
} else if (frame.isEval()) {
- fileLocation = "eval at " + frame.getEvalOrigin();
+ fileName = frame.getScriptNameOrSourceURL();
+ if (!fileName)
+ fileLocation = frame.getEvalOrigin();
} else {
- var fileName = frame.getFileName();
- if (fileName) {
- fileLocation += fileName;
- var lineNumber = frame.getLineNumber();
- if (lineNumber != null) {
- fileLocation += ":" + lineNumber;
- var columnNumber = frame.getColumnNumber();
- if (columnNumber) {
- fileLocation += ":" + columnNumber;
- }
+ fileName = frame.getFileName();
+ }
+
+ if (fileName) {
+ fileLocation += fileName;
+ var lineNumber = frame.getLineNumber();
+ if (lineNumber != null) {
+ fileLocation += ":" + lineNumber;
+ var columnNumber = frame.getColumnNumber();
+ if (columnNumber) {
+ fileLocation += ":" + columnNumber;
}
}
}
+
if (!fileLocation) {
fileLocation = "unknown source";
}
« no previous file with comments | « no previous file | test/mjsunit/stack-traces.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698