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