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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_const_expr.dart

Issue 1952663006: Support for NamedExpression(s) as constructor initializer arguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library serialization.summarize_const_expr; 5 library serialization.summarize_const_expr;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/type.dart' show DartType; 9 import 'package:analyzer/dart/element/type.dart' show DartType;
10 import 'package:analyzer/src/summary/format.dart'; 10 import 'package:analyzer/src/summary/format.dart';
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 throw new StateError('Unexpected initializer type ${node.runtimeType}'); 39 throw new StateError('Unexpected initializer type ${node.runtimeType}');
40 } 40 }
41 41
42 /** 42 /**
43 * Instances of this class keep track of intermediate state during 43 * Instances of this class keep track of intermediate state during
44 * serialization of a single constant [Expression]. 44 * serialization of a single constant [Expression].
45 */ 45 */
46 abstract class AbstractConstExprSerializer { 46 abstract class AbstractConstExprSerializer {
47 /** 47 /**
48 * See [UnlinkedConstBuilder.isInvalid]. 48 * See [UnlinkedConstBuilder.isValidConst].
49 */ 49 */
50 bool isValidConst = true; 50 bool isValidConst = true;
51 51
52 /** 52 /**
53 * See [UnlinkedConstBuilder.nmae].
54 */
55 String name = null;
56
57 /**
53 * See [UnlinkedConstBuilder.operations]. 58 * See [UnlinkedConstBuilder.operations].
54 */ 59 */
55 final List<UnlinkedConstOperation> operations = <UnlinkedConstOperation>[]; 60 final List<UnlinkedConstOperation> operations = <UnlinkedConstOperation>[];
56 61
57 /** 62 /**
58 * See [UnlinkedConstBuilder.assignmentOperators]. 63 * See [UnlinkedConstBuilder.assignmentOperators].
59 */ 64 */
60 final List<UnlinkedExprAssignOperator> assignmentOperators = 65 final List<UnlinkedExprAssignOperator> assignmentOperators =
61 <UnlinkedExprAssignOperator>[]; 66 <UnlinkedExprAssignOperator>[];
62 67
(...skipping 21 matching lines...) Expand all
84 * Return `true` if a constructor initializer expression is being serialized 89 * Return `true` if a constructor initializer expression is being serialized
85 * and the given [name] is a constructor parameter reference. 90 * and the given [name] is a constructor parameter reference.
86 */ 91 */
87 bool isConstructorParameterName(String name); 92 bool isConstructorParameterName(String name);
88 93
89 /** 94 /**
90 * Serialize the given [expr] expression into this serializer state. 95 * Serialize the given [expr] expression into this serializer state.
91 */ 96 */
92 void serialize(Expression expr) { 97 void serialize(Expression expr) {
93 try { 98 try {
99 if (expr is NamedExpression) {
100 NamedExpression namedExpression = expr;
101 name = namedExpression.name.label.name;
102 expr = namedExpression.expression;
103 }
94 _serialize(expr); 104 _serialize(expr);
95 } on StateError { 105 } on StateError {
96 isValidConst = false; 106 isValidConst = false;
97 } 107 }
98 } 108 }
99 109
100 /** 110 /**
101 * Serialize the given [annotation] into this serializer state. 111 * Serialize the given [annotation] into this serializer state.
102 */ 112 */
103 void serializeAnnotation(Annotation annotation); 113 void serializeAnnotation(Annotation annotation);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return serializeType(type?.type, type?.name, type?.typeArguments); 155 return serializeType(type?.type, type?.name, type?.typeArguments);
146 } 156 }
147 157
148 /** 158 /**
149 * Return the [UnlinkedConstBuilder] that corresponds to the state of this 159 * Return the [UnlinkedConstBuilder] that corresponds to the state of this
150 * serializer. 160 * serializer.
151 */ 161 */
152 UnlinkedConstBuilder toBuilder() { 162 UnlinkedConstBuilder toBuilder() {
153 return new UnlinkedConstBuilder( 163 return new UnlinkedConstBuilder(
154 isValidConst: isValidConst, 164 isValidConst: isValidConst,
165 name: name,
155 operations: operations, 166 operations: operations,
156 assignmentOperators: assignmentOperators, 167 assignmentOperators: assignmentOperators,
157 ints: ints, 168 ints: ints,
158 doubles: doubles, 169 doubles: doubles,
159 strings: strings, 170 strings: strings,
160 references: references); 171 references: references);
161 } 172 }
162 173
163 /** 174 /**
164 * Push the operation for the given assignable [expr]. 175 * Push the operation for the given assignable [expr].
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 expr = (expr as PrefixedIdentifier).prefix; 582 expr = (expr as PrefixedIdentifier).prefix;
572 } else if (expr is PropertyAccess) { 583 } else if (expr is PropertyAccess) {
573 expr = (expr as PropertyAccess).target; 584 expr = (expr as PropertyAccess).target;
574 } else { 585 } else {
575 return false; 586 return false;
576 } 587 }
577 } 588 }
578 return false; 589 return false;
579 } 590 }
580 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698