OLD | NEW |
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 * Names are generated through three stages: | 10 * Names are generated through three stages: |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 757 |
758 /** | 758 /** |
759 * Returns the JavaScript property name used to store an instance field. | 759 * Returns the JavaScript property name used to store an instance field. |
760 */ | 760 */ |
761 jsAst.Name instanceFieldPropertyName(FieldElement element) { | 761 jsAst.Name instanceFieldPropertyName(FieldElement element) { |
762 ClassElement enclosingClass = element.enclosingClass; | 762 ClassElement enclosingClass = element.enclosingClass; |
763 | 763 |
764 if (element.hasFixedBackendName) { | 764 if (element.hasFixedBackendName) { |
765 // Certain native fields must be given a specific name. Native names must | 765 // Certain native fields must be given a specific name. Native names must |
766 // not contain '$'. We rely on this to avoid clashes. | 766 // not contain '$'. We rely on this to avoid clashes. |
| 767 // TODO(jacobr): we need to relax this constraint. |
767 assert(enclosingClass.isNative && | 768 assert(enclosingClass.isNative && |
768 !element.fixedBackendName.contains(r'$')); | 769 !element.fixedBackendName.contains(r'$')); |
769 | 770 |
770 return new StringBackedName(element.fixedBackendName); | 771 return new StringBackedName(element.fixedBackendName); |
771 } | 772 } |
772 | 773 |
773 // Instances of BoxFieldElement are special. They are already created with | 774 // Instances of BoxFieldElement are special. They are already created with |
774 // a unique and safe name. However, as boxes are not really instances of | 775 // a unique and safe name. However, as boxes are not really instances of |
775 // classes, the usual naming scheme that tries to avoid name clashes with | 776 // classes, the usual naming scheme that tries to avoid name clashes with |
776 // super classes does not apply. We still do not mark the name as a | 777 // super classes does not apply. We still do not mark the name as a |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 } | 1983 } |
1983 } | 1984 } |
1984 } | 1985 } |
1985 } | 1986 } |
1986 | 1987 |
1987 enum NamingScope { | 1988 enum NamingScope { |
1988 global, | 1989 global, |
1989 instance, | 1990 instance, |
1990 constant | 1991 constant |
1991 } | 1992 } |
OLD | NEW |