| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Defines static information collected by the type checker and used later by | 5 /// Defines static information collected by the type checker and used later by |
| 6 /// emitters to generate code. | 6 /// emitters to generate code. |
| 7 library ddc.src.info; | 7 library dev_compiler.src.info; |
| 8 | 8 |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| 11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/scanner.dart' | 13 import 'package:analyzer/src/generated/scanner.dart' |
| 14 show Token, TokenType, SyntheticStringToken; | 14 show Token, TokenType, SyntheticStringToken; |
| 15 import 'package:logging/logging.dart' show Level; | 15 import 'package:logging/logging.dart' show Level; |
| 16 | 16 |
| 17 import 'package:dev_compiler/src/checker/rules.dart'; | 17 import 'package:dev_compiler/src/checker/rules.dart'; |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 R visitDownCastExact(DownCastExact node) => visitDownCastBase(node); | 567 R visitDownCastExact(DownCastExact node) => visitDownCastBase(node); |
| 568 R visitClosureWrapBase(ClosureWrapBase node) => visitConversion(node); | 568 R visitClosureWrapBase(ClosureWrapBase node) => visitConversion(node); |
| 569 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node); | 569 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node); |
| 570 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node); | 570 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node); |
| 571 } | 571 } |
| 572 | 572 |
| 573 /// Automatically infer list of types by scanning this library using mirrors. | 573 /// Automatically infer list of types by scanning this library using mirrors. |
| 574 final List<Type> infoTypes = () { | 574 final List<Type> infoTypes = () { |
| 575 var allTypes = new Set(); | 575 var allTypes = new Set(); |
| 576 var baseTypes = new Set(); | 576 var baseTypes = new Set(); |
| 577 var lib = currentMirrorSystem().findLibrary(#ddc.src.info); | |
| 578 var infoMirror = reflectClass(StaticInfo); | 577 var infoMirror = reflectClass(StaticInfo); |
| 579 for (var cls in lib.declarations.values.where((d) => d is ClassMirror)) { | 578 var declarations = infoMirror.owner.declarations.values; |
| 579 for (var cls in declarations.where((d) => d is ClassMirror)) { |
| 580 if (cls.isSubtypeOf(infoMirror)) { | 580 if (cls.isSubtypeOf(infoMirror)) { |
| 581 allTypes.add(cls); | 581 allTypes.add(cls); |
| 582 baseTypes.add(cls.superclass); | 582 baseTypes.add(cls.superclass); |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 allTypes.removeAll(baseTypes); | 585 allTypes.removeAll(baseTypes); |
| 586 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) | 586 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) |
| 587 ..sort((t1, t2) => '$t1'.compareTo('$t2')); | 587 ..sort((t1, t2) => '$t1'.compareTo('$t2')); |
| 588 }(); | 588 }(); |
| OLD | NEW |