summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-source-map.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-03-27 13:57:42 -0400
committerGitHub <noreply@github.com>2023-03-27 10:57:42 -0700
commitca1f93a916ce6b984cba402c8d3710988f2b618f (patch)
treef39b638210d38efdc7e2bb746c06b881323d0f53 /source/compiler-core/slang-source-map.h
parent2179480e28bdd46c71cec269a8f55ba93aa54f53 (diff)
Using SourceMap for location output (#2736)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP using SourceMap with SourceManager. * Add a test to check obfuscation map is working. --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/compiler-core/slang-source-map.h')
-rw-r--r--source/compiler-core/slang-source-map.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/source/compiler-core/slang-source-map.h b/source/compiler-core/slang-source-map.h
index accd2473f..1ccc87e90 100644
--- a/source/compiler-core/slang-source-map.h
+++ b/source/compiler-core/slang-source-map.h
@@ -2,21 +2,17 @@
#define SLANG_COMPILER_CORE_SOURCE_MAP_H
#include "../../slang.h"
-#include "../../slang-com-helper.h"
-#include "../../slang-com-ptr.h"
#include "../core/slang-string.h"
#include "../core/slang-list.h"
-#include "../core/slang-rtti-info.h"
#include "../core/slang-string-slice-pool.h"
-#include "slang-json-value.h"
-
namespace Slang {
-struct SourceMap : public RefObject
+class SourceMap : public RefObject
{
+public:
struct Entry
{
void init()
@@ -36,12 +32,6 @@ struct SourceMap : public RefObject
Index nameIndex; ///< Name index
};
- /// Decode from root into the source map
- SlangResult decode(JSONContainer* container, JSONValue root, DiagnosticSink* sink);
-
- /// Converts the source map contents into JSON
- SlangResult encode(JSONContainer* container, DiagnosticSink* sink, JSONValue& outValue);
-
/// Get the total number of generated lines
Count getGeneratedLineCount() const { return m_lineStarts.getCount(); }
/// Get the entries on the line
@@ -61,6 +51,16 @@ struct SourceMap : public RefObject
/// Get the name index
Index getNameIndex(const UnownedStringSlice& slice);
+ /// Given a row and col index, find the closest entry
+ /// NOTE! Zero indexed line and column.
+ Index findEntry(Index lineIndex, Index colIndex) const;
+
+ /// Given an entry index return the entry
+ const Entry& getEntryByIndex(Index i) const {return m_lineEntries[i]; }
+
+ /// Given the sourceFileIndex return the name
+ UnownedStringSlice getSourceFileName(Index sourceFileIndex) const;
+
/// Clear the contents of the source map
void clear();