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

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

Issue 1009053005: Do not use the namer for naming closure elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Better naming for closure/box fields. Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 7 /**
8 * Assigns JavaScript identifiers to Dart variables, class-names and members. 8 * Assigns JavaScript identifiers to Dart variables, class-names and members.
9 */ 9 */
10 class MinifyNamer extends Namer { 10 class MinifyNamer extends Namer {
(...skipping 30 matching lines...) Expand all
41 if (suggestion != null && !usedNames.contains(suggestion)) { 41 if (suggestion != null && !usedNames.contains(suggestion)) {
42 freshName = suggestion; 42 freshName = suggestion;
43 } else { 43 } else {
44 freshName = _getUnusedName(proposedName, usedNames, 44 freshName = _getUnusedName(proposedName, usedNames,
45 suggestedNames.values); 45 suggestedNames.values);
46 } 46 }
47 usedNames.add(freshName); 47 usedNames.add(freshName);
48 return freshName; 48 return freshName;
49 } 49 }
50 50
51 String getClosureVariableName(String _, int id) {
52 if (id < ALPHABET_CHARACTERS) {
53 return new String.fromCharCodes([_letterNumber(id)]);
54 }
55 // Fall back to a slightly longer name.
56 String basename = _disambiguateMember(null, 'closure');
57 return '${basename}_$id';
58 }
59
60 // From issue 7554. These should not be used on objects (as instance 51 // From issue 7554. These should not be used on objects (as instance
61 // variables) because they clash with names from the DOM. However, it is 52 // variables) because they clash with names from the DOM. However, it is
62 // OK to use them as fields, as we only access fields directly if we know 53 // OK to use them as fields, as we only access fields directly if we know
63 // the receiver type. 54 // the receiver type.
64 static const List<String> _reservedNativeProperties = const <String>[ 55 static const List<String> _reservedNativeProperties = const <String>[
65 'Q', 'a', 'b', 'c', 'd', 'e', 'f', 'r', 'x', 'y', 'z', 56 'Q', 'a', 'b', 'c', 'd', 'e', 'f', 'r', 'x', 'y', 'z',
66 // 2-letter: 57 // 2-letter:
67 'ch', 'cx', 'cy', 'db', 'dx', 'dy', 'fr', 'fx', 'fy', 'go', 'id', 'k1', 58 'ch', 'cx', 'cy', 'db', 'dx', 'dy', 'fr', 'fx', 'fy', 'go', 'id', 'k1',
68 'k2', 'k3', 'k4', 'r1', 'r2', 'rx', 'ry', 'x1', 'x2', 'y1', 'y2', 59 'k2', 'k3', 'k4', 'r1', 'r2', 'rx', 'ry', 'x1', 'x2', 'y1', 'y2',
69 // 3-letter: 60 // 3-letter:
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 _BoxFieldNamingScope(Local box, _FieldNamingRegistry registry) : 435 _BoxFieldNamingScope(Local box, _FieldNamingRegistry registry) :
445 super.rootScope(box, registry); 436 super.rootScope(box, registry);
446 437
447 bool containsField(_) => true; 438 bool containsField(_) => true;
448 439
449 String operator[](Element field) { 440 String operator[](Element field) {
450 if (!names.containsKey(field)) add(field); 441 if (!names.containsKey(field)) add(field);
451 return names[field]; 442 return names[field];
452 } 443 }
453 } 444 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698