OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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 dartino_compiler.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/diagnostics/source_span.dart' show | 12 import 'package:compiler/src/diagnostics/source_span.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 unparse; | 21 unparse; |
22 | 22 |
23 import 'package:compiler/src/source_file_provider.dart' show | 23 import 'package:compiler/src/source_file_provider.dart' show |
24 SourceFileProvider; | 24 SourceFileProvider; |
25 | 25 |
26 import 'codegen_visitor.dart'; | 26 import 'codegen_visitor.dart'; |
27 import '../fletch_system.dart'; | 27 import '../dartino_system.dart'; |
28 import 'hub/session_manager.dart' show | 28 import 'hub/session_manager.dart' show |
29 SessionState; | 29 SessionState; |
30 | 30 |
31 import 'fletch_compiler_implementation.dart' show | 31 import 'dartino_compiler_implementation.dart' show |
32 FletchCompilerImplementation; | 32 DartinoCompilerImplementation; |
33 | 33 |
34 class ScopeInfo { | 34 class ScopeInfo { |
35 static const ScopeInfo sentinel = const ScopeInfo(0, null, null); | 35 static const ScopeInfo sentinel = const ScopeInfo(0, null, null); |
36 | 36 |
37 final int bytecodeIndex; | 37 final int bytecodeIndex; |
38 final LocalValue local; | 38 final LocalValue local; |
39 final ScopeInfo previous; | 39 final ScopeInfo previous; |
40 const ScopeInfo(this.bytecodeIndex, this.local, this.previous); | 40 const ScopeInfo(this.bytecodeIndex, this.local, this.previous); |
41 | 41 |
42 LocalValue lookup(String name) { | 42 LocalValue lookup(String name) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 bool isSameSourceLevelLocationAs(SourceLocation other) { | 77 bool isSameSourceLevelLocationAs(SourceLocation other) { |
78 if (other == null) return false; | 78 if (other == null) return false; |
79 if (file != other.file) return false; | 79 if (file != other.file) return false; |
80 if (span == null || other.span == null) return span == other.span; | 80 if (span == null || other.span == null) return span == other.span; |
81 return span.begin == other.span.begin && span.end == other.span.end; | 81 return span.begin == other.span.begin && span.end == other.span.end; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 class DebugInfo { | 85 class DebugInfo { |
86 final FletchFunction function; | 86 final DartinoFunction function; |
87 final List<SourceLocation> locations = <SourceLocation>[]; | 87 final List<SourceLocation> locations = <SourceLocation>[]; |
88 final List<ScopeInfo> scopeInfos = <ScopeInfo>[ScopeInfo.sentinel]; | 88 final List<ScopeInfo> scopeInfos = <ScopeInfo>[ScopeInfo.sentinel]; |
89 | 89 |
90 DebugInfo(this.function); | 90 DebugInfo(this.function); |
91 | 91 |
92 void addLocation( | 92 void addLocation( |
93 FletchCompilerImplementation compiler, | 93 DartinoCompilerImplementation compiler, |
94 int bytecodeIndex, | 94 int bytecodeIndex, |
95 Node node) { | 95 Node node) { |
96 SourceSpan span = compiler.reporter.spanFromSpannable(node); | 96 SourceSpan span = compiler.reporter.spanFromSpannable(node); |
97 SourceFile file = null; | 97 SourceFile file = null; |
98 // TODO(ahe): What to do if compiler.provider isn't a SourceFileProvider? | 98 // TODO(ahe): What to do if compiler.provider isn't a SourceFileProvider? |
99 // Perhaps we can create a new type of diagnostic, see | 99 // Perhaps we can create a new type of diagnostic, see |
100 // package:compiler/compiler.dart. The class Diagnostic is an "extensible" | 100 // package:compiler/compiler.dart. The class Diagnostic is an "extensible" |
101 // enum class. This way, the debugger doesn't hold on to files. | 101 // enum class. This way, the debugger doesn't hold on to files. |
102 // Alternatively, source files should be obtained by iterating through the | 102 // Alternatively, source files should be obtained by iterating through the |
103 // compilation units. | 103 // compilation units. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 String highlight(String message, Function color, SessionState state) { | 237 String highlight(String message, Function color, SessionState state) { |
238 return state.colorsDisabled ? message : color(message); | 238 return state.colorsDisabled ? message : color(message); |
239 } | 239 } |
240 | 240 |
241 SourceLocation sourceLocationFor(int bytecodeIndex) { | 241 SourceLocation sourceLocationFor(int bytecodeIndex) { |
242 return locationFor(bytecodeIndex); | 242 return locationFor(bytecodeIndex); |
243 } | 243 } |
244 } | 244 } |
OLD | NEW |