Chromium Code Reviews| 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 part of dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 class LocalPlaceholder { | 7 class LocalPlaceholder { |
| 8 final String identifier; | 8 final String identifier; |
| 9 final Set<Node> nodes; | 9 final Set<Node> nodes; |
| 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 makeVarDeclarationTypePlaceholder(definitions); | 237 makeVarDeclarationTypePlaceholder(definitions); |
| 238 } else { | 238 } else { |
| 239 assert(element is ClassElement || element is TypedefElement); | 239 assert(element is ClassElement || element is TypedefElement); |
| 240 } | 240 } |
| 241 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); | 241 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); |
| 242 compiler.withCurrentElement(element, () { | 242 compiler.withCurrentElement(element, () { |
| 243 elementNode.accept(this); | 243 elementNode.accept(this); |
| 244 }); | 244 }); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // TODO(karlklose): should we create placeholders for these? | |
| 248 bool isTypedefParameter(Element element) { | |
| 249 return element != null && | |
| 250 element.enclosingElement != null && | |
| 251 element.enclosingElement.isTypedef(); | |
| 252 } | |
| 253 | |
| 247 void tryMakeLocalPlaceholder(Element element, Identifier node) { | 254 void tryMakeLocalPlaceholder(Element element, Identifier node) { |
| 248 bool isNamedOptionalParameter() { | 255 bool isNamedOptionalParameter() { |
| 249 FunctionElement function = element.enclosingElement; | 256 FunctionElement function = element.enclosingElement; |
| 250 FunctionSignature signature = function.functionSignature; | 257 FunctionSignature signature = function.functionSignature; |
| 251 if (!signature.optionalParametersAreNamed) return false; | 258 if (!signature.optionalParametersAreNamed) return false; |
| 252 for (Element parameter in signature.optionalParameters) { | 259 for (Element parameter in signature.optionalParameters) { |
| 253 if (identical(parameter, element)) return true; | 260 if (identical(parameter, element)) return true; |
| 254 } | 261 } |
| 255 return false; | 262 return false; |
| 256 } | 263 } |
| 257 | 264 |
| 258 // TODO(smok): Maybe we should rename privates as well, their privacy | 265 // TODO(smok): Maybe we should rename privates as well, their privacy |
| 259 // should not matter if they are local vars. | 266 // should not matter if they are local vars. |
| 260 if (node.source.isPrivate()) return; | 267 if (node.source.isPrivate()) return; |
| 261 if (element.isParameter() && isNamedOptionalParameter()) { | 268 if (element.isParameter() && !isTypedefParameter(element) && |
| 269 isNamedOptionalParameter()) { | |
| 262 currentFunctionScope.registerParameter(node); | 270 currentFunctionScope.registerParameter(node); |
| 263 } else if (Elements.isLocal(element)) { | 271 } else if (Elements.isLocal(element) && !isTypedefParameter(element)) { |
|
Johnni Winther
2013/09/23 08:06:18
How can this happen?
karlklose
2013/09/23 08:09:52
Typedef parameters are parameters that are not ins
| |
| 264 makeLocalPlaceholder(node); | 272 makeLocalPlaceholder(node); |
| 265 } | 273 } |
| 266 } | 274 } |
| 267 | 275 |
| 268 void tryMakeMemberPlaceholder(Identifier node) { | 276 void tryMakeMemberPlaceholder(Identifier node) { |
| 269 assert(node != null); | 277 assert(node != null); |
| 270 if (node.source.isPrivate()) return; | 278 if (node.source.isPrivate()) return; |
| 271 if (node is Operator) return; | 279 if (node is Operator) return; |
| 272 final identifier = node.source.slowToString(); | 280 final identifier = node.source.slowToString(); |
| 273 if (fixedMemberNames.contains(identifier)) return; | 281 if (fixedMemberNames.contains(identifier)) return; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 | 634 |
| 627 visitBlock(Block node) { | 635 visitBlock(Block node) { |
| 628 for (Node statement in node.statements.nodes) { | 636 for (Node statement in node.statements.nodes) { |
| 629 if (statement is VariableDefinitions) { | 637 if (statement is VariableDefinitions) { |
| 630 makeVarDeclarationTypePlaceholder(statement); | 638 makeVarDeclarationTypePlaceholder(statement); |
| 631 } | 639 } |
| 632 } | 640 } |
| 633 node.visitChildren(this); | 641 node.visitChildren(this); |
| 634 } | 642 } |
| 635 } | 643 } |
| OLD | NEW |