Chromium Code Reviews| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class NativeEmitter { | 7 class NativeEmitter { |
| 8 | 8 |
| 9 final Map<Element, ClassBuilder> cachedBuilders; | 9 final Map<Element, ClassBuilder> cachedBuilders; |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 } | 161 } |
| 162 if (sufficingInterceptor == objectClass) { | 162 if (sufficingInterceptor == objectClass) { |
| 163 sufficingInterceptor = jsInterceptorClass; | 163 sufficingInterceptor = jsInterceptorClass; |
| 164 } | 164 } |
| 165 leafTags | 165 leafTags |
| 166 .putIfAbsent(sufficingInterceptor, () => new Set<String>()) | 166 .putIfAbsent(sufficingInterceptor, () => new Set<String>()) |
| 167 .addAll(nativeTags); | 167 .addAll(nativeTags); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Add properties containing the information needed to construct maps used | 171 Set<Class> unneededClasses = classes |
| 172 // by getNativeInterceptor and custom elements. | 172 .where((Class cls) => cls.isNative && !neededClasses.contains(cls)) |
| 173 if (compiler.enqueuer.codegen.nativeEnqueuer | 173 .toSet(); |
| 174 .hasInstantiatedNativeClasses()) { | 174 |
| 175 // If native classes are emitted, add properties containing the information | |
| 176 // needed to construct maps used by getNativeInterceptor and custom | |
| 177 // elements. | |
| 178 if (classes.length != unneededClasses.length) { | |
|
floitsch
2015/02/26 18:12:12
Explain when/why this can happen.
From what I und
zarah
2015/02/27 09:03:48
It happens in the case you mention, I am not compl
| |
| 175 void generateClassInfo(Class cls) { | 179 void generateClassInfo(Class cls) { |
| 176 // Property has the form: | 180 // Property has the form: |
| 177 // | 181 // |
| 178 // "%": "leafTag1|leafTag2|...;nonleafTag1|...;Class1|Class2|...", | 182 // "%": "leafTag1|leafTag2|...;nonleafTag1|...;Class1|Class2|...", |
| 179 // | 183 // |
| 180 // If there is no data following a semicolon, the semicolon can be | 184 // If there is no data following a semicolon, the semicolon can be |
| 181 // omitted. | 185 // omitted. |
| 182 | 186 |
| 183 String formatTags(Iterable<String> tags) { | 187 String formatTags(Iterable<String> tags) { |
| 184 if (tags == null) return ''; | 188 if (tags == null) return ''; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 211 generateClassInfo(cls); | 215 generateClassInfo(cls); |
| 212 } | 216 } |
| 213 } | 217 } |
| 214 } | 218 } |
| 215 | 219 |
| 216 // TODO(sra): Issue #13731- this is commented out as part of custom | 220 // TODO(sra): Issue #13731- this is commented out as part of custom |
| 217 // element constructor work. | 221 // element constructor work. |
| 218 // (floitsch: was run on every native class.) | 222 // (floitsch: was run on every native class.) |
| 219 //assert(!classElement.hasBackendMembers); | 223 //assert(!classElement.hasBackendMembers); |
| 220 | 224 |
| 221 return classes | 225 return unneededClasses; |
| 222 .where((Class cls) => cls.isNative && !neededClasses.contains(cls)) | |
| 223 .toSet(); | |
| 224 } | 226 } |
| 225 | 227 |
| 226 /** | 228 /** |
| 227 * Computes the native classes that are extended (subclassed) by non-native | 229 * Computes the native classes that are extended (subclassed) by non-native |
| 228 * classes and the set non-mative classes that extend them. (A List is used | 230 * classes and the set non-mative classes that extend them. (A List is used |
| 229 * instead of a Set for out stability). | 231 * instead of a Set for out stability). |
| 230 */ | 232 */ |
| 231 Map<Class, List<Class>> computeExtensionPoints(List<Class> classes) { | 233 Map<Class, List<Class>> computeExtensionPoints(List<Class> classes) { |
| 232 Class nativeSuperclassOf(Class cls) { | 234 Class nativeSuperclassOf(Class cls) { |
| 233 if (cls == null) return null; | 235 if (cls == null) return null; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 } | 468 } |
| 467 ''', {'info': infoAccess, | 469 ''', {'info': infoAccess, |
| 468 'constructor': constructorAccess, | 470 'constructor': constructorAccess, |
| 469 'subclassRead': subclassRead, | 471 'subclassRead': subclassRead, |
| 470 'interceptorsByTagAccess': interceptorsByTagAccess, | 472 'interceptorsByTagAccess': interceptorsByTagAccess, |
| 471 'leafTagsAccess': leafTagsAccess, | 473 'leafTagsAccess': leafTagsAccess, |
| 472 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, | 474 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, |
| 473 'allowNativesSubclassing': true}); | 475 'allowNativesSubclassing': true}); |
| 474 } | 476 } |
| 475 } | 477 } |
| OLD | NEW |