| 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 nullNodes.add(node); | 303 nullNodes.add(node); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void makeElementPlaceholder(Node node, Element element) { | 306 void makeElementPlaceholder(Node node, Element element) { |
| 307 assert(element != null); | 307 assert(element != null); |
| 308 if (identical(element, entryFunction)) return; | 308 if (identical(element, entryFunction)) return; |
| 309 if (identical(element.getLibrary(), coreLibrary)) return; | 309 if (identical(element.getLibrary(), coreLibrary)) return; |
| 310 if (element.getLibrary().isPlatformLibrary && !element.isTopLevel()) { | 310 if (element.getLibrary().isPlatformLibrary && !element.isTopLevel()) { |
| 311 return; | 311 return; |
| 312 } | 312 } |
| 313 if (element == compiler.types.dynamicType.element) { | 313 if (element == compiler.dynamicClass) { |
| 314 internalError( | 314 internalError( |
| 315 'Should never make element placeholder for dynamic type element', | 315 'Should never make element placeholder for dynamic type element', |
| 316 node: node); | 316 node: node); |
| 317 } | 317 } |
| 318 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); | 318 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void makePrivateIdentifier(Identifier node) { | 321 void makePrivateIdentifier(Identifier node) { |
| 322 assert(node != null); | 322 assert(node != null); |
| 323 privateNodes.putIfAbsent( | 323 privateNodes.putIfAbsent( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 358 } |
| 359 | 359 |
| 360 void unreachable() { internalError('Unreachable case'); } | 360 void unreachable() { internalError('Unreachable case'); } |
| 361 | 361 |
| 362 visit(Node node) => (node == null) ? null : node.accept(this); | 362 visit(Node node) => (node == null) ? null : node.accept(this); |
| 363 | 363 |
| 364 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. | 364 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. |
| 365 | 365 |
| 366 visitNewExpression(NewExpression node) { | 366 visitNewExpression(NewExpression node) { |
| 367 Send send = node.send; | 367 Send send = node.send; |
| 368 InterfaceType type = treeElements.getType(node); | 368 DartType type = treeElements.getType(node); |
| 369 assert(type != null); | 369 assert(type != null); |
| 370 Element constructor = treeElements[send]; | 370 Element constructor = treeElements[send]; |
| 371 assert(constructor != null); | 371 assert(constructor != null); |
| 372 assert(send.receiver == null); | 372 assert(send.receiver == null); |
| 373 if (!Elements.isErroneousElement(constructor)) { | 373 if (!Elements.isErroneousElement(constructor)) { |
| 374 makeConstructorPlaceholder(node.send.selector, constructor, type); | 374 makeConstructorPlaceholder(node.send.selector, constructor, type); |
| 375 // TODO(smok): Should this be in visitNamedArgument? | 375 // TODO(smok): Should this be in visitNamedArgument? |
| 376 // Field names can be exposed as names of optional arguments, e.g. | 376 // Field names can be exposed as names of optional arguments, e.g. |
| 377 // class C { | 377 // class C { |
| 378 // final field; | 378 // final field; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 typeDeclarationElement, node.typeName)) { | 474 typeDeclarationElement, node.typeName)) { |
| 475 return; | 475 return; |
| 476 } | 476 } |
| 477 // We call [resolveReturnType] to allow having 'void'. | 477 // We call [resolveReturnType] to allow having 'void'. |
| 478 final type = compiler.resolveReturnType(currentElement, node); | 478 final type = compiler.resolveReturnType(currentElement, node); |
| 479 if (type is InterfaceType || type is TypedefType) { | 479 if (type is InterfaceType || type is TypedefType) { |
| 480 // TODO(antonm): is there a better way to detect unresolved types? | 480 // TODO(antonm): is there a better way to detect unresolved types? |
| 481 // Corner case: dart:core type with a prefix. | 481 // Corner case: dart:core type with a prefix. |
| 482 // Most probably there are some additional problems with | 482 // Most probably there are some additional problems with |
| 483 // coreLibPrefix.topLevels. | 483 // coreLibPrefix.topLevels. |
| 484 if (!identical(type.element, compiler.types.dynamicType.element)) { | 484 if (!type.treatAsDynamic) { |
| 485 makeTypePlaceholder(node.typeName, type); | 485 makeTypePlaceholder(node.typeName, type); |
| 486 } else { | 486 } else { |
| 487 if (!isDynamicType(node)) makeUnresolvedPlaceholder(node.typeName); | 487 if (!isDynamicType(node)) makeUnresolvedPlaceholder(node.typeName); |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 // Visit only type arguments, otherwise in case of lib.Class type | 490 // Visit only type arguments, otherwise in case of lib.Class type |
| 491 // annotation typeName is Send and we go to visitGetterSend, as a result | 491 // annotation typeName is Send and we go to visitGetterSend, as a result |
| 492 // "Class" is added to member placeholders. | 492 // "Class" is added to member placeholders. |
| 493 visit(node.typeArguments); | 493 visit(node.typeArguments); |
| 494 } | 494 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 visitBlock(Block node) { | 616 visitBlock(Block node) { |
| 617 for (Node statement in node.statements.nodes) { | 617 for (Node statement in node.statements.nodes) { |
| 618 if (statement is VariableDefinitions) { | 618 if (statement is VariableDefinitions) { |
| 619 makeVarDeclarationTypePlaceholder(statement); | 619 makeVarDeclarationTypePlaceholder(statement); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 node.visitChildren(this); | 622 node.visitChildren(this); |
| 623 } | 623 } |
| 624 } | 624 } |
| OLD | NEW |