| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Test of Compiler.forgetElement. | 5 // Test of Compiler.forgetElement. |
| 6 library trydart.forget_element_test; | 6 library trydart.forget_element_test; |
| 7 | 7 |
| 8 import 'package:compiler/src/elements/elements.dart' show | 8 import 'package:compiler/src/elements/elements.dart' show |
| 9 AstElement, | 9 AstElement, |
| 10 ClassElement, | 10 ClassElement, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 for (MetadataAnnotation metadata in e.metadata) { | 191 for (MetadataAnnotation metadata in e.metadata) { |
| 192 if (metadata is PartialMetadataAnnotation) { | 192 if (metadata is PartialMetadataAnnotation) { |
| 193 if (metadata.cachedNode != null) { | 193 if (metadata.cachedNode != null) { |
| 194 metadata.cachedNode.accept(collector); | 194 metadata.cachedNode.accept(collector); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 }); | 198 }); |
| 199 | 199 |
| 200 List<MetadataAnnotation> metadata = | 200 List<MetadataAnnotation> metadata = |
| 201 (new MetadataCollector()..visit(library)).metadata; | 201 (new MetadataCollector()..visit(library, null)).metadata; |
| 202 return collector.nodes; | 202 return collector.nodes; |
| 203 } | 203 } |
| 204 | 204 |
| 205 Iterable constantsIn(LibraryElement library) { | 205 Iterable constantsIn(LibraryElement library) { |
| 206 return nodesIn(library) | 206 return nodesIn(library) |
| 207 .map((node) => backend.constants.nodeConstantMap[node]) | 207 .map((node) => backend.constants.nodeConstantMap[node]) |
| 208 .where((constant) => constant != null); | 208 .where((constant) => constant != null); |
| 209 } | 209 } |
| 210 | 210 |
| 211 Iterable elementsWithJsInitialValuesIn(LibraryElement library) { | 211 Iterable elementsWithJsInitialValuesIn(LibraryElement library) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 void visitNode(tree.Node node) { | 276 void visitNode(tree.Node node) { |
| 277 nodes.add(node); | 277 nodes.add(node); |
| 278 node.visitChildren(this); | 278 node.visitChildren(this); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 class MetadataCollector extends ElementVisitor { | 282 class MetadataCollector extends ElementVisitor { |
| 283 final List<MetadataAnnotation> metadata = <MetadataAnnotation>[]; | 283 final List<MetadataAnnotation> metadata = <MetadataAnnotation>[]; |
| 284 | 284 |
| 285 void visitElement(Element e) { | 285 void visitElement(Element e, _) { |
| 286 metadata.addAll(e.metadata.toList()); | 286 metadata.addAll(e.metadata.toList()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void visitScopeContainerElement(ScopeContainerElement e) { | 289 void visitScopeContainerElement(ScopeContainerElement e, _) { |
| 290 super.visitScopeContainerElement(e); | 290 super.visitScopeContainerElement(e); |
| 291 e.forEachLocalMember(this.visit); | 291 e.forEachLocalMember(this.visit); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void visitFunctionElement(FunctionElement e) { | 294 void visitFunctionElement(FunctionElement e, _) { |
| 295 super.visitFunctionElement(e); | 295 super.visitFunctionElement(e); |
| 296 if (e.hasFunctionSignature) { | 296 if (e.hasFunctionSignature) { |
| 297 e.functionSignature.forEachParameter(this.visit); | 297 e.functionSignature.forEachParameter(this.visit); |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 void main() { | 302 void main() { |
| 303 runTests(tests); | 303 runTests(tests); |
| 304 } | 304 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 // correctly (deeply nested function). | 395 // correctly (deeply nested function). |
| 396 new ForgetElementTestCase( | 396 new ForgetElementTestCase( |
| 397 'main() => (() => (([x = const Constant()]) => x)())();' | 397 'main() => (() => (([x = const Constant()]) => x)())();' |
| 398 ' $CONSTANT_CLASS', | 398 ' $CONSTANT_CLASS', |
| 399 closureCount: 2, | 399 closureCount: 2, |
| 400 constantCount: 1, | 400 constantCount: 1, |
| 401 initialValueCount: 1), | 401 initialValueCount: 1), |
| 402 | 402 |
| 403 // TODO(ahe): Add test for super sends [backend.aliasedSuperMembers]. | 403 // TODO(ahe): Add test for super sends [backend.aliasedSuperMembers]. |
| 404 ]..addAll(assertUnimplementedLocalMetadata()); | 404 ]..addAll(assertUnimplementedLocalMetadata()); |
| OLD | NEW |