Home | History | Annotate | Download | only in DWARF
      1 //===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef SymbolFileDWARF_DWARFAttribute_h_
     11 #define SymbolFileDWARF_DWARFAttribute_h_
     12 
     13 #include "DWARFDefines.h"
     14 #include <vector>
     15 
     16 class DWARFAttribute
     17 {
     18 public:
     19     DWARFAttribute(dw_attr_t attr, dw_form_t form) :
     20         m_attr_form ( attr << 16 | form )
     21     {
     22     }
     23 
     24     void        set(dw_attr_t attr, dw_form_t form) { m_attr_form = (attr << 16) | form; }
     25     void        set_attr(dw_attr_t attr) { m_attr_form = (m_attr_form & 0x0000ffffu) | (attr << 16); }
     26     void        set_form(dw_form_t form) { m_attr_form = (m_attr_form & 0xffff0000u) | form; }
     27     dw_attr_t   get_attr() const { return m_attr_form >> 16; }
     28     dw_form_t   get_form() const { return (dw_form_t)m_attr_form; }
     29     void        get(dw_attr_t& attr, dw_form_t& form)  const
     30     {
     31         register uint32_t attr_form = m_attr_form;
     32         attr = attr_form >> 16;
     33         form = (dw_form_t)attr_form;
     34     }
     35     bool        operator == (const DWARFAttribute& rhs) const { return m_attr_form == rhs.m_attr_form; }
     36     typedef std::vector<DWARFAttribute> collection;
     37     typedef collection::iterator iterator;
     38     typedef collection::const_iterator const_iterator;
     39 
     40 protected:
     41     uint32_t    m_attr_form;    // Upper 16 bits is attribute, lower 16 bits is form
     42 };
     43 
     44 
     45 #endif  // SymbolFileDWARF_DWARFAttribute_h_
     46