Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2023)

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 21110003: Implement MirrorUsed.targets for libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r25609 and added test. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
index 86f5db8a6694bea5537badd7cf79ad520b404139..b6c76067f9e7c04b180ebdcb5bf7cadc5931120b 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -211,6 +211,12 @@ abstract class Backend {
void registerMetadataInstantiatedType(DartType type, TreeElements elements) {}
void registerMetadataStaticUse(Element element) {}
void registerMetadataGetOfStaticFunction(FunctionElement element) {}
+
+ void registerMirrorUsage(Set<String> symbols,
Johnni Winther 2013/07/30 11:15:09 Please document.
ahe 2013/07/30 12:05:45 Done.
+ Set<Element> targets,
+ Set<Element> metaTargets) {}
+
+ bool isNeededForReflection(Element element) => false;
Johnni Winther 2013/07/30 11:15:09 Please document. For instance, is [element] only n
ahe 2013/07/30 12:05:45 Done.
}
/**
@@ -338,6 +344,9 @@ abstract class Compiler implements DiagnosticListener {
LibraryElement foreignLibrary;
LibraryElement mainApp;
+ /// Initialized when dart:mirrors is loaded.
+ LibraryElement mirrorsLibrary;
+
ClassElement objectClass;
ClassElement closureClass;
ClassElement boundClosureClass;
@@ -361,6 +370,9 @@ abstract class Compiler implements DiagnosticListener {
// Initialized when dart:mirrors is loaded.
ClassElement mirrorSystemClass;
+ // Initialized when dart:mirrors is loaded.
+ ClassElement mirrorsUsedClass;
+
// Initialized after mirrorSystemClass has been resolved.
FunctionElement mirrorSystemGetNameFunction;
@@ -437,6 +449,7 @@ abstract class Compiler implements DiagnosticListener {
EnqueueTask enqueuer;
CompilerTask fileReadingTask;
DeferredLoadTask deferredLoadTask;
+ MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask;
ContainerTracer containerTracer;
String buildId;
@@ -545,6 +558,7 @@ abstract class Compiler implements DiagnosticListener {
containerTracer = new ContainerTracer(this),
constantHandler = new ConstantHandler(this, backend.constantSystem),
deferredLoadTask = new DeferredLoadTask(this),
+ mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this),
enqueuer = new EnqueueTask(this)];
tasks.addAll(backend.tasks);
@@ -692,8 +706,11 @@ abstract class Compiler implements DiagnosticListener {
});
}
if (uri == new Uri(scheme: 'dart', path: 'mirrors')) {
+ mirrorsLibrary = library;
mirrorSystemClass =
findRequiredElement(library, const SourceString('MirrorSystem'));
+ mirrorsUsedClass =
+ findRequiredElement(library, const SourceString('MirrorsUsed'));
} else if (uri == new Uri(scheme: 'dart', path: '_collection-dev')) {
symbolImplementationClass =
findRequiredElement(library, const SourceString('Symbol'));
@@ -898,6 +915,8 @@ abstract class Compiler implements DiagnosticListener {
});
}
+ mirrorUsageAnalyzerTask.analyzeUsage(mainApp);
+
// In order to see if a library is deferred, we must compute the
// compile-time constants that are metadata. This means adding
// something to the resolution queue. So we cannot wait with
@@ -1181,6 +1200,10 @@ abstract class Compiler implements DiagnosticListener {
api.Diagnostic.HINT);
}
+ void reportHere(Spannable node, String debugMessage) {
Johnni Winther 2013/07/30 11:15:09 Document that this is for debugging only.
ahe 2013/07/30 12:05:45 Done.
+ reportInfo(node, MessageKind.GENERIC, {'text': 'HERE: $debugMessage'});
+ }
+
void reportInternalError(Spannable node, String message) {
reportError(
node, MessageKind.GENERIC, {'text': 'Internal Error: $message'});

Powered by Google App Engine
This is Rietveld 408576698