Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Unified Diff: pkg/kernel/lib/ast.dart

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Updated kernels binary.md too. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 71316b5406eeaedbf6e74c5a748bec6f6ae49155..ca3af13c0f40584cf4d60c1d08dc02b712466a27 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -3504,17 +3504,19 @@ class Supertype extends Node {
class Program extends TreeNode {
final List<Library> libraries;
- /// Map from a source file uri to a line-starts table.
+ /// Map from a source file uri to a line-starts table and source code.
/// Given a source file uri and a offset in that file one can translate
/// it to a line:column position in that file.
- final Map<String, List<int>> uriToLineStarts;
+ final Map<String, LineStartsAndSource> uriToLineStartsAndSource;
/// Reference to the main method in one of the libraries.
Procedure mainMethod;
- Program([List<Library> libraries, Map<String, List<int>> uriToLineStarts])
+ Program(
+ [List<Library> libraries,
+ Map<String, LineStartsAndSource> uriToLineStartsAndSource])
: libraries = libraries ?? <Library>[],
- uriToLineStarts = uriToLineStarts ?? {} {
+ uriToLineStartsAndSource = uriToLineStartsAndSource ?? {} {
Kevin Millikin (Google) 2016/12/20 12:03:33 Should be <String, LineStartsAndSource>{}. Can't
jensj 2016/12/20 13:30:22 In loader.dart we add to it. We only have it up-fr
setParents(libraries, this);
}
@@ -3533,7 +3535,7 @@ class Program extends TreeNode {
/// Translates an offset to line and column numbers in the given file.
Location getLocation(String file, int offset) {
- List<int> lines = uriToLineStarts[file];
+ List<int> lines = uriToLineStartsAndSource[file].lineStarts;
int low = 0, high = lines.length - 1;
while (low < high) {
int mid = high - ((high - low) >> 1); // Get middle, rounding up.
@@ -3651,3 +3653,10 @@ class _ChildReplacer extends Transformer {
}
}
}
+
+class LineStartsAndSource {
Kevin Millikin (Google) 2016/12/20 12:03:33 I would just call this "Source", not describe the
jensj 2016/12/20 13:30:22 Done.
+ final List<int> lineStarts;
+ final String source;
+
+ LineStartsAndSource(this.lineStarts, this.source);
+}

Powered by Google App Engine
This is Rietveld 408576698