Index: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart |
index 3a43d7c656e416c4c2be20f8f56af905adf5f576..1072c0960fe4bc51ed42a0b09280071c08f6330b 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart |
@@ -75,6 +75,12 @@ import '../errors.dart' show |
reportCrash, |
resetCrashReporting; |
+import '../util/relativize.dart' show |
+ relativizeUri; |
+ |
+import '../compiler_context.dart' show |
+ CompilerContext; |
+ |
import 'kernel_builder.dart' show |
Builder, |
ClassBuilder, |
@@ -92,18 +98,29 @@ import 'kernel_builder.dart' show |
class KernelTarget extends TargetImplementation { |
final DillTarget dillTarget; |
+ |
+ /// Shared with [CompilerContext]. |
+ final Map<String, Source> uriToSource; |
+ |
SourceLoader<Library> loader; |
Program program; |
final List errors = []; |
- KernelTarget(DillTarget dillTarget, TranslateUri uriTranslator) |
+ KernelTarget(DillTarget dillTarget, TranslateUri uriTranslator, |
+ [Map<String, Source> uriToSource]) |
: dillTarget = dillTarget, |
+ uriToSource = uriToSource ?? CompilerContext.current.uriToSource, |
super(dillTarget.ticker, uriTranslator) { |
resetCrashReporting(); |
loader = new SourceLoader<Library>(this); |
} |
+ void addLineStarts(Uri uri, List<int> lineStarts) { |
+ String fileUri = relativizeUri(uri); |
+ uriToSource[fileUri] = new Source(lineStarts, fileUri); |
+ } |
+ |
void read(Uri uri) { |
loader.read(uri); |
} |
@@ -317,7 +334,9 @@ class KernelTarget extends TargetImplementation { |
program.mainMethod = builder.procedure; |
} |
} |
- setup_builtin_library.transformProgram(program); |
+ if (errors.isEmpty || dillTarget.isLoaded) { |
+ setup_builtin_library.transformProgram(program); |
+ } |
ticker.logMs("Linked program"); |
return program; |
} |