OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.startup_emitter.model_emitter; | 5 part of dart2js.js_emitter.startup_emitter.model_emitter; |
6 | 6 |
7 /// The name of the property that stores the tear-off getter on a static | 7 /// The name of the property that stores the tear-off getter on a static |
8 /// function. | 8 /// function. |
9 /// | 9 /// |
10 /// This property is only used when isolates are used. | 10 /// This property is only used when isolates are used. |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 } | 770 } |
771 | 771 |
772 /// Emits the inheritance block of the fragment. | 772 /// Emits the inheritance block of the fragment. |
773 /// | 773 /// |
774 /// In this section prototype chains are updated and mixin functions are | 774 /// In this section prototype chains are updated and mixin functions are |
775 /// copied. | 775 /// copied. |
776 js.Statement emitInheritance(Fragment fragment) { | 776 js.Statement emitInheritance(Fragment fragment) { |
777 List<js.Expression> inheritCalls = <js.Expression>[]; | 777 List<js.Expression> inheritCalls = <js.Expression>[]; |
778 List<js.Expression> mixinCalls = <js.Expression>[]; | 778 List<js.Expression> mixinCalls = <js.Expression>[]; |
779 | 779 |
| 780 Set<Class> emittedClasses = new Set<Class>(); |
| 781 |
| 782 void emitInheritanceForClass(cls) { |
| 783 if (cls == null || emittedClasses.contains(cls)) return; |
| 784 |
| 785 Class superclass = cls.superclass; |
| 786 emitInheritanceForClass(superclass); |
| 787 |
| 788 js.Expression superclassReference = (superclass == null) |
| 789 ? new js.LiteralNull() |
| 790 : classReference(superclass); |
| 791 |
| 792 inheritCalls.add(js.js('inherit(#, #)', |
| 793 [classReference(cls), superclassReference])); |
| 794 |
| 795 emittedClasses.add(cls); |
| 796 } |
| 797 |
780 for (Library library in fragment.libraries) { | 798 for (Library library in fragment.libraries) { |
781 for (Class cls in library.classes) { | 799 for (Class cls in library.classes) { |
782 js.Expression superclassReference = (cls.superclass == null) | 800 emitInheritanceForClass(cls); |
783 ? new js.LiteralNull() | |
784 : classReference(cls.superclass); | |
785 | |
786 inheritCalls.add(js.js('inherit(#, #)', | |
787 [classReference(cls), superclassReference])); | |
788 | 801 |
789 if (cls.isMixinApplication) { | 802 if (cls.isMixinApplication) { |
790 MixinApplication mixin = cls; | 803 MixinApplication mixin = cls; |
791 mixinCalls.add(js.js('mixin(#, #)', | 804 mixinCalls.add(js.js('mixin(#, #)', |
792 [classReference(cls), classReference(mixin.mixinClass)])); | 805 [classReference(cls), classReference(mixin.mixinClass)])); |
793 } | 806 } |
794 } | 807 } |
795 } | 808 } |
796 | 809 |
797 return new js.Block([inheritCalls, mixinCalls] | 810 return new js.Block([inheritCalls, mixinCalls] |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 } | 1312 } |
1300 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", | 1313 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", |
1301 js.objectLiteral(interceptorsByTag))); | 1314 js.objectLiteral(interceptorsByTag))); |
1302 statements.add(js.js.statement("setOrUpdateLeafTags(#);", | 1315 statements.add(js.js.statement("setOrUpdateLeafTags(#);", |
1303 js.objectLiteral(leafTags))); | 1316 js.objectLiteral(leafTags))); |
1304 statements.add(subclassAssignment); | 1317 statements.add(subclassAssignment); |
1305 | 1318 |
1306 return new js.Block(statements); | 1319 return new js.Block(statements); |
1307 } | 1320 } |
1308 } | 1321 } |
OLD | NEW |