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

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

Issue 1616023002: Add named arguments support into constant ASTs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/scanner.dart'; 8 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/summary/format.dart'; 9 import 'package:analyzer/src/summary/format.dart';
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } else if (operator == TokenType.PERCENT) { 181 } else if (operator == TokenType.PERCENT) {
182 operations.add(UnlinkedConstOperation.modulo); 182 operations.add(UnlinkedConstOperation.modulo);
183 } else { 183 } else {
184 throw new _ConstExprSerializationError('Unknown operator: $operator'); 184 throw new _ConstExprSerializationError('Unknown operator: $operator');
185 } 185 }
186 } 186 }
187 187
188 void _serializeInstanceCreation(InstanceCreationExpression expr) { 188 void _serializeInstanceCreation(InstanceCreationExpression expr) {
189 ConstructorName constructor = expr.constructorName; 189 ConstructorName constructor = expr.constructorName;
190 List<Expression> arguments = expr.argumentList.arguments; 190 List<Expression> arguments = expr.argumentList.arguments;
191 arguments.forEach(serialize); 191 // Serialize the arguments.
192 List<String> argumentNames = <String>[];
193 arguments.forEach((arg) {
194 if (arg is NamedExpression) {
195 argumentNames.add(arg.name.label.name);
196 serialize(arg.expression);
197 } else {
198 serialize(arg);
199 }
200 });
201 // Add the op-code and numbers of named and positional arguments.
192 operations.add(UnlinkedConstOperation.invokeConstructor); 202 operations.add(UnlinkedConstOperation.invokeConstructor);
203 ints.add(argumentNames.length);
204 strings.addAll(argumentNames);
205 ints.add(arguments.length - argumentNames.length);
206 // Serialize the reference.
193 references.add(serializeType(constructor.type)); 207 references.add(serializeType(constructor.type));
194 if (constructor.name != null) { 208 if (constructor.name != null) {
195 strings.add(constructor.name.name); 209 strings.add(constructor.name.name);
196 } else { 210 } else {
197 strings.add(''); 211 strings.add('');
198 } 212 }
199 // TODO(scheglov) named arguments?
200 ints.add(arguments.length);
201 } 213 }
202 214
203 void _serializeListLiteral(ListLiteral expr) { 215 void _serializeListLiteral(ListLiteral expr) {
204 List<Expression> elements = expr.elements; 216 List<Expression> elements = expr.elements;
205 elements.forEach(serialize); 217 elements.forEach(serialize);
206 TypeName typeArgument; 218 TypeName typeArgument;
207 if (expr.typeArguments != null && 219 if (expr.typeArguments != null &&
208 expr.typeArguments.arguments.length == 1) { 220 expr.typeArguments.arguments.length == 1) {
209 typeArgument = expr.typeArguments.arguments[0]; 221 typeArgument = expr.typeArguments.arguments[0];
210 } 222 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 * Error that describes a problem during a constant expression serialization. 290 * Error that describes a problem during a constant expression serialization.
279 */ 291 */
280 class _ConstExprSerializationError { 292 class _ConstExprSerializationError {
281 final String message; 293 final String message;
282 294
283 _ConstExprSerializationError(this.message); 295 _ConstExprSerializationError(this.message);
284 296
285 @override 297 @override
286 String toString() => message; 298 String toString() => message;
287 } 299 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698