From f7db44a236bb867003395d1a91d6907901653528 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 28 Feb 2023 15:09:19 -0800 Subject: Add `SourceBlobWithPathInfoArtifactRepresentation`. (#2682) --- source/slang/slang.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/slang') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 4f057bb21..3a11d3831 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -2980,17 +2980,22 @@ RefPtr Linkage::loadModule( // Create an artifact for the source auto sourceArtifact = ArtifactUtil::createArtifact(ArtifactDesc::make(ArtifactKind::Source, ArtifactPayload::Slang, ArtifactStyle::Unknown)); - // Create with the 'friendly' name - if (filePathInfo.type == PathInfo::Type::Normal || + if (sourceBlob) + { + // If the user has already provided a source blob, use that. + sourceArtifact->addRepresentation(new SourceBlobWithPathInfoArtifactRepresentation(filePathInfo, sourceBlob)); + } + else if ( + filePathInfo.type == PathInfo::Type::Normal || filePathInfo.type == PathInfo::Type::FoundPath) { + // Create with the 'friendly' name // We create that it was loaded from the file system sourceArtifact->addRepresentation(new ExtFileArtifactRepresentation(filePathInfo.foundPath.getUnownedSlice(), getFileSystemExt())); } else { - // Else we say we don't know and just add the blob - sourceArtifact->addRepresentationUnknown(sourceBlob); + return nullptr; } translationUnit->addSourceArtifact(sourceArtifact); -- cgit v1.2.3