diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-08 17:34:50 +0000 |
| commit | 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch) | |
| tree | 62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/lldb/source/API/SBScriptObject.cpp | |
| parent | cf037972ea8863e2bab7461d77345367d2c1e054 (diff) | |
| parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) | |
Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.
PR: 273753
MFC after: 1 month
Diffstat (limited to 'contrib/llvm-project/lldb/source/API/SBScriptObject.cpp')
| -rw-r--r-- | contrib/llvm-project/lldb/source/API/SBScriptObject.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/llvm-project/lldb/source/API/SBScriptObject.cpp b/contrib/llvm-project/lldb/source/API/SBScriptObject.cpp new file mode 100644 index 000000000000..3e067d0ab1ee --- /dev/null +++ b/contrib/llvm-project/lldb/source/API/SBScriptObject.cpp @@ -0,0 +1,84 @@ +//===-- SBScriptObject.cpp ------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBScriptObject.h" + +#include "Utils.h" + +#include "lldb/Interpreter/ScriptObject.h" +#include "lldb/Utility/Instrumentation.h" + +using namespace lldb; +using namespace lldb_private; + +SBScriptObject::SBScriptObject(const ScriptObjectPtr ptr, + lldb::ScriptLanguage lang) + : m_opaque_up(std::make_unique<lldb_private::ScriptObject>(ptr, lang)) { + LLDB_INSTRUMENT_VA(this, ptr, lang); +} + +SBScriptObject::SBScriptObject(const SBScriptObject &rhs) + : m_opaque_up(new ScriptObject(nullptr, eScriptLanguageNone)) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} +SBScriptObject::~SBScriptObject() = default; + +const SBScriptObject &SBScriptObject::operator=(const SBScriptObject &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +bool SBScriptObject::operator!=(const SBScriptObject &rhs) const { + LLDB_INSTRUMENT_VA(this, rhs); + + return !(m_opaque_up == rhs.m_opaque_up); +} + +bool SBScriptObject::IsValid() const { + LLDB_INSTRUMENT_VA(this); + + return this->operator bool(); +} + +SBScriptObject::operator bool() const { + LLDB_INSTRUMENT_VA(this); + + return m_opaque_up != nullptr && m_opaque_up->operator bool(); +} + +lldb::ScriptObjectPtr SBScriptObject::GetPointer() const { + LLDB_INSTRUMENT_VA(this); + + return m_opaque_up ? const_cast<void *>(m_opaque_up->GetPointer()) : nullptr; +} + +lldb::ScriptLanguage SBScriptObject::GetLanguage() const { + LLDB_INSTRUMENT_VA(this); + + return m_opaque_up ? m_opaque_up->GetLanguage() : eScriptLanguageNone; +} + +ScriptObject &SBScriptObject::ref() { + if (m_opaque_up == nullptr) + m_opaque_up = std::make_unique<ScriptObject>(nullptr, eScriptLanguageNone); + return *m_opaque_up; +} + +const ScriptObject &SBScriptObject::ref() const { + // This object should already have checked with "IsValid()" prior to calling + // this function. In case you didn't we will assert and die to let you know. + assert(m_opaque_up.get()); + return *m_opaque_up; +} + +ScriptObject *SBScriptObject::get() { return m_opaque_up.get(); } |
