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

Unified Diff: pkg/fletchc/lib/src/fletch_compiler_implementation.dart

Issue 1450393002: Roll sdk dependency to 34357cdad108dcba734949bd13bd28c76ea285e0 (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Update status files Created 5 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
Index: pkg/fletchc/lib/src/fletch_compiler_implementation.dart
diff --git a/pkg/fletchc/lib/src/fletch_compiler_implementation.dart b/pkg/fletchc/lib/src/fletch_compiler_implementation.dart
index 8b905f2c0c9129f4326e739fa3b6a718a6d98782..3ec3210dec10f2317176e211ce659d6020fe6c1f 100644
--- a/pkg/fletchc/lib/src/fletch_compiler_implementation.dart
+++ b/pkg/fletchc/lib/src/fletch_compiler_implementation.dart
@@ -8,13 +8,15 @@ import 'dart:async' show
EventSink;
import 'package:sdk_library_metadata/libraries.dart' show
- libraries,
LibraryInfo;
import 'package:compiler/compiler_new.dart' as api;
import 'package:compiler/src/apiimpl.dart' as apiimpl;
+import 'package:compiler/src/compiler.dart' show
+ GlobalDependencyRegistry;
ahe 2015/12/01 10:12:13 Unused import.
sigurdm 2015/12/03 14:48:10 Done.
+
import 'package:compiler/src/io/source_file.dart';
import 'package:compiler/src/source_file_provider.dart' show
@@ -27,16 +29,18 @@ import 'package:compiler/src/elements/modelx.dart' show
import 'package:compiler/compiler_new.dart' show
CompilerOutput;
-import 'package:compiler/src/util/uri_extras.dart' show
- relativize;
-
-import 'package:compiler/src/dart2jslib.dart' show
- CodegenRegistry,
+import 'package:compiler/src/diagnostics/messages.dart' show
Message,
MessageKind,
MessageTemplate;
+import 'package:compiler/src/diagnostics/source_span.dart' show
ahe 2015/12/01 10:12:13 Add newline before import.
sigurdm 2015/12/03 14:48:10 Done.
+ SourceSpan;
+
+import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
+ DiagnosticMessage,
+ DiagnosticReporter;
-import 'package:compiler/src/util/util.dart' show
+import 'package:compiler/src/diagnostics/spannable.dart' show
Spannable;
import 'fletch_registry.dart' show
@@ -51,7 +55,12 @@ import 'debug_info.dart';
import 'find_position_visitor.dart';
import 'fletch_context.dart';
+import 'fletch_enqueuer.dart' show
+ FletchEnqueueTask;
+
import '../fletch_system.dart';
+import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
ahe 2015/12/01 10:12:13 Newlines between imports.
sigurdm 2015/12/03 14:48:10 Done.
+import 'package:compiler/src/elements/elements.dart';
const EXTRA_DART2JS_OPTIONS = const <String>[
// TODO(ahe): This doesn't completely disable type inference. Investigate.
@@ -112,7 +121,7 @@ const Map<String, LibraryInfo> FLETCH_LIBRARIES = const {
platforms: FLETCH_PLATFORM),
};
-class FletchCompilerImplementation extends apiimpl.Compiler {
+class FletchCompilerImplementation extends apiimpl.CompilerImpl {
final Map<String, LibraryInfo> fletchLibraries = <String, LibraryInfo>{};
final Uri fletchVm;
@@ -129,6 +138,11 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
// TODO(ahe): Clean this up and remove this.
var helper;
+ @override
ahe 2015/12/01 10:12:13 Please dont use @override.
sigurdm 2015/12/03 14:48:10 Done.
+ FletchEnqueueTask get enqueuer => super.enqueuer;
+
+ FletchDiagnosticReporter reporter;
+
FletchCompilerImplementation(
api.CompilerInput provider,
api.CompilerOutput outputProvider,
@@ -144,9 +158,7 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
provider, outputProvider, handler, libraryRoot, null,
EXTRA_DART2JS_OPTIONS.toList()..addAll(options), environment,
packageConfig, null, FletchBackend.newInstance) {
- CodegenRegistry global = globalDependencies;
- globalDependencies =
- new FletchRegistry(this, global.treeElements).asRegistry;
+ reporter = new FletchDiagnosticReporter(super.reporter);
}
bool get showPackageWarnings => true;
@@ -160,50 +172,17 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
String fletchPatchLibraryFor(String name) => FLETCH_PATCHES[name];
- LibraryInfo lookupLibraryInfo(String name) {
- return fletchLibraries.putIfAbsent(name, () {
- // Let FLETCH_LIBRARIES shadow libraries.
- if (FLETCH_LIBRARIES.containsKey(name)) {
- return computeFletchLibraryInfo(name);
- }
- LibraryInfo info = libraries[name];
- if (info == null) {
- return computeFletchLibraryInfo(name);
- }
- return new LibraryInfo(
- info.path,
- categories: info.categoriesString,
- dart2jsPath: info.dart2jsPath,
- dart2jsPatchPath: fletchPatchLibraryFor(name),
- implementation: info.implementation,
- documented: info.documented,
- maturity: info.maturity,
- platforms: info.platforms);
- });
- }
-
- LibraryInfo computeFletchLibraryInfo(String name) {
- LibraryInfo info = FLETCH_LIBRARIES[name];
- if (info == null) return null;
- // Since this LibraryInfo is completely internal to Fletch, there's no need
- // for dart2js extensions and patches.
- assert(info.dart2jsPath == null);
- assert(info.dart2jsPatchPath == null);
- String path = relativize(
- libraryRoot, patchRoot.resolve("lib/${info.path}"), false);
- return new LibraryInfo(
- '../$path',
- categories: info.categoriesString,
- implementation: info.implementation,
- documented: info.documented,
- maturity: info.maturity,
- platforms: info.platforms);
+ @override
ahe 2015/12/01 10:12:13 Ditto.
sigurdm 2015/12/03 14:48:10 Done.
+ Uri lookupLibraryUri(String libraryName) {
+ LibraryInfo info = FLETCH_LIBRARIES[libraryName];
+ if (info == null) return super.lookupLibraryUri(libraryName);
+ return patchRoot.resolve("lib/${info.path}");
}
Uri resolvePatchUri(String dartLibraryPath) {
- String patchPath = lookupPatchPath(dartLibraryPath);
+ String patchPath = fletchPatchLibraryFor(dartLibraryPath);
if (patchPath == null) return null;
- return patchRoot.resolve(patchPath);
+ return patchRoot.resolve("lib/$patchPath");
}
CompilationUnitElementX compilationUnitForUri(Uri uri) {
@@ -266,13 +245,15 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
void reportVerboseInfo(
ahe 2015/12/01 10:12:13 This should probably be moved to our reporter obje
sigurdm 2015/12/03 14:48:10 I'll wait for Johnni to move it in the dart2js fro
Spannable node,
- String message,
+ String messageText,
{bool forceVerbose: false}) {
// TODO(johnniwinther): Use super.reportVerboseInfo once added.
if (forceVerbose || verbose) {
MessageTemplate template = MessageTemplate.TEMPLATES[MessageKind.GENERIC];
- reportDiagnostic(
- node, template.message({'text': message}, true), api.Diagnostic.HINT);
+ SourceSpan span = reporter.spanFromSpannable(node);
+ Message message = template.message({'text': messageText});
+ reportDiagnostic(new DiagnosticMessage(span, node, message),
ahe 2015/12/01 10:12:13 Why is reportDiagnostic not called on reporter?
sigurdm 2015/12/03 14:48:10 There is not reportDiagnostic on reporter, but on
+ [], api.Diagnostic.HINT);
}
}
@@ -281,19 +262,6 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
crashReportRequested = true;
print(requestBugReportOnCompilerCrashMessage);
}
-
- void reportError(
- Spannable node,
- MessageKind messageKind,
- [Map arguments = const {}]) {
- if (messageKind == MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) {
- const String noMirrors =
- "Fletch doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O";
- messageKind = MessageKind.GENERIC;
- arguments = {'text': noMirrors};
- }
- super.reportError(node, messageKind, arguments);
- }
}
/// Output provider which collects output in [output].
@@ -341,3 +309,74 @@ SourceFile getSourceFile(api.CompilerInput provider, Uri uri) {
return null;
}
}
+
+/// A wrapper around a DiagnosticReporter, that customizes some messages to
+/// Fletch.
+class FletchDiagnosticReporter extends DiagnosticReporter {
ahe 2015/12/01 10:12:13 Move to own file.
ahe 2015/12/01 10:12:13 If you used implements, you wouldn't need all thos
sigurdm 2015/12/03 14:48:10 I don't understand the argument. I use extends to
sigurdm 2015/12/03 14:48:10 Done.
+ DiagnosticReporter _internalReporter;
ahe 2015/12/01 10:12:13 Please don't use library privacy when you're not i
sigurdm 2015/12/03 14:48:10 Done.
+
+ FletchDiagnosticReporter(this._internalReporter);
+
+ @override
+ DiagnosticMessage createMessage(Spannable spannable,
ahe 2015/12/01 10:12:13 Add newline after ( for consistency with code styl
sigurdm 2015/12/03 14:48:10 Done.
+ MessageKind messageKind,
+ [Map arguments = const {}]) {
+ return _internalReporter.createMessage(spannable, messageKind, arguments);
+ }
+
+ @override
+ internalError(Spannable spannable, message) {
+ return _internalReporter.internalError(spannable, message);
+ }
+
+ @override
+ void log(message) {
+ _internalReporter.log(message);
+ }
+
+ @override
+ DiagnosticOptions get options => _internalReporter.options;
+
+ @override
+ void reportError(DiagnosticMessage message,
+ [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
+ if (message.message.kind ==
+ MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) {
+ const String noMirrors =
+ "Fletch doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O";
+ message = createMessage(message.spannable,
+ MessageKind.GENERIC,
+ {'text': message});
+ }
+ _internalReporter.reportError(message, infos);
+ }
+
+ @override
+ void reportHint(DiagnosticMessage message,
+ [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
+ _internalReporter.reportHint(message, infos);
+ }
+
+ @override
+ void reportInfo(Spannable node,
+ MessageKind errorCode,
+ [Map arguments = const {}]) {
+ _internalReporter.reportInfo(node, errorCode, arguments);
+ }
+
+ @override
+ void reportWarning(DiagnosticMessage message,
+ [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
+ _internalReporter.reportWarning(message, infos);
+ }
+
+ @override
+ SourceSpan spanFromSpannable(Spannable node) {
+ return _internalReporter.spanFromSpannable(node);
+ }
+
+ @override
+ withCurrentElement(Element element, f()) {
+ return _internalReporter.withCurrentElement(element, f);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698