diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-15 09:05:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-15 09:05:49 -0700 |
| commit | 7e7425de730d7b3f4590c71111e22e5103b53200 (patch) | |
| tree | 9cdaee6b9deb0a94e40526b698ae13a1dc88da36 /source/slang/slang-lower-to-ir.cpp | |
| parent | 04a81ab634ce058168f7e1554274bbeb34f3a3c5 (diff) | |
| parent | 90444f8366255f274993ce4699738d9ab7cf4ee1 (diff) | |
Merge branch 'master' into glsl-loop
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index a1089b537..42f53ef22 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1105,7 +1105,8 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower UNREACHABLE_RETURN(LoweredValInfo()); } - auto irWitnessTable = getBuilder()->createWitnessTable(); + auto irWitnessTableBaseType = lowerType(context, supDeclRefType); + auto irWitnessTable = getBuilder()->createWitnessTable(irWitnessTableBaseType); // Now we will iterate over the requirements (members) of the // interface and try to synthesize an appropriate value for each. @@ -4524,7 +4525,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> if(!mapASTToIRWitnessTable.TryGetValue(astReqWitnessTable, irSatisfyingWitnessTable)) { // Need to construct a sub-witness-table - irSatisfyingWitnessTable = subBuilder->createWitnessTable(); + auto irWitnessTableBaseType = lowerType(subContext, astReqWitnessTable->baseType); + irSatisfyingWitnessTable = subBuilder->createWitnessTable(irWitnessTableBaseType); // Recursively lower the sub-table. lowerWitnessTable( @@ -4637,10 +4639,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // and we need those parameters to lower as references to // the parameters of our IR-level generic. // - lowerType(subContext, superType); + auto irWitnessTableBaseType = lowerType(subContext, superType); // Create the IR-level witness table - auto irWitnessTable = subBuilder->createWitnessTable(); + auto irWitnessTable = subBuilder->createWitnessTable(irWitnessTableBaseType); addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice()); // Register the value now, rather than later, to avoid any possible infinite recursion. @@ -5243,9 +5245,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // a witness table for the interface type's conformance // to its own interface. // + List<IRStructKey*> requirementKeys; for (auto requirementDecl : decl->members) { - getInterfaceRequirementKey(requirementDecl); + requirementKeys.add(getInterfaceRequirementKey(requirementDecl)); // As a special case, any type constraints placed // on an associated type will *also* need to be turned @@ -5254,7 +5257,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { for (auto constraintDecl : associatedTypeDecl->getMembersOfType<TypeConstraintDecl>()) { - getInterfaceRequirementKey(constraintDecl); + requirementKeys.add(getInterfaceRequirementKey(constraintDecl)); } } } @@ -5267,11 +5270,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // Emit any generics that should wrap the actual type. emitOuterGenerics(subContext, decl, decl); - IRInterfaceType* irInterface = subBuilder->createInterfaceType(); + IRInterfaceType* irInterface = subBuilder->createInterfaceType( + requirementKeys.getCount(), + reinterpret_cast<IRInst**>(requirementKeys.getBuffer())); addNameHint(context, irInterface, decl); addLinkageDecoration(context, irInterface, decl); subBuilder->setInsertInto(irInterface); - // TODO: are there any interface members that should be // nested inside the interface type itself? |
