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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2876813002: Implement generalized function types. (Closed)
Patch Set: Address comments. Created 3 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 fasta.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; 7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind;
8 8
9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip; 9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip;
10 10
11 import '../parser/parser.dart' show FormalParameterType, optional; 11 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional;
12 12
13 import '../parser/identifier_context.dart' show IdentifierContext; 13 import '../parser/identifier_context.dart' show IdentifierContext;
14 14
15 import '../../scanner/token.dart' show Token; 15 import '../../scanner/token.dart' show Token;
16 16
17 import '../util/link.dart' show Link; 17 import '../util/link.dart' show Link;
18 18
19 import '../combinator.dart' show Combinator; 19 import '../combinator.dart' show Combinator;
20 20
21 import '../errors.dart' show internalError; 21 import '../errors.dart' show internalError;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 push(popList(count) ?? NullValue.TypeVariables); 475 push(popList(count) ?? NullValue.TypeVariables);
476 } 476 }
477 477
478 @override 478 @override
479 void handleVoidKeyword(Token token) { 479 void handleVoidKeyword(Token token) {
480 debugEvent("VoidKeyword"); 480 debugEvent("VoidKeyword");
481 push(library.addVoidType(token.charOffset)); 481 push(library.addVoidType(token.charOffset));
482 } 482 }
483 483
484 @override 484 @override
485 void endFormalParameter(Token covariantKeyword, Token thisKeyword, 485 void endFormalParameter(Token thisKeyword, Token nameToken,
486 Token nameToken, FormalParameterType kind) { 486 FormalParameterType kind, MemberKind memberKind) {
487 debugEvent("FormalParameter"); 487 debugEvent("FormalParameter");
488 int charOffset = pop(); 488 int charOffset = pop();
489 String name = pop(); 489 String name = pop();
490 TypeBuilder type = pop(); 490 TypeBuilder type = pop();
491 int modifiers = Modifier.validate(pop()); 491 int modifiers = Modifier.validate(pop());
492 List<MetadataBuilder> metadata = pop(); 492 List<MetadataBuilder> metadata = pop();
493 push(library.addFormalParameter( 493 push(library.addFormalParameter(
494 metadata, modifiers, type, name, thisKeyword != null, charOffset)); 494 metadata, modifiers, type, name, thisKeyword != null, charOffset));
495 } 495 }
496 496
497 @override 497 @override
498 void handleValuedFormalParameter(Token equals, Token token) { 498 void handleValuedFormalParameter(Token equals, Token token) {
499 debugEvent("ValuedFormalParameter"); 499 debugEvent("ValuedFormalParameter");
500 // Ignored for now. 500 // Ignored for now.
501 } 501 }
502 502
503 @override 503 @override
504 void handleFormalParameterWithoutValue(Token token) { 504 void handleFormalParameterWithoutValue(Token token) {
505 debugEvent("FormalParameterWithoutValue"); 505 debugEvent("FormalParameterWithoutValue");
506 // Ignored for now. 506 // Ignored for now.
507 } 507 }
508 508
509 @override 509 @override
510 void endFunctionTypedFormalParameter( 510 void endFunctionTypedFormalParameter(
511 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 511 Token thisKeyword, FormalParameterType kind) {
512 debugEvent("FunctionTypedFormalParameter"); 512 debugEvent("FunctionTypedFormalParameter");
513 List<FormalParameterBuilder> formals = pop(); 513 List<FormalParameterBuilder> formals = pop();
514 int formalsOffset = pop(); 514 int formalsOffset = pop();
515 List<TypeVariableBuilder> typeVariables = pop(); 515 List<TypeVariableBuilder> typeVariables = pop();
516 int charOffset = pop(); 516 int charOffset = pop();
517 String name = pop(); 517 String name = pop();
518 TypeBuilder returnType = pop(); 518 TypeBuilder returnType = pop();
519 push(library.addFunctionType( 519 push(library.addFunctionType(
520 returnType, typeVariables, formals, formalsOffset)); 520 returnType, typeVariables, formals, formalsOffset));
521 push(name); 521 push(name);
(...skipping 12 matching lines...) Expand all
534 // case, however, then [beginOptionalFormalParameters] wouldn't always be 534 // case, however, then [beginOptionalFormalParameters] wouldn't always be
535 // matched by this method. 535 // matched by this method.
536 List parameters = popList(count) ?? []; 536 List parameters = popList(count) ?? [];
537 for (FormalParameterBuilder parameter in parameters) { 537 for (FormalParameterBuilder parameter in parameters) {
538 parameter.kind = kind; 538 parameter.kind = kind;
539 } 539 }
540 push(parameters); 540 push(parameters);
541 } 541 }
542 542
543 @override 543 @override
544 void endFormalParameters(int count, Token beginToken, Token endToken) { 544 void endFormalParameters(
545 int count, Token beginToken, Token endToken, MemberKind kind) {
545 debugEvent("FormalParameters"); 546 debugEvent("FormalParameters");
546 List formals = popList(count); 547 List formals = popList(count);
547 if (formals != null && formals.isNotEmpty) { 548 if (formals != null && formals.isNotEmpty) {
548 var last = formals.last; 549 var last = formals.last;
549 if (last is List) { 550 if (last is List) {
550 // TODO(sigmund): change `List newList` back to `var` (this is a 551 // TODO(sigmund): change `List newList` back to `var` (this is a
551 // workaround for issue #28651). Eventually, make optional 552 // workaround for issue #28651). Eventually, make optional
552 // formals a separate stack entry (#28673). 553 // formals a separate stack entry (#28673).
553 List newList = 554 List newList =
554 new List<FormalParameterBuilder>(formals.length - 1 + last.length); 555 new List<FormalParameterBuilder>(formals.length - 1 + last.length);
(...skipping 11 matching lines...) Expand all
566 internalError(formals); 567 internalError(formals);
567 } 568 }
568 } 569 }
569 formals = new List<FormalParameterBuilder>.from(formals); 570 formals = new List<FormalParameterBuilder>.from(formals);
570 } 571 }
571 push(beginToken.charOffset); 572 push(beginToken.charOffset);
572 push(formals ?? NullValue.FormalParameters); 573 push(formals ?? NullValue.FormalParameters);
573 } 574 }
574 575
575 @override 576 @override
576 void handleNoFormalParameters(Token token) { 577 void handleNoFormalParameters(Token token, MemberKind kind) {
577 push(token.charOffset); 578 push(token.charOffset);
578 super.handleNoFormalParameters(token); 579 super.handleNoFormalParameters(token, kind);
579 } 580 }
580 581
581 @override 582 @override
582 void endEnum(Token enumKeyword, Token endBrace, int count) { 583 void endEnum(Token enumKeyword, Token endBrace, int count) {
583 List constantNamesAndOffsets = popList(count * 2); 584 List constantNamesAndOffsets = popList(count * 2);
584 int charOffset = pop(); 585 int charOffset = pop();
585 String name = pop(); 586 String name = pop();
586 List<MetadataBuilder> metadata = pop(); 587 List<MetadataBuilder> metadata = pop();
587 library.addEnum(metadata, name, constantNamesAndOffsets, charOffset, 588 library.addEnum(metadata, name, constantNamesAndOffsets, charOffset,
588 endBrace.charOffset); 589 endBrace.charOffset);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 debugEvent("endTopLevelFields"); 652 debugEvent("endTopLevelFields");
652 List namesOffsetsAndInitializers = popList(count * 4); 653 List namesOffsetsAndInitializers = popList(count * 4);
653 TypeBuilder type = pop(); 654 TypeBuilder type = pop();
654 int modifiers = Modifier.validate(pop()); 655 int modifiers = Modifier.validate(pop());
655 List<MetadataBuilder> metadata = pop(); 656 List<MetadataBuilder> metadata = pop();
656 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers); 657 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers);
657 checkEmpty(beginToken.charOffset); 658 checkEmpty(beginToken.charOffset);
658 } 659 }
659 660
660 @override 661 @override
661 void endFields( 662 void endFields(int count, Token beginToken, Token endToken) {
662 int count, Token covariantToken, Token beginToken, Token endToken) {
663 debugEvent("Fields"); 663 debugEvent("Fields");
664 List namesOffsetsAndInitializers = popList(count * 4); 664 List namesOffsetsAndInitializers = popList(count * 4);
665 TypeBuilder type = pop(); 665 TypeBuilder type = pop();
666 int modifiers = Modifier.validate(pop()); 666 int modifiers = Modifier.validate(pop());
667 List<MetadataBuilder> metadata = pop(); 667 List<MetadataBuilder> metadata = pop();
668 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers); 668 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers);
669 } 669 }
670 670
671 @override 671 @override
672 void endTypeVariable(Token token, Token extendsOrSuper) { 672 void endTypeVariable(Token token, Token extendsOrSuper) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 Link<Token> handleMemberName(Link<Token> identifiers) { 818 Link<Token> handleMemberName(Link<Token> identifiers) {
819 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 819 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
820 return removeNativeClause(identifiers); 820 return removeNativeClause(identifiers);
821 } 821 }
822 822
823 @override 823 @override
824 void debugEvent(String name) { 824 void debugEvent(String name) {
825 // printEvent(name); 825 // printEvent(name);
826 } 826 }
827 } 827 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/source/diet_parser.dart ('k') | pkg/front_end/lib/src/fasta/source/stack_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698