From 8a61b9dd0ca729df894dad4c89c6ce3bf39ef0be Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 17 Mar 2023 11:05:15 -0400 Subject: Support for producing SourceMap on emit (#2707) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP source map. * Split out handling of RttiTypeFuncs to a map type. * Make RttiTypeFuncsMap hold default impls. * Slightly more sophisticated RttiTypeFuncsMap * Source map decoding. * Fix tabs. * Fix asserts due to negative values. * Use less obscure mechanisms in SourceMap. * Source map decoding. Simplifying SourceMap usage. * First attempt at ouputting a source map as part of emit. * Added support for -source-map option. SourceMap is added to the artifact. --- source/compiler-core/slang-source-map.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source/compiler-core/slang-source-map.h') diff --git a/source/compiler-core/slang-source-map.h b/source/compiler-core/slang-source-map.h index 7fd64510a..739cf1992 100644 --- a/source/compiler-core/slang-source-map.h +++ b/source/compiler-core/slang-source-map.h @@ -15,10 +15,19 @@ namespace Slang { -struct SourceMap +struct SourceMap : public RefObject { struct Entry { + void init() + { + generatedColumn = 0; + sourceFileIndex = 0; + sourceLine = 0; + sourceColumn = 0; + nameIndex = 0; + } + // Note! All column/line are zero indexed Index generatedColumn; ///< The generated column Index sourceFileIndex; ///< The index into the source name/contents @@ -38,6 +47,20 @@ struct SourceMap /// Get the entries on the line SLANG_FORCE_INLINE ConstArrayView getEntriesForLine(Index generatedLine) const; + /// Advance to the specified line index. + /// It is an error to specify a line *before* the current line. It should either be the current + /// output line or a later output line. Interveining lines will be set as empty + void advanceToLine(Index lineIndex); + + /// Add an entry to the current line + void addEntry(const Entry& entry); + + /// Given the slice returns the index + Index getSourceFileIndex(const UnownedStringSlice& slice); + + /// Get the name index + Index getNameIndex(const UnownedStringSlice& slice); + /// Clear the contents of the source map void clear(); -- cgit v1.2.3