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