| 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 cyclic_proto: ["Cyclic __proto__ value"], | 9 cyclic_proto: ["Cyclic __proto__ value"], |
| 10 code_gen_from_strings: ["%0"], | 10 code_gen_from_strings: ["%0"], |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 */ | 435 */ |
| 436 function ScriptLocationFromPosition(position, | 436 function ScriptLocationFromPosition(position, |
| 437 include_resource_offset) { | 437 include_resource_offset) { |
| 438 var line = this.lineFromPosition(position); | 438 var line = this.lineFromPosition(position); |
| 439 if (line == -1) return null; | 439 if (line == -1) return null; |
| 440 | 440 |
| 441 // Determine start, end and column. | 441 // Determine start, end and column. |
| 442 var line_ends = this.line_ends; | 442 var line_ends = this.line_ends; |
| 443 var start = line == 0 ? 0 : line_ends[line - 1] + 1; | 443 var start = line == 0 ? 0 : line_ends[line - 1] + 1; |
| 444 var end = line_ends[line]; | 444 var end = line_ends[line]; |
| 445 if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') { | 445 if (end > 0 && %_CallFunction(this.source, end - 1, $stringCharAt) == '\r') { |
| 446 end--; | 446 end--; |
| 447 } | 447 } |
| 448 var column = position - start; | 448 var column = position - start; |
| 449 | 449 |
| 450 // Adjust according to the offset within the resource. | 450 // Adjust according to the offset within the resource. |
| 451 if (include_resource_offset) { | 451 if (include_resource_offset) { |
| 452 line += this.line_offset; | 452 line += this.line_offset; |
| 453 if (line == this.line_offset) { | 453 if (line == this.line_offset) { |
| 454 column += this.column_offset; | 454 column += this.column_offset; |
| 455 } | 455 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 558 |
| 559 // Check parameter. | 559 // Check parameter. |
| 560 if (line < 0 || this.lineCount() <= line) { | 560 if (line < 0 || this.lineCount() <= line) { |
| 561 return null; | 561 return null; |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Return the source line. | 564 // Return the source line. |
| 565 var line_ends = this.line_ends; | 565 var line_ends = this.line_ends; |
| 566 var start = line == 0 ? 0 : line_ends[line - 1] + 1; | 566 var start = line == 0 ? 0 : line_ends[line - 1] + 1; |
| 567 var end = line_ends[line]; | 567 var end = line_ends[line]; |
| 568 return %_CallFunction(this.source, start, end, StringSubstring); | 568 return %_CallFunction(this.source, start, end, $stringSubstring); |
| 569 } | 569 } |
| 570 | 570 |
| 571 | 571 |
| 572 /** | 572 /** |
| 573 * Returns the number of source lines. | 573 * Returns the number of source lines. |
| 574 * @return {number} | 574 * @return {number} |
| 575 * Number of source lines. | 575 * Number of source lines. |
| 576 */ | 576 */ |
| 577 function ScriptLineCount() { | 577 function ScriptLineCount() { |
| 578 // Return number of source lines. | 578 // Return number of source lines. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 700 |
| 701 /** | 701 /** |
| 702 * Get the source text for a SourceLocation | 702 * Get the source text for a SourceLocation |
| 703 * @return {String} | 703 * @return {String} |
| 704 * Source text for this location. | 704 * Source text for this location. |
| 705 */ | 705 */ |
| 706 function SourceLocationSourceText() { | 706 function SourceLocationSourceText() { |
| 707 return %_CallFunction(this.script.source, | 707 return %_CallFunction(this.script.source, |
| 708 this.start, | 708 this.start, |
| 709 this.end, | 709 this.end, |
| 710 StringSubstring); | 710 $stringSubstring); |
| 711 } | 711 } |
| 712 | 712 |
| 713 | 713 |
| 714 SetUpLockedPrototype(SourceLocation, | 714 SetUpLockedPrototype(SourceLocation, |
| 715 $Array("script", "position", "line", "column", "start", "end"), | 715 $Array("script", "position", "line", "column", "start", "end"), |
| 716 $Array( | 716 $Array( |
| 717 "restrict", SourceLocationRestrict, | 717 "restrict", SourceLocationRestrict, |
| 718 "sourceText", SourceLocationSourceText | 718 "sourceText", SourceLocationSourceText |
| 719 ) | 719 ) |
| 720 ); | 720 ); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 748 | 748 |
| 749 /** | 749 /** |
| 750 * Get the source text for a SourceSlice | 750 * Get the source text for a SourceSlice |
| 751 * @return {String} Source text for this slice. The last line will include | 751 * @return {String} Source text for this slice. The last line will include |
| 752 * the line terminating characters (if any) | 752 * the line terminating characters (if any) |
| 753 */ | 753 */ |
| 754 function SourceSliceSourceText() { | 754 function SourceSliceSourceText() { |
| 755 return %_CallFunction(this.script.source, | 755 return %_CallFunction(this.script.source, |
| 756 this.from_position, | 756 this.from_position, |
| 757 this.to_position, | 757 this.to_position, |
| 758 StringSubstring); | 758 $stringSubstring); |
| 759 } | 759 } |
| 760 | 760 |
| 761 SetUpLockedPrototype(SourceSlice, | 761 SetUpLockedPrototype(SourceSlice, |
| 762 $Array("script", "from_line", "to_line", "from_position", "to_position"), | 762 $Array("script", "from_line", "to_line", "from_position", "to_position"), |
| 763 $Array("sourceText", SourceSliceSourceText) | 763 $Array("sourceText", SourceSliceSourceText) |
| 764 ); | 764 ); |
| 765 | 765 |
| 766 | 766 |
| 767 // Returns the offset of the given position within the containing | 767 // Returns the offset of the given position within the containing |
| 768 // line. | 768 // line. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 var line = ""; | 962 var line = ""; |
| 963 var functionName = this.getFunctionName(); | 963 var functionName = this.getFunctionName(); |
| 964 var addSuffix = true; | 964 var addSuffix = true; |
| 965 var isConstructor = this.isConstructor(); | 965 var isConstructor = this.isConstructor(); |
| 966 var isMethodCall = !(this.isToplevel() || isConstructor); | 966 var isMethodCall = !(this.isToplevel() || isConstructor); |
| 967 if (isMethodCall) { | 967 if (isMethodCall) { |
| 968 var typeName = GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), true); | 968 var typeName = GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), true); |
| 969 var methodName = this.getMethodName(); | 969 var methodName = this.getMethodName(); |
| 970 if (functionName) { | 970 if (functionName) { |
| 971 if (typeName && | 971 if (typeName && |
| 972 %_CallFunction(functionName, typeName, StringIndexOfJS) != 0) { | 972 %_CallFunction(functionName, typeName, $stringIndexOf) != 0) { |
| 973 line += typeName + "."; | 973 line += typeName + "."; |
| 974 } | 974 } |
| 975 line += functionName; | 975 line += functionName; |
| 976 if (methodName && | 976 if (methodName && |
| 977 (%_CallFunction(functionName, "." + methodName, StringIndexOfJS) != | 977 (%_CallFunction(functionName, "." + methodName, $stringIndexOf) != |
| 978 functionName.length - methodName.length - 1)) { | 978 functionName.length - methodName.length - 1)) { |
| 979 line += " [as " + methodName + "]"; | 979 line += " [as " + methodName + "]"; |
| 980 } | 980 } |
| 981 } else { | 981 } else { |
| 982 line += typeName + "." + (methodName || "<anonymous>"); | 982 line += typeName + "." + (methodName || "<anonymous>"); |
| 983 } | 983 } |
| 984 } else if (isConstructor) { | 984 } else if (isConstructor) { |
| 985 line += "new " + (functionName || "<anonymous>"); | 985 line += "new " + (functionName || "<anonymous>"); |
| 986 } else if (functionName) { | 986 } else if (functionName) { |
| 987 line += functionName; | 987 line += functionName; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 function SetUpStackOverflowBoilerplate() { | 1323 function SetUpStackOverflowBoilerplate() { |
| 1324 var boilerplate = MakeRangeError('stack_overflow', []); | 1324 var boilerplate = MakeRangeError('stack_overflow', []); |
| 1325 | 1325 |
| 1326 %DefineAccessorPropertyUnchecked( | 1326 %DefineAccessorPropertyUnchecked( |
| 1327 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1327 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1328 | 1328 |
| 1329 return boilerplate; | 1329 return boilerplate; |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1332 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |