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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * The [ConstantHandler] keeps track of compile-time constants, | 8 * The [ConstantHandler] keeps track of compile-time constants, |
9 * initializations of global and static fields, and default values of | 9 * initializations of global and static fields, and default values of |
10 * optional parameters. | 10 * optional parameters. |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 Constant visitNewExpression(NewExpression node) { | 641 Constant visitNewExpression(NewExpression node) { |
642 if (!node.isConst()) { | 642 if (!node.isConst()) { |
643 return signalNotCompileTimeConstant(node); | 643 return signalNotCompileTimeConstant(node); |
644 } | 644 } |
645 | 645 |
646 Send send = node.send; | 646 Send send = node.send; |
647 FunctionElement constructor = elements[send]; | 647 FunctionElement constructor = elements[send]; |
648 constructor = constructor.redirectionTarget; | 648 constructor = constructor.redirectionTarget; |
649 ClassElement classElement = constructor.getEnclosingClass(); | 649 ClassElement classElement = constructor.getEnclosingClass(); |
650 if (classElement.isInterface()) { | |
651 compiler.resolver.resolveMethodElement(constructor); | |
652 constructor = constructor.defaultImplementation; | |
653 classElement = constructor.getEnclosingClass(); | |
654 } | |
655 // The constructor must be an implementation to ensure that field | 650 // The constructor must be an implementation to ensure that field |
656 // initializers are handled correctly. | 651 // initializers are handled correctly. |
657 constructor = constructor.implementation; | 652 constructor = constructor.implementation; |
658 assert(invariant(node, constructor.isImplementation)); | 653 assert(invariant(node, constructor.isImplementation)); |
659 | 654 |
660 Selector selector = elements.getSelector(send); | 655 Selector selector = elements.getSelector(send); |
661 List<Constant> arguments = evaluateArgumentsToConstructor( | 656 List<Constant> arguments = evaluateArgumentsToConstructor( |
662 node, selector, send.arguments, constructor); | 657 node, selector, send.arguments, constructor); |
663 ConstructorEvaluator evaluator = | 658 ConstructorEvaluator evaluator = |
664 new ConstructorEvaluator(node, constructor, handler, compiler); | 659 new ConstructorEvaluator(node, constructor, handler, compiler); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 // Use the default value. | 882 // Use the default value. |
888 fieldValue = handler.compileConstant(field); | 883 fieldValue = handler.compileConstant(field); |
889 } | 884 } |
890 jsNewArguments.add(fieldValue); | 885 jsNewArguments.add(fieldValue); |
891 }, | 886 }, |
892 includeBackendMembers: true, | 887 includeBackendMembers: true, |
893 includeSuperMembers: true); | 888 includeSuperMembers: true); |
894 return jsNewArguments; | 889 return jsNewArguments; |
895 } | 890 } |
896 } | 891 } |
OLD | NEW |