Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: pkg/compiler/lib/src/constants/constant_constructors.dart

Issue 2104843002: Handle fields with initializers in constant constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix invariants Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 333 }
329 return new IdenticalConstantExpression( 334 return new IdenticalConstantExpression(
330 apply(arguments.nodes.head), apply(arguments.nodes.tail.head)); 335 apply(arguments.nodes.head), apply(arguments.nodes.tail.head));
331 } 336 }
332 337
333 @override 338 @override
334 ConstantExpression visitNamedArgument(NamedArgument node) { 339 ConstantExpression visitNamedArgument(NamedArgument node) {
335 return apply(node.expression); 340 return apply(node.expression);
336 } 341 }
337 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698