diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-03-16 15:19:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-16 15:19:20 -0400 |
| commit | 4cb899f824ee5e4421f36506e4c77f682b238b09 (patch) | |
| tree | c348029866666fad59531032ba76f325d67c32ab /source/core/slang-rtti-info.cpp | |
| parent | 1036d1a9edec83d8840577f388af8599b5e18f5f (diff) | |
Preliminary SourceMap support (#2701)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP source map.
* Split out handling of RttiTypeFuncs to a map type.
* Make RttiTypeFuncsMap hold default impls.
* Slightly more sophisticated RttiTypeFuncsMap
* Source map decoding.
* Fix tabs.
* Fix asserts due to negative values.
* Use less obscure mechanisms in SourceMap.
Diffstat (limited to 'source/core/slang-rtti-info.cpp')
| -rw-r--r-- | source/core/slang-rtti-info.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/core/slang-rtti-info.cpp b/source/core/slang-rtti-info.cpp index 043e6490a..c35444d03 100644 --- a/source/core/slang-rtti-info.cpp +++ b/source/core/slang-rtti-info.cpp @@ -2,6 +2,8 @@ #include "../../slang-com-helper.h" +#include "slang-rtti-util.h" + #include <mutex> namespace Slang { @@ -191,4 +193,35 @@ StructRttiInfo StructRttiBuilder::make() return m_rttiInfo; } +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RttiTypeFuncsMap !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +RttiTypeFuncs RttiTypeFuncsMap::getFuncsForType(const RttiInfo* rttiInfo) +{ + if (auto funcsPtr = m_map.TryGetValue(rttiInfo)) + { + return *funcsPtr; + } + + // Try to get the default impl + // NOTE! funcs could be invalid if there is no default impl. + const auto funcs = RttiUtil::getDefaultTypeFuncs(rttiInfo); + + // Add to the map + m_map.Add(rttiInfo, funcs); + return funcs; +} + +void RttiTypeFuncsMap::add(const RttiInfo* rttiInfo, const RttiTypeFuncs& funcs) +{ + if (auto funcsPtr = m_map.TryGetValueOrAdd(rttiInfo, funcs)) + { + // If there are funcs set, they aren't valid otherwise this would be + // replacing, so assert on that scenario. + SLANG_ASSERT(!funcsPtr->isValid()); + + // Replace the funcs + *funcsPtr = funcs; + } +} + } // namespace Slang |
