| OLD | NEW |
| 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library fletchc.debug_info; | 5 library fletchc.debug_info; |
| 6 | 6 |
| 7 import 'dart:math' show | 7 import 'dart:math' show |
| 8 min; | 8 min; |
| 9 | 9 |
| 10 import 'package:compiler/src/colors.dart' as colors; | 10 import 'package:compiler/src/colors.dart' as colors; |
| 11 | 11 |
| 12 import 'package:compiler/src/dart2jslib.dart' show | 12 import 'package:compiler/src/dart2jslib.dart' show |
| 13 SourceSpan; | 13 SourceSpan; |
| 14 | 14 |
| 15 import 'package:compiler/src/elements/elements.dart'; | 15 import 'package:compiler/src/elements/elements.dart'; |
| 16 | 16 |
| 17 import 'package:compiler/src/io/source_file.dart'; | 17 import 'package:compiler/src/io/source_file.dart'; |
| 18 | 18 |
| 19 import 'package:compiler/src/tree/tree.dart' show | 19 import 'package:compiler/src/tree/tree.dart' show |
| 20 Node; | 20 Node; |
| 21 | 21 |
| 22 import 'package:compiler/src/source_file_provider.dart' show | 22 import 'package:compiler/src/source_file_provider.dart' show |
| 23 SourceFileProvider; | 23 SourceFileProvider; |
| 24 | 24 |
| 25 import 'codegen_visitor.dart'; | 25 import 'codegen_visitor.dart'; |
| 26 import 'compiled_function.dart'; | 26 import 'fletch_function_builder.dart'; |
| 27 | 27 |
| 28 import 'fletch_compiler.dart' show | 28 import 'fletch_compiler.dart' show |
| 29 FletchCompiler; | 29 FletchCompiler; |
| 30 | 30 |
| 31 class ScopeInfo { | 31 class ScopeInfo { |
| 32 static const ScopeInfo sentinel = const ScopeInfo(0, null, null); | 32 static const ScopeInfo sentinel = const ScopeInfo(0, null, null); |
| 33 | 33 |
| 34 final int bytecodeIndex; | 34 final int bytecodeIndex; |
| 35 final LocalValue local; | 35 final LocalValue local; |
| 36 final ScopeInfo previous; | 36 final ScopeInfo previous; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 bool isSameSourceLevelLocationAs(SourceLocation other) { | 74 bool isSameSourceLevelLocationAs(SourceLocation other) { |
| 75 if (other == null) return false; | 75 if (other == null) return false; |
| 76 if (file != other.file) return false; | 76 if (file != other.file) return false; |
| 77 if (span == null || other.span == null) return span == other.span; | 77 if (span == null || other.span == null) return span == other.span; |
| 78 return span.begin == other.span.begin && span.end == other.span.end; | 78 return span.begin == other.span.begin && span.end == other.span.end; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 class DebugInfo { | 82 class DebugInfo { |
| 83 final CompiledFunction function; | 83 final FletchFunctionBuilder function; |
| 84 final List<SourceLocation> locations = <SourceLocation>[]; | 84 final List<SourceLocation> locations = <SourceLocation>[]; |
| 85 final List<ScopeInfo> scopeInfos = <ScopeInfo>[ScopeInfo.sentinel]; | 85 final List<ScopeInfo> scopeInfos = <ScopeInfo>[ScopeInfo.sentinel]; |
| 86 | 86 |
| 87 DebugInfo(this.function); | 87 DebugInfo(this.function); |
| 88 | 88 |
| 89 void addLocation(FletchCompiler compiler, int bytecodeIndex, Node node) { | 89 void addLocation(FletchCompiler compiler, int bytecodeIndex, Node node) { |
| 90 SourceSpan span = compiler.spanFromSpannable(node); | 90 SourceSpan span = compiler.spanFromSpannable(node); |
| 91 SourceFile file = null; | 91 SourceFile file = null; |
| 92 // TODO(ahe): What to do if compiler.provider isn't a SourceFileProvider? | 92 // TODO(ahe): What to do if compiler.provider isn't a SourceFileProvider? |
| 93 // Perhaps we can create a new type of diagnostic, see | 93 // Perhaps we can create a new type of diagnostic, see |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 buffer.write('${startLine + 1}'.padRight(5) + l); | 220 buffer.write('${startLine + 1}'.padRight(5) + l); |
| 221 } | 221 } |
| 222 | 222 |
| 223 return buffer.toString(); | 223 return buffer.toString(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 SourceLocation sourceLocationFor(int bytecodeIndex) { | 226 SourceLocation sourceLocationFor(int bytecodeIndex) { |
| 227 return locationFor(bytecodeIndex); | 227 return locationFor(bytecodeIndex); |
| 228 } | 228 } |
| 229 } | 229 } |
| OLD | NEW |