| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class FrequencyBasedNamer extends Namer with _MinifiedFieldNamer, | 7 class FrequencyBasedNamer extends Namer with _MinifiedFieldNamer, |
| 8 _MinifiedOneShotInterceptorNamer implements jsAst.TokenFinalizer { | 8 _MinifiedOneShotInterceptorNamer implements jsAst.TokenFinalizer { |
| 9 _FieldNamingRegistry fieldRegistry; | 9 _FieldNamingRegistry fieldRegistry; |
| 10 List<TokenName> tokens = new List<TokenName>(); | 10 List<TokenName> tokens = new List<TokenName>(); |
| 11 | 11 |
| 12 Map<NamingScope, TokenScope> _tokenScopes = | 12 Map<NamingScope, TokenScope> _tokenScopes = |
| 13 new Maplet<NamingScope, TokenScope>(); | 13 new Maplet<NamingScope, TokenScope>(); |
| 14 | 14 |
| 15 // Some basic settings for smaller names | 15 // Some basic settings for smaller names |
| 16 String get isolateName => 'I'; | 16 String get isolateName => 'I'; |
| 17 String get isolatePropertiesName => 'p'; | 17 String get isolatePropertiesName => 'p'; |
| 18 bool get shouldMinify => true; | 18 bool get shouldMinify => true; |
| 19 | 19 |
| 20 final String getterPrefix = 'g'; | 20 final String getterPrefix = 'g'; |
| 21 final String setterPrefix = 's'; | 21 final String setterPrefix = 's'; |
| 22 final String callPrefix = ''; // this will create function names $<n> | 22 final String callPrefix = ''; // this will create function names $<n> |
| 23 | 23 |
| 24 jsAst.Name get staticsPropertyName => |
| 25 _staticsPropertyName ??= getFreshName(instanceScope, 'static'); |
| 26 |
| 24 FrequencyBasedNamer(Compiler compiler) : super(compiler) { | 27 FrequencyBasedNamer(Compiler compiler) : super(compiler) { |
| 25 fieldRegistry = new _FieldNamingRegistry(this); | 28 fieldRegistry = new _FieldNamingRegistry(this); |
| 26 } | 29 } |
| 27 | 30 |
| 28 TokenScope newScopeFor(NamingScope scope) { | 31 TokenScope newScopeFor(NamingScope scope) { |
| 29 if (scope == instanceScope) { | 32 if (scope == instanceScope) { |
| 30 Set<String> illegalNames = new Set<String>.from(jsReserved); | 33 Set<String> illegalNames = new Set<String>.from(jsReserved); |
| 31 for (String illegal in MinifyNamer._reservedNativeProperties) { | 34 for (String illegal in MinifyNamer._reservedNativeProperties) { |
| 32 illegalNames.add(illegal); | 35 illegalNames.add(illegal); |
| 33 if (MinifyNamer._hasBannedPrefix(illegal)) { | 36 if (MinifyNamer._hasBannedPrefix(illegal)) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 do { | 135 do { |
| 133 proposal = new String.fromCharCodes(_nextName); | 136 proposal = new String.fromCharCodes(_nextName); |
| 134 _incrementName(); | 137 _incrementName(); |
| 135 } while (MinifyNamer._hasBannedPrefix(proposal) || | 138 } while (MinifyNamer._hasBannedPrefix(proposal) || |
| 136 illegalNames.contains(proposal)); | 139 illegalNames.contains(proposal)); |
| 137 | 140 |
| 138 return proposal; | 141 return proposal; |
| 139 } | 142 } |
| 140 } | 143 } |
| 141 | 144 |
| OLD | NEW |