diff options
author | Chris Lattner <sabre@nondot.org> | 2010-06-08 16:52:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-06-08 16:52:24 +0000 |
commit | 30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c (patch) | |
tree | f70013106f6a461a14abcd71c65f48a95a2979a6 /lldb/source/Core/Flags.cpp | |
parent | 312c4c799da215b337f790fda330f70c4aa757cf (diff) | |
download | bcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.tar.gz bcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.zip |
Initial checkin of lldb code from internal Apple repo.
llvm-svn: 105619
Diffstat (limited to 'lldb/source/Core/Flags.cpp')
-rw-r--r-- | lldb/source/Core/Flags.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/lldb/source/Core/Flags.cpp b/lldb/source/Core/Flags.cpp new file mode 100644 index 00000000000..13cbd85915b --- /dev/null +++ b/lldb/source/Core/Flags.cpp @@ -0,0 +1,122 @@ +//===-- Flags.cpp -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/Flags.h" + +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Default Constructor +//---------------------------------------------------------------------- +Flags::Flags (ValueType flags) : + m_flags(flags) +{ +} + +//---------------------------------------------------------------------- +// Copy Constructor +//---------------------------------------------------------------------- +Flags::Flags (const Flags& rhs) : + m_flags(rhs.m_flags) +{ +} + +//---------------------------------------------------------------------- +// Virtual destructor in case anyone inherits from this class. +//---------------------------------------------------------------------- +Flags::~Flags () +{ +} + +//---------------------------------------------------------------------- +// Get accessor for all of the current flag bits. +//---------------------------------------------------------------------- +Flags::ValueType +Flags::GetAllFlagBits () const +{ + return m_flags; +} + +size_t +Flags::GetBitSize() const +{ + return sizeof (ValueType) * 8; +} + +//---------------------------------------------------------------------- +// Set accessor for all of the current flag bits. +//---------------------------------------------------------------------- +void +Flags::SetAllFlagBits (ValueType flags) +{ + m_flags = flags; +} + +//---------------------------------------------------------------------- +// Clear one or more bits in our flag bits +//---------------------------------------------------------------------- +Flags::ValueType +Flags::Clear (ValueType bits) +{ + m_flags &= ~bits; + return m_flags; +} + +//---------------------------------------------------------------------- +// Set one or more bits in our flag bits +//---------------------------------------------------------------------- +Flags::ValueType +Flags::Set (ValueType bits) +{ + m_flags |= bits; + return m_flags; +} + +//---------------------------------------------------------------------- +// Returns true if any flag bits in "bits" are set +//---------------------------------------------------------------------- +bool +Flags::IsSet (ValueType bits) const +{ + return (m_flags & bits) != 0; +} + +//---------------------------------------------------------------------- +// Returns true if all flag bits in "bits" are clear +//---------------------------------------------------------------------- +bool +Flags::IsClear (ValueType bits) const +{ + return (m_flags & bits) == 0; +} + + +size_t +Flags::SetCount () const +{ + size_t count = 0; + for (ValueType mask = m_flags; mask; mask >>= 1) + { + if (mask & 1) + ++count; + } + return count; +} + +size_t +Flags::ClearCount () const +{ + size_t count = 0; + for (ValueType shift = 0; shift < sizeof(ValueType)*8; ++shift) + { + if ((m_flags & (1u << shift)) == 0) + ++count; + } + return count; +} |