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; |
(...skipping 18 matching lines...) Expand all Loading... |
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; |
34 EnumSet<Feature> _features; | 34 EnumSet<Feature> _features; |
35 Setlet<MapLiteralUse> _mapLiterals; | 35 Setlet<MapLiteralUse> _mapLiterals; |
36 Setlet<ListLiteralUse> _listLiterals; | 36 Setlet<ListLiteralUse> _listLiterals; |
37 Setlet<String> _constSymbolNames; | 37 Setlet<String> _constSymbolNames; |
38 Setlet<ConstantExpression> _constantLiterals; | 38 Setlet<ConstantExpression> _constantLiterals; |
| 39 Setlet<dynamic> _nativeData; |
39 | 40 |
40 _ResolutionWorldImpact(this.name); | 41 _ResolutionWorldImpact(this.name); |
41 | 42 |
42 void registerMapLiteral(MapLiteralUse mapLiteralUse) { | 43 void registerMapLiteral(MapLiteralUse mapLiteralUse) { |
43 assert(mapLiteralUse != null); | 44 assert(mapLiteralUse != null); |
44 if (_mapLiterals == null) { | 45 if (_mapLiterals == null) { |
45 _mapLiterals = new Setlet<MapLiteralUse>(); | 46 _mapLiterals = new Setlet<MapLiteralUse>(); |
46 } | 47 } |
47 _mapLiterals.add(mapLiteralUse); | 48 _mapLiterals.add(mapLiteralUse); |
48 } | 49 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 98 } |
98 _constantLiterals.add(constant); | 99 _constantLiterals.add(constant); |
99 } | 100 } |
100 | 101 |
101 Iterable<ConstantExpression> get constantLiterals { | 102 Iterable<ConstantExpression> get constantLiterals { |
102 return _constantLiterals != null | 103 return _constantLiterals != null |
103 ? _constantLiterals | 104 ? _constantLiterals |
104 : const <ConstantExpression>[]; | 105 : const <ConstantExpression>[]; |
105 } | 106 } |
106 | 107 |
| 108 void registerNativeData(dynamic nativeData) { |
| 109 assert(nativeData != null); |
| 110 if (_nativeData == null) { |
| 111 _nativeData = new Setlet<dynamic>(); |
| 112 } |
| 113 _nativeData.add(nativeData); |
| 114 } |
| 115 |
| 116 @override |
| 117 Iterable<dynamic> get nativeData { |
| 118 return _nativeData != null ? _nativeData : const <dynamic>[]; |
| 119 } |
| 120 |
107 String toString() { | 121 String toString() { |
108 StringBuffer sb = new StringBuffer(); | 122 StringBuffer sb = new StringBuffer(); |
109 sb.write('_ResolutionWorldImpact($name)'); | 123 sb.write('_ResolutionWorldImpact($name)'); |
110 WorldImpact.printOn(sb, this); | 124 WorldImpact.printOn(sb, this); |
111 if (_features != null) { | 125 if (_features != null) { |
112 sb.write('\n features:'); | 126 sb.write('\n features:'); |
113 for (Feature feature in _features.iterable(Feature.values)) { | 127 for (Feature feature in _features.iterable(Feature.values)) { |
114 sb.write('\n $feature'); | 128 sb.write('\n $feature'); |
115 } | 129 } |
116 } | 130 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 setType(node, type); | 366 setType(node, type); |
353 worldImpact.registerMapLiteral( | 367 worldImpact.registerMapLiteral( |
354 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | 368 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); |
355 } | 369 } |
356 | 370 |
357 void registerForeignCall(Node node, Element element, | 371 void registerForeignCall(Node node, Element element, |
358 CallStructure callStructure, ResolverVisitor visitor) { | 372 CallStructure callStructure, ResolverVisitor visitor) { |
359 var nativeData = backend.resolveForeignCall(node, element, callStructure, | 373 var nativeData = backend.resolveForeignCall(node, element, callStructure, |
360 new ForeignResolutionResolver(visitor, this)); | 374 new ForeignResolutionResolver(visitor, this)); |
361 if (nativeData != null) { | 375 if (nativeData != null) { |
| 376 // Split impact from resolution result. |
362 mapping.registerNativeData(node, nativeData); | 377 mapping.registerNativeData(node, nativeData); |
| 378 worldImpact.registerNativeData(nativeData); |
363 } | 379 } |
364 } | 380 } |
365 | 381 |
366 void registerDynamicUse(DynamicUse dynamicUse) { | 382 void registerDynamicUse(DynamicUse dynamicUse) { |
367 worldImpact.registerDynamicUse(dynamicUse); | 383 worldImpact.registerDynamicUse(dynamicUse); |
368 } | 384 } |
369 | 385 |
370 void registerFeature(Feature feature) { | 386 void registerFeature(Feature feature) { |
371 worldImpact.registerFeature(feature); | 387 worldImpact.registerFeature(feature); |
372 } | 388 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 @override | 441 @override |
426 void registerInstantiatedType(InterfaceType type) { | 442 void registerInstantiatedType(InterfaceType type) { |
427 registry.registerInstantiation(type); | 443 registry.registerInstantiation(type); |
428 } | 444 } |
429 | 445 |
430 @override | 446 @override |
431 DartType resolveTypeFromString(Node node, String typeName) { | 447 DartType resolveTypeFromString(Node node, String typeName) { |
432 return visitor.resolveTypeFromString(node, typeName); | 448 return visitor.resolveTypeFromString(node, typeName); |
433 } | 449 } |
434 } | 450 } |
OLD | NEW |