diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-09-01 15:38:17 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-01 15:38:17 -0400 |
| commit | be8497804f803c02cfab1aa2c54d921042e90ec9 (patch) | |
| tree | c9451382ba2bf112848441f9d61470a90ed764ee /source/compiler-core | |
| parent | 174048f26c147e31a6f72907a3af5dfafeedb877 (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/compiler-core')
| -rw-r--r-- | source/compiler-core/slang-artifact-representation-impl.cpp | 2 | ||||
| -rw-r--r-- | source/compiler-core/slang-artifact-representation-impl.h | 2 | ||||
| -rw-r--r-- | source/compiler-core/slang-include-system.cpp | 3 | ||||
| -rw-r--r-- | source/compiler-core/slang-source-loc.cpp | 63 | ||||
| -rw-r--r-- | source/compiler-core/slang-source-loc.h | 12 |
5 files changed, 2 insertions, 80 deletions
diff --git a/source/compiler-core/slang-artifact-representation-impl.cpp b/source/compiler-core/slang-artifact-representation-impl.cpp index 9a5c13311..950ce5d7d 100644 --- a/source/compiler-core/slang-artifact-representation-impl.cpp +++ b/source/compiler-core/slang-artifact-representation-impl.cpp @@ -23,7 +23,7 @@ void* ExtFileArtifactRepresentation::getInterface(const Guid& guid) guid == IPathArtifactRepresentation::getTypeGuid() || guid == IExtFileArtifactRepresentation::getTypeGuid()) { - return static_cast<IPathArtifactRepresentation*>(this); + return static_cast<IExtFileArtifactRepresentation*>(this); } return nullptr; } diff --git a/source/compiler-core/slang-artifact-representation-impl.h b/source/compiler-core/slang-artifact-representation-impl.h index da21e30bc..880a90c18 100644 --- a/source/compiler-core/slang-artifact-representation-impl.h +++ b/source/compiler-core/slang-artifact-representation-impl.h @@ -108,7 +108,7 @@ protected: /* This allows wrapping any object to be an artifact representation. -NOTE! Only allows casting from a single guid. Passing a RefObject across an ABI bounday remains risky! +NOTE! Only allows casting from a single guid. Passing a RefObject across an ABI boundary remains risky! */ class ObjectArtifactRepresentation : public ComBaseObject, public IArtifactRepresentation { diff --git a/source/compiler-core/slang-include-system.cpp b/source/compiler-core/slang-include-system.cpp index 9cd193ec6..ebfc8db05 100644 --- a/source/compiler-core/slang-include-system.cpp +++ b/source/compiler-core/slang-include-system.cpp @@ -132,8 +132,6 @@ SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob> sourceFile = m_sourceManager->createSourceFileWithBlob(pathInfo, foundSourceBlob); m_sourceManager->addSourceFile(pathInfo.uniqueIdentity, sourceFile); - sourceFile->maybeAddArtifact(nullptr, m_fileSystemExt); - outBlob = foundSourceBlob; return SLANG_OK; } @@ -152,7 +150,6 @@ SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob> } sourceFile->setContents(foundSourceBlob); - sourceFile->maybeAddArtifact(nullptr, m_fileSystemExt); outBlob = foundSourceBlob; return SLANG_OK; diff --git a/source/compiler-core/slang-source-loc.cpp b/source/compiler-core/slang-source-loc.cpp index 6b4c5654d..ac6589e76 100644 --- a/source/compiler-core/slang-source-loc.cpp +++ b/source/compiler-core/slang-source-loc.cpp @@ -434,69 +434,6 @@ String SourceFile::calcVerbosePath() const return m_pathInfo.foundPath; } -void SourceFile::maybeAddArtifact(const ArtifactDesc* inArtifactDesc, ISlangFileSystemExt* ext) -{ - if (!m_contentBlob) - { - return; - } - - // If there already is an artifact, we don't need to create one - if (m_artifact) - { - // Check it has a blob and the blob is the same as the content blob - SLANG_ASSERT(m_contentBlob == findRepresentation<ISlangBlob>(m_artifact)); - return; - } - - ArtifactDesc artifactDesc; - - if (inArtifactDesc) - { - artifactDesc = *inArtifactDesc; - } - else - { - // Set the default - artifactDesc = ArtifactDesc::make(ArtifactKind::Source, ArtifactPayload::Unknown, ArtifactStyle::Unknown); - - // Let's work out from the - // We could try and work it out - if (getPathInfo().foundPath.getLength()) - { - // Let's work out what kind of source it is from the this - auto desc = ArtifactDescUtil::getDescFromPath(getPathInfo().foundPath.getUnownedSlice()); - - // If found something just use that - if (desc.kind == ArtifactKind::Source) - { - artifactDesc = desc; - } - } - } - - // We don't know how the source will be used - m_artifact = Artifact::create(artifactDesc); - - // Add the blob as a representation. - m_artifact->addRepresentationUnknown(m_contentBlob); - - // If we have the file system, set up the rep to that - if (ext) - { - // Add the representation on the file system - auto extRep = new ExtFileArtifactRepresentation(getPathInfo().foundPath.getUnownedSlice(), ext); - m_artifact->addRepresentation(extRep); - } - - // Get the name - auto name = getPathInfo().getName(); - if (name.getLength()) - { - m_artifact->setName(name.getBuffer()); - } -} - /* !!!!!!!!!!!!!!!!!!!!!!!!! SourceManager !!!!!!!!!!!!!!!!!!!!!!!!!!!! */ void SourceManager::initialize( diff --git a/source/compiler-core/slang-source-loc.h b/source/compiler-core/slang-source-loc.h index 29ed9dfbb..66e4c0475 100644 --- a/source/compiler-core/slang-source-loc.h +++ b/source/compiler-core/slang-source-loc.h @@ -9,8 +9,6 @@ #include "../../slang-com-ptr.h" #include "../../slang.h" -#include "slang-artifact-representation.h" - namespace Slang { /** Overview: @@ -236,20 +234,11 @@ public: /// Get path info const PathInfo& getPathInfo() const { return m_pathInfo; } - /// Get the (optional) assoicated artifact. Note its desc might be Source/Unknown - IArtifact* getArtifact() const { return m_artifact; } - /// Set the artifact - void setArtifact(IArtifact* artifact) { m_artifact = artifact; } - /// Set the content as a blob void setContents(ISlangBlob* blob); /// Set the content as a string void setContents(const String& content); - /// If the desc isn't set, will use Unknown source type - /// If artifact isn't defined will try and associate one. - void maybeAddArtifact(const ArtifactDesc* desc, ISlangFileSystemExt* ext); - /// Calculate a display path -> can canonicalize if necessary String calcVerbosePath() const; @@ -266,7 +255,6 @@ public: SourceManager* m_sourceManager; ///< The source manager this belongs to PathInfo m_pathInfo; ///< The path The logical file path to report for locations inside this span. - ComPtr<IArtifact> m_artifact; ///< Optional artifact ComPtr<ISlangBlob> m_contentBlob; ///< A blob that owns the storage for the file contents. If nullptr, there is no contents UnownedStringSlice m_content; ///< The actual contents of the file. size_t m_contentSize; ///< The size of the actual contents |
