diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-17 13:08:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-17 13:08:27 -0700 |
| commit | cd7f01b63a52eaaad00088524801e502bcb0f168 (patch) | |
| tree | a04b6d9f2f7f85466b537a8aedeb3795339fae71 /source/slang/slang-lower-to-ir.cpp | |
| parent | ca503d48bff31d3990d4740751d5f6a4a48bfe5a (diff) | |
Generate dynamic C++ code for the minimal test case. (#1391)
* Add IR pass to lower generics into ordinary functions.
* Fix project files
* Emit dynamic C++ code for simple generics and witness tables.
Fixes #1386.
* Remove -dump-ir flag.
* Fixups.
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index fa23b3307..01bd0e972 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1034,7 +1034,8 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower LoweredValInfo visitDeclaredSubtypeWitness(DeclaredSubtypeWitness* val) { return emitDeclRef(context, val->declRef, - context->irBuilder->getWitnessTableType()); + context->irBuilder->getWitnessTableType( + lowerType(context, DeclRefType::create(context->astBuilder, val->declRef)))); } LoweredValInfo visitTransitiveSubtypeWitness( @@ -4480,8 +4481,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { // This is a constraint on a global generic type parameters, // and so it should lower as a parameter of its own. - - auto inst = getBuilder()->emitGlobalGenericWitnessTableParam(); + auto supType = lowerType(context, decl->getSup().type); + auto inst = getBuilder()->emitGlobalGenericWitnessTableParam(supType); addLinkageDecoration(context, inst, decl); return LoweredValInfo::simple(inst); } @@ -5728,7 +5729,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { // TODO: use a `TypeKind` to represent the // classifier of the parameter. - auto param = subBuilder->emitParam(nullptr); + auto param = subBuilder->emitParam(subBuilder->getTypeType()); addNameHint(context, param, typeParamDecl); setValue(subContext, typeParamDecl, LoweredValInfo::simple(param)); } @@ -5748,7 +5749,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { // TODO: use a `WitnessTableKind` to represent the // classifier of the parameter. - auto param = subBuilder->emitParam(nullptr); + auto param = subBuilder->emitParam(subBuilder->getWitnessTableType( + lowerType(context, constraintDecl->sup.type))); addNameHint(context, param, constraintDecl); setValue(subContext, constraintDecl, LoweredValInfo::simple(param)); } @@ -6590,12 +6592,15 @@ IRInst* lowerSubstitutionArg( else if (auto declaredSubtypeWitness = as<DeclaredSubtypeWitness>(val)) { // We need to look up the IR-level representation of the witness (which will be a witness table). + auto supType = lowerType( + context, + DeclRefType::create(context->astBuilder, declaredSubtypeWitness->declRef)); auto irWitnessTable = getSimpleVal( context, emitDeclRef( context, declaredSubtypeWitness->declRef, - context->irBuilder->getWitnessTableType())); + context->irBuilder->getWitnessTableType(supType))); return irWitnessTable; } else |
