| 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 part of type_graph_inferrer; | 5 part of type_graph_inferrer; |
| 6 | 6 |
| 7 Set<String> okMapSelectorsSet = new Set.from( | 7 Set<String> okMapSelectorsSet = new Set.from( |
| 8 const <String>[ | 8 const <String>[ |
| 9 // From Object. | 9 // From Object. |
| 10 "==", | 10 "==", |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 bailout('Used in JS ${info.call}'); | 65 bailout('Used in JS ${info.call}'); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { | 69 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { |
| 70 super.visitDynamicCallSiteTypeInformation(info); | 70 super.visitDynamicCallSiteTypeInformation(info); |
| 71 Selector selector = info.selector; | 71 Selector selector = info.selector; |
| 72 String selectorName = selector.name; | 72 String selectorName = selector.name; |
| 73 if (currentUser == info.receiver) { | 73 if (currentUser == info.receiver) { |
| 74 if (!okMapSelectorsSet.contains(selectorName)) { | 74 if (!okMapSelectorsSet.contains(selectorName)) { |
| 75 if (selector.isCall()) { | 75 if (selector.isCall) { |
| 76 int positionalLength = info.arguments.positional.length; | 76 int positionalLength = info.arguments.positional.length; |
| 77 if (selectorName == 'addAll') { | 77 if (selectorName == 'addAll') { |
| 78 // All keys and values from the argument flow into | 78 // All keys and values from the argument flow into |
| 79 // the map. | 79 // the map. |
| 80 TypeInformation map = info.arguments.positional[0]; | 80 TypeInformation map = info.arguments.positional[0]; |
| 81 if (map is MapTypeInformation) { | 81 if (map is MapTypeInformation) { |
| 82 mapAssignments.add(map); | 82 mapAssignments.add(map); |
| 83 } else { | 83 } else { |
| 84 // If we could select a component from a [TypeInformation], | 84 // If we could select a component from a [TypeInformation], |
| 85 // like the keytype or valuetype in this case, we could | 85 // like the keytype or valuetype in this case, we could |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 valueAssignments.add(inferrer.types.dynamicType); | 99 valueAssignments.add(inferrer.types.dynamicType); |
| 100 } else { | 100 } else { |
| 101 // It would be nice to handle [Map.keys] and [Map.values], too. | 101 // It would be nice to handle [Map.keys] and [Map.values], too. |
| 102 // However, currently those calls do not trigger the creation | 102 // However, currently those calls do not trigger the creation |
| 103 // of a [ListTypeInformation], so I have nowhere to propagate | 103 // of a [ListTypeInformation], so I have nowhere to propagate |
| 104 // that information. | 104 // that information. |
| 105 // TODO(herhut): add support for Map.keys and Map.values. | 105 // TODO(herhut): add support for Map.keys and Map.values. |
| 106 bailout('Map used in a not-ok selector [$selectorName]'); | 106 bailout('Map used in a not-ok selector [$selectorName]'); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 } else if (selector.isIndexSet()) { | 109 } else if (selector.isIndexSet) { |
| 110 keyAssignments.add(info.arguments.positional[0]); | 110 keyAssignments.add(info.arguments.positional[0]); |
| 111 valueAssignments.add(info.arguments.positional[1]); | 111 valueAssignments.add(info.arguments.positional[1]); |
| 112 } else if (!selector.isIndex()) { | 112 } else if (!selector.isIndex) { |
| 113 bailout('Map used in a not-ok selector [$selectorName]'); | 113 bailout('Map used in a not-ok selector [$selectorName]'); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 } else if (selector.isCall() && | 117 } else if (selector.isCall && |
| 118 !info.targets.every((element) => element.isFunction())) { | 118 !info.targets.every((element) => element.isFunction)) { |
| 119 bailout('Passed to a closure'); | 119 bailout('Passed to a closure'); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| OLD | NEW |