| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class LocalPlaceholder implements Hashable { | 5 class LocalPlaceholder implements Hashable { |
| 6 final String identifier; | 6 final String identifier; |
| 7 final Set<Node> nodes; | 7 final Set<Node> nodes; |
| 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
| 9 int hashCode() => identifier.hashCode(); | 9 int hashCode() => identifier.hashCode(); |
| 10 String toString() => | 10 String toString() => |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 for (Node definition in node.definitions) { | 168 for (Node definition in node.definitions) { |
| 169 if (definition is Identifier) { | 169 if (definition is Identifier) { |
| 170 tryMakePrivateIdentifier(definition.asIdentifier()); | 170 tryMakePrivateIdentifier(definition.asIdentifier()); |
| 171 } else if (definition is SendSet) { | 171 } else if (definition is SendSet) { |
| 172 tryMakePrivateIdentifier( | 172 tryMakePrivateIdentifier( |
| 173 definition.asSendSet().selector.asIdentifier()); | 173 definition.asSendSet().selector.asIdentifier()); |
| 174 } else { | 174 } else { |
| 175 internalError('Unreachable case'); | 175 internalError('Unreachable case'); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } else if (element.isTopLevel()) { |
| 179 Node fieldNode = element.parseNode(compiler); |
| 180 if (fieldNode is Identifier) { |
| 181 makeElementPlaceholder(fieldNode, element); |
| 182 } else if (fieldNode is SendSet) { |
| 183 makeElementPlaceholder(fieldNode.selector, element); |
| 184 } else { |
| 185 internalError('Unreachable case'); |
| 186 } |
| 178 } | 187 } |
| 179 } | 188 } |
| 180 | 189 |
| 181 void collect(Element element, TreeElements elements) { | 190 void collect(Element element, TreeElements elements) { |
| 182 treeElements = elements; | 191 treeElements = elements; |
| 183 Node elementNode; | 192 Node elementNode; |
| 184 if (element is FunctionElement) { | 193 if (element is FunctionElement) { |
| 185 currentElement = element; | 194 currentElement = element; |
| 186 elementNode = currentElement.parseNode(compiler); | 195 elementNode = currentElement.parseNode(compiler); |
| 187 collectFunctionDeclarationPlaceholders(element, elementNode); | 196 collectFunctionDeclarationPlaceholders(element, elementNode); |
| 188 } else if (element.isField()) { | 197 } else if (element.isField()) { |
| 189 // TODO(smok): In the future make sure we don't process same | 198 // TODO(smok): In the future make sure we don't process same |
| 190 // variable list element twice, better merge this with emitter logic. | 199 // variable list element twice, better merge this with emitter logic. |
| 191 currentElement = (element as VariableElement).variables; | 200 currentElement = (element as VariableElement).variables; |
| 192 elementNode = currentElement.parseNode(compiler); | 201 elementNode = currentElement.parseNode(compiler); |
| 202 // We don't collect other elements from the same variable lists |
| 203 // if they are not used. http://dartbug.com/4536 |
| 193 collectFieldDeclarationPlaceholders(element, elementNode); | 204 collectFieldDeclarationPlaceholders(element, elementNode); |
| 194 } else if (element is ClassElement || element is TypedefElement) { | 205 } else if (element is ClassElement || element is TypedefElement) { |
| 195 currentElement = element; | 206 currentElement = element; |
| 196 elementNode = currentElement.parseNode(compiler); | 207 elementNode = currentElement.parseNode(compiler); |
| 197 } else { | 208 } else { |
| 198 assert(false); // Unreachable. | 209 assert(false); // Unreachable. |
| 199 } | 210 } |
| 200 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); | 211 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); |
| 201 compiler.withCurrentElement(element, () { | 212 compiler.withCurrentElement(element, () { |
| 202 elementNode.accept(this); | 213 elementNode.accept(this); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 makeElementPlaceholder(node.name, currentElement); | 416 makeElementPlaceholder(node.name, currentElement); |
| 406 node.visitChildren(this); | 417 node.visitChildren(this); |
| 407 } | 418 } |
| 408 | 419 |
| 409 visitTypedef(Typedef node) { | 420 visitTypedef(Typedef node) { |
| 410 assert(currentElement is TypedefElement); | 421 assert(currentElement is TypedefElement); |
| 411 makeElementPlaceholder(node.name, currentElement); | 422 makeElementPlaceholder(node.name, currentElement); |
| 412 node.visitChildren(this); | 423 node.visitChildren(this); |
| 413 } | 424 } |
| 414 } | 425 } |
| OLD | NEW |