| 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 abstract class _MinifiedFieldNamer implements Namer { | 7 abstract class _MinifiedFieldNamer implements Namer { |
| 8 _FieldNamingRegistry get fieldRegistry; | 8 _FieldNamingRegistry get fieldRegistry; |
| 9 | 9 |
| 10 // Returns a minimal name for the field that is globally unique along | 10 // Returns a minimal name for the field that is globally unique along |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // | 64 // |
| 65 // The implementation assumes that names are requedsted in order, that is the | 65 // The implementation assumes that names are requedsted in order, that is the |
| 66 // name at position i+1 is requested after the name at position i was | 66 // name at position i+1 is requested after the name at position i was |
| 67 // requested. | 67 // requested. |
| 68 jsAst.Name getName(int index) { | 68 jsAst.Name getName(int index) { |
| 69 if (index >= nameStore.length) { | 69 if (index >= nameStore.length) { |
| 70 // The namer usually does not use certain names as they clash with | 70 // The namer usually does not use certain names as they clash with |
| 71 // existing properties on JS objects (see [_reservedNativeProperties]). | 71 // existing properties on JS objects (see [_reservedNativeProperties]). |
| 72 // However, some of them are really short and safe to use for fields. | 72 // However, some of them are really short and safe to use for fields. |
| 73 // Thus, we shortcut the namer to use those first. | 73 // Thus, we shortcut the namer to use those first. |
| 74 assert(index == nameStore.length + 1); | 74 assert(index == nameStore.length); |
| 75 if (index < MinifyNamer._reservedNativeProperties.length && | 75 if (index < MinifyNamer._reservedNativeProperties.length && |
| 76 MinifyNamer._reservedNativeProperties[index].length <= 2) { | 76 MinifyNamer._reservedNativeProperties[index].length <= 2) { |
| 77 nameStore.add( | 77 nameStore.add( |
| 78 new StringBackedName(MinifyNamer._reservedNativeProperties[index])); | 78 new StringBackedName(MinifyNamer._reservedNativeProperties[index])); |
| 79 } else { | 79 } else { |
| 80 nameStore.add(namer.getFreshName("field$index", namer.usedInstanceNames, | 80 nameStore.add(namer.getFreshName("field$index", namer.usedInstanceNames, |
| 81 namer.suggestedInstanceNames)); | 81 namer.suggestedInstanceNames)); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 : super.rootScope(box, registry); | 229 : super.rootScope(box, registry); |
| 230 | 230 |
| 231 @override | 231 @override |
| 232 bool containsField(_) => true; | 232 bool containsField(_) => true; |
| 233 | 233 |
| 234 jsAst.Name operator [](Element field) { | 234 jsAst.Name operator [](Element field) { |
| 235 if (!names.containsKey(field)) add(field); | 235 if (!names.containsKey(field)) add(field); |
| 236 return names[field]; | 236 return names[field]; |
| 237 } | 237 } |
| 238 } | 238 } |
| OLD | NEW |