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

Unified Diff: pkg/compiler/lib/src/js_emitter/metadata_collector.dart

Issue 981143003: dart2js: split out types from metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 5 years, 9 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/metadata_collector.dart
diff --git a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
index 5319a878eb1094083db8781e528fb2f3306f795f..9876dacd6ace666e315f5468244f61204c14c3fb 100644
--- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
+++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
@@ -9,12 +9,19 @@ class MetadataCollector {
final Emitter _emitter;
/// A list of JS expressions that represent metadata, parameter names and
- /// type, and return types.
- final List<String> globalMetadata = [];
+ /// type variable types.
+ final List<String> globalMetadata = <String>[];
/// A map used to canonicalize the entries of globalMetadata.
final Map<String, int> _globalMetadataMap = <String, int>{};
+ /// A list of JS expression representing types including function types and
+ /// typedefs.
+ final List<String> types = <String>[];
+
+ /// A map used to canonicalize the entries of types.
+ final Map<String, int> _typesMap = <String, int>{};
+
MetadataCollector(this._compiler, this._emitter);
JavaScriptBackend get _backend => _compiler.backend;
@@ -96,7 +103,7 @@ class MetadataCollector {
return _backend.isAccessibleByReflection(typedef.element);
});
- return addGlobalMetadata(
+ return addType(
jsAst.prettyPrint(representation, _compiler).getText());
}
@@ -111,6 +118,13 @@ class MetadataCollector {
});
}
+ int addType(String compiledType) {
+ return _typesMap.putIfAbsent(compiledType, () {
+ types.add(compiledType);
+ return types.length - 1;
+ });
+ }
+
List<int> computeMetadata(FunctionElement element) {
return _compiler.withCurrentElement(element, () {
if (!_mustEmitMetadataFor(element)) return const <int>[];
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698