diff options
Diffstat (limited to 'source/compiler-core/slang-artifact-representation-impl.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-representation-impl.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/source/compiler-core/slang-artifact-representation-impl.cpp b/source/compiler-core/slang-artifact-representation-impl.cpp index d1de75c79..6ae2d646f 100644 --- a/source/compiler-core/slang-artifact-representation-impl.cpp +++ b/source/compiler-core/slang-artifact-representation-impl.cpp @@ -94,4 +94,94 @@ FileArtifactRepresentation::~FileArtifactRepresentation() } } +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DiagnosticsArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void* DiagnosticsArtifactRepresentation::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || + guid == ICastable::getTypeGuid() || + guid == IArtifactRepresentation::getTypeGuid() || + guid == IDiagnosticsArtifactRepresentation::getTypeGuid()) + { + return static_cast<DiagnosticsArtifactRepresentation*>(this); + } + return nullptr; +} + +void* DiagnosticsArtifactRepresentation::getObject(const Guid& guid) +{ + SLANG_UNUSED(guid); + return nullptr; +} + +void* DiagnosticsArtifactRepresentation::castAs(const Guid& guid) +{ + if (auto intf = getInterface(guid)) + { + return intf; + } + return getObject(guid); +} + +SlangResult DiagnosticsArtifactRepresentation::writeToBlob(ISlangBlob** outBlob) +{ + *outBlob = nullptr; + return SLANG_E_NOT_IMPLEMENTED; +} + +bool DiagnosticsArtifactRepresentation::exists() +{ + return true; +} + +ZeroTerminatedCharSlice DiagnosticsArtifactRepresentation::_allocateSlice(const Slice<char>& in) +{ + if (in.count == 0) + { + return ZeroTerminatedCharSlice("", 0); + } + const char* dst = m_arena.allocateString(in.data, in.count); + return ZeroTerminatedCharSlice(dst, in.count); +} + +void DiagnosticsArtifactRepresentation::add(const Diagnostic& inDiagnostic) +{ + Diagnostic diagnostic(inDiagnostic); + + diagnostic.text = _allocateSlice(inDiagnostic.text); + diagnostic.code = _allocateSlice(inDiagnostic.code); + diagnostic.filePath = _allocateSlice(inDiagnostic.filePath); + + m_diagnostics.add(diagnostic); +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PostEmitMetadataArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void* PostEmitMetadataArtifactRepresentation::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || + guid == ICastable::getTypeGuid() || + guid == IArtifactRepresentation::getTypeGuid() || + guid == IPostEmitMetadataArtifactRepresentation::getTypeGuid()) + { + return static_cast<IPostEmitMetadataArtifactRepresentation*>(this); + } + return nullptr; +} + +void* PostEmitMetadataArtifactRepresentation::getObject(const Guid& uuid) +{ + if (uuid == getTypeGuid()) + { + return this; + } + return nullptr; +} + +Slice<ShaderBindingRange> PostEmitMetadataArtifactRepresentation::getBindingRanges() +{ + return Slice<ShaderBindingRange>(m_usedBindings.getBuffer(), m_usedBindings.getCount()); +} + + } // namespace Slang |
