| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(johnniwinther): Remove this library when all constant constructors are | 5 // TODO(johnniwinther): Remove this library when all constant constructors are |
| 6 // computed during resolution. | 6 // computed during resolution. |
| 7 library dart2js.constants.constant_constructors; | 7 library dart2js.constants.constant_constructors; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ConstantConstructor visitGenerativeConstructorDeclaration( | 80 ConstantConstructor visitGenerativeConstructorDeclaration( |
| 81 FunctionExpression node, | 81 FunctionExpression node, |
| 82 ConstructorElement constructor, | 82 ConstructorElement constructor, |
| 83 NodeList parameters, | 83 NodeList parameters, |
| 84 NodeList initializers, | 84 NodeList initializers, |
| 85 Node body, | 85 Node body, |
| 86 _) { | 86 _) { |
| 87 applyParameters(parameters, _); | 87 applyParameters(parameters, _); |
| 88 ConstructedConstantExpression constructorInvocation = | 88 ConstructedConstantExpression constructorInvocation = |
| 89 applyInitializers(node, _); | 89 applyInitializers(node, _); |
| 90 constructor.enclosingClass.forEachInstanceField((_, FieldElement field) { | |
| 91 if (!fieldMap.containsKey(field)) { | |
| 92 fieldMap[field] = field.constant; | |
| 93 } | |
| 94 }); | |
| 95 return new GenerativeConstantConstructor( | 90 return new GenerativeConstantConstructor( |
| 96 currentClass.thisType, defaultValues, fieldMap, constructorInvocation); | 91 currentClass.thisType, defaultValues, fieldMap, constructorInvocation); |
| 97 } | 92 } |
| 98 | 93 |
| 99 ConstantConstructor visitRedirectingGenerativeConstructorDeclaration( | 94 ConstantConstructor visitRedirectingGenerativeConstructorDeclaration( |
| 100 FunctionExpression node, | 95 FunctionExpression node, |
| 101 ConstructorElement constructor, | 96 ConstructorElement constructor, |
| 102 NodeList parameters, | 97 NodeList parameters, |
| 103 NodeList initializers, | 98 NodeList initializers, |
| 104 _) { | 99 _) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 ConstantExpression visitNamedArgument(NamedArgument node) { | 334 ConstantExpression visitNamedArgument(NamedArgument node) { |
| 340 return apply(node.expression); | 335 return apply(node.expression); |
| 341 } | 336 } |
| 342 | 337 |
| 343 @override | 338 @override |
| 344 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { | 339 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { |
| 345 return new BinaryConstantExpression( | 340 return new BinaryConstantExpression( |
| 346 apply(left), BinaryOperator.IF_NULL, apply(right)); | 341 apply(left), BinaryOperator.IF_NULL, apply(right)); |
| 347 } | 342 } |
| 348 } | 343 } |
| OLD | NEW |