OLD | NEW |
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 30 matching lines...) Expand all Loading... |
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 class OutlineBuilder extends UnhandledListener { | 48 class OutlineBuilder extends UnhandledListener { |
49 final SourceLibraryBuilder library; | 49 final SourceLibraryBuilder library; |
50 | 50 |
51 final bool isDartLibrary; | 51 final bool enableNative; |
52 | 52 |
53 String nativeMethodName; | 53 String nativeMethodName; |
54 | 54 |
55 OutlineBuilder(SourceLibraryBuilder library) | 55 OutlineBuilder(SourceLibraryBuilder library) |
56 : library = library, | 56 : library = library, |
57 isDartLibrary = library.uri.scheme == "dart"; | 57 enableNative = (library.uri.scheme == "dart" || library.isPatch); |
58 | 58 |
59 @override | 59 @override |
60 Uri get uri => library.fileUri; | 60 Uri get uri => library.fileUri; |
61 | 61 |
62 @override | 62 @override |
63 int popCharOffset() => pop(); | 63 int popCharOffset() => pop(); |
64 | 64 |
65 List<String> popIdentifierList(int count) { | 65 List<String> popIdentifierList(int count) { |
66 if (count == 0) return null; | 66 if (count == 0) return null; |
67 List<String> list = new List<String>.filled(count, null, growable: true); | 67 List<String> list = new List<String>.filled(count, null, growable: true); |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 } | 769 } |
770 | 770 |
771 @override | 771 @override |
772 void handleModifiers(int count) { | 772 void handleModifiers(int count) { |
773 debugEvent("Modifiers"); | 773 debugEvent("Modifiers"); |
774 push(popList(count) ?? NullValue.Modifiers); | 774 push(popList(count) ?? NullValue.Modifiers); |
775 } | 775 } |
776 | 776 |
777 @override | 777 @override |
778 Token handleUnrecoverableError(Token token, FastaMessage message) { | 778 Token handleUnrecoverableError(Token token, FastaMessage message) { |
779 if (isDartLibrary && message.code == codeExpectedBlockToSkip) { | 779 if (enableNative && message.code == codeExpectedBlockToSkip) { |
780 var target = library.loader.target; | 780 var target = library.loader.target; |
781 Token recover = target.skipNativeClause(token); | 781 Token recover = target.skipNativeClause(token); |
782 if (recover != null) { | 782 if (recover != null) { |
783 nativeMethodName = target.extractNativeMethodName(token); | 783 nativeMethodName = target.extractNativeMethodName(token); |
784 return recover; | 784 return recover; |
785 } | 785 } |
786 } | 786 } |
787 return super.handleUnrecoverableError(token, message); | 787 return super.handleUnrecoverableError(token, message); |
788 } | 788 } |
789 | 789 |
790 @override | 790 @override |
791 void addCompileTimeErrorFromMessage(FastaMessage message) { | 791 void addCompileTimeErrorFromMessage(FastaMessage message) { |
792 library.addCompileTimeError(message.charOffset, message.message, | 792 library.addCompileTimeError(message.charOffset, message.message, |
793 fileUri: message.uri); | 793 fileUri: message.uri); |
794 } | 794 } |
795 | 795 |
796 @override | 796 @override |
797 Link<Token> handleMemberName(Link<Token> identifiers) { | 797 Link<Token> handleMemberName(Link<Token> identifiers) { |
798 if (!isDartLibrary || identifiers.isEmpty) return identifiers; | 798 if (!enableNative || identifiers.isEmpty) return identifiers; |
799 return removeNativeClause(identifiers); | 799 return removeNativeClause(identifiers); |
800 } | 800 } |
801 | 801 |
802 @override | 802 @override |
803 void debugEvent(String name) { | 803 void debugEvent(String name) { |
804 // printEvent(name); | 804 // printEvent(name); |
805 } | 805 } |
806 } | 806 } |
OLD | NEW |