| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |