summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-10-17 11:57:33 -0400
committerGitHub <noreply@github.com>2018-10-17 11:57:33 -0400
commitf9710d50bc675ddba51cc6d94b125ba1549708a8 (patch)
treeaec03343b18248d0751868ee3acc59ec99f8b416 /source/slang/slang.cpp
parent3e74d39f24fdfaa547ce900be177863e2bfe2dea (diff)
IncludeFileSystem -> DefaultFileSystem (#677)
Improvements in 'singleton'ness of DefaultFileSystem Made WrapFileSystem a stand alone type - to remove 'odd' aspects of deriving from DefaultFileSystem (such as inheriting getSingleton method/fixing ref counting) Simplified CompileRequest::loadFile - becauce fileSystemExt is always available.
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp41
1 files changed, 4 insertions, 37 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 908bee283..5461afbf7 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -9,7 +9,7 @@
#include "syntax-visitors.h"
#include "../slang/type-layout.h"
-#include "include-file-system.h"
+#include "default-file-system.h"
#include "ir-serialize.h"
@@ -316,7 +316,7 @@ CompileRequest::CompileRequest(Session* session)
// Set up the default file system
SLANG_ASSERT(fileSystem == nullptr);
- fileSystemExt = IncludeFileSystem::getDefault();
+ fileSystemExt = DefaultFileSystem::getSingleton();
}
CompileRequest::~CompileRequest()
@@ -407,42 +407,9 @@ ComPtr<ISlangBlob> createRawBlob(void const* inData, size_t size)
SlangResult CompileRequest::loadFile(String const& path, ISlangBlob** outBlob)
{
- // If there is a used-defined filesystem, then use that to load files.
- //
- if(fileSystem)
- {
- return fileSystem->loadFile(path.Buffer(), outBlob);
- }
-
- // Otherwise, fall back to a default implementation that uses the `core`
- // libraries facilities for talking to the OS filesystem.
- //
- // TODO: we might want to conditionally compile these in, so that
- // a user could create a build of Slang that doesn't include any OS
- // filesystem calls.
- //
-
- if (!File::Exists(path))
- {
- return SLANG_FAIL;
- }
-
- try
- {
- String sourceString = File::ReadAllText(path);
- ComPtr<ISlangBlob> sourceBlob = createStringBlob(sourceString);
- *outBlob = sourceBlob.detach();
-
- return SLANG_OK;
- }
- catch(...)
- {
- }
- return SLANG_FAIL;
-
+ return fileSystemExt->loadFile(path.Buffer(), outBlob);
}
-
RefPtr<Expr> CompileRequest::parseTypeString(TranslationUnitRequest * translationUnit, String typeStr, RefPtr<Scope> scope)
{
// Create a SourceManager on the stack, so any allocations for 'SourceFile'/'SourceView' etc will be cleaned up
@@ -1214,7 +1181,7 @@ SLANG_API void spSetFileSystem(
// Set up fileSystemExt appropriately
if (fileSystem == nullptr)
{
- req->fileSystemExt = Slang::IncludeFileSystem::getDefault();
+ req->fileSystemExt = Slang::DefaultFileSystem::getSingleton();
}
else
{