| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| 11 /// Iterables of the dependencies that this [TreeElement] records of | 11 /// Iterables of the dependencies that this [TreeElement] records of |
| 12 /// [analyzedElement]. | 12 /// [analyzedElement]. |
| 13 Iterable<Element> get allElements; | 13 Iterable<Element> get allElements; |
| 14 | 14 |
| 15 /// The set of types that this TreeElement depends on. |
| 16 /// This includes instantiated types, types in is-checks and as-expressions |
| 17 /// and in checked mode the types of all type-annotations. |
| 18 Iterable<DartType> get requiredTypes; |
| 19 |
| 15 void forEachConstantNode(f(Node n, ConstantExpression c)); | 20 void forEachConstantNode(f(Node n, ConstantExpression c)); |
| 16 void forEachType(f(Node n, DartType t)); | |
| 17 | 21 |
| 18 /// A set of additional dependencies. See [registerDependency] below. | 22 /// A set of additional dependencies. See [registerDependency] below. |
| 19 Iterable<Element> get otherDependencies; | 23 Iterable<Element> get otherDependencies; |
| 20 | 24 |
| 21 Element operator[](Node node); | 25 Element operator[](Node node); |
| 22 | 26 |
| 23 SendStructure getSendStructure(Send send); | 27 SendStructure getSendStructure(Send send); |
| 24 | 28 |
| 25 // TODO(johnniwinther): Investigate whether [Node] could be a [Send]. | 29 // TODO(johnniwinther): Investigate whether [Node] could be a [Send]. |
| 26 Selector getSelector(Node node); | 30 Selector getSelector(Node node); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 */ | 68 */ |
| 65 bool isTypeLiteral(Send node); | 69 bool isTypeLiteral(Send node); |
| 66 | 70 |
| 67 /// Returns the type that the type literal [node] refers to. | 71 /// Returns the type that the type literal [node] refers to. |
| 68 DartType getTypeLiteralType(Send node); | 72 DartType getTypeLiteralType(Send node); |
| 69 | 73 |
| 70 /// Register additional dependencies required by [analyzedElement]. | 74 /// Register additional dependencies required by [analyzedElement]. |
| 71 /// For example, elements that are used by a backend. | 75 /// For example, elements that are used by a backend. |
| 72 void registerDependency(Element element); | 76 void registerDependency(Element element); |
| 73 | 77 |
| 78 /// Register a dependency on [type]. |
| 79 void addRequiredType(DartType type); |
| 80 |
| 74 /// Returns a list of nodes that potentially mutate [element] anywhere in its | 81 /// Returns a list of nodes that potentially mutate [element] anywhere in its |
| 75 /// scope. | 82 /// scope. |
| 76 List<Node> getPotentialMutations(VariableElement element); | 83 List<Node> getPotentialMutations(VariableElement element); |
| 77 | 84 |
| 78 /// Returns a list of nodes that potentially mutate [element] in [node]. | 85 /// Returns a list of nodes that potentially mutate [element] in [node]. |
| 79 List<Node> getPotentialMutationsIn(Node node, VariableElement element); | 86 List<Node> getPotentialMutationsIn(Node node, VariableElement element); |
| 80 | 87 |
| 81 /// Returns a list of nodes that potentially mutate [element] in a closure. | 88 /// Returns a list of nodes that potentially mutate [element] in a closure. |
| 82 List<Node> getPotentialMutationsInClosure(VariableElement element); | 89 List<Node> getPotentialMutationsInClosure(VariableElement element); |
| 83 | 90 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 105 Setlet<Node> _superUses; | 112 Setlet<Node> _superUses; |
| 106 Setlet<Element> _otherDependencies; | 113 Setlet<Element> _otherDependencies; |
| 107 Map<Node, ConstantExpression> _constants; | 114 Map<Node, ConstantExpression> _constants; |
| 108 Map<VariableElement, List<Node>> _potentiallyMutated; | 115 Map<VariableElement, List<Node>> _potentiallyMutated; |
| 109 Map<Node, Map<VariableElement, List<Node>>> _potentiallyMutatedIn; | 116 Map<Node, Map<VariableElement, List<Node>>> _potentiallyMutatedIn; |
| 110 Map<VariableElement, List<Node>> _potentiallyMutatedInClosure; | 117 Map<VariableElement, List<Node>> _potentiallyMutatedInClosure; |
| 111 Map<Node, Map<VariableElement, List<Node>>> _accessedByClosureIn; | 118 Map<Node, Map<VariableElement, List<Node>>> _accessedByClosureIn; |
| 112 Setlet<Element> _elements; | 119 Setlet<Element> _elements; |
| 113 Setlet<Send> _asserts; | 120 Setlet<Send> _asserts; |
| 114 Maplet<Send, SendStructure> _sendStructureMap; | 121 Maplet<Send, SendStructure> _sendStructureMap; |
| 122 Setlet<DartType> _requiredTypes; |
| 115 | 123 |
| 116 /// Map from nodes to the targets they define. | 124 /// Map from nodes to the targets they define. |
| 117 Map<Node, JumpTarget> _definedTargets; | 125 Map<Node, JumpTarget> _definedTargets; |
| 118 | 126 |
| 119 /// Map from goto statements to their targets. | 127 /// Map from goto statements to their targets. |
| 120 Map<GotoStatement, JumpTarget> _usedTargets; | 128 Map<GotoStatement, JumpTarget> _usedTargets; |
| 121 | 129 |
| 122 /// Map from labels to their label definition. | 130 /// Map from labels to their label definition. |
| 123 Map<Label, LabelDefinition> _definedLabels; | 131 Map<Label, LabelDefinition> _definedLabels; |
| 124 | 132 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 176 |
| 169 void setType(Node node, DartType type) { | 177 void setType(Node node, DartType type) { |
| 170 if (_types == null) { | 178 if (_types == null) { |
| 171 _types = new Maplet<Node, DartType>(); | 179 _types = new Maplet<Node, DartType>(); |
| 172 } | 180 } |
| 173 _types[node] = type; | 181 _types[node] = type; |
| 174 } | 182 } |
| 175 | 183 |
| 176 DartType getType(Node node) => _types != null ? _types[node] : null; | 184 DartType getType(Node node) => _types != null ? _types[node] : null; |
| 177 | 185 |
| 178 void forEachType(f(Node n, DartType t)) { | 186 void addRequiredType(DartType type) { |
| 179 if (_types != null) { | 187 if (_requiredTypes == null) _requiredTypes = new Setlet<DartType>(); |
| 180 _types.forEach(f); | 188 _requiredTypes.add(type); |
| 189 } |
| 190 |
| 191 Iterable<DartType> get requiredTypes { |
| 192 if (_requiredTypes == null) { |
| 193 return const <DartType>[]; |
| 194 } else { |
| 195 return _requiredTypes; |
| 181 } | 196 } |
| 182 } | 197 } |
| 183 | 198 |
| 184 Iterable<Node> get superUses { | 199 Iterable<Node> get superUses { |
| 185 return _superUses != null ? _superUses : const <Node>[]; | 200 return _superUses != null ? _superUses : const <Node>[]; |
| 186 } | 201 } |
| 187 | 202 |
| 188 void addSuperUse(Node node) { | 203 void addSuperUse(Node node) { |
| 189 if (_superUses == null) { | 204 if (_superUses == null) { |
| 190 _superUses = new Setlet<Node>(); | 205 _superUses = new Setlet<Node>(); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 TreeElements get treeElements { | 549 TreeElements get treeElements { |
| 535 assert(invariant(this, _treeElements !=null, | 550 assert(invariant(this, _treeElements !=null, |
| 536 message: "TreeElements have not been computed for $this.")); | 551 message: "TreeElements have not been computed for $this.")); |
| 537 return _treeElements; | 552 return _treeElements; |
| 538 } | 553 } |
| 539 | 554 |
| 540 void reuseElement() { | 555 void reuseElement() { |
| 541 _treeElements = null; | 556 _treeElements = null; |
| 542 } | 557 } |
| 543 } | 558 } |
| OLD | NEW |