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 compiler.src.inferrer.map_tracer; | 5 library compiler.src.inferrer.map_tracer; |
6 | 6 |
7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
8 import '../universe/selector.dart' show Selector; | 8 import '../universe/selector.dart' show Selector; |
9 | 9 |
10 import 'node_tracer.dart'; | 10 import 'node_tracer.dart'; |
11 import 'type_graph_nodes.dart'; | 11 import 'type_graph_nodes.dart'; |
12 | 12 |
13 Set<String> okMapSelectorsSet = new Set.from( | 13 Set<String> okMapSelectorsSet = new Set.from(const <String>[ |
14 const <String>[ | 14 // From Object. |
15 // From Object. | 15 "==", |
16 "==", | 16 "hashCode", |
17 "hashCode", | 17 "toString", |
18 "toString", | 18 "noSuchMethod", |
19 "noSuchMethod", | 19 "runtimeType", |
20 "runtimeType", | 20 // From Map |
21 // From Map | 21 "[]", |
22 "[]", | 22 "isEmpty", |
23 "isEmpty", | 23 "isNotEmpty", |
24 "isNotEmpty", | 24 "keys", |
25 "keys", | 25 "length", |
26 "length", | 26 "values", |
27 "values", | 27 "clear", |
28 "clear", | 28 "containsKey", |
29 "containsKey", | 29 "containsValue", |
30 "containsValue", | 30 "forEach", |
31 "forEach", | 31 "remove" |
32 "remove"]); | 32 ]); |
33 | 33 |
34 class MapTracerVisitor extends TracerVisitor<MapTypeInformation> { | 34 class MapTracerVisitor extends TracerVisitor<MapTypeInformation> { |
35 // These lists are used to keep track of newly discovered assignments to | 35 // These lists are used to keep track of newly discovered assignments to |
36 // the map. Note that elements at corresponding indices are expected to | 36 // the map. Note that elements at corresponding indices are expected to |
37 // belong to the same assignment operation. | 37 // belong to the same assignment operation. |
38 List<TypeInformation> keyAssignments = <TypeInformation>[]; | 38 List<TypeInformation> keyAssignments = <TypeInformation>[]; |
39 List<TypeInformation> valueAssignments = <TypeInformation>[]; | 39 List<TypeInformation> valueAssignments = <TypeInformation>[]; |
40 // This list is used to keep track of assignments of entire maps to | 40 // This list is used to keep track of assignments of entire maps to |
41 // this map. | 41 // this map. |
42 List<MapTypeInformation> mapAssignments = <MapTypeInformation>[]; | 42 List<MapTypeInformation> mapAssignments = <MapTypeInformation>[]; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 } else if (selector.isIndexSet) { | 115 } else if (selector.isIndexSet) { |
116 keyAssignments.add(info.arguments.positional[0]); | 116 keyAssignments.add(info.arguments.positional[0]); |
117 valueAssignments.add(info.arguments.positional[1]); | 117 valueAssignments.add(info.arguments.positional[1]); |
118 } else if (!selector.isIndex) { | 118 } else if (!selector.isIndex) { |
119 bailout('Map used in a not-ok selector [$selectorName]'); | 119 bailout('Map used in a not-ok selector [$selectorName]'); |
120 return; | 120 return; |
121 } | 121 } |
122 } | 122 } |
123 } else if (selector.isCall && | 123 } else if (selector.isCall && |
124 !info.targets.every((element) => element.isFunction)) { | 124 !info.targets.every((element) => element.isFunction)) { |
125 bailout('Passed to a closure'); | 125 bailout('Passed to a closure'); |
126 return; | 126 return; |
127 } | 127 } |
128 } | 128 } |
129 } | 129 } |
OLD | NEW |