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 }); |
90 return new GenerativeConstantConstructor( | 95 return new GenerativeConstantConstructor( |
91 currentClass.thisType, defaultValues, fieldMap, constructorInvocation); | 96 currentClass.thisType, defaultValues, fieldMap, constructorInvocation); |
92 } | 97 } |
93 | 98 |
94 ConstantConstructor visitRedirectingGenerativeConstructorDeclaration( | 99 ConstantConstructor visitRedirectingGenerativeConstructorDeclaration( |
95 FunctionExpression node, | 100 FunctionExpression node, |
96 ConstructorElement constructor, | 101 ConstructorElement constructor, |
97 NodeList parameters, | 102 NodeList parameters, |
98 NodeList initializers, | 103 NodeList initializers, |
99 _) { | 104 _) { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 ConstantExpression visitNamedArgument(NamedArgument node) { | 339 ConstantExpression visitNamedArgument(NamedArgument node) { |
335 return apply(node.expression); | 340 return apply(node.expression); |
336 } | 341 } |
337 | 342 |
338 @override | 343 @override |
339 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { | 344 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { |
340 return new BinaryConstantExpression( | 345 return new BinaryConstantExpression( |
341 apply(left), BinaryOperator.IF_NULL, apply(right)); | 346 apply(left), BinaryOperator.IF_NULL, apply(right)); |
342 } | 347 } |
343 } | 348 } |
OLD | NEW |