diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:29:59 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:29:59 -0700 |
| commit | e05fba99e9f4fa08b6252e31c39b0d5ac2d23a34 (patch) | |
| tree | c8b32aad918f61d93165282171619c8d43023554 /source | |
| parent | 03de737f0d18526b99b59a1810c7e290b66f4be2 (diff) | |
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`.
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) |
