summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ast-print.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-10-08 13:29:57 -0700
committerGitHub <noreply@github.com>2024-10-08 13:29:57 -0700
commitc42a9faad8d84f7bd05457d5f8e1fe45d6eecfa2 (patch)
treef6b5a249074882755e0232b1c9560118b7ccd6b2 /source/slang/slang-ast-print.cpp
parent50f44c178de4c614dc45fc48938e6881c0373f6a (diff)
Overhaul docgen tool and setup CI to generate stdlib reference. (#5232)
* Overhaul docgen tool and setup CI to generate stdlib reference. * Fix build error. * Write parsed doc for all decls. * fix. * fix callout. * Fix. * Fix comment. * Fix. * Delete obsolete doc tests. * Fix. * Categorize functions and types. * Fix CI. * Update comments.
Diffstat (limited to 'source/slang/slang-ast-print.cpp')
-rw-r--r--source/slang/slang-ast-print.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/source/slang/slang-ast-print.cpp b/source/slang/slang-ast-print.cpp
index f5f99f01d..f3ed4ee0b 100644
--- a/source/slang/slang-ast-print.cpp
+++ b/source/slang/slang-ast-print.cpp
@@ -1,6 +1,8 @@
// slang-ast-print.cpp
#include "slang-ast-print.h"
+#include "core/slang-char-util.h"
+
#include "slang-check-impl.h"
namespace Slang {
@@ -81,7 +83,11 @@ void ASTPrinter::addVal(Val* val)
}
else
{
- out << getText(decl->getName());
+ auto text = getText(decl->getName());
+ if (text.getLength() && !(CharUtil::isAlphaOrDigit(text[0]) || text[0] == '_'))
+ out << "operator" << text;
+ else
+ out << text;
}
}
@@ -140,6 +146,13 @@ void ASTPrinter::_addDeclPathRec(const DeclRef<Decl>& declRef, Index depth)
{
ExtensionDecl* extensionDecl = as<ExtensionDecl>(parentDeclRef.getDecl());
Type* type = extensionDecl->targetType.type;
+ if (m_optionFlags & OptionFlag::NoSpecializedExtensionTypeName)
+ {
+ if (auto unspecializedDeclRef = isDeclRefTypeOf<Decl>(type))
+ {
+ type = DeclRefType::create(m_astBuilder, unspecializedDeclRef.getDecl()->getDefaultDeclRef());
+ }
+ }
addType(type);
sb << toSlice(".");
}