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

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

Issue 10866017: dart2dart Fix type variables rename (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 } 436 }
437 } 437 }
438 node.visitChildren(this); 438 node.visitChildren(this);
439 } 439 }
440 440
441 visitClassNode(ClassNode node) { 441 visitClassNode(ClassNode node) {
442 assert(currentElement is ClassElement); 442 assert(currentElement is ClassElement);
443 makeElementPlaceholder(node.name, currentElement); 443 makeElementPlaceholder(node.name, currentElement);
444 node.visitChildren(this); 444 node.visitChildren(this);
445 if (node.typeParameters !== null) {
446 // Another poor man resolution.
447 final typeVariableTypes =
448 new List<Type>.from(currentElement.typeVariables);
449 int i = 0;
450 for (TypeVariable typeVariable in node.typeParameters) {
451 makeTypePlaceholder(typeVariable.name, typeVariableTypes[i]);
452 i++;
453 }
454 }
455 if (node.defaultClause !== null) { 445 if (node.defaultClause !== null) {
456 // Can't just visit class node's default clause because of the bug in the 446 // Can't just visit class node's default clause because of the bug in the
457 // resolver, it just crashes when it meets type variable. 447 // resolver, it just crashes when it meets type variable.
458 Type defaultType = (currentElement as ClassElement).defaultClass; 448 Type defaultType = (currentElement as ClassElement).defaultClass;
459 assert(defaultType !== null); 449 assert(defaultType !== null);
460 makeTypePlaceholder(node.defaultClause.typeName, defaultType); 450 makeTypePlaceholder(node.defaultClause.typeName, defaultType);
461 visit(node.defaultClause.typeArguments); 451 visit(node.defaultClause.typeArguments);
462 } 452 }
463 } 453 }
464 454
455 visitTypeVariable(TypeVariable node) {
Anton Muhin 2012/08/22 12:34:53 it fixes a case with typedefs too?
Roman 2012/08/22 12:38:22 Yes, there's a test for it in unparser_test. At fi
456 assert(currentElement is TypedefElement || currentElement is ClassElement);
457 // Another poor man type resolution.
458 // Find this variable in current element type parameters.
459 for (Type type in currentElement.typeVariables) {
460 if (type.name.slowToString() == node.name.source.slowToString()) {
461 makeTypePlaceholder(node.name, type);
462 break;
463 }
464 }
465 node.visitChildren(this);
466 }
467
465 visitTypedef(Typedef node) { 468 visitTypedef(Typedef node) {
466 assert(currentElement is TypedefElement); 469 assert(currentElement is TypedefElement);
467 makeElementPlaceholder(node.name, currentElement); 470 makeElementPlaceholder(node.name, currentElement);
468 node.visitChildren(this); 471 node.visitChildren(this);
469 } 472 }
470 } 473 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698