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

Side by Side Diff: src/messages.js

Issue 10966011: Supported sourceURL comments for scripts having a name. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Comments addressed: changed method comment and added a test. Created 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/cctest.h » ('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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 * @return {number} 525 * @return {number}
526 * Number of source lines. 526 * Number of source lines.
527 */ 527 */
528 function ScriptLineCount() { 528 function ScriptLineCount() {
529 // Return number of source lines. 529 // Return number of source lines.
530 return this.line_ends.length; 530 return this.line_ends.length;
531 } 531 }
532 532
533 533
534 /** 534 /**
535 * Returns the name of script if available, contents of sourceURL comment 535 * If sourceURL comment is available and script starts at zero returns sourceURL
536 * otherwise. See 536 * comment contents. Otherwise, script name is returned. See
537 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt 537 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
538 * for details on using //@ sourceURL comment to identify scritps that don't 538 * for details on using //@ sourceURL comment to identify scritps that don't
539 * have name. 539 * have name.
540 * 540 *
541 * @return {?string} script name if present, value for //@ sourceURL comment 541 * @return {?string} script name if present, value for //@ sourceURL comment
542 * otherwise. 542 * otherwise.
543 */ 543 */
544 function ScriptNameOrSourceURL() { 544 function ScriptNameOrSourceURL() {
545 if (this.name) { 545 if (this.line_offset > 0 || this.column_offset > 0) {
546 return this.name; 546 return this.name;
547 } 547 }
548 548
549 // The result is cached as on long scripts it takes noticable time to search 549 // The result is cached as on long scripts it takes noticable time to search
550 // for the sourceURL. 550 // for the sourceURL.
551 if (this.hasCachedNameOrSourceURL) 551 if (this.hasCachedNameOrSourceURL) {
552 return this.cachedNameOrSourceURL; 552 return this.cachedNameOrSourceURL;
553 }
553 this.hasCachedNameOrSourceURL = true; 554 this.hasCachedNameOrSourceURL = true;
554 555
555 // TODO(608): the spaces in a regexp below had to be escaped as \040 556 // TODO(608): the spaces in a regexp below had to be escaped as \040
556 // because this file is being processed by js2c whose handling of spaces 557 // because this file is being processed by js2c whose handling of spaces
557 // in regexps is broken. Also, ['"] are excluded from allowed URLs to 558 // in regexps is broken. Also, ['"] are excluded from allowed URLs to
558 // avoid matches against sources that invoke evals with sourceURL. 559 // avoid matches against sources that invoke evals with sourceURL.
559 // A better solution would be to detect these special comments in 560 // A better solution would be to detect these special comments in
560 // the scanner/parser. 561 // the scanner/parser.
561 var source = ToString(this.source); 562 var source = ToString(this.source);
562 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); 563 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0);
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 throw e; 1261 throw e;
1261 } 1262 }
1262 } 1263 }
1263 1264
1264 1265
1265 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); 1266 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]);
1266 1267
1267 // Boilerplate for exceptions for stack overflows. Used from 1268 // Boilerplate for exceptions for stack overflows. Used from
1268 // Isolate::StackOverflow(). 1269 // Isolate::StackOverflow().
1269 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 1270 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « no previous file | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698