From a083a37ee58dc48d92cf2b844466a295eb3e643e Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 Aug 2022 15:37:19 -0700 Subject: Add `none` literal that is convertible to `Optional`. (#2356) * Add `none` literal that is convertible to `Optional`. * Fix cpu code gen. * Include vk and cpu test for is-as operator test. * Inline comparison operators. Co-authored-by: Yong He --- source/slang/slang-ast-builder.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/slang-ast-builder.cpp') diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 2acdc26d3..fa8051171 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -131,6 +131,16 @@ Type* SharedASTBuilder::getNullPtrType() return m_nullPtrType; } +Type* SharedASTBuilder::getNoneType() +{ + if (!m_noneType) + { + auto noneTypeDecl = findMagicDecl("NoneType"); + m_noneType = DeclRefType::create(m_astBuilder, makeDeclRef(noneTypeDecl)); + } + return m_noneType; +} + SharedASTBuilder::~SharedASTBuilder() { // Release built in types.. -- cgit v1.2.3