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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/mirror-debugger.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt 490 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
491 * for details on using //@ sourceURL comment to identify scritps that don't 491 * for details on using //@ sourceURL comment to identify scritps that don't
492 * have name. 492 * have name.
493 * 493 *
494 * @return {?string} script name if present, value for //@ sourceURL comment 494 * @return {?string} script name if present, value for //@ sourceURL comment
495 * otherwise. 495 * otherwise.
496 */ 496 */
497 Script.prototype.nameOrSourceURL = function() { 497 Script.prototype.nameOrSourceURL = function() {
498 if (this.name) 498 if (this.name)
499 return this.name; 499 return this.name;
500 return this.findMagicComment("sourceURL");
501 }
502
503
504 /**
505 * Returns script source mapping url, if present.
506 *
507 * @return {?string} script source mapping url, if present.
508 */
509 Script.prototype.sourceMappingURL = function() {
510 return this.findMagicComment("sourceMappingURL");
511 }
512
513
514 /**
515 * Returns the value of the magic comment "//@ name=<value>", if present.
516 *
517 * @return {?string} the value of the magic comment, if present.
518 */
519 Script.prototype.findMagicComment = function(name) {
500 // TODO(608): the spaces in a regexp below had to be escaped as \040 520 // TODO(608): the spaces in a regexp below had to be escaped as \040
501 // because this file is being processed by js2c whose handling of spaces 521 // because this file is being processed by js2c whose handling of spaces
502 // in regexps is broken. Also, ['"] are excluded from allowed URLs to 522 // in regexps is broken. Also, ['"] are excluded from allowed URLs to
503 // avoid matches against sources that invoke evals with sourceURL. 523 // avoid matches against sources that invoke evals with sourceURL.
504 // A better solution would be to detect these special comments in 524 // A better solution would be to detect these special comments in
505 // the scanner/parser. 525 // the scanner/parser.
506 var source = ToString(this.source); 526 var source = ToString(this.source);
507 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); 527 var position = %StringIndexOf(source, name + "=", 0);
508 if (sourceUrlPos > 4) { 528 if (position > 4) {
509 var sourceUrlPattern = 529 var pattern = "\/\/@[ \t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
510 /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm; 530 var regexp = new $RegExp(pattern, "gm");
511 // Don't reuse lastMatchInfo here, so we create a new array with room 531 // Don't reuse lastMatchInfo here, so we create a new array with room
512 // for four captures (array with length one longer than the index 532 // for four captures (array with length one longer than the index
513 // of the fourth capture, where the numbering is zero-based). 533 // of the fourth capture, where the numbering is zero-based).
514 var matchInfo = new InternalArray(CAPTURE(3) + 1); 534 var matchInfo = new InternalArray(CAPTURE(3) + 1);
515 var match = 535 var match =
516 %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo); 536 %_RegExpExec(regexp, source, position - 4, matchInfo);
517 if (match) { 537 if (match) {
518 return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]); 538 return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]);
519 } 539 }
520 } 540 }
521 return this.name;
522 } 541 }
523 542
524 543
525 /** 544 /**
526 * Class for source location. A source location is a position within some 545 * Class for source location. A source location is a position within some
527 * source with the following properties: 546 * source with the following properties:
528 * script : script object for the source 547 * script : script object for the source
529 * line : source line number 548 * line : source line number
530 * column : source column within the line 549 * column : source column within the line
531 * position : position within the source 550 * position : position within the source
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 else throw e; 1109 else throw e;
1091 } 1110 }
1092 } 1111 }
1093 1112
1094 1113
1095 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); 1114 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]);
1096 1115
1097 // Boilerplate for exceptions for stack overflows. Used from 1116 // Boilerplate for exceptions for stack overflows. Used from
1098 // Isolate::StackOverflow(). 1117 // Isolate::StackOverflow().
1099 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 1118 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« 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