| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 8 final Set<HInstruction> boundsChecked; | 8 final Set<HInstruction> boundsChecked; |
| 9 | 9 |
| 10 JavaScriptItemCompilationContext() | 10 JavaScriptItemCompilationContext() |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 isTreeShakingDisabled = true; | 1431 isTreeShakingDisabled = true; |
| 1432 enqueuer.enqueueEverything(); | 1432 enqueuer.enqueueEverything(); |
| 1433 } else if (element == preserveNamesMarker) { | 1433 } else if (element == preserveNamesMarker) { |
| 1434 if (mustPreserveNames) return; | 1434 if (mustPreserveNames) return; |
| 1435 mustPreserveNames = true; | 1435 mustPreserveNames = true; |
| 1436 compiler.log('Preserving names.'); | 1436 compiler.log('Preserving names.'); |
| 1437 } else if (element == preserveMetadataMarker) { | 1437 } else if (element == preserveMetadataMarker) { |
| 1438 if (mustRetainMetadata) return; | 1438 if (mustRetainMetadata) return; |
| 1439 compiler.log('Retaining metadata.'); | 1439 compiler.log('Retaining metadata.'); |
| 1440 mustRetainMetadata = true; | 1440 mustRetainMetadata = true; |
| 1441 for (LibraryElement library in compiler.libraries.values) { | 1441 compiler.libraries.values.forEach(retainMetadataOf); |
| 1442 if (retainMetadataOf(library)) { | |
| 1443 for (Link link = library.metadata; !link.isEmpty; link = link.tail) { | |
| 1444 link.head.ensureResolved(compiler); | |
| 1445 } | |
| 1446 } | |
| 1447 } | |
| 1448 for (Dependency dependency in metadataInstantiatedTypes) { | 1442 for (Dependency dependency in metadataInstantiatedTypes) { |
| 1449 registerMetadataInstantiatedType(dependency.type, dependency.user); | 1443 registerMetadataInstantiatedType(dependency.type, dependency.user); |
| 1450 } | 1444 } |
| 1451 metadataInstantiatedTypes.clear(); | 1445 metadataInstantiatedTypes.clear(); |
| 1452 for (Element e in metadataStaticUse) { | 1446 for (Element e in metadataStaticUse) { |
| 1453 registerMetadataStaticUse(e); | 1447 registerMetadataStaticUse(e); |
| 1454 } | 1448 } |
| 1455 metadataStaticUse.clear(); | 1449 metadataStaticUse.clear(); |
| 1456 for (Element e in metadataGetOfStaticFunction) { | 1450 for (Element e in metadataGetOfStaticFunction) { |
| 1457 registerMetadataGetOfStaticFunction(e); | 1451 registerMetadataGetOfStaticFunction(e); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1481 if (name == const SourceString('')) return false; | 1475 if (name == const SourceString('')) return false; |
| 1482 return symbolsUsed.contains(name.slowToString()); | 1476 return symbolsUsed.contains(name.slowToString()); |
| 1483 } | 1477 } |
| 1484 | 1478 |
| 1485 bool get rememberLazies => isTreeShakingDisabled; | 1479 bool get rememberLazies => isTreeShakingDisabled; |
| 1486 | 1480 |
| 1487 bool retainMetadataOf(Element element) { | 1481 bool retainMetadataOf(Element element) { |
| 1488 if (mustRetainMetadata) hasRetainedMetadata = true; | 1482 if (mustRetainMetadata) hasRetainedMetadata = true; |
| 1489 if (mustRetainMetadata && isNeededForReflection(element)) { | 1483 if (mustRetainMetadata && isNeededForReflection(element)) { |
| 1490 for (MetadataAnnotation metadata in element.metadata) { | 1484 for (MetadataAnnotation metadata in element.metadata) { |
| 1491 metadata.value.accept(new ConstantCopier(compiler.constantHandler)); | 1485 metadata.ensureResolved(compiler) |
| 1486 .value.accept(new ConstantCopier(compiler.constantHandler)); |
| 1492 } | 1487 } |
| 1493 return true; | 1488 return true; |
| 1494 } | 1489 } |
| 1495 return false; | 1490 return false; |
| 1496 } | 1491 } |
| 1497 | 1492 |
| 1498 void onLibraryLoaded(LibraryElement library, Uri uri) { | 1493 void onLibraryLoaded(LibraryElement library, Uri uri) { |
| 1499 if (uri == Uri.parse('dart:_js_mirrors')) { | 1494 if (uri == Uri.parse('dart:_js_mirrors')) { |
| 1500 disableTreeShakingMarker = | 1495 disableTreeShakingMarker = |
| 1501 library.find(const SourceString('disableTreeShaking')); | 1496 library.find(const SourceString('disableTreeShaking')); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 copy(constant.values); | 1665 copy(constant.values); |
| 1671 copy(constant.protoValue); | 1666 copy(constant.protoValue); |
| 1672 copy(constant); | 1667 copy(constant); |
| 1673 } | 1668 } |
| 1674 | 1669 |
| 1675 void visitConstructed(ConstructedConstant constant) { | 1670 void visitConstructed(ConstructedConstant constant) { |
| 1676 copy(constant.fields); | 1671 copy(constant.fields); |
| 1677 copy(constant); | 1672 copy(constant); |
| 1678 } | 1673 } |
| 1679 } | 1674 } |
| OLD | NEW |