in src/SourcemapToolkit.SourcemapParser/MappingListParser.cs [142:196]
internal NumericMappingEntry ParseSingleMappingSegment(IReadOnlyList<int> segmentFields, MappingsParserState mappingsParserState)
{
if (segmentFields == null)
{
throw new ArgumentNullException(nameof(segmentFields));
}
if (segmentFields.Count == 0 || segmentFields.Count == 2 || segmentFields.Count == 3)
{
throw new ArgumentOutOfRangeException(nameof(segmentFields));
}
NumericMappingEntry numericMappingEntry = new NumericMappingEntry()
{
GeneratedLineNumber = mappingsParserState.CurrentGeneratedLineNumber,
GeneratedColumnNumber = mappingsParserState.CurrentGeneratedColumnBase + segmentFields[0]
};
/*
* The following description was taken from the Sourcemap V3 spec https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/mobilebasic?pref=2&pli=1
* The Sourcemap V3 spec is under a Creative Commons Attribution-ShareAlike 3.0 Unported License. https://creativecommons.org/licenses/by-sa/3.0/
*
* Each VLQ segment has 1, 4, or 5 variable length fields.
* The fields in each segment are:
* 1. The zero-based starting column of the line in the generated code that the segment represents.
* If this is the first field of the first segment, or the first segment following a new generated line(“;”),
* then this field holds the whole base 64 VLQ.Otherwise, this field contains a base 64 VLQ that is relative to
* the previous occurrence of this field.Note that this is different than the fields below because the previous
* value is reset after every generated line.
* 2. If present, an zero - based index into the “sources” list.This field is a base 64 VLQ relative to the previous
* occurrence of this field, unless this is the first occurrence of this field, in which case the whole value is represented.
* 3. If present, the zero-based starting line in the original source represented. This field is a base 64 VLQ relative to the
* previous occurrence of this field, unless this is the first occurrence of this field, in which case the whole value is
* represented.Always present if there is a source field.
* 4. If present, the zero - based starting column of the line in the source represented.This field is a base 64 VLQ relative to
* the previous occurrence of this field, unless this is the first occurrence of this field, in which case the whole value is
* represented.Always present if there is a source field.
* 5. If present, the zero - based index into the “names” list associated with this segment.This field is a base 64 VLQ relative
* to the previous occurrence of this field, unless this is the first occurrence of this field, in which case the whole value
* is represented.
*/
if (segmentFields.Count > 1)
{
numericMappingEntry.OriginalSourceFileIndex = mappingsParserState.SourcesListIndexBase + segmentFields[1];
numericMappingEntry.OriginalLineNumber = mappingsParserState.OriginalSourceStartingLineBase + segmentFields[2];
numericMappingEntry.OriginalColumnNumber = mappingsParserState.OriginalSourceStartingColumnBase + segmentFields[3];
}
if (segmentFields.Count >= 5)
{
numericMappingEntry.OriginalNameIndex = mappingsParserState.NamesListIndexBase + segmentFields[4];
}
return numericMappingEntry;
}