[MLIR][NVVM] Add Op for TMA Store with reduction (#118853)
[llvm-project.git] / lldb / source / API / SBScriptObject.cpp
blob3e067d0ab1eedbf3c41c8a7a46070f23abb3ae8a
1 //===-- SBScriptObject.cpp ------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBScriptObject.h"
11 #include "Utils.h"
13 #include "lldb/Interpreter/ScriptObject.h"
14 #include "lldb/Utility/Instrumentation.h"
16 using namespace lldb;
17 using namespace lldb_private;
19 SBScriptObject::SBScriptObject(const ScriptObjectPtr ptr,
20 lldb::ScriptLanguage lang)
21 : m_opaque_up(std::make_unique<lldb_private::ScriptObject>(ptr, lang)) {
22 LLDB_INSTRUMENT_VA(this, ptr, lang);
25 SBScriptObject::SBScriptObject(const SBScriptObject &rhs)
26 : m_opaque_up(new ScriptObject(nullptr, eScriptLanguageNone)) {
27 LLDB_INSTRUMENT_VA(this, rhs);
29 m_opaque_up = clone(rhs.m_opaque_up);
31 SBScriptObject::~SBScriptObject() = default;
33 const SBScriptObject &SBScriptObject::operator=(const SBScriptObject &rhs) {
34 LLDB_INSTRUMENT_VA(this, rhs);
36 if (this != &rhs)
37 m_opaque_up = clone(rhs.m_opaque_up);
38 return *this;
41 bool SBScriptObject::operator!=(const SBScriptObject &rhs) const {
42 LLDB_INSTRUMENT_VA(this, rhs);
44 return !(m_opaque_up == rhs.m_opaque_up);
47 bool SBScriptObject::IsValid() const {
48 LLDB_INSTRUMENT_VA(this);
50 return this->operator bool();
53 SBScriptObject::operator bool() const {
54 LLDB_INSTRUMENT_VA(this);
56 return m_opaque_up != nullptr && m_opaque_up->operator bool();
59 lldb::ScriptObjectPtr SBScriptObject::GetPointer() const {
60 LLDB_INSTRUMENT_VA(this);
62 return m_opaque_up ? const_cast<void *>(m_opaque_up->GetPointer()) : nullptr;
65 lldb::ScriptLanguage SBScriptObject::GetLanguage() const {
66 LLDB_INSTRUMENT_VA(this);
68 return m_opaque_up ? m_opaque_up->GetLanguage() : eScriptLanguageNone;
71 ScriptObject &SBScriptObject::ref() {
72 if (m_opaque_up == nullptr)
73 m_opaque_up = std::make_unique<ScriptObject>(nullptr, eScriptLanguageNone);
74 return *m_opaque_up;
77 const ScriptObject &SBScriptObject::ref() const {
78 // This object should already have checked with "IsValid()" prior to calling
79 // this function. In case you didn't we will assert and die to let you know.
80 assert(m_opaque_up.get());
81 return *m_opaque_up;
84 ScriptObject *SBScriptObject::get() { return m_opaque_up.get(); }