| 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 library js_backend.namer; | 5 library js_backend.namer; |
| 6 | 6 |
| 7 import 'dart:collection' show HashMap; | 7 import 'dart:collection' show HashMap; |
| 8 | 8 |
| 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; | 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; |
| 10 | 10 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 return asName(functionTypeNamedParametersTag); | 658 return asName(functionTypeNamedParametersTag); |
| 659 case JsGetName.IS_INDEXABLE_FIELD_NAME: | 659 case JsGetName.IS_INDEXABLE_FIELD_NAME: |
| 660 return operatorIs(_commonElements.jsIndexingBehaviorInterface); | 660 return operatorIs(_commonElements.jsIndexingBehaviorInterface); |
| 661 case JsGetName.NULL_CLASS_TYPE_NAME: | 661 case JsGetName.NULL_CLASS_TYPE_NAME: |
| 662 return runtimeTypeName(_commonElements.nullClass); | 662 return runtimeTypeName(_commonElements.nullClass); |
| 663 case JsGetName.OBJECT_CLASS_TYPE_NAME: | 663 case JsGetName.OBJECT_CLASS_TYPE_NAME: |
| 664 return runtimeTypeName(_commonElements.objectClass); | 664 return runtimeTypeName(_commonElements.objectClass); |
| 665 case JsGetName.FUNCTION_CLASS_TYPE_NAME: | 665 case JsGetName.FUNCTION_CLASS_TYPE_NAME: |
| 666 return runtimeTypeName(_commonElements.functionClass); | 666 return runtimeTypeName(_commonElements.functionClass); |
| 667 default: | 667 default: |
| 668 throw new SpannableAssertionFailure( | 668 throw failedAt(spannable, 'Error: Namer has no name for "$name".'); |
| 669 spannable, 'Error: Namer has no name for "$name".'); | |
| 670 } | 669 } |
| 671 } | 670 } |
| 672 | 671 |
| 673 /// Return a reference to the given [name]. | 672 /// Return a reference to the given [name]. |
| 674 /// | 673 /// |
| 675 /// This is used to ensure that every use site of a name has a unique node so | 674 /// This is used to ensure that every use site of a name has a unique node so |
| 676 /// that we can properly attribute source information. | 675 /// that we can properly attribute source information. |
| 677 jsAst.Name _newReference(jsAst.Name name) { | 676 jsAst.Name _newReference(jsAst.Name name) { |
| 678 return new _NameReference(name); | 677 return new _NameReference(name); |
| 679 } | 678 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 List<String> suffix = callSuffixForStructure(selector.callStructure); | 845 List<String> suffix = callSuffixForStructure(selector.callStructure); |
| 847 if (selector.name == Identifiers.call) { | 846 if (selector.name == Identifiers.call) { |
| 848 // Derive the annotated name for this variant of 'call'. | 847 // Derive the annotated name for this variant of 'call'. |
| 849 return deriveCallMethodName(suffix); | 848 return deriveCallMethodName(suffix); |
| 850 } | 849 } |
| 851 jsAst.Name disambiguatedName = | 850 jsAst.Name disambiguatedName = |
| 852 _disambiguateMember(selector.memberName, suffix); | 851 _disambiguateMember(selector.memberName, suffix); |
| 853 return disambiguatedName; // Methods other than call are not annotated. | 852 return disambiguatedName; // Methods other than call are not annotated. |
| 854 | 853 |
| 855 default: | 854 default: |
| 856 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, | 855 throw failedAt(CURRENT_ELEMENT_SPANNABLE, |
| 857 'Unexpected selector kind: ${selector.kind}'); | 856 'Unexpected selector kind: ${selector.kind}'); |
| 858 } | 857 } |
| 859 } | 858 } |
| 860 | 859 |
| 861 /** | 860 /** |
| 862 * Returns the internal name used for an invocation mirror of this selector. | 861 * Returns the internal name used for an invocation mirror of this selector. |
| 863 */ | 862 */ |
| 864 jsAst.Name invocationMirrorInternalName(Selector selector) => | 863 jsAst.Name invocationMirrorInternalName(Selector selector) => |
| 865 invocationName(selector); | 864 invocationName(selector); |
| 866 | 865 |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 case SyntheticConstantKind.DUMMY_INTERCEPTOR: | 1956 case SyntheticConstantKind.DUMMY_INTERCEPTOR: |
| 1958 add('dummy_receiver'); | 1957 add('dummy_receiver'); |
| 1959 break; | 1958 break; |
| 1960 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: | 1959 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: |
| 1961 // Omit. These are opaque deferred indexes with nothing helpful to add. | 1960 // Omit. These are opaque deferred indexes with nothing helpful to add. |
| 1962 break; | 1961 break; |
| 1963 case SyntheticConstantKind.NAME: | 1962 case SyntheticConstantKind.NAME: |
| 1964 add('name'); | 1963 add('name'); |
| 1965 break; | 1964 break; |
| 1966 default: | 1965 default: |
| 1967 throw new SpannableAssertionFailure( | 1966 failedAt( |
| 1968 CURRENT_ELEMENT_SPANNABLE, "Unexpected SyntheticConstantValue"); | 1967 CURRENT_ELEMENT_SPANNABLE, "Unexpected SyntheticConstantValue"); |
| 1969 } | 1968 } |
| 1970 } | 1969 } |
| 1971 | 1970 |
| 1972 @override | 1971 @override |
| 1973 void visitDeferred(DeferredConstantValue constant, [_]) { | 1972 void visitDeferred(DeferredConstantValue constant, [_]) { |
| 1974 addRoot('Deferred'); | 1973 addRoot('Deferred'); |
| 1975 } | 1974 } |
| 1976 } | 1975 } |
| 1977 | 1976 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 | 2071 |
| 2073 @override | 2072 @override |
| 2074 int visitSynthetic(SyntheticConstantValue constant, [_]) { | 2073 int visitSynthetic(SyntheticConstantValue constant, [_]) { |
| 2075 switch (constant.valueKind) { | 2074 switch (constant.valueKind) { |
| 2076 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: | 2075 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: |
| 2077 // These contain a deferred opaque index into metadata. There is nothing | 2076 // These contain a deferred opaque index into metadata. There is nothing |
| 2078 // we can access that is stable between compiles. Luckily, since they | 2077 // we can access that is stable between compiles. Luckily, since they |
| 2079 // resolve to integer indexes, they're always part of a larger constant. | 2078 // resolve to integer indexes, they're always part of a larger constant. |
| 2080 return 0; | 2079 return 0; |
| 2081 default: | 2080 default: |
| 2082 throw new SpannableAssertionFailure( | 2081 throw failedAt( |
| 2083 NO_LOCATION_SPANNABLE, | 2082 NO_LOCATION_SPANNABLE, |
| 2084 'SyntheticConstantValue should never be named and ' | 2083 'SyntheticConstantValue should never be named and ' |
| 2085 'never be subconstant'); | 2084 'never be subconstant'); |
| 2086 } | 2085 } |
| 2087 } | 2086 } |
| 2088 | 2087 |
| 2089 @override | 2088 @override |
| 2090 int visitDeferred(DeferredConstantValue constant, [_]) { | 2089 int visitDeferred(DeferredConstantValue constant, [_]) { |
| 2091 // TODO(sra): Investigate that the use of hashCode here is probably a source | 2090 // TODO(sra): Investigate that the use of hashCode here is probably a source |
| 2092 // of instability. | 2091 // of instability. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 void addSuggestion(String original, String suggestion) { | 2237 void addSuggestion(String original, String suggestion) { |
| 2239 assert(!_suggestedNames.containsKey(original)); | 2238 assert(!_suggestedNames.containsKey(original)); |
| 2240 _suggestedNames[original] = suggestion; | 2239 _suggestedNames[original] = suggestion; |
| 2241 } | 2240 } |
| 2242 | 2241 |
| 2243 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2242 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2244 bool isSuggestion(String candidate) { | 2243 bool isSuggestion(String candidate) { |
| 2245 return _suggestedNames.containsValue(candidate); | 2244 return _suggestedNames.containsValue(candidate); |
| 2246 } | 2245 } |
| 2247 } | 2246 } |
| OLD | NEW |