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

Side by Side Diff: tests/compiler/dart2js/memory_compiler.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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.test.memory_compiler; 5 library dart2js.test.memory_compiler;
6 6
7 import 'memory_source_file_helper.dart'; 7 import 'memory_source_file_helper.dart';
8 8
9 import 'package:compiler/src/dart2jslib.dart' 9 import 'package:compiler/src/dart2jslib.dart'
10 show NullSink; 10 show NullSink;
11 11
12 import 'package:compiler/compiler.dart' 12 import 'package:compiler/compiler.dart'
13 show Diagnostic, DiagnosticHandler, CompilerOutputProvider; 13 show Diagnostic, DiagnosticHandler, CompilerOutputProvider;
14 14
15 import 'dart:async'; 15 import 'dart:async';
16 16
17 import 'package:compiler/src/mirrors/source_mirrors.dart'; 17 import 'package:compiler/src/mirrors/source_mirrors.dart';
18 import 'package:compiler/src/mirrors/analyze.dart'; 18 import 'package:compiler/src/mirrors/analyze.dart';
19 19
20 import 'package:compiler/src/library_loader.dart' 20 import 'package:compiler/src/library_loader.dart'
21 show LoadedLibraries; 21 show LoadedLibraries;
22 22
23 export 'output_collector.dart';
24
23 class DiagnosticMessage { 25 class DiagnosticMessage {
24 final Uri uri; 26 final Uri uri;
25 final int begin; 27 final int begin;
26 final int end; 28 final int end;
27 final String message; 29 final String message;
28 final Diagnostic kind; 30 final Diagnostic kind;
29 31
30 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); 32 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind);
31 33
32 String toString() => '$uri:$begin:$end:$message:$kind'; 34 String toString() => '$uri:$begin:$end:$message:$kind';
(...skipping 22 matching lines...) Expand all
55 57
56 Iterable<DiagnosticMessage> get hints { 58 Iterable<DiagnosticMessage> get hints {
57 return filterMessagesByKind(Diagnostic.HINT); 59 return filterMessagesByKind(Diagnostic.HINT);
58 } 60 }
59 61
60 Iterable<DiagnosticMessage> get infos { 62 Iterable<DiagnosticMessage> get infos {
61 return filterMessagesByKind(Diagnostic.INFO); 63 return filterMessagesByKind(Diagnostic.INFO);
62 } 64 }
63 } 65 }
64 66
65 class BufferedEventSink implements EventSink<String> {
66 StringBuffer sb = new StringBuffer();
67 String text;
68
69 void add(String event) {
70 sb.write(event);
71 }
72
73 void addError(errorEvent, [StackTrace stackTrace]) {
74 // Do not support this.
75 }
76
77 void close() {
78 text = sb.toString();
79 sb = null;
80 }
81 }
82
83 class OutputCollector {
84 Map<String, Map<String, BufferedEventSink>> outputMap = {};
85
86 EventSink<String> call(String name, String extension) {
87 Map<String, BufferedEventSink> sinkMap =
88 outputMap.putIfAbsent(extension, () => {});
89 return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
90 }
91
92 String getOutput(String name, String extension) {
93 Map<String, BufferedEventSink> sinkMap = outputMap[extension];
94 if (sinkMap == null) return null;
95 BufferedEventSink sink = sinkMap[name];
96 return sink != null ? sink.text : null;
97 }
98 }
99
100 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler, 67 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler,
101 SourceFileProvider provider, 68 SourceFileProvider provider,
102 bool showDiagnostics) { 69 bool showDiagnostics) {
103 var handler = diagnosticHandler; 70 var handler = diagnosticHandler;
104 if (showDiagnostics) { 71 if (showDiagnostics) {
105 if (diagnosticHandler == null) { 72 if (diagnosticHandler == null) {
106 handler = new FormattingDiagnosticHandler(provider); 73 handler = new FormattingDiagnosticHandler(provider);
107 } else { 74 } else {
108 var formattingHandler = new FormattingDiagnosticHandler(provider); 75 var formattingHandler = new FormattingDiagnosticHandler(provider);
109 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { 76 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 201
235 class MemoryLoadedLibraries implements LoadedLibraries { 202 class MemoryLoadedLibraries implements LoadedLibraries {
236 final Map copiedLibraries; 203 final Map copiedLibraries;
237 204
238 MemoryLoadedLibraries(this.copiedLibraries); 205 MemoryLoadedLibraries(this.copiedLibraries);
239 206
240 @override 207 @override
241 bool containsLibrary(Uri uri) => copiedLibraries.containsKey(uri); 208 bool containsLibrary(Uri uri) => copiedLibraries.containsKey(uri);
242 209
243 @override 210 @override
244 void forEachImportChain(f) {} 211 void forEachImportChain(f, {callback}) {}
245 212
246 @override 213 @override
247 void forEachLibrary(f) {} 214 void forEachLibrary(f) {}
248 215
249 @override 216 @override
250 getLibrary(Uri uri) => copiedLibraries[uri]; 217 getLibrary(Uri uri) => copiedLibraries[uri];
251 218
252 @override 219 @override
253 Uri get rootUri => null; 220 Uri get rootUri => null;
254 } 221 }
(...skipping 11 matching lines...) Expand all
266 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); 233 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics);
267 234
268 List<Uri> libraries = <Uri>[]; 235 List<Uri> libraries = <Uri>[];
269 memorySourceFiles.forEach((String path, _) { 236 memorySourceFiles.forEach((String path, _) {
270 libraries.add(new Uri(scheme: 'memory', path: path)); 237 libraries.add(new Uri(scheme: 'memory', path: path));
271 }); 238 });
272 239
273 return analyze(libraries, libraryRoot, packageRoot, 240 return analyze(libraries, libraryRoot, packageRoot,
274 provider, handler, options); 241 provider, handler, options);
275 } 242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698