Chromium Code Reviews| 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>[]; |