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 library dev_compiler.src.codegen.reify_coercions; | 5 library dev_compiler.src.codegen.reify_coercions; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart' as analyzer; | 7 import 'package:analyzer/analyzer.dart' as analyzer; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
10 import 'package:logging/logging.dart' as logger; | 10 import 'package:logging/logging.dart' as logger; |
11 | 11 |
12 import '../compiler.dart' show AbstractCompiler; | |
13 import '../checker/rules.dart'; | 12 import '../checker/rules.dart'; |
14 import '../info.dart'; | 13 import '../info.dart'; |
15 | 14 |
16 import 'ast_builder.dart'; | 15 import 'ast_builder.dart'; |
17 | 16 |
18 final _log = new logger.Logger('dev_compiler.reify_coercions'); | 17 final _log = new logger.Logger('dev_compiler.reify_coercions'); |
19 | 18 |
20 // TODO(leafp) Factor this out or use an existing library | 19 // TODO(leafp) Factor this out or use an existing library |
21 class Tuple2<T0, T1> { | 20 class Tuple2<T0, T1> { |
22 final T0 e0; | 21 final T0 e0; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 class CoercionReifier extends analyzer.GeneralizingAstVisitor<Object> { | 92 class CoercionReifier extends analyzer.GeneralizingAstVisitor<Object> { |
94 final CoercionManager _cm; | 93 final CoercionManager _cm; |
95 final TypeManager _tm; | 94 final TypeManager _tm; |
96 final VariableManager _vm; | 95 final VariableManager _vm; |
97 final LibraryUnit _library; | 96 final LibraryUnit _library; |
98 final _Inference _inferrer; | 97 final _Inference _inferrer; |
99 | 98 |
100 CoercionReifier._( | 99 CoercionReifier._( |
101 this._cm, this._tm, this._vm, this._library, this._inferrer); | 100 this._cm, this._tm, this._vm, this._library, this._inferrer); |
102 | 101 |
103 factory CoercionReifier(LibraryUnit library, AbstractCompiler compiler) { | 102 factory CoercionReifier(LibraryUnit library, TypeRules rules) { |
104 var vm = new VariableManager(); | 103 var vm = new VariableManager(); |
105 var tm = new TypeManager(library.library.element.enclosingElement, vm); | 104 var tm = new TypeManager(library.library.element.enclosingElement, vm); |
106 var cm = new CoercionManager(vm, tm); | 105 var cm = new CoercionManager(vm, tm); |
107 var inferrer = new _Inference(compiler.rules, tm); | 106 var inferrer = new _Inference(rules, tm); |
108 return new CoercionReifier._(cm, tm, vm, library, inferrer); | 107 return new CoercionReifier._(cm, tm, vm, library, inferrer); |
109 } | 108 } |
110 | 109 |
111 // This should be the entry point for this class. Entering via the | 110 // This should be the entry point for this class. Entering via the |
112 // visit functions directly may not do the right thing with respect | 111 // visit functions directly may not do the right thing with respect |
113 // to discharging the collected definitions. | 112 // to discharging the collected definitions. |
114 // Returns the set of new type identifiers added by the reifier | 113 // Returns the set of new type identifiers added by the reifier |
115 Map<Identifier, NewTypeIdDesc> reify() { | 114 Map<Identifier, NewTypeIdDesc> reify() { |
116 _library.partsThenLibrary.forEach(visitCompilationUnit); | 115 _library.partsThenLibrary.forEach(visitCompilationUnit); |
117 return _tm.addedTypes; | 116 return _tm.addedTypes; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 var t = _mkNewTypeName(dType, id, args); | 493 var t = _mkNewTypeName(dType, id, args); |
495 return t; | 494 return t; |
496 } | 495 } |
497 | 496 |
498 TypeName _mkNewTypeName(DartType type, Identifier id, List<TypeName> args) { | 497 TypeName _mkNewTypeName(DartType type, Identifier id, List<TypeName> args) { |
499 var t = AstBuilder.typeName(id, args); | 498 var t = AstBuilder.typeName(id, args); |
500 t.type = type; | 499 t.type = type; |
501 return t; | 500 return t; |
502 } | 501 } |
503 } | 502 } |
OLD | NEW |