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

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

Issue 2953703002: Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service (Closed)
Patch Set: cl review updates: cleanup in kernel deserialization 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 if (silenceParserErrors) { 837 if (silenceParserErrors) {
833 debugEvent("RecoverableError"); 838 debugEvent("RecoverableError");
834 } else { 839 } else {
835 super.handleRecoverableError(token, message); 840 super.handleRecoverableError(token, message);
836 } 841 }
837 } 842 }
838 843
839 @override 844 @override
840 Token handleUnrecoverableError(Token token, FastaMessage message) { 845 Token handleUnrecoverableError(Token token, FastaMessage message) {
841 if (enableNative && message.code == codeExpectedBlockToSkip) { 846 if (enableNative && message.code == codeExpectedBlockToSkip) {
842 var target = library.loader.target; 847 Token recover = skipNativeClause(token, stringExpectedAfterNative);
843 Token recover = target.skipNativeClause(token);
844 if (recover != null) { 848 if (recover != null) {
845 nativeMethodName = target.extractNativeMethodName(token); 849 nativeMethodName =
850 stringExpectedAfterNative ? extractNativeMethodName(token) : "";
846 return recover; 851 return recover;
847 } 852 }
848 } 853 }
849 return super.handleUnrecoverableError(token, message); 854 return super.handleUnrecoverableError(token, message);
850 } 855 }
851 856
852 @override 857 @override
853 void addCompileTimeErrorFromMessage(FastaMessage message) { 858 void addCompileTimeErrorFromMessage(FastaMessage message) {
854 library.addCompileTimeError(message.charOffset, message.message, 859 library.addCompileTimeError(message.charOffset, message.message,
855 fileUri: message.uri); 860 fileUri: message.uri);
856 } 861 }
857 862
858 @override 863 @override
859 Link<Token> handleMemberName(Link<Token> identifiers) { 864 Link<Token> handleMemberName(Link<Token> identifiers) {
860 if (!enableNative || identifiers.isEmpty) return identifiers; 865 if (!enableNative || identifiers.isEmpty) return identifiers;
861 return removeNativeClause(identifiers); 866 return removeNativeClause(identifiers, stringExpectedAfterNative);
862 } 867 }
863 868
864 @override 869 @override
865 void debugEvent(String name) { 870 void debugEvent(String name) {
866 // printEvent(name); 871 // printEvent(name);
867 } 872 }
868 } 873 }
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