diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/core/exception.h | 7 | ||||
| -rw-r--r-- | source/slang/lower.cpp | 65 |
2 files changed, 68 insertions, 4 deletions
diff --git a/source/core/exception.h b/source/core/exception.h index 6739c6778..dc674de7f 100644 --- a/source/core/exception.h +++ b/source/core/exception.h @@ -110,6 +110,13 @@ namespace Slang { } }; + + #define SLANG_UNEXPECTED(reason) \ + throw Slang::Exception("unexpected: " reason) + + #define SLANG_UNIMPLEMENTED_X(what) \ + throw Slang::NotImplementedException("unimplemented: " what) + } #endif
\ No newline at end of file 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<Decl> visit( - Decl* decl) + + RefPtr<Decl> visit(ModifierDecl*) { - assert(!"unimplemented"); - return decl; + // should not occur in user code + SLANG_UNEXPECTED("modifiers shouldn't occur in user code"); + } + + RefPtr<Decl> visit(GenericValueParamDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr<Decl> visit(GenericTypeParamDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr<Decl> visit(GenericTypeConstraintDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr<Decl> visit(GenericDecl*) + { + SLANG_UNEXPECTED("generics should be lowered to specialized decls"); + } + + RefPtr<Decl> visit(ProgramSyntaxNode*) + { + SLANG_UNEXPECTED("module decls should be lowered explicitly"); + } + + RefPtr<Decl> visit(SubscriptDecl*) + { + // We don't expect to find direct references to a subscript + // declaration, but rather to the underlying accessors + return nullptr; + } + + RefPtr<Decl> visit(InheritanceDecl*) + { + // We should deal with these explicitly, as part of lowering + // the type that contains them. + return nullptr; + } + + RefPtr<Decl> visit(ExtensionDecl*) + { + // Extensions won't exist in the lowered code: their members + // will turn into ordinary functions that get called explicitly + return nullptr; + } + + RefPtr<Decl> visit(TypeDefDecl* decl) + { + RefPtr<TypeDefDecl> loweredDecl = new TypeDefDecl(); + lowerDeclCommon(loweredDecl, decl); + + loweredDecl->Type = lowerType(decl->Type); + + addMember(shared->loweredProgram, loweredDecl); + return loweredDecl; } RefPtr<ImportDecl> visit(ImportDecl* decl) |
