diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-20 01:03:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 01:03:06 -0700 |
| commit | af70651a4843b16dd24e14b5cedffe399ebeb862 (patch) | |
| tree | a6aefd5db94a048114b9a8d7ed3f826533105fab /source/slang/slang-lower-to-ir.cpp | |
| parent | 6412c4913b6a063438bb11863f2c154d3ae42dfe (diff) | |
Call `gfx` in slang program. (#2370)
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 1f3da064a..1285afca8 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1185,6 +1185,31 @@ static void addLinkageDecoration( addLinkageDecoration(context, inst, decl, mangledName.getUnownedSlice()); } +bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl) +{ + if (auto funcDecl = as<CallableDecl>(requirementDecl)) + { + } + else if (auto propertyDecl = as<PropertyDecl>(requirementDecl)) + { + } + else if (auto assocTypeDecl = as<AssocTypeDecl>(requirementDecl)) + { + } + else if (auto typeConstraint = as<TypeConstraintDecl>(requirementDecl)) + { + } + else if (auto genericDecl = as<GenericDecl>(requirementDecl)) + { + return shouldDeclBeTreatedAsInterfaceRequirement(genericDecl->inner); + } + else + { + return false; + } + return true; +} + IRStructKey* getInterfaceRequirementKey( IRGenContext* context, Decl* requirementDecl) @@ -1195,6 +1220,12 @@ IRStructKey* getInterfaceRequirementKey( // decl as the requirement key. if (auto genericDecl = as<GenericDecl>(requirementDecl)) return getInterfaceRequirementKey(context, genericDecl->inner); + + // Only specific types of decls are treated as requirements, e.g. methods and asssociated types. + // Other types of decls are allowed but not regarded as a requirement. + if (!shouldDeclBeTreatedAsInterfaceRequirement(requirementDecl)) + return nullptr; + IRStructKey* requirementKey = nullptr; if(context->shared->interfaceRequirementKeys.TryGetValue(requirementDecl, requirementKey)) { @@ -1356,6 +1387,9 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower // auto irReqKey = getInterfaceRequirementKey(context, reqDeclRef.getDecl()); + if (!irReqKey) + continue; + // We expect that each of the witness tables in `caseWitnessTables` // will have an entry to match these keys. However, we may not // have a concrete `IRWitnessTable` for each of the case types, either @@ -5866,6 +5900,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> auto satisfyingWitness = entry.Value; auto irRequirementKey = getInterfaceRequirementKey(requiredMemberDecl); + if (!irRequirementKey) continue; + IRInst* irSatisfyingVal = nullptr; switch(satisfyingWitness.getFlavor()) @@ -6613,6 +6649,9 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> UInt operandCount = 0; for (auto requirementDecl : decl->members) { + if (!shouldDeclBeTreatedAsInterfaceRequirement(requirementDecl)) + continue; + operandCount++; // As a special case, any type constraints placed // on an associated type will *also* need to be turned @@ -6647,8 +6686,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> for (auto requirementDecl : decl->members) { + auto requirementKey = getInterfaceRequirementKey(requirementDecl); + if (!requirementKey) continue; auto entry = subBuilder->createInterfaceRequirementEntry( - getInterfaceRequirementKey(requirementDecl), + requirementKey, nullptr); if (auto inheritance = as<InheritanceDecl>(requirementDecl)) { @@ -8551,6 +8592,13 @@ static void ensureAllDeclsRec( ensureAllDeclsRec(context, memberDecl); } } + else if (auto namespaceDecl = as<NamespaceDecl>(decl)) + { + for (auto memberDecl : namespaceDecl->members) + { + ensureAllDeclsRec(context, memberDecl); + } + } else if (auto genericDecl = as<GenericDecl>(decl)) { ensureAllDeclsRec(context, genericDecl->inner); |
