#14043

refactor(domain): one ByteSource representation for streaming parsers

Openmorlutoopened 2d ago

Summary

Streaming parsers declare six copies of the same random-access contract:

  • NativeByteSource in nativeSectionDirectory.ts, with an optional prefix.
  • ElfNoteByteSource, ElfDependencyByteSource, V8CodeCacheByteSource, PeImportByteSource and PeResourceByteSource, each with a required prefix: Buffer.

The in-memory adapters are duplicated the same way: a private bufferSource in peResourceInventory.ts, three test-local copies, and the elfNoteByteSource, elfUnwindByteSource and goByteSource fixtures. Their out-of-range behavior differs between copies.

Proposed Change

Add src/domain/byteSource.ts with ByteSource, PrefixedByteSource and bufferByteSource(bytes, prefixBytes?). Its out-of-range reads are short, as a positional file read would be. Migrate every consumer directly and delete the copies.

Activity

0

No activity yet.