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

Unified Diff: pkg/compiler/lib/src/old_to_new_api.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 months 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 | « pkg/compiler/lib/src/null_compiler_output.dart ('k') | pkg/compiler/lib/src/source_file_provider.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/old_to_new_api.dart
diff --git a/pkg/compiler/lib/src/old_to_new_api.dart b/pkg/compiler/lib/src/old_to_new_api.dart
new file mode 100644
index 0000000000000000000000000000000000000000..34d6e79d019f293ccff6104a5b5b33abc3dd9ae5
--- /dev/null
+++ b/pkg/compiler/lib/src/old_to_new_api.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Implementation of the new compiler API in '../compiler_new.dart' through the
+/// old compiler API in '../compiler.dart'.
+
+library compiler.api.legacy;
+
+import 'dart:async' show EventSink, Future;
+import 'null_compiler_output.dart' show NullSink;
+import '../compiler.dart';
+import '../compiler_new.dart';
+
+/// Implementation of [CompilerInput] using a [CompilerInputProvider].
+class LegacyCompilerInput implements CompilerInput {
+ final CompilerInputProvider _inputProvider;
+
+ LegacyCompilerInput(this._inputProvider);
+
+ @override
+ Future readFromUri(Uri uri) {
+ return _inputProvider(uri);
+ }
+}
+
+/// Implementation of [CompilerDiagnostics] using a [DiagnosticHandler].
+class LegacyCompilerDiagnostics implements CompilerDiagnostics {
+ final DiagnosticHandler _handler;
+
+ LegacyCompilerDiagnostics(this._handler);
+
+ @override
+ void report(Uri uri, int begin, int end,
+ String message, Diagnostic kind) {
+ _handler(uri, begin, end, message, kind);
+ }
+}
+
+/// Implementation of [CompilerOutput] using an optional
+/// [CompilerOutputProvider].
+class LegacyCompilerOutput implements CompilerOutput {
+ final CompilerOutputProvider _outputProvider;
+
+ LegacyCompilerOutput([this._outputProvider]);
+
+ @override
+ EventSink<String> createEventSink(String name, String extension) {
+ if (_outputProvider != null) return _outputProvider(name, extension);
+ return NullSink.outputProvider(name, extension);
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/null_compiler_output.dart ('k') | pkg/compiler/lib/src/source_file_provider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698