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

Side by Side Diff: src/messages.js

Issue 1053563002: Revert of Correctly compute line numbers in functions from the function constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added regression test Created 5 years, 8 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 | « src/generator.js ('k') | src/objects.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ------------------------------------------------------------------- 5 // -------------------------------------------------------------------
6 6
7 var kMessages = { 7 var kMessages = {
8 // Error 8 // Error
9 cyclic_proto: ["Cyclic __proto__ value"], 9 cyclic_proto: ["Cyclic __proto__ value"],
10 code_gen_from_strings: ["%0"], 10 code_gen_from_strings: ["%0"],
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return MakeGenericError($ReferenceError, type, [arg]); 403 return MakeGenericError($ReferenceError, type, [arg]);
404 } 404 }
405 405
406 /** 406 /**
407 * Find a line number given a specific source position. 407 * Find a line number given a specific source position.
408 * @param {number} position The source position. 408 * @param {number} position The source position.
409 * @return {number} 0 if input too small, -1 if input too large, 409 * @return {number} 0 if input too small, -1 if input too large,
410 else the line number. 410 else the line number.
411 */ 411 */
412 function ScriptLineFromPosition(position) { 412 function ScriptLineFromPosition(position) {
413 var lower = 0;
414 var upper = this.lineCount() - 1;
413 var line_ends = this.line_ends; 415 var line_ends = this.line_ends;
414 var upper = line_ends.length - 1;
415 if (upper < 0) return -1;
416 416
417 // We'll never find invalid positions so bail right away. 417 // We'll never find invalid positions so bail right away.
418 if (position > line_ends[upper]) return -1; 418 if (position > line_ends[upper]) {
419 if (position <= line_ends[0]) return 0; 419 return -1;
420 }
420 421
421 var lower = 1; 422 // This means we don't have to safe-guard indexing line_ends[i - 1].
422 // Binary search. 423 if (position <= line_ends[0]) {
423 while (true) { 424 return 0;
424 var mid = (upper + lower) >> 1; 425 }
425 if (position <= line_ends[mid - 1]) { 426
426 upper = mid - 1; 427 // Binary search to find line # from position range.
427 } else if (position > line_ends[mid]){ 428 while (upper >= 1) {
428 lower = mid + 1; 429 var i = (lower + upper) >> 1;
430
431 if (position > line_ends[i]) {
432 lower = i + 1;
433 } else if (position <= line_ends[i - 1]) {
434 upper = i - 1;
429 } else { 435 } else {
430 return mid; 436 return i;
431 } 437 }
432 } 438 }
439
440 return -1;
433 } 441 }
434 442
435 /** 443 /**
436 * Get information on a specific source position. 444 * Get information on a specific source position.
437 * @param {number} position The source position 445 * @param {number} position The source position
438 * @param {boolean} include_resource_offset Set to true to have the resource 446 * @param {boolean} include_resource_offset Set to true to have the resource
439 * offset added to the location 447 * offset added to the location
440 * @return {SourceLocation} 448 * @return {SourceLocation}
441 * If line is negative or not in the source null is returned. 449 * If line is negative or not in the source null is returned.
442 */ 450 */
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 function SetUpStackOverflowBoilerplate() { 1277 function SetUpStackOverflowBoilerplate() {
1270 var boilerplate = MakeRangeError('stack_overflow', []); 1278 var boilerplate = MakeRangeError('stack_overflow', []);
1271 1279
1272 %DefineAccessorPropertyUnchecked( 1280 %DefineAccessorPropertyUnchecked(
1273 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); 1281 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM);
1274 1282
1275 return boilerplate; 1283 return boilerplate;
1276 } 1284 }
1277 1285
1278 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1286 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW
« no previous file with comments | « src/generator.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698