| 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>[];
|
|
|