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 import 'dart:collection' show HashMap, HashSet, LinkedHashMap; | 5 import 'dart:collection' show HashMap, HashSet, LinkedHashMap; |
6 | 6 |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
9 | 9 |
10 import '../js_ast/js_ast.dart' as JS; | 10 import '../js_ast/js_ast.dart' as JS; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 /// cache/generator variables discharged at the binding site for the | 158 /// cache/generator variables discharged at the binding site for the |
159 /// type variable since the type definition depends on the type | 159 /// type variable since the type definition depends on the type |
160 /// parameter. | 160 /// parameter. |
161 final _scopeDependencies = | 161 final _scopeDependencies = |
162 new HashMap<TypeParameterElement, List<DartType>>(); | 162 new HashMap<TypeParameterElement, List<DartType>>(); |
163 | 163 |
164 /// Emit a list of statements declaring the cache variables and generator | 164 /// Emit a list of statements declaring the cache variables and generator |
165 /// definitions tracked by the table. If [formals] is present, only | 165 /// definitions tracked by the table. If [formals] is present, only |
166 /// emit the definitions which depend on the formals. | 166 /// emit the definitions which depend on the formals. |
167 List<JS.Statement> discharge([List<TypeParameterElement> formals]) { | 167 List<JS.Statement> discharge([List<TypeParameterElement> formals]) { |
168 var filter = formals?.expand((p) => _scopeDependencies[p] ?? []); | 168 var filter = formals?.expand((p) => _scopeDependencies[p] ?? <DartType>[]); |
169 var stmts = [ | 169 var stmts = [ |
170 _cacheNames, | 170 _cacheNames, |
171 _definiteCacheNames, | 171 _definiteCacheNames, |
172 _generators, | 172 _generators, |
173 _definiteGenerators | 173 _definiteGenerators |
174 ].expand((c) => c.discharge(filter)).toList(); | 174 ].expand((c) => c.discharge(filter)).toList(); |
175 formals?.forEach(_scopeDependencies.remove); | 175 formals?.forEach(_scopeDependencies.remove); |
176 return stmts; | 176 return stmts; |
177 } | 177 } |
178 | 178 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 assert(hoistType != null); | 223 assert(hoistType != null); |
224 var table = hoistType | 224 var table = hoistType |
225 ? (definite ? _definiteGenerators : _generators) | 225 ? (definite ? _definiteGenerators : _generators) |
226 : (definite ? _definiteCacheNames : _cacheNames); | 226 : (definite ? _definiteCacheNames : _cacheNames); |
227 if (!table.isNamed(type)) { | 227 if (!table.isNamed(type)) { |
228 if (recordScopeDependencies(type)) return typeRep; | 228 if (recordScopeDependencies(type)) return typeRep; |
229 } | 229 } |
230 return table.nameType(type, typeRep); | 230 return table.nameType(type, typeRep); |
231 } | 231 } |
232 } | 232 } |
OLD | NEW |