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

Unified Diff: dart/sdk/lib/_internal/lib/js_mirrors.dart

Issue 17315012: Generate less code when importing dart:mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 years, 6 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/lib/js_mirrors.dart
diff --git a/dart/sdk/lib/_internal/lib/js_mirrors.dart b/dart/sdk/lib/_internal/lib/js_mirrors.dart
index fd1dd30ad3060dafc01647dde627d9482d3d9630..dc58e3835cfcf565b726017f0cf619d1c8a44612 100644
--- a/dart/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/dart/sdk/lib/_internal/lib/js_mirrors.dart
@@ -20,10 +20,14 @@ import 'dart:_js_helper' show
import 'dart:_interceptors' show Interceptor;
import 'dart:_js_names';
-/// No-op method that is called to inform the compiler that
-/// tree-shaking needs to be disabled.
+/// No-op method that is called to inform the compiler that tree-shaking needs
+/// to be disabled.
disableTreeShaking() => preserveNames();
+/// No-op method that is called to inform the compiler that metadata must be
+/// preserved at runtime.
+preserveMetadata() {}
+
String getName(Symbol symbol) {
preserveNames();
return n(symbol);
@@ -185,7 +189,10 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
return result;
}
- List<InstanceMirror> get metadata => _metadata.map(reflect).toList();
+ List<InstanceMirror> get metadata {
+ preserveMetadata();
+ return _metadata.map(reflect).toList();
+ }
}
String n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
@@ -584,6 +591,7 @@ class JsVariableMirror extends JsDeclarationMirror implements VariableMirror {
Symbol get qualifiedName => computeQualifiedName(owner, simpleName);
List<InstanceMirror> get metadata {
+ preserveMetadata();
if (_metadata == null) {
_metadata = (_metadataFunction == null)
? const [] : JS('', '#()', _metadataFunction);
@@ -718,6 +726,7 @@ Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) {
}
List extractMetadata(victim) {
+ preserveMetadata();
var metadataFunction = JS('', '#["@"]', victim);
return (metadataFunction == null)
? const [] : JS('', '#()', metadataFunction);
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | dart/sdk/lib/_internal/lib/js_names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698