| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer2dart.treeShaker; | 5 library analyzer2dart.treeShaker; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:analyzer/src/generated/resolver.dart'; |
| 12 import 'package:compiler/src/universe/universe.dart'; | 13 import 'package:compiler/src/universe/universe.dart'; |
| 13 | 14 |
| 14 import 'closed_world.dart'; | 15 import 'closed_world.dart'; |
| 15 import 'util.dart'; | 16 import 'util.dart'; |
| 16 import 'semantic_visitor.dart'; | 17 import 'semantic_visitor.dart'; |
| 17 import 'identifier_semantics.dart'; | 18 import 'identifier_semantics.dart'; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * The result of performing local reachability analysis on a method. | 21 * The result of performing local reachability analysis on a method. |
| 21 */ | 22 */ |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 * methods. | 167 * methods. |
| 167 */ | 168 */ |
| 168 class TreeShaker { | 169 class TreeShaker { |
| 169 List<Element> _queue = <Element>[]; | 170 List<Element> _queue = <Element>[]; |
| 170 Set<Element> _alreadyEnqueued = new HashSet<Element>(); | 171 Set<Element> _alreadyEnqueued = new HashSet<Element>(); |
| 171 ClosedWorld _world; | 172 ClosedWorld _world; |
| 172 Set<Selector> _selectors = new HashSet<Selector>(); | 173 Set<Selector> _selectors = new HashSet<Selector>(); |
| 173 final LocalReachabilityComputer _localComputer = | 174 final LocalReachabilityComputer _localComputer = |
| 174 new LocalReachabilityComputer(); | 175 new LocalReachabilityComputer(); |
| 175 | 176 |
| 176 TreeShaker(FunctionElement mainFunction) | 177 TreeShaker(TypeProvider typeProvider, FunctionElement mainFunction) |
| 177 : _world = new ClosedWorld(mainFunction); | 178 : _world = new ClosedWorld(typeProvider, mainFunction); |
| 178 | 179 |
| 179 void _addElement(Element element) { | 180 void _addElement(Element element) { |
| 180 if (_alreadyEnqueued.add(element)) { | 181 if (_alreadyEnqueued.add(element)) { |
| 181 _queue.add(element); | 182 _queue.add(element); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 | 185 |
| 185 void _addSelector(Selector selector) { | 186 void _addSelector(Selector selector) { |
| 186 if (_selectors.add(selector)) { | 187 if (_selectors.add(selector)) { |
| 187 // New selector, so match it against all class methods. | 188 // New selector, so match it against all class methods. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // null, because that would have been detected by the analyzer and | 389 // null, because that would have been detected by the analyzer and |
| 389 // reported as a compile time error. | 390 // reported as a compile time error. |
| 390 analysis.calls.add(node.staticElement); | 391 analysis.calls.add(node.staticElement); |
| 391 } | 392 } |
| 392 | 393 |
| 393 @override | 394 @override |
| 394 void handleAssignmentExpression(AssignmentExpression node) { | 395 void handleAssignmentExpression(AssignmentExpression node) { |
| 395 // Don't special-case assignment expressions. | 396 // Don't special-case assignment expressions. |
| 396 } | 397 } |
| 397 } | 398 } |
| OLD | NEW |