OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.tree_elements; | 5 library dart2js.resolution.tree_elements; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../diagnostics/source_span.dart'; |
10 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
11 import '../types/types.dart' show | 12 import '../types/types.dart' show |
12 TypeMask; | 13 TypeMask; |
13 import '../tree/tree.dart'; | 14 import '../tree/tree.dart'; |
14 import '../util/util.dart'; | 15 import '../util/util.dart'; |
15 import '../universe/selector.dart' show | 16 import '../universe/selector.dart' show |
16 Selector; | 17 Selector; |
17 | 18 |
18 import 'secret_tree_element.dart' show | 19 import 'secret_tree_element.dart' show |
19 getTreeElement, | 20 getTreeElement, |
20 setTreeElement; | 21 setTreeElement; |
21 import 'send_structure.dart'; | 22 import 'send_structure.dart'; |
22 | 23 |
23 abstract class TreeElements { | 24 abstract class TreeElements { |
24 AnalyzableElement get analyzedElement; | 25 AnalyzableElement get analyzedElement; |
25 Iterable<Node> get superUses; | 26 Iterable<SourceSpan> get superUses; |
26 | 27 |
27 void forEachConstantNode(f(Node n, ConstantExpression c)); | 28 void forEachConstantNode(f(Node n, ConstantExpression c)); |
28 | 29 |
29 Element operator[](Node node); | 30 Element operator[](Node node); |
30 Map<Node, DartType> get typesCache; | 31 Map<Node, DartType> get typesCache; |
31 | 32 |
32 /// Returns the [SendStructure] that describes the semantics of [node]. | 33 /// Returns the [SendStructure] that describes the semantics of [node]. |
33 SendStructure getSendStructure(Send node); | 34 SendStructure getSendStructure(Send node); |
34 | 35 |
35 /// Returns the [NewStructure] that describes the semantics of [node]. | 36 /// Returns the [NewStructure] that describes the semantics of [node]. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 /// `true` if the [analyzedElement]'s source code contains a [TryStatement]. | 105 /// `true` if the [analyzedElement]'s source code contains a [TryStatement]. |
105 bool get containsTryStatement; | 106 bool get containsTryStatement; |
106 } | 107 } |
107 | 108 |
108 class TreeElementMapping extends TreeElements { | 109 class TreeElementMapping extends TreeElements { |
109 final AnalyzableElement analyzedElement; | 110 final AnalyzableElement analyzedElement; |
110 Map<Spannable, Selector> _selectors; | 111 Map<Spannable, Selector> _selectors; |
111 Map<Spannable, TypeMask> _typeMasks; | 112 Map<Spannable, TypeMask> _typeMasks; |
112 Map<Node, DartType> _types; | 113 Map<Node, DartType> _types; |
113 Map<Node, DartType> typesCache = <Node, DartType>{}; | 114 Map<Node, DartType> typesCache = <Node, DartType>{}; |
114 Setlet<Node> _superUses; | 115 Setlet<SourceSpan> _superUses; |
115 Map<Node, ConstantExpression> _constants; | 116 Map<Node, ConstantExpression> _constants; |
116 Map<VariableElement, List<Node>> _potentiallyMutated; | 117 Map<VariableElement, List<Node>> _potentiallyMutated; |
117 Map<Node, Map<VariableElement, List<Node>>> _potentiallyMutatedIn; | 118 Map<Node, Map<VariableElement, List<Node>>> _potentiallyMutatedIn; |
118 Map<VariableElement, List<Node>> _potentiallyMutatedInClosure; | 119 Map<VariableElement, List<Node>> _potentiallyMutatedInClosure; |
119 Map<Node, Map<VariableElement, List<Node>>> _accessedByClosureIn; | 120 Map<Node, Map<VariableElement, List<Node>>> _accessedByClosureIn; |
120 Maplet<Send, SendStructure> _sendStructureMap; | 121 Maplet<Send, SendStructure> _sendStructureMap; |
121 Maplet<NewExpression, NewStructure> _newStructureMap; | 122 Maplet<NewExpression, NewStructure> _newStructureMap; |
122 bool containsTryStatement = false; | 123 bool containsTryStatement = false; |
123 | 124 |
124 /// Map from nodes to the targets they define. | 125 /// Map from nodes to the targets they define. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 185 |
185 void setType(Node node, DartType type) { | 186 void setType(Node node, DartType type) { |
186 if (_types == null) { | 187 if (_types == null) { |
187 _types = new Maplet<Node, DartType>(); | 188 _types = new Maplet<Node, DartType>(); |
188 } | 189 } |
189 _types[node] = type; | 190 _types[node] = type; |
190 } | 191 } |
191 | 192 |
192 DartType getType(Node node) => _types != null ? _types[node] : null; | 193 DartType getType(Node node) => _types != null ? _types[node] : null; |
193 | 194 |
194 Iterable<Node> get superUses { | 195 Iterable<SourceSpan> get superUses { |
195 return _superUses != null ? _superUses : const <Node>[]; | 196 return _superUses != null ? _superUses : const <SourceSpan>[]; |
196 } | 197 } |
197 | 198 |
198 void addSuperUse(Node node) { | 199 void addSuperUse(SourceSpan span) { |
199 if (_superUses == null) { | 200 if (_superUses == null) { |
200 _superUses = new Setlet<Node>(); | 201 _superUses = new Setlet<SourceSpan>(); |
201 } | 202 } |
202 _superUses.add(node); | 203 _superUses.add(span); |
203 } | 204 } |
204 | 205 |
205 Selector _getSelector(Spannable node) { | 206 Selector _getSelector(Spannable node) { |
206 return _selectors != null ? _selectors[node] : null; | 207 return _selectors != null ? _selectors[node] : null; |
207 } | 208 } |
208 | 209 |
209 void _setSelector(Spannable node, Selector selector) { | 210 void _setSelector(Spannable node, Selector selector) { |
210 if (_selectors == null) { | 211 if (_selectors == null) { |
211 _selectors = new Maplet<Spannable, Selector>(); | 212 _selectors = new Maplet<Spannable, Selector>(); |
212 } | 213 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 467 } |
467 | 468 |
468 void setCurrentTypeMask(ForIn node, TypeMask mask) { | 469 void setCurrentTypeMask(ForIn node, TypeMask mask) { |
469 _setTypeMask(node.inToken, mask); | 470 _setTypeMask(node.inToken, mask); |
470 } | 471 } |
471 | 472 |
472 TypeMask getCurrentTypeMask(ForIn node) { | 473 TypeMask getCurrentTypeMask(ForIn node) { |
473 return _getTypeMask(node.inToken); | 474 return _getTypeMask(node.inToken); |
474 } | 475 } |
475 } | 476 } |
OLD | NEW |