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

Side by Side Diff: pkg/compiler/lib/src/old_to_new_api.dart

Issue 2690063002: Refactor CompilerOutput (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Implementation of the new compiler API in '../compiler_new.dart' through the 5 /// Implementation of the new compiler API in '../compiler_new.dart' through the
6 /// old compiler API in '../compiler.dart'. 6 /// old compiler API in '../compiler.dart'.
7 7
8 library compiler.api.legacy; 8 library compiler.api.legacy;
9 9
10 import 'dart:async' show EventSink, Future; 10 import 'dart:async' show EventSink, Future;
(...skipping 22 matching lines...) Expand all
33 33
34 @override 34 @override
35 void report( 35 void report(
36 var code, Uri uri, int begin, int end, String message, Diagnostic kind) { 36 var code, Uri uri, int begin, int end, String message, Diagnostic kind) {
37 _handler(uri, begin, end, message, kind); 37 _handler(uri, begin, end, message, kind);
38 } 38 }
39 } 39 }
40 40
41 /// Implementation of [CompilerOutput] using an optional 41 /// Implementation of [CompilerOutput] using an optional
42 /// [CompilerOutputProvider]. 42 /// [CompilerOutputProvider].
43 // TODO(johnniwinther): Change Pub to use the new interface and remove this.
43 class LegacyCompilerOutput implements CompilerOutput { 44 class LegacyCompilerOutput implements CompilerOutput {
44 final CompilerOutputProvider _outputProvider; 45 final CompilerOutputProvider _outputProvider;
45 46
46 LegacyCompilerOutput([this._outputProvider]); 47 LegacyCompilerOutput([this._outputProvider]);
47 48
48 @override 49 @override
49 EventSink<String> createEventSink(String name, String extension) { 50 OutputSink createOutputSink(String name, String extension, OutputType type) {
50 if (_outputProvider != null) return _outputProvider(name, extension); 51 if (_outputProvider != null) {
51 return NullSink.outputProvider(name, extension); 52 switch (type) {
53 case OutputType.info:
54 if (extension == '') {
55 // Needed to make Pub generate the same output name.
56 extension = 'deferred_map';
57 }
58 break;
59 default:
60 }
61 return new LegacyOutputSink(_outputProvider(name, extension));
62 }
63 return NullSink.outputProvider(name, extension, type);
52 } 64 }
53 } 65 }
66
67 class LegacyOutputSink implements OutputSink {
68 final EventSink<String> sink;
69
70 LegacyOutputSink(this.sink);
71
72 @override
73 void add(String event) => sink.add(event);
74
75 @override
76 void close() => sink.close();
77 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/null_compiler_output.dart ('k') | pkg/compiler/lib/src/serialization/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698