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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart

Issue 14198010: Revert "Remove dartdoc specific methods from dart2js_mirror." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « no previous file | sdk/lib/_internal/dartdoc/lib/dartdoc.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 mirrors_dart2js; 5 library mirrors_dart2js;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection' show LinkedHashMap; 8 import 'dart:collection' show LinkedHashMap;
9 import 'dart:io' show Path;
9 import 'dart:uri'; 10 import 'dart:uri';
10 11
11 import '../../compiler.dart' as api; 12 import '../../compiler.dart' as api;
12 import '../elements/elements.dart'; 13 import '../elements/elements.dart';
14 import '../resolution/resolution.dart' show ResolverTask, ResolverVisitor;
13 import '../apiimpl.dart' as apiimpl; 15 import '../apiimpl.dart' as apiimpl;
14 import '../scanner/scannerlib.dart' hide SourceString; 16 import '../scanner/scannerlib.dart' hide SourceString;
17 import '../ssa/ssa.dart';
15 import '../dart2jslib.dart'; 18 import '../dart2jslib.dart';
16 import '../dart_types.dart'; 19 import '../dart_types.dart';
20 import '../filenames.dart';
17 import '../source_file.dart'; 21 import '../source_file.dart';
18 import '../tree/tree.dart'; 22 import '../tree/tree.dart';
19 import '../util/util.dart' show Spannable, Link; 23 import '../util/util.dart';
20 import '../util/characters.dart' show $CR, $LF; 24 import '../util/uri_extras.dart';
25 import '../dart2js.dart';
26 import '../util/characters.dart';
27 import '../source_file_provider.dart';
21 28
22 import 'mirrors.dart'; 29 import 'mirrors.dart';
23 import 'mirrors_util.dart'; 30 import 'mirrors_util.dart';
24 import 'util.dart'; 31 import 'util.dart';
25 32
26 //------------------------------------------------------------------------------ 33 //------------------------------------------------------------------------------
27 // Utility types and functions for the dart2js mirror system 34 // Utility types and functions for the dart2js mirror system
28 //------------------------------------------------------------------------------ 35 //------------------------------------------------------------------------------
29 36
30 bool _isPrivate(String name) { 37 bool _isPrivate(String name) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 'or': '|', 185 'or': '|',
179 }; 186 };
180 String newName = mapping[name]; 187 String newName = mapping[name];
181 if (newName == null) { 188 if (newName == null) {
182 throw new Exception('Unhandled operator name: $name'); 189 throw new Exception('Unhandled operator name: $name');
183 } 190 }
184 return newName; 191 return newName;
185 } 192 }
186 193
187 //------------------------------------------------------------------------------ 194 //------------------------------------------------------------------------------
188 // Analysis entry point. 195 // Compilation implementation
189 //------------------------------------------------------------------------------ 196 //------------------------------------------------------------------------------
190 197
198 // TODO(johnniwinther): Support client configurable providers.
199
200 /**
201 * Returns a future that completes to a non-null String when [script]
202 * has been successfully compiled.
203 *
204 * TODO(johnniwinther): The method is deprecated but here to support [Path]
205 * which is used through dartdoc.
206 */
207 Future<String> compile(Path script,
208 Path libraryRoot,
209 {Path packageRoot,
210 List<String> options: const <String>[],
211 api.DiagnosticHandler diagnosticHandler}) {
212 SourceFileProvider provider = new SourceFileProvider();
213 if (diagnosticHandler == null) {
214 diagnosticHandler =
215 new FormattingDiagnosticHandler(provider).diagnosticHandler;
216 }
217 Uri scriptUri = currentDirectory.resolve(script.toString());
218 Uri libraryUri = currentDirectory.resolve(appendSlash('$libraryRoot'));
219 Uri packageUri = null;
220 if (packageRoot != null) {
221 packageUri = currentDirectory.resolve(appendSlash('$packageRoot'));
222 }
223 return api.compile(scriptUri, libraryUri, packageUri,
224 provider.readStringFromUri, diagnosticHandler, options);
225 }
226
191 /** 227 /**
192 * Analyzes set of libraries and provides a mirror system which can be used for 228 * Analyzes set of libraries and provides a mirror system which can be used for
193 * static inspection of the source code. 229 * static inspection of the source code.
194 */ 230 */
195 // TODO(johnniwinther): Move this to [compiler/compiler.dart]. 231 // TODO(johnniwinther): Move this to [compiler/compiler.dart] and rename to
196 Future<MirrorSystem> analyze(List<Uri> libraries, 232 // [:analyze:].
197 Uri libraryRoot, 233 Future<MirrorSystem> analyzeUri(List<Uri> libraries,
198 Uri packageRoot, 234 Uri libraryRoot,
199 api.CompilerInputProvider inputProvider, 235 Uri packageRoot,
200 api.DiagnosticHandler diagnosticHandler, 236 api.CompilerInputProvider inputProvider,
201 [List<String> options = const <String>[]]) { 237 api.DiagnosticHandler diagnosticHandler,
238 [List<String> options = const <String>[]]) {
202 if (!libraryRoot.path.endsWith("/")) { 239 if (!libraryRoot.path.endsWith("/")) {
203 throw new ArgumentError("libraryRoot must end with a /"); 240 throw new ArgumentError("libraryRoot must end with a /");
204 } 241 }
205 if (packageRoot != null && !packageRoot.path.endsWith("/")) { 242 if (packageRoot != null && !packageRoot.path.endsWith("/")) {
206 throw new ArgumentError("packageRoot must end with a /"); 243 throw new ArgumentError("packageRoot must end with a /");
207 } 244 }
208 options = new List<String>.from(options); 245 options = new List<String>.from(options);
209 options.add('--analyze-only'); 246 options.add('--analyze-only');
210 options.add('--analyze-signatures-only'); 247 options.add('--analyze-signatures-only');
211 options.add('--analyze-all'); 248 options.add('--analyze-all');
(...skipping 14 matching lines...) Expand all
226 libraryRoot, packageRoot, options); 263 libraryRoot, packageRoot, options);
227 compiler.librariesToAnalyzeWhenRun = libraries; 264 compiler.librariesToAnalyzeWhenRun = libraries;
228 bool success = compiler.run(null); 265 bool success = compiler.run(null);
229 if (success && !compilationFailed) { 266 if (success && !compilationFailed) {
230 return new Future<MirrorSystem>.value(new Dart2JsMirrorSystem(compiler)); 267 return new Future<MirrorSystem>.value(new Dart2JsMirrorSystem(compiler));
231 } else { 268 } else {
232 return new Future<MirrorSystem>.error('Failed to create mirror system.'); 269 return new Future<MirrorSystem>.error('Failed to create mirror system.');
233 } 270 }
234 } 271 }
235 272
273 /**
274 * Analyzes set of libraries and provides a mirror system which can be used for
275 * static inspection of the source code.
276 */
277 // TODO(johnniwinther): Move dart:io dependent parts outside
278 // dart2js_mirror.dart.
279 Future<MirrorSystem> analyze(List<Path> libraries,
280 Path libraryRoot,
281 {Path packageRoot,
282 List<String> options: const <String>[],
283 api.DiagnosticHandler diagnosticHandler}) {
284 SourceFileProvider provider = new SourceFileProvider();
285 if (diagnosticHandler == null) {
286 diagnosticHandler =
287 new FormattingDiagnosticHandler(provider).diagnosticHandler;
288 }
289 Uri libraryUri = currentDirectory.resolve(appendSlash('$libraryRoot'));
290 Uri packageUri = null;
291 if (packageRoot != null) {
292 packageUri = currentDirectory.resolve(appendSlash('$packageRoot'));
293 }
294 List<Uri> librariesUri = <Uri>[];
295 for (Path library in libraries) {
296 librariesUri.add(currentDirectory.resolve(library.toString()));
297 }
298 return analyzeUri(librariesUri, libraryUri, packageUri,
299 provider.readStringFromUri, diagnosticHandler, options);
300 }
301
236 //------------------------------------------------------------------------------ 302 //------------------------------------------------------------------------------
237 // Dart2Js specific extensions of mirror interfaces 303 // Dart2Js specific extensions of mirror interfaces
238 //------------------------------------------------------------------------------ 304 //------------------------------------------------------------------------------
239 305
240 abstract class Dart2JsMirror implements Mirror { 306 abstract class Dart2JsMirror implements Mirror {
241 Dart2JsMirrorSystem get mirrors; 307 Dart2JsMirrorSystem get mirrors;
242 } 308 }
243 309
244 abstract class Dart2JsDeclarationMirror extends Dart2JsMirror 310 abstract class Dart2JsDeclarationMirror extends Dart2JsMirror
245 implements DeclarationMirror { 311 implements DeclarationMirror {
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 return new Future.value( 1747 return new Future.value(
1682 new Dart2JsStringConstantMirror.fromString(mirrors, text)); 1748 new Dart2JsStringConstantMirror.fromString(mirrors, text));
1683 } else if (fieldName == 'trimmedText') { 1749 } else if (fieldName == 'trimmedText') {
1684 return new Future.value( 1750 return new Future.value(
1685 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText)); 1751 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText));
1686 } 1752 }
1687 // TODO(johnniwinther): Which exception/error should be thrown here? 1753 // TODO(johnniwinther): Which exception/error should be thrown here?
1688 throw new UnsupportedError('InstanceMirror does not have a reflectee'); 1754 throw new UnsupportedError('InstanceMirror does not have a reflectee');
1689 } 1755 }
1690 } 1756 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698