| 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(enclosingClass.getLibrary()); |
| 773 |
| 770 FunctionElement targetConstructor = | 774 FunctionElement targetConstructor = |
| 771 superClass.lookupConstructor(superClass.name); | 775 superClass.lookupConstructor(selector); |
| 772 if (targetConstructor === null) { | 776 if (targetConstructor === null) { |
| 773 compiler.internalError("no default constructor available", | 777 compiler.internalError("no default constructor available", |
| 774 node: functionNode); | 778 node: functionNode); |
| 775 } | 779 } |
| 776 | 780 |
| 777 Selector selector = new Selector.call(superClass.name, | |
| 778 enclosingClass.getLibrary(), | |
| 779 0); | |
| 780 evaluateSuperOrRedirectSend(functionNode, | 781 evaluateSuperOrRedirectSend(functionNode, |
| 781 selector, | 782 selector, |
| 782 const EmptyLink<Node>(), | 783 const EmptyLink<Node>(), |
| 783 targetConstructor); | 784 targetConstructor); |
| 784 } | 785 } |
| 785 } | 786 } |
| 786 } | 787 } |
| 787 | 788 |
| 788 /** | 789 /** |
| 789 * Simulates the execution of the [constructor] with the given | 790 * Simulates the execution of the [constructor] with the given |
| (...skipping 16 matching lines...) Expand all Loading... |
| 806 Constant fieldValue = fieldValues[field]; | 807 Constant fieldValue = fieldValues[field]; |
| 807 if (fieldValue === null) { | 808 if (fieldValue === null) { |
| 808 // Use the default value. | 809 // Use the default value. |
| 809 fieldValue = compiler.compileConstant(field); | 810 fieldValue = compiler.compileConstant(field); |
| 810 } | 811 } |
| 811 jsNewArguments.add(fieldValue); | 812 jsNewArguments.add(fieldValue); |
| 812 }); | 813 }); |
| 813 return jsNewArguments; | 814 return jsNewArguments; |
| 814 } | 815 } |
| 815 } | 816 } |
| OLD | NEW |