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.namer; | 5 part of js_backend.namer; |
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 |
11 // the given element's class inheritance chain. | 11 // the given element's class inheritance chain. |
12 // | 12 // |
13 // The inheritance scope based naming might not yield a name. For instance, | 13 // The inheritance scope based naming might not yield a name. For instance, |
14 // this could be because the field belongs to a mixin. In such a case this | 14 // this could be because the field belongs to a mixin. In such a case this |
15 // will return `null` and a normal field name has to be used. | 15 // will return `null` and a normal field name has to be used. |
16 jsAst.Name _minifiedInstanceFieldPropertyName(Element element) { | 16 jsAst.Name _minifiedInstanceFieldPropertyName(Element element) { |
17 if (backend.nativeData.hasFixedBackendName(element)) { | 17 if (_nativeData.hasFixedBackendName(element)) { |
18 return new StringBackedName( | 18 return new StringBackedName(_nativeData.getFixedBackendName(element)); |
19 backend.nativeData.getFixedBackendName(element)); | |
20 } | 19 } |
21 | 20 |
22 _FieldNamingScope names; | 21 _FieldNamingScope names; |
23 if (element is BoxFieldElement) { | 22 if (element is BoxFieldElement) { |
24 names = new _FieldNamingScope.forBox(element.box, fieldRegistry); | 23 names = new _FieldNamingScope.forBox(element.box, fieldRegistry); |
25 } else { | 24 } else { |
26 ClassElement cls = element.enclosingClass; | 25 ClassElement cls = element.enclosingClass; |
27 names = new _FieldNamingScope.forClass(cls, closedWorld, fieldRegistry); | 26 names = new _FieldNamingScope.forClass(cls, _closedWorld, fieldRegistry); |
28 } | 27 } |
29 | 28 |
30 if (names.containsField(element)) { | 29 if (names.containsField(element)) { |
31 return names[element]; | 30 return names[element]; |
32 } | 31 } |
33 return null; | 32 return null; |
34 } | 33 } |
35 } | 34 } |
36 | 35 |
37 /** | 36 /** |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 : super.rootScope(box, registry); | 225 : super.rootScope(box, registry); |
227 | 226 |
228 @override | 227 @override |
229 bool containsField(_) => true; | 228 bool containsField(_) => true; |
230 | 229 |
231 jsAst.Name operator [](Element field) { | 230 jsAst.Name operator [](Element field) { |
232 if (!names.containsKey(field)) add(field); | 231 if (!names.containsKey(field)) add(field); |
233 return names[field]; | 232 return names[field]; |
234 } | 233 } |
235 } | 234 } |
OLD | NEW |