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 dart2js.resolution.registry; | 5 library dart2js.resolution.registry; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/backend_api.dart' show Backend, ForeignResolver; | 8 import '../common/backend_api.dart' show Backend, ForeignResolver; |
9 import '../common/resolution.dart' | 9 import '../common/resolution.dart' |
10 show Feature, ListLiteralUse, MapLiteralUse, ResolutionImpact; | 10 show Feature, ListLiteralUse, MapLiteralUse, ResolutionImpact; |
11 import '../common/registry.dart' show Registry; | 11 import '../common/registry.dart' show Registry; |
12 import '../compiler.dart' show Compiler; | 12 import '../compiler.dart' show Compiler; |
13 import '../constants/expressions.dart'; | 13 import '../constants/expressions.dart'; |
14 import '../dart_types.dart'; | 14 import '../dart_types.dart'; |
15 import '../diagnostics/source_span.dart'; | 15 import '../diagnostics/source_span.dart'; |
16 import '../enqueue.dart' show ResolutionEnqueuer; | 16 import '../enqueue.dart' show ResolutionEnqueuer; |
17 import '../elements/elements.dart'; | 17 import '../elements/elements.dart'; |
18 import '../tree/tree.dart'; | 18 import '../tree/tree.dart'; |
19 import '../util/util.dart' show Setlet; | 19 import '../util/util.dart' show Setlet; |
20 import '../universe/call_structure.dart' show CallStructure; | 20 import '../universe/call_structure.dart' show CallStructure; |
21 import '../universe/selector.dart' show Selector; | 21 import '../universe/selector.dart' show Selector; |
22 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; | 22 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; |
23 import '../universe/world_impact.dart' show WorldImpactBuilder; | 23 import '../universe/world_impact.dart' show WorldImpact, WorldImpactBuilder; |
24 import '../util/enumset.dart' show EnumSet; | 24 import '../util/enumset.dart' show EnumSet; |
25 import '../world.dart' show World; | 25 import '../world.dart' show World; |
26 | 26 |
27 import 'send_structure.dart'; | 27 import 'send_structure.dart'; |
28 | 28 |
29 import 'members.dart' show ResolverVisitor; | 29 import 'members.dart' show ResolverVisitor; |
30 import 'tree_elements.dart' show TreeElementMapping; | 30 import 'tree_elements.dart' show TreeElementMapping; |
31 | 31 |
32 class _ResolutionWorldImpact extends ResolutionImpact with WorldImpactBuilder { | 32 class _ResolutionWorldImpact extends ResolutionImpact with WorldImpactBuilder { |
33 final String name; | 33 final String name; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 _constantLiterals.add(constant); | 98 _constantLiterals.add(constant); |
99 } | 99 } |
100 | 100 |
101 Iterable<ConstantExpression> get constantLiterals { | 101 Iterable<ConstantExpression> get constantLiterals { |
102 return _constantLiterals != null | 102 return _constantLiterals != null |
103 ? _constantLiterals | 103 ? _constantLiterals |
104 : const <ConstantExpression>[]; | 104 : const <ConstantExpression>[]; |
105 } | 105 } |
106 | 106 |
107 String toString() => '_ResolutionWorldImpact($name)'; | 107 String toString() { |
| 108 StringBuffer sb = new StringBuffer(); |
| 109 sb.write('_ResolutionWorldImpact($name)'); |
| 110 WorldImpact.printOn(sb, this); |
| 111 if (_features != null) { |
| 112 sb.write('\n features:'); |
| 113 for (Feature feature in _features.iterable(Feature.values)) { |
| 114 sb.write('\n $feature'); |
| 115 } |
| 116 } |
| 117 if (_mapLiterals != null) { |
| 118 sb.write('\n map-literals:'); |
| 119 for (MapLiteralUse use in _mapLiterals) { |
| 120 sb.write('\n $use'); |
| 121 } |
| 122 } |
| 123 if (_listLiterals != null) { |
| 124 sb.write('\n list-literals:'); |
| 125 for (ListLiteralUse use in _listLiterals) { |
| 126 sb.write('\n $use'); |
| 127 } |
| 128 } |
| 129 if (_constantLiterals != null) { |
| 130 sb.write('\n const-literals:'); |
| 131 for (ConstantExpression constant in _constantLiterals) { |
| 132 sb.write('\n ${constant.getText()}'); |
| 133 } |
| 134 } |
| 135 if (_constSymbolNames != null) { |
| 136 sb.write('\n const-symbol-names: $_constSymbolNames'); |
| 137 } |
| 138 return sb.toString(); |
| 139 } |
108 } | 140 } |
109 | 141 |
110 /// [ResolutionRegistry] collects all resolution information. It stores node | 142 /// [ResolutionRegistry] collects all resolution information. It stores node |
111 /// related information in a [TreeElements] mapping and registers calls with | 143 /// related information in a [TreeElements] mapping and registers calls with |
112 /// [Backend], [World] and [Enqueuer]. | 144 /// [Backend], [World] and [Enqueuer]. |
113 // TODO(johnniwinther): Split this into an interface and implementation class. | 145 // TODO(johnniwinther): Split this into an interface and implementation class. |
114 class ResolutionRegistry extends Registry { | 146 class ResolutionRegistry extends Registry { |
115 final Compiler compiler; | 147 final Compiler compiler; |
116 final TreeElementMapping mapping; | 148 final TreeElementMapping mapping; |
117 final _ResolutionWorldImpact worldImpact; | 149 final _ResolutionWorldImpact worldImpact; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 @override | 422 @override |
391 void registerInstantiatedType(InterfaceType type) { | 423 void registerInstantiatedType(InterfaceType type) { |
392 registry.registerInstantiation(type); | 424 registry.registerInstantiation(type); |
393 } | 425 } |
394 | 426 |
395 @override | 427 @override |
396 DartType resolveTypeFromString(Node node, String typeName) { | 428 DartType resolveTypeFromString(Node node, String typeName) { |
397 return visitor.resolveTypeFromString(node, typeName); | 429 return visitor.resolveTypeFromString(node, typeName); |
398 } | 430 } |
399 } | 431 } |
OLD | NEW |