summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-downstream-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-10-04 14:15:51 -0400
committerGitHub <noreply@github.com>2021-10-04 14:15:51 -0400
commit97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 (patch)
treef120ba282cbea96d23ed179737984a4610d3b520 /source/compiler-core/slang-downstream-compiler.cpp
parentb3dfe383c6d31ff3dbd76dcfb32de8d536382f3e (diff)
Removing exceptions from core/compiler-core (#1953)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Stream. Working on all tests. * Split out CharEncode. * Make method names lower camel. m_prefix in Writer/Reader * Tidy up around CharEncode interface. * Small improvements around encode/decode. * Better use of types. * Remove readLine from TextReader. * Remove exceptions from Stream/Text handling. * Fix some typos. * Fix tabbing. * Fix missing override. * Remove remaining exception throw/catch via using signal mechanism. * Remove exceptions that are not used anymore. * Document the Stream interface. * Remove index for decoding 'get byte' function. * Fix CharReader -> ByteReader.
Diffstat (limited to 'source/compiler-core/slang-downstream-compiler.cpp')
-rw-r--r--source/compiler-core/slang-downstream-compiler.cpp39
1 files changed, 11 insertions, 28 deletions
diff --git a/source/compiler-core/slang-downstream-compiler.cpp b/source/compiler-core/slang-downstream-compiler.cpp
index 2a172eb3a..9312554ae 100644
--- a/source/compiler-core/slang-downstream-compiler.cpp
+++ b/source/compiler-core/slang-downstream-compiler.cpp
@@ -391,20 +391,14 @@ SlangResult CommandLineDownstreamCompileResult::getBinary(ComPtr<ISlangBlob>& ou
return SLANG_OK;
}
+ List<uint8_t> contents;
// Read the binary
- try
- {
// Read the contents of the binary
- List<uint8_t> contents = File::readAllBytes(m_moduleFilePath);
+ SLANG_RETURN_ON_FAIL(File::readAllBytes(m_moduleFilePath, contents));
- m_binaryBlob = new ScopeRefObjectBlob(ListBlob::moveCreate(contents), m_temporaryFiles);
- outBlob = m_binaryBlob;
- return SLANG_OK;
- }
- catch (const Slang::IOException&)
- {
- return SLANG_FAIL;
- }
+ m_binaryBlob = new ScopeRefObjectBlob(ListBlob::moveCreate(contents), m_temporaryFiles);
+ outBlob = m_binaryBlob;
+ return SLANG_OK;
}
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CommandLineDownstreamCompiler !!!!!!!!!!!!!!!!!!!!!!*/
@@ -428,15 +422,12 @@ static bool _isContentsInFile(const DownstreamCompiler::CompileOptions& options)
// file either from some specialized ISlangFileSystem, so this is probably as good as it gets
// until we can integrate directly to a C/C++ compiler through say a shared library where we can control
// file system access.
- try
+ String readContents;
+
+ if (SLANG_SUCCEEDED(File::readAllText(options.sourceContentsPath, readContents)))
{
- String readContents = File::readAllText(options.sourceContentsPath);
- // We should see if they are the same
return options.sourceContents == readContents.getUnownedSlice();
}
- catch (const Slang::IOException&)
- {
- }
}
return false;
}
@@ -484,17 +475,9 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio
}
// Write it out
- try
- {
- productFileSet->add(compileSourcePath);
-
- File::writeAllText(compileSourcePath, options.sourceContents);
- }
- catch (...)
- {
- return SLANG_FAIL;
- }
-
+ productFileSet->add(compileSourcePath);
+ SLANG_RETURN_ON_FAIL(File::writeAllText(compileSourcePath, options.sourceContents));
+
// Add it as a source file
options.sourceFiles.add(compileSourcePath);
}