Index: lib/src/compiler/reify_coercions.dart |
diff --git a/lib/src/codegen/reify_coercions.dart b/lib/src/compiler/reify_coercions.dart |
similarity index 84% |
rename from lib/src/codegen/reify_coercions.dart |
rename to lib/src/compiler/reify_coercions.dart |
index f38e039aba799c26b67fdb1bfadab7873455aaed..59f97147bdcb416612f104204e867880b6aa2cf6 100644 |
--- a/lib/src/codegen/reify_coercions.dart |
+++ b/lib/src/compiler/reify_coercions.dart |
@@ -4,7 +4,6 @@ |
import 'package:analyzer/analyzer.dart' as analyzer; |
import 'package:analyzer/dart/ast/ast.dart'; |
-import 'package:analyzer/dart/element/element.dart'; |
import 'package:analyzer/dart/element/type.dart'; |
import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; |
import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; |
@@ -17,35 +16,20 @@ import 'ast_builder.dart'; |
final _log = new logger.Logger('dev_compiler.reify_coercions'); |
-class NewTypeIdDesc { |
- /// If null, then this is not a library level identifier (i.e. it's |
- /// a type parameter, or a special type like void, dynamic, etc) |
- LibraryElement importedFrom; |
- |
- /// True => use/def in same library |
- bool fromCurrent; |
- |
- /// True => not a source variable |
- bool synthetic; |
- NewTypeIdDesc({this.fromCurrent, this.importedFrom, this.synthetic}); |
-} |
- |
// This class implements a pass which modifies (in place) the ast replacing |
// abstract coercion nodes with their dart implementations. |
class CoercionReifier extends analyzer.GeneralizingAstVisitor<Object> { |
final cloner = new _TreeCloner(); |
- /// Makes coercions explicit in the resolved AST, and returns the new AST. |
- /// |
- /// This should be the entry point for this class. |
- /// Entering via the visit functions directly will incorrectly mutate the AST. |
- /// |
- /// Returns the new compilation units. |
- List<CompilationUnit> reify(List<CompilationUnit> units) { |
- // Copy the AST before modifying it. |
- units = units.map(_clone).toList(); |
- // Visit the AST and make coercions explicit. |
- units.forEach(visitCompilationUnit); |
+ CoercionReifier._(); |
+ |
+ /// Transforms the given compilation units, and returns a new AST with |
+ /// explicit coercion nodes in appropriate places. |
+ static List<CompilationUnit> reify(List<CompilationUnit> units) { |
+ var cr = new CoercionReifier._(); |
+ // Clone compilation units, so we don't modify the originals. |
+ units = units.map(cr._clone).toList(growable: false); |
+ units.forEach(cr.visitCompilationUnit); |
return units; |
} |