diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-compiler.cpp | 28 | ||||
| -rw-r--r-- | source/slang/slang-emit.cpp | 26 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 11 |
3 files changed, 12 insertions, 53 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index becd65596..907f39f48 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -15,8 +15,6 @@ #include "../compiler-core/slang-lexer.h" -#include "../compiler-core/slang-json-source-map-util.h" - // Artifact #include "../compiler-core/slang-artifact-desc-util.h" #include "../compiler-core/slang-artifact-representation-impl.h" @@ -1902,9 +1900,6 @@ namespace Slang auto frontEndReq = getFrontEndReq(); - auto sourceManager = frontEndReq->getSourceManager(); - auto sink = getSink(); - for (auto translationUnit : frontEndReq->translationUnits) { // Hmmm do I have to therefore add a map for all translation units(!) @@ -1915,29 +1910,14 @@ namespace Slang // If we have a source map *and* we want to generate them for output add to the container if (sourceMap && getLinkage()->m_generateSourceMap) { - // Write it out - String json; - { - RefPtr<JSONContainer> jsonContainer(new JSONContainer(sourceManager)); - - JSONValue jsonValue; - - SLANG_RETURN_ON_FAIL(JSONSourceMapUtil::encode(sourceMap, jsonContainer, sink, jsonValue)); - - // Convert into a string - JSONWriter writer(JSONWriter::IndentationStyle::Allman); - jsonContainer->traverseRecursively(jsonValue, &writer); - - json = writer.getBuilder(); - } - - auto jsonSourceMapBlob = StringBlob::moveCreate(json); - auto artifactDesc = ArtifactDesc::make(ArtifactKind::Json, ArtifactPayload::SourceMap, ArtifactStyle::Obfuscated); // Create the source map artifact auto sourceMapArtifact = Artifact::create(artifactDesc, sourceMap->m_file.getUnownedSlice()); - sourceMapArtifact->addRepresentationUnknown(jsonSourceMapBlob); + + // Add the repesentation + ComPtr<IObjectCastableAdapter> castableAdapter(new ObjectCastableAdapter(sourceMap)); + sourceMapArtifact->addRepresentation(castableAdapter); // Associate with the container m_containerArtifact->addAssociated(sourceMapArtifact); diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index e2948561c..67a4c4610 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -82,7 +82,7 @@ #include "../compiler-core/slang-artifact-impl.h" #include "../compiler-core/slang-artifact-associated-impl.h" -#include "../compiler-core/slang-json-source-map-util.h" +#include "../core/slang-castable.h" #include <assert.h> @@ -1152,28 +1152,10 @@ SlangResult CodeGenContext::emitEntryPointsSourceFromIR(ComPtr<IArtifact>& outAr if (sourceMap) { - SourceManager sourceMapSourceManager; - sourceMapSourceManager.initialize(nullptr, nullptr); - - // Create a sink - DiagnosticSink sourceMapSink(&sourceMapSourceManager, nullptr); - - // Turn into JSON - RefPtr<JSONContainer> jsonContainer(new JSONContainer(&sourceMapSourceManager)); - - JSONValue jsonValue; - SLANG_RETURN_ON_FAIL(JSONSourceMapUtil::encode(sourceMap, jsonContainer, &sourceMapSink, jsonValue)); - - // Okay now convert this into a text file and then a blob - - // Convert into a string - JSONWriter writer(JSONWriter::IndentationStyle::KNR); - jsonContainer->traverseRecursively(jsonValue, &writer); - - auto sourceMapBlob = StringBlob::moveCreate(writer.getBuilder()); - auto sourceMapArtifact = ArtifactUtil::createArtifact(ArtifactDesc::make(ArtifactKind::Json, ArtifactPayload::SourceMap, ArtifactStyle::None)); - sourceMapArtifact->addRepresentationUnknown(sourceMapBlob); + + ComPtr<IObjectCastableAdapter> castableAdapter(new ObjectCastableAdapter(sourceMap)); + sourceMapArtifact->addRepresentation(castableAdapter); artifact->addAssociated(sourceMapArtifact); } diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index c8cda0dca..bedfb1161 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -15,8 +15,6 @@ #include "../compiler-core/slang-artifact-associated-impl.h" #include "../compiler-core/slang-artifact-container-util.h" -#include "../compiler-core/slang-json-source-map-util.h" - #include "../core/slang-memory-file-system.h" #include "slang-module-library.h" @@ -4884,12 +4882,11 @@ SlangResult _addLibraryReference(EndToEndCompileRequest* req, IArtifact* artifac isDerivedFrom(assocDesc.payload, ArtifactPayload::SourceMap) && isDerivedFrom(assocDesc.style, ArtifactStyle::Obfuscated)) { - ComPtr<ISlangBlob> sourceMapBlob; - SLANG_RETURN_ON_FAIL(associated->loadBlob(ArtifactKeep::No, sourceMapBlob.writeRef())); + ComPtr<ICastable> castable; + SLANG_RETURN_ON_FAIL(associated->getOrCreateRepresentation(SourceMap::getTypeGuid(), ArtifactKeep::Yes, castable.writeRef())); + + auto sourceMap = as<SourceMap>(castable); - RefPtr<SourceMap> sourceMap; - SLANG_RETURN_ON_FAIL(JSONSourceMapUtil::read(sourceMapBlob, nullptr, sourceMap)); - // I guess we add to all ir modules? for (auto irModule : library->m_modules) |
