| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 strict_lhs_assignment: ["Assignment to eval or arguments is not all
owed in strict mode"], | 223 strict_lhs_assignment: ["Assignment to eval or arguments is not all
owed in strict mode"], |
| 224 strict_lhs_postfix: ["Postfix increment/decrement may not have e
val or arguments operand in strict mode"], | 224 strict_lhs_postfix: ["Postfix increment/decrement may not have e
val or arguments operand in strict mode"], |
| 225 strict_lhs_prefix: ["Prefix increment/decrement may not have ev
al or arguments operand in strict mode"], | 225 strict_lhs_prefix: ["Prefix increment/decrement may not have ev
al or arguments operand in strict mode"], |
| 226 strict_reserved_word: ["Use of future reserved word in strict mode
"], | 226 strict_reserved_word: ["Use of future reserved word in strict mode
"], |
| 227 strict_delete: ["Delete of an unqualified identifier in str
ict mode."], | 227 strict_delete: ["Delete of an unqualified identifier in str
ict mode."], |
| 228 strict_delete_property: ["Cannot delete property '", "%0", "' of ",
"%1"], | 228 strict_delete_property: ["Cannot delete property '", "%0", "' of ",
"%1"], |
| 229 strict_const: ["Use of const in strict mode."], | 229 strict_const: ["Use of const in strict mode."], |
| 230 strict_function: ["In strict mode code, functions can only be
declared at top level or immediately within another function." ], | 230 strict_function: ["In strict mode code, functions can only be
declared at top level or immediately within another function." ], |
| 231 strict_read_only_property: ["Cannot assign to read only property '", "%
0", "' of ", "%1"], | 231 strict_read_only_property: ["Cannot assign to read only property '", "%
0", "' of ", "%1"], |
| 232 strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in
strict mode"], | 232 strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in
strict mode"], |
| 233 strict_arguments_callee: ["Cannot access property 'callee' of strict
mode arguments"], |
| 234 strict_arguments_caller: ["Cannot access property 'caller' of strict
mode arguments"], |
| 235 strict_function_caller: ["Cannot access property 'caller' of a stric
t mode function"], |
| 236 strict_function_arguments: ["Cannot access property 'arguments' of a st
rict mode function"], |
| 233 }; | 237 }; |
| 234 } | 238 } |
| 235 var message_type = %MessageGetType(message); | 239 var message_type = %MessageGetType(message); |
| 236 var format = kMessages[message_type]; | 240 var format = kMessages[message_type]; |
| 237 if (!format) return "<unknown message " + message_type + ">"; | 241 if (!format) return "<unknown message " + message_type + ">"; |
| 238 return FormatString(format, message); | 242 return FormatString(format, message); |
| 239 } | 243 } |
| 240 | 244 |
| 241 | 245 |
| 242 function GetLineNumber(message) { | 246 function GetLineNumber(message) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 * @return {?string} script name if present, value for //@ sourceURL comment | 488 * @return {?string} script name if present, value for //@ sourceURL comment |
| 485 * otherwise. | 489 * otherwise. |
| 486 */ | 490 */ |
| 487 Script.prototype.nameOrSourceURL = function() { | 491 Script.prototype.nameOrSourceURL = function() { |
| 488 if (this.name) | 492 if (this.name) |
| 489 return this.name; | 493 return this.name; |
| 490 // TODO(608): the spaces in a regexp below had to be escaped as \040 | 494 // TODO(608): the spaces in a regexp below had to be escaped as \040 |
| 491 // because this file is being processed by js2c whose handling of spaces | 495 // because this file is being processed by js2c whose handling of spaces |
| 492 // in regexps is broken. Also, ['"] are excluded from allowed URLs to | 496 // in regexps is broken. Also, ['"] are excluded from allowed URLs to |
| 493 // avoid matches against sources that invoke evals with sourceURL. | 497 // avoid matches against sources that invoke evals with sourceURL. |
| 494 var sourceUrlPattern = | 498 // A better solution would be to detect these special comments in |
| 495 /\/\/@[\040\t]sourceURL=[\040\t]*([^\s'"]*)[\040\t]*$/m; | 499 // the scanner/parser. |
| 496 var match = sourceUrlPattern.exec(this.source); | 500 var source = ToString(this.source); |
| 497 return match ? match[1] : this.name; | 501 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); |
| 502 if (sourceUrlPos > 4) { |
| 503 var sourceUrlPattern = |
| 504 /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm; |
| 505 // Don't reuse lastMatchInfo here, so we create a new array with room |
| 506 // for four captures (array with length one longer than the index |
| 507 // of the fourth capture, where the numbering is zero-based). |
| 508 var matchInfo = new InternalArray(CAPTURE(3) + 1); |
| 509 var match = |
| 510 %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo); |
| 511 if (match) { |
| 512 return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]); |
| 513 } |
| 514 } |
| 515 return this.name; |
| 498 } | 516 } |
| 499 | 517 |
| 500 | 518 |
| 501 /** | 519 /** |
| 502 * Class for source location. A source location is a position within some | 520 * Class for source location. A source location is a position within some |
| 503 * source with the following properties: | 521 * source with the following properties: |
| 504 * script : script object for the source | 522 * script : script object for the source |
| 505 * line : source line number | 523 * line : source line number |
| 506 * column : source column within the line | 524 * column : source column within the line |
| 507 * position : position within the source | 525 * position : position within the source |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 else throw e; | 1080 else throw e; |
| 1063 } | 1081 } |
| 1064 } | 1082 } |
| 1065 | 1083 |
| 1066 | 1084 |
| 1067 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1085 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
| 1068 | 1086 |
| 1069 // Boilerplate for exceptions for stack overflows. Used from | 1087 // Boilerplate for exceptions for stack overflows. Used from |
| 1070 // Top::StackOverflow(). | 1088 // Top::StackOverflow(). |
| 1071 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1089 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |