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

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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698