OLD | NEW |
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:io'; | 7 import 'dart:io'; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 | 9 |
10 import '../../../../../lib/compiler/compiler.dart' as diagnostics; | 10 import '../../../../../lib/compiler/compiler.dart' as diagnostics; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 String get simpleName => _element.name.slowToString(); | 404 String get simpleName => _element.name.slowToString(); |
405 | 405 |
406 String get displayName => simpleName; | 406 String get displayName => simpleName; |
407 | 407 |
408 Location get location => new Dart2JsLocation( | 408 Location get location => new Dart2JsLocation( |
409 _element.getCompilationUnit().script, | 409 _element.getCompilationUnit().script, |
410 system.compiler.spanFromElement(_element)); | 410 system.compiler.spanFromElement(_element)); |
411 | 411 |
412 String toString() => _element.toString(); | 412 String toString() => _element.toString(); |
413 | 413 |
414 int hashCode() => qualifiedName.hashCode(); | 414 int get hashCode => qualifiedName.hashCode; |
415 } | 415 } |
416 | 416 |
417 abstract class Dart2JsProxyMirror implements Dart2JsMirror { | 417 abstract class Dart2JsProxyMirror implements Dart2JsMirror { |
418 final Dart2JsMirrorSystem system; | 418 final Dart2JsMirrorSystem system; |
419 | 419 |
420 Dart2JsProxyMirror(this.system); | 420 Dart2JsProxyMirror(this.system); |
421 | 421 |
422 String get displayName => simpleName; | 422 String get displayName => simpleName; |
423 | 423 |
424 int hashCode() => qualifiedName.hashCode(); | 424 int get hashCode => qualifiedName.hashCode; |
425 } | 425 } |
426 | 426 |
427 //------------------------------------------------------------------------------ | 427 //------------------------------------------------------------------------------ |
428 // Mirror system implementation. | 428 // Mirror system implementation. |
429 //------------------------------------------------------------------------------ | 429 //------------------------------------------------------------------------------ |
430 | 430 |
431 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { | 431 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { |
432 final api.Compiler compiler; | 432 final api.Compiler compiler; |
433 Map<String, Dart2JsLibraryMirror> _libraries; | 433 Map<String, Dart2JsLibraryMirror> _libraries; |
434 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; | 434 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; |
(...skipping 21 matching lines...) Expand all Loading... |
456 return _libraryMap[element]; | 456 return _libraryMap[element]; |
457 } | 457 } |
458 | 458 |
459 Dart2JsMirrorSystem get system => this; | 459 Dart2JsMirrorSystem get system => this; |
460 | 460 |
461 String get simpleName => "mirror"; | 461 String get simpleName => "mirror"; |
462 String get displayName => simpleName; | 462 String get displayName => simpleName; |
463 String get qualifiedName => simpleName; | 463 String get qualifiedName => simpleName; |
464 | 464 |
465 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror. | 465 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror. |
466 int hashCode() => qualifiedName.hashCode(); | 466 int get hashCode => qualifiedName.hashCode; |
467 } | 467 } |
468 | 468 |
469 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror | 469 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror |
470 implements ObjectMirror { | 470 implements ObjectMirror { |
471 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element) | 471 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element) |
472 : super(system, element); | 472 : super(system, element); |
473 } | 473 } |
474 | 474 |
475 class Dart2JsLibraryMirror extends Dart2JsObjectMirror | 475 class Dart2JsLibraryMirror extends Dart2JsObjectMirror |
476 implements LibraryMirror { | 476 implements LibraryMirror { |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 if (node !== null) { | 1389 if (node !== null) { |
1390 var span = system.compiler.spanFromNode(node, script.uri); | 1390 var span = system.compiler.spanFromNode(node, script.uri); |
1391 return new Dart2JsLocation(script, span); | 1391 return new Dart2JsLocation(script, span); |
1392 } else { | 1392 } else { |
1393 var span = system.compiler.spanFromElement(_variable); | 1393 var span = system.compiler.spanFromElement(_variable); |
1394 return new Dart2JsLocation(script, span); | 1394 return new Dart2JsLocation(script, span); |
1395 } | 1395 } |
1396 } | 1396 } |
1397 } | 1397 } |
1398 | 1398 |
OLD | NEW |