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 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 } else if (definition is FunctionExpression) { | 492 } else if (definition is FunctionExpression) { |
| 493 // Skip, it will be processed in visitFunctionExpression. | 493 // Skip, it will be processed in visitFunctionExpression. |
| 494 } else { | 494 } else { |
| 495 internalError('Unexpected definition structure $definition'); | 495 internalError('Unexpected definition structure $definition'); |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 node.visitChildren(this); | 498 node.visitChildren(this); |
| 499 } | 499 } |
| 500 | 500 |
| 501 visitFunctionExpression(FunctionExpression node) { | 501 visitFunctionExpression(FunctionExpression node) { |
| 502 bool isKeyword(Identifier id) => | |
| 503 id !== null && Keyword.keywords[id.source.slowToString()] !== null; | |
| 504 | |
| 502 Element element = treeElements[node]; | 505 Element element = treeElements[node]; |
| 503 // May get null here in case of A(int this.f()); | 506 // May get null here in case of A(int this.f()); |
| 504 if (element !== null) { | 507 if (element !== null) { |
| 505 // Rename only local functions. | 508 // Rename only local functions. |
| 506 if (topmostEnclosingFunction === null) { | 509 if (topmostEnclosingFunction === null) { |
| 507 topmostEnclosingFunction = element; | 510 topmostEnclosingFunction = element; |
| 508 } | 511 } |
| 509 if (element !== currentElement) { | 512 if (element !== currentElement) { |
| 510 if (node.name !== null) { | 513 if (node.name !== null) { |
| 511 assert(node.name is Identifier); | 514 assert(node.name is Identifier); |
| 512 tryMakeLocalPlaceholder(element, node.name); | 515 tryMakeLocalPlaceholder(element, node.name); |
| 513 } | 516 } |
| 514 } | 517 } |
| 515 } | 518 } |
| 516 node.visitChildren(this); | 519 node.visitChildren(this); |
| 517 makeOmitDeclarationTypePlaceholder(node.returnType); | 520 // Make sure we don't omit return type of methods which names are |
|
Anton Muhin
2012/09/19 06:51:37
TODO to change that and bug against VM?
Roman
2012/09/19 09:17:36
http://code.google.com/p/dart/issues/detail?id=527
| |
| 521 // identifiers, because the following works fine: | |
| 522 // int interface() => 1; | |
| 523 // But omitting 'int' makes VM unhappy. | |
| 524 if (node.name === null || !isKeyword(node.name.asIdentifier())) { | |
| 525 makeOmitDeclarationTypePlaceholder(node.returnType); | |
| 526 } | |
| 518 collectFunctionParameters(node.parameters); | 527 collectFunctionParameters(node.parameters); |
| 519 } | 528 } |
| 520 | 529 |
| 521 void collectFunctionParameters(NodeList parameters) { | 530 void collectFunctionParameters(NodeList parameters) { |
| 522 if (parameters === null) return; | 531 if (parameters === null) return; |
| 523 for (Node parameter in parameters.nodes) { | 532 for (Node parameter in parameters.nodes) { |
| 524 if (parameter is NodeList) { | 533 if (parameter is NodeList) { |
| 525 // Optional parameter list. | 534 // Optional parameter list. |
| 526 collectFunctionParameters(parameter); | 535 collectFunctionParameters(parameter); |
| 527 } else { | 536 } else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 | 593 |
| 585 visitBlock(Block node) { | 594 visitBlock(Block node) { |
| 586 for (Node statement in node.statements.nodes) { | 595 for (Node statement in node.statements.nodes) { |
| 587 if (statement is VariableDefinitions) { | 596 if (statement is VariableDefinitions) { |
| 588 makeVarDeclarationTypePlaceholder(statement); | 597 makeVarDeclarationTypePlaceholder(statement); |
| 589 } | 598 } |
| 590 } | 599 } |
| 591 node.visitChildren(this); | 600 node.visitChildren(this); |
| 592 } | 601 } |
| 593 } | 602 } |
| OLD | NEW |