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

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

Issue 2730093002: Avoid crashing on function syntax. (Closed)
Patch Set: Update status. 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
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 '../parser/parser.dart' show FormalParameterType, optional; 9 import '../parser/parser.dart' show FormalParameterType, optional;
10 10
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 library.addEnum(metadata, name, constants, enumKeyword.charOffset); 475 library.addEnum(metadata, name, constants, enumKeyword.charOffset);
476 checkEmpty(enumKeyword.charOffset); 476 checkEmpty(enumKeyword.charOffset);
477 } 477 }
478 478
479 @override 479 @override
480 void beginFunctionTypeAlias(Token token) { 480 void beginFunctionTypeAlias(Token token) {
481 library.beginNestedDeclaration(null, hasMembers: false); 481 library.beginNestedDeclaration(null, hasMembers: false);
482 } 482 }
483 483
484 @override 484 @override
485 void handleFunctionType(Token functionToken, Token endToken) {
486 debugEvent("FunctionType");
487 List<FormalParameterBuilder> formals = pop();
488 List<TypeVariableBuilder> typeVariables = pop();
489 TypeBuilder returnType = pop();
490 push(library.addFunctionType(
491 returnType, typeVariables, formals, functionToken.charOffset));
492 }
493
494 @override
485 void endFunctionTypeAlias( 495 void endFunctionTypeAlias(
486 Token typedefKeyword, Token equals, Token endToken) { 496 Token typedefKeyword, Token equals, Token endToken) {
487 debugEvent("endFunctionTypeAlias"); 497 debugEvent("endFunctionTypeAlias");
488 List<FormalParameterBuilder> formals = pop(); 498 List<FormalParameterBuilder> formals;
489 List<TypeVariableBuilder> typeVariables = pop(); 499 List<TypeVariableBuilder> typeVariables;
490 String name = pop(); 500 String name;
491 TypeBuilder returnType = pop(); 501 TypeBuilder returnType;
502 if (equals == null) {
503 formals = pop();
504 typeVariables = pop();
505 name = pop();
506 returnType = pop();
507 } else {
508 var type = pop();
509 typeVariables = pop();
510 name = pop();
511 if (type is FunctionTypeBuilder) {
512 // TODO(ahe): We need to start a nested declaration when parsing the
513 // formals and return type so we can correctly bind
514 // `type.typeVariables`. A typedef can have type variables, and a new
515 // function type can also have type variables (representing the type of
516 // a generic function).
517 formals = type.formals;
518 returnType = type.returnType;
519 } else {
520 // TODO(ahe): Improve this error message.
521 library.addCompileTimeError(
522 equals.charOffset, "Can't create typedef from non-function type.");
523 }
524 }
492 List<MetadataBuilder> metadata = pop(); 525 List<MetadataBuilder> metadata = pop();
493 library.addFunctionTypeAlias(metadata, returnType, name, typeVariables, 526 library.addFunctionTypeAlias(metadata, returnType, name, typeVariables,
494 formals, typedefKeyword.charOffset); 527 formals, typedefKeyword.charOffset);
495 checkEmpty(typedefKeyword.charOffset); 528 checkEmpty(typedefKeyword.charOffset);
496 } 529 }
497 530
498 @override 531 @override
499 void endTopLevelFields(int count, Token beginToken, Token endToken) { 532 void endTopLevelFields(int count, Token beginToken, Token endToken) {
500 debugEvent("endTopLevelFields"); 533 debugEvent("endTopLevelFields");
501 List<String> names = popList(count); 534 List<String> names = popList(count);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 Link<Token> handleMemberName(Link<Token> identifiers) { 674 Link<Token> handleMemberName(Link<Token> identifiers) {
642 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 675 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
643 return removeNativeClause(identifiers); 676 return removeNativeClause(identifiers);
644 } 677 }
645 678
646 @override 679 @override
647 void debugEvent(String name) { 680 void debugEvent(String name) {
648 // printEvent(name); 681 // printEvent(name);
649 } 682 }
650 } 683 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/source/diet_listener.dart ('k') | pkg/front_end/lib/src/fasta/source/source_library_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698