summaryrefslogtreecommitdiff
path: root/source/slang/slang-preprocessor.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-preprocessor.h')
-rw-r--r--source/slang/slang-preprocessor.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/slang/slang-preprocessor.h b/source/slang/slang-preprocessor.h
index 191adce88..0e7509a27 100644
--- a/source/slang/slang-preprocessor.h
+++ b/source/slang/slang-preprocessor.h
@@ -3,7 +3,10 @@
#define SLANG_PREPROCESSOR_H_INCLUDED
#include "../core/slang-basic.h"
-#include "../slang/slang-lexer.h"
+
+#include "slang-lexer.h"
+
+#include "slang-include-system.h"
namespace Slang {
@@ -16,14 +19,27 @@ class ModuleDecl;
// for files in `#include` directives.
struct IncludeHandler
{
-
- virtual SlangResult findFile(const String& pathToInclude,
- const String& pathIncludedFrom,
- PathInfo& pathInfoOut) = 0;
-
+ virtual SlangResult findFile(const String& pathToInclude, const String& pathIncludedFrom, PathInfo& outPathInfo) = 0;
virtual String simplifyPath(const String& path) = 0;
};
+// A default implementation that uses IncludeSystem to implement functionality
+struct IncludeHandlerImpl : IncludeHandler
+{
+ virtual SlangResult findFile(const String& pathToInclude, const String& pathIncludedFrom, PathInfo& outPathInfo) override
+ {
+ return m_system.findFile(pathToInclude, pathIncludedFrom, outPathInfo);
+ }
+ virtual String simplifyPath(const String& path) override { return m_system.simplifyPath(path); }
+
+ IncludeHandlerImpl(SearchDirectoryList* searchDirectories, ISlangFileSystemExt* fileSystemExt, SourceManager* sourceManager = nullptr) :
+ m_system(searchDirectories, fileSystemExt, sourceManager)
+ {
+ }
+protected:
+ IncludeSystem m_system;
+};
+
// Take a string of source code and preprocess it into a list of tokens.
TokenList preprocessSource(
SourceFile* file,