Chromium Code Reviews| 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; | 5 import 'dart:collection' show HashMap, HashSet; |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 /// cache/generator variables discharged at the binding site for the | 155 /// cache/generator variables discharged at the binding site for the |
| 156 /// type variable since the type definition depends on the type | 156 /// type variable since the type definition depends on the type |
| 157 /// parameter. | 157 /// parameter. |
| 158 final _scopeDependencies = | 158 final _scopeDependencies = |
| 159 new HashMap<TypeParameterElement, List<DartType>>(); | 159 new HashMap<TypeParameterElement, List<DartType>>(); |
| 160 | 160 |
| 161 /// Emit a list of statements declaring the cache variables and generator | 161 /// Emit a list of statements declaring the cache variables and generator |
| 162 /// definitions tracked by the table. If [formals] is present, only | 162 /// definitions tracked by the table. If [formals] is present, only |
| 163 /// emit the definitions which depend on the formals. | 163 /// emit the definitions which depend on the formals. |
| 164 List<JS.Statement> discharge([List<TypeParameterElement> formals]) { | 164 List<JS.Statement> discharge([List<TypeParameterElement> formals]) { |
| 165 var filter = formals?.expand((p) => _scopeDependencies[p] ?? []); | 165 var filter = formals?.expand((p) => _scopeDependencies[p] ?? <DartType>[]); |
|
Leaf
2016/05/26 17:53:38
It sure would be nice if our final inference algor
Jennifer Messerly
2016/05/26 18:11:48
Had the same thought :)
filed https://github.com/
| |
| 166 var stmts = [ | 166 var stmts = [ |
| 167 _cacheNames, | 167 _cacheNames, |
| 168 _definiteCacheNames, | 168 _definiteCacheNames, |
| 169 _generators, | 169 _generators, |
| 170 _definiteGenerators | 170 _definiteGenerators |
| 171 ].expand((c) => c.discharge(filter)).toList(); | 171 ].expand((c) => c.discharge(filter)).toList(); |
| 172 formals?.forEach(_scopeDependencies.remove); | 172 formals?.forEach(_scopeDependencies.remove); |
| 173 return stmts; | 173 return stmts; |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 assert(hoistType != null); | 220 assert(hoistType != null); |
| 221 var table = hoistType | 221 var table = hoistType |
| 222 ? (definite ? _definiteGenerators : _generators) | 222 ? (definite ? _definiteGenerators : _generators) |
| 223 : (definite ? _definiteCacheNames : _cacheNames); | 223 : (definite ? _definiteCacheNames : _cacheNames); |
| 224 if (!table.isNamed(type)) { | 224 if (!table.isNamed(type)) { |
| 225 if (recordScopeDependencies(type)) return typeRep; | 225 if (recordScopeDependencies(type)) return typeRep; |
| 226 } | 226 } |
| 227 return table.nameType(type, typeRep); | 227 return table.nameType(type, typeRep); |
| 228 } | 228 } |
| 229 } | 229 } |
| OLD | NEW |