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

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

Issue 21242002: Retain elements a finer granularity than library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Variable initialized too early. Created 7 years, 4 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 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'memory_source_file_helper.dart'; 8 import 'memory_source_file_helper.dart';
9 9
10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
11 show NullSink; 11 show NullSink;
12 12
13 import '../../../sdk/lib/_internal/compiler/compiler.dart' 13 import '../../../sdk/lib/_internal/compiler/compiler.dart'
14 show DiagnosticHandler; 14 show DiagnosticHandler;
15 15
16 import 'dart:async'; 16 import 'dart:async';
17 17
18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ; 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ;
19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart'; 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart';
20 20
21 Compiler compilerFor(Map<String,String> memorySourceFiles, 21 Compiler compilerFor(Map<String,String> memorySourceFiles,
22 {DiagnosticHandler diagnosticHandler, 22 {DiagnosticHandler diagnosticHandler,
23 List<String> options: const []}) { 23 List<String> options: const [],
24 Compiler cachedCompiler}) {
24 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); 25 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
25 Uri libraryRoot = script.resolve('../../../sdk/'); 26 Uri libraryRoot = script.resolve('../../../sdk/');
26 Uri packageRoot = script.resolve('./packages/'); 27 Uri packageRoot = script.resolve('./packages/');
27 28
28 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; 29 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles;
29 var provider = new MemorySourceFileProvider(); 30 var provider = new MemorySourceFileProvider();
30 if (diagnosticHandler == null) { 31 if (diagnosticHandler == null) {
31 diagnosticHandler = new FormattingDiagnosticHandler(provider); 32 diagnosticHandler = new FormattingDiagnosticHandler(provider);
32 } 33 }
33 34
34 EventSink<String> outputProvider(String name, String extension) { 35 EventSink<String> outputProvider(String name, String extension) {
35 if (name != '') throw 'Attempt to output file "$name.$extension"'; 36 if (name != '') throw 'Attempt to output file "$name.$extension"';
36 return new NullSink('$name.$extension'); 37 return new NullSink('$name.$extension');
37 } 38 }
38 39
39 Compiler compiler = new Compiler(provider.readStringFromUri, 40 Compiler compiler = new Compiler(provider.readStringFromUri,
40 outputProvider, 41 outputProvider,
41 diagnosticHandler, 42 diagnosticHandler,
42 libraryRoot, 43 libraryRoot,
43 packageRoot, 44 packageRoot,
44 options); 45 options);
46 if (cachedCompiler != null) {
47 compiler.coreLibrary = cachedCompiler.libraries['dart:core'];
48 compiler.types = cachedCompiler.types;
49 cachedCompiler.libraries.forEach((String uri, library) {
50 if (library.isPlatformLibrary) {
51 compiler.libraries[uri] = library;
52 compiler.onLibraryScanned(library, library.canonicalUri);
53 }
54 });
55
56 compiler.symbolConstructor = cachedCompiler.symbolConstructor;
57 compiler.mirrorSystemClass = cachedCompiler.mirrorSystemClass;
58 compiler.mirrorsUsedClass = cachedCompiler.mirrorsUsedClass;
59 compiler.mirrorSystemGetNameFunction =
60 cachedCompiler.mirrorSystemGetNameFunction;
61 compiler.symbolImplementationClass =
62 cachedCompiler.symbolImplementationClass;
63 compiler.symbolValidatedConstructor =
64 cachedCompiler.symbolValidatedConstructor;
65 compiler.mirrorsUsedConstructor = cachedCompiler.mirrorsUsedConstructor;
66 compiler.deferredLibraryClass = cachedCompiler.deferredLibraryClass;
67
68 Map cachedTreeElements =
69 cachedCompiler.enqueuer.resolution.resolvedElements;
70 cachedTreeElements.forEach((element, treeElements) {
71 if (element.getLibrary().isPlatformLibrary) {
72 compiler.enqueuer.resolution.resolvedElements[element] =
73 treeElements;
74 }
75 });
76 }
45 return compiler; 77 return compiler;
46 } 78 }
47 79
48 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, 80 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles,
49 {DiagnosticHandler diagnosticHandler, 81 {DiagnosticHandler diagnosticHandler,
50 List<String> options: const []}) { 82 List<String> options: const []}) {
51 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); 83 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
52 Uri libraryRoot = script.resolve('../../../sdk/'); 84 Uri libraryRoot = script.resolve('../../../sdk/');
53 Uri packageRoot = script.resolve('./packages/'); 85 Uri packageRoot = script.resolve('./packages/');
54 86
55 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles; 87 MemorySourceFileProvider.MEMORY_SOURCE_FILES = memorySourceFiles;
56 var provider = new MemorySourceFileProvider(); 88 var provider = new MemorySourceFileProvider();
57 if (diagnosticHandler == null) { 89 if (diagnosticHandler == null) {
58 diagnosticHandler = new FormattingDiagnosticHandler(provider); 90 diagnosticHandler = new FormattingDiagnosticHandler(provider);
59 } 91 }
60 92
61 List<Uri> libraries = <Uri>[]; 93 List<Uri> libraries = <Uri>[];
62 memorySourceFiles.forEach((String path, _) { 94 memorySourceFiles.forEach((String path, _) {
63 libraries.add(new Uri(scheme: 'memory', path: path)); 95 libraries.add(new Uri(scheme: 'memory', path: path));
64 }); 96 });
65 97
66 return analyze(libraries, libraryRoot, packageRoot, 98 return analyze(libraries, libraryRoot, packageRoot,
67 provider, diagnosticHandler, options); 99 provider, diagnosticHandler, options);
68 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698