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

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

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

Powered by Google App Engine
This is Rietveld 408576698