Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: lib/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 10917298: [dart2dart] Cut declaration types by default if we check that it is safe to do so. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
521 // identifiers, because the following works fine:
522 // int interface() => 1;
523 // But omitting 'int' makes VM unhappy.
524 // TODO(smok): Remove it when http://dartbug.com/5278 is fixed.
525 if (node.name === null || !isKeyword(node.name.asIdentifier())) {
526 makeOmitDeclarationTypePlaceholder(node.returnType);
527 }
518 collectFunctionParameters(node.parameters); 528 collectFunctionParameters(node.parameters);
519 } 529 }
520 530
521 void collectFunctionParameters(NodeList parameters) { 531 void collectFunctionParameters(NodeList parameters) {
522 if (parameters === null) return; 532 if (parameters === null) return;
523 for (Node parameter in parameters.nodes) { 533 for (Node parameter in parameters.nodes) {
524 if (parameter is NodeList) { 534 if (parameter is NodeList) {
525 // Optional parameter list. 535 // Optional parameter list.
526 collectFunctionParameters(parameter); 536 collectFunctionParameters(parameter);
527 } else { 537 } else {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 594
585 visitBlock(Block node) { 595 visitBlock(Block node) {
586 for (Node statement in node.statements.nodes) { 596 for (Node statement in node.statements.nodes) {
587 if (statement is VariableDefinitions) { 597 if (statement is VariableDefinitions) {
588 makeVarDeclarationTypePlaceholder(statement); 598 makeVarDeclarationTypePlaceholder(statement);
589 } 599 }
590 } 600 }
591 node.visitChildren(this); 601 node.visitChildren(this);
592 } 602 }
593 } 603 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698