| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| 7 | 7 |
| 8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 const uint8_t* saved_raw_buffer_; | 708 const uint8_t* saved_raw_buffer_; |
| 709 const TypedData* saved_typed_data_; | 709 const TypedData* saved_typed_data_; |
| 710 intptr_t saved_offset_; | 710 intptr_t saved_offset_; |
| 711 }; | 711 }; |
| 712 | 712 |
| 713 // Helper class that reads a kernel FunctionNode from binary. | 713 // Helper class that reads a kernel FunctionNode from binary. |
| 714 // | 714 // |
| 715 // Use ReadUntilExcluding to read up to but not including a field. | 715 // Use ReadUntilExcluding to read up to but not including a field. |
| 716 // One can then for instance read the field from the call-site (and remember to | 716 // One can then for instance read the field from the call-site (and remember to |
| 717 // call SetAt to inform this helper class), and then use this to read more. | 717 // call SetAt to inform this helper class), and then use this to read more. |
| 718 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 718 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 719 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 719 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 720 class FunctionNodeHelper { | 720 class FunctionNodeHelper { |
| 721 public: | 721 public: |
| 722 enum Fields { | 722 enum Field { |
| 723 kStart, // tag. | 723 kStart, // tag. |
| 724 kPosition, | 724 kPosition, |
| 725 kEndPosition, | 725 kEndPosition, |
| 726 kAsyncMarker, | 726 kAsyncMarker, |
| 727 kDartAsyncMarker, | 727 kDartAsyncMarker, |
| 728 kTypeParameters, | 728 kTypeParameters, |
| 729 kTotalParameterCount, | 729 kTotalParameterCount, |
| 730 kRequiredParameterCount, | 730 kRequiredParameterCount, |
| 731 kPositionalParameters, | 731 kPositionalParameters, |
| 732 kNamedParameters, | 732 kNamedParameters, |
| 733 kReturnType, | 733 kReturnType, |
| 734 kBody, | 734 kBody, |
| 735 kEnd | 735 kEnd |
| 736 }; | 736 }; |
| 737 | 737 |
| 738 explicit FunctionNodeHelper(StreamingFlowGraphBuilder* builder) { | 738 explicit FunctionNodeHelper(StreamingFlowGraphBuilder* builder) { |
| 739 builder_ = builder; | 739 builder_ = builder; |
| 740 next_read_ = kStart; | 740 next_read_ = kStart; |
| 741 } | 741 } |
| 742 | 742 |
| 743 void ReadUntilIncluding(Fields field) { | 743 void ReadUntilIncluding(Field field) { |
| 744 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 744 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 745 } | 745 } |
| 746 | 746 |
| 747 void ReadUntilExcluding(Fields field) { | 747 void ReadUntilExcluding(Field field); |
| 748 if (field <= next_read_) return; | |
| 749 | 748 |
| 750 // Ordered with fall-through. | 749 void SetNext(Field field) { next_read_ = field; } |
| 751 switch (next_read_) { | 750 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 752 case kStart: { | |
| 753 Tag tag = builder_->ReadTag(); // read tag. | |
| 754 ASSERT(tag == kFunctionNode); | |
| 755 if (++next_read_ == field) return; | |
| 756 } | |
| 757 case kPosition: | |
| 758 position_ = builder_->ReadPosition(); // read position. | |
| 759 if (++next_read_ == field) return; | |
| 760 case kEndPosition: | |
| 761 end_position_ = builder_->ReadPosition(); // read end position. | |
| 762 if (++next_read_ == field) return; | |
| 763 case kAsyncMarker: | |
| 764 async_marker_ = static_cast<FunctionNode::AsyncMarker>( | |
| 765 builder_->ReadByte()); // read async marker. | |
| 766 if (++next_read_ == field) return; | |
| 767 case kDartAsyncMarker: | |
| 768 dart_async_marker_ = static_cast<FunctionNode::AsyncMarker>( | |
| 769 builder_->ReadByte()); // read dart async marker. | |
| 770 if (++next_read_ == field) return; | |
| 771 case kTypeParameters: | |
| 772 builder_->SkipTypeParametersList(); // read type parameters. | |
| 773 if (++next_read_ == field) return; | |
| 774 case kTotalParameterCount: | |
| 775 total_parameter_count_ = | |
| 776 builder_->ReadUInt(); // read total parameter count. | |
| 777 if (++next_read_ == field) return; | |
| 778 case kRequiredParameterCount: | |
| 779 required_parameter_count_ = | |
| 780 builder_->ReadUInt(); // read required parameter count. | |
| 781 if (++next_read_ == field) return; | |
| 782 case kPositionalParameters: | |
| 783 builder_->SkipListOfVariableDeclarations(); // read positionals. | |
| 784 if (++next_read_ == field) return; | |
| 785 case kNamedParameters: | |
| 786 builder_->SkipListOfVariableDeclarations(); // read named. | |
| 787 if (++next_read_ == field) return; | |
| 788 case kReturnType: | |
| 789 builder_->SkipDartType(); // read return type. | |
| 790 if (++next_read_ == field) return; | |
| 791 case kBody: | |
| 792 if (builder_->ReadTag() == kSomething) | |
| 793 builder_->SkipStatement(); // read body. | |
| 794 if (++next_read_ == field) return; | |
| 795 case kEnd: | |
| 796 return; | |
| 797 } | |
| 798 } | |
| 799 | |
| 800 void SetNext(Fields field) { next_read_ = field; } | |
| 801 void SetJustRead(Fields field) { | |
| 802 next_read_ = field; | |
| 803 ++next_read_; | |
| 804 } | |
| 805 | 751 |
| 806 TokenPosition position_; | 752 TokenPosition position_; |
| 807 TokenPosition end_position_; | 753 TokenPosition end_position_; |
| 808 FunctionNode::AsyncMarker async_marker_; | 754 FunctionNode::AsyncMarker async_marker_; |
| 809 FunctionNode::AsyncMarker dart_async_marker_; | 755 FunctionNode::AsyncMarker dart_async_marker_; |
| 810 intptr_t total_parameter_count_; | 756 intptr_t total_parameter_count_; |
| 811 intptr_t required_parameter_count_; | 757 intptr_t required_parameter_count_; |
| 812 | 758 |
| 813 private: | 759 private: |
| 814 StreamingFlowGraphBuilder* builder_; | 760 StreamingFlowGraphBuilder* builder_; |
| 815 intptr_t next_read_; | 761 intptr_t next_read_; |
| 816 }; | 762 }; |
| 817 | 763 |
| 818 // Helper class that reads a kernel VariableDeclaration from binary. | 764 // Helper class that reads a kernel VariableDeclaration from binary. |
| 819 // | 765 // |
| 820 // Use ReadUntilExcluding to read up to but not including a field. | 766 // Use ReadUntilExcluding to read up to but not including a field. |
| 821 // One can then for instance read the field from the call-site (and remember to | 767 // One can then for instance read the field from the call-site (and remember to |
| 822 // call SetAt to inform this helper class), and then use this to read more. | 768 // call SetAt to inform this helper class), and then use this to read more. |
| 823 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 769 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 824 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 770 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 825 class VariableDeclarationHelper { | 771 class VariableDeclarationHelper { |
| 826 public: | 772 public: |
| 827 enum Fields { | 773 enum Field { |
| 828 kPosition, | 774 kPosition, |
| 829 kEqualPosition, | 775 kEqualPosition, |
| 830 kFlags, | 776 kFlags, |
| 831 kNameIndex, | 777 kNameIndex, |
| 832 kType, | 778 kType, |
| 833 kInitializer, | 779 kInitializer, |
| 834 kEnd | 780 kEnd |
| 835 }; | 781 }; |
| 836 | 782 |
| 837 explicit VariableDeclarationHelper(StreamingFlowGraphBuilder* builder) { | 783 explicit VariableDeclarationHelper(StreamingFlowGraphBuilder* builder) { |
| 838 builder_ = builder; | 784 builder_ = builder; |
| 839 next_read_ = kPosition; | 785 next_read_ = kPosition; |
| 840 } | 786 } |
| 841 | 787 |
| 842 void ReadUntilIncluding(Fields field) { | 788 void ReadUntilIncluding(Field field) { |
| 843 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 789 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 844 } | 790 } |
| 845 | 791 |
| 846 void ReadUntilExcluding(Fields field) { | 792 void ReadUntilExcluding(Field field); |
| 847 if (field <= next_read_) return; | |
| 848 | 793 |
| 849 // Ordered with fall-through. | 794 void SetNext(Field field) { next_read_ = field; } |
| 850 switch (next_read_) { | 795 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 851 case kPosition: | |
| 852 position_ = builder_->ReadPosition(); // read position. | |
| 853 if (++next_read_ == field) return; | |
| 854 case kEqualPosition: | |
| 855 equals_position_ = builder_->ReadPosition(); // read equals position. | |
| 856 if (++next_read_ == field) return; | |
| 857 case kFlags: | |
| 858 flags_ = builder_->ReadFlags(); // read flags. | |
| 859 if (++next_read_ == field) return; | |
| 860 case kNameIndex: | |
| 861 name_index_ = builder_->ReadStringReference(); // read name index. | |
| 862 if (++next_read_ == field) return; | |
| 863 case kType: | |
| 864 builder_->SkipDartType(); // read type. | |
| 865 if (++next_read_ == field) return; | |
| 866 case kInitializer: | |
| 867 if (builder_->ReadTag() == kSomething) | |
| 868 builder_->SkipExpression(); // read initializer. | |
| 869 if (++next_read_ == field) return; | |
| 870 case kEnd: | |
| 871 return; | |
| 872 } | |
| 873 } | |
| 874 | |
| 875 void SetNext(Fields field) { next_read_ = field; } | |
| 876 void SetJustRead(Fields field) { | |
| 877 next_read_ = field; | |
| 878 ++next_read_; | |
| 879 } | |
| 880 | 796 |
| 881 bool IsConst() { | 797 bool IsConst() { |
| 882 return (flags_ & VariableDeclaration::kFlagConst) == | 798 return (flags_ & VariableDeclaration::kFlagConst) == |
| 883 VariableDeclaration::kFlagConst; | 799 VariableDeclaration::kFlagConst; |
| 884 } | 800 } |
| 885 bool IsFinal() { | 801 bool IsFinal() { |
| 886 return (flags_ & VariableDeclaration::kFlagFinal) == | 802 return (flags_ & VariableDeclaration::kFlagFinal) == |
| 887 VariableDeclaration::kFlagFinal; | 803 VariableDeclaration::kFlagFinal; |
| 888 } | 804 } |
| 889 | 805 |
| 890 TokenPosition position_; | 806 TokenPosition position_; |
| 891 TokenPosition equals_position_; | 807 TokenPosition equals_position_; |
| 892 word flags_; | 808 word flags_; |
| 893 StringIndex name_index_; | 809 StringIndex name_index_; |
| 894 | 810 |
| 895 private: | 811 private: |
| 896 StreamingFlowGraphBuilder* builder_; | 812 StreamingFlowGraphBuilder* builder_; |
| 897 intptr_t next_read_; | 813 intptr_t next_read_; |
| 898 }; | 814 }; |
| 899 | 815 |
| 900 // Helper class that reads a kernel Field from binary. | 816 // Helper class that reads a kernel Field from binary. |
| 901 // | 817 // |
| 902 // Use ReadUntilExcluding to read up to but not including a field. | 818 // Use ReadUntilExcluding to read up to but not including a field. |
| 903 // One can then for instance read the field from the call-site (and remember to | 819 // One can then for instance read the field from the call-site (and remember to |
| 904 // call SetAt to inform this helper class), and then use this to read more. | 820 // call SetAt to inform this helper class), and then use this to read more. |
| 905 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 821 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 906 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 822 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 907 class FieldHelper { | 823 class FieldHelper { |
| 908 public: | 824 public: |
| 909 enum Fields { | 825 enum Field { |
| 910 kStart, // tag. | 826 kStart, // tag. |
| 911 kCanonicalName, | 827 kCanonicalName, |
| 912 kPosition, | 828 kPosition, |
| 913 kEndPosition, | 829 kEndPosition, |
| 914 kFlags, | 830 kFlags, |
| 915 kName, | 831 kName, |
| 916 kSourceUriIndex, | 832 kSourceUriIndex, |
| 917 kDocumentationCommentIndex, | 833 kDocumentationCommentIndex, |
| 918 kAnnotations, | 834 kAnnotations, |
| 919 kType, | 835 kType, |
| 920 kInitializer, | 836 kInitializer, |
| 921 kEnd | 837 kEnd |
| 922 }; | 838 }; |
| 923 | 839 |
| 924 explicit FieldHelper(StreamingFlowGraphBuilder* builder) | 840 explicit FieldHelper(StreamingFlowGraphBuilder* builder) |
| 925 : builder_(builder), | 841 : builder_(builder), |
| 926 next_read_(kStart), | 842 next_read_(kStart), |
| 927 has_function_literal_initializer_(false) {} | 843 has_function_literal_initializer_(false) {} |
| 928 | 844 |
| 929 FieldHelper(StreamingFlowGraphBuilder* builder, intptr_t offset) | 845 FieldHelper(StreamingFlowGraphBuilder* builder, intptr_t offset) |
| 930 : builder_(builder), | 846 : builder_(builder), |
| 931 next_read_(kStart), | 847 next_read_(kStart), |
| 932 has_function_literal_initializer_(false) { | 848 has_function_literal_initializer_(false) { |
| 933 builder_->SetOffset(offset); | 849 builder_->SetOffset(offset); |
| 934 } | 850 } |
| 935 | 851 |
| 936 void ReadUntilIncluding(Fields field) { | 852 void ReadUntilIncluding(Field field) { |
| 937 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 853 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 938 } | 854 } |
| 939 | 855 |
| 940 void ReadUntilExcluding(Fields field, | 856 void ReadUntilExcluding(Field field, |
| 941 bool detect_function_literal_initializer = false) { | 857 bool detect_function_literal_initializer = false); |
| 942 if (field <= next_read_) return; | |
| 943 | 858 |
| 944 // Ordered with fall-through. | 859 void SetNext(Field field) { next_read_ = field; } |
| 945 switch (next_read_) { | 860 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 946 case kStart: { | |
| 947 Tag tag = builder_->ReadTag(); // read tag. | |
| 948 ASSERT(tag == kField); | |
| 949 if (++next_read_ == field) return; | |
| 950 } | |
| 951 case kCanonicalName: | |
| 952 canonical_name_ = | |
| 953 builder_->ReadCanonicalNameReference(); // read canonical_name. | |
| 954 if (++next_read_ == field) return; | |
| 955 case kPosition: | |
| 956 position_ = builder_->ReadPosition(false); // read position. | |
| 957 if (++next_read_ == field) return; | |
| 958 case kEndPosition: | |
| 959 end_position_ = builder_->ReadPosition(false); // read end position. | |
| 960 if (++next_read_ == field) return; | |
| 961 case kFlags: | |
| 962 flags_ = builder_->ReadFlags(); // read flags. | |
| 963 if (++next_read_ == field) return; | |
| 964 case kName: | |
| 965 builder_->SkipName(); // read name. | |
| 966 if (++next_read_ == field) return; | |
| 967 case kSourceUriIndex: | |
| 968 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | |
| 969 builder_->current_script_id_ = source_uri_index_; | |
| 970 builder_->record_token_position(position_); | |
| 971 builder_->record_token_position(end_position_); | |
| 972 if (++next_read_ == field) return; | |
| 973 case kDocumentationCommentIndex: | |
| 974 builder_->ReadStringReference(); | |
| 975 if (++next_read_ == field) return; | |
| 976 case kAnnotations: { | |
| 977 annotation_count_ = builder_->ReadListLength(); // read list length. | |
| 978 for (intptr_t i = 0; i < annotation_count_; ++i) { | |
| 979 builder_->SkipExpression(); // read ith expression. | |
| 980 } | |
| 981 if (++next_read_ == field) return; | |
| 982 } | |
| 983 case kType: | |
| 984 builder_->SkipDartType(); // read type. | |
| 985 if (++next_read_ == field) return; | |
| 986 case kInitializer: | |
| 987 if (builder_->ReadTag() == kSomething) { | |
| 988 if (detect_function_literal_initializer && | |
| 989 builder_->PeekTag() == kFunctionExpression) { | |
| 990 AlternativeReadingScope alt(builder_->reader_); | |
| 991 Tag tag = builder_->ReadTag(); | |
| 992 ASSERT(tag == kFunctionExpression); | |
| 993 builder_->ReadPosition(); // read position. | |
| 994 | 861 |
| 995 FunctionNodeHelper helper(builder_); | 862 bool IsConst() { |
| 996 helper.ReadUntilIncluding(FunctionNodeHelper::kEndPosition); | 863 return (flags_ & kernel::Field::kFlagConst) == kernel::Field::kFlagConst; |
| 997 | |
| 998 has_function_literal_initializer_ = true; | |
| 999 function_literal_start_ = helper.position_; | |
| 1000 function_literal_end_ = helper.end_position_; | |
| 1001 } | |
| 1002 builder_->SkipExpression(); // read initializer. | |
| 1003 } | |
| 1004 if (++next_read_ == field) return; | |
| 1005 case kEnd: | |
| 1006 return; | |
| 1007 } | |
| 1008 } | 864 } |
| 1009 | 865 bool IsFinal() { |
| 1010 void SetNext(Fields field) { next_read_ = field; } | 866 return (flags_ & kernel::Field::kFlagFinal) == kernel::Field::kFlagFinal; |
| 1011 void SetJustRead(Fields field) { | |
| 1012 next_read_ = field; | |
| 1013 ++next_read_; | |
| 1014 } | 867 } |
| 1015 | |
| 1016 bool IsConst() { return (flags_ & Field::kFlagConst) == Field::kFlagConst; } | |
| 1017 bool IsFinal() { return (flags_ & Field::kFlagFinal) == Field::kFlagFinal; } | |
| 1018 bool IsStatic() { | 868 bool IsStatic() { |
| 1019 return (flags_ & Field::kFlagStatic) == Field::kFlagStatic; | 869 return (flags_ & kernel::Field::kFlagStatic) == kernel::Field::kFlagStatic; |
| 1020 } | 870 } |
| 1021 | 871 |
| 1022 bool FieldHasFunctionLiteralInitializer(TokenPosition* start, | 872 bool FieldHasFunctionLiteralInitializer(TokenPosition* start, |
| 1023 TokenPosition* end) { | 873 TokenPosition* end) { |
| 1024 if (has_function_literal_initializer_) { | 874 if (has_function_literal_initializer_) { |
| 1025 *start = function_literal_start_; | 875 *start = function_literal_start_; |
| 1026 *end = function_literal_end_; | 876 *end = function_literal_end_; |
| 1027 } | 877 } |
| 1028 return has_function_literal_initializer_; | 878 return has_function_literal_initializer_; |
| 1029 } | 879 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1042 bool has_function_literal_initializer_; | 892 bool has_function_literal_initializer_; |
| 1043 TokenPosition function_literal_start_; | 893 TokenPosition function_literal_start_; |
| 1044 TokenPosition function_literal_end_; | 894 TokenPosition function_literal_end_; |
| 1045 }; | 895 }; |
| 1046 | 896 |
| 1047 // Helper class that reads a kernel Procedure from binary. | 897 // Helper class that reads a kernel Procedure from binary. |
| 1048 // | 898 // |
| 1049 // Use ReadUntilExcluding to read up to but not including a field. | 899 // Use ReadUntilExcluding to read up to but not including a field. |
| 1050 // One can then for instance read the field from the call-site (and remember to | 900 // One can then for instance read the field from the call-site (and remember to |
| 1051 // call SetAt to inform this helper class), and then use this to read more. | 901 // call SetAt to inform this helper class), and then use this to read more. |
| 1052 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 902 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 1053 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 903 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 1054 class ProcedureHelper { | 904 class ProcedureHelper { |
| 1055 public: | 905 public: |
| 1056 enum Fields { | 906 enum Field { |
| 1057 kStart, // tag. | 907 kStart, // tag. |
| 1058 kCanonicalName, | 908 kCanonicalName, |
| 1059 kPosition, | 909 kPosition, |
| 1060 kEndPosition, | 910 kEndPosition, |
| 1061 kKind, | 911 kKind, |
| 1062 kFlags, | 912 kFlags, |
| 1063 kName, | 913 kName, |
| 1064 kSourceUriIndex, | 914 kSourceUriIndex, |
| 1065 kDocumentationCommentIndex, | 915 kDocumentationCommentIndex, |
| 1066 kAnnotations, | 916 kAnnotations, |
| 1067 kFunction, | 917 kFunction, |
| 1068 kEnd | 918 kEnd |
| 1069 }; | 919 }; |
| 1070 | 920 |
| 1071 explicit ProcedureHelper(StreamingFlowGraphBuilder* builder) { | 921 explicit ProcedureHelper(StreamingFlowGraphBuilder* builder) { |
| 1072 builder_ = builder; | 922 builder_ = builder; |
| 1073 next_read_ = kStart; | 923 next_read_ = kStart; |
| 1074 } | 924 } |
| 1075 | 925 |
| 1076 void ReadUntilIncluding(Fields field) { | 926 void ReadUntilIncluding(Field field) { |
| 1077 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 927 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 1078 } | 928 } |
| 1079 | 929 |
| 1080 void ReadUntilExcluding(Fields field) { | 930 void ReadUntilExcluding(Field field); |
| 1081 if (field <= next_read_) return; | |
| 1082 | 931 |
| 1083 // Ordered with fall-through. | 932 void SetNext(Field field) { next_read_ = field; } |
| 1084 switch (next_read_) { | 933 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 1085 case kStart: { | |
| 1086 Tag tag = builder_->ReadTag(); // read tag. | |
| 1087 ASSERT(tag == kProcedure); | |
| 1088 if (++next_read_ == field) return; | |
| 1089 } | |
| 1090 case kCanonicalName: | |
| 1091 canonical_name_ = | |
| 1092 builder_->ReadCanonicalNameReference(); // read canonical_name. | |
| 1093 if (++next_read_ == field) return; | |
| 1094 case kPosition: | |
| 1095 position_ = builder_->ReadPosition(false); // read position. | |
| 1096 if (++next_read_ == field) return; | |
| 1097 case kEndPosition: | |
| 1098 end_position_ = builder_->ReadPosition(false); // read end position. | |
| 1099 if (++next_read_ == field) return; | |
| 1100 case kKind: | |
| 1101 kind_ = static_cast<Procedure::ProcedureKind>( | |
| 1102 builder_->ReadByte()); // read kind. | |
| 1103 if (++next_read_ == field) return; | |
| 1104 case kFlags: | |
| 1105 flags_ = builder_->ReadFlags(); // read flags. | |
| 1106 if (++next_read_ == field) return; | |
| 1107 case kName: | |
| 1108 builder_->SkipName(); // read name. | |
| 1109 if (++next_read_ == field) return; | |
| 1110 case kSourceUriIndex: | |
| 1111 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | |
| 1112 builder_->current_script_id_ = source_uri_index_; | |
| 1113 builder_->record_token_position(position_); | |
| 1114 builder_->record_token_position(end_position_); | |
| 1115 if (++next_read_ == field) return; | |
| 1116 case kDocumentationCommentIndex: | |
| 1117 builder_->ReadStringReference(); | |
| 1118 if (++next_read_ == field) return; | |
| 1119 case kAnnotations: { | |
| 1120 annotation_count_ = builder_->ReadListLength(); // read list length. | |
| 1121 for (intptr_t i = 0; i < annotation_count_; ++i) { | |
| 1122 builder_->SkipExpression(); // read ith expression. | |
| 1123 } | |
| 1124 if (++next_read_ == field) return; | |
| 1125 } | |
| 1126 case kFunction: | |
| 1127 if (builder_->ReadTag() == kSomething) | |
| 1128 builder_->SkipFunctionNode(); // read function node. | |
| 1129 if (++next_read_ == field) return; | |
| 1130 case kEnd: | |
| 1131 return; | |
| 1132 } | |
| 1133 } | |
| 1134 | |
| 1135 void SetNext(Fields field) { next_read_ = field; } | |
| 1136 void SetJustRead(Fields field) { | |
| 1137 next_read_ = field; | |
| 1138 ++next_read_; | |
| 1139 } | |
| 1140 | 934 |
| 1141 bool IsStatic() { | 935 bool IsStatic() { |
| 1142 return (flags_ & Procedure::kFlagStatic) == Procedure::kFlagStatic; | 936 return (flags_ & Procedure::kFlagStatic) == Procedure::kFlagStatic; |
| 1143 } | 937 } |
| 1144 bool IsAbstract() { | 938 bool IsAbstract() { |
| 1145 return (flags_ & Procedure::kFlagAbstract) == Procedure::kFlagAbstract; | 939 return (flags_ & Procedure::kFlagAbstract) == Procedure::kFlagAbstract; |
| 1146 } | 940 } |
| 1147 bool IsExternal() { | 941 bool IsExternal() { |
| 1148 return (flags_ & Procedure::kFlagExternal) == Procedure::kFlagExternal; | 942 return (flags_ & Procedure::kFlagExternal) == Procedure::kFlagExternal; |
| 1149 } | 943 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1162 private: | 956 private: |
| 1163 StreamingFlowGraphBuilder* builder_; | 957 StreamingFlowGraphBuilder* builder_; |
| 1164 intptr_t next_read_; | 958 intptr_t next_read_; |
| 1165 }; | 959 }; |
| 1166 | 960 |
| 1167 // Helper class that reads a kernel Constructor from binary. | 961 // Helper class that reads a kernel Constructor from binary. |
| 1168 // | 962 // |
| 1169 // Use ReadUntilExcluding to read up to but not including a field. | 963 // Use ReadUntilExcluding to read up to but not including a field. |
| 1170 // One can then for instance read the field from the call-site (and remember to | 964 // One can then for instance read the field from the call-site (and remember to |
| 1171 // call SetAt to inform this helper class), and then use this to read more. | 965 // call SetAt to inform this helper class), and then use this to read more. |
| 1172 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 966 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 1173 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 967 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 1174 class ConstructorHelper { | 968 class ConstructorHelper { |
| 1175 public: | 969 public: |
| 1176 enum Fields { | 970 enum Field { |
| 1177 kStart, // tag. | 971 kStart, // tag. |
| 1178 kCanonicalName, | 972 kCanonicalName, |
| 1179 kPosition, | 973 kPosition, |
| 1180 kEndPosition, | 974 kEndPosition, |
| 1181 kFlags, | 975 kFlags, |
| 1182 kName, | 976 kName, |
| 1183 kDocumentationCommentIndex, | 977 kDocumentationCommentIndex, |
| 1184 kAnnotations, | 978 kAnnotations, |
| 1185 kFunction, | 979 kFunction, |
| 1186 kInitializers, | 980 kInitializers, |
| 1187 kEnd | 981 kEnd |
| 1188 }; | 982 }; |
| 1189 | 983 |
| 1190 explicit ConstructorHelper(StreamingFlowGraphBuilder* builder) { | 984 explicit ConstructorHelper(StreamingFlowGraphBuilder* builder) { |
| 1191 builder_ = builder; | 985 builder_ = builder; |
| 1192 next_read_ = kStart; | 986 next_read_ = kStart; |
| 1193 } | 987 } |
| 1194 | 988 |
| 1195 void ReadUntilIncluding(Fields field) { | 989 void ReadUntilIncluding(Field field) { |
| 1196 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 990 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 1197 } | 991 } |
| 1198 | 992 |
| 1199 void ReadUntilExcluding(Fields field) { | 993 void ReadUntilExcluding(Field field); |
| 1200 if (field <= next_read_) return; | |
| 1201 | 994 |
| 1202 // Ordered with fall-through. | 995 void SetNext(Field field) { next_read_ = field; } |
| 1203 switch (next_read_) { | 996 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 1204 case kStart: { | |
| 1205 Tag tag = builder_->ReadTag(); // read tag. | |
| 1206 ASSERT(tag == kConstructor); | |
| 1207 if (++next_read_ == field) return; | |
| 1208 } | |
| 1209 case kCanonicalName: | |
| 1210 canonical_name_ = | |
| 1211 builder_->ReadCanonicalNameReference(); // read canonical_name. | |
| 1212 if (++next_read_ == field) return; | |
| 1213 case kPosition: | |
| 1214 position_ = builder_->ReadPosition(); // read position. | |
| 1215 if (++next_read_ == field) return; | |
| 1216 case kEndPosition: | |
| 1217 end_position_ = builder_->ReadPosition(); // read end position. | |
| 1218 if (++next_read_ == field) return; | |
| 1219 case kFlags: | |
| 1220 flags_ = builder_->ReadFlags(); // read flags. | |
| 1221 if (++next_read_ == field) return; | |
| 1222 case kName: | |
| 1223 builder_->SkipName(); // read name. | |
| 1224 if (++next_read_ == field) return; | |
| 1225 case kDocumentationCommentIndex: | |
| 1226 builder_->ReadStringReference(); | |
| 1227 if (++next_read_ == field) return; | |
| 1228 case kAnnotations: { | |
| 1229 annotation_count_ = builder_->ReadListLength(); // read list length. | |
| 1230 for (intptr_t i = 0; i < annotation_count_; ++i) { | |
| 1231 builder_->SkipExpression(); // read ith expression. | |
| 1232 } | |
| 1233 if (++next_read_ == field) return; | |
| 1234 } | |
| 1235 case kFunction: | |
| 1236 builder_->SkipFunctionNode(); // read function. | |
| 1237 if (++next_read_ == field) return; | |
| 1238 case kInitializers: { | |
| 1239 intptr_t list_length = | |
| 1240 builder_->ReadListLength(); // read initializers list length. | |
| 1241 for (intptr_t i = 0; i < list_length; i++) { | |
| 1242 Tag tag = builder_->ReadTag(); | |
| 1243 builder_->ReadByte(); // read isSynthetic. | |
| 1244 switch (tag) { | |
| 1245 case kInvalidInitializer: | |
| 1246 continue; | |
| 1247 case kFieldInitializer: | |
| 1248 builder_->SkipCanonicalNameReference(); // read field_reference. | |
| 1249 builder_->SkipExpression(); // read value. | |
| 1250 continue; | |
| 1251 case kSuperInitializer: | |
| 1252 builder_->SkipCanonicalNameReference(); // read target_reference. | |
| 1253 builder_->SkipArguments(); // read arguments. | |
| 1254 continue; | |
| 1255 case kRedirectingInitializer: | |
| 1256 builder_->SkipCanonicalNameReference(); // read target_reference. | |
| 1257 builder_->SkipArguments(); // read arguments. | |
| 1258 continue; | |
| 1259 case kLocalInitializer: | |
| 1260 builder_->SkipVariableDeclaration(); // read variable. | |
| 1261 continue; | |
| 1262 default: | |
| 1263 UNREACHABLE(); | |
| 1264 } | |
| 1265 } | |
| 1266 if (++next_read_ == field) return; | |
| 1267 } | |
| 1268 case kEnd: | |
| 1269 return; | |
| 1270 } | |
| 1271 } | |
| 1272 | |
| 1273 void SetNext(Fields field) { next_read_ = field; } | |
| 1274 void SetJustRead(Fields field) { | |
| 1275 next_read_ = field; | |
| 1276 ++next_read_; | |
| 1277 } | |
| 1278 | 997 |
| 1279 bool IsExternal() { | 998 bool IsExternal() { |
| 1280 return (flags_ & Constructor::kFlagExternal) == Constructor::kFlagExternal; | 999 return (flags_ & Constructor::kFlagExternal) == Constructor::kFlagExternal; |
| 1281 } | 1000 } |
| 1282 bool IsConst() { | 1001 bool IsConst() { |
| 1283 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst; | 1002 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst; |
| 1284 } | 1003 } |
| 1285 | 1004 |
| 1286 NameIndex canonical_name_; | 1005 NameIndex canonical_name_; |
| 1287 TokenPosition position_; | 1006 TokenPosition position_; |
| 1288 TokenPosition end_position_; | 1007 TokenPosition end_position_; |
| 1289 word flags_; | 1008 word flags_; |
| 1290 intptr_t annotation_count_; | 1009 intptr_t annotation_count_; |
| 1291 | 1010 |
| 1292 private: | 1011 private: |
| 1293 StreamingFlowGraphBuilder* builder_; | 1012 StreamingFlowGraphBuilder* builder_; |
| 1294 intptr_t next_read_; | 1013 intptr_t next_read_; |
| 1295 }; | 1014 }; |
| 1296 | 1015 |
| 1297 // Helper class that reads a kernel Class from binary. | 1016 // Helper class that reads a kernel Class from binary. |
| 1298 // | 1017 // |
| 1299 // Use ReadUntilExcluding to read up to but not including a field. | 1018 // Use ReadUntilExcluding to read up to but not including a field. |
| 1300 // One can then for instance read the field from the call-site (and remember to | 1019 // One can then for instance read the field from the call-site (and remember to |
| 1301 // call SetAt to inform this helper class), and then use this to read more. | 1020 // call SetAt to inform this helper class), and then use this to read more. |
| 1302 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 1021 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 1303 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 1022 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 1304 class ClassHelper { | 1023 class ClassHelper { |
| 1305 public: | 1024 public: |
| 1306 enum Fields { | 1025 enum Field { |
| 1307 kStart, // tag. | 1026 kStart, // tag. |
| 1308 kCanonicalName, | 1027 kCanonicalName, |
| 1309 kPosition, | 1028 kPosition, |
| 1310 kEndPosition, | 1029 kEndPosition, |
| 1311 kIsAbstract, | 1030 kIsAbstract, |
| 1312 kNameIndex, | 1031 kNameIndex, |
| 1313 kSourceUriIndex, | 1032 kSourceUriIndex, |
| 1314 kDocumentationCommentIndex, | 1033 kDocumentationCommentIndex, |
| 1315 kAnnotations, | 1034 kAnnotations, |
| 1316 kTypeParameters, | 1035 kTypeParameters, |
| 1317 kSuperClass, | 1036 kSuperClass, |
| 1318 kMixinType, | 1037 kMixinType, |
| 1319 kImplementedClasses, | 1038 kImplementedClasses, |
| 1320 kFields, | 1039 kFields, |
| 1321 kConstructors, | 1040 kConstructors, |
| 1322 kProcedures, | 1041 kProcedures, |
| 1323 kEnd | 1042 kEnd |
| 1324 }; | 1043 }; |
| 1325 | 1044 |
| 1326 explicit ClassHelper(StreamingFlowGraphBuilder* builder) { | 1045 explicit ClassHelper(StreamingFlowGraphBuilder* builder) { |
| 1327 builder_ = builder; | 1046 builder_ = builder; |
| 1328 next_read_ = kStart; | 1047 next_read_ = kStart; |
| 1329 } | 1048 } |
| 1330 | 1049 |
| 1331 void ReadUntilIncluding(Fields field) { | 1050 void ReadUntilIncluding(Field field) { |
| 1332 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 1051 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 1333 } | 1052 } |
| 1334 | 1053 |
| 1335 void ReadUntilExcluding(Fields field) { | 1054 void ReadUntilExcluding(Field field); |
| 1336 if (field <= next_read_) return; | |
| 1337 | 1055 |
| 1338 // Ordered with fall-through. | 1056 void SetNext(Field field) { next_read_ = field; } |
| 1339 switch (next_read_) { | 1057 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 1340 case kStart: { | |
| 1341 Tag tag = builder_->ReadTag(); // read tag. | |
| 1342 ASSERT(tag == kClass); | |
| 1343 if (++next_read_ == field) return; | |
| 1344 } | |
| 1345 case kCanonicalName: | |
| 1346 canonical_name_ = | |
| 1347 builder_->ReadCanonicalNameReference(); // read canonical_name. | |
| 1348 if (++next_read_ == field) return; | |
| 1349 case kPosition: | |
| 1350 position_ = builder_->ReadPosition(false); // read position. | |
| 1351 if (++next_read_ == field) return; | |
| 1352 case kEndPosition: | |
| 1353 end_position_ = builder_->ReadPosition(); // read end position. | |
| 1354 if (++next_read_ == field) return; | |
| 1355 case kIsAbstract: | |
| 1356 is_abstract_ = builder_->ReadBool(); // read is_abstract. | |
| 1357 if (++next_read_ == field) return; | |
| 1358 case kNameIndex: | |
| 1359 name_index_ = builder_->ReadStringReference(); // read name index. | |
| 1360 if (++next_read_ == field) return; | |
| 1361 case kSourceUriIndex: | |
| 1362 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | |
| 1363 builder_->current_script_id_ = source_uri_index_; | |
| 1364 builder_->record_token_position(position_); | |
| 1365 if (++next_read_ == field) return; | |
| 1366 case kDocumentationCommentIndex: | |
| 1367 builder_->ReadStringReference(); | |
| 1368 if (++next_read_ == field) return; | |
| 1369 case kAnnotations: { | |
| 1370 annotation_count_ = builder_->ReadListLength(); // read list length. | |
| 1371 for (intptr_t i = 0; i < annotation_count_; ++i) { | |
| 1372 builder_->SkipExpression(); // read ith expression. | |
| 1373 } | |
| 1374 if (++next_read_ == field) return; | |
| 1375 } | |
| 1376 case kTypeParameters: | |
| 1377 builder_->SkipTypeParametersList(); // read type parameters. | |
| 1378 if (++next_read_ == field) return; | |
| 1379 case kSuperClass: { | |
| 1380 Tag type_tag = builder_->ReadTag(); // read super class type (part 1). | |
| 1381 if (type_tag == kSomething) { | |
| 1382 builder_->SkipDartType(); // read super class type (part 2). | |
| 1383 } | |
| 1384 if (++next_read_ == field) return; | |
| 1385 } | |
| 1386 case kMixinType: { | |
| 1387 Tag type_tag = builder_->ReadTag(); // read mixin type (part 1). | |
| 1388 if (type_tag == kSomething) { | |
| 1389 builder_->SkipDartType(); // read mixin type (part 2). | |
| 1390 } | |
| 1391 if (++next_read_ == field) return; | |
| 1392 } | |
| 1393 case kImplementedClasses: | |
| 1394 builder_->SkipListOfDartTypes(); // read implemented_classes. | |
| 1395 if (++next_read_ == field) return; | |
| 1396 case kFields: { | |
| 1397 intptr_t list_length = | |
| 1398 builder_->ReadListLength(); // read fields list length. | |
| 1399 for (intptr_t i = 0; i < list_length; i++) { | |
| 1400 FieldHelper field_helper(builder_); | |
| 1401 field_helper.ReadUntilExcluding(FieldHelper::kEnd); // read field. | |
| 1402 } | |
| 1403 if (++next_read_ == field) return; | |
| 1404 } | |
| 1405 case kConstructors: { | |
| 1406 intptr_t list_length = | |
| 1407 builder_->ReadListLength(); // read constructors list length. | |
| 1408 for (intptr_t i = 0; i < list_length; i++) { | |
| 1409 ConstructorHelper constructor_helper(builder_); | |
| 1410 constructor_helper.ReadUntilExcluding( | |
| 1411 ConstructorHelper::kEnd); // read constructor. | |
| 1412 } | |
| 1413 if (++next_read_ == field) return; | |
| 1414 } | |
| 1415 case kProcedures: { | |
| 1416 intptr_t list_length = | |
| 1417 builder_->ReadListLength(); // read procedures list length. | |
| 1418 for (intptr_t i = 0; i < list_length; i++) { | |
| 1419 ProcedureHelper procedure_helper(builder_); | |
| 1420 procedure_helper.ReadUntilExcluding( | |
| 1421 ProcedureHelper::kEnd); // read procedure. | |
| 1422 } | |
| 1423 if (++next_read_ == field) return; | |
| 1424 } | |
| 1425 case kEnd: | |
| 1426 return; | |
| 1427 } | |
| 1428 } | |
| 1429 | |
| 1430 void SetNext(Fields field) { next_read_ = field; } | |
| 1431 void SetJustRead(Fields field) { | |
| 1432 next_read_ = field; | |
| 1433 ++next_read_; | |
| 1434 } | |
| 1435 | 1058 |
| 1436 NameIndex canonical_name_; | 1059 NameIndex canonical_name_; |
| 1437 TokenPosition position_; | 1060 TokenPosition position_; |
| 1438 TokenPosition end_position_; | 1061 TokenPosition end_position_; |
| 1439 bool is_abstract_; | 1062 bool is_abstract_; |
| 1440 StringIndex name_index_; | 1063 StringIndex name_index_; |
| 1441 intptr_t source_uri_index_; | 1064 intptr_t source_uri_index_; |
| 1442 intptr_t annotation_count_; | 1065 intptr_t annotation_count_; |
| 1443 | 1066 |
| 1444 private: | 1067 private: |
| 1445 StreamingFlowGraphBuilder* builder_; | 1068 StreamingFlowGraphBuilder* builder_; |
| 1446 intptr_t next_read_; | 1069 intptr_t next_read_; |
| 1447 }; | 1070 }; |
| 1448 | 1071 |
| 1449 // Helper class that reads a kernel Library from binary. | 1072 // Helper class that reads a kernel Library from binary. |
| 1450 // | 1073 // |
| 1451 // Use ReadUntilExcluding to read up to but not including a field. | 1074 // Use ReadUntilExcluding to read up to but not including a field. |
| 1452 // One can then for instance read the field from the call-site (and remember to | 1075 // One can then for instance read the field from the call-site (and remember to |
| 1453 // call SetAt to inform this helper class), and then use this to read more. | 1076 // call SetAt to inform this helper class), and then use this to read more. |
| 1454 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. | 1077 // Simple fields are stored (e.g. integers) and can be fetched from this class. |
| 1455 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. | 1078 // If asked to read a compound field (e.g. an expression) it will be skipped. |
| 1456 class LibraryHelper { | 1079 class LibraryHelper { |
| 1457 public: | 1080 public: |
| 1458 enum Fields { | 1081 enum Field { |
| 1459 kFlags, | 1082 kFlags, |
| 1460 kCanonicalName, | 1083 kCanonicalName, |
| 1461 kName, | 1084 kName, |
| 1462 kSourceUriIndex, | 1085 kSourceUriIndex, |
| 1463 kAnnotations, | 1086 kAnnotations, |
| 1464 kDependencies, | 1087 kDependencies, |
| 1465 kParts, | 1088 kParts, |
| 1466 kTypedefs, | 1089 kTypedefs, |
| 1467 kClasses, | 1090 kClasses, |
| 1468 kToplevelField, | 1091 kToplevelField, |
| 1469 kToplevelProcedures, | 1092 kToplevelProcedures, |
| 1470 kEnd | 1093 kEnd |
| 1471 }; | 1094 }; |
| 1472 | 1095 |
| 1473 explicit LibraryHelper(StreamingFlowGraphBuilder* builder) { | 1096 explicit LibraryHelper(StreamingFlowGraphBuilder* builder) { |
| 1474 builder_ = builder; | 1097 builder_ = builder; |
| 1475 next_read_ = kFlags; | 1098 next_read_ = kFlags; |
| 1476 } | 1099 } |
| 1477 | 1100 |
| 1478 void ReadUntilIncluding(Fields field) { | 1101 void ReadUntilIncluding(Field field) { |
| 1479 ReadUntilExcluding(static_cast<Fields>(static_cast<int>(field) + 1)); | 1102 ReadUntilExcluding(static_cast<Field>(static_cast<int>(field) + 1)); |
| 1480 } | 1103 } |
| 1481 | 1104 |
| 1482 void ReadUntilExcluding(Fields field) { | 1105 void ReadUntilExcluding(Field field); |
| 1483 if (field <= next_read_) return; | |
| 1484 | 1106 |
| 1485 // Ordered with fall-through. | 1107 void SetNext(Field field) { next_read_ = field; } |
| 1486 switch (next_read_) { | 1108 void SetJustRead(Field field) { next_read_ = field + 1; } |
| 1487 case kFlags: { | |
| 1488 word flags = builder_->ReadFlags(); // read flags. | |
| 1489 ASSERT(flags == 0); // external libraries not supported | |
| 1490 if (++next_read_ == field) return; | |
| 1491 } | |
| 1492 case kCanonicalName: | |
| 1493 canonical_name_ = | |
| 1494 builder_->ReadCanonicalNameReference(); // read canonical_name. | |
| 1495 if (++next_read_ == field) return; | |
| 1496 case kName: | |
| 1497 name_index_ = builder_->ReadStringReference(); // read name index. | |
| 1498 if (++next_read_ == field) return; | |
| 1499 case kSourceUriIndex: | |
| 1500 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | |
| 1501 builder_->current_script_id_ = source_uri_index_; | |
| 1502 if (++next_read_ == field) return; | |
| 1503 case kAnnotations: | |
| 1504 builder_->SkipListOfExpressions(); // read annotations. | |
| 1505 if (++next_read_ == field) return; | |
| 1506 case kDependencies: { | |
| 1507 intptr_t dependency_count = builder_->ReadUInt(); // read list length. | |
| 1508 for (intptr_t i = 0; i < dependency_count; ++i) { | |
| 1509 builder_->SkipLibraryDependency(); | |
| 1510 } | |
| 1511 if (++next_read_ == field) return; | |
| 1512 } | |
| 1513 case kParts: { | |
| 1514 intptr_t part_count = builder_->ReadUInt(); // read list length. | |
| 1515 for (intptr_t i = 0; i < part_count; ++i) { | |
| 1516 builder_->SkipLibraryPart(); | |
| 1517 } | |
| 1518 if (++next_read_ == field) return; | |
| 1519 } | |
| 1520 case kTypedefs: { | |
| 1521 intptr_t typedef_count = | |
| 1522 builder_->ReadListLength(); // read list length. | |
| 1523 for (intptr_t i = 0; i < typedef_count; i++) { | |
| 1524 builder_->SkipLibraryTypedef(); | |
| 1525 } | |
| 1526 if (++next_read_ == field) return; | |
| 1527 } | |
| 1528 case kClasses: { | |
| 1529 int class_count = builder_->ReadListLength(); // read list length. | |
| 1530 for (intptr_t i = 0; i < class_count; ++i) { | |
| 1531 ClassHelper class_helper(builder_); | |
| 1532 class_helper.ReadUntilExcluding(ClassHelper::kEnd); | |
| 1533 } | |
| 1534 if (++next_read_ == field) return; | |
| 1535 } | |
| 1536 case kToplevelField: { | |
| 1537 intptr_t field_count = builder_->ReadListLength(); // read list length. | |
| 1538 for (intptr_t i = 0; i < field_count; ++i) { | |
| 1539 FieldHelper field_helper(builder_); | |
| 1540 field_helper.ReadUntilExcluding(FieldHelper::kEnd); | |
| 1541 } | |
| 1542 if (++next_read_ == field) return; | |
| 1543 } | |
| 1544 case kToplevelProcedures: { | |
| 1545 intptr_t procedure_count = | |
| 1546 builder_->ReadListLength(); // read list length. | |
| 1547 for (intptr_t i = 0; i < procedure_count; ++i) { | |
| 1548 ProcedureHelper procedure_helper(builder_); | |
| 1549 procedure_helper.ReadUntilExcluding(ProcedureHelper::kEnd); | |
| 1550 } | |
| 1551 if (++next_read_ == field) return; | |
| 1552 } | |
| 1553 case kEnd: | |
| 1554 return; | |
| 1555 } | |
| 1556 } | |
| 1557 | |
| 1558 void SetNext(Fields field) { next_read_ = field; } | |
| 1559 void SetJustRead(Fields field) { | |
| 1560 next_read_ = field; | |
| 1561 ++next_read_; | |
| 1562 } | |
| 1563 | 1109 |
| 1564 NameIndex canonical_name_; | 1110 NameIndex canonical_name_; |
| 1565 StringIndex name_index_; | 1111 StringIndex name_index_; |
| 1566 intptr_t source_uri_index_; | 1112 intptr_t source_uri_index_; |
| 1567 | 1113 |
| 1568 private: | 1114 private: |
| 1569 StreamingFlowGraphBuilder* builder_; | 1115 StreamingFlowGraphBuilder* builder_; |
| 1570 intptr_t next_read_; | 1116 intptr_t next_read_; |
| 1571 }; | 1117 }; |
| 1572 | 1118 |
| 1573 } // namespace kernel | 1119 } // namespace kernel |
| 1574 } // namespace dart | 1120 } // namespace dart |
| 1575 | 1121 |
| 1576 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1122 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1577 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 1123 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
| OLD | NEW |