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

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

Issue 10823346: Properly rename typedefs. (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/language/language.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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (currentElement is ClassElement) { 324 if (currentElement is ClassElement) {
325 ClassElement classElement = currentElement; 325 ClassElement classElement = currentElement;
326 String typeName = node.typeName.asIdentifier().source.slowToString(); 326 String typeName = node.typeName.asIdentifier().source.slowToString();
327 for (TypeVariableType argument in classElement.type.arguments) { 327 for (TypeVariableType argument in classElement.type.arguments) {
328 // If names are equal, then it's a variable and sholdn't be renamed. 328 // If names are equal, then it's a variable and sholdn't be renamed.
329 if (argument.name.slowToString() == typeName) return; 329 if (argument.name.slowToString() == typeName) return;
330 } 330 }
331 } 331 }
332 } 332 }
333 final type = compiler.resolveTypeAnnotation(currentElement, node); 333 final type = compiler.resolveTypeAnnotation(currentElement, node);
334 if (type is !InterfaceType) return null; 334 if (type is InterfaceType || type is FunctionType) {
335 var target = node.typeName; 335 var target = node.typeName;
336 if (node.typeName is Send) { 336 if (node.typeName is Send) {
337 final element = treeElements[node]; 337 final element = treeElements[node];
338 if (element !== null) { 338 if (element !== null) {
339 final send = node.typeName.asSend(); 339 final send = node.typeName.asSend();
340 Identifier receiver = send.receiver; 340 Identifier receiver = send.receiver;
341 Identifier selector = send.selector; 341 Identifier selector = send.selector;
342 final hasPrefix = element.lookupConstructor( 342 final hasPrefix = element is TypedefElement ||
343 receiver.source, selector.source) === null; 343 element.lookupConstructor(receiver.source, selector.source)
344 if (!hasPrefix) target = send.receiver; 344 === null;
345 if (!hasPrefix) target = send.receiver;
346 }
345 } 347 }
346 } 348 // TODO(antonm): is there a better way to detect unresolved types?
347 // TODO(antonm): is there a better way to detect unresolved types? 349 if (type !== compiler.types.dynamicType) {
348 if (type !== compiler.types.dynamicType) { 350 makeTypePlaceholder(target, type);
349 makeTypePlaceholder(target, type); 351 } else {
350 } else { 352 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
351 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 353 }
352 } 354 }
353 node.visitChildren(this); 355 node.visitChildren(this);
354 } 356 }
355 357
356 visitVariableDefinitions(VariableDefinitions node) { 358 visitVariableDefinitions(VariableDefinitions node) {
357 // Collect only local placeholders. 359 // Collect only local placeholders.
358 if (currentElement is FunctionElement) { 360 if (currentElement is FunctionElement) {
359 for (Node definition in node.definitions.nodes) { 361 for (Node definition in node.definitions.nodes) {
360 Element definitionElement = treeElements[definition]; 362 Element definitionElement = treeElements[definition];
361 // definitionElement may be null if we're inside variable definitions 363 // definitionElement may be null if we're inside variable definitions
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 398 }
397 } 399 }
398 node.visitChildren(this); 400 node.visitChildren(this);
399 } 401 }
400 402
401 visitClassNode(ClassNode node) { 403 visitClassNode(ClassNode node) {
402 assert(currentElement is ClassElement); 404 assert(currentElement is ClassElement);
403 makeElementPlaceholder(node.name, currentElement); 405 makeElementPlaceholder(node.name, currentElement);
404 node.visitChildren(this); 406 node.visitChildren(this);
405 } 407 }
408
409 visitTypedef(Typedef node) {
410 assert(currentElement is TypedefElement);
411 makeElementPlaceholder(node.name, currentElement);
412 node.visitChildren(this);
413 }
406 } 414 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698