| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 return compiledArguments; | 638 return compiledArguments; |
| 639 } | 639 } |
| 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 // TODO(ahe): This is nasty: we must eagerly analyze the |
| 649 // constructor to ensure the redirectionTarget has been computed |
| 650 // correctly. Find a way to avoid this. |
| 651 compiler.analyzeElement(constructor); |
| 648 constructor = constructor.redirectionTarget; | 652 constructor = constructor.redirectionTarget; |
| 649 ClassElement classElement = constructor.getEnclosingClass(); | 653 ClassElement classElement = constructor.getEnclosingClass(); |
| 650 // The constructor must be an implementation to ensure that field | 654 // The constructor must be an implementation to ensure that field |
| 651 // initializers are handled correctly. | 655 // initializers are handled correctly. |
| 652 constructor = constructor.implementation; | 656 constructor = constructor.implementation; |
| 653 assert(invariant(node, constructor.isImplementation)); | 657 assert(invariant(node, constructor.isImplementation)); |
| 654 | 658 |
| 655 Selector selector = elements.getSelector(send); | 659 Selector selector = elements.getSelector(send); |
| 656 List<Constant> arguments = evaluateArgumentsToConstructor( | 660 List<Constant> arguments = evaluateArgumentsToConstructor( |
| 657 node, selector, send.arguments, constructor); | 661 node, selector, send.arguments, constructor); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 if (fieldValue == null) { | 885 if (fieldValue == null) { |
| 882 // Use the default value. | 886 // Use the default value. |
| 883 fieldValue = handler.compileConstant(field); | 887 fieldValue = handler.compileConstant(field); |
| 884 } | 888 } |
| 885 jsNewArguments.add(fieldValue); | 889 jsNewArguments.add(fieldValue); |
| 886 }, | 890 }, |
| 887 includeSuperAndInjectedMembers: true); | 891 includeSuperAndInjectedMembers: true); |
| 888 return jsNewArguments; | 892 return jsNewArguments; |
| 889 } | 893 } |
| 890 } | 894 } |
| OLD | NEW |