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

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: 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
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..aac8069fbcc74930f371259c0e13f28cae3fbd08 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.
+ /// type variable types.
final List<String> globalMetadata = [];
/// 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 = [];
floitsch 2015/03/06 12:48:50 Make it typed? (same for the globalMetadata)
zarah 2015/03/06 13:05:51 Done.
+
+ /// 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 string) {
floitsch 2015/03/06 12:48:50 Not this CL, but we should consider storing the js
floitsch 2015/03/06 12:48:50 s/string/code s/string/compiledType ?
zarah 2015/03/06 13:05:51 Acknowledged.
zarah 2015/03/06 13:05:52 I like compiledType.
+ return _typesMap.putIfAbsent(string, () {
+ types.add(string);
+ 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') | pkg/compiler/lib/src/js_emitter/model.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698