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 30 matching lines...) Expand all Loading... |
41 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); | 41 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); |
42 } | 42 } |
43 | 43 |
44 class SendVisitor extends ResolvedVisitor { | 44 class SendVisitor extends ResolvedVisitor { |
45 final PlaceholderCollector collector; | 45 final PlaceholderCollector collector; |
46 | 46 |
47 get compiler => collector.compiler; | 47 get compiler => collector.compiler; |
48 | 48 |
49 SendVisitor(this.collector, TreeElements elements) : super(elements); | 49 SendVisitor(this.collector, TreeElements elements) : super(elements); |
50 | 50 |
51 visitOperatorSend(Send node) {} | 51 visitOperatorSend(Send node) { |
| 52 if (node.isParameterCheck) { |
| 53 final element = elements[node.receiver]; |
| 54 if (element != null) { |
| 55 collector.tryMakeLocalPlaceholder(element, node.receiver); |
| 56 } |
| 57 } |
| 58 } |
| 59 |
52 visitForeignSend(Send node) {} | 60 visitForeignSend(Send node) {} |
53 | 61 |
54 visitSuperSend(Send node) { | 62 visitSuperSend(Send node) { |
55 Element element = elements[node]; | 63 Element element = elements[node]; |
56 if (element != null && element.isConstructor()) { | 64 if (element != null && element.isConstructor()) { |
57 collector.makeRedirectingConstructorPlaceholder(node.selector, element); | 65 collector.makeRedirectingConstructorPlaceholder(node.selector, element); |
58 } else { | 66 } else { |
59 collector.tryMakeMemberPlaceholder(node.selector); | 67 collector.tryMakeMemberPlaceholder(node.selector); |
60 } | 68 } |
61 } | 69 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } else { | 237 } else { |
230 assert(element is ClassElement || element is TypedefElement); | 238 assert(element is ClassElement || element is TypedefElement); |
231 } | 239 } |
232 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); | 240 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); |
233 compiler.withCurrentElement(element, () { | 241 compiler.withCurrentElement(element, () { |
234 elementNode.accept(this); | 242 elementNode.accept(this); |
235 }); | 243 }); |
236 } | 244 } |
237 | 245 |
238 void tryMakeLocalPlaceholder(Element element, Identifier node) { | 246 void tryMakeLocalPlaceholder(Element element, Identifier node) { |
239 bool isOptionalParameter() { | 247 bool isNamedOptionalParameter() { |
240 FunctionElement function = element.enclosingElement; | 248 FunctionElement function = element.enclosingElement; |
241 for (Element parameter in function.functionSignature.optionalParameters) { | 249 FunctionSignature signature = function.functionSignature; |
| 250 if (!signature.optionalParametersAreNamed) return false; |
| 251 for (Element parameter in signature.optionalParameters) { |
242 if (identical(parameter, element)) return true; | 252 if (identical(parameter, element)) return true; |
243 } | 253 } |
244 return false; | 254 return false; |
245 } | 255 } |
246 | 256 |
247 // TODO(smok): Maybe we should rename privates as well, their privacy | 257 // TODO(smok): Maybe we should rename privates as well, their privacy |
248 // should not matter if they are local vars. | 258 // should not matter if they are local vars. |
249 if (node.source.isPrivate()) return; | 259 if (node.source.isPrivate()) return; |
250 if (element.isParameter() && isOptionalParameter()) { | 260 if (element.isParameter() && isNamedOptionalParameter()) { |
251 currentFunctionScope.registerParameter(node); | 261 currentFunctionScope.registerParameter(node); |
252 } else if (Elements.isLocal(element)) { | 262 } else if (Elements.isLocal(element)) { |
253 makeLocalPlaceholder(node); | 263 makeLocalPlaceholder(node); |
254 } | 264 } |
255 } | 265 } |
256 | 266 |
257 void tryMakeMemberPlaceholder(Identifier node) { | 267 void tryMakeMemberPlaceholder(Identifier node) { |
258 assert(node != null); | 268 assert(node != null); |
259 if (node.source.isPrivate()) return; | 269 if (node.source.isPrivate()) return; |
260 if (node is Operator) return; | 270 if (node is Operator) return; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 621 |
612 visitBlock(Block node) { | 622 visitBlock(Block node) { |
613 for (Node statement in node.statements.nodes) { | 623 for (Node statement in node.statements.nodes) { |
614 if (statement is VariableDefinitions) { | 624 if (statement is VariableDefinitions) { |
615 makeVarDeclarationTypePlaceholder(statement); | 625 makeVarDeclarationTypePlaceholder(statement); |
616 } | 626 } |
617 } | 627 } |
618 node.visitChildren(this); | 628 node.visitChildren(this); |
619 } | 629 } |
620 } | 630 } |
OLD | NEW |