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

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

Issue 1963213002: Remove 'name' from argumentNames and replace with 'argumentsNames' in UnlinkedConstructorInitialize… (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';
11 import 'package:analyzer/src/summary/idl.dart'; 11 import 'package:analyzer/src/summary/idl.dart';
12 12
13 /** 13 /**
14 * Serialize the given constructor initializer [node]. 14 * Serialize the given constructor initializer [node].
15 */ 15 */
16 UnlinkedConstructorInitializer serializeConstructorInitializer( 16 UnlinkedConstructorInitializer serializeConstructorInitializer(
17 ConstructorInitializer node, 17 ConstructorInitializer node,
18 UnlinkedConstBuilder serializeConstExpr(Expression expr)) { 18 UnlinkedConstBuilder serializeConstExpr(Expression expr)) {
19 if (node is ConstructorFieldInitializer) { 19 if (node is ConstructorFieldInitializer) {
20 return new UnlinkedConstructorInitializerBuilder( 20 return new UnlinkedConstructorInitializerBuilder(
21 kind: UnlinkedConstructorInitializerKind.field, 21 kind: UnlinkedConstructorInitializerKind.field,
22 name: node.fieldName.name, 22 name: node.fieldName.name,
23 expression: serializeConstExpr(node.expression)); 23 expression: serializeConstExpr(node.expression));
24 } 24 }
25
26 List<UnlinkedConstBuilder> arguments = <UnlinkedConstBuilder>[];
27 List<String> argumentNames = <String>[];
28 void serializeArguments(List<Expression> args) {
29 for (Expression arg in args) {
30 if (arg is NamedExpression) {
31 NamedExpression namedExpression = arg;
32 argumentNames.add(namedExpression.name.label.name);
33 arg = namedExpression.expression;
34 }
35 arguments.add(serializeConstExpr(arg));
36 }
37 }
38
25 if (node is RedirectingConstructorInvocation) { 39 if (node is RedirectingConstructorInvocation) {
40 serializeArguments(node.argumentList.arguments);
26 return new UnlinkedConstructorInitializerBuilder( 41 return new UnlinkedConstructorInitializerBuilder(
27 kind: UnlinkedConstructorInitializerKind.thisInvocation, 42 kind: UnlinkedConstructorInitializerKind.thisInvocation,
28 name: node?.constructorName?.name, 43 name: node?.constructorName?.name,
29 arguments: 44 arguments: arguments,
30 node.argumentList.arguments.map(serializeConstExpr).toList()); 45 argumentNames: argumentNames);
31 } 46 }
32 if (node is SuperConstructorInvocation) { 47 if (node is SuperConstructorInvocation) {
48 serializeArguments(node.argumentList.arguments);
33 return new UnlinkedConstructorInitializerBuilder( 49 return new UnlinkedConstructorInitializerBuilder(
34 kind: UnlinkedConstructorInitializerKind.superInvocation, 50 kind: UnlinkedConstructorInitializerKind.superInvocation,
35 name: node?.constructorName?.name, 51 name: node?.constructorName?.name,
36 arguments: 52 arguments: arguments,
37 node.argumentList.arguments.map(serializeConstExpr).toList()); 53 argumentNames: argumentNames);
38 } 54 }
39 throw new StateError('Unexpected initializer type ${node.runtimeType}'); 55 throw new StateError('Unexpected initializer type ${node.runtimeType}');
40 } 56 }
41 57
42 /** 58 /**
43 * Instances of this class keep track of intermediate state during 59 * Instances of this class keep track of intermediate state during
44 * serialization of a single constant [Expression]. 60 * serialization of a single constant [Expression].
45 */ 61 */
46 abstract class AbstractConstExprSerializer { 62 abstract class AbstractConstExprSerializer {
47 /** 63 /**
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return serializeType(type?.type, type?.name, type?.typeArguments); 171 return serializeType(type?.type, type?.name, type?.typeArguments);
156 } 172 }
157 173
158 /** 174 /**
159 * Return the [UnlinkedConstBuilder] that corresponds to the state of this 175 * Return the [UnlinkedConstBuilder] that corresponds to the state of this
160 * serializer. 176 * serializer.
161 */ 177 */
162 UnlinkedConstBuilder toBuilder() { 178 UnlinkedConstBuilder toBuilder() {
163 return new UnlinkedConstBuilder( 179 return new UnlinkedConstBuilder(
164 isValidConst: isValidConst, 180 isValidConst: isValidConst,
165 name: name,
166 operations: operations, 181 operations: operations,
167 assignmentOperators: assignmentOperators, 182 assignmentOperators: assignmentOperators,
168 ints: ints, 183 ints: ints,
169 doubles: doubles, 184 doubles: doubles,
170 strings: strings, 185 strings: strings,
171 references: references); 186 references: references);
172 } 187 }
173 188
174 /** 189 /**
175 * Push the operation for the given assignable [expr]. 190 * Push the operation for the given assignable [expr].
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 expr = (expr as PrefixedIdentifier).prefix; 597 expr = (expr as PrefixedIdentifier).prefix;
583 } else if (expr is PropertyAccess) { 598 } else if (expr is PropertyAccess) {
584 expr = (expr as PropertyAccess).target; 599 expr = (expr as PropertyAccess).target;
585 } else { 600 } else {
586 return false; 601 return false;
587 } 602 }
588 } 603 }
589 return false; 604 return false;
590 } 605 }
591 } 606 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698