From 274c20a5eb133779a9d890ca79120815fb92b04e Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 30 Sep 2020 13:28:56 -0400 Subject: Generalizing Serialization (#1563) * First pass at generalizing serializer. * Split out ReflectClassInfo * Use the general ReflectClassInfo * Fix some typos in debug generalized serialization. * Add calculation of classIds. Make distinct addCopy/add on SerialClasses. * Write up of more generalized serialization * WIP to transition from ASTSerialReader/Writer etc to generalized SerialReader/Writer and associated types. * Improvements to SerialExtraObjects. Keep RefObjects in scope in factory * Compiles with Serial refactor - doesn't quite work yet. * First pass serialization appears to work with refector. * Split out type info for general slang types. * Split out slang-serialize-misc-type-info.h * DebugSerialData -> SerialSourecLocData DebugSerialReader -> SerialSourceLocReader DebugSerialWriter -> SerialSourceLocWriter * Remove unused template that only compiles on VS. * Fix warning around unused function on non-VS. --- source/slang/slang-serialize-ir.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/slang/slang-serialize-ir.cpp') diff --git a/source/slang/slang-serialize-ir.cpp b/source/slang/slang-serialize-ir.cpp index ac8085d51..d923577f4 100644 --- a/source/slang/slang-serialize-ir.cpp +++ b/source/slang/slang-serialize-ir.cpp @@ -34,7 +34,7 @@ void IRSerialWriter::_addInstruction(IRInst* inst) m_insts.add(inst); } -Result IRSerialWriter::_calcDebugInfo(DebugSerialWriter* debugWriter) +Result IRSerialWriter::_calcDebugInfo(SerialSourceLocWriter* sourceLocWriter) { // We need to find the unique source Locs // We are not going to store SourceLocs directly, because there may be multiple views mapping down to @@ -93,7 +93,7 @@ Result IRSerialWriter::_calcDebugInfo(DebugSerialWriter* debugWriter) IRSerialData::SourceLocRun sourceLocRun; sourceLocRun.m_numInst = curInstIndex - startInstLoc->instIndex;; sourceLocRun.m_startInstIndex = IRSerialData::InstIndex(startInstLoc->instIndex); - sourceLocRun.m_sourceLoc = debugWriter->addSourceLoc(SourceLoc::fromRaw(startSourceLoc)); + sourceLocRun.m_sourceLoc = sourceLocWriter->addSourceLoc(SourceLoc::fromRaw(startSourceLoc)); m_serialData->m_debugSourceLocRuns.add(sourceLocRun); @@ -104,7 +104,7 @@ Result IRSerialWriter::_calcDebugInfo(DebugSerialWriter* debugWriter) return SLANG_OK; } -Result IRSerialWriter::write(IRModule* module, DebugSerialWriter* debugWriter, SerialOptionFlags options, IRSerialData* serialData) +Result IRSerialWriter::write(IRModule* module, SerialSourceLocWriter* sourceLocWriter, SerialOptionFlags options, IRSerialData* serialData) { typedef Ser::Inst::PayloadType PayloadType; @@ -307,9 +307,9 @@ Result IRSerialWriter::write(IRModule* module, DebugSerialWriter* debugWriter, S } } - if ((options & SerialOptionFlag::DebugInfo) && debugWriter) + if ((options & SerialOptionFlag::DebugInfo) && sourceLocWriter) { - _calcDebugInfo(debugWriter); + _calcDebugInfo(sourceLocWriter); } m_serialData = nullptr; @@ -669,7 +669,7 @@ static Result _readInstArrayChunk(SerialCompressionType containerCompressionType return SLANG_OK; } -Result IRSerialReader::read(const IRSerialData& data, Session* session, DebugSerialReader* debugReader, RefPtr& outModule) +Result IRSerialReader::read(const IRSerialData& data, Session* session, SerialSourceLocReader* sourceLocReader, RefPtr& outModule) { typedef Ser::Inst::PayloadType PayloadType; @@ -866,14 +866,14 @@ Result IRSerialReader::read(const IRSerialData& data, Session* session, DebugSer } // We now need to apply the runs - if (debugReader && m_serialData->m_debugSourceLocRuns.getCount()) + if (sourceLocReader && m_serialData->m_debugSourceLocRuns.getCount()) { List sourceRuns(m_serialData->m_debugSourceLocRuns); // They are now in source location order sourceRuns.sort(); // Just guess initially 0 for the source file that contains the initial run - DebugSerialData::SourceRange range = DebugSerialData::SourceRange::getInvalid(); + SerialSourceLocData::SourceRange range = SerialSourceLocData::SourceRange::getInvalid(); int fix = 0; const Index numRuns = sourceRuns.getCount(); @@ -887,9 +887,9 @@ Result IRSerialReader::read(const IRSerialData& data, Session* session, DebugSer { if (!range.contains(run.m_sourceLoc)) { - fix = debugReader->calcFixSourceLoc(run.m_sourceLoc, range); + fix = sourceLocReader->calcFixSourceLoc(run.m_sourceLoc, range); } - sourceLoc = debugReader->calcFixedLoc(run.m_sourceLoc, fix, range); + sourceLoc = sourceLocReader->calcFixedLoc(run.m_sourceLoc, fix, range); } // Write to all the instructions -- cgit v1.2.3