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

Side by Side Diff: tests/compiler/dart2js/output_collector.dart

Issue 832363002: Remove Compiler.assembledCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
(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 // Output provider that collects the output in string buffers.
6
7 library output_collector;
8
9 import 'dart:async';
10
11 class BufferedEventSink implements EventSink<String> {
12 StringBuffer sb = new StringBuffer();
13 String text;
14
15 void add(String event) {
16 sb.write(event);
17 }
18
19 void addError(errorEvent, [StackTrace stackTrace]) {
20 // Do not support this.
21 }
22
23 void close() {
24 text = sb.toString();
25 sb = null;
26 }
27 }
28
29 class OutputCollector {
30 Map<String, Map<String, BufferedEventSink>> outputMap = {};
31
32 EventSink<String> call(String name, String extension) {
33 Map<String, BufferedEventSink> sinkMap =
34 outputMap.putIfAbsent(extension, () => {});
35 return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
36 }
37
38 String getOutput(String name, String extension) {
39 Map<String, BufferedEventSink> sinkMap = outputMap[extension];
40 if (sinkMap == null) return null;
41 BufferedEventSink sink = sinkMap[name];
42 return sink != null ? sink.text : null;
43 }
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698