Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 constructor_is_generator: ["Class constructor may not be a generator"], | 9 constructor_is_generator: ["Class constructor may not be a generator"], |
| 10 constructor_is_accessor: ["Class constructor may not be an accessor"], | 10 constructor_is_accessor: ["Class constructor may not be an accessor"], |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 * @param {number} position The source position. | 394 * @param {number} position The source position. |
| 395 * @return {number} 0 if input too small, -1 if input too large, | 395 * @return {number} 0 if input too small, -1 if input too large, |
| 396 else the line number. | 396 else the line number. |
| 397 */ | 397 */ |
| 398 function ScriptLineFromPosition(position) { | 398 function ScriptLineFromPosition(position) { |
| 399 var lower = 0; | 399 var lower = 0; |
| 400 var upper = this.lineCount() - 1; | 400 var upper = this.lineCount() - 1; |
| 401 var line_ends = this.line_ends; | 401 var line_ends = this.line_ends; |
| 402 | 402 |
| 403 // We'll never find invalid positions so bail right away. | 403 // We'll never find invalid positions so bail right away. |
| 404 if (position - 1 > line_ends[upper]) { | |
|
yurys
2015/04/27 09:23:15
I'd rather v8 highlighted position of the last tok
| |
| 405 return -1; | |
| 406 } | |
| 407 | |
| 408 // Process EOS token | |
| 404 if (position > line_ends[upper]) { | 409 if (position > line_ends[upper]) { |
| 405 return -1; | 410 return upper; |
| 406 } | 411 } |
| 407 | 412 |
| 408 // This means we don't have to safe-guard indexing line_ends[i - 1]. | 413 // This means we don't have to safe-guard indexing line_ends[i - 1]. |
| 409 if (position <= line_ends[0]) { | 414 if (position <= line_ends[0]) { |
| 410 return 0; | 415 return 0; |
| 411 } | 416 } |
| 412 | 417 |
| 413 // Binary search to find line # from position range. | 418 // Binary search to find line # from position range. |
| 414 while (upper >= 1) { | 419 while (upper >= 1) { |
| 415 var i = (lower + upper) >> 1; | 420 var i = (lower + upper) >> 1; |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1267 function SetUpStackOverflowBoilerplate() { | 1272 function SetUpStackOverflowBoilerplate() { |
| 1268 var boilerplate = MakeRangeError(kStackOverflow); | 1273 var boilerplate = MakeRangeError(kStackOverflow); |
| 1269 | 1274 |
| 1270 %DefineAccessorPropertyUnchecked( | 1275 %DefineAccessorPropertyUnchecked( |
| 1271 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1276 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1272 | 1277 |
| 1273 return boilerplate; | 1278 return boilerplate; |
| 1274 } | 1279 } |
| 1275 | 1280 |
| 1276 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1281 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |