OLD | NEW |
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 * @return {number} | 426 * @return {number} |
427 * Number of source lines. | 427 * Number of source lines. |
428 */ | 428 */ |
429 Script.prototype.lineCount = function() { | 429 Script.prototype.lineCount = function() { |
430 // Return number of source lines. | 430 // Return number of source lines. |
431 return this.line_ends.length; | 431 return this.line_ends.length; |
432 }; | 432 }; |
433 | 433 |
434 | 434 |
435 /** | 435 /** |
| 436 * Returns the name of script if available, contents of sourceURL comment |
| 437 * otherwise. See |
| 438 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt |
| 439 * for details on using //@ sourceURL comment to identify scritps that don't |
| 440 * have name. |
| 441 * |
| 442 * @return {?string} script name if present, value for //@ sourceURL comment |
| 443 * otherwise. |
| 444 */ |
| 445 Script.prototype.nameOrSourceURL = function() { |
| 446 if (this.name) |
| 447 return this.name; |
| 448 // TODO(608): the spaces in a regexp below had to be escaped as \040 |
| 449 // because this file is being processed by js2c whose handling of spaces |
| 450 // in regexps is broken. Also, ['"] are excluded from allowed URLs to |
| 451 // avoid matches against sources that invoke evals with sourceURL. |
| 452 var sourceUrlPattern = |
| 453 /\/\/@[\040\t]sourceURL=[\040\t]*([^\s'"]*)[\040\t]*$/m; |
| 454 var match = sourceUrlPattern.exec(this.source); |
| 455 return match ? match[1] : this.name; |
| 456 } |
| 457 |
| 458 |
| 459 /** |
436 * Class for source location. A source location is a position within some | 460 * Class for source location. A source location is a position within some |
437 * source with the following properties: | 461 * source with the following properties: |
438 * script : script object for the source | 462 * script : script object for the source |
439 * line : source line number | 463 * line : source line number |
440 * column : source column within the line | 464 * column : source column within the line |
441 * position : position within the source | 465 * position : position within the source |
442 * start : position of start of source context (inclusive) | 466 * start : position of start of source context (inclusive) |
443 * end : position of end of source context (not inclusive) | 467 * end : position of end of source context (not inclusive) |
444 * Source text for the source context is the character interval [start, end[. In | 468 * Source text for the source context is the character interval [start, end[. In |
445 * most cases end will point to a newline character. It might point just past | 469 * most cases end will point to a newline character. It might point just past |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); | 965 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); |
942 } | 966 } |
943 var message = this.message; | 967 var message = this.message; |
944 return this.name + (message ? (": " + message) : ""); | 968 return this.name + (message ? (": " + message) : ""); |
945 }, DONT_ENUM); | 969 }, DONT_ENUM); |
946 | 970 |
947 | 971 |
948 // Boilerplate for exceptions for stack overflows. Used from | 972 // Boilerplate for exceptions for stack overflows. Used from |
949 // Top::StackOverflow(). | 973 // Top::StackOverflow(). |
950 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 974 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |