Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: lib/src/compiler/reify_coercions.dart

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/compiler/nullable_type_inference.dart ('k') | lib/src/compiler/side_effect_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « lib/src/compiler/nullable_type_inference.dart ('k') | lib/src/compiler/side_effect_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698