| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of debugger; | 5 part of debugger; |
| 6 | 6 |
| 7 class SourceLocation { | 7 class SourceLocation { |
| 8 SourceLocation.file(this.script, this.line, this.col); | 8 SourceLocation.file(this.script, this.line, this.col); |
| 9 SourceLocation.func(this.function); | 9 SourceLocation.func(this.function); |
| 10 SourceLocation.error(this.errorMessage); | 10 SourceLocation.error(this.errorMessage); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return new Future.value(new SourceLocation.error( | 41 return new Future.value(new SourceLocation.error( |
| 42 "Invalid source location '${locDesc}'")); | 42 "Invalid source location '${locDesc}'")); |
| 43 } | 43 } |
| 44 | 44 |
| 45 static Future<SourceLocation> _currentLocation(Debugger debugger) { | 45 static Future<SourceLocation> _currentLocation(Debugger debugger) { |
| 46 ServiceMap stack = debugger.stack; | 46 ServiceMap stack = debugger.stack; |
| 47 if (stack == null || stack['frames'].length == 0) { | 47 if (stack == null || stack['frames'].length == 0) { |
| 48 return new Future.value(new SourceLocation.error( | 48 return new Future.value(new SourceLocation.error( |
| 49 'A script must be provided when the stack is empty')); | 49 'A script must be provided when the stack is empty')); |
| 50 } | 50 } |
| 51 var frame = stack['frames'][0]; | 51 var frame = stack['frames'][debugger.currentFrame]; |
| 52 Script script = frame['script']; | 52 Script script = frame['script']; |
| 53 return script.load().then((_) { | 53 return script.load().then((_) { |
| 54 var line = script.tokenToLine(frame['tokenPos']); | 54 var line = script.tokenToLine(frame['tokenPos']); |
| 55 // TODO(turnidge): Pass in the column here once the protocol supports it. | 55 // TODO(turnidge): Pass in the column here once the protocol supports it. |
| 56 return new Future.value(new SourceLocation.file(script, line, null)); | 56 return new Future.value(new SourceLocation.file(script, line, null)); |
| 57 }); | 57 }); |
| 58 } | 58 } |
| 59 | 59 |
| 60 static Future<SourceLocation> _parseScriptLine(Debugger debugger, | 60 static Future<SourceLocation> _parseScriptLine(Debugger debugger, |
| 61 Match match) { | 61 Match match) { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return 'invalid source location (${errorMessage})'; | 358 return 'invalid source location (${errorMessage})'; |
| 359 } | 359 } |
| 360 | 360 |
| 361 Script script; | 361 Script script; |
| 362 int line; | 362 int line; |
| 363 int col; | 363 int col; |
| 364 ServiceFunction function; | 364 ServiceFunction function; |
| 365 String errorMessage; | 365 String errorMessage; |
| 366 bool get valid => (errorMessage == null); | 366 bool get valid => (errorMessage == null); |
| 367 } | 367 } |
| OLD | NEW |