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 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
10 class ElementAst { | 10 class ElementAst { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 final newTypedefElementCallback; | 548 final newTypedefElementCallback; |
549 final newClassElementCallback; | 549 final newClassElementCallback; |
550 | 550 |
551 ReferencedElementCollector( | 551 ReferencedElementCollector( |
552 this.compiler, | 552 this.compiler, |
553 Element rootElement, this.treeElements, | 553 Element rootElement, this.treeElements, |
554 this.newTypedefElementCallback, this.newClassElementCallback) | 554 this.newTypedefElementCallback, this.newClassElementCallback) |
555 : this.rootElement = (rootElement is VariableElement) | 555 : this.rootElement = (rootElement is VariableElement) |
556 ? (rootElement as VariableElement).variables : rootElement; | 556 ? (rootElement as VariableElement).variables : rootElement; |
557 | 557 |
558 visitClassNode(ClassNode node) { | |
559 super.visitClassNode(node); | |
560 // Temporary hack which should go away once interfaces | |
561 // and default clauses are out. | |
562 if (node.defaultClause != null) { | |
563 // Resolver cannot resolve parameterized default clauses. | |
564 TypeAnnotation evilCousine = new TypeAnnotation( | |
565 node.defaultClause.typeName, null); | |
566 evilCousine.accept(this); | |
567 } | |
568 } | |
569 | |
570 visitNode(Node node) { node.visitChildren(this); } | 558 visitNode(Node node) { node.visitChildren(this); } |
571 | 559 |
572 visitTypeAnnotation(TypeAnnotation typeAnnotation) { | 560 visitTypeAnnotation(TypeAnnotation typeAnnotation) { |
573 // We call [resolveReturnType] to allow having 'void'. | 561 // We call [resolveReturnType] to allow having 'void'. |
574 final type = compiler.resolveReturnType(rootElement, typeAnnotation); | 562 final type = compiler.resolveReturnType(rootElement, typeAnnotation); |
575 Element typeElement = type.element; | 563 Element typeElement = type.element; |
576 if (typeElement.isTypedef()) newTypedefElementCallback(typeElement); | 564 if (typeElement.isTypedef()) newTypedefElementCallback(typeElement); |
577 if (typeElement.isClass()) newClassElementCallback(typeElement); | 565 if (typeElement.isClass()) newClassElementCallback(typeElement); |
578 typeAnnotation.visitChildren(this); | 566 typeAnnotation.visitChildren(this); |
579 } | 567 } |
(...skipping 14 matching lines...) Expand all Loading... |
594 } | 582 } |
595 | 583 |
596 compareElements(e0, e1) { | 584 compareElements(e0, e1) { |
597 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 585 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
598 if (result != 0) return result; | 586 if (result != 0) return result; |
599 return compareBy((e) => e.position().charOffset)(e0, e1); | 587 return compareBy((e) => e.position().charOffset)(e0, e1); |
600 } | 588 } |
601 | 589 |
602 List<Element> sortElements(Iterable<Element> elements) => | 590 List<Element> sortElements(Iterable<Element> elements) => |
603 sorted(elements, compareElements); | 591 sorted(elements, compareElements); |
OLD | NEW |