From e05fba99e9f4fa08b6252e31c39b0d5ac2d23a34 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 6 Jul 2017 11:29:59 -0700 Subject: Add missing declaration types to lowering pass. Most of these are cases we don't expect to encounter, but the big missing one was `TypeDefDecl`. --- source/slang/lower.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'source/slang/lower.cpp') diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index e03fd878b..8a732467c 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -826,11 +826,68 @@ struct LoweringVisitor } // Catch-all - RefPtr visit( - Decl* decl) + + RefPtr visit(ModifierDecl*) { - assert(!"unimplemented"); - return decl; + // should not occur in user code + SLANG_UNEXPECTED("modifiers shouldn't occur in user code"); + } + + RefPtr visit(GenericValueParamDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr visit(GenericTypeParamDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr visit(GenericTypeConstraintDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr visit(GenericDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr visit(ProgramSyntaxNode*) + { + SLANG_UNEXPECTED("module decls should be lowered explicitly"); + } + + RefPtr visit(SubscriptDecl*) + { + // We don't expect to find direct references to a subscript + // declaration, but rather to the underlying accessors + return nullptr; + } + + RefPtr visit(InheritanceDecl*) + { + // We should deal with these explicitly, as part of lowering + // the type that contains them. + return nullptr; + } + + RefPtr visit(ExtensionDecl*) + { + // Extensions won't exist in the lowered code: their members + // will turn into ordinary functions that get called explicitly + return nullptr; + } + + RefPtr visit(TypeDefDecl* decl) + { + RefPtr loweredDecl = new TypeDefDecl(); + lowerDeclCommon(loweredDecl, decl); + + loweredDecl->Type = lowerType(decl->Type); + + addMember(shared->loweredProgram, loweredDecl); + return loweredDecl; } RefPtr visit(ImportDecl* decl) -- cgit v1.2.3