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

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

Issue 2979463002: Revert "Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service." (Closed)
Patch Set: Created 3 years, 5 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 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
(...skipping 10 matching lines...) Expand all
21 import '../errors.dart' show internalError; 21 import '../errors.dart' show internalError;
22 22
23 import '../builder/builder.dart'; 23 import '../builder/builder.dart';
24 24
25 import '../modifier.dart' show abstractMask, externalMask, Modifier; 25 import '../modifier.dart' show abstractMask, externalMask, Modifier;
26 26
27 import 'source_library_builder.dart' show SourceLibraryBuilder; 27 import 'source_library_builder.dart' show SourceLibraryBuilder;
28 28
29 import 'unhandled_listener.dart' show NullValue, Unhandled, UnhandledListener; 29 import 'unhandled_listener.dart' show NullValue, Unhandled, UnhandledListener;
30 30
31 import '../parser/native_support.dart' 31 import '../parser/dart_vm_native.dart' show removeNativeClause;
32 show extractNativeMethodName, removeNativeClause, skipNativeClause;
33 32
34 import '../operator.dart' 33 import '../operator.dart'
35 show 34 show
36 Operator, 35 Operator,
37 operatorFromString, 36 operatorFromString,
38 operatorToString, 37 operatorToString,
39 operatorRequiredArgumentCount; 38 operatorRequiredArgumentCount;
40 39
41 import '../quote.dart' show unescapeString; 40 import '../quote.dart' show unescapeString;
42 41
43 enum MethodBody { 42 enum MethodBody {
44 Abstract, 43 Abstract,
45 Regular, 44 Regular,
46 RedirectingFactoryBody, 45 RedirectingFactoryBody,
47 } 46 }
48 47
49 class OutlineBuilder extends UnhandledListener { 48 class OutlineBuilder extends UnhandledListener {
50 final SourceLibraryBuilder library; 49 final SourceLibraryBuilder library;
51 50
52 final bool enableNative; 51 final bool enableNative;
53 final bool stringExpectedAfterNative;
54 52
55 /// When true, recoverable parser errors are silently ignored. This is 53 /// When true, recoverable parser errors are silently ignored. This is
56 /// because they will be reported by the BodyBuilder later. However, typedefs 54 /// because they will be reported by the BodyBuilder later. However, typedefs
57 /// are fully compiled by the outline builder, so parser errors are turned on 55 /// are fully compiled by the outline builder, so parser errors are turned on
58 /// when parsing typedefs. 56 /// when parsing typedefs.
59 bool silenceParserErrors = true; 57 bool silenceParserErrors = true;
60 58
61 String nativeMethodName; 59 String nativeMethodName;
62 60
63 OutlineBuilder(SourceLibraryBuilder library) 61 OutlineBuilder(SourceLibraryBuilder library)
64 : library = library, 62 : library = library,
65 enableNative = 63 enableNative = library.loader.target.enableNative(library);
66 library.loader.target.backendTarget.enableNative(library.uri),
67 stringExpectedAfterNative =
68 library.loader.target.backendTarget.nativeExtensionExpectsString;
69 64
70 @override 65 @override
71 Uri get uri => library.fileUri; 66 Uri get uri => library.fileUri;
72 67
73 @override 68 @override
74 int popCharOffset() => pop(); 69 int popCharOffset() => pop();
75 70
76 List<String> popIdentifierList(int count) { 71 List<String> popIdentifierList(int count) {
77 if (count == 0) return null; 72 if (count == 0) return null;
78 List<String> list = new List<String>.filled(count, null, growable: true); 73 List<String> list = new List<String>.filled(count, null, growable: true);
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 if (silenceParserErrors) { 842 if (silenceParserErrors) {
848 debugEvent("RecoverableError"); 843 debugEvent("RecoverableError");
849 } else { 844 } else {
850 super.handleRecoverableError(token, message); 845 super.handleRecoverableError(token, message);
851 } 846 }
852 } 847 }
853 848
854 @override 849 @override
855 Token handleUnrecoverableError(Token token, FastaMessage message) { 850 Token handleUnrecoverableError(Token token, FastaMessage message) {
856 if (enableNative && message.code == codeExpectedBlockToSkip) { 851 if (enableNative && message.code == codeExpectedBlockToSkip) {
857 Token recover = skipNativeClause(token, stringExpectedAfterNative); 852 var target = library.loader.target;
853 Token recover = target.skipNativeClause(token);
858 if (recover != null) { 854 if (recover != null) {
859 nativeMethodName = 855 nativeMethodName = target.extractNativeMethodName(token);
860 stringExpectedAfterNative ? extractNativeMethodName(token) : "";
861 return recover; 856 return recover;
862 } 857 }
863 } 858 }
864 return super.handleUnrecoverableError(token, message); 859 return super.handleUnrecoverableError(token, message);
865 } 860 }
866 861
867 @override 862 @override
868 void addCompileTimeErrorFromMessage(FastaMessage message) { 863 void addCompileTimeErrorFromMessage(FastaMessage message) {
869 library.addCompileTimeError(message.charOffset, message.message, 864 library.addCompileTimeError(message.charOffset, message.message,
870 fileUri: message.uri); 865 fileUri: message.uri);
871 } 866 }
872 867
873 @override 868 @override
874 Link<Token> handleMemberName(Link<Token> identifiers) { 869 Link<Token> handleMemberName(Link<Token> identifiers) {
875 if (!enableNative || identifiers.isEmpty) return identifiers; 870 if (!enableNative || identifiers.isEmpty) return identifiers;
876 return removeNativeClause(identifiers, stringExpectedAfterNative); 871 return removeNativeClause(identifiers);
877 } 872 }
878 873
879 @override 874 @override
880 void debugEvent(String name) { 875 void debugEvent(String name) {
881 // printEvent(name); 876 // printEvent(name);
882 } 877 }
883 } 878 }
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_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698