summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-builder.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-06-11 12:49:04 -0700
committerGitHub <noreply@github.com>2021-06-11 12:49:04 -0700
commit746ee0dc5bddeea177aaf609bcc5085b46c4057c (patch)
tree699e24ca1c1d6889afed9c6e0b1418d637603df9 /source/slang/slang-ast-builder.cpp
parent37e8917d10626b519470f2e34625f0efe741352f (diff)
Properly fill `declref` in `Linkage::getContainerType`. (#1882)
* Properly fill `declref` in `Linkage::getContainerType`. * Fix timestamp query on cpu * Fix typo. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
-rw-r--r--source/slang/slang-ast-builder.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index 240b39d6c..4948a68a6 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -257,6 +257,29 @@ VectorExpressionType* ASTBuilder::getVectorType(
return as<VectorExpressionType>(DeclRefType::create(this, declRef));
}
+DeclRef<Decl> ASTBuilder::getBuiltinDeclRef(const char* builtinMagicTypeName, ConstArrayView<Val*> genericArgs)
+{
+ DeclRef<Decl> declRef;
+ declRef.decl = m_sharedASTBuilder->findMagicDecl(builtinMagicTypeName);
+ if (auto genericDecl = as<GenericDecl>(declRef.decl))
+ {
+ if (genericArgs.getCount())
+ {
+ auto substitutions = create<GenericSubstitution>();
+ substitutions->genericDecl = genericDecl;
+ for (auto arg : genericArgs)
+ substitutions->args.add(arg);
+ declRef.substitutions = substitutions;
+ }
+ declRef.decl = genericDecl->inner;
+ }
+ else
+ {
+ SLANG_ASSERT(genericArgs.getCount() == 0);
+ }
+ return declRef;
+}
+
Type* ASTBuilder::getAndType(Type* left, Type* right)
{
auto type = create<AndType>();