diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-04 15:47:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-04 15:47:39 -0700 |
| commit | a2d90fb275962da84611160f8ddd74d934a68dbd (patch) | |
| tree | 066084537b9f4fe1f367de100ed6638a88a028c1 /source/slang/slang-ast-base.cpp | |
| parent | 17da4f0dec2b86ba3a4bdaf8a2ae112047d23623 (diff) | |
Redesign `DeclRef` and systematic `Val` deduplication (#3049)
* Redesign DeclRef + Deduplicate Val.
* Update project files
* Fix warning.
* Fix.
* Fix.
* Remove `Val::_equalsImplOverride`.
* Rmove `Val::_getHashCodeOverride`.
* Remove `semanticVisitor` param from `resolve`.
* Cleanups.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-base.cpp')
| -rw-r--r-- | source/slang/slang-ast-base.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/slang/slang-ast-base.cpp b/source/slang/slang-ast-base.cpp new file mode 100644 index 000000000..0ad2bb101 --- /dev/null +++ b/source/slang/slang-ast-base.cpp @@ -0,0 +1,33 @@ +#include "slang-ast-base.h" +#include "slang-ast-builder.h" + +namespace Slang +{ +void NodeBase::_initDebug(ASTNodeType inAstNodeType, ASTBuilder* inAstBuilder) +{ +#ifdef _DEBUG + SLANG_UNUSED(inAstNodeType); + static int32_t uidCounter = 0; + static int32_t breakValue = 0; + uidCounter++; + _debugUID = uidCounter; + if (inAstBuilder->getId() == -1) + _debugUID = -_debugUID; + if (breakValue != 0 && _debugUID == breakValue) + SLANG_BREAKPOINT(0) +#else + SLANG_UNUSED(inAstNodeType); + SLANG_UNUSED(inAstBuilder); +#endif +} +DeclRefBase* Decl::getDefaultDeclRef() +{ + auto astBuilder = getCurrentASTBuilder(); + if (astBuilder->getEpoch() != m_defaultDeclRefEpoch || !m_defaultDeclRef) + { + m_defaultDeclRef = astBuilder->getDirectDeclRef(this); + m_defaultDeclRefEpoch = astBuilder->getEpoch(); + } + return m_defaultDeclRef; +} +} |
