From 17e3b88b541ed7f45d575f0f9caaa808cd0a6619 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 1 Jun 2022 17:37:07 -0700 Subject: New language feature: basic error handling. (#2253) * New language feature: basic error handling. * Fix. * Fix `tryCall` encoding according to code review. Co-authored-by: Yong He --- source/slang/slang-syntax.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-syntax.cpp') diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index b9a5b8cd5..24ccfa4a4 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -1057,6 +1057,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt FuncType* funcType = astBuilder->create(); funcType->resultType = getResultType(astBuilder, declRef); + funcType->errorType = getErrorCodeType(astBuilder, declRef); for (auto paramDeclRef : getParameters(declRef)) { auto paramDecl = paramDeclRef.getDecl(); @@ -1269,9 +1270,27 @@ char const* getGLSLNameForImageFormat(ImageFormat format) return kImageFormatInfos[Index(format)].name.begin(); } - const ImageFormatInfo& getImageFormatInfo(ImageFormat format) - { - return kImageFormatInfos[Index(format)]; - } + +const ImageFormatInfo& getImageFormatInfo(ImageFormat format) +{ + return kImageFormatInfos[Index(format)]; +} + +char const* getTryClauseTypeName(TryClauseType c) +{ + switch (c) + { + case TryClauseType::None: + return "None"; + case TryClauseType::Standard: + return "Standard"; + case TryClauseType::Optional: + return "Optional"; + case TryClauseType::Assert: + return "Assert"; + default: + return "Unknown"; + } +} } // namespace Slang -- cgit v1.2.3