MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / sequencePoints

Function sequencePoints

test/dotnet-parser-tests.ts:274–305  ·  view source on GitHub ↗
(points: Array<{offset: number; line: number | null; column?: number}>)

Source from the content-addressed store, hash-verified

272}
273
274function sequencePoints(points: Array<{offset: number; line: number | null; column?: number}>) {
275 // Emit a Portable PDB sequence-points blob.
276 const chunks = [compressedUInt(0)]; // The local-signature token
277 let previousOffset = 0;
278 let previousLine = 0;
279 let previousColumn = 0;
280 let hasPrevious = false;
281
282 for (const point of points) {
283 chunks.push(compressedUInt(hasPrevious ? point.offset - previousOffset : point.offset));
284 if (point.line === null) {
285 // Hidden sequence point: delta lines and delta columns are both zero, and no source span follows.
286 chunks.push(compressedUInt(0), compressedUInt(0));
287 } else {
288 // Visible points in this fixture are one-column spans on a single source line.
289 chunks.push(compressedUInt(0), compressedUInt(1));
290 if (hasPrevious) {
291 chunks.push(compressedSignedInt(point.line - previousLine));
292 chunks.push(compressedSignedInt((point.column ?? 1) - previousColumn));
293 } else {
294 chunks.push(compressedUInt(point.line), compressedUInt(point.column ?? 1));
295 }
296 previousLine = point.line;
297 previousColumn = point.column ?? 1;
298 }
299
300 previousOffset = point.offset;
301 hasPrevious = true;
302 }
303
304 return Buffer.concat(chunks);
305}
306
307function ecma335Fixture() {
308 // Build a tiny ECMA-335 metadata root plus matching portable-PDB metadata.

Callers 1

ecma335FixtureFunction · 0.85

Calls 3

compressedUIntFunction · 0.85
compressedSignedIntFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected