Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: pkg/compiler/lib/src/js_backend/frequency_namer.dart

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.namer; 5 part of js_backend.namer;
6 6
7 class FrequencyBasedNamer extends Namer 7 class FrequencyBasedNamer extends Namer
8 with _MinifiedFieldNamer, _MinifiedOneShotInterceptorNamer 8 with _MinifiedFieldNamer, _MinifiedOneShotInterceptorNamer
9 implements jsAst.TokenFinalizer { 9 implements jsAst.TokenFinalizer {
10 _FieldNamingRegistry fieldRegistry; 10 _FieldNamingRegistry fieldRegistry;
11 List<TokenName> tokens = new List<TokenName>(); 11 List<TokenName> tokens = new List<TokenName>();
12 12
13 Map<NamingScope, TokenScope> _tokenScopes = 13 Map<NamingScope, TokenScope> _tokenScopes =
14 new Maplet<NamingScope, TokenScope>(); 14 new Maplet<NamingScope, TokenScope>();
15 15
16 // Some basic settings for smaller names 16 // Some basic settings for smaller names
17 String get isolateName => 'I'; 17 String get isolateName => 'I';
18 String get isolatePropertiesName => 'p'; 18 String get isolatePropertiesName => 'p';
19 bool get shouldMinify => true; 19 bool get shouldMinify => true;
20 20
21 final String getterPrefix = 'g'; 21 final String getterPrefix = 'g';
22 final String setterPrefix = 's'; 22 final String setterPrefix = 's';
23 final String callPrefix = ''; // this will create function names $<n> 23 final String callPrefix = ''; // this will create function names $<n>
24 24
25 jsAst.Name get staticsPropertyName => 25 jsAst.Name get staticsPropertyName =>
26 _staticsPropertyName ??= getFreshName(instanceScope, 'static'); 26 _staticsPropertyName ??= getFreshName(instanceScope, 'static');
27 27
28 FrequencyBasedNamer(JavaScriptBackend backend, ClosedWorld closedWorld) 28 FrequencyBasedNamer(JavaScriptBackend backend, ClosedWorld closedWorld,
29 : super(backend, closedWorld) { 29 CodegenWorldBuilder codegenWorldBuilder)
30 : super(backend, closedWorld, codegenWorldBuilder) {
30 fieldRegistry = new _FieldNamingRegistry(this); 31 fieldRegistry = new _FieldNamingRegistry(this);
31 } 32 }
32 33
33 TokenScope newScopeFor(NamingScope scope) { 34 TokenScope newScopeFor(NamingScope scope) {
34 if (scope == instanceScope) { 35 if (scope == instanceScope) {
35 Set<String> illegalNames = new Set<String>.from(jsReserved); 36 Set<String> illegalNames = new Set<String>.from(jsReserved);
36 for (String illegal in MinifyNamer._reservedNativeProperties) { 37 for (String illegal in MinifyNamer._reservedNativeProperties) {
37 illegalNames.add(illegal); 38 illegalNames.add(illegal);
38 if (MinifyNamer._hasBannedPrefix(illegal)) { 39 if (MinifyNamer._hasBannedPrefix(illegal)) {
39 illegalNames.add(illegal.substring(1)); 40 illegalNames.add(illegal.substring(1));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 String proposal; 133 String proposal;
133 do { 134 do {
134 proposal = new String.fromCharCodes(_nextName); 135 proposal = new String.fromCharCodes(_nextName);
135 _incrementName(); 136 _incrementName();
136 } while (MinifyNamer._hasBannedPrefix(proposal) || 137 } while (MinifyNamer._hasBannedPrefix(proposal) ||
137 illegalNames.contains(proposal)); 138 illegalNames.contains(proposal));
138 139
139 return proposal; 140 return proposal;
140 } 141 }
141 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698