OLD | NEW |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 "called_on_non_object", ["%0", " called on non-object"], | 222 "called_on_non_object", ["%0", " called on non-object"], |
223 "called_on_null_or_undefined", ["%0", " called on null or undefined"], | 223 "called_on_null_or_undefined", ["%0", " called on null or undefined"], |
224 "array_indexof_not_defined", ["Array.getIndexOf: Argument undefined"], | 224 "array_indexof_not_defined", ["Array.getIndexOf: Argument undefined"], |
225 "object_not_extensible", ["Can't add property ", "%0", ", object is
not extensible"], | 225 "object_not_extensible", ["Can't add property ", "%0", ", object is
not extensible"], |
226 "illegal_access", ["Illegal access"], | 226 "illegal_access", ["Illegal access"], |
227 "invalid_preparser_data", ["Invalid preparser data for function ", "
%0"], | 227 "invalid_preparser_data", ["Invalid preparser data for function ", "
%0"], |
228 "strict_mode_with", ["Strict mode code may not include a with
statement"], | 228 "strict_mode_with", ["Strict mode code may not include a with
statement"], |
229 "strict_catch_variable", ["Catch variable may not be eval or argume
nts in strict mode"], | 229 "strict_catch_variable", ["Catch variable may not be eval or argume
nts in strict mode"], |
230 "too_many_arguments", ["Too many arguments in function call (onl
y 32766 allowed)"], | 230 "too_many_arguments", ["Too many arguments in function call (onl
y 32766 allowed)"], |
231 "too_many_parameters", ["Too many parameters in function definiti
on (only 32766 allowed)"], | 231 "too_many_parameters", ["Too many parameters in function definiti
on (only 32766 allowed)"], |
232 "too_many_variables", ["Too many variables declared (only 65535
allowed)"], | 232 "too_many_variables", ["Too many variables declared (only 32767
allowed)"], |
233 "strict_param_name", ["Parameter name eval or arguments is not
allowed in strict mode"], | 233 "strict_param_name", ["Parameter name eval or arguments is not
allowed in strict mode"], |
234 "strict_param_dupe", ["Strict mode function may not have duplic
ate parameter names"], | 234 "strict_param_dupe", ["Strict mode function may not have duplic
ate parameter names"], |
235 "strict_var_name", ["Variable name may not be eval or argumen
ts in strict mode"], | 235 "strict_var_name", ["Variable name may not be eval or argumen
ts in strict mode"], |
236 "strict_function_name", ["Function name may not be eval or argumen
ts in strict mode"], | 236 "strict_function_name", ["Function name may not be eval or argumen
ts in strict mode"], |
237 "strict_octal_literal", ["Octal literals are not allowed in strict
mode."], | 237 "strict_octal_literal", ["Octal literals are not allowed in strict
mode."], |
238 "strict_duplicate_property", ["Duplicate data property in object litera
l not allowed in strict mode"], | 238 "strict_duplicate_property", ["Duplicate data property in object litera
l not allowed in strict mode"], |
239 "accessor_data_property", ["Object literal may not have data and acc
essor property with the same name"], | 239 "accessor_data_property", ["Object literal may not have data and acc
essor property with the same name"], |
240 "accessor_get_set", ["Object literal may not have multiple get
/set accessors with the same name"], | 240 "accessor_get_set", ["Object literal may not have multiple get
/set accessors with the same name"], |
241 "strict_lhs_assignment", ["Assignment to eval or arguments is not a
llowed in strict mode"], | 241 "strict_lhs_assignment", ["Assignment to eval or arguments is not a
llowed in strict mode"], |
242 "strict_lhs_postfix", ["Postfix increment/decrement may not have
eval or arguments operand in strict mode"], | 242 "strict_lhs_postfix", ["Postfix increment/decrement may not have
eval or arguments operand in strict mode"], |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 * If sourceURL comment is available and script starts at zero returns sourceURL | 535 * Returns the name of script if available, contents of sourceURL comment |
536 * comment contents. Otherwise, script name is returned. See | 536 * otherwise. 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.line_offset > 0 || this.column_offset > 0) { | 545 if (this.name) { |
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 } | |
554 this.hasCachedNameOrSourceURL = true; | 553 this.hasCachedNameOrSourceURL = true; |
555 | 554 |
556 // TODO(608): the spaces in a regexp below had to be escaped as \040 | 555 // TODO(608): the spaces in a regexp below had to be escaped as \040 |
557 // because this file is being processed by js2c whose handling of spaces | 556 // because this file is being processed by js2c whose handling of spaces |
558 // in regexps is broken. Also, ['"] are excluded from allowed URLs to | 557 // in regexps is broken. Also, ['"] are excluded from allowed URLs to |
559 // avoid matches against sources that invoke evals with sourceURL. | 558 // avoid matches against sources that invoke evals with sourceURL. |
560 // A better solution would be to detect these special comments in | 559 // A better solution would be to detect these special comments in |
561 // the scanner/parser. | 560 // the scanner/parser. |
562 var source = ToString(this.source); | 561 var source = ToString(this.source); |
563 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); | 562 var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 throw e; | 1260 throw e; |
1262 } | 1261 } |
1263 } | 1262 } |
1264 | 1263 |
1265 | 1264 |
1266 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); | 1265 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); |
1267 | 1266 |
1268 // Boilerplate for exceptions for stack overflows. Used from | 1267 // Boilerplate for exceptions for stack overflows. Used from |
1269 // Isolate::StackOverflow(). | 1268 // Isolate::StackOverflow(). |
1270 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1269 var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |