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

Unified Diff: src/messages.js

Issue 7045003: Support extracting source mapping url defined by //@ sourceMappingURL=<url> comment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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 | src/mirror-debugger.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index de388214c7dffeec6b4ae71e353e29184ccb46cc..4fd7c4b411e252a7aaa19cfbcd57bec73511fd84 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -497,6 +497,26 @@ Script.prototype.lineCount = function() {
Script.prototype.nameOrSourceURL = function() {
if (this.name)
return this.name;
+ return this.findMagicComment("sourceURL");
+}
+
+
+/**
+ * Returns script source mapping url, if present.
+ *
+ * @return {?string} script source mapping url, if present.
+ */
+Script.prototype.sourceMappingURL = function() {
+ return this.findMagicComment("sourceMappingURL");
+}
+
+
+/**
+ * Returns the value of the magic comment "//@ name=<value>", if present.
+ *
+ * @return {?string} the value of the magic comment, if present.
+ */
+Script.prototype.findMagicComment = function(name) {
// TODO(608): the spaces in a regexp below had to be escaped as \040
// because this file is being processed by js2c whose handling of spaces
// in regexps is broken. Also, ['"] are excluded from allowed URLs to
@@ -504,21 +524,20 @@ Script.prototype.nameOrSourceURL = function() {
// A better solution would be to detect these special comments in
// the scanner/parser.
var source = ToString(this.source);
- var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0);
- if (sourceUrlPos > 4) {
- var sourceUrlPattern =
- /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
+ var position = %StringIndexOf(source, name + "=", 0);
+ if (position > 4) {
+ var pattern = "\/\/@[ \t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+ var regexp = new $RegExp(pattern, "gm");
// Don't reuse lastMatchInfo here, so we create a new array with room
// for four captures (array with length one longer than the index
// of the fourth capture, where the numbering is zero-based).
var matchInfo = new InternalArray(CAPTURE(3) + 1);
var match =
- %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo);
+ %_RegExpExec(regexp, source, position - 4, matchInfo);
if (match) {
return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]);
}
}
- return this.name;
}
« no previous file with comments | « no previous file | src/mirror-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698