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

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

Issue 2888823004: Remove async modifier from outlines (Closed)
Patch Set: 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 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, 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;
(...skipping 20 matching lines...) Expand all
38 operatorRequiredArgumentCount; 38 operatorRequiredArgumentCount;
39 39
40 import '../quote.dart' show unescapeString; 40 import '../quote.dart' show unescapeString;
41 41
42 enum MethodBody { 42 enum MethodBody {
43 Abstract, 43 Abstract,
44 Regular, 44 Regular,
45 RedirectingFactoryBody, 45 RedirectingFactoryBody,
46 } 46 }
47 47
48 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) {
Siggi Cherem (dart-lang) 2017/05/18 19:44:03 this now only used by body_builder, so I moved it
49 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) {
50 if (starToken == null) {
51 return AsyncMarker.Sync;
52 } else {
53 assert(identical(starToken.stringValue, "*"));
54 return AsyncMarker.SyncStar;
55 }
56 } else if (identical(asyncToken.stringValue, "async")) {
57 if (starToken == null) {
58 return AsyncMarker.Async;
59 } else {
60 assert(identical(starToken.stringValue, "*"));
61 return AsyncMarker.AsyncStar;
62 }
63 } else {
64 return internalError("Unknown async modifier: $asyncToken");
65 }
66 }
67
68 class OutlineBuilder extends UnhandledListener { 48 class OutlineBuilder extends UnhandledListener {
69 final SourceLibraryBuilder library; 49 final SourceLibraryBuilder library;
70 50
71 final bool isDartLibrary; 51 final bool isDartLibrary;
72 52
73 String nativeMethodName; 53 String nativeMethodName;
74 54
75 OutlineBuilder(SourceLibraryBuilder library) 55 OutlineBuilder(SourceLibraryBuilder library)
76 : library = library, 56 : library = library,
77 isDartLibrary = library.uri.scheme == "dart"; 57 isDartLibrary = library.uri.scheme == "dart";
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 279
300 @override 280 @override
301 void beginTopLevelMethod(Token token, Token name) { 281 void beginTopLevelMethod(Token token, Token name) {
302 library.beginNestedDeclaration(name.lexeme, hasMembers: false); 282 library.beginNestedDeclaration(name.lexeme, hasMembers: false);
303 } 283 }
304 284
305 @override 285 @override
306 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { 286 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) {
307 debugEvent("endTopLevelMethod"); 287 debugEvent("endTopLevelMethod");
308 MethodBody kind = pop(); 288 MethodBody kind = pop();
309 AsyncMarker asyncModifier = pop();
310 List<FormalParameterBuilder> formals = pop(); 289 List<FormalParameterBuilder> formals = pop();
311 int formalsOffset = pop(); 290 int formalsOffset = pop();
312 List<TypeVariableBuilder> typeVariables = pop(); 291 List<TypeVariableBuilder> typeVariables = pop();
313 int charOffset = pop(); 292 int charOffset = pop();
314 String name = pop(); 293 String name = pop();
315 TypeBuilder returnType = pop(); 294 TypeBuilder returnType = pop();
316 int modifiers = 295 int modifiers =
317 Modifier.validate(pop(), isAbstract: kind == MethodBody.Abstract); 296 Modifier.validate(pop(), isAbstract: kind == MethodBody.Abstract);
318 List<MetadataBuilder> metadata = pop(); 297 List<MetadataBuilder> metadata = pop();
319 checkEmpty(beginToken.charOffset); 298 checkEmpty(beginToken.charOffset);
320 library.addProcedure( 299 library.addProcedure(
321 metadata, 300 metadata,
322 modifiers, 301 modifiers,
323 returnType, 302 returnType,
324 name, 303 name,
325 typeVariables, 304 typeVariables,
326 formals, 305 formals,
327 asyncModifier,
328 computeProcedureKind(getOrSet), 306 computeProcedureKind(getOrSet),
329 charOffset, 307 charOffset,
330 formalsOffset, 308 formalsOffset,
331 endToken.charOffset, 309 endToken.charOffset,
332 nativeMethodName, 310 nativeMethodName,
333 isTopLevel: true); 311 isTopLevel: true);
334 nativeMethodName = null; 312 nativeMethodName = null;
335 } 313 }
336 314
337 @override 315 @override
(...skipping 14 matching lines...) Expand all
352 } 330 }
353 331
354 @override 332 @override
355 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 333 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
356 debugEvent("Method"); 334 debugEvent("Method");
357 MethodBody bodyKind = pop(); 335 MethodBody bodyKind = pop();
358 if (bodyKind == MethodBody.RedirectingFactoryBody) { 336 if (bodyKind == MethodBody.RedirectingFactoryBody) {
359 // This will cause an error later. 337 // This will cause an error later.
360 pop(); 338 pop();
361 } 339 }
362 AsyncMarker asyncModifier = pop();
363 List<FormalParameterBuilder> formals = pop(); 340 List<FormalParameterBuilder> formals = pop();
364 int formalsOffset = pop(); 341 int formalsOffset = pop();
365 List<TypeVariableBuilder> typeVariables = pop(); 342 List<TypeVariableBuilder> typeVariables = pop();
366 int charOffset = pop(); 343 int charOffset = pop();
367 dynamic nameOrOperator = pop(); 344 dynamic nameOrOperator = pop();
368 if (Operator.subtract == nameOrOperator && formals == null) { 345 if (Operator.subtract == nameOrOperator && formals == null) {
369 nameOrOperator = Operator.unaryMinus; 346 nameOrOperator = Operator.unaryMinus;
370 } 347 }
371 String name; 348 String name;
372 ProcedureKind kind; 349 ProcedureKind kind;
(...skipping 24 matching lines...) Expand all
397 int modifiers = 374 int modifiers =
398 Modifier.validate(pop(), isAbstract: bodyKind == MethodBody.Abstract); 375 Modifier.validate(pop(), isAbstract: bodyKind == MethodBody.Abstract);
399 List<MetadataBuilder> metadata = pop(); 376 List<MetadataBuilder> metadata = pop();
400 library.addProcedure( 377 library.addProcedure(
401 metadata, 378 metadata,
402 modifiers, 379 modifiers,
403 returnType, 380 returnType,
404 name, 381 name,
405 typeVariables, 382 typeVariables,
406 formals, 383 formals,
407 asyncModifier,
408 kind, 384 kind,
409 charOffset, 385 charOffset,
410 formalsOffset, 386 formalsOffset,
411 endToken.charOffset, 387 endToken.charOffset,
412 nativeMethodName, 388 nativeMethodName,
413 isTopLevel: false); 389 isTopLevel: false);
414 nativeMethodName = null; 390 nativeMethodName = null;
415 } 391 }
416 392
417 @override 393 @override
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 689
714 @override 690 @override
715 void endFactoryMethod( 691 void endFactoryMethod(
716 Token beginToken, Token factoryKeyword, Token endToken) { 692 Token beginToken, Token factoryKeyword, Token endToken) {
717 debugEvent("FactoryMethod"); 693 debugEvent("FactoryMethod");
718 MethodBody kind = pop(); 694 MethodBody kind = pop();
719 ConstructorReferenceBuilder redirectionTarget; 695 ConstructorReferenceBuilder redirectionTarget;
720 if (kind == MethodBody.RedirectingFactoryBody) { 696 if (kind == MethodBody.RedirectingFactoryBody) {
721 redirectionTarget = pop(); 697 redirectionTarget = pop();
722 } 698 }
723 AsyncMarker asyncModifier = pop();
724 List<FormalParameterBuilder> formals = pop(); 699 List<FormalParameterBuilder> formals = pop();
725 int formalsOffset = pop(); 700 int formalsOffset = pop();
726 var name = pop(); 701 var name = pop();
727 int modifiers = Modifier.validate(pop()); 702 int modifiers = Modifier.validate(pop());
728 List<MetadataBuilder> metadata = pop(); 703 List<MetadataBuilder> metadata = pop();
729 library.addFactoryMethod( 704 library.addFactoryMethod(
730 metadata, 705 metadata,
731 modifiers, 706 modifiers,
732 name, 707 name,
733 formals, 708 formals,
734 asyncModifier,
735 redirectionTarget, 709 redirectionTarget,
736 factoryKeyword.next.charOffset, 710 factoryKeyword.next.charOffset,
737 formalsOffset, 711 formalsOffset,
738 endToken.charOffset, 712 endToken.charOffset,
739 nativeMethodName); 713 nativeMethodName);
740 nativeMethodName = null; 714 nativeMethodName = null;
741 } 715 }
742 716
743 @override 717 @override
744 void endRedirectingFactoryBody(Token beginToken, Token endToken) { 718 void endRedirectingFactoryBody(Token beginToken, Token endToken) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 753 }
780 754
781 @override 755 @override
782 void endClassBody(int memberCount, Token beginToken, Token endToken) { 756 void endClassBody(int memberCount, Token beginToken, Token endToken) {
783 debugEvent("ClassBody"); 757 debugEvent("ClassBody");
784 } 758 }
785 759
786 @override 760 @override
787 void handleAsyncModifier(Token asyncToken, Token starToken) { 761 void handleAsyncModifier(Token asyncToken, Token starToken) {
788 debugEvent("AsyncModifier"); 762 debugEvent("AsyncModifier");
789 push(asyncMarkerFromTokens(asyncToken, starToken));
790 } 763 }
791 764
792 @override 765 @override
793 void handleModifier(Token token) { 766 void handleModifier(Token token) {
794 debugEvent("Modifier"); 767 debugEvent("Modifier");
795 push(new Modifier.fromString(token.stringValue)); 768 push(new Modifier.fromString(token.stringValue));
796 } 769 }
797 770
798 @override 771 @override
799 void handleModifiers(int count) { 772 void handleModifiers(int count) {
(...skipping 18 matching lines...) Expand all
818 Link<Token> handleMemberName(Link<Token> identifiers) { 791 Link<Token> handleMemberName(Link<Token> identifiers) {
819 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 792 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
820 return removeNativeClause(identifiers); 793 return removeNativeClause(identifiers);
821 } 794 }
822 795
823 @override 796 @override
824 void debugEvent(String name) { 797 void debugEvent(String name) {
825 // printEvent(name); 798 // printEvent(name);
826 } 799 }
827 } 800 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698