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

Side by Side Diff: pkg/dart2js_incremental/lib/compiler.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 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future, 9 Future,
10 Stream, 10 Stream,
11 StreamController, 11 StreamController,
12 StreamSubscription; 12 StreamSubscription;
13 13
14 import 'package:dart2js_incremental/dart2js_incremental.dart' show 14 import 'package:dart2js_incremental/dart2js_incremental.dart' show
15 IncrementalCompilationFailed, 15 IncrementalCompilationFailed,
16 IncrementalCompiler; 16 IncrementalCompiler;
17 17
18 import 'package:compiler/compiler_new.dart' show
19 CompilerOutput;
20
21 import 'package:compiler/src/old_to_new_api.dart' show
22 LegacyCompilerDiagnostics,
23 LegacyCompilerInput;
24
18 import 'package:compiler/src/source_file_provider.dart' show 25 import 'package:compiler/src/source_file_provider.dart' show
19 FormattingDiagnosticHandler; 26 FormattingDiagnosticHandler;
20 27
21 import 'watcher.dart'; 28 import 'watcher.dart';
22 29
23 main(List<String> arguments) { 30 main(List<String> arguments) {
24 int updateCount = 0; 31 int updateCount = 0;
25 StreamSubscription<CompilerEvent> subscription = 32 StreamSubscription<CompilerEvent> subscription =
26 compile(Uri.base.resolve(arguments.first)).listen(null); 33 compile(Uri.base.resolve(arguments.first)).listen(null);
27 subscription.onData((CompilerEvent event) { 34 subscription.onData((CompilerEvent event) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 104 }
98 } 105 }
99 return diagnosticHandler.provider(uri); 106 return diagnosticHandler.provider(uri);
100 } 107 }
101 108
102 while (true) { 109 while (true) {
103 Stopwatch sw = new Stopwatch()..start(); 110 Stopwatch sw = new Stopwatch()..start();
104 IncrementalCompiler compiler = new IncrementalCompiler( 111 IncrementalCompiler compiler = new IncrementalCompiler(
105 libraryRoot: libraryRoot, 112 libraryRoot: libraryRoot,
106 packageRoot: packageRoot, 113 packageRoot: packageRoot,
107 inputProvider: inputProvider, 114 inputProvider: new LegacyCompilerInput(inputProvider),
108 diagnosticHandler: resilientDiagnosticHandler, 115 diagnosticHandler:
116 new LegacyCompilerDiagnostics(resilientDiagnosticHandler),
109 outputProvider: outputProvider); 117 outputProvider: outputProvider);
110 118
111 bool success = await compiler.compile(originalInput); 119 bool success = await compiler.compile(originalInput);
112 sw.stop(); 120 sw.stop();
113 if (success) { 121 if (success) {
114 controller.add( 122 controller.add(
115 new CompilerEvent( 123 new CompilerEvent(
116 IncrementalKind.FULL, compiler, outputProvider.output, sw)); 124 IncrementalKind.FULL, compiler, outputProvider.output, sw));
117 } else { 125 } else {
118 controller.add( 126 controller.add(
(...skipping 16 matching lines...) Expand all
135 143
136 } on IncrementalCompilationFailed catch (error, trace) { 144 } on IncrementalCompilationFailed catch (error, trace) {
137 controller.addError(error, trace); 145 controller.addError(error, trace);
138 break; 146 break;
139 } 147 }
140 } 148 }
141 } 149 }
142 } 150 }
143 151
144 /// Output provider which collects output in [output]. 152 /// Output provider which collects output in [output].
145 class OutputProvider { 153 class OutputProvider implements CompilerOutput {
146 final Map<String, String> output = new Map<String, String>(); 154 final Map<String, String> output = new Map<String, String>();
147 155
148 EventSink<String> call(String name, String extension) { 156 EventSink<String> createSink(String name, String extension) {
149 return new StringEventSink((String data) { 157 return new StringEventSink((String data) {
150 output['$name.$extension'] = data; 158 output['$name.$extension'] = data;
151 }); 159 });
152 } 160 }
153 161
154 String operator[](String key) => output[key]; 162 String operator[](String key) => output[key];
155 } 163 }
156 164
157 /// Helper class to collect sources. 165 /// Helper class to collect sources.
158 class StringEventSink implements EventSink<String> { 166 class StringEventSink implements EventSink<String> {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 202
195 final Stopwatch stopwatch; 203 final Stopwatch stopwatch;
196 204
197 final String updates; 205 final String updates;
198 206
199 CompilerEvent( 207 CompilerEvent(
200 this.kind, this.compiler, this._output, this.stopwatch, {this.updates}); 208 this.kind, this.compiler, this._output, this.stopwatch, {this.updates});
201 209
202 String operator[](String key) => _output[key]; 210 String operator[](String key) => _output[key];
203 } 211 }
OLDNEW
« no previous file with comments | « pkg/dart2js_incremental/lib/caching_compiler.dart ('k') | pkg/dart2js_incremental/lib/dart2js_incremental.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698