| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.backend; | 5 library js_backend.backend; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| 10 | 10 |
| 11 import '../closure.dart'; | 11 import '../closure.dart'; |
| 12 import '../common.dart'; | 12 import '../common.dart'; |
| 13 import '../common/backend_api.dart' | 13 import '../common/backend_api.dart' |
| 14 show | 14 show |
| 15 Backend, | 15 Backend, |
| 16 BackendClasses, | 16 BackendClasses, |
| 17 ImpactTransformer, | 17 ImpactTransformer, |
| 18 ForeignResolver, | 18 ForeignResolver, |
| 19 NativeRegistry; | 19 NativeRegistry; |
| 20 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; | 20 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; |
| 21 import '../common/names.dart' show Identifiers, Uris; | 21 import '../common/names.dart' show Identifiers, Uris; |
| 22 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; | 22 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; |
| 23 import '../common/tasks.dart' show CompilerTask; | 23 import '../common/tasks.dart' show CompilerTask; |
| 24 import '../compiler.dart' show Compiler; | 24 import '../compiler.dart' show Compiler; |
| 25 import '../constants/constant_system.dart'; | 25 import '../constants/constant_system.dart'; |
| 26 import '../constants/expressions.dart'; | 26 import '../constants/expressions.dart'; |
| 27 import '../constants/values.dart'; | 27 import '../constants/values.dart'; |
| 28 import '../core_types.dart' show CommonElements, CoreClasses, CoreTypes; | 28 import '../core_types.dart' show CommonElements; |
| 29 import '../dart_types.dart'; | 29 import '../dart_types.dart'; |
| 30 import '../deferred_load.dart' show DeferredLoadTask; | 30 import '../deferred_load.dart' show DeferredLoadTask; |
| 31 import '../dump_info.dart' show DumpInfoTask; | 31 import '../dump_info.dart' show DumpInfoTask; |
| 32 import '../elements/elements.dart'; | 32 import '../elements/elements.dart'; |
| 33 import '../elements/entities.dart'; | 33 import '../elements/entities.dart'; |
| 34 import '../enqueue.dart' | 34 import '../enqueue.dart' |
| 35 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; | 35 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; |
| 36 import '../io/position_information.dart' show PositionSourceInformationStrategy; | 36 import '../io/position_information.dart' show PositionSourceInformationStrategy; |
| 37 import '../io/source_information.dart' show SourceInformationStrategy; | 37 import '../io/source_information.dart' show SourceInformationStrategy; |
| 38 import '../io/start_end_information.dart' | 38 import '../io/start_end_information.dart' |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 serialization = new JavaScriptBackendSerialization(this); | 600 serialization = new JavaScriptBackendSerialization(this); |
| 601 backendClasses = new JavaScriptBackendClasses(helpers); | 601 backendClasses = new JavaScriptBackendClasses(helpers); |
| 602 } | 602 } |
| 603 | 603 |
| 604 ConstantSystem get constantSystem => constants.constantSystem; | 604 ConstantSystem get constantSystem => constants.constantSystem; |
| 605 | 605 |
| 606 DiagnosticReporter get reporter => compiler.reporter; | 606 DiagnosticReporter get reporter => compiler.reporter; |
| 607 | 607 |
| 608 CommonElements get commonElements => compiler.commonElements; | 608 CommonElements get commonElements => compiler.commonElements; |
| 609 | 609 |
| 610 CoreClasses get coreClasses => compiler.coreClasses; | |
| 611 | |
| 612 CoreTypes get coreTypes => compiler.coreTypes; | |
| 613 | |
| 614 Resolution get resolution => compiler.resolution; | 610 Resolution get resolution => compiler.resolution; |
| 615 | 611 |
| 616 /// Returns constant environment for the JavaScript interpretation of the | 612 /// Returns constant environment for the JavaScript interpretation of the |
| 617 /// constants. | 613 /// constants. |
| 618 JavaScriptConstantCompiler get constants { | 614 JavaScriptConstantCompiler get constants { |
| 619 return constantCompilerTask.jsConstantCompiler; | 615 return constantCompilerTask.jsConstantCompiler; |
| 620 } | 616 } |
| 621 | 617 |
| 622 @override | 618 @override |
| 623 bool isDefaultNoSuchMethod(MethodElement element) { | 619 bool isDefaultNoSuchMethod(MethodElement element) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 671 } |
| 676 return element; | 672 return element; |
| 677 } | 673 } |
| 678 | 674 |
| 679 bool _isValidBackendUse(Element element) { | 675 bool _isValidBackendUse(Element element) { |
| 680 assert(invariant(element, element.isDeclaration, message: "")); | 676 assert(invariant(element, element.isDeclaration, message: "")); |
| 681 if (element == helpers.streamIteratorConstructor || | 677 if (element == helpers.streamIteratorConstructor || |
| 682 compiler.commonElements.isSymbolConstructor(element) || | 678 compiler.commonElements.isSymbolConstructor(element) || |
| 683 helpers.isSymbolValidatedConstructor(element) || | 679 helpers.isSymbolValidatedConstructor(element) || |
| 684 element == helpers.syncCompleterConstructor || | 680 element == helpers.syncCompleterConstructor || |
| 685 element == coreClasses.symbolClass || | 681 element == commonElements.symbolClass || |
| 686 element == helpers.objectNoSuchMethod) { | 682 element == helpers.objectNoSuchMethod) { |
| 687 // TODO(johnniwinther): These are valid but we could be more precise. | 683 // TODO(johnniwinther): These are valid but we could be more precise. |
| 688 return true; | 684 return true; |
| 689 } else if (element.implementationLibrary.isPatch || | 685 } else if (element.implementationLibrary.isPatch || |
| 690 // Needed to detect deserialized injected elements, that is | 686 // Needed to detect deserialized injected elements, that is |
| 691 // element declared in patch files. | 687 // element declared in patch files. |
| 692 (element.library.isPlatformLibrary && | 688 (element.library.isPlatformLibrary && |
| 693 element.sourcePosition.uri.path | 689 element.sourcePosition.uri.path |
| 694 .contains('_internal/js_runtime/lib/')) || | 690 .contains('_internal/js_runtime/lib/')) || |
| 695 element.library == helpers.jsHelperLibrary || | 691 element.library == helpers.jsHelperLibrary || |
| 696 element.library == helpers.interceptorsLibrary || | 692 element.library == helpers.interceptorsLibrary || |
| 697 element.library == helpers.isolateHelperLibrary) { | 693 element.library == helpers.isolateHelperLibrary) { |
| 698 // TODO(johnniwinther): We should be more precise about these. | 694 // TODO(johnniwinther): We should be more precise about these. |
| 699 return true; | 695 return true; |
| 700 } else if (element == coreClasses.listClass || | 696 } else if (element == commonElements.listClass || |
| 701 element == helpers.mapLiteralClass || | 697 element == helpers.mapLiteralClass || |
| 702 element == coreClasses.functionClass || | 698 element == commonElements.functionClass || |
| 703 element == coreClasses.stringClass) { | 699 element == commonElements.stringClass) { |
| 704 // TODO(johnniwinther): Avoid these. | 700 // TODO(johnniwinther): Avoid these. |
| 705 return true; | 701 return true; |
| 706 } else if (element == helpers.genericNoSuchMethod || | 702 } else if (element == helpers.genericNoSuchMethod || |
| 707 element == helpers.unresolvedConstructorError || | 703 element == helpers.unresolvedConstructorError || |
| 708 element == helpers.malformedTypeError) { | 704 element == helpers.malformedTypeError) { |
| 709 return true; | 705 return true; |
| 710 } | 706 } |
| 711 return false; | 707 return false; |
| 712 } | 708 } |
| 713 | 709 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 } | 967 } |
| 972 | 968 |
| 973 bool operatorEqHandlesNullArgument(FunctionElement operatorEqfunction) { | 969 bool operatorEqHandlesNullArgument(FunctionElement operatorEqfunction) { |
| 974 return specialOperatorEqClasses.contains(operatorEqfunction.enclosingClass); | 970 return specialOperatorEqClasses.contains(operatorEqfunction.enclosingClass); |
| 975 } | 971 } |
| 976 | 972 |
| 977 void validateInterceptorImplementsAllObjectMethods( | 973 void validateInterceptorImplementsAllObjectMethods( |
| 978 ClassElement interceptorClass) { | 974 ClassElement interceptorClass) { |
| 979 if (interceptorClass == null) return; | 975 if (interceptorClass == null) return; |
| 980 interceptorClass.ensureResolved(resolution); | 976 interceptorClass.ensureResolved(resolution); |
| 981 coreClasses.objectClass.forEachMember((_, Element member) { | 977 commonElements.objectClass.forEachMember((_, Element member) { |
| 982 if (member.isGenerativeConstructor) return; | 978 if (member.isGenerativeConstructor) return; |
| 983 Element interceptorMember = interceptorClass.lookupMember(member.name); | 979 Element interceptorMember = interceptorClass.lookupMember(member.name); |
| 984 // Interceptors must override all Object methods due to calling convention | 980 // Interceptors must override all Object methods due to calling convention |
| 985 // differences. | 981 // differences. |
| 986 assert(invariant(interceptorMember, | 982 assert(invariant(interceptorMember, |
| 987 interceptorMember.enclosingClass == interceptorClass, | 983 interceptorMember.enclosingClass == interceptorClass, |
| 988 message: | 984 message: |
| 989 "Member ${member.name} not overridden in ${interceptorClass}. " | 985 "Member ${member.name} not overridden in ${interceptorClass}. " |
| 990 "Found $interceptorMember from " | 986 "Found $interceptorMember from " |
| 991 "${interceptorMember.enclosingClass}.")); | 987 "${interceptorMember.enclosingClass}.")); |
| 992 }); | 988 }); |
| 993 } | 989 } |
| 994 | 990 |
| 995 void addInterceptorsForNativeClassMembers(ClassElement cls, | 991 void addInterceptorsForNativeClassMembers(ClassElement cls, |
| 996 {bool forResolution}) { | 992 {bool forResolution}) { |
| 997 if (forResolution) { | 993 if (forResolution) { |
| 998 cls.ensureResolved(resolution); | 994 cls.ensureResolved(resolution); |
| 999 cls.forEachMember((ClassElement classElement, Element member) { | 995 cls.forEachMember((ClassElement classElement, Element member) { |
| 1000 if (member.name == Identifiers.call) { | 996 if (member.name == Identifiers.call) { |
| 1001 return; | 997 return; |
| 1002 } | 998 } |
| 1003 if (member.isSynthesized) return; | 999 if (member.isSynthesized) return; |
| 1004 // All methods on [Object] are shadowed by [Interceptor]. | 1000 // All methods on [Object] are shadowed by [Interceptor]. |
| 1005 if (classElement == coreClasses.objectClass) return; | 1001 if (classElement == commonElements.objectClass) return; |
| 1006 Set<Element> set = interceptedElements.putIfAbsent( | 1002 Set<Element> set = interceptedElements.putIfAbsent( |
| 1007 member.name, () => new Set<Element>()); | 1003 member.name, () => new Set<Element>()); |
| 1008 set.add(member); | 1004 set.add(member); |
| 1009 }, includeSuperAndInjectedMembers: true); | 1005 }, includeSuperAndInjectedMembers: true); |
| 1010 | 1006 |
| 1011 // Walk superclass chain to find mixins. | 1007 // Walk superclass chain to find mixins. |
| 1012 for (; cls != null; cls = cls.superclass) { | 1008 for (; cls != null; cls = cls.superclass) { |
| 1013 if (cls.isMixinApplication) { | 1009 if (cls.isMixinApplication) { |
| 1014 MixinApplicationElement mixinApplication = cls; | 1010 MixinApplicationElement mixinApplication = cls; |
| 1015 classesMixedIntoInterceptedClasses.add(mixinApplication.mixin); | 1011 classesMixedIntoInterceptedClasses.add(mixinApplication.mixin); |
| 1016 } | 1012 } |
| 1017 } | 1013 } |
| 1018 } | 1014 } |
| 1019 } | 1015 } |
| 1020 | 1016 |
| 1021 void addInterceptors(ClassElement cls, WorldImpactBuilder impactBuilder, | 1017 void addInterceptors(ClassElement cls, WorldImpactBuilder impactBuilder, |
| 1022 {bool forResolution}) { | 1018 {bool forResolution}) { |
| 1023 if (forResolution) { | 1019 if (forResolution) { |
| 1024 if (_interceptedClasses.add(cls)) { | 1020 if (_interceptedClasses.add(cls)) { |
| 1025 cls.ensureResolved(resolution); | 1021 cls.ensureResolved(resolution); |
| 1026 cls.forEachMember((ClassElement classElement, Element member) { | 1022 cls.forEachMember((ClassElement classElement, Element member) { |
| 1027 // All methods on [Object] are shadowed by [Interceptor]. | 1023 // All methods on [Object] are shadowed by [Interceptor]. |
| 1028 if (classElement == coreClasses.objectClass) return; | 1024 if (classElement == commonElements.objectClass) return; |
| 1029 Set<Element> set = interceptedElements.putIfAbsent( | 1025 Set<Element> set = interceptedElements.putIfAbsent( |
| 1030 member.name, () => new Set<Element>()); | 1026 member.name, () => new Set<Element>()); |
| 1031 set.add(member); | 1027 set.add(member); |
| 1032 }, includeSuperAndInjectedMembers: true); | 1028 }, includeSuperAndInjectedMembers: true); |
| 1033 } | 1029 } |
| 1034 _interceptedClasses.add(helpers.jsInterceptorClass); | 1030 _interceptedClasses.add(helpers.jsInterceptorClass); |
| 1035 } | 1031 } |
| 1036 impactTransformer.registerBackendInstantiation(impactBuilder, cls); | 1032 impactTransformer.registerBackendInstantiation(impactBuilder, cls); |
| 1037 } | 1033 } |
| 1038 | 1034 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1068 dependency, impactBuilder, isForResolution); | 1064 dependency, impactBuilder, isForResolution); |
| 1069 } | 1065 } |
| 1070 } | 1066 } |
| 1071 | 1067 |
| 1072 void addCompileTimeConstantForEmission(ConstantValue constant) { | 1068 void addCompileTimeConstantForEmission(ConstantValue constant) { |
| 1073 constants.addCompileTimeConstantForEmission(constant); | 1069 constants.addCompileTimeConstantForEmission(constant); |
| 1074 } | 1070 } |
| 1075 | 1071 |
| 1076 void computeImpactForCompileTimeConstantInternal(ConstantValue constant, | 1072 void computeImpactForCompileTimeConstantInternal(ConstantValue constant, |
| 1077 WorldImpactBuilder impactBuilder, bool isForResolution) { | 1073 WorldImpactBuilder impactBuilder, bool isForResolution) { |
| 1078 DartType type = constant.getType(compiler.coreTypes); | 1074 DartType type = constant.getType(compiler.commonElements); |
| 1079 computeImpactForInstantiatedConstantType(type, impactBuilder); | 1075 computeImpactForInstantiatedConstantType(type, impactBuilder); |
| 1080 | 1076 |
| 1081 if (constant.isFunction) { | 1077 if (constant.isFunction) { |
| 1082 FunctionConstantValue function = constant; | 1078 FunctionConstantValue function = constant; |
| 1083 impactBuilder | 1079 impactBuilder |
| 1084 .registerStaticUse(new StaticUse.staticTearOff(function.element)); | 1080 .registerStaticUse(new StaticUse.staticTearOff(function.element)); |
| 1085 } else if (constant.isInterceptor) { | 1081 } else if (constant.isInterceptor) { |
| 1086 // An interceptor constant references the class's prototype chain. | 1082 // An interceptor constant references the class's prototype chain. |
| 1087 InterceptorConstantValue interceptor = constant; | 1083 InterceptorConstantValue interceptor = constant; |
| 1088 computeImpactForInstantiatedConstantType( | 1084 computeImpactForInstantiatedConstantType( |
| 1089 interceptor.dispatchedType, impactBuilder); | 1085 interceptor.dispatchedType, impactBuilder); |
| 1090 } else if (constant.isType) { | 1086 } else if (constant.isType) { |
| 1091 if (isForResolution) { | 1087 if (isForResolution) { |
| 1092 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( | 1088 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( |
| 1093 // TODO(johnniwinther): Find the right [CallStructure]. | 1089 // TODO(johnniwinther): Find the right [CallStructure]. |
| 1094 helpers.createRuntimeType, | 1090 helpers.createRuntimeType, |
| 1095 null)); | 1091 null)); |
| 1096 registerBackendUse(helpers.createRuntimeType); | 1092 registerBackendUse(helpers.createRuntimeType); |
| 1097 } | 1093 } |
| 1098 impactBuilder.registerTypeUse( | 1094 impactBuilder.registerTypeUse( |
| 1099 new TypeUse.instantiation(backendClasses.typeImplementation.rawType)); | 1095 new TypeUse.instantiation(backendClasses.typeImplementation.rawType)); |
| 1100 } | 1096 } |
| 1101 lookupMapAnalysis.registerConstantKey(constant); | 1097 lookupMapAnalysis.registerConstantKey(constant); |
| 1102 } | 1098 } |
| 1103 | 1099 |
| 1104 void computeImpactForInstantiatedConstantType( | 1100 void computeImpactForInstantiatedConstantType( |
| 1105 DartType type, WorldImpactBuilder impactBuilder) { | 1101 DartType type, WorldImpactBuilder impactBuilder) { |
| 1106 DartType instantiatedType = | 1102 DartType instantiatedType = |
| 1107 type.isFunctionType ? coreTypes.functionType : type; | 1103 type.isFunctionType ? commonElements.functionType : type; |
| 1108 if (type is InterfaceType) { | 1104 if (type is InterfaceType) { |
| 1109 impactBuilder | 1105 impactBuilder |
| 1110 .registerTypeUse(new TypeUse.instantiation(instantiatedType)); | 1106 .registerTypeUse(new TypeUse.instantiation(instantiatedType)); |
| 1111 if (classNeedsRtiField(type.element)) { | 1107 if (classNeedsRtiField(type.element)) { |
| 1112 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( | 1108 impactBuilder.registerStaticUse(new StaticUse.staticInvoke( |
| 1113 // TODO(johnniwinther): Find the right [CallStructure]. | 1109 // TODO(johnniwinther): Find the right [CallStructure]. |
| 1114 helpers.setRuntimeTypeInfo, | 1110 helpers.setRuntimeTypeInfo, |
| 1115 null)); | 1111 null)); |
| 1116 } | 1112 } |
| 1117 if (type.element == backendClasses.typeImplementation) { | 1113 if (type.element == backendClasses.typeImplementation) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1137 | 1133 |
| 1138 WorldImpact _processClass(ClassElement cls, {bool forResolution}) { | 1134 WorldImpact _processClass(ClassElement cls, {bool forResolution}) { |
| 1139 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl(); | 1135 WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl(); |
| 1140 if (!cls.typeVariables.isEmpty) { | 1136 if (!cls.typeVariables.isEmpty) { |
| 1141 typeVariableHandler.registerClassWithTypeVariables(cls, | 1137 typeVariableHandler.registerClassWithTypeVariables(cls, |
| 1142 forResolution: forResolution); | 1138 forResolution: forResolution); |
| 1143 } | 1139 } |
| 1144 | 1140 |
| 1145 // Register any helper that will be needed by the backend. | 1141 // Register any helper that will be needed by the backend. |
| 1146 if (forResolution) { | 1142 if (forResolution) { |
| 1147 if (cls == coreClasses.intClass || | 1143 if (cls == commonElements.intClass || |
| 1148 cls == coreClasses.doubleClass || | 1144 cls == commonElements.doubleClass || |
| 1149 cls == coreClasses.numClass) { | 1145 cls == commonElements.numClass) { |
| 1150 impactTransformer.registerBackendImpact( | 1146 impactTransformer.registerBackendImpact( |
| 1151 impactBuilder, impacts.numClasses); | 1147 impactBuilder, impacts.numClasses); |
| 1152 } else if (cls == coreClasses.listClass || | 1148 } else if (cls == commonElements.listClass || |
| 1153 cls == coreClasses.stringClass) { | 1149 cls == commonElements.stringClass) { |
| 1154 impactTransformer.registerBackendImpact( | 1150 impactTransformer.registerBackendImpact( |
| 1155 impactBuilder, impacts.listOrStringClasses); | 1151 impactBuilder, impacts.listOrStringClasses); |
| 1156 } else if (cls == coreClasses.functionClass) { | 1152 } else if (cls == commonElements.functionClass) { |
| 1157 impactTransformer.registerBackendImpact( | 1153 impactTransformer.registerBackendImpact( |
| 1158 impactBuilder, impacts.functionClass); | 1154 impactBuilder, impacts.functionClass); |
| 1159 } else if (cls == coreClasses.mapClass) { | 1155 } else if (cls == commonElements.mapClass) { |
| 1160 impactTransformer.registerBackendImpact( | 1156 impactTransformer.registerBackendImpact( |
| 1161 impactBuilder, impacts.mapClass); | 1157 impactBuilder, impacts.mapClass); |
| 1162 // For map literals, the dependency between the implementation class | 1158 // For map literals, the dependency between the implementation class |
| 1163 // and [Map] is not visible, so we have to add it manually. | 1159 // and [Map] is not visible, so we have to add it manually. |
| 1164 rti.registerRtiDependency(helpers.mapLiteralClass, cls); | 1160 rti.registerRtiDependency(helpers.mapLiteralClass, cls); |
| 1165 } else if (cls == helpers.boundClosureClass) { | 1161 } else if (cls == helpers.boundClosureClass) { |
| 1166 impactTransformer.registerBackendImpact( | 1162 impactTransformer.registerBackendImpact( |
| 1167 impactBuilder, impacts.boundClosureClass); | 1163 impactBuilder, impacts.boundClosureClass); |
| 1168 } else if (isNativeOrExtendsNative(cls)) { | 1164 } else if (isNativeOrExtendsNative(cls)) { |
| 1169 impactTransformer.registerBackendImpact( | 1165 impactTransformer.registerBackendImpact( |
| 1170 impactBuilder, impacts.nativeOrExtendsClass); | 1166 impactBuilder, impacts.nativeOrExtendsClass); |
| 1171 } else if (cls == helpers.mapLiteralClass) { | 1167 } else if (cls == helpers.mapLiteralClass) { |
| 1172 impactTransformer.registerBackendImpact( | 1168 impactTransformer.registerBackendImpact( |
| 1173 impactBuilder, impacts.mapLiteralClass); | 1169 impactBuilder, impacts.mapLiteralClass); |
| 1174 } | 1170 } |
| 1175 } | 1171 } |
| 1176 if (cls == helpers.closureClass) { | 1172 if (cls == helpers.closureClass) { |
| 1177 impactTransformer.registerBackendImpact( | 1173 impactTransformer.registerBackendImpact( |
| 1178 impactBuilder, impacts.closureClass); | 1174 impactBuilder, impacts.closureClass); |
| 1179 } | 1175 } |
| 1180 if (cls == coreClasses.stringClass || cls == helpers.jsStringClass) { | 1176 if (cls == commonElements.stringClass || cls == helpers.jsStringClass) { |
| 1181 addInterceptors(helpers.jsStringClass, impactBuilder, | 1177 addInterceptors(helpers.jsStringClass, impactBuilder, |
| 1182 forResolution: forResolution); | 1178 forResolution: forResolution); |
| 1183 } else if (cls == coreClasses.listClass || | 1179 } else if (cls == commonElements.listClass || |
| 1184 cls == helpers.jsArrayClass || | 1180 cls == helpers.jsArrayClass || |
| 1185 cls == helpers.jsFixedArrayClass || | 1181 cls == helpers.jsFixedArrayClass || |
| 1186 cls == helpers.jsExtendableArrayClass || | 1182 cls == helpers.jsExtendableArrayClass || |
| 1187 cls == helpers.jsUnmodifiableArrayClass) { | 1183 cls == helpers.jsUnmodifiableArrayClass) { |
| 1188 addInterceptors(helpers.jsArrayClass, impactBuilder, | 1184 addInterceptors(helpers.jsArrayClass, impactBuilder, |
| 1189 forResolution: forResolution); | 1185 forResolution: forResolution); |
| 1190 addInterceptors(helpers.jsMutableArrayClass, impactBuilder, | 1186 addInterceptors(helpers.jsMutableArrayClass, impactBuilder, |
| 1191 forResolution: forResolution); | 1187 forResolution: forResolution); |
| 1192 addInterceptors(helpers.jsFixedArrayClass, impactBuilder, | 1188 addInterceptors(helpers.jsFixedArrayClass, impactBuilder, |
| 1193 forResolution: forResolution); | 1189 forResolution: forResolution); |
| 1194 addInterceptors(helpers.jsExtendableArrayClass, impactBuilder, | 1190 addInterceptors(helpers.jsExtendableArrayClass, impactBuilder, |
| 1195 forResolution: forResolution); | 1191 forResolution: forResolution); |
| 1196 addInterceptors(helpers.jsUnmodifiableArrayClass, impactBuilder, | 1192 addInterceptors(helpers.jsUnmodifiableArrayClass, impactBuilder, |
| 1197 forResolution: forResolution); | 1193 forResolution: forResolution); |
| 1198 if (forResolution) { | 1194 if (forResolution) { |
| 1199 impactTransformer.registerBackendImpact( | 1195 impactTransformer.registerBackendImpact( |
| 1200 impactBuilder, impacts.listClasses); | 1196 impactBuilder, impacts.listClasses); |
| 1201 } | 1197 } |
| 1202 } else if (cls == coreClasses.intClass || cls == helpers.jsIntClass) { | 1198 } else if (cls == commonElements.intClass || cls == helpers.jsIntClass) { |
| 1203 addInterceptors(helpers.jsIntClass, impactBuilder, | 1199 addInterceptors(helpers.jsIntClass, impactBuilder, |
| 1204 forResolution: forResolution); | 1200 forResolution: forResolution); |
| 1205 addInterceptors(helpers.jsPositiveIntClass, impactBuilder, | 1201 addInterceptors(helpers.jsPositiveIntClass, impactBuilder, |
| 1206 forResolution: forResolution); | 1202 forResolution: forResolution); |
| 1207 addInterceptors(helpers.jsUInt32Class, impactBuilder, | 1203 addInterceptors(helpers.jsUInt32Class, impactBuilder, |
| 1208 forResolution: forResolution); | 1204 forResolution: forResolution); |
| 1209 addInterceptors(helpers.jsUInt31Class, impactBuilder, | 1205 addInterceptors(helpers.jsUInt31Class, impactBuilder, |
| 1210 forResolution: forResolution); | 1206 forResolution: forResolution); |
| 1211 addInterceptors(helpers.jsNumberClass, impactBuilder, | 1207 addInterceptors(helpers.jsNumberClass, impactBuilder, |
| 1212 forResolution: forResolution); | 1208 forResolution: forResolution); |
| 1213 } else if (cls == coreClasses.doubleClass || cls == helpers.jsDoubleClass) { | 1209 } else if (cls == commonElements.doubleClass || |
| 1210 cls == helpers.jsDoubleClass) { |
| 1214 addInterceptors(helpers.jsDoubleClass, impactBuilder, | 1211 addInterceptors(helpers.jsDoubleClass, impactBuilder, |
| 1215 forResolution: forResolution); | 1212 forResolution: forResolution); |
| 1216 addInterceptors(helpers.jsNumberClass, impactBuilder, | 1213 addInterceptors(helpers.jsNumberClass, impactBuilder, |
| 1217 forResolution: forResolution); | 1214 forResolution: forResolution); |
| 1218 } else if (cls == coreClasses.boolClass || cls == helpers.jsBoolClass) { | 1215 } else if (cls == commonElements.boolClass || cls == helpers.jsBoolClass) { |
| 1219 addInterceptors(helpers.jsBoolClass, impactBuilder, | 1216 addInterceptors(helpers.jsBoolClass, impactBuilder, |
| 1220 forResolution: forResolution); | 1217 forResolution: forResolution); |
| 1221 } else if (cls == coreClasses.nullClass || cls == helpers.jsNullClass) { | 1218 } else if (cls == commonElements.nullClass || cls == helpers.jsNullClass) { |
| 1222 addInterceptors(helpers.jsNullClass, impactBuilder, | 1219 addInterceptors(helpers.jsNullClass, impactBuilder, |
| 1223 forResolution: forResolution); | 1220 forResolution: forResolution); |
| 1224 } else if (cls == coreClasses.numClass || cls == helpers.jsNumberClass) { | 1221 } else if (cls == commonElements.numClass || cls == helpers.jsNumberClass) { |
| 1225 addInterceptors(helpers.jsIntClass, impactBuilder, | 1222 addInterceptors(helpers.jsIntClass, impactBuilder, |
| 1226 forResolution: forResolution); | 1223 forResolution: forResolution); |
| 1227 addInterceptors(helpers.jsPositiveIntClass, impactBuilder, | 1224 addInterceptors(helpers.jsPositiveIntClass, impactBuilder, |
| 1228 forResolution: forResolution); | 1225 forResolution: forResolution); |
| 1229 addInterceptors(helpers.jsUInt32Class, impactBuilder, | 1226 addInterceptors(helpers.jsUInt32Class, impactBuilder, |
| 1230 forResolution: forResolution); | 1227 forResolution: forResolution); |
| 1231 addInterceptors(helpers.jsUInt31Class, impactBuilder, | 1228 addInterceptors(helpers.jsUInt31Class, impactBuilder, |
| 1232 forResolution: forResolution); | 1229 forResolution: forResolution); |
| 1233 addInterceptors(helpers.jsDoubleClass, impactBuilder, | 1230 addInterceptors(helpers.jsDoubleClass, impactBuilder, |
| 1234 forResolution: forResolution); | 1231 forResolution: forResolution); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 return new native.NativeCodegenEnqueuer(compiler, emitter); | 1517 return new native.NativeCodegenEnqueuer(compiler, emitter); |
| 1521 } | 1518 } |
| 1522 | 1519 |
| 1523 ClassElement defaultSuperclass(ClassElement element) { | 1520 ClassElement defaultSuperclass(ClassElement element) { |
| 1524 if (isJsInterop(element)) { | 1521 if (isJsInterop(element)) { |
| 1525 return helpers.jsJavaScriptObjectClass; | 1522 return helpers.jsJavaScriptObjectClass; |
| 1526 } | 1523 } |
| 1527 // Native classes inherit from Interceptor. | 1524 // Native classes inherit from Interceptor. |
| 1528 return isNative(element) | 1525 return isNative(element) |
| 1529 ? helpers.jsInterceptorClass | 1526 ? helpers.jsInterceptorClass |
| 1530 : coreClasses.objectClass; | 1527 : commonElements.objectClass; |
| 1531 } | 1528 } |
| 1532 | 1529 |
| 1533 /** | 1530 /** |
| 1534 * Unit test hook that returns code of an element as a String. | 1531 * Unit test hook that returns code of an element as a String. |
| 1535 * | 1532 * |
| 1536 * Invariant: [element] must be a declaration element. | 1533 * Invariant: [element] must be a declaration element. |
| 1537 */ | 1534 */ |
| 1538 String getGeneratedCode(Element element) { | 1535 String getGeneratedCode(Element element) { |
| 1539 assert(invariant(element, element.isDeclaration)); | 1536 assert(invariant(element, element.isDeclaration)); |
| 1540 return jsAst.prettyPrint(generatedCode[element], compiler); | 1537 return jsAst.prettyPrint(generatedCode[element], compiler); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 // TODO(13955), TODO(9731). The test for non-primitive types should use an | 1631 // TODO(13955), TODO(9731). The test for non-primitive types should use an |
| 1635 // interceptor. The interceptor should be an argument to HTypeConversion so | 1632 // interceptor. The interceptor should be an argument to HTypeConversion so |
| 1636 // that it can be optimized by standard interceptor optimizations. | 1633 // that it can be optimized by standard interceptor optimizations. |
| 1637 nativeCheck = true; | 1634 nativeCheck = true; |
| 1638 | 1635 |
| 1639 if (type.isVoid) { | 1636 if (type.isVoid) { |
| 1640 assert(!typeCast); // Cannot cast to void. | 1637 assert(!typeCast); // Cannot cast to void. |
| 1641 if (nativeCheckOnly) return null; | 1638 if (nativeCheckOnly) return null; |
| 1642 return 'voidTypeCheck'; | 1639 return 'voidTypeCheck'; |
| 1643 } else if (element == helpers.jsStringClass || | 1640 } else if (element == helpers.jsStringClass || |
| 1644 element == coreClasses.stringClass) { | 1641 element == commonElements.stringClass) { |
| 1645 if (nativeCheckOnly) return null; | 1642 if (nativeCheckOnly) return null; |
| 1646 return typeCast ? 'stringTypeCast' : 'stringTypeCheck'; | 1643 return typeCast ? 'stringTypeCast' : 'stringTypeCheck'; |
| 1647 } else if (element == helpers.jsDoubleClass || | 1644 } else if (element == helpers.jsDoubleClass || |
| 1648 element == coreClasses.doubleClass) { | 1645 element == commonElements.doubleClass) { |
| 1649 if (nativeCheckOnly) return null; | 1646 if (nativeCheckOnly) return null; |
| 1650 return typeCast ? 'doubleTypeCast' : 'doubleTypeCheck'; | 1647 return typeCast ? 'doubleTypeCast' : 'doubleTypeCheck'; |
| 1651 } else if (element == helpers.jsNumberClass || | 1648 } else if (element == helpers.jsNumberClass || |
| 1652 element == coreClasses.numClass) { | 1649 element == commonElements.numClass) { |
| 1653 if (nativeCheckOnly) return null; | 1650 if (nativeCheckOnly) return null; |
| 1654 return typeCast ? 'numTypeCast' : 'numTypeCheck'; | 1651 return typeCast ? 'numTypeCast' : 'numTypeCheck'; |
| 1655 } else if (element == helpers.jsBoolClass || | 1652 } else if (element == helpers.jsBoolClass || |
| 1656 element == coreClasses.boolClass) { | 1653 element == commonElements.boolClass) { |
| 1657 if (nativeCheckOnly) return null; | 1654 if (nativeCheckOnly) return null; |
| 1658 return typeCast ? 'boolTypeCast' : 'boolTypeCheck'; | 1655 return typeCast ? 'boolTypeCast' : 'boolTypeCheck'; |
| 1659 } else if (element == helpers.jsIntClass || | 1656 } else if (element == helpers.jsIntClass || |
| 1660 element == coreClasses.intClass || | 1657 element == commonElements.intClass || |
| 1661 element == helpers.jsUInt32Class || | 1658 element == helpers.jsUInt32Class || |
| 1662 element == helpers.jsUInt31Class || | 1659 element == helpers.jsUInt31Class || |
| 1663 element == helpers.jsPositiveIntClass) { | 1660 element == helpers.jsPositiveIntClass) { |
| 1664 if (nativeCheckOnly) return null; | 1661 if (nativeCheckOnly) return null; |
| 1665 return typeCast ? 'intTypeCast' : 'intTypeCheck'; | 1662 return typeCast ? 'intTypeCast' : 'intTypeCheck'; |
| 1666 } else if (Elements.isNumberOrStringSupertype(element, commonElements)) { | 1663 } else if (Elements.isNumberOrStringSupertype(element, commonElements)) { |
| 1667 if (nativeCheck) { | 1664 if (nativeCheck) { |
| 1668 return typeCast | 1665 return typeCast |
| 1669 ? 'numberOrStringSuperNativeTypeCast' | 1666 ? 'numberOrStringSuperNativeTypeCast' |
| 1670 : 'numberOrStringSuperNativeTypeCheck'; | 1667 : 'numberOrStringSuperNativeTypeCheck'; |
| 1671 } else { | 1668 } else { |
| 1672 return typeCast | 1669 return typeCast |
| 1673 ? 'numberOrStringSuperTypeCast' | 1670 ? 'numberOrStringSuperTypeCast' |
| 1674 : 'numberOrStringSuperTypeCheck'; | 1671 : 'numberOrStringSuperTypeCheck'; |
| 1675 } | 1672 } |
| 1676 } else if (Elements.isStringOnlySupertype(element, commonElements)) { | 1673 } else if (Elements.isStringOnlySupertype(element, commonElements)) { |
| 1677 if (nativeCheck) { | 1674 if (nativeCheck) { |
| 1678 return typeCast | 1675 return typeCast |
| 1679 ? 'stringSuperNativeTypeCast' | 1676 ? 'stringSuperNativeTypeCast' |
| 1680 : 'stringSuperNativeTypeCheck'; | 1677 : 'stringSuperNativeTypeCheck'; |
| 1681 } else { | 1678 } else { |
| 1682 return typeCast ? 'stringSuperTypeCast' : 'stringSuperTypeCheck'; | 1679 return typeCast ? 'stringSuperTypeCast' : 'stringSuperTypeCheck'; |
| 1683 } | 1680 } |
| 1684 } else if ((element == coreClasses.listClass || | 1681 } else if ((element == commonElements.listClass || |
| 1685 element == helpers.jsArrayClass) && | 1682 element == helpers.jsArrayClass) && |
| 1686 type.treatAsRaw) { | 1683 type.treatAsRaw) { |
| 1687 if (nativeCheckOnly) return null; | 1684 if (nativeCheckOnly) return null; |
| 1688 return typeCast ? 'listTypeCast' : 'listTypeCheck'; | 1685 return typeCast ? 'listTypeCast' : 'listTypeCheck'; |
| 1689 } else { | 1686 } else { |
| 1690 if (Elements.isListSupertype(element, commonElements)) { | 1687 if (Elements.isListSupertype(element, commonElements)) { |
| 1691 if (nativeCheck) { | 1688 if (nativeCheck) { |
| 1692 return typeCast | 1689 return typeCast |
| 1693 ? 'listSuperNativeTypeCast' | 1690 ? 'listSuperNativeTypeCast' |
| 1694 : 'listSuperNativeTypeCheck'; | 1691 : 'listSuperNativeTypeCheck'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 impactTransformer.registerBackendImpact( | 1724 impactTransformer.registerBackendImpact( |
| 1728 impactBuilder, new BackendImpact(globalUses: staticUses)); | 1725 impactBuilder, new BackendImpact(globalUses: staticUses)); |
| 1729 } | 1726 } |
| 1730 | 1727 |
| 1731 /** | 1728 /** |
| 1732 * Returns [:true:] if the checking of [type] is performed directly on the | 1729 * Returns [:true:] if the checking of [type] is performed directly on the |
| 1733 * object and not on an interceptor. | 1730 * object and not on an interceptor. |
| 1734 */ | 1731 */ |
| 1735 bool hasDirectCheckFor(DartType type) { | 1732 bool hasDirectCheckFor(DartType type) { |
| 1736 Element element = type.element; | 1733 Element element = type.element; |
| 1737 return element == coreClasses.stringClass || | 1734 return element == commonElements.stringClass || |
| 1738 element == coreClasses.boolClass || | 1735 element == commonElements.boolClass || |
| 1739 element == coreClasses.numClass || | 1736 element == commonElements.numClass || |
| 1740 element == coreClasses.intClass || | 1737 element == commonElements.intClass || |
| 1741 element == coreClasses.doubleClass || | 1738 element == commonElements.doubleClass || |
| 1742 element == helpers.jsArrayClass || | 1739 element == helpers.jsArrayClass || |
| 1743 element == helpers.jsMutableArrayClass || | 1740 element == helpers.jsMutableArrayClass || |
| 1744 element == helpers.jsExtendableArrayClass || | 1741 element == helpers.jsExtendableArrayClass || |
| 1745 element == helpers.jsFixedArrayClass || | 1742 element == helpers.jsFixedArrayClass || |
| 1746 element == helpers.jsUnmodifiableArrayClass; | 1743 element == helpers.jsUnmodifiableArrayClass; |
| 1747 } | 1744 } |
| 1748 | 1745 |
| 1749 bool mayGenerateInstanceofCheck(DartType type) { | 1746 bool mayGenerateInstanceofCheck(DartType type) { |
| 1750 // We can use an instanceof check for raw types that have no subclass that | 1747 // We can use an instanceof check for raw types that have no subclass that |
| 1751 // is mixed-in or in an implements clause. | 1748 // is mixed-in or in an implements clause. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 } | 1904 } |
| 1908 | 1905 |
| 1909 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 1906 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 1910 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { | 1907 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { |
| 1911 return new Future.value(); | 1908 return new Future.value(); |
| 1912 } | 1909 } |
| 1913 | 1910 |
| 1914 helpers.onLibrariesLoaded(loadedLibraries); | 1911 helpers.onLibrariesLoaded(loadedLibraries); |
| 1915 | 1912 |
| 1916 implementationClasses = <ClassElement, ClassElement>{}; | 1913 implementationClasses = <ClassElement, ClassElement>{}; |
| 1917 implementationClasses[coreClasses.intClass] = helpers.jsIntClass; | 1914 implementationClasses[commonElements.intClass] = helpers.jsIntClass; |
| 1918 implementationClasses[coreClasses.boolClass] = helpers.jsBoolClass; | 1915 implementationClasses[commonElements.boolClass] = helpers.jsBoolClass; |
| 1919 implementationClasses[coreClasses.numClass] = helpers.jsNumberClass; | 1916 implementationClasses[commonElements.numClass] = helpers.jsNumberClass; |
| 1920 implementationClasses[coreClasses.doubleClass] = helpers.jsDoubleClass; | 1917 implementationClasses[commonElements.doubleClass] = helpers.jsDoubleClass; |
| 1921 implementationClasses[coreClasses.stringClass] = helpers.jsStringClass; | 1918 implementationClasses[commonElements.stringClass] = helpers.jsStringClass; |
| 1922 implementationClasses[coreClasses.listClass] = helpers.jsArrayClass; | 1919 implementationClasses[commonElements.listClass] = helpers.jsArrayClass; |
| 1923 implementationClasses[coreClasses.nullClass] = helpers.jsNullClass; | 1920 implementationClasses[commonElements.nullClass] = helpers.jsNullClass; |
| 1924 | 1921 |
| 1925 // These methods are overwritten with generated versions. | 1922 // These methods are overwritten with generated versions. |
| 1926 inlineCache.markAsNonInlinable(helpers.getInterceptorMethod, | 1923 inlineCache.markAsNonInlinable(helpers.getInterceptorMethod, |
| 1927 insideLoop: true); | 1924 insideLoop: true); |
| 1928 | 1925 |
| 1929 specialOperatorEqClasses | 1926 specialOperatorEqClasses |
| 1930 ..add(coreClasses.objectClass) | 1927 ..add(commonElements.objectClass) |
| 1931 ..add(helpers.jsInterceptorClass) | 1928 ..add(helpers.jsInterceptorClass) |
| 1932 ..add(helpers.jsNullClass); | 1929 ..add(helpers.jsNullClass); |
| 1933 | 1930 |
| 1934 validateInterceptorImplementsAllObjectMethods(helpers.jsInterceptorClass); | 1931 validateInterceptorImplementsAllObjectMethods(helpers.jsInterceptorClass); |
| 1935 // The null-interceptor must also implement *all* methods. | 1932 // The null-interceptor must also implement *all* methods. |
| 1936 validateInterceptorImplementsAllObjectMethods(helpers.jsNullClass); | 1933 validateInterceptorImplementsAllObjectMethods(helpers.jsNullClass); |
| 1937 | 1934 |
| 1938 return new Future.value(); | 1935 return new Future.value(); |
| 1939 } | 1936 } |
| 1940 | 1937 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 bool matchesMirrorsMetaTarget(Element element) { | 2006 bool matchesMirrorsMetaTarget(Element element) { |
| 2010 if (metaTargetsUsed.isEmpty) return false; | 2007 if (metaTargetsUsed.isEmpty) return false; |
| 2011 for (MetadataAnnotation metadata in element.metadata) { | 2008 for (MetadataAnnotation metadata in element.metadata) { |
| 2012 // TODO(kasperl): It would be nice if we didn't have to resolve | 2009 // TODO(kasperl): It would be nice if we didn't have to resolve |
| 2013 // all metadata but only stuff that potentially would match one | 2010 // all metadata but only stuff that potentially would match one |
| 2014 // of the used meta targets. | 2011 // of the used meta targets. |
| 2015 metadata.ensureResolved(resolution); | 2012 metadata.ensureResolved(resolution); |
| 2016 ConstantValue value = | 2013 ConstantValue value = |
| 2017 compiler.constants.getConstantValue(metadata.constant); | 2014 compiler.constants.getConstantValue(metadata.constant); |
| 2018 if (value == null) continue; | 2015 if (value == null) continue; |
| 2019 DartType type = value.getType(compiler.coreTypes); | 2016 DartType type = value.getType(compiler.commonElements); |
| 2020 if (metaTargetsUsed.contains(type.element)) return true; | 2017 if (metaTargetsUsed.contains(type.element)) return true; |
| 2021 } | 2018 } |
| 2022 return false; | 2019 return false; |
| 2023 } | 2020 } |
| 2024 | 2021 |
| 2025 /** | 2022 /** |
| 2026 * Visits all classes and computes whether its members are needed for | 2023 * Visits all classes and computes whether its members are needed for |
| 2027 * reflection. | 2024 * reflection. |
| 2028 * | 2025 * |
| 2029 * We have to precompute this set as we cannot easily answer the need for | 2026 * We have to precompute this set as we cannot easily answer the need for |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 // TODO(johnniwinther): This should have its own uncatchable error. | 2733 // TODO(johnniwinther): This should have its own uncatchable error. |
| 2737 registerBackendImpact(transformed, impacts.throwRuntimeError); | 2734 registerBackendImpact(transformed, impacts.throwRuntimeError); |
| 2738 } | 2735 } |
| 2739 break; | 2736 break; |
| 2740 case Feature.FALL_THROUGH_ERROR: | 2737 case Feature.FALL_THROUGH_ERROR: |
| 2741 registerBackendImpact(transformed, impacts.fallThroughError); | 2738 registerBackendImpact(transformed, impacts.fallThroughError); |
| 2742 break; | 2739 break; |
| 2743 case Feature.FIELD_WITHOUT_INITIALIZER: | 2740 case Feature.FIELD_WITHOUT_INITIALIZER: |
| 2744 case Feature.LOCAL_WITHOUT_INITIALIZER: | 2741 case Feature.LOCAL_WITHOUT_INITIALIZER: |
| 2745 transformed.registerTypeUse( | 2742 transformed.registerTypeUse( |
| 2746 new TypeUse.instantiation(backend.coreTypes.nullType)); | 2743 new TypeUse.instantiation(backend.commonElements.nullType)); |
| 2747 registerBackendImpact(transformed, impacts.nullLiteral); | 2744 registerBackendImpact(transformed, impacts.nullLiteral); |
| 2748 break; | 2745 break; |
| 2749 case Feature.LAZY_FIELD: | 2746 case Feature.LAZY_FIELD: |
| 2750 registerBackendImpact(transformed, impacts.lazyField); | 2747 registerBackendImpact(transformed, impacts.lazyField); |
| 2751 break; | 2748 break; |
| 2752 case Feature.STACK_TRACE_IN_CATCH: | 2749 case Feature.STACK_TRACE_IN_CATCH: |
| 2753 registerBackendImpact(transformed, impacts.stackTraceInCatch); | 2750 registerBackendImpact(transformed, impacts.stackTraceInCatch); |
| 2754 break; | 2751 break; |
| 2755 case Feature.STRING_INTERPOLATION: | 2752 case Feature.STRING_INTERPOLATION: |
| 2756 registerBackendImpact(transformed, impacts.stringInterpolation); | 2753 registerBackendImpact(transformed, impacts.stringInterpolation); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2826 break; | 2823 break; |
| 2827 } | 2824 } |
| 2828 } | 2825 } |
| 2829 | 2826 |
| 2830 if (hasAsCast) { | 2827 if (hasAsCast) { |
| 2831 registerBackendImpact(transformed, impacts.asCheck); | 2828 registerBackendImpact(transformed, impacts.asCheck); |
| 2832 } | 2829 } |
| 2833 | 2830 |
| 2834 if (hasTypeLiteral) { | 2831 if (hasTypeLiteral) { |
| 2835 transformed.registerTypeUse( | 2832 transformed.registerTypeUse( |
| 2836 new TypeUse.instantiation(backend.compiler.coreTypes.typeType)); | 2833 new TypeUse.instantiation(backend.compiler.commonElements.typeType)); |
| 2837 registerBackendImpact(transformed, impacts.typeLiteral); | 2834 registerBackendImpact(transformed, impacts.typeLiteral); |
| 2838 } | 2835 } |
| 2839 | 2836 |
| 2840 for (MapLiteralUse mapLiteralUse in worldImpact.mapLiterals) { | 2837 for (MapLiteralUse mapLiteralUse in worldImpact.mapLiterals) { |
| 2841 // TODO(johnniwinther): Use the [isEmpty] property when factory | 2838 // TODO(johnniwinther): Use the [isEmpty] property when factory |
| 2842 // constructors are registered directly. | 2839 // constructors are registered directly. |
| 2843 if (mapLiteralUse.isConstant) { | 2840 if (mapLiteralUse.isConstant) { |
| 2844 registerBackendImpact(transformed, impacts.constantMapLiteral); | 2841 registerBackendImpact(transformed, impacts.constantMapLiteral); |
| 2845 } else { | 2842 } else { |
| 2846 transformed | 2843 transformed |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3221 ClassElement get fixedListImplementation => helpers.jsFixedArrayClass; | 3218 ClassElement get fixedListImplementation => helpers.jsFixedArrayClass; |
| 3222 ClassElement get growableListImplementation => helpers.jsExtendableArrayClass; | 3219 ClassElement get growableListImplementation => helpers.jsExtendableArrayClass; |
| 3223 ClassElement get mapImplementation => helpers.mapLiteralClass; | 3220 ClassElement get mapImplementation => helpers.mapLiteralClass; |
| 3224 ClassElement get constMapImplementation => helpers.constMapLiteralClass; | 3221 ClassElement get constMapImplementation => helpers.constMapLiteralClass; |
| 3225 ClassElement get typeImplementation => helpers.typeLiteralClass; | 3222 ClassElement get typeImplementation => helpers.typeLiteralClass; |
| 3226 ClassElement get boolImplementation => helpers.jsBoolClass; | 3223 ClassElement get boolImplementation => helpers.jsBoolClass; |
| 3227 ClassElement get nullImplementation => helpers.jsNullClass; | 3224 ClassElement get nullImplementation => helpers.jsNullClass; |
| 3228 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; | 3225 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; |
| 3229 ClassElement get asyncFutureImplementation => helpers.futureImplementation; | 3226 ClassElement get asyncFutureImplementation => helpers.futureImplementation; |
| 3230 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; | 3227 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; |
| 3231 ClassElement get functionImplementation => helpers.coreClasses.functionClass; | 3228 ClassElement get functionImplementation => |
| 3229 helpers.commonElements.functionClass; |
| 3232 ClassElement get indexableImplementation => helpers.jsIndexableClass; | 3230 ClassElement get indexableImplementation => helpers.jsIndexableClass; |
| 3233 ClassElement get mutableIndexableImplementation => | 3231 ClassElement get mutableIndexableImplementation => |
| 3234 helpers.jsMutableIndexableClass; | 3232 helpers.jsMutableIndexableClass; |
| 3235 ClassElement get indexingBehaviorImplementation => | 3233 ClassElement get indexingBehaviorImplementation => |
| 3236 helpers.jsIndexingBehaviorInterface; | 3234 helpers.jsIndexingBehaviorInterface; |
| 3237 ClassElement get interceptorImplementation => helpers.jsInterceptorClass; | 3235 ClassElement get interceptorImplementation => helpers.jsInterceptorClass; |
| 3238 | 3236 |
| 3239 bool isDefaultEqualityImplementation(Element element) { | 3237 bool isDefaultEqualityImplementation(Element element) { |
| 3240 assert(element.name == '=='); | 3238 assert(element.name == '=='); |
| 3241 ClassElement classElement = element.enclosingClass; | 3239 ClassElement classElement = element.enclosingClass; |
| 3242 return classElement == helpers.coreClasses.objectClass || | 3240 return classElement == helpers.commonElements.objectClass || |
| 3243 classElement == helpers.jsInterceptorClass || | 3241 classElement == helpers.jsInterceptorClass || |
| 3244 classElement == helpers.jsNullClass; | 3242 classElement == helpers.jsNullClass; |
| 3245 } | 3243 } |
| 3246 | 3244 |
| 3247 @override | 3245 @override |
| 3248 bool isInterceptorClass(ClassElement cls) { | 3246 bool isInterceptorClass(ClassElement cls) { |
| 3249 return helpers.backend.isInterceptorClass(cls); | 3247 return helpers.backend.isInterceptorClass(cls); |
| 3250 } | 3248 } |
| 3251 | 3249 |
| 3252 @override | 3250 @override |
| 3253 bool isNative(Element element) { | 3251 bool isNative(Element element) { |
| 3254 return helpers.backend.isNative(element); | 3252 return helpers.backend.isNative(element); |
| 3255 } | 3253 } |
| 3256 } | 3254 } |
| OLD | NEW |