summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-22 07:14:55 -0800
committerGitHub <noreply@github.com>2024-02-22 07:14:55 -0800
commit8ec5b3e6ef2e7e5c3adaa5accb375676b1c09ff0 (patch)
treef3023dc51c32d74d1b5dd4701f5535c8227fe17e /source/compiler-core
parentc5ac7dee8a47dcb168a6556d2e8cdb8d2fe09a37 (diff)
Add API for querying and reusing precompiled binary modules. (#3614)
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-source-loc.cpp12
-rw-r--r--source/compiler-core/slang-source-loc.h5
2 files changed, 16 insertions, 1 deletions
diff --git a/source/compiler-core/slang-source-loc.cpp b/source/compiler-core/slang-source-loc.cpp
index fe08f8dfc..872c40f0d 100644
--- a/source/compiler-core/slang-source-loc.cpp
+++ b/source/compiler-core/slang-source-loc.cpp
@@ -4,7 +4,6 @@
#include "../core/slang-string-util.h"
#include "../core/slang-string-escape-util.h"
#include "../core/slang-char-encode.h"
-
#include "slang-artifact-representation-impl.h"
#include "slang-artifact-impl.h"
#include "slang-artifact-util.h"
@@ -602,6 +601,17 @@ SourceFile::~SourceFile()
{
}
+SHA1::Digest SourceFile::getDigest()
+{
+ if (m_digest == SHA1::Digest())
+ {
+ DigestBuilder<SHA1> builder;
+ builder.append(getContent());
+ m_digest = builder.finalize();
+ }
+ return m_digest;
+}
+
String SourceFile::calcVerbosePath() const
{
ISlangFileSystemExt* fileSystemExt = getSourceManager()->getFileSystemExt();
diff --git a/source/compiler-core/slang-source-loc.h b/source/compiler-core/slang-source-loc.h
index f432b2432..a5919d809 100644
--- a/source/compiler-core/slang-source-loc.h
+++ b/source/compiler-core/slang-source-loc.h
@@ -6,6 +6,7 @@
#include "../core/slang-memory-arena.h"
#include "../core/slang-string-slice-pool.h"
#include "../core/slang-castable.h"
+#include "../core/slang-crypto.h"
#include "slang-source-map.h"
@@ -277,6 +278,8 @@ public:
/// Dtor
~SourceFile();
+ SHA1::Digest getDigest();
+
protected:
SourceManager* m_sourceManager; ///< The source manager this belongs to
@@ -286,6 +289,8 @@ public:
UnownedStringSlice m_content; ///< The actual contents of the file.
size_t m_contentSize; ///< The size of the actual contents
+ SHA1::Digest m_digest;
+
// In order to speed up lookup of line number information,
// we will cache the starting offset of each line break in
// the input file: