diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-check-impl.h | 8 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 6 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h index f0c6d693d..d90c3c4b0 100644 --- a/source/slang/slang-check-impl.h +++ b/source/slang/slang-check-impl.h @@ -798,7 +798,13 @@ namespace Slang : m_shared(shared) , m_sink(shared->getSink()) , m_astBuilder(shared->getLinkage()->getASTBuilder()) - {} + { + if (shared->getLinkage()->m_optionSet.hasOption(CompilerOptionName::DisableShortCircuit)) + { + m_shouldShortCircuitLogicExpr = + !shared->getLinkage()->m_optionSet.getBoolOption(CompilerOptionName::DisableShortCircuit); + } + } SharedSemanticsContext* getShared() { return m_shared; } CompilerOptionSet& getOptionSet() { return getShared()->getOptionSet(); } diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index dad69350e..7337b9210 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -343,6 +343,7 @@ void initCommandOptions(CommandOptions& options) "The name used as the basis for variables output for source embedding."}, { OptionKind::SourceEmbedLanguage, "-source-embed-language", "-source-embed-language <language>", "The language to be used for source embedding. Defaults to C/C++. Currently only C/C++ are supported"}, + { OptionKind::DisableShortCircuit, "-disable-short-circuit", nullptr, "Disable short-circuiting for \"&&\" and \"||\" operations" }, }; _addOptions(makeConstArrayView(generalOpts), options); @@ -2298,6 +2299,11 @@ SlangResult OptionsParser::_parse( break; } + case OptionKind::DisableShortCircuit: + { + linkage->m_optionSet.add(OptionKind::DisableShortCircuit, true); + break; + } default: { // Hmmm, we looked up and produced a valid enum, but it wasn't handled in the switch... diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 4a446a351..112ec2058 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -170,6 +170,7 @@ void Session::init() // Built in linkage uses the built in builder m_builtinLinkage = new Linkage(this, builtinAstBuilder, nullptr); m_builtinLinkage->m_optionSet.set(CompilerOptionName::DebugInformation, DebugInfoLevel::None); + m_builtinLinkage->m_optionSet.set(CompilerOptionName::DisableShortCircuit, true); // Because the `Session` retains the builtin `Linkage`, // we need to make sure that the parent pointer inside |
