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

Side by Side Diff: lib/compiler/implementation/apiimpl.dart

Issue 10894005: Remove library_map.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove dart:mirror from dart2js and dartdoc. Created 8 years, 3 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
« no previous file with comments | « lib/_internal/libraries.dart ('k') | lib/compiler/implementation/library_map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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('leg_apiimpl'); 5 #library('leg_apiimpl');
6 6
7 #import('dart:uri'); 7 #import('dart:uri');
8 8
9 #import('../compiler.dart', prefix: 'api'); 9 #import('../compiler.dart', prefix: 'api');
10 #import('leg.dart', prefix: 'leg'); 10 #import('leg.dart', prefix: 'leg');
11 #import('tree/tree.dart', prefix: 'tree'); 11 #import('tree/tree.dart', prefix: 'tree');
12 #import('elements/elements.dart', prefix: 'elements'); 12 #import('elements/elements.dart', prefix: 'elements');
13 #import('ssa/tracer.dart', prefix: 'ssa'); 13 #import('ssa/tracer.dart', prefix: 'ssa');
14 #import('library_map.dart'); 14 #import('../../../lib/_internal/libraries.dart');
15 #import('source_file.dart'); 15 #import('source_file.dart');
16 16
17 class Compiler extends leg.Compiler { 17 class Compiler extends leg.Compiler {
18 api.ReadStringFromUri provider; 18 api.ReadStringFromUri provider;
19 api.DiagnosticHandler handler; 19 api.DiagnosticHandler handler;
20 final Uri libraryRoot; 20 final Uri libraryRoot;
21 final Uri packageRoot; 21 final Uri packageRoot;
22 List<String> options; 22 List<String> options;
23 bool mockableLibraryUsed = false; 23 bool mockableLibraryUsed = false;
24 24
25 Compiler(this.provider, this.handler, this.libraryRoot, this.packageRoot, 25 Compiler(this.provider, this.handler, this.libraryRoot, this.packageRoot,
26 List<String> options) 26 List<String> options)
27 : this.options = options, 27 : this.options = options,
28 super( 28 super(
29 tracer: new ssa.HTracer(), 29 tracer: new ssa.HTracer(),
30 enableTypeAssertions: options.indexOf('--enable-checked-mode') != -1, 30 enableTypeAssertions: _hasOption(options, '--enable-checked-mode'),
31 enableUserAssertions: options.indexOf('--enable-checked-mode') != -1, 31 enableUserAssertions: _hasOption(options, '--enable-checked-mode'),
32 emitJavascript: options.indexOf('--output-type=dart') == -1, 32 emitJavascript: !_hasOption(options, '--output-type=dart'),
33 minify: options.indexOf('--minify') != -1, 33 minify: _hasOption(options, '--minify'),
34 cutDeclarationTypes: options.indexOf('--cutDeclarationTypes') != -1); 34 cutDeclarationTypes: _hasOption(options, '--cutDeclarationTypes'));
35
36 static bool _hasOption(List<String> options, String option) {
ahe 2012/08/29 12:30:21 Why is this method private?
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Because it can't be unnamed, and I can't make it v
37 return options.indexOf(option) >= 0;
38 }
39
40 String lookupDartLibraryPath(String dartLibraryName) {
41 LibraryInfo info = LIBRARIES[dartLibraryName];
42 if (info == null) return null;
ahe 2012/08/29 12:30:21 Please use === as long as the new == semantics are
Lasse Reichstein Nielsen 2012/08/29 12:43:53 The semantics change will not make any difference
43 if (!info.isDart2jsLibrary) return null;
44 String path = info.dart2jsPath;
45 if (path == null) path = info.path;
ahe 2012/08/29 12:30:21 ===
ahe 2012/08/29 12:30:21 This looks like a bail out, but it is not a return
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Done.
46 return "lib/$path";
47 }
48
49 String lookupDartPatchPath(String dartLibraryName) {
ahe 2012/08/29 12:30:21 Remove "dart" from method name. This brings focus
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Done.
50 LibraryInfo info = LIBRARIES[dartLibraryName];
51 if (info == null) return null;
52 if (!info.isDart2jsLibrary) return null;
53 String path = info.dart2jsPatchPath;
54 if (path == null) return null;
55 return "lib/$path";
56 }
35 57
36 elements.LibraryElement scanBuiltinLibrary(String path) { 58 elements.LibraryElement scanBuiltinLibrary(String path) {
37 Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path].libraryPath); 59 Uri uri = libraryRoot.resolve(lookupDartLibraryPath(path));
38 Uri canonicalUri; 60 Uri canonicalUri;
39 if (path.startsWith("_")) { 61 if (path.startsWith("_")) {
40 canonicalUri = uri; 62 canonicalUri = uri;
41 } else { 63 } else {
42 canonicalUri = new Uri.fromComponents(scheme: "dart", path: path); 64 canonicalUri = new Uri.fromComponents(scheme: "dart", path: path);
43 } 65 }
44 elements.LibraryElement library = 66 elements.LibraryElement library =
45 scanner.loadLibrary(uri, null, canonicalUri); 67 scanner.loadLibrary(uri, null, canonicalUri);
46 return library; 68 return library;
47 } 69 }
(...skipping 23 matching lines...) Expand all
71 } 93 }
72 94
73 Uri translateUri(Uri uri, tree.Node node) { 95 Uri translateUri(Uri uri, tree.Node node) {
74 switch (uri.scheme) { 96 switch (uri.scheme) {
75 case 'package': return translatePackageUri(uri, node); 97 case 'package': return translatePackageUri(uri, node);
76 default: return uri; 98 default: return uri;
77 } 99 }
78 } 100 }
79 101
80 Uri translateDartUri(Uri uri, tree.Node node) { 102 Uri translateDartUri(Uri uri, tree.Node node) {
81 String path = DART2JS_LIBRARY_MAP[uri.path].libraryPath; 103 String path = lookupDartLibraryPath(uri.path);
82 if (path === null || uri.path.startsWith('_')) { 104 if (path === null || LIBRARIES[uri.path].category == "Internal") {
83 reportError(node, 'library not found ${uri}'); 105 reportError(node, 'library not found ${uri}');
84 return null; 106 return null;
85 } 107 }
86 if (uri.path == 'dom_deprecated' 108 if (uri.path == 'dom_deprecated' ||
87 || uri.path == 'html' || uri.path == 'io') { 109 uri.path == 'html' ||
110 uri.path == 'io') {
88 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart 111 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart
89 // supports this use case better. 112 // supports this use case better.
90 mockableLibraryUsed = true; 113 mockableLibraryUsed = true;
91 } 114 }
92 return libraryRoot.resolve(path); 115 return libraryRoot.resolve(path);
93 } 116 }
94 117
95 Uri resolvePatchUri(String dartLibraryPath) { 118 Uri resolvePatchUri(String dartLibraryPath) {
96 String patchPath = DART2JS_LIBRARY_MAP[dartLibraryPath].patchPath; 119 String patchPath = lookupDartPatchPath(dartLibraryPath);
97 if (patchPath === null) return null; 120 if (patchPath === null) return null;
98 return libraryRoot.resolve(patchPath); 121 return libraryRoot.resolve(patchPath);
99 } 122 }
100 123
101 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path); 124 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path);
102 125
103 bool run(Uri uri) { 126 bool run(Uri uri) {
104 bool success = super.run(uri); 127 bool success = super.run(uri);
105 for (final task in tasks) { 128 for (final task in tasks) {
106 log('${task.name} took ${task.timing}msec'); 129 log('${task.name} took ${task.timing}msec');
(...skipping 14 matching lines...) Expand all
121 handler(translateUri(span.uri, null), span.begin, span.end, 144 handler(translateUri(span.uri, null), span.begin, span.end,
122 message, kind); 145 message, kind);
123 } 146 }
124 } 147 }
125 148
126 bool get isMockCompilation { 149 bool get isMockCompilation {
127 return mockableLibraryUsed 150 return mockableLibraryUsed
128 && (options.indexOf('--allow-mock-compilation') !== -1); 151 && (options.indexOf('--allow-mock-compilation') !== -1);
129 } 152 }
130 } 153 }
OLDNEW
« no previous file with comments | « lib/_internal/libraries.dart ('k') | lib/compiler/implementation/library_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698