diff options
| author | Yong He <yonghe@outlook.com> | 2024-12-11 13:34:54 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-11 13:34:54 -0800 |
| commit | 941f07040a505f1f673c96da959bde839c629aba (patch) | |
| tree | fe5cd3cd0a63919ad8971d32cd18e8161f9cbd99 /source | |
| parent | e50aac13e2c161d672b137a62f6d66820d0f9ff1 (diff) | |
Fix attribute reflection. (#5823)
* Fix attribute reflection.
* Fix.
* Fix.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-modifier.cpp | 15 | ||||
| -rw-r--r-- | source/slang/slang-reflection-api.cpp | 10 |
2 files changed, 12 insertions, 13 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index aebfe3b96..05eb978bc 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -752,18 +752,15 @@ Modifier* SemanticsVisitor::validateAttribute( { auto& arg = attr->args[paramIndex]; bool typeChecked = false; - if (auto basicType = as<BasicExpressionType>(paramDecl->getType())) + if (isValidCompileTimeConstantType(paramDecl->getType())) { - if (basicType->getBaseType() == BaseType::Int) + if (auto cint = checkConstantIntVal(arg)) { - if (auto cint = checkConstantIntVal(arg)) - { - for (Index ci = attr->intArgVals.getCount(); ci < paramIndex + 1; ci++) - attr->intArgVals.add(nullptr); - attr->intArgVals[(uint32_t)paramIndex] = cint; - } - typeChecked = true; + for (Index ci = attr->intArgVals.getCount(); ci < paramIndex + 1; ci++) + attr->intArgVals.add(nullptr); + attr->intArgVals[(uint32_t)paramIndex] = cint; } + typeChecked = true; } if (!typeChecked) { diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index 93e495194..d7f793d05 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -23,11 +23,11 @@ namespace Slang // Conversion routines to help with strongly-typed reflection API -static inline UserDefinedAttribute* convert(SlangReflectionUserAttribute* attrib) +static inline Attribute* convert(SlangReflectionUserAttribute* attrib) { - return (UserDefinedAttribute*)attrib; + return (Attribute*)attrib; } -static inline SlangReflectionUserAttribute* convert(UserDefinedAttribute* attrib) +static inline SlangReflectionUserAttribute* convert(Attribute* attrib) { return (SlangReflectionUserAttribute*)attrib; } @@ -154,7 +154,9 @@ static SlangReflectionUserAttribute* findUserAttributeByName( const char* name) { auto nameObj = session->tryGetNameObj(name); - for (auto x : decl->getModifiersOfType<UserDefinedAttribute>()) + if (!nameObj) + return nullptr; + for (auto x : decl->getModifiersOfType<Attribute>()) { if (x->keywordName == nameObj) return (SlangReflectionUserAttribute*)(x); |
