| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 Dart2JsElementMirror(this.system, this._element) { | 406 Dart2JsElementMirror(this.system, this._element) { |
| 407 assert (system !== null); | 407 assert (system !== null); |
| 408 assert (_element !== null); | 408 assert (_element !== null); |
| 409 } | 409 } |
| 410 | 410 |
| 411 String get simpleName => _element.name.slowToString(); | 411 String get simpleName => _element.name.slowToString(); |
| 412 | 412 |
| 413 String get displayName => simpleName; | 413 String get displayName => simpleName; |
| 414 | 414 |
| 415 Location get location => new Dart2JsLocation( | 415 SourceLocation get location => new Dart2JsLocation( |
| 416 _element.getCompilationUnit().script, | 416 _element.getCompilationUnit().script, |
| 417 system.compiler.spanFromElement(_element)); | 417 system.compiler.spanFromElement(_element)); |
| 418 | 418 |
| 419 String toString() => _element.toString(); | 419 String toString() => _element.toString(); |
| 420 | 420 |
| 421 int get hashCode => qualifiedName.hashCode; | 421 int get hashCode => qualifiedName.hashCode; |
| 422 } | 422 } |
| 423 | 423 |
| 424 abstract class Dart2JsProxyMirror implements Dart2JsDeclarationMirror { | 424 abstract class Dart2JsProxyMirror implements Dart2JsDeclarationMirror { |
| 425 final Dart2JsMirrorSystem system; | 425 final Dart2JsMirrorSystem system; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 Map<String, MemberMirror> get declaredMembers { | 556 Map<String, MemberMirror> get declaredMembers { |
| 557 _ensureMembers(); | 557 _ensureMembers(); |
| 558 return new ImmutableMapWrapper<String, MemberMirror>(_members); | 558 return new ImmutableMapWrapper<String, MemberMirror>(_members); |
| 559 } | 559 } |
| 560 | 560 |
| 561 Map<String, ClassMirror> get types { | 561 Map<String, ClassMirror> get types { |
| 562 _ensureTypes(); | 562 _ensureTypes(); |
| 563 return new ImmutableMapWrapper<String, ClassMirror>(_types); | 563 return new ImmutableMapWrapper<String, ClassMirror>(_types); |
| 564 } | 564 } |
| 565 | 565 |
| 566 Location get location { | 566 SourceLocation get location { |
| 567 var script = _library.getCompilationUnit().script; | 567 var script = _library.getCompilationUnit().script; |
| 568 return new Dart2JsLocation( | 568 return new Dart2JsLocation( |
| 569 script, | 569 script, |
| 570 new SourceSpan(script.uri, 0, script.text.length)); | 570 new SourceSpan(script.uri, 0, script.text.length)); |
| 571 } | 571 } |
| 572 } | 572 } |
| 573 | 573 |
| 574 class Dart2JsLocation implements Location { | 574 class Dart2JsLocation implements SourceLocation { |
| 575 Script _script; | 575 Script _script; |
| 576 SourceSpan _span; | 576 SourceSpan _span; |
| 577 | 577 |
| 578 Dart2JsLocation(this._script, this._span); | 578 Dart2JsLocation(this._script, this._span); |
| 579 | 579 |
| 580 int get start => _span.begin; | 580 int get start => _span.begin; |
| 581 | 581 |
| 582 int get end => _span.end; | 582 int get end => _span.end; |
| 583 | 583 |
| 584 Source get source => new Dart2JsSource(_script); | 584 Source get source => new Dart2JsSource(_script); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 | 686 |
| 687 ClassElement get _class => _element; | 687 ClassElement get _class => _element; |
| 688 | 688 |
| 689 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library, | 689 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library, |
| 690 ClassElement _class) | 690 ClassElement _class) |
| 691 : this.library = library, | 691 : this.library = library, |
| 692 super(library.system, _class); | 692 super(library.system, _class); |
| 693 | 693 |
| 694 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; | 694 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; |
| 695 | 695 |
| 696 Location get location { | 696 SourceLocation get location { |
| 697 if (_class is PartialClassElement) { | 697 if (_class is PartialClassElement) { |
| 698 var node = _class.parseNode(system.compiler); | 698 var node = _class.parseNode(system.compiler); |
| 699 if (node !== null) { | 699 if (node !== null) { |
| 700 var script = _class.getCompilationUnit().script; | 700 var script = _class.getCompilationUnit().script; |
| 701 var span = system.compiler.spanFromNode(node, script.uri); | 701 var span = system.compiler.spanFromNode(node, script.uri); |
| 702 return new Dart2JsLocation(script, span); | 702 return new Dart2JsLocation(script, span); |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 return super.location; | 705 return super.location; |
| 706 } | 706 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 827 |
| 828 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, | 828 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, |
| 829 TypedefType _typedef) | 829 TypedefType _typedef) |
| 830 : this._library = library, | 830 : this._library = library, |
| 831 super(library.system, _typedef); | 831 super(library.system, _typedef); |
| 832 | 832 |
| 833 TypedefType get _typedef => _type; | 833 TypedefType get _typedef => _type; |
| 834 | 834 |
| 835 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; | 835 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; |
| 836 | 836 |
| 837 Location get location { | 837 SourceLocation get location { |
| 838 var node = _typedef.element.parseNode(_diagnosticListener); | 838 var node = _typedef.element.parseNode(_diagnosticListener); |
| 839 if (node !== null) { | 839 if (node !== null) { |
| 840 var script = _typedef.element.getCompilationUnit().script; | 840 var script = _typedef.element.getCompilationUnit().script; |
| 841 var span = system.compiler.spanFromNode(node, script.uri); | 841 var span = system.compiler.spanFromNode(node, script.uri); |
| 842 return new Dart2JsLocation(script, span); | 842 return new Dart2JsLocation(script, span); |
| 843 } | 843 } |
| 844 return super.location; | 844 return super.location; |
| 845 } | 845 } |
| 846 | 846 |
| 847 LibraryMirror get library => _library; | 847 LibraryMirror get library => _library; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 962 |
| 963 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror | 963 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror |
| 964 implements Dart2JsTypeMirror { | 964 implements Dart2JsTypeMirror { |
| 965 final DartType _type; | 965 final DartType _type; |
| 966 | 966 |
| 967 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) | 967 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) |
| 968 : super(system); | 968 : super(system); |
| 969 | 969 |
| 970 String get simpleName => _type.name.slowToString(); | 970 String get simpleName => _type.name.slowToString(); |
| 971 | 971 |
| 972 Location get location { | 972 SourceLocation get location { |
| 973 var script = _type.element.getCompilationUnit().script; | 973 var script = _type.element.getCompilationUnit().script; |
| 974 return new Dart2JsLocation(script, | 974 return new Dart2JsLocation(script, |
| 975 system.compiler.spanFromElement(_type.element)); | 975 system.compiler.spanFromElement(_type.element)); |
| 976 } | 976 } |
| 977 | 977 |
| 978 LibraryMirror get library { | 978 LibraryMirror get library { |
| 979 return system.getLibrary(_type.element.getLibrary()); | 979 return system.getLibrary(_type.element.getLibrary()); |
| 980 } | 980 } |
| 981 | 981 |
| 982 bool get isObject => false; | 982 bool get isObject => false; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) | 1160 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) |
| 1161 : super(system, voidType); | 1161 : super(system, voidType); |
| 1162 | 1162 |
| 1163 VoidType get _voidType => _type; | 1163 VoidType get _voidType => _type; |
| 1164 | 1164 |
| 1165 String get qualifiedName => simpleName; | 1165 String get qualifiedName => simpleName; |
| 1166 | 1166 |
| 1167 /** | 1167 /** |
| 1168 * The void type has no location. | 1168 * The void type has no location. |
| 1169 */ | 1169 */ |
| 1170 Location get location => null; | 1170 SourceLocation get location => null; |
| 1171 | 1171 |
| 1172 /** | 1172 /** |
| 1173 * The void type has no library. | 1173 * The void type has no library. |
| 1174 */ | 1174 */ |
| 1175 LibraryMirror get library => null; | 1175 LibraryMirror get library => null; |
| 1176 | 1176 |
| 1177 bool get isVoid => true; | 1177 bool get isVoid => true; |
| 1178 | 1178 |
| 1179 bool operator ==(Object other) { | 1179 bool operator ==(Object other) { |
| 1180 if (this === other) { | 1180 if (this === other) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1192 Dart2JsDynamicMirror(Dart2JsMirrorSystem system, InterfaceType voidType) | 1192 Dart2JsDynamicMirror(Dart2JsMirrorSystem system, InterfaceType voidType) |
| 1193 : super(system, voidType); | 1193 : super(system, voidType); |
| 1194 | 1194 |
| 1195 InterfaceType get _dynamicType => _type; | 1195 InterfaceType get _dynamicType => _type; |
| 1196 | 1196 |
| 1197 String get qualifiedName => simpleName; | 1197 String get qualifiedName => simpleName; |
| 1198 | 1198 |
| 1199 /** | 1199 /** |
| 1200 * The dynamic type has no location. | 1200 * The dynamic type has no location. |
| 1201 */ | 1201 */ |
| 1202 Location get location => null; | 1202 SourceLocation get location => null; |
| 1203 | 1203 |
| 1204 /** | 1204 /** |
| 1205 * The dynamic type has no library. | 1205 * The dynamic type has no library. |
| 1206 */ | 1206 */ |
| 1207 LibraryMirror get library => null; | 1207 LibraryMirror get library => null; |
| 1208 | 1208 |
| 1209 bool get isDynamic => true; | 1209 bool get isDynamic => true; |
| 1210 | 1210 |
| 1211 bool operator ==(Object other) { | 1211 bool operator ==(Object other) { |
| 1212 if (this === other) { | 1212 if (this === other) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 String get constructorName => _constructorName; | 1337 String get constructorName => _constructorName; |
| 1338 | 1338 |
| 1339 bool get isGetter => _kind == Dart2JsMethodKind.GETTER; | 1339 bool get isGetter => _kind == Dart2JsMethodKind.GETTER; |
| 1340 | 1340 |
| 1341 bool get isSetter => _kind == Dart2JsMethodKind.SETTER; | 1341 bool get isSetter => _kind == Dart2JsMethodKind.SETTER; |
| 1342 | 1342 |
| 1343 bool get isOperator => _kind == Dart2JsMethodKind.OPERATOR; | 1343 bool get isOperator => _kind == Dart2JsMethodKind.OPERATOR; |
| 1344 | 1344 |
| 1345 String get operatorName => _operatorName; | 1345 String get operatorName => _operatorName; |
| 1346 | 1346 |
| 1347 Location get location { | 1347 SourceLocation get location { |
| 1348 var node = _function.parseNode(_diagnosticListener); | 1348 var node = _function.parseNode(_diagnosticListener); |
| 1349 if (node !== null) { | 1349 if (node !== null) { |
| 1350 var script = _function.getCompilationUnit().script; | 1350 var script = _function.getCompilationUnit().script; |
| 1351 var span = system.compiler.spanFromNode(node, script.uri); | 1351 var span = system.compiler.spanFromNode(node, script.uri); |
| 1352 return new Dart2JsLocation(script, span); | 1352 return new Dart2JsLocation(script, span); |
| 1353 } | 1353 } |
| 1354 return super.location; | 1354 return super.location; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 } | 1357 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1385 bool get isStatic => _variable.modifiers.isStatic(); | 1385 bool get isStatic => _variable.modifiers.isStatic(); |
| 1386 | 1386 |
| 1387 bool get isFinal => _variable.modifiers.isFinal(); | 1387 bool get isFinal => _variable.modifiers.isFinal(); |
| 1388 | 1388 |
| 1389 bool get isConst => _variable.modifiers.isConst(); | 1389 bool get isConst => _variable.modifiers.isConst(); |
| 1390 | 1390 |
| 1391 TypeMirror get type => _convertTypeToTypeMirror(system, | 1391 TypeMirror get type => _convertTypeToTypeMirror(system, |
| 1392 _variable.computeType(system.compiler), | 1392 _variable.computeType(system.compiler), |
| 1393 system.compiler.types.dynamicType); | 1393 system.compiler.types.dynamicType); |
| 1394 | 1394 |
| 1395 Location get location { | 1395 SourceLocation get location { |
| 1396 var script = _variable.getCompilationUnit().script; | 1396 var script = _variable.getCompilationUnit().script; |
| 1397 var node = _variable.variables.parseNode(_diagnosticListener); | 1397 var node = _variable.variables.parseNode(_diagnosticListener); |
| 1398 if (node !== null) { | 1398 if (node !== null) { |
| 1399 var span = system.compiler.spanFromNode(node, script.uri); | 1399 var span = system.compiler.spanFromNode(node, script.uri); |
| 1400 return new Dart2JsLocation(script, span); | 1400 return new Dart2JsLocation(script, span); |
| 1401 } else { | 1401 } else { |
| 1402 var span = system.compiler.spanFromElement(_variable); | 1402 var span = system.compiler.spanFromElement(_variable); |
| 1403 return new Dart2JsLocation(script, span); | 1403 return new Dart2JsLocation(script, span); |
| 1404 } | 1404 } |
| 1405 } | 1405 } |
| 1406 } | 1406 } |
| 1407 | 1407 |
| OLD | NEW |