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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 11412086: Make 'where' lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: FilteredIterable/Iterator -> WhereIterable/Iterator. Created 8 years 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 | Annotate | Revision Log
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 class NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 seen.add(cls); 289 seen.add(cls);
290 for (final ClassElement subclass in getDirectSubclasses(cls)) { 290 for (final ClassElement subclass in getDirectSubclasses(cls)) {
291 visit(subclass); 291 visit(subclass);
292 } 292 }
293 classes.add(cls); 293 classes.add(cls);
294 } 294 }
295 for (final ClassElement classElement in classesWithDynamicDispatch) { 295 for (final ClassElement classElement in classesWithDynamicDispatch) {
296 visit(classElement); 296 visit(classElement);
297 } 297 }
298 298
299 Collection<ClassElement> dispatchClasses = classes.where( 299 List<ClassElement> dispatchClasses = classes.where(
300 (cls) => !getDirectSubclasses(cls).isEmpty && 300 (cls) => !getDirectSubclasses(cls).isEmpty &&
301 classesWithDynamicDispatch.contains(cls)); 301 classesWithDynamicDispatch.contains(cls)).toList();
302 302
303 nativeBuffer.add('// ${classes.length} classes\n'); 303 nativeBuffer.add('// ${classes.length} classes\n');
304 Collection<ClassElement> classesThatHaveSubclasses = classes.where( 304 Iterable<ClassElement> classesThatHaveSubclasses = classes.where(
305 (ClassElement t) => !getDirectSubclasses(t).isEmpty); 305 (ClassElement t) => !getDirectSubclasses(t).isEmpty);
306 nativeBuffer.add('// ${classesThatHaveSubclasses.length} !leaf\n'); 306 nativeBuffer.add('// ${classesThatHaveSubclasses.length} !leaf\n');
307 307
308 // Generate code that builds the map from cls tags used in dynamic dispatch 308 // Generate code that builds the map from cls tags used in dynamic dispatch
309 // to the set of cls tags of classes that extend (TODO: or implement) those 309 // to the set of cls tags of classes that extend (TODO: or implement) those
310 // classes. The set is represented as a string of tags joined with '|'. 310 // classes. The set is represented as a string of tags joined with '|'.
311 // This is easily split into an array of tags, or converted into a regexp. 311 // This is easily split into an array of tags, or converted into a regexp.
312 // 312 //
313 // To reduce the size of the sets, subsets are CSE-ed out into variables. 313 // To reduce the size of the sets, subsets are CSE-ed out into variables.
314 // The sets could be much smaller if we could make assumptions about the 314 // The sets could be much smaller if we could make assumptions about the
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (!first) targetBuffer.add(",\n"); 475 if (!first) targetBuffer.add(",\n");
476 targetBuffer.add(" $name: $function"); 476 targetBuffer.add(" $name: $function");
477 first = false; 477 first = false;
478 }); 478 });
479 targetBuffer.add("\n});\n\n"); 479 targetBuffer.add("\n});\n\n");
480 } 480 }
481 targetBuffer.add(nativeBuffer); 481 targetBuffer.add(nativeBuffer);
482 targetBuffer.add('\n'); 482 targetBuffer.add('\n');
483 } 483 }
484 } 484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698