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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 * 2) The code has typedefs in right hand side of IS checks, | 130 * 2) The code has typedefs in right hand side of IS checks, |
131 * 3) The code has classes which extend typedefs, have type arguments typedefs | 131 * 3) The code has classes which extend typedefs, have type arguments typedefs |
132 * or type variable bounds typedefs. | 132 * or type variable bounds typedefs. |
133 * These restrictions can be less strict. | 133 * These restrictions can be less strict. |
134 */ | 134 */ |
135 bool isSafeToRemoveTypeDeclarations( | 135 bool isSafeToRemoveTypeDeclarations( |
136 Map<ClassElement, Set<Element>> classMembers) { | 136 Map<ClassElement, Set<Element>> classMembers) { |
137 Set<DartType> processedTypes = new Set<DartType>(); | 137 Set<DartType> processedTypes = new Set<DartType>(); |
138 List<DartType> workQueue = new List<DartType>(); | 138 List<DartType> workQueue = new List<DartType>(); |
139 workQueue.addAll( | 139 workQueue.addAll( |
140 classMembers.keys.mappedBy((classElement) => classElement.thisType)); | 140 classMembers.keys.map((classElement) => classElement.thisType)); |
141 workQueue.addAll(compiler.resolverWorld.isChecks); | 141 workQueue.addAll(compiler.resolverWorld.isChecks); |
142 Element typeErrorElement = | 142 Element typeErrorElement = |
143 compiler.coreLibrary.find(new SourceString('TypeError')); | 143 compiler.coreLibrary.find(new SourceString('TypeError')); |
144 DartType typeErrorType = typeErrorElement.computeType(compiler); | 144 DartType typeErrorType = typeErrorElement.computeType(compiler); |
145 if (workQueue.indexOf(typeErrorType) != -1) { | 145 if (workQueue.indexOf(typeErrorType) != -1) { |
146 return false; | 146 return false; |
147 } | 147 } |
148 | 148 |
149 void processTypeArguments(Element classElement, NodeList typeArguments) { | 149 void processTypeArguments(Element classElement, NodeList typeArguments) { |
150 if (typeArguments == null) return; | 150 if (typeArguments == null) return; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 584 } |
585 | 585 |
586 compareElements(e0, e1) { | 586 compareElements(e0, e1) { |
587 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 587 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
588 if (result != 0) return result; | 588 if (result != 0) return result; |
589 return compareBy((e) => e.position().charOffset)(e0, e1); | 589 return compareBy((e) => e.position().charOffset)(e0, e1); |
590 } | 590 } |
591 | 591 |
592 List<Element> sortElements(Iterable<Element> elements) => | 592 List<Element> sortElements(Iterable<Element> elements) => |
593 sorted(elements, compareElements); | 593 sorted(elements, compareElements); |
OLD | NEW |