From 20ea33f3321738e7c1b4cad7bdcaedcdb54dd0f0 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 11 Apr 2023 10:18:18 -0400 Subject: Artifact simplification (#2781) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP simplifying artifact interface. * Use ContainedKind. * Remove LazyCastableList. Use ContainedKind for find. * Remove ICastableList. * Remove need for ICastableList. * Remove IArtifactContainer. * Small fixes. * Small improvements around Artifact. * Make explicit find is for *representations* that can cast. Fix bug in handling casting in lookup. * Made associated items artifacts too. * Small fixes. * Small improvements around writing a container. --- source/slang/slang-compiler.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 839a4e67c..497cf3d94 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -8,6 +8,7 @@ #include "../core/slang-riff.h" #include "../core/slang-type-text-util.h" #include "../core/slang-type-convert-util.h" +#include "../core/slang-castable.h" #include "slang-check.h" #include "slang-compiler.h" @@ -1119,7 +1120,7 @@ namespace Slang ComPtr metadata; if (sourceArtifact) { - metadata = findAssociated(sourceArtifact); + metadata = findAssociatedRepresentation(sourceArtifact); // Set the source artifacts options.sourceArtifacts = makeSlice(sourceArtifact.readRef(), 1); @@ -1411,7 +1412,7 @@ namespace Slang (std::chrono::high_resolution_clock::now() - downstreamStartTime).count() * 0.000000001; getSession()->addDownstreamCompileTime(downstreamElapsedTime); - auto diagnostics = findAssociated(artifact); + auto diagnostics = findAssociatedRepresentation(artifact); if (diagnostics->getCount()) { @@ -1468,10 +1469,7 @@ namespace Slang return SLANG_FAIL; } - if (metadata) - { - artifact->addAssociated(metadata); - } + ArtifactUtil::addAssociated(artifact, metadata); // Set the artifact outArtifact.swap(artifact); @@ -1975,22 +1973,19 @@ namespace Slang { Index nameCount = 0; - auto associated = m_containerArtifact->getAssociated(); - const Count count = associated->getCount(); - for (Index i = 0; i < count; ++i) + for (auto associatedArtifact : m_containerArtifact->getAssociated()) { - IArtifact* artifact = as(associated->getAt(i)); - auto desc = artifact->getDesc(); + auto desc = associatedArtifact->getDesc(); if (isDerivedFrom(desc.payload, ArtifactPayload::SourceMap)) { StringBuilder artifactFilename; // Dump out - const char* artifactName = artifact->getName(); + const char* artifactName = associatedArtifact->getName(); if (artifactName && artifactName[0] != 0) { - SLANG_RETURN_ON_FAIL(ArtifactUtil::calcName(artifact, UnownedStringSlice(artifactName), artifactFilename)); + SLANG_RETURN_ON_FAIL(ArtifactUtil::calcName(associatedArtifact, UnownedStringSlice(artifactName), artifactFilename)); } else { @@ -2005,13 +2000,13 @@ namespace Slang baseName.append(nameCount); } - SLANG_RETURN_ON_FAIL(ArtifactUtil::calcName(artifact, baseName.getUnownedSlice(), artifactFilename)); + SLANG_RETURN_ON_FAIL(ArtifactUtil::calcName(associatedArtifact, baseName.getUnownedSlice(), artifactFilename)); nameCount ++; } ComPtr blob; - SLANG_RETURN_ON_FAIL(artifact->loadBlob(ArtifactKeep::No, blob.writeRef())); + SLANG_RETURN_ON_FAIL(associatedArtifact->loadBlob(ArtifactKeep::No, blob.writeRef())); // Try to write it out { -- cgit v1.2.3