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 dev_compiler.src.info; | 7 library dev_compiler.src.info; |
8 | 8 |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 | 10 |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node); | 713 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node); |
714 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node); | 714 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node); |
715 R visitInferredTypeBase(InferredTypeBase node) => visitConversion(node); | 715 R visitInferredTypeBase(InferredTypeBase node) => visitConversion(node); |
716 } | 716 } |
717 | 717 |
718 /// Automatically infer list of types by scanning this library using mirrors. | 718 /// Automatically infer list of types by scanning this library using mirrors. |
719 final List<Type> infoTypes = () { | 719 final List<Type> infoTypes = () { |
720 var allTypes = new Set(); | 720 var allTypes = new Set(); |
721 var baseTypes = new Set(); | 721 var baseTypes = new Set(); |
722 var infoMirror = reflectClass(StaticInfo); | 722 var infoMirror = reflectClass(StaticInfo); |
723 var declarations = infoMirror.owner.declarations.values; | 723 var libMirror = infoMirror.owner as LibraryMirror; |
724 for (var cls in declarations.where((d) => d is ClassMirror)) { | 724 var declarations = libMirror.declarations.values; |
| 725 for (ClassMirror cls in declarations.where((d) => d is ClassMirror)) { |
725 if (cls.isSubtypeOf(infoMirror)) { | 726 if (cls.isSubtypeOf(infoMirror)) { |
726 allTypes.add(cls); | 727 allTypes.add(cls); |
727 baseTypes.add(cls.superclass); | 728 baseTypes.add(cls.superclass); |
728 } | 729 } |
729 } | 730 } |
730 allTypes.removeAll(baseTypes); | 731 allTypes.removeAll(baseTypes); |
731 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) | 732 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) |
732 ..sort((t1, t2) => '$t1'.compareTo('$t2')); | 733 ..sort((t1, t2) => '$t1'.compareTo('$t2')); |
733 }(); | 734 }(); |
734 | 735 |
735 class AnalyzerError extends Message { | 736 class AnalyzerError extends Message { |
736 factory AnalyzerError.from(analyzer.AnalysisError error) { | 737 factory AnalyzerError.from(analyzer.AnalysisError error) { |
737 var severity = error.errorCode.type.severity; | 738 var severity = error.errorCode.type.severity; |
738 var isError = severity == analyzer.ErrorSeverity.WARNING; | 739 var isError = severity == analyzer.ErrorSeverity.WARNING; |
739 var level = isError ? Level.SEVERE : Level.WARNING; | 740 var level = isError ? Level.SEVERE : Level.WARNING; |
740 int begin = error.offset; | 741 int begin = error.offset; |
741 int end = begin + error.length; | 742 int end = begin + error.length; |
742 return new AnalyzerError(error.message, level, begin, end); | 743 return new AnalyzerError(error.message, level, begin, end); |
743 } | 744 } |
744 | 745 |
745 const AnalyzerError(String message, Level level, int begin, int end) | 746 const AnalyzerError(String message, Level level, int begin, int end) |
746 : super(message, level, begin, end); | 747 : super(message, level, begin, end); |
747 } | 748 } |
OLD | NEW |