Allow VarStreamArray to use stateful extractors.

Previously extractors tried to be stateless with any additional
context information needed in order to parse items being passed
in via the extraction method.  This led to quite cumbersome
implementation challenges and awkwardness of use.  This patch
brings back support for stateful extractors, making the
implementation and usage simpler.

llvm-svn: 305093
This commit is contained in:
Zachary Turner
2017-06-09 17:54:36 +00:00
parent d9de6389fc
commit 7e62cd17d6
15 changed files with 143 additions and 217 deletions

View File

@@ -17,9 +17,8 @@
using namespace llvm;
using namespace llvm::codeview;
Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len,
LineColumnEntry &Item,
const LineFragmentHeader *Header) {
Error LineColumnExtractor::operator()(BinaryStreamRef Stream, uint32_t &Len,
LineColumnEntry &Item) {
using namespace codeview;
const LineBlockFragmentHeader *BlockHeader;
BinaryStreamReader Reader(Stream);
@@ -56,8 +55,8 @@ Error DebugLinesSubsectionRef::initialize(BinaryStreamReader Reader) {
if (auto EC = Reader.readObject(Header))
return EC;
if (auto EC =
Reader.readArray(LinesAndColumns, Reader.bytesRemaining(), Header))
LinesAndColumns.getExtractor().Header = Header;
if (auto EC = Reader.readArray(LinesAndColumns, Reader.bytesRemaining()))
return EC;
return Error::success();