Chromium Code Reviews| Index: pkg/compiler/lib/src/js_backend/minify_namer.dart |
| diff --git a/pkg/compiler/lib/src/js_backend/minify_namer.dart b/pkg/compiler/lib/src/js_backend/minify_namer.dart |
| index 8e5bb409010fdb175bb15066fabca672fc806faa..fd1ef6473d600cba6f976629f4abe5a7a0e8a338 100644 |
| --- a/pkg/compiler/lib/src/js_backend/minify_namer.dart |
| +++ b/pkg/compiler/lib/src/js_backend/minify_namer.dart |
| @@ -8,7 +8,7 @@ part of js_backend; |
| * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| */ |
| class MinifyNamer extends Namer with _MinifiedFieldNamer, |
| - _MinifiedOneShotInterceptorNamer { |
| + _MinifyConstructorBodyNamer, _MinifiedOneShotInterceptorNamer { |
| MinifyNamer(Compiler compiler) : super(compiler) { |
| reserveBackendNames(); |
| fieldRegistry = new _FieldNamingRegistry(this); |
| @@ -256,6 +256,71 @@ class MinifyNamer extends Namer with _MinifiedFieldNamer, |
| } |
| } |
| +class _ConstructorBodyNamingScope { |
|
sra1
2015/07/01 16:15:47
Add a comment saying what this is doing and why it
herhut
2015/07/02 09:03:00
Done.
|
| + final int _startIndex; |
| + final List _constructors; |
| + |
| + int get numberOfConstructors => _constructors.length; |
| + |
| + _ConstructorBodyNamingScope _superScope; |
| + |
| + _ConstructorBodyNamingScope.rootScope(ClassElement cls) |
| + : _superScope = null, |
| + _startIndex = 0, |
| + _constructors = cls.constructors.toList(growable: false); |
| + |
| + _ConstructorBodyNamingScope.forClass(ClassElement cls, |
| + _ConstructorBodyNamingScope superScope) |
| + : _superScope = superScope, |
| + _startIndex = superScope._startIndex + superScope.numberOfConstructors, |
| + _constructors = cls.constructors.toList(growable: false); |
| + |
| + // Mixin Applications have constructors but we never generate code for them, |
| + // so they do not count in the inheritance chain. |
| + _ConstructorBodyNamingScope.forMixinApplication(ClassElement cls, |
| + _ConstructorBodyNamingScope superScope) |
| + : _superScope = superScope, |
| + _startIndex = superScope._startIndex + superScope.numberOfConstructors, |
| + _constructors = const []; |
| + |
| + factory _ConstructorBodyNamingScope(ClassElement cls, Map<ClassElement, |
|
sra1
2015/07/01 16:15:47
break between parameters before breaking within pa
herhut
2015/07/02 09:03:00
Done.
|
| + _ConstructorBodyNamingScope> registry) { |
| + return registry.putIfAbsent(cls, () { |
| + if (cls.superclass == null) { |
| + return new _ConstructorBodyNamingScope.rootScope(cls); |
| + } else if (cls.isMixinApplication) { |
| + return new _ConstructorBodyNamingScope.forMixinApplication(cls, |
| + new _ConstructorBodyNamingScope(cls.superclass, registry)); |
| + } else { |
| + return new _ConstructorBodyNamingScope.forClass(cls, |
| + new _ConstructorBodyNamingScope(cls.superclass, registry)); |
| + } |
| + }); |
| + } |
| + |
| + String constructorBodyKeyFor(ConstructorBodyElement body) { |
| + int position = _constructors.indexOf(body.constructor); |
| + assert(invariant(body, position >= 0, message: "constructor body missing")); |
| + return "@constructorBody@${_startIndex + position}"; |
| + } |
| +} |
| + |
| +abstract class _MinifyConstructorBodyNamer implements Namer { |
| + Map<ClassElement, _ConstructorBodyNamingScope> _constructorBodyScopes = |
| + new Map<ClassElement, _ConstructorBodyNamingScope>(); |
| + |
| + @override |
| + jsAst.Name constructorBodyName(FunctionElement method) { |
| + _ConstructorBodyNamingScope scope = |
| + new _ConstructorBodyNamingScope(method.enclosingClass, |
| + _constructorBodyScopes); |
| + String key = scope.constructorBodyKeyFor(method); |
| + return _disambiguateMemberByKey(key, |
| + () => _proposeNameForConstructorBody(method)); |
| + return _disambiguateInternalMember(method, null); |
|
sra1
2015/07/01 16:15:47
remove dead code.
I was trying to understand how t
herhut
2015/07/02 09:03:00
Sorry. Done.
|
| + } |
| +} |
| + |
| abstract class _MinifiedOneShotInterceptorNamer implements Namer { |
| /// Property name used for the one-shot interceptor method for the given |
| /// [selector] and return-type specialization. |