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

Unified Diff: lib/kernel.dart

Issue 2464053002: Generate fileUris. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | lib/src/rastask.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/kernel.dart
diff --git a/lib/kernel.dart b/lib/kernel.dart
index cdbbeb98f177f62d8218204df092ac013270471b..a79ff230174ba50a30d965c5ac94d31c038d1260 100644
--- a/lib/kernel.dart
+++ b/lib/kernel.dart
@@ -94,6 +94,9 @@ class Kernel {
/// nodes are correct.
final Queue<WorkItem> workQueue = new Queue<WorkItem>();
+ // TODO(ahe): this should be pruned when unloading libraries.
+ final Map<String, List<int>> lineStarts = <String, List<int>>{};
+
Kernel(this.compiler);
bool hasMainMethod(Uri uri) {
@@ -153,6 +156,16 @@ class Kernel {
return libraryToIr(await compiler.libraryLoader.loadLibrary(uri));
}
+ String fileUri(Element element) {
+ String fileUri = "${element.compilationUnit.script.resourceUri}";
+ lineStarts[fileUri] = <int>[0];
+ return fileUri;
+ }
+
+ void addLineStartsTo(ir.Program program) {
+ program.uriToLineStarts.addAll(lineStarts);
+ }
+
ir.Library libraryToIr(LibraryElement library) {
library = library.declaration;
return libraries.putIfAbsent(library, () {
@@ -160,6 +173,7 @@ class Kernel {
ir.Library libraryNode = new ir.Library(
library.canonicalUri, name: name, classes: null, procedures: null,
fields: null);
+ libraryNode.fileUri = fileUri(library);
addWork(library, () {
Queue<ir.Class> classes = new Queue<ir.Class>();
Queue<ir.Member> members = new Queue<ir.Member>();
@@ -208,7 +222,7 @@ class Kernel {
ir.Class classNode = new ir.Class(
name: name, isAbstract: cls.isAbstract,
typeParameters: null, implementedTypes: null, constructors: null,
- procedures: null, fields: null);
+ procedures: null, fields: null, fileUri: fileUri(cls));
addWork(cls, () {
if (cls.supertype != null) {
classNode.supertype = interfaceTypeToIr(cls.supertype);
@@ -376,6 +390,7 @@ class Kernel {
isStatic: function.isStatic || function.isTopLevel
|| function.isFactoryConstructor,
isExternal: isNative || function.isExternal,
+ fileUri: fileUri(function),
isConst: false); // TODO(ahe): When is this true?
}
addWork(function, () {
@@ -456,7 +471,7 @@ class Kernel {
ir.Field fieldNode = new ir.Field(
irName(field.memberName.text, field), type: type, initializer: null,
isFinal: field.isFinal, isStatic: field.isStatic || field.isTopLevel,
- isConst: field.isConst);
+ isConst: field.isConst, fileUri: fileUri(field));
addWork(field, () {
setParent(fieldNode, field);
if (!field.isMalformed && !field.isInstanceMember &&
« no previous file with comments | « no previous file | lib/src/rastask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698