| 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 9876dacd6ace666e315f5468244f61204c14c3fb..48df1396d7382af53e862e07d1ea95a544a56915 100644
|
| --- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
|
| +++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
|
| @@ -15,12 +15,13 @@ class MetadataCollector {
|
| /// 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 with lists of JS expressions, one list for each output unit. The
|
| + /// entries represent types including function types and typedefs.
|
| + final Map<OutputUnit, List<String>> types = <OutputUnit, List<String>>{};
|
|
|
| /// A map used to canonicalize the entries of types.
|
| - final Map<String, int> _typesMap = <String, int>{};
|
| + final Map<OutputUnit, Map<String, int>> _typesMap =
|
| + <OutputUnit, Map<String, int>>{};
|
|
|
| MetadataCollector(this._compiler, this._emitter);
|
|
|
| @@ -91,6 +92,11 @@ class MetadataCollector {
|
| }
|
|
|
| int reifyType(DartType type) {
|
| + return reifyTypeForOutputUnit(type,
|
| + _compiler.deferredLoadTask.mainOutputUnit);
|
| + }
|
| +
|
| + int reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit) {
|
| jsAst.Expression representation =
|
| _backend.rti.getTypeRepresentation(
|
| type,
|
| @@ -103,8 +109,8 @@ class MetadataCollector {
|
| return _backend.isAccessibleByReflection(typedef.element);
|
| });
|
|
|
| - return addType(
|
| - jsAst.prettyPrint(representation, _compiler).getText());
|
| + return addTypeInOutputUnit(
|
| + jsAst.prettyPrint(representation, _compiler).getText(), outputUnit);
|
| }
|
|
|
| int reifyName(String name) {
|
| @@ -118,10 +124,17 @@ class MetadataCollector {
|
| });
|
| }
|
|
|
| - int addType(String compiledType) {
|
| - return _typesMap.putIfAbsent(compiledType, () {
|
| - types.add(compiledType);
|
| - return types.length - 1;
|
| + int addTypeInOutputUnit(String compiledType, OutputUnit outputUnit) {
|
| + if (_typesMap[outputUnit] == null) {
|
| + _typesMap[outputUnit] = <String, int>{};
|
| + }
|
| + return _typesMap[outputUnit].putIfAbsent(compiledType, () {
|
| +
|
| + if (types[outputUnit] == null)
|
| + types[outputUnit] = <String>[];
|
| +
|
| + types[outputUnit].add(compiledType);
|
| + return types[outputUnit].length - 1;
|
| });
|
| }
|
|
|
|
|