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

Side by Side Diff: src/messages.js

Issue 126109: Fix all lines > 80 chars in messages.js so they are <= 80. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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 | no next file » | 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Error 55 // Error
56 cyclic_proto: "Cyclic __proto__ value", 56 cyclic_proto: "Cyclic __proto__ value",
57 // TypeError 57 // TypeError
58 unexpected_token: "Unexpected token %0", 58 unexpected_token: "Unexpected token %0",
59 unexpected_token_number: "Unexpected number", 59 unexpected_token_number: "Unexpected number",
60 unexpected_token_string: "Unexpected string", 60 unexpected_token_string: "Unexpected string",
61 unexpected_token_identifier: "Unexpected identifier", 61 unexpected_token_identifier: "Unexpected identifier",
62 unexpected_eos: "Unexpected end of input", 62 unexpected_eos: "Unexpected end of input",
63 malformed_regexp: "Invalid regular expression: /%0/: %1", 63 malformed_regexp: "Invalid regular expression: /%0/: %1",
64 unterminated_regexp: "Invalid regular expression: missing /", 64 unterminated_regexp: "Invalid regular expression: missing /",
65 regexp_flags: "Cannot supply flags when constructing one RegEx p from another", 65 regexp_flags: "Cannot supply flags when constructing one " +
66 "RegExp from another",
66 invalid_lhs_in_assignment: "Invalid left-hand side in assignment", 67 invalid_lhs_in_assignment: "Invalid left-hand side in assignment",
67 invalid_lhs_in_for_in: "Invalid left-hand side in for-in", 68 invalid_lhs_in_for_in: "Invalid left-hand side in for-in",
68 invalid_lhs_in_postfix_op: "Invalid left-hand side expression in postfix op eration", 69 invalid_lhs_in_postfix_op: "Invalid left-hand side expression in " +
69 invalid_lhs_in_prefix_op: "Invalid left-hand side expression in prefix ope ration", 70 "postfix operation",
70 multiple_defaults_in_switch: "More than one default clause in switch statemen t", 71 invalid_lhs_in_prefix_op: "Invalid left-hand side expression in " +
72 "prefix operation",
73 multiple_defaults_in_switch: "More than one default clause in switch " +
74 "statement",
71 newline_after_throw: "Illegal newline after throw", 75 newline_after_throw: "Illegal newline after throw",
72 redeclaration: "%0 '%1' has already been declared", 76 redeclaration: "%0 '%1' has already been declared",
73 no_catch_or_finally: "Missing catch or finally after try", 77 no_catch_or_finally: "Missing catch or finally after try",
74 unknown_label: "Undefined label '%0'", 78 unknown_label: "Undefined label '%0'",
75 uncaught_exception: "Uncaught %0", 79 uncaught_exception: "Uncaught %0",
76 stack_trace: "Stack Trace:\n%0", 80 stack_trace: "Stack Trace:\n%0",
77 called_non_callable: "%0 is not a function", 81 called_non_callable: "%0 is not a function",
78 undefined_method: "Object %1 has no method '%0'", 82 undefined_method: "Object %1 has no method '%0'",
79 property_not_function: "Property '%0' of object %1 is not a function", 83 property_not_function: "Property '%0' of object %1 is not a function",
80 cannot_convert_to_primitive: "Cannot convert object to primitive value", 84 cannot_convert_to_primitive: "Cannot convert object to primitive value",
81 not_constructor: "%0 is not a constructor", 85 not_constructor: "%0 is not a constructor",
82 not_defined: "%0 is not defined", 86 not_defined: "%0 is not defined",
83 non_object_property_load: "Cannot read property '%0' of %1", 87 non_object_property_load: "Cannot read property '%0' of %1",
84 non_object_property_store: "Cannot set property '%0' of %1", 88 non_object_property_store: "Cannot set property '%0' of %1",
85 non_object_property_call: "Cannot call method '%0' of %1", 89 non_object_property_call: "Cannot call method '%0' of %1",
86 with_expression: "%0 has no properties", 90 with_expression: "%0 has no properties",
87 illegal_invocation: "Illegal invocation", 91 illegal_invocation: "Illegal invocation",
88 no_setter_in_callback: "Cannot set property %0 of %1 which has only a g etter", 92 no_setter_in_callback: "Cannot set property %0 of %1 which has " +
89 apply_non_function: "Function.prototype.apply was called on %0, whic h is a %1 and not a function", 93 "only a getter",
90 apply_wrong_args: "Function.prototype.apply: Arguments list has wr ong type", 94 apply_non_function: "Function.prototype.apply was called on %0, " +
91 invalid_in_operator_use: "Cannot use 'in' operator to search for '%0' in %1", 95 "which is a %1 and not a function",
92 instanceof_function_expected: "Expecting a function in instanceof check, but g ot %0", 96 apply_wrong_args: "Function.prototype.apply: Arguments list " +
93 instanceof_nonobject_proto: "Function has non-object prototype '%0' in insta nceof check", 97 "has wrong type",
98 invalid_in_operator_use: "Cannot use 'in' operator to search for " +
99 "'%0' in %1",
100 instanceof_function_expected: "Expecting a function in instanceof check, " +
101 "but got %0",
102 instanceof_nonobject_proto: "Function has non-object prototype '%0' in " +
103 "instanceof check",
94 null_to_object: "Cannot convert null to object", 104 null_to_object: "Cannot convert null to object",
95 reduce_no_initial: "Reduce of empty array with no initial value", 105 reduce_no_initial: "Reduce of empty array with no initial value",
96 // RangeError 106 // RangeError
97 invalid_array_length: "Invalid array length", 107 invalid_array_length: "Invalid array length",
98 stack_overflow: "Maximum call stack size exceeded", 108 stack_overflow: "Maximum call stack size exceeded",
99 apply_overflow: "Function.prototype.apply cannot support %0 argu ments", 109 apply_overflow: "Function.prototype.apply cannot support %0 " +
110 "arguments",
100 // SyntaxError 111 // SyntaxError
101 unable_to_parse: "Parse error", 112 unable_to_parse: "Parse error",
102 duplicate_regexp_flag: "Duplicate RegExp flag %0", 113 duplicate_regexp_flag: "Duplicate RegExp flag %0",
103 invalid_regexp: "Invalid RegExp pattern /%0/", 114 invalid_regexp: "Invalid RegExp pattern /%0/",
104 illegal_break: "Illegal break statement", 115 illegal_break: "Illegal break statement",
105 illegal_continue: "Illegal continue statement", 116 illegal_continue: "Illegal continue statement",
106 illegal_return: "Illegal return statement", 117 illegal_return: "Illegal return statement",
107 error_loading_debugger: "Error loading debugger %0", 118 error_loading_debugger: "Error loading debugger %0",
108 no_input_to_regexp: "No input to %0", 119 no_input_to_regexp: "No input to %0",
109 result_not_primitive: "Result of %0 must be a primitive, was %1", 120 result_not_primitive: "Result of %0 must be a primitive, was %1",
110 invalid_json: "String '%0' is not valid JSON", 121 invalid_json: "String '%0' is not valid JSON",
111 circular_structure: "Converting circular structure to JSON" 122 circular_structure: "Converting circular structure to JSON"
112 }; 123 };
113 124
114 125
115 function FormatString(format, args) { 126 function FormatString(format, args) {
116 var result = format; 127 var result = format;
117 for (var i = 0; i < args.length; i++) { 128 for (var i = 0; i < args.length; i++) {
118 var str; 129 var str;
119 try { str = ToDetailString(args[i]); } 130 try { str = ToDetailString(args[i]); }
120 catch (e) { str = "#<error>"; } 131 catch (e) { str = "#<error>"; }
121 result = ArrayJoin.call(StringSplit.call(result, "%" + i), str); 132 result = ArrayJoin.call(StringSplit.call(result, "%" + i), str);
122 } 133 }
123 return result; 134 return result;
124 } 135 }
125 136
126 137
127 function ToDetailString(obj) { 138 function ToDetailString(obj) {
128 if (obj != null && IS_OBJECT(obj) && obj.toString === $Object.prototype.toStri ng) { 139 if (obj != null && IS_OBJECT(obj) &&
140 obj.toString === $Object.prototype.toString) {
129 var constructor = obj.constructor; 141 var constructor = obj.constructor;
130 if (!constructor) return ToString(obj); 142 if (!constructor) return ToString(obj);
131 var constructorName = constructor.name; 143 var constructorName = constructor.name;
132 if (!constructorName) return ToString(obj); 144 if (!constructorName) return ToString(obj);
133 return "#<" + GetInstanceName(constructorName) + ">"; 145 return "#<" + GetInstanceName(constructorName) + ">";
134 } else { 146 } else {
135 return ToString(obj); 147 return ToString(obj);
136 } 148 }
137 } 149 }
138 150
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 /** 295 /**
284 * Get information on a specific source line and column possibly offset by a 296 * Get information on a specific source line and column possibly offset by a
285 * fixed source position. This function is used to find a source position from 297 * fixed source position. This function is used to find a source position from
286 * a line and column position. The fixed source position offset is typically 298 * a line and column position. The fixed source position offset is typically
287 * used to find a source position in a function based on a line and column in 299 * used to find a source position in a function based on a line and column in
288 * the source for the function alone. The offset passed will then be the 300 * the source for the function alone. The offset passed will then be the
289 * start position of the source for the function within the full script source. 301 * start position of the source for the function within the full script source.
290 * @param {number} opt_line The line within the source. Default value is 0 302 * @param {number} opt_line The line within the source. Default value is 0
291 * @param {number} opt_column The column in within the line. Default value is 0 303 * @param {number} opt_column The column in within the line. Default value is 0
292 * @param {number} opt_offset_position The offset from the begining of the 304 * @param {number} opt_offset_position The offset from the begining of the
293 * source from where the line and column calculation starts. Default value i s 0 305 * source from where the line and column calculation starts. Default
306 * value is 0
294 * @return {SourceLocation} 307 * @return {SourceLocation}
295 * If line is negative or not in the source null is returned. 308 * If line is negative or not in the source null is returned.
296 */ 309 */
297 Script.prototype.locationFromLine = function (opt_line, opt_column, opt_offset_p osition) { 310 Script.prototype.locationFromLine = function (opt_line, opt_column,
311 opt_offset_position) {
298 // Default is the first line in the script. Lines in the script is relative 312 // Default is the first line in the script. Lines in the script is relative
299 // to the offset within the resource. 313 // to the offset within the resource.
300 var line = 0; 314 var line = 0;
301 if (!IS_UNDEFINED(opt_line)) { 315 if (!IS_UNDEFINED(opt_line)) {
302 line = opt_line - this.line_offset; 316 line = opt_line - this.line_offset;
303 } 317 }
304 318
305 // Default is first column. If on the first line add the offset within the 319 // Default is first column. If on the first line add the offset within the
306 // resource. 320 // resource.
307 var column = opt_column || 0; 321 var column = opt_column || 0;
308 if (line == 0) { 322 if (line == 0) {
309 column -= this.column_offset 323 column -= this.column_offset
310 } 324 }
311 325
312 var offset_position = opt_offset_position || 0; 326 var offset_position = opt_offset_position || 0;
313 if (line < 0 || column < 0 || offset_position < 0) return null; 327 if (line < 0 || column < 0 || offset_position < 0) return null;
314 if (line == 0) { 328 if (line == 0) {
315 return this.locationFromPosition(offset_position + column, false); 329 return this.locationFromPosition(offset_position + column, false);
316 } else { 330 } else {
317 // Find the line where the offset position is located. 331 // Find the line where the offset position is located.
318 var offset_line = this.lineFromPosition(offset_position); 332 var offset_line = this.lineFromPosition(offset_position);
319 333
320 if (offset_line == -1 || offset_line + line >= this.lineCount()) { 334 if (offset_line == -1 || offset_line + line >= this.lineCount()) {
321 return null; 335 return null;
322 } 336 }
323 337
324 return this.locationFromPosition(this.line_ends[offset_line + line - 1] + 1 + column); // line > 0 here. 338 // line > 0 here.
339 return this.locationFromPosition(this.line_ends[offset_line + line - 1] +
340 1 + column);
325 } 341 }
326 } 342 }
327 343
328 344
329 /** 345 /**
330 * Get a slice of source code from the script. The boundaries for the slice is 346 * Get a slice of source code from the script. The boundaries for the slice is
331 * specified in lines. 347 * specified in lines.
332 * @param {number} opt_from_line The first line (zero bound) in the slice. 348 * @param {number} opt_from_line The first line (zero bound) in the slice.
333 * Default is 0 349 * Default is 0
334 * @param {number} opt_to_column The last line (zero bound) in the slice (non 350 * @param {number} opt_to_column The last line (zero bound) in the slice (non
335 * inclusive). Default is the number of lines in the script 351 * inclusive). Default is the number of lines in the script
336 * @return {SourceSlice} The source slice or null of the parameters where 352 * @return {SourceSlice} The source slice or null of the parameters where
337 * invalid 353 * invalid
338 */ 354 */
339 Script.prototype.sourceSlice = function (opt_from_line, opt_to_line) { 355 Script.prototype.sourceSlice = function (opt_from_line, opt_to_line) {
340 var from_line = IS_UNDEFINED(opt_from_line) ? this.line_offset : opt_from_line ; 356 var from_line =
341 var to_line = IS_UNDEFINED(opt_to_line) ? this.line_offset + this.lineCount() : opt_to_line 357 IS_UNDEFINED(opt_from_line) ? this.line_offset : opt_from_line;
358 var to_line =
359 IS_UNDEFINED(opt_to_line) ?
360 this.line_offset + this.lineCount() :
361 opt_to_line;
342 362
343 // Adjust according to the offset within the resource. 363 // Adjust according to the offset within the resource.
344 from_line -= this.line_offset; 364 from_line -= this.line_offset;
345 to_line -= this.line_offset; 365 to_line -= this.line_offset;
346 if (from_line < 0) from_line = 0; 366 if (from_line < 0) from_line = 0;
347 if (to_line > this.lineCount()) to_line = this.lineCount(); 367 if (to_line > this.lineCount()) to_line = this.lineCount();
348 368
349 // Check parameters. 369 // Check parameters.
350 if (from_line >= this.lineCount() || 370 if (from_line >= this.lineCount() ||
351 to_line < 0 || 371 to_line < 0 ||
352 from_line > to_line) { 372 from_line > to_line) {
353 return null; 373 return null;
354 } 374 }
355 375
356 var from_position = from_line == 0 ? 0 : this.line_ends[from_line - 1] + 1; 376 var from_position = from_line == 0 ? 0 : this.line_ends[from_line - 1] + 1;
357 var to_position = to_line == 0 ? 0 : this.line_ends[to_line - 1] + 1; 377 var to_position = to_line == 0 ? 0 : this.line_ends[to_line - 1] + 1;
358 378
359 // Return a source slice with line numbers re-adjusted to the resource. 379 // Return a source slice with line numbers re-adjusted to the resource.
360 return new SourceSlice(this, from_line + this.line_offset, to_line + this.line _offset, 380 return new SourceSlice(this, from_line + this.line_offset,
381 to_line + this.line_offset,
361 from_position, to_position); 382 from_position, to_position);
362 } 383 }
363 384
364 385
365 Script.prototype.sourceLine = function (opt_line) { 386 Script.prototype.sourceLine = function (opt_line) {
366 // Default is the first line in the script. Lines in the script are relative 387 // Default is the first line in the script. Lines in the script are relative
367 // to the offset within the resource. 388 // to the offset within the resource.
368 var line = 0; 389 var line = 0;
369 if (!IS_UNDEFINED(opt_line)) { 390 if (!IS_UNDEFINED(opt_line)) {
370 line = opt_line - this.line_offset; 391 line = opt_line - this.line_offset;
(...skipping 24 matching lines...) Expand all
395 416
396 /** 417 /**
397 * Class for source location. A source location is a position within some 418 * Class for source location. A source location is a position within some
398 * source with the following properties: 419 * source with the following properties:
399 * script : script object for the source 420 * script : script object for the source
400 * line : source line number 421 * line : source line number
401 * column : source column within the line 422 * column : source column within the line
402 * position : position within the source 423 * position : position within the source
403 * start : position of start of source context (inclusive) 424 * start : position of start of source context (inclusive)
404 * end : position of end of source context (not inclusive) 425 * end : position of end of source context (not inclusive)
405 * Source text for the source context is the character interval [start, end[. In 426 * Source text for the source context is the character interval [start, end[.
406 * most cases end will point to a newline character. It might point just past 427 * In most cases end will point to a newline character. It might point just
407 * the final position of the source if the last source line does not end with a 428 * past the final position of the source if the last source line does not end
408 * newline character. 429 * with a newline character.
409 * @param {Script} script The Script object for which this is a location 430 * @param {Script} script The Script object for which this is a location
410 * @param {number} position Source position for the location 431 * @param {number} position Source position for the location
411 * @param {number} line The line number for the location 432 * @param {number} line The line number for the location
412 * @param {number} column The column within the line for the location 433 * @param {number} column The column within the line for the location
413 * @param {number} start Source position for start of source context 434 * @param {number} start Source position for start of source context
414 * @param {number} end Source position for end of source context 435 * @param {number} end Source position for end of source context
415 * @constructor 436 * @constructor
416 */ 437 */
417 function SourceLocation(script, position, line, column, start, end) { 438 function SourceLocation(script, position, line, column, start, end) {
418 this.script = script; 439 this.script = script;
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 DefineError(function ReferenceError() { }); 879 DefineError(function ReferenceError() { });
859 DefineError(function EvalError() { }); 880 DefineError(function EvalError() { });
860 DefineError(function URIError() { }); 881 DefineError(function URIError() { });
861 882
862 // Setup extra properties of the Error.prototype object. 883 // Setup extra properties of the Error.prototype object.
863 $Error.prototype.message = ''; 884 $Error.prototype.message = '';
864 885
865 %SetProperty($Error.prototype, 'toString', function toString() { 886 %SetProperty($Error.prototype, 'toString', function toString() {
866 var type = this.type; 887 var type = this.type;
867 if (type && !this.hasOwnProperty("message")) { 888 if (type && !this.hasOwnProperty("message")) {
868 return this.name + ": " + FormatMessage({ type: type, args: this.arguments } ); 889 return this.name + ": " +
890 FormatMessage({ type: type, args: this.arguments });
869 } 891 }
870 var message = this.message; 892 var message = this.message;
871 return this.name + (message ? (": " + message) : ""); 893 return this.name + (message ? (": " + message) : "");
872 }, DONT_ENUM); 894 }, DONT_ENUM);
873 895
874 896
875 // Boilerplate for exceptions for stack overflows. Used from 897 // Boilerplate for exceptions for stack overflows. Used from
876 // Top::StackOverflow(). 898 // Top::StackOverflow().
877 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 899 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698