| 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 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 | 1716 |
| 1717 @override | 1717 @override |
| 1718 void visitType(TypeConstantValue constant, [_]) { | 1718 void visitType(TypeConstantValue constant, [_]) { |
| 1719 // Generates something like 'Type_String_k8F', using the simple name of the | 1719 // Generates something like 'Type_String_k8F', using the simple name of the |
| 1720 // type and a hash to disambiguate the same name in different libraries. | 1720 // type and a hash to disambiguate the same name in different libraries. |
| 1721 addRoot('Type'); | 1721 addRoot('Type'); |
| 1722 DartType type = constant.representedType; | 1722 DartType type = constant.representedType; |
| 1723 String name = type.element?.name; | 1723 String name = type.element?.name; |
| 1724 if (name == null) { // e.g. DartType 'dynamic' has no element. | 1724 if (name == null) { // e.g. DartType 'dynamic' has no element. |
| 1725 JavaScriptBackend backend = compiler.backend; | 1725 JavaScriptBackend backend = compiler.backend; |
| 1726 name = backend.rti.getTypeRepresentationForTypeConstant(type); | 1726 name = backend.rtiEncoder.getTypeRepresentationForTypeConstant(type); |
| 1727 } | 1727 } |
| 1728 addIdentifier(name); | 1728 addIdentifier(name); |
| 1729 add(getHashTag(constant, 3)); | 1729 add(getHashTag(constant, 3)); |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 @override | 1732 @override |
| 1733 void visitInterceptor(InterceptorConstantValue constant, [_]) { | 1733 void visitInterceptor(InterceptorConstantValue constant, [_]) { |
| 1734 addRoot(constant.dispatchedType.element.name); | 1734 addRoot(constant.dispatchedType.element.name); |
| 1735 add('methods'); | 1735 add('methods'); |
| 1736 } | 1736 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 hash = _combine(hash, _visit(value)); | 1837 hash = _combine(hash, _visit(value)); |
| 1838 } | 1838 } |
| 1839 return hash; | 1839 return hash; |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 @override | 1842 @override |
| 1843 int visitType(TypeConstantValue constant, [_]) { | 1843 int visitType(TypeConstantValue constant, [_]) { |
| 1844 DartType type = constant.representedType; | 1844 DartType type = constant.representedType; |
| 1845 JavaScriptBackend backend = compiler.backend; | 1845 JavaScriptBackend backend = compiler.backend; |
| 1846 // This name includes the library name and type parameters. | 1846 // This name includes the library name and type parameters. |
| 1847 String name = backend.rti.getTypeRepresentationForTypeConstant(type); | 1847 String name = backend.rtiEncoder.getTypeRepresentationForTypeConstant(type); |
| 1848 return _hashString(4, name); | 1848 return _hashString(4, name); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 @override | 1851 @override |
| 1852 int visitInterceptor(InterceptorConstantValue constant, [_]) { | 1852 int visitInterceptor(InterceptorConstantValue constant, [_]) { |
| 1853 String typeName = constant.dispatchedType.element.name; | 1853 String typeName = constant.dispatchedType.element.name; |
| 1854 return _hashString(5, typeName); | 1854 return _hashString(5, typeName); |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 @override | 1857 @override |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 1963 |
| 1964 visit(DartType type, [_]) { | 1964 visit(DartType type, [_]) { |
| 1965 type.accept(this, null); | 1965 type.accept(this, null); |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 visitType(DartType type, _) { | 1968 visitType(DartType type, _) { |
| 1969 sb.write(type.name); | 1969 sb.write(type.name); |
| 1970 } | 1970 } |
| 1971 | 1971 |
| 1972 visitFunctionType(FunctionType type, _) { | 1972 visitFunctionType(FunctionType type, _) { |
| 1973 if (backend.rti.isSimpleFunctionType(type)) { | 1973 if (backend.rtiEncoder.isSimpleFunctionType(type)) { |
| 1974 sb.write('args${type.parameterTypes.length}'); | 1974 sb.write('args${type.parameterTypes.length}'); |
| 1975 return; | 1975 return; |
| 1976 } | 1976 } |
| 1977 visit(type.returnType); | 1977 visit(type.returnType); |
| 1978 sb.write('_'); | 1978 sb.write('_'); |
| 1979 for (DartType parameter in type.parameterTypes) { | 1979 for (DartType parameter in type.parameterTypes) { |
| 1980 sb.write('_'); | 1980 sb.write('_'); |
| 1981 visit(parameter); | 1981 visit(parameter); |
| 1982 } | 1982 } |
| 1983 bool first = false; | 1983 bool first = false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2001 } | 2001 } |
| 2002 } | 2002 } |
| 2003 } | 2003 } |
| 2004 } | 2004 } |
| 2005 | 2005 |
| 2006 enum NamingScope { | 2006 enum NamingScope { |
| 2007 global, | 2007 global, |
| 2008 instance, | 2008 instance, |
| 2009 constant | 2009 constant |
| 2010 } | 2010 } |
| OLD | NEW |