| 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 /// A [ConstantEnvironment] provides access for constants compiled for variable | 7 /// A [ConstantEnvironment] provides access for constants compiled for variable |
| 8 /// initializers. | 8 /// initializers. |
| 9 abstract class ConstantEnvironment { | 9 abstract class ConstantEnvironment { |
| 10 /// Returns the constant for the initializer of [element]. | 10 /// Returns the constant for the initializer of [element]. |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 * | 636 * |
| 637 * Invariant: [target] must be an implementation element. | 637 * Invariant: [target] must be an implementation element. |
| 638 */ | 638 */ |
| 639 List<AstConstant> evaluateArgumentsToConstructor( | 639 List<AstConstant> evaluateArgumentsToConstructor( |
| 640 Node node, | 640 Node node, |
| 641 Selector selector, | 641 Selector selector, |
| 642 Link<Node> arguments, | 642 Link<Node> arguments, |
| 643 FunctionElement target, | 643 FunctionElement target, |
| 644 {AstConstant compileArgument(Node node)}) { | 644 {AstConstant compileArgument(Node node)}) { |
| 645 assert(invariant(node, target.isImplementation)); | 645 assert(invariant(node, target.isImplementation)); |
| 646 List<AstConstant> compiledArguments = <AstConstant>[]; | |
| 647 | 646 |
| 648 AstConstant compileDefaultValue(VariableElement element) { | 647 AstConstant compileDefaultValue(VariableElement element) { |
| 649 ConstantExpression constant = handler.compileConstant(element); | 648 ConstantExpression constant = handler.compileConstant(element); |
| 650 return new AstConstant.fromDefaultValue(element, constant); | 649 return new AstConstant.fromDefaultValue(element, constant); |
| 651 } | 650 } |
| 652 target.computeSignature(compiler); | 651 target.computeSignature(compiler); |
| 653 bool succeeded = selector.addArgumentsToList(arguments, | 652 |
| 654 compiledArguments, | 653 if (!selector.applies(target, compiler.world)) { |
| 655 target, | |
| 656 compileArgument, | |
| 657 compileDefaultValue, | |
| 658 compiler.world); | |
| 659 if (!succeeded) { | |
| 660 String name = Elements.constructorNameForDiagnostics( | 654 String name = Elements.constructorNameForDiagnostics( |
| 661 target.enclosingClass.name, target.name); | 655 target.enclosingClass.name, target.name); |
| 662 compiler.reportFatalError( | 656 compiler.reportFatalError( |
| 663 node, | 657 node, |
| 664 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, | 658 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, |
| 665 {'constructorName': name}); | 659 {'constructorName': name}); |
| 666 } | 660 } |
| 667 return compiledArguments; | 661 return selector.makeArgumentsList(arguments, |
| 662 target, |
| 663 compileArgument, |
| 664 compileDefaultValue); |
| 668 } | 665 } |
| 669 | 666 |
| 670 AstConstant visitNewExpression(NewExpression node) { | 667 AstConstant visitNewExpression(NewExpression node) { |
| 671 if (!node.isConst) { | 668 if (!node.isConst) { |
| 672 return signalNotCompileTimeConstant(node); | 669 return signalNotCompileTimeConstant(node); |
| 673 } | 670 } |
| 674 | 671 |
| 675 Send send = node.send; | 672 Send send = node.send; |
| 676 FunctionElement constructor = elements[send]; | 673 FunctionElement constructor = elements[send]; |
| 677 if (Elements.isUnresolved(constructor)) { | 674 if (Elements.isUnresolved(constructor)) { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 return new AstConstant( | 1089 return new AstConstant( |
| 1093 element, | 1090 element, |
| 1094 element.initializer != null ? element.initializer : element.node, | 1091 element.initializer != null ? element.initializer : element.node, |
| 1095 constant); | 1092 constant); |
| 1096 } | 1093 } |
| 1097 | 1094 |
| 1098 ConstantValue get value => expression.value; | 1095 ConstantValue get value => expression.value; |
| 1099 | 1096 |
| 1100 String toString() => expression.toString(); | 1097 String toString() => expression.toString(); |
| 1101 } | 1098 } |
| OLD | NEW |