| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 for (Holder holder in holders) { | 630 for (Holder holder in holders) { |
| 631 holderCode[holder] = <js.Name, js.Expression>{}; | 631 holderCode[holder] = <js.Name, js.Expression>{}; |
| 632 } | 632 } |
| 633 | 633 |
| 634 for (Library library in fragment.libraries) { | 634 for (Library library in fragment.libraries) { |
| 635 for (StaticMethod method in library.statics) { | 635 for (StaticMethod method in library.statics) { |
| 636 assert(!method.holder.isStaticStateHolder); | 636 assert(!method.holder.isStaticStateHolder); |
| 637 var staticMethod = emitStaticMethod(method); | 637 var staticMethod = emitStaticMethod(method); |
| 638 if (compiler.options.dumpInfo) { | 638 if (compiler.options.dumpInfo) { |
| 639 for (var code in staticMethod.values) { | 639 for (var code in staticMethod.values) { |
| 640 compiler.dumpInfoTask.registerElementAst(method.element, code); | 640 compiler.dumpInfoTask.registerEntityAst(method.element, code); |
| 641 compiler.dumpInfoTask.registerElementAst(library.element, code); | 641 compiler.dumpInfoTask.registerEntityAst(library.element, code); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 holderCode[method.holder].addAll(staticMethod); | 644 holderCode[method.holder].addAll(staticMethod); |
| 645 } | 645 } |
| 646 for (Class cls in library.classes) { | 646 for (Class cls in library.classes) { |
| 647 assert(!cls.holder.isStaticStateHolder); | 647 assert(!cls.holder.isStaticStateHolder); |
| 648 var constructor = emitConstructor(cls); | 648 var constructor = emitConstructor(cls); |
| 649 compiler.dumpInfoTask.registerElementAst(cls.element, constructor); | 649 compiler.dumpInfoTask.registerEntityAst(cls.element, constructor); |
| 650 compiler.dumpInfoTask.registerElementAst(library.element, constructor); | 650 compiler.dumpInfoTask.registerEntityAst(library.element, constructor); |
| 651 holderCode[cls.holder][cls.name] = constructor; | 651 holderCode[cls.holder][cls.name] = constructor; |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 | 654 |
| 655 js.VariableInitialization emitHolderInitialization(Holder holder) { | 655 js.VariableInitialization emitHolderInitialization(Holder holder) { |
| 656 List<js.Property> properties = <js.Property>[]; | 656 List<js.Property> properties = <js.Property>[]; |
| 657 holderCode[holder].forEach((js.Name key, js.Expression value) { | 657 holderCode[holder].forEach((js.Name key, js.Expression value) { |
| 658 properties.add(new js.Property(js.quoteName(key), value)); | 658 properties.add(new js.Property(js.quoteName(key), value)); |
| 659 }); | 659 }); |
| 660 | 660 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 /// This section updates the prototype-property of all constructors in the | 776 /// This section updates the prototype-property of all constructors in the |
| 777 /// global holders. | 777 /// global holders. |
| 778 js.Statement emitPrototypes(Fragment fragment, {softDeferred = false}) { | 778 js.Statement emitPrototypes(Fragment fragment, {softDeferred = false}) { |
| 779 List<js.Statement> assignments = fragment.libraries | 779 List<js.Statement> assignments = fragment.libraries |
| 780 .expand((Library library) => library.classes) | 780 .expand((Library library) => library.classes) |
| 781 .where((Class cls) => cls.isSoftDeferred == softDeferred) | 781 .where((Class cls) => cls.isSoftDeferred == softDeferred) |
| 782 .map((Class cls) { | 782 .map((Class cls) { |
| 783 var proto = js.js.statement( | 783 var proto = js.js.statement( |
| 784 '#.prototype = #;', [classReference(cls), emitPrototype(cls)]); | 784 '#.prototype = #;', [classReference(cls), emitPrototype(cls)]); |
| 785 ClassEntity element = cls.element; | 785 ClassEntity element = cls.element; |
| 786 compiler.dumpInfoTask.registerElementAst(element, proto); | 786 compiler.dumpInfoTask.registerEntityAst(element, proto); |
| 787 compiler.dumpInfoTask.registerElementAst(element.library, proto); | 787 compiler.dumpInfoTask.registerEntityAst(element.library, proto); |
| 788 return proto; | 788 return proto; |
| 789 }).toList(growable: false); | 789 }).toList(growable: false); |
| 790 | 790 |
| 791 return new js.Block(assignments); | 791 return new js.Block(assignments); |
| 792 } | 792 } |
| 793 | 793 |
| 794 /// Emits the prototype of the given class [cls]. | 794 /// Emits the prototype of the given class [cls]. |
| 795 /// | 795 /// |
| 796 /// The prototype is generated as object literal. Inheritance is ignored. | 796 /// The prototype is generated as object literal. Inheritance is ignored. |
| 797 /// | 797 /// |
| (...skipping 23 matching lines...) Expand all Loading... |
| 821 properties | 821 properties |
| 822 .add(new js.Property(js.string("constructor"), classReference(cls))); | 822 .add(new js.Property(js.string("constructor"), classReference(cls))); |
| 823 properties | 823 properties |
| 824 .add(new js.Property(namer.operatorIs(cls.element), js.number(1))); | 824 .add(new js.Property(namer.operatorIs(cls.element), js.number(1))); |
| 825 } | 825 } |
| 826 | 826 |
| 827 allMethods.forEach((Method method) { | 827 allMethods.forEach((Method method) { |
| 828 emitInstanceMethod(method) | 828 emitInstanceMethod(method) |
| 829 .forEach((js.Expression name, js.Expression code) { | 829 .forEach((js.Expression name, js.Expression code) { |
| 830 var prop = new js.Property(name, code); | 830 var prop = new js.Property(name, code); |
| 831 compiler.dumpInfoTask.registerElementAst(method.element, prop); | 831 compiler.dumpInfoTask.registerEntityAst(method.element, prop); |
| 832 properties.add(prop); | 832 properties.add(prop); |
| 833 }); | 833 }); |
| 834 }); | 834 }); |
| 835 | 835 |
| 836 if (cls.isClosureBaseClass) { | 836 if (cls.isClosureBaseClass) { |
| 837 // Closures extend a common base class, so we can put properties on the | 837 // Closures extend a common base class, so we can put properties on the |
| 838 // prototype for common values. | 838 // prototype for common values. |
| 839 | 839 |
| 840 // Most closures have no optional arguments. | 840 // Most closures have no optional arguments. |
| 841 properties.add(new js.Property( | 841 properties.add(new js.Property( |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1549 } |
| 1550 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", | 1550 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", |
| 1551 js.objectLiteral(interceptorsByTag))); | 1551 js.objectLiteral(interceptorsByTag))); |
| 1552 statements.add( | 1552 statements.add( |
| 1553 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); | 1553 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); |
| 1554 statements.addAll(subclassAssignments); | 1554 statements.addAll(subclassAssignments); |
| 1555 | 1555 |
| 1556 return wrapPhase('nativeSupport', statements); | 1556 return wrapPhase('nativeSupport', statements); |
| 1557 } | 1557 } |
| 1558 } | 1558 } |
| OLD | NEW |