From e140c4950eb8c69606386ca57284c0655513b9e1 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 18 Nov 2020 18:12:43 -0500 Subject: Test for serializing out and reading back Stdlib (#1605) * #include an absolute path didn't work - because paths were taken to always be relative. * Mangling/module name extraction for GenericDecl * Add comment on SerialFilter to explain re-enabling Stmt. * Support setting up SyntaxDecl when reconstructed after deserialization. * Improvements to setup SyntaxDecl. * Fix typo so can read compressed SourceLocs. * Fix issue with SourceManger. * Simple test for serializing out stdlib and reading back in. * Fix calling convention. * Add override to StdLib impls. * Fix typo. * Apply testing to an actual compute test when using load-stdlib Make -load/compile-stdlib processable by Slang Move out testing into util into TestToolUtil so can be shared. * Slightly more concise setup of session. * Fix some errors introduced with session handling. * Made setup for compile same across slangc and slangc-tool. --- source/core/slang-test-tool-util.cpp | 13 +++++++++++++ source/core/slang-test-tool-util.h | 3 +++ 2 files changed, 16 insertions(+) (limited to 'source/core') diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index f06095ada..68673a29f 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -37,6 +37,19 @@ namespace Slang } } +/* static */bool TestToolUtil::hasDeferredStdLib(Index argc, const char*const* argv) +{ + for (Index i = 0; i < argc; ++i) + { + UnownedStringSlice option(argv[i]); + if (option == "-load-stdlib" || option == "-compile-stdlib") + { + return true; + } + } + return false; +} + /* static */SlangResult TestToolUtil::getIncludePath(const String& parentPath, const char* path, String& outIncludePath) { String includePath; diff --git a/source/core/slang-test-tool-util.h b/source/core/slang-test-tool-util.h index 07532682b..186003a62 100644 --- a/source/core/slang-test-tool-util.h +++ b/source/core/slang-test-tool-util.h @@ -63,6 +63,9 @@ struct TestToolUtil /// Sets the default preludes on the session based on the executable path static SlangResult setSessionDefaultPreludeFromExePath(const char* exePath, slang::IGlobalSession* session); + + /// Returns true if the StdLib should not be initialized immediately (eg when doing a -load-stdlib). + static bool hasDeferredStdLib(Index numArgs, const char*const* args); }; } // namespace Slang -- cgit v1.2.3