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 (function(global, utils) { | 7 (function(global, utils) { |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 var Int16x8ToString; | 30 var Int16x8ToString; |
31 var Int32x4ToString; | 31 var Int32x4ToString; |
32 var Int8x16ToString; | 32 var Int8x16ToString; |
33 var InternalArray = utils.InternalArray; | 33 var InternalArray = utils.InternalArray; |
34 var internalErrorSymbol = utils.ImportNow("internal_error_symbol"); | 34 var internalErrorSymbol = utils.ImportNow("internal_error_symbol"); |
35 var ObjectDefineProperty; | 35 var ObjectDefineProperty; |
36 var ObjectHasOwnProperty; | 36 var ObjectHasOwnProperty; |
37 var ObjectToString = utils.ImportNow("object_to_string"); | 37 var ObjectToString = utils.ImportNow("object_to_string"); |
38 var Script = utils.ImportNow("Script"); | 38 var Script = utils.ImportNow("Script"); |
39 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol"); | 39 var stackTraceSymbol = utils.ImportNow("stack_trace_symbol"); |
40 var StringCharAt; | |
41 var StringIndexOf; | 40 var StringIndexOf; |
42 var StringSubstring; | 41 var StringSubstring; |
43 var SymbolToString; | 42 var SymbolToString; |
44 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 43 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
45 var Uint16x8ToString; | 44 var Uint16x8ToString; |
46 var Uint32x4ToString; | 45 var Uint32x4ToString; |
47 var Uint8x16ToString; | 46 var Uint8x16ToString; |
48 | 47 |
49 utils.Import(function(from) { | 48 utils.Import(function(from) { |
50 ArrayJoin = from.ArrayJoin; | 49 ArrayJoin = from.ArrayJoin; |
51 Bool16x8ToString = from.Bool16x8ToString; | 50 Bool16x8ToString = from.Bool16x8ToString; |
52 Bool32x4ToString = from.Bool32x4ToString; | 51 Bool32x4ToString = from.Bool32x4ToString; |
53 Bool8x16ToString = from.Bool8x16ToString; | 52 Bool8x16ToString = from.Bool8x16ToString; |
54 Float32x4ToString = from.Float32x4ToString; | 53 Float32x4ToString = from.Float32x4ToString; |
55 Int16x8ToString = from.Int16x8ToString; | 54 Int16x8ToString = from.Int16x8ToString; |
56 Int32x4ToString = from.Int32x4ToString; | 55 Int32x4ToString = from.Int32x4ToString; |
57 Int8x16ToString = from.Int8x16ToString; | 56 Int8x16ToString = from.Int8x16ToString; |
58 ObjectDefineProperty = from.ObjectDefineProperty; | 57 ObjectDefineProperty = from.ObjectDefineProperty; |
59 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 58 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
60 StringCharAt = from.StringCharAt; | |
61 StringIndexOf = from.StringIndexOf; | 59 StringIndexOf = from.StringIndexOf; |
62 StringSubstring = from.StringSubstring; | 60 StringSubstring = from.StringSubstring; |
63 SymbolToString = from.SymbolToString; | 61 SymbolToString = from.SymbolToString; |
64 Uint16x8ToString = from.Uint16x8ToString; | 62 Uint16x8ToString = from.Uint16x8ToString; |
65 Uint32x4ToString = from.Uint32x4ToString; | 63 Uint32x4ToString = from.Uint32x4ToString; |
66 Uint8x16ToString = from.Uint8x16ToString; | 64 Uint8x16ToString = from.Uint8x16ToString; |
67 }); | 65 }); |
68 | 66 |
69 // ------------------------------------------------------------------- | 67 // ------------------------------------------------------------------- |
70 | 68 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } else if (position <= line_ends[i - 1]) { | 246 } else if (position <= line_ends[i - 1]) { |
249 upper = i - 1; | 247 upper = i - 1; |
250 } else { | 248 } else { |
251 return i; | 249 return i; |
252 } | 250 } |
253 } | 251 } |
254 | 252 |
255 return -1; | 253 return -1; |
256 } | 254 } |
257 | 255 |
| 256 |
258 /** | 257 /** |
259 * Get information on a specific source position. | 258 * Get information on a specific source position. |
260 * @param {number} position The source position | 259 * @param {number} position The source position |
261 * @param {boolean} include_resource_offset Set to true to have the resource | 260 * @param {boolean} include_resource_offset Set to true to have the resource |
262 * offset added to the location | 261 * offset added to the location |
263 * @return {SourceLocation} | 262 * @return {SourceLocation} |
264 * If line is negative or not in the source null is returned. | 263 * If line is negative or not in the source null is returned. |
265 */ | 264 */ |
266 function ScriptLocationFromPosition(position, | 265 function ScriptLocationFromPosition(position, |
267 include_resource_offset) { | 266 include_resource_offset) { |
268 var line = this.lineFromPosition(position); | 267 var line = this.lineFromPosition(position); |
269 if (line == -1) return null; | 268 if (line == -1) return null; |
270 | 269 |
271 // Determine start, end and column. | 270 // Determine start, end and column. |
272 var line_ends = this.line_ends; | 271 var line_ends = this.line_ends; |
273 var start = line == 0 ? 0 : line_ends[line - 1] + 1; | 272 var start = line == 0 ? 0 : line_ends[line - 1] + 1; |
274 var end = line_ends[line]; | 273 var end = line_ends[line]; |
275 if (end > 0 && %_Call(StringCharAt, this.source, end - 1) == '\r') { | 274 if (end > 0 && %_StringCharAt(this.source, end - 1) === '\r') { |
276 end--; | 275 end--; |
277 } | 276 } |
278 var column = position - start; | 277 var column = position - start; |
279 | 278 |
280 // Adjust according to the offset within the resource. | 279 // Adjust according to the offset within the resource. |
281 if (include_resource_offset) { | 280 if (include_resource_offset) { |
282 line += this.line_offset; | 281 line += this.line_offset; |
283 if (line == this.line_offset) { | 282 if (line == this.line_offset) { |
284 column += this.column_offset; | 283 column += this.column_offset; |
285 } | 284 } |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 utils.Export(function(to) { | 1017 utils.Export(function(to) { |
1019 to.ErrorToString = ErrorToString; | 1018 to.ErrorToString = ErrorToString; |
1020 to.MakeError = MakeError; | 1019 to.MakeError = MakeError; |
1021 to.MakeRangeError = MakeRangeError; | 1020 to.MakeRangeError = MakeRangeError; |
1022 to.MakeSyntaxError = MakeSyntaxError; | 1021 to.MakeSyntaxError = MakeSyntaxError; |
1023 to.MakeTypeError = MakeTypeError; | 1022 to.MakeTypeError = MakeTypeError; |
1024 to.MakeURIError = MakeURIError; | 1023 to.MakeURIError = MakeURIError; |
1025 }); | 1024 }); |
1026 | 1025 |
1027 }); | 1026 }); |
OLD | NEW |