diff options
| author | Yong He <yonghe@outlook.com> | 2022-11-01 08:46:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-01 08:46:57 -0700 |
| commit | cbc1eff56057f199183bb7c17d8a360326512367 (patch) | |
| tree | 487865e928cd2ceecbb509f0bfd06aa8d9584411 /source/slang/slang-ast-builder.cpp | |
| parent | b707a07b1de3535cb0a8ccb6fe2ed4afa4a016d1 (diff) | |
Make `DifferentialPair` able to nest. (#2477)
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index f6c550d69..beee16f9c 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -141,6 +141,16 @@ Type* SharedASTBuilder::getNoneType() return m_noneType; } +Type* SharedASTBuilder::getDifferentialBottomType() +{ + if (!m_diffBottomType) + { + auto diffBottomTypeDecl = findMagicDecl("DifferentialBottomType"); + m_diffBottomType = DeclRefType::create(m_astBuilder, makeDeclRef<Decl>(diffBottomTypeDecl)); + } + return m_diffBottomType; +} + SharedASTBuilder::~SharedASTBuilder() { // Release built in types.. @@ -299,13 +309,18 @@ VectorExpressionType* ASTBuilder::getVectorType( return result; } -DifferentialPairType* ASTBuilder::getDifferentialPairType(Type* valueType, Witness* conformanceWitness) +DifferentialPairType* ASTBuilder::getDifferentialPairType( + Type* valueType, + Witness* primalIsDifferentialWitness) { auto genericDecl = dynamicCast<GenericDecl>(m_sharedASTBuilder->findMagicDecl("DifferentialPairType")); auto typeDecl = genericDecl->inner; - auto substitutions = getOrCreate<GenericSubstitution>(genericDecl, valueType, conformanceWitness); + auto substitutions = getOrCreate<GenericSubstitution>( + genericDecl, + valueType, + primalIsDifferentialWitness); auto declRef = DeclRef<Decl>(typeDecl, substitutions); auto rsType = DeclRefType::create(this, declRef); |
