diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-05 05:49:42 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-05 05:49:42 -0500 |
| commit | ff7c46a11787ca6ecebf0a224772a41efef33fc0 (patch) | |
| tree | bff41e36c9b6843d83a5ca5e83645310be6687f3 /source | |
| parent | 0d250f0d49e9e29d143c5794671669ea025b357e (diff) | |
small cleanups
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/check.cpp | 2 | ||||
| -rw-r--r-- | source/slang/ir.cpp | 4 | ||||
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 7 |
3 files changed, 10 insertions, 3 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 79a4f28cf..ed2ed4a1b 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -1662,6 +1662,8 @@ namespace Slang return false; auto structTypeDecl = declRefType->declRef.getDecl()->As<AggTypeDecl>(); + if (!structTypeDecl) + return false; //TODO: What do we do if type is a generic specialization? // i.e. if the struct defines typedef Generic<float> T; // how to check if T satisfies the associatedtype constraints? diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 04569771a..ab961a159 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -562,11 +562,13 @@ namespace Slang IRValue * IRBuilder::getTypeVal(IRType * type) { - auto irValue = createValue<IRDeclRef>( + auto irValue = createValue<IRValue>( this, kIROp_TypeType, nullptr); irValue->type = type; + if (auto typetype = dynamic_cast<TypeType*>(type)) + irValue->type = typetype->type; return irValue; } diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index be91b9d3d..2672c5698 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -2311,8 +2311,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> ensureDecl(context, inheritanceDecl); } - // For now, we don't have an IR-level representation - // for the type itself. + // TODO: we currently store a Decl* in the witness table, which causes this function + // being invoked to translate the witness table entry into an IRValue. + // We should really allow a witness table entry to represent a type and not having to + // construct the type here. The current implementation will not work when the struct type + // is defined in a generic parent (we lose the environmental substitutions). return LoweredValInfo::simple(context->irBuilder->getTypeVal(DeclRefType::Create(context->getSession(), DeclRef<Decl>(decl, nullptr)))); } |
