summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-09-01 15:38:17 -0400
committerGitHub <noreply@github.com>2022-09-01 15:38:17 -0400
commitbe8497804f803c02cfab1aa2c54d921042e90ec9 (patch)
treec9451382ba2bf112848441f9d61470a90ed764ee /source/slang/slang-compiler.h
parent174048f26c147e31a6f72907a3af5dfafeedb877 (diff)
Remove artifact from SourceFile (#2384)
* #include an absolute path didn't work - because paths were taken to always be relative. * Make DownstreamCompileOptions use POD types. * CharSliceAllocator -> SliceAllocator Added SliceConverter CharSliceCaster -> SliceCaster * First attempt at zero terminating around blobs. * Fix clang warning. * Add SlangTerminatedChars Make Blob implementations support it. Make most blobs 'terminated'. * Fix bug setting up sourceFiles for CommandLineDownstreamCompiler. * Traffic in TerminatedCharSlice for sourceFiles. Use ArtifactDesc to generate temporary file names for source. * Fix typo in testing for shared library/C++. * Working with source being passed as artifacts to DownstreamCompiler. * Use artifacts in SourceManager/SourceFile. * Support infering extension from the original file extension. * * Infer extension if can't determine from the artifact type * Split IOSFile/IExtFile representations * Move responsibility for creating OS file to the handler. * Disable the check memory path. * Remove artifact from SourceFile. Lazily generate SourceFile from artifacts as needed. * Fix some small bugs. * Remove maybeAddArtifact. * Load artifacts if repro capture is enabled. * Remove adding by string, because doing so means source will be allocated twice or there is a potential race around ref counting to the contained String. * Add built in source as a blob. * Fix warning. * Make StringBlob own the contents if moved. Fix some compilation issues. * Share StringBlob uniqueness code. * Do move unique on Ctor. * Change MoveUnique to not have any values. * MoveUnique can more sensibly be a struct. Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-compiler.h')
-rwxr-xr-xsource/slang/slang-compiler.h56
1 files changed, 39 insertions, 17 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 4c6b0a6b1..8aba89677 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -1381,19 +1381,33 @@ namespace Slang
// The parent compile request
FrontEndCompileRequest* compileRequest = nullptr;
- // The language in which the source file(s)
- // are assumed to be written
+ // The language in which the source file(s)
+ // are assumed to be written
SourceLanguage sourceLanguage = SourceLanguage::Unknown;
- // The source file(s) that will be compiled to form this translation unit
- //
- // Usually, for HLSL or GLSL there will be only one file.
- List<SourceFile*> m_sourceFiles;
+ /// Makes any source artifact available as a SourceFile.
+ /// If successful any of the source artifacts will be represented by the same index
+ /// of sourceArtifacts
+ SlangResult requireSourceFiles();
+
+ /// Get the source files.
+ /// Since lazily evaluated requires calling requireSourceFiles to know it's in sync
+ /// with sourceArtifacts.
+ List<SourceFile*> const& getSourceFiles();
+
+ /// Get the source artifacts associated
+ const List<ComPtr<IArtifact>>& getSourceArtifacts() const { return m_sourceArtifacts; }
+
+ /// Clear all of the source
+ void clearSource() { m_sourceArtifacts.clear(); m_sourceFiles.clear(); }
+
+ /// Add a source artifact
+ void addSourceArtifact(IArtifact* sourceArtifact);
- List<SourceFile*> const& getSourceFiles() { return m_sourceFiles; }
- void addSourceFile(SourceFile* sourceFile);
+ /// Add both the artifact and the sourceFile.
+ void addSource(IArtifact* sourceArtifact, SourceFile* sourceFile);
- // The entry points associated with this translation unit
+ // The entry points associated with this translation unit
List<RefPtr<EntryPoint>> const& getEntryPoints() { return module->getEntryPoints(); }
void _addEntryPoint(EntryPoint* entryPoint) { module->_addEntryPoint(entryPoint); }
@@ -1414,6 +1428,17 @@ namespace Slang
Session* getSession();
NamePool* getNamePool();
SourceManager* getSourceManager();
+
+ protected:
+ void _addSourceFile(SourceFile* sourceFile);
+
+ List<ComPtr<IArtifact>> m_sourceArtifacts;
+ // The source file(s) that will be compiled to form this translation unit
+ //
+ // Usually, for HLSL or GLSL there will be only one file.
+ // NOTE! This member is generated lazily from m_sourceArtifacts
+ // it is *necessary* to call requireSourceFiles to ensure it's in sync.
+ List<SourceFile*> m_sourceFiles;
};
enum class FloatingPointMode : SlangFloatingPointModeIntegral
@@ -2007,20 +2032,15 @@ namespace Slang
int addTranslationUnit(TranslationUnitRequest* translationUnit);
- void addTranslationUnitSourceFile(
+ void addTranslationUnitSourceArtifact(
int translationUnitIndex,
- SourceFile* sourceFile);
+ IArtifact* sourceArtifact);
void addTranslationUnitSourceBlob(
int translationUnitIndex,
String const& path,
ISlangBlob* sourceBlob);
- void addTranslationUnitSourceString(
- int translationUnitIndex,
- String const& path,
- String const& source);
-
void addTranslationUnitSourceFile(
int translationUnitIndex,
String const& path);
@@ -2386,6 +2406,8 @@ namespace Slang
bool isSpecializationDisabled();
+ SlangResult requireTranslationUnitSourceFiles();
+
//
SlangResult emitEntryPoints(ComPtr<IArtifact>& outArtifact);
@@ -2890,7 +2912,7 @@ namespace Slang
void addBuiltinSource(
Scope* scope,
String const& path,
- String const& source);
+ ISlangBlob* sourceBlob);
~Session();
void addDownstreamCompileTime(double time) { m_downstreamCompileTime += time; }