OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /// Implementation of the new compiler API in '../compiler_new.dart' through the |
| 6 /// old compiler API in '../compiler.dart'. |
| 7 |
| 8 library compiler.api.legacy; |
| 9 |
| 10 import 'dart:async' show EventSink, Future; |
| 11 import 'null_compiler_output.dart' show NullSink; |
| 12 import '../compiler.dart'; |
| 13 import '../compiler_new.dart'; |
| 14 |
| 15 /// Implementation of [CompilerInput] using a [CompilerInputProvider]. |
| 16 class LegacyCompilerInput implements CompilerInput { |
| 17 final CompilerInputProvider _inputProvider; |
| 18 |
| 19 LegacyCompilerInput(this._inputProvider); |
| 20 |
| 21 @override |
| 22 Future readFromUri(Uri uri) { |
| 23 return _inputProvider(uri); |
| 24 } |
| 25 } |
| 26 |
| 27 /// Implementation of [CompilerDiagnostics] using a [DiagnosticHandler]. |
| 28 class LegacyCompilerDiagnostics implements CompilerDiagnostics { |
| 29 final DiagnosticHandler _handler; |
| 30 |
| 31 LegacyCompilerDiagnostics(this._handler); |
| 32 |
| 33 @override |
| 34 void report(Uri uri, int begin, int end, |
| 35 String message, Diagnostic kind) { |
| 36 _handler(uri, begin, end, message, kind); |
| 37 } |
| 38 } |
| 39 |
| 40 /// Implementation of [CompilerOutput] using an optional |
| 41 /// [CompilerOutputProvider]. |
| 42 class LegacyCompilerOutput implements CompilerOutput { |
| 43 final CompilerOutputProvider _outputProvider; |
| 44 |
| 45 LegacyCompilerOutput([this._outputProvider]); |
| 46 |
| 47 @override |
| 48 EventSink<String> createEventSink(String name, String extension) { |
| 49 if (_outputProvider != null) return _outputProvider(name, extension); |
| 50 return NullSink.outputProvider(name, extension); |
| 51 } |
| 52 } |
OLD | NEW |