LLDB mainline
lldb_private::Scalar Class Reference

#include <Scalar.h>

Public Types

enum  Type { e_void = 0 , e_int , e_float }

Public Member Functions

 Scalar ()
 Scalar (int v)
 Scalar (unsigned int v)
 Scalar (long v)
 Scalar (unsigned long v)
 Scalar (long long v)
 Scalar (unsigned long long v)
 Scalar (float v)
 Scalar (double v)
 Scalar (long double v)
 Scalar (llvm::APInt v)
 Scalar (llvm::APSInt v)
 Scalar (llvm::APFloat v)
bool SignExtend (uint32_t bit_pos)
bool ExtractBitfield (uint32_t bit_size, uint32_t bit_offset)
bool SetBit (uint32_t bit)
bool ClearBit (uint32_t bit)
void GetBytes (uint8_t *storage, size_t length) const
 Store the binary representation of this value into the given storage.
void GetBytes (llvm::MutableArrayRef< uint8_t > storage) const
size_t GetByteSize () const
bool GetData (DataExtractor &data) const
 Get data with a byte size of GetByteSize().
bool GetData (DataExtractor &data, size_t result_byte_size) const
 Get data with a byte size forced to result_byte_size.
size_t GetAsMemoryData (void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
bool IsZero () const
void Clear ()
const char * GetTypeAsCString () const
void GetValue (Stream &s, bool show_type) const
bool IsValid () const
void TruncOrExtendTo (uint16_t bits, bool sign)
 Convert to an integer with bits and the given signedness.
bool IntegralPromote (uint16_t bits, bool sign)
bool FloatPromote (const llvm::fltSemantics &semantics)
bool IsSigned () const
bool MakeSigned ()
bool MakeUnsigned ()
Scalaroperator+= (Scalar rhs)
Scalaroperator<<= (const Scalar &rhs)
Scalaroperator>>= (const Scalar &rhs)
Scalaroperator&= (const Scalar &rhs)
bool ShiftRightLogical (const Scalar &rhs)
bool AbsoluteValue ()
bool UnaryNegate ()
bool OnesComplement ()
Scalar::Type GetType () const
int SInt (int fail_value=0) const
unsigned char UChar (unsigned char fail_value=0) const
signed char SChar (signed char fail_value=0) const
unsigned short UShort (unsigned short fail_value=0) const
short SShort (short fail_value=0) const
unsigned int UInt (unsigned int fail_value=0) const
long SLong (long fail_value=0) const
unsigned long ULong (unsigned long fail_value=0) const
long long SLongLong (long long fail_value=0) const
unsigned long long ULongLong (unsigned long long fail_value=0) const
llvm::APInt SInt128 (const llvm::APInt &fail_value) const
llvm::APInt UInt128 (const llvm::APInt &fail_value) const
float Float (float fail_value=0.0f) const
double Double (double fail_value=0.0) const
long double LongDouble (long double fail_value=0.0) const
llvm::APSInt GetAPSInt () const
llvm::APFloat GetAPFloat () const
Status SetValueFromCString (const char *s, lldb::Encoding encoding, size_t byte_size)
Status SetValueFromData (const DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
llvm::APFloat CreateAPFloatFromAPSInt (lldb::BasicType basic_type)
llvm::APFloat CreateAPFloatFromAPFloat (lldb::BasicType basic_type)

Static Public Member Functions

static const char * GetValueTypeAsCString (Scalar::Type value_type)

Protected Types

using PromotionKey = std::tuple<Type, unsigned, bool>

Protected Member Functions

template<typename T>
GetAs (T fail_value) const
PromotionKey GetPromoKey () const

Static Protected Member Functions

static Type PromoteToMaxType (Scalar &lhs, Scalar &rhs)
static PromotionKey GetFloatPromoKey (const llvm::fltSemantics &semantics)

Protected Attributes

Scalar::Type m_type = e_void
llvm::APSInt m_integer
llvm::APFloat m_float

Static Private Member Functions

template<typename T>
static llvm::APSInt MakeAPSInt (T v)

Friends

llvm::APFloat::cmpResult compare (Scalar lhs, Scalar rhs)
const Scalar operator+ (const Scalar &lhs, const Scalar &rhs)
const Scalar operator- (Scalar lhs, Scalar rhs)
const Scalar operator/ (Scalar lhs, Scalar rhs)
const Scalar operator* (Scalar lhs, Scalar rhs)
const Scalar operator& (Scalar lhs, Scalar rhs)
const Scalar operator| (Scalar lhs, Scalar rhs)
const Scalar operator% (Scalar lhs, Scalar rhs)
const Scalar operator^ (Scalar lhs, Scalar rhs)
const Scalar operator<< (const Scalar &lhs, const Scalar &rhs)
const Scalar operator>> (const Scalar &lhs, const Scalar &rhs)
bool operator== (const Scalar &lhs, const Scalar &rhs)
bool operator!= (const Scalar &lhs, const Scalar &rhs)
bool operator< (const Scalar &lhs, const Scalar &rhs)
bool operator<= (const Scalar &lhs, const Scalar &rhs)
bool operator> (const Scalar &lhs, const Scalar &rhs)
bool operator>= (const Scalar &lhs, const Scalar &rhs)

Detailed Description

Definition at line 34 of file Scalar.h.

Member Typedef Documentation

◆ PromotionKey

using lldb_private::Scalar::PromotionKey = std::tuple<Type, unsigned, bool>
protected

Definition at line 211 of file Scalar.h.

Member Enumeration Documentation

◆ Type

Enumerator
e_void 
e_int 
e_float 

Definition at line 45 of file Scalar.h.

Constructor & Destructor Documentation

◆ Scalar() [1/13]

◆ Scalar() [2/13]

lldb_private::Scalar::Scalar ( int v)
inline

Definition at line 53 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [3/13]

lldb_private::Scalar::Scalar ( unsigned int v)
inline

Definition at line 54 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [4/13]

lldb_private::Scalar::Scalar ( long v)
inline

Definition at line 56 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [5/13]

lldb_private::Scalar::Scalar ( unsigned long v)
inline

Definition at line 57 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [6/13]

lldb_private::Scalar::Scalar ( long long v)
inline

Definition at line 59 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [7/13]

lldb_private::Scalar::Scalar ( unsigned long long v)
inline

Definition at line 61 of file Scalar.h.

References e_int, m_float, m_integer, m_type, and MakeAPSInt().

◆ Scalar() [8/13]

lldb_private::Scalar::Scalar ( float v)
inline

Definition at line 63 of file Scalar.h.

References e_float, m_float, and m_type.

◆ Scalar() [9/13]

lldb_private::Scalar::Scalar ( double v)
inline

Definition at line 64 of file Scalar.h.

References e_float, m_float, and m_type.

◆ Scalar() [10/13]

lldb_private::Scalar::Scalar ( long double v)
inline

Definition at line 65 of file Scalar.h.

References e_float, m_float, and m_type.

◆ Scalar() [11/13]

lldb_private::Scalar::Scalar ( llvm::APInt v)
inline

Definition at line 70 of file Scalar.h.

References e_int, m_float, m_integer, and m_type.

◆ Scalar() [12/13]

lldb_private::Scalar::Scalar ( llvm::APSInt v)
inline

Definition at line 72 of file Scalar.h.

References e_int, m_float, m_integer, and m_type.

◆ Scalar() [13/13]

lldb_private::Scalar::Scalar ( llvm::APFloat v)
inline

Definition at line 74 of file Scalar.h.

References e_float, m_float, m_integer, and m_type.

Member Function Documentation

◆ AbsoluteValue()

bool Scalar::AbsoluteValue ( )

Definition at line 489 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, and m_type.

◆ Clear()

void lldb_private::Scalar::Clear ( )
inline

Definition at line 102 of file Scalar.h.

References e_void, m_integer, and m_type.

Referenced by lldb_private::CompilerType::GetValueAsScalar().

◆ ClearBit()

bool Scalar::ClearBit ( uint32_t bit)

Definition at line 918 of file Scalar.cpp.

References lldb_private::bit(), e_float, e_int, e_void, m_integer, and m_type.

◆ CreateAPFloatFromAPFloat()

llvm::APFloat Scalar::CreateAPFloatFromAPFloat ( lldb::BasicType basic_type)

◆ CreateAPFloatFromAPSInt()

llvm::APFloat Scalar::CreateAPFloatFromAPSInt ( lldb::BasicType basic_type)

◆ Double()

double Scalar::Double ( double fail_value = 0.0) const

Definition at line 413 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, and m_type.

Referenced by LongDouble().

◆ ExtractBitfield()

bool Scalar::ExtractBitfield ( uint32_t bit_size,
uint32_t bit_offset )

◆ Float()

float Scalar::Float ( float fail_value = 0.0f) const

Definition at line 393 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, and m_type.

◆ FloatPromote()

bool Scalar::FloatPromote ( const llvm::fltSemantics & semantics)

Definition at line 224 of file Scalar.cpp.

References e_float, e_int, e_void, GetFloatPromoKey(), m_float, m_integer, and m_type.

Referenced by PromoteToMaxType().

◆ GetAPFloat()

llvm::APFloat lldb_private::Scalar::GetAPFloat ( ) const
inline

Definition at line 190 of file Scalar.h.

References m_float.

Referenced by lldb_private::ValueObject::GetValueAsAPFloat().

◆ GetAPSInt()

llvm::APSInt lldb_private::Scalar::GetAPSInt ( ) const
inline

◆ GetAs()

template<typename T>
T Scalar::GetAs ( T fail_value) const
protected

Definition at line 316 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, m_type, and ToAPInt().

Referenced by SChar(), SInt(), SLong(), SLongLong(), SShort(), UChar(), UInt(), ULong(), ULongLong(), and UShort().

◆ GetAsMemoryData()

◆ GetBytes() [1/2]

void Scalar::GetBytes ( llvm::MutableArrayRef< uint8_t > storage) const

Definition at line 144 of file Scalar.cpp.

References e_float, e_int, e_void, GetByteSize(), m_float, m_integer, and m_type.

◆ GetBytes() [2/2]

void Scalar::GetBytes ( uint8_t * storage,
size_t length ) const

Store the binary representation of this value into the given storage.

Exactly GetByteSize() bytes will be stored, and the buffer must be large enough to hold this data.

Definition at line 138 of file Scalar.cpp.

References GetBytes(), and GetByteSize().

Referenced by GetBytes(), GetData(), and GetData().

◆ GetByteSize()

◆ GetData() [1/2]

◆ GetData() [2/2]

bool Scalar::GetData ( DataExtractor & data,
size_t result_byte_size ) const

◆ GetFloatPromoKey()

Scalar::PromotionKey Scalar::GetFloatPromoKey ( const llvm::fltSemantics & semantics)
staticprotected

Definition at line 43 of file Scalar.cpp.

References e_float.

Referenced by FloatPromote(), and GetPromoKey().

◆ GetPromoKey()

Scalar::PromotionKey Scalar::GetPromoKey ( ) const
protected

Definition at line 31 of file Scalar.cpp.

References e_float, e_int, e_void, GetFloatPromoKey(), m_float, m_integer, and m_type.

Referenced by IntegralPromote(), and PromoteToMaxType().

◆ GetType()

Scalar::Type lldb_private::Scalar::GetType ( ) const
inline

Definition at line 153 of file Scalar.h.

References m_type.

Referenced by PromoteToMaxType().

◆ GetTypeAsCString()

const char * lldb_private::Scalar::GetTypeAsCString ( ) const
inline

Definition at line 107 of file Scalar.h.

References GetValueTypeAsCString(), and m_type.

Referenced by GetValue().

◆ GetValue()

◆ GetValueTypeAsCString()

const char * Scalar::GetValueTypeAsCString ( Scalar::Type value_type)
static

Definition at line 248 of file Scalar.cpp.

References e_float, e_int, and e_void.

Referenced by GetTypeAsCString().

◆ IntegralPromote()

bool Scalar::IntegralPromote ( uint16_t bits,
bool sign )

Definition at line 209 of file Scalar.cpp.

References lldb_private::bits(), e_float, e_int, e_void, GetPromoKey(), m_integer, and m_type.

Referenced by PromoteToMaxType().

◆ IsSigned()

bool Scalar::IsSigned ( ) const

Definition at line 260 of file Scalar.cpp.

References e_float, e_int, e_void, m_integer, and m_type.

◆ IsValid()

◆ IsZero()

◆ LongDouble()

long double Scalar::LongDouble ( long double fail_value = 0.0) const

No way to get more precision at the moment.

Definition at line 433 of file Scalar.cpp.

References Double().

◆ MakeAPSInt()

template<typename T>
llvm::APSInt lldb_private::Scalar::MakeAPSInt ( T v)
inlinestaticprivate

Definition at line 36 of file Scalar.h.

Referenced by Scalar(), Scalar(), Scalar(), Scalar(), Scalar(), and Scalar().

◆ MakeSigned()

◆ MakeUnsigned()

bool Scalar::MakeUnsigned ( )

◆ OnesComplement()

bool Scalar::OnesComplement ( )

Definition at line 520 of file Scalar.cpp.

References e_int, m_integer, and m_type.

◆ operator&=()

Scalar & Scalar::operator&= ( const Scalar & rhs)

Definition at line 481 of file Scalar.cpp.

References e_int, e_void, m_integer, m_type, and Scalar().

◆ operator+=()

Scalar & Scalar::operator+= ( Scalar rhs)

Definition at line 438 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, m_type, PromoteToMaxType(), and Scalar().

◆ operator<<=()

Scalar & Scalar::operator<<= ( const Scalar & rhs)

Definition at line 456 of file Scalar.cpp.

References e_int, e_void, m_integer, m_type, and Scalar().

◆ operator>>=()

Scalar & Scalar::operator>>= ( const Scalar & rhs)

Definition at line 473 of file Scalar.cpp.

References e_int, e_void, m_integer, m_type, and Scalar().

◆ PromoteToMaxType()

◆ SChar()

signed char Scalar::SChar ( signed char fail_value = 0) const

Definition at line 333 of file Scalar.cpp.

References GetAs().

◆ SetBit()

bool Scalar::SetBit ( uint32_t bit)

Definition at line 931 of file Scalar.cpp.

References lldb_private::bit(), e_float, e_int, e_void, m_integer, and m_type.

◆ SetValueFromCString()

◆ SetValueFromData()

◆ ShiftRightLogical()

bool Scalar::ShiftRightLogical ( const Scalar & rhs)

Definition at line 464 of file Scalar.cpp.

References e_int, e_void, m_integer, m_type, and Scalar().

Referenced by IRInterpreter::Interpret().

◆ SignExtend()

◆ SInt()

int Scalar::SInt ( int fail_value = 0) const

Definition at line 349 of file Scalar.cpp.

References GetAs().

Referenced by lldb_private::ClassDescriptorV2::iVarsStorage::fill().

◆ SInt128()

llvm::APInt Scalar::SInt128 ( const llvm::APInt & fail_value) const

Definition at line 369 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, m_type, and ToAPInt().

◆ SLong()

long Scalar::SLong ( long fail_value = 0) const

Definition at line 355 of file Scalar.cpp.

References GetAs().

◆ SLongLong()

long long Scalar::SLongLong ( long long fail_value = 0) const

◆ SShort()

short Scalar::SShort ( short fail_value = 0) const

Definition at line 341 of file Scalar.cpp.

References GetAs().

◆ TruncOrExtendTo()

void Scalar::TruncOrExtendTo ( uint16_t bits,
bool sign )

Convert to an integer with bits and the given signedness.

Definition at line 204 of file Scalar.cpp.

References lldb_private::bits(), and m_integer.

Referenced by lldb_private::DWARFExpression::Evaluate(), and lldb_private::dil::Interpreter::Visit().

◆ UChar()

unsigned char Scalar::UChar ( unsigned char fail_value = 0) const

Definition at line 337 of file Scalar.cpp.

References GetAs().

◆ UInt()

◆ UInt128()

llvm::APInt Scalar::UInt128 ( const llvm::APInt & fail_value) const

Definition at line 381 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, m_type, and ToAPInt().

Referenced by InterpreterStackFrame::AssignValue().

◆ ULong()

unsigned long Scalar::ULong ( unsigned long fail_value = 0) const

Definition at line 357 of file Scalar.cpp.

References GetAs().

Referenced by lldb_private::AppleObjCRuntimeV2::ParseClassInfoArray().

◆ ULongLong()

◆ UnaryNegate()

bool Scalar::UnaryNegate ( )

Definition at line 506 of file Scalar.cpp.

References e_float, e_int, e_void, m_float, m_integer, and m_type.

◆ UShort()

unsigned short Scalar::UShort ( unsigned short fail_value = 0) const

Definition at line 345 of file Scalar.cpp.

References GetAs().

◆ compare

llvm::APFloat::cmpResult compare ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator!=

bool operator!= ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator%

const Scalar operator% ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator&

const Scalar operator& ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator*

const Scalar operator* ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator+

const Scalar operator+ ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator-

const Scalar operator- ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator/

const Scalar operator/ ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator<

bool operator< ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator<<

const Scalar operator<< ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator<=

bool operator<= ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator==

bool operator== ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator>

bool operator> ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator>=

bool operator>= ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator>>

const Scalar operator>> ( const Scalar & lhs,
const Scalar & rhs )
friend

References Scalar().

◆ operator^

const Scalar operator^ ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

◆ operator|

const Scalar operator| ( Scalar lhs,
Scalar rhs )
friend

References Scalar().

Member Data Documentation

◆ m_float

◆ m_integer

◆ m_type


The documentation for this class was generated from the following files: