| 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 /** | 5 /** |
| 6 * The [ConstantHandler] keeps track of compile-time constants, | 6 * The [ConstantHandler] keeps track of compile-time constants, |
| 7 * initializations of global and static fields, and default values of | 7 * initializations of global and static fields, and default values of |
| 8 * optional parameters. | 8 * optional parameters. |
| 9 */ | 9 */ |
| 10 class ConstantHandler extends CompilerTask { | 10 class ConstantHandler extends CompilerTask { |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 760 } |
| 761 | 761 |
| 762 if (!foundSuperOrRedirect) { | 762 if (!foundSuperOrRedirect) { |
| 763 // No super initializer found. Try to find the default constructor if | 763 // No super initializer found. Try to find the default constructor if |
| 764 // the class is not Object. | 764 // the class is not Object. |
| 765 ClassElement enclosingClass = constructor.getEnclosingClass(); | 765 ClassElement enclosingClass = constructor.getEnclosingClass(); |
| 766 ClassElement superClass = enclosingClass.superclass; | 766 ClassElement superClass = enclosingClass.superclass; |
| 767 if (enclosingClass != compiler.objectClass) { | 767 if (enclosingClass != compiler.objectClass) { |
| 768 assert(superClass !== null); | 768 assert(superClass !== null); |
| 769 assert(superClass.resolutionState == STATE_DONE); | 769 assert(superClass.resolutionState == STATE_DONE); |
| 770 |
| 771 Selector selector = |
| 772 new Selector.callDefaultConstructor(superClass.name, |
| 773 enclosingClass.getLibrary()); |
| 774 |
| 770 FunctionElement targetConstructor = | 775 FunctionElement targetConstructor = |
| 771 superClass.lookupConstructor(superClass.name); | 776 superClass.lookupConstructor(selector); |
| 772 if (targetConstructor === null) { | 777 if (targetConstructor === null) { |
| 773 compiler.internalError("no default constructor available", | 778 compiler.internalError("no default constructor available", |
| 774 node: functionNode); | 779 node: functionNode); |
| 775 } | 780 } |
| 776 | 781 |
| 777 Selector selector = new Selector.call(superClass.name, | |
| 778 enclosingClass.getLibrary(), | |
| 779 0); | |
| 780 evaluateSuperOrRedirectSend(functionNode, | 782 evaluateSuperOrRedirectSend(functionNode, |
| 781 selector, | 783 selector, |
| 782 const EmptyLink<Node>(), | 784 const EmptyLink<Node>(), |
| 783 targetConstructor); | 785 targetConstructor); |
| 784 } | 786 } |
| 785 } | 787 } |
| 786 } | 788 } |
| 787 | 789 |
| 788 /** | 790 /** |
| 789 * Simulates the execution of the [constructor] with the given | 791 * Simulates the execution of the [constructor] with the given |
| (...skipping 16 matching lines...) Expand all Loading... |
| 806 Constant fieldValue = fieldValues[field]; | 808 Constant fieldValue = fieldValues[field]; |
| 807 if (fieldValue === null) { | 809 if (fieldValue === null) { |
| 808 // Use the default value. | 810 // Use the default value. |
| 809 fieldValue = compiler.compileConstant(field); | 811 fieldValue = compiler.compileConstant(field); |
| 810 } | 812 } |
| 811 jsNewArguments.add(fieldValue); | 813 jsNewArguments.add(fieldValue); |
| 812 }); | 814 }); |
| 813 return jsNewArguments; | 815 return jsNewArguments; |
| 814 } | 816 } |
| 815 } | 817 } |
| OLD | NEW |