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

Unified Diff: lib/compiler/implementation/js_backend/emitter.dart

Issue 10951026: Fix algorithm to know whether we should emit an is check on a class: all interfaces/implemented cla… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/is_interfaces2_test.dart » ('j') | tests/language/is_interfaces2_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/js_backend/emitter.dart
===================================================================
--- lib/compiler/implementation/js_backend/emitter.dart (revision 12536)
+++ lib/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -701,29 +701,34 @@
if (checkedClasses.contains(cls)) {
generateTypeTest(cls);
}
- generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>());
+ Set<Element> generated = new Set<Element>();
+ for (DartType interfaceType in cls.interfaces) {
+ generateInterfacesIsTests(
Lasse Reichstein Nielsen 2012/09/19 09:52:10 Why is it called "IsTests" in the called function'
ngeoffray 2012/09/19 10:14:39 Renamed everything to IsTest instead of TypeTest.
+ interfaceType.element, generateTypeTest, generated);
+ }
}
void generateInterfacesIsTests(ClassElement cls,
Lasse Reichstein Nielsen 2012/09/19 09:52:10 Please document what the function does. And the fu
ngeoffray 2012/09/19 10:14:39 Done.
void generateTypeTest(ClassElement element),
Set<Element> alreadyGenerated) {
+ void tryEmitTest(ClassElement cls) {
+ if (!alreadyGenerated.contains(cls) && checkedClasses.contains(cls)) {
+ alreadyGenerated.add(cls);
+ generateTypeTest(cls);
+ }
+ };
+
for (DartType interfaceType in cls.interfaces) {
Element element = interfaceType.element;
- if (!alreadyGenerated.contains(element) &&
- checkedClasses.contains(element)) {
- alreadyGenerated.add(element);
- generateTypeTest(element);
- }
+ tryEmitTest(element);
generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated);
+ }
- // Since [element] is implemented by [cls], we need to also emit
- // is checks for the superclass and its supertypes.
- ClassElement superclass = element.superclass;
- if (!alreadyGenerated.contains(superclass) &&
- checkedClasses.contains(superclass)) {
- alreadyGenerated.add(superclass);
- generateTypeTest(superclass);
- }
+ // We need to also emit
Lasse Reichstein Nielsen 2012/09/19 09:52:10 Fix linebreaking. Put quotes around "is-checks" or
ngeoffray 2012/09/19 10:14:39 Done.
+ // is checks for the superclass and its supertypes.
+ ClassElement superclass = cls.superclass;
+ if (superclass != null) {
+ tryEmitTest(superclass);
generateInterfacesIsTests(superclass, generateTypeTest, alreadyGenerated);
}
}
« no previous file with comments | « no previous file | tests/language/is_interfaces2_test.dart » ('j') | tests/language/is_interfaces2_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698