Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueSInt64.h --------------------------------------*- C++
0002 //-*-===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef LLDB_INTERPRETER_OPTIONVALUESINT64_H
0011 #define LLDB_INTERPRETER_OPTIONVALUESINT64_H
0012 
0013 #include "lldb/Interpreter/OptionValue.h"
0014 
0015 namespace lldb_private {
0016 
0017 class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
0018 public:
0019   OptionValueSInt64() = default;
0020 
0021   OptionValueSInt64(int64_t value)
0022       : m_current_value(value), m_default_value(value) {}
0023 
0024   OptionValueSInt64(int64_t current_value, int64_t default_value)
0025       : m_current_value(current_value), m_default_value(default_value) {}
0026 
0027   OptionValueSInt64(const OptionValueSInt64 &rhs) = default;
0028 
0029   ~OptionValueSInt64() override = default;
0030 
0031   // Virtual subclass pure virtual overrides
0032 
0033   OptionValue::Type GetType() const override { return eTypeSInt64; }
0034 
0035   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0036                  uint32_t dump_mask) override;
0037 
0038   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
0039     return m_current_value;
0040   }
0041 
0042   Status
0043   SetValueFromString(llvm::StringRef value,
0044                      VarSetOperationType op = eVarSetOperationAssign) override;
0045 
0046   void Clear() override {
0047     m_current_value = m_default_value;
0048     m_value_was_set = false;
0049   }
0050 
0051   // Subclass specific functions
0052 
0053   const int64_t &operator=(int64_t value) {
0054     m_current_value = value;
0055     return m_current_value;
0056   }
0057 
0058   int64_t GetCurrentValue() const { return m_current_value; }
0059 
0060   int64_t GetDefaultValue() const { return m_default_value; }
0061 
0062   bool SetCurrentValue(int64_t value) {
0063     if (value >= m_min_value && value <= m_max_value) {
0064       m_current_value = value;
0065       return true;
0066     }
0067     return false;
0068   }
0069 
0070   bool SetDefaultValue(int64_t value) {
0071     if (value >= m_min_value && value <= m_max_value) {
0072       m_default_value = value;
0073       return true;
0074     }
0075     return false;
0076   }
0077 
0078   void SetMinimumValue(int64_t v) { m_min_value = v; }
0079 
0080   int64_t GetMinimumValue() const { return m_min_value; }
0081 
0082   void SetMaximumValue(int64_t v) { m_max_value = v; }
0083 
0084   int64_t GetMaximumValue() const { return m_max_value; }
0085 
0086 protected:
0087   int64_t m_current_value = 0;
0088   int64_t m_default_value = 0;
0089   int64_t m_min_value = std::numeric_limits<int64_t>::min();
0090   int64_t m_max_value = std::numeric_limits<int64_t>::max();
0091 };
0092 
0093 } // namespace lldb_private
0094 
0095 #endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H