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

Side by Side Diff: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Issue 2716433002: Add support for FieldFormalParameter. (Closed)
Patch Set: Rollback parser changes. Created 3 years, 9 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
« pkg/front_end/front_end.iml ('K') | « pkg/front_end/front_end.iml ('k') | no next file » | 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 fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 thenExpression, toAnalyzerToken(colon), elseExpression)); 465 thenExpression, toAnalyzerToken(colon), elseExpression));
466 } 466 }
467 467
468 void endThrowExpression(Token throwToken, Token endToken) { 468 void endThrowExpression(Token throwToken, Token endToken) {
469 debugEvent("ThrowExpression"); 469 debugEvent("ThrowExpression");
470 push(ast.throwExpression(toAnalyzerToken(throwToken), pop())); 470 push(ast.throwExpression(toAnalyzerToken(throwToken), pop()));
471 } 471 }
472 472
473 void endFormalParameter(Token thisKeyword) { 473 void endFormalParameter(Token thisKeyword) {
474 debugEvent("FormalParameter"); 474 debugEvent("FormalParameter");
475 if (thisKeyword != null) {
476 internalError("'this' can't be used here.");
477 }
478 SimpleIdentifier name = pop(); 475 SimpleIdentifier name = pop();
479 TypeName type = pop(); 476 TypeName type = pop();
480 Token keyword = _popOptionalSingleModifier(); 477 Token keyword = _popOptionalSingleModifier();
481 pop(); // TODO(paulberry): Metadata. 478 pop(); // TODO(paulberry): Metadata.
482 // TODO(paulberry): handle covariant keyword. 479 // TODO(paulberry): handle covariant keyword.
483 SimpleFormalParameter node = ast.simpleFormalParameter( 480
484 null, null, toAnalyzerToken(keyword), type, name); 481 FormalParameter node;
482 if (thisKeyword == null) {
483 node = ast.simpleFormalParameter(
484 null, null, toAnalyzerToken(keyword), type, name);
485 } else {
486 // TODO(scheglov): Ideally the period token should be passed in.
487 Token period = identical('.', thisKeyword.next?.stringValue)
488 ? thisKeyword.next
489 : null;
490 TypeParameterList typeParameters; // TODO(scheglov)
491 FormalParameterList formalParameters; // TODO(scheglov)
492 node = ast.fieldFormalParameter(
493 null,
494 null,
495 toAnalyzerToken(keyword),
496 type,
497 toAnalyzerToken(thisKeyword),
498 toAnalyzerToken(period),
499 name,
500 typeParameters,
501 formalParameters);
502 }
503
485 scope[name.name] = name.staticElement = new AnalyzerParameterElement(node); 504 scope[name.name] = name.staticElement = new AnalyzerParameterElement(node);
486 push(node); 505 push(node);
487 } 506 }
488 507
489 void endFormalParameters(int count, Token beginToken, Token endToken) { 508 void endFormalParameters(int count, Token beginToken, Token endToken) {
490 debugEvent("FormalParameters"); 509 debugEvent("FormalParameters");
491 List<FormalParameter> parameters = popList(count) ?? <FormalParameter>[]; 510 List<FormalParameter> parameters = popList(count) ?? <FormalParameter>[];
492 push(ast.formalParameterList(toAnalyzerToken(beginToken), parameters, null, 511 push(ast.formalParameterList(toAnalyzerToken(beginToken), parameters, null,
493 null, toAnalyzerToken(endToken))); 512 null, toAnalyzerToken(endToken)));
494 } 513 }
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 /// [ClassDeclaration] or [ClassTypeAlias] object. 1202 /// [ClassDeclaration] or [ClassTypeAlias] object.
1184 class _MixinApplication { 1203 class _MixinApplication {
1185 final TypeName supertype; 1204 final TypeName supertype;
1186 1205
1187 final Token withKeyword; 1206 final Token withKeyword;
1188 1207
1189 final List<TypeName> mixinTypes; 1208 final List<TypeName> mixinTypes;
1190 1209
1191 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); 1210 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes);
1192 } 1211 }
OLDNEW
« pkg/front_end/front_end.iml ('K') | « pkg/front_end/front_end.iml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698