@@ -563,6 +563,8 @@ class BinaryBuilder {
563563 }
564564
565565 /// Deserializes the source and stores it in [component] .
566+ /// Note that the _coverage_ normally included in the source in the
567+ /// uri-to-source mapping is _not_ included.
566568 ///
567569 /// The input bytes may contain multiple files concatenated.
568570 void readComponentSource (Component component) {
@@ -724,7 +726,7 @@ class BinaryBuilder {
724726 _ComponentIndex index = _readComponentIndex (componentFileSize);
725727
726728 _byteOffset = index.binaryOffsetForSourceTable;
727- Map <Uri , Source > uriToSource = readUriToSource ();
729+ Map <Uri , Source > uriToSource = readUriToSource (/* readCoverage = */ false );
728730 _mergeUriToSource (component.uriToSource, uriToSource);
729731
730732 _byteOffset = _componentStartOffset + componentFileSize;
@@ -773,7 +775,7 @@ class BinaryBuilder {
773775 _associateMetadata (component, _componentStartOffset);
774776
775777 _byteOffset = index.binaryOffsetForSourceTable;
776- Map <Uri , Source > uriToSource = readUriToSource ();
778+ Map <Uri , Source > uriToSource = readUriToSource (/* readCoverage = */ true );
777779 _mergeUriToSource (component.uriToSource, uriToSource);
778780
779781 _byteOffset = index.binaryOffsetForConstantTable;
@@ -821,7 +823,14 @@ class BinaryBuilder {
821823 return strings;
822824 }
823825
824- Map <Uri , Source > readUriToSource () {
826+ /// Read the uri-to-source part of the binary.
827+ /// Note that this can include coverage, but that it is only included if
828+ /// [readCoverage] is true, otherwise coverage will be skipped. Note also that
829+ /// if [readCoverage] is true, references are read and that the link table
830+ /// thus has to be read first.
831+ Map <Uri , Source > readUriToSource (bool readCoverage) {
832+ assert (! readCoverage || (readCoverage && _linkTable != null ));
833+
825834 int length = readUint32 ();
826835
827836 // Read data.
@@ -847,10 +856,16 @@ class BinaryBuilder {
847856 Set <Reference > coverageConstructors;
848857 {
849858 int constructorCoverageCount = readUInt30 ();
850- coverageConstructors =
851- constructorCoverageCount == 0 ? null : new Set <Reference >();
852- for (int j = 0 ; j < constructorCoverageCount; ++ j) {
853- coverageConstructors.add (readMemberReference ());
859+ if (readCoverage) {
860+ coverageConstructors =
861+ constructorCoverageCount == 0 ? null : new Set <Reference >();
862+ for (int j = 0 ; j < constructorCoverageCount; ++ j) {
863+ coverageConstructors.add (readMemberReference ());
864+ }
865+ } else {
866+ for (int j = 0 ; j < constructorCoverageCount; ++ j) {
867+ skipMemberReference ();
868+ }
854869 }
855870 }
856871
@@ -906,6 +921,10 @@ class BinaryBuilder {
906921 }
907922 }
908923
924+ void skipCanonicalNameReference () {
925+ readUInt30 ();
926+ }
927+
909928 CanonicalName readCanonicalNameReference () {
910929 int index = readUInt30 ();
911930 if (index == 0 ) return null ;
@@ -937,6 +956,10 @@ class BinaryBuilder {
937956 return name? .getReference ();
938957 }
939958
959+ void skipMemberReference () {
960+ skipCanonicalNameReference ();
961+ }
962+
940963 Reference readMemberReference ({bool allowNull: false }) {
941964 CanonicalName name = readCanonicalNameReference ();
942965 if (name == null && ! allowNull) {
0 commit comments