summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-13 03:29:36 -0800
committerGitHub <noreply@github.com>2025-02-13 19:29:36 +0800
commitccc75cdd9508a4e19efa22e7c911cc2013f514fa (patch)
tree6cc198fcb0d5a58b58f56705ef134bbd5f584587 /source/slang/slang.cpp
parent8406b5647a61fb70be4e041a76c1b64b05a70452 (diff)
Reflection Fixes. (#6346)
* Fix 6317. * Fixes #6316. * Fix cmake preset. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index ee0aa4c14..c316974f1 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -2714,6 +2714,16 @@ Expr* ComponentType::findDeclFromString(String const& name, DiagnosticSink* sink
return result;
}
+bool isSimpleName(String const& name)
+{
+ for (char c : name)
+ {
+ if (!CharUtil::isAlphaOrDigit(c) && c != '_' && c != '$')
+ return false;
+ }
+ return true;
+}
+
Expr* ComponentType::findDeclFromStringInType(
Type* type,
String const& name,
@@ -2743,8 +2753,19 @@ Expr* ComponentType::findDeclFromStringInType(
SLANG_AST_BUILDER_RAII(linkage->getASTBuilder());
- Expr* expr = linkage->parseTermString(name, scope);
+ Expr* expr = nullptr;
+ if (isSimpleName(name))
+ {
+ auto varExpr = astBuilder->create<VarExpr>();
+ varExpr->scope = scope;
+ varExpr->name = getLinkage()->getNamePool()->getName(name);
+ expr = varExpr;
+ }
+ else
+ {
+ expr = linkage->parseTermString(name, scope);
+ }
SemanticsContext context(linkage->getSemanticsForReflection());
context = context.allowStaticReferenceToNonStaticMember().withSink(sink);