| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 return compiledArguments; | 613 return compiledArguments; |
| 614 } | 614 } |
| 615 | 615 |
| 616 Constant visitNewExpression(NewExpression node) { | 616 Constant visitNewExpression(NewExpression node) { |
| 617 if (!node.isConst()) { | 617 if (!node.isConst()) { |
| 618 return signalNotCompileTimeConstant(node); | 618 return signalNotCompileTimeConstant(node); |
| 619 } | 619 } |
| 620 | 620 |
| 621 Send send = node.send; | 621 Send send = node.send; |
| 622 FunctionElement constructor = elements[send]; | 622 FunctionElement constructor = elements[send]; |
| 623 if (Elements.isUnresolved(constructor)) { |
| 624 return signalNotCompileTimeConstant(node); |
| 625 } |
| 623 // TODO(ahe): This is nasty: we must eagerly analyze the | 626 // TODO(ahe): This is nasty: we must eagerly analyze the |
| 624 // constructor to ensure the redirectionTarget has been computed | 627 // constructor to ensure the redirectionTarget has been computed |
| 625 // correctly. Find a way to avoid this. | 628 // correctly. Find a way to avoid this. |
| 626 compiler.analyzeElement(constructor.declaration); | 629 compiler.analyzeElement(constructor.declaration); |
| 627 | 630 |
| 628 InterfaceType type = elements.getType(node); | 631 InterfaceType type = elements.getType(node); |
| 629 List<Constant> evaluateArguments(FunctionElement constructor) { | 632 List<Constant> evaluateArguments(FunctionElement constructor) { |
| 630 Selector selector = elements.getSelector(send); | 633 Selector selector = elements.getSelector(send); |
| 631 return evaluateArgumentsToConstructor( | 634 return evaluateArgumentsToConstructor( |
| 632 node, selector, send.arguments, constructor); | 635 node, selector, send.arguments, constructor); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 if (fieldValue == null) { | 881 if (fieldValue == null) { |
| 879 // Use the default value. | 882 // Use the default value. |
| 880 fieldValue = handler.compileConstant(field); | 883 fieldValue = handler.compileConstant(field); |
| 881 } | 884 } |
| 882 jsNewArguments.add(fieldValue); | 885 jsNewArguments.add(fieldValue); |
| 883 }, | 886 }, |
| 884 includeSuperAndInjectedMembers: true); | 887 includeSuperAndInjectedMembers: true); |
| 885 return jsNewArguments; | 888 return jsNewArguments; |
| 886 } | 889 } |
| 887 } | 890 } |
| OLD | NEW |