Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1588733008: dart2js: Default to an empty set instead of null (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 /// Maps compile-time classes to their runtime class. The runtime class is 933 /// Maps compile-time classes to their runtime class. The runtime class is
934 /// always a superclass or the class itself. 934 /// always a superclass or the class itself.
935 ClassElement getRuntimeClass(ClassElement class_) { 935 ClassElement getRuntimeClass(ClassElement class_) {
936 if (class_.isSubclassOf(helpers.jsIntClass)) return helpers.jsIntClass; 936 if (class_.isSubclassOf(helpers.jsIntClass)) return helpers.jsIntClass;
937 if (class_.isSubclassOf(helpers.jsArrayClass)) return helpers.jsArrayClass; 937 if (class_.isSubclassOf(helpers.jsArrayClass)) return helpers.jsArrayClass;
938 return class_; 938 return class_;
939 } 939 }
940 940
941 final Map<String, Set<ClassElement>> interceptedClassesCache = 941 final Map<String, Set<ClassElement>> interceptedClassesCache =
942 new Map<String, Set<ClassElement>>(); 942 new Map<String, Set<ClassElement>>();
943 final Set<ClassElement> _noClasses = new Set<ClassElement>();
943 944
944 /** 945 /// Returns a set of interceptor classes that contain a member named [name]
945 * Returns a set of interceptor classes that contain a member named 946 ///
946 * [name]. Returns [:null:] if there is no class. 947 /// Returns an empty set if there is no class. Do not modify the returned set.
947 */
948 Set<ClassElement> getInterceptedClassesOn(String name) { 948 Set<ClassElement> getInterceptedClassesOn(String name) {
949 Set<Element> intercepted = interceptedElements[name]; 949 Set<Element> intercepted = interceptedElements[name];
950 if (intercepted == null) return null; 950 if (intercepted == null) return _noClasses;
951 return interceptedClassesCache.putIfAbsent(name, () { 951 return interceptedClassesCache.putIfAbsent(name, () {
952 // Populate the cache by running through all the elements and 952 // Populate the cache by running through all the elements and
953 // determine if the given selector applies to them. 953 // determine if the given selector applies to them.
954 Set<ClassElement> result = new Set<ClassElement>(); 954 Set<ClassElement> result = new Set<ClassElement>();
955 for (Element element in intercepted) { 955 for (Element element in intercepted) {
956 ClassElement classElement = element.enclosingClass; 956 ClassElement classElement = element.enclosingClass;
957 if (isCompileTimeOnlyClass(classElement)) continue; 957 if (isCompileTimeOnlyClass(classElement)) continue;
958 if (isNativeOrExtendsNative(classElement) 958 if (isNativeOrExtendsNative(classElement)
959 || interceptedClasses.contains(classElement)) { 959 || interceptedClasses.contains(classElement)) {
960 result.add(classElement); 960 result.add(classElement);
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 } 3164 }
3165 } 3165 }
3166 3166
3167 @override 3167 @override
3168 void onImpactUsed(ImpactUseCase impactUse) { 3168 void onImpactUsed(ImpactUseCase impactUse) {
3169 if (impactUse == DeferredLoadTask.IMPACT_USE) { 3169 if (impactUse == DeferredLoadTask.IMPACT_USE) {
3170 resolution.emptyCache(); 3170 resolution.emptyCache();
3171 } 3171 }
3172 } 3172 }
3173 } 3173 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698