| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 /** | 692 /** |
| 693 * Given the arguments (a list of constants) assigns them to the parameters, | 693 * Given the arguments (a list of constants) assigns them to the parameters, |
| 694 * updating the definitions map. If the constructor has field-initializer | 694 * updating the definitions map. If the constructor has field-initializer |
| 695 * parameters (like [:this.x:]), also updates the [fieldValues] map. | 695 * parameters (like [:this.x:]), also updates the [fieldValues] map. |
| 696 */ | 696 */ |
| 697 void assignArgumentsToParameters(List<Constant> arguments) { | 697 void assignArgumentsToParameters(List<Constant> arguments) { |
| 698 // Assign arguments to parameters. | 698 // Assign arguments to parameters. |
| 699 FunctionSignature parameters = constructor.computeSignature(compiler); | 699 FunctionSignature parameters = constructor.computeSignature(compiler); |
| 700 int index = 0; | 700 int index = 0; |
| 701 parameters.forEachParameter((Element parameter) { | 701 parameters.orderedForEachParameter((Element parameter) { |
| 702 Constant argument = arguments[index++]; | 702 Constant argument = arguments[index++]; |
| 703 Node node = parameter.parseNode(compiler); | 703 Node node = parameter.parseNode(compiler); |
| 704 potentiallyCheckType(node, parameter, argument); | 704 potentiallyCheckType(node, parameter, argument); |
| 705 definitions[parameter] = argument; | 705 definitions[parameter] = argument; |
| 706 if (parameter.kind == ElementKind.FIELD_PARAMETER) { | 706 if (parameter.kind == ElementKind.FIELD_PARAMETER) { |
| 707 FieldParameterElement fieldParameterElement = parameter; | 707 FieldParameterElement fieldParameterElement = parameter; |
| 708 updateFieldValue(node, fieldParameterElement.fieldElement, argument); | 708 updateFieldValue(node, fieldParameterElement.fieldElement, argument); |
| 709 } | 709 } |
| 710 }); | 710 }); |
| 711 } | 711 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 Constant fieldValue = fieldValues[field]; | 808 Constant fieldValue = fieldValues[field]; |
| 809 if (fieldValue === null) { | 809 if (fieldValue === null) { |
| 810 // Use the default value. | 810 // Use the default value. |
| 811 fieldValue = compiler.compileConstant(field); | 811 fieldValue = compiler.compileConstant(field); |
| 812 } | 812 } |
| 813 jsNewArguments.add(fieldValue); | 813 jsNewArguments.add(fieldValue); |
| 814 }); | 814 }); |
| 815 return jsNewArguments; | 815 return jsNewArguments; |
| 816 } | 816 } |
| 817 } | 817 } |
| OLD | NEW |