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

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

Issue 824103005: Revert "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
25 class DiagnosticMessage { 23 class DiagnosticMessage {
26 final Uri uri; 24 final Uri uri;
27 final int begin; 25 final int begin;
28 final int end; 26 final int end;
29 final String message; 27 final String message;
30 final Diagnostic kind; 28 final Diagnostic kind;
31 29
32 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); 30 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind);
33 31
34 String toString() => '$uri:$begin:$end:$message:$kind'; 32 String toString() => '$uri:$begin:$end:$message:$kind';
(...skipping 22 matching lines...) Expand all
57 55
58 Iterable<DiagnosticMessage> get hints { 56 Iterable<DiagnosticMessage> get hints {
59 return filterMessagesByKind(Diagnostic.HINT); 57 return filterMessagesByKind(Diagnostic.HINT);
60 } 58 }
61 59
62 Iterable<DiagnosticMessage> get infos { 60 Iterable<DiagnosticMessage> get infos {
63 return filterMessagesByKind(Diagnostic.INFO); 61 return filterMessagesByKind(Diagnostic.INFO);
64 } 62 }
65 } 63 }
66 64
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
67 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler, 100 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler,
68 SourceFileProvider provider, 101 SourceFileProvider provider,
69 bool showDiagnostics) { 102 bool showDiagnostics) {
70 var handler = diagnosticHandler; 103 var handler = diagnosticHandler;
71 if (showDiagnostics) { 104 if (showDiagnostics) {
72 if (diagnosticHandler == null) { 105 if (diagnosticHandler == null) {
73 handler = new FormattingDiagnosticHandler(provider); 106 handler = new FormattingDiagnosticHandler(provider);
74 } else { 107 } else {
75 var formattingHandler = new FormattingDiagnosticHandler(provider); 108 var formattingHandler = new FormattingDiagnosticHandler(provider);
76 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { 109 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 234
202 class MemoryLoadedLibraries implements LoadedLibraries { 235 class MemoryLoadedLibraries implements LoadedLibraries {
203 final Map copiedLibraries; 236 final Map copiedLibraries;
204 237
205 MemoryLoadedLibraries(this.copiedLibraries); 238 MemoryLoadedLibraries(this.copiedLibraries);
206 239
207 @override 240 @override
208 bool containsLibrary(Uri uri) => copiedLibraries.containsKey(uri); 241 bool containsLibrary(Uri uri) => copiedLibraries.containsKey(uri);
209 242
210 @override 243 @override
211 void forEachImportChain(f, {callback}) {} 244 void forEachImportChain(f) {}
212 245
213 @override 246 @override
214 void forEachLibrary(f) {} 247 void forEachLibrary(f) {}
215 248
216 @override 249 @override
217 getLibrary(Uri uri) => copiedLibraries[uri]; 250 getLibrary(Uri uri) => copiedLibraries[uri];
218 251
219 @override 252 @override
220 Uri get rootUri => null; 253 Uri get rootUri => null;
221 } 254 }
(...skipping 11 matching lines...) Expand all
233 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); 266 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics);
234 267
235 List<Uri> libraries = <Uri>[]; 268 List<Uri> libraries = <Uri>[];
236 memorySourceFiles.forEach((String path, _) { 269 memorySourceFiles.forEach((String path, _) {
237 libraries.add(new Uri(scheme: 'memory', path: path)); 270 libraries.add(new Uri(scheme: 'memory', path: path));
238 }); 271 });
239 272
240 return analyze(libraries, libraryRoot, packageRoot, 273 return analyze(libraries, libraryRoot, packageRoot,
241 provider, handler, options); 274 provider, handler, options);
242 } 275 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/js_backend_cps_ir_test.dart ('k') | tests/compiler/dart2js/mirror_helper_rename_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698