From: Roland McGrath Date: Mon, 6 Jul 2009 12:00:22 +0000 (-0700) Subject: All leaf value types nominally there. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80db1db3f4fac2a8c3d15bac271a199f636377e8;p=thirdparty%2Felfutils.git All leaf value types nominally there. --- diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index 91d4e663d..dc98e6d7d 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -516,6 +516,9 @@ namespace elfutils typedef std::pair _base; public: + friend class subr::base_hasher; + typedef subr::base_hasher hasher; + inline line_info_table () : _base () {} template @@ -574,14 +577,8 @@ namespace elfutils {} public: - struct hasher - : public std::unary_function - { - size_t operator () (const dwarf_enum &v) const - { - return subr::hash_this<_base> (v); - } - }; + friend class subr::base_hasher; + typedef subr::base_hasher hasher; inline dwarf_enum (unsigned int attr, unsigned int value) : _base (value, attr) @@ -1057,6 +1054,11 @@ namespace elfutils inline value_location (const loc &other, arg_type &) : location_attr (other) {} + + template + inline value_location (const loc &other) + : location_attr (other) + {} }; }; diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index bd9b63b7d..832a1075a 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -317,14 +317,6 @@ namespace elfutils throw std::logic_error ("dwarf_output cannot be default-constructed"); } - // XXX temporary - template - static inline value_dispatch * - make (flavor *&result, const input &x, copier &c) - { - return result = new flavor (x, c); - } - template static inline const value_dispatch * make (value_string *&, const input &x, copier &c) @@ -339,7 +331,12 @@ namespace elfutils return c.add_identifier (x); } - // XXX reference + template + static inline const value_dispatch * + make (value_reference *&, const input &x, copier &c) + { + return c.add_reference (x); + } template static inline const value_dispatch * @@ -362,14 +359,12 @@ namespace elfutils return c.add_ranges (x); } - /* XXX lineptr template static inline const value_dispatch * make (value_lineptr *&, const input &x, copier &c) { return c.add_line_info (x); } - */ template static inline const value_dispatch * @@ -414,7 +409,14 @@ namespace elfutils } // XXX macptr - // XXX location + + template + static inline const value_dispatch * + make (value_location *&, const input &x, copier &c) + { + return c.add_location (x); + } + }; public: @@ -646,12 +648,14 @@ namespace elfutils subr::value_set _m_identifiers; subr::value_set _m_address; subr::value_set _m_ranges; + subr::value_set _m_line_info; subr::value_set _m_constants; subr::value_set _m_const_block; subr::value_set _m_dwarf_const; subr::value_set _m_source_file; subr::value_set _m_source_line; subr::value_set _m_source_column; + subr::value_set _m_locations; static const dwarf_output::value::value_flag flag_true; static const dwarf_output::value::value_flag flag_false; @@ -696,6 +700,13 @@ namespace elfutils return _m_collector->_m_identifiers.add (x); } + template + inline const value::value_reference *add_reference (const input &x) + { + // XXX temporary kludge + return new value::value_reference (x, *this); + } + template inline const value::value_flag *add_flag (const input &x) { @@ -714,6 +725,12 @@ namespace elfutils return _m_collector->_m_ranges.add (x); } + template + inline const value::value_lineptr *add_line_info (const input &x) + { + return _m_collector->_m_line_info.add (x, *_m_collector); + } + template inline const value::value_constant *add_constant (const input &x) { @@ -751,6 +768,12 @@ namespace elfutils { return _m_collector->_m_source_column.add (x); } + + template + inline const value::value_location *add_location (const input &x) + { + return _m_collector->_m_locations.add (x); + } }; // Copy construction instantiates a copier derived from the collector. diff --git a/libdw/c++/subr.hh b/libdw/c++/subr.hh index 694b9b215..5b6859f09 100644 --- a/libdw/c++/subr.hh +++ b/libdw/c++/subr.hh @@ -42,6 +42,15 @@ namespace elfutils hash_combine (seed, v.second); } + template + struct base_hasher : public std::unary_function + { + size_t operator () (const T &v) const + { + return subr::hash_this (v); + } + }; + template struct integer_hash : public std::unary_function { @@ -438,6 +447,12 @@ namespace elfutils { return add (value_type (v)); } + + template + const value_type *add (const input &v, arg_type &arg) + { + return add (value_type (v, arg)); + } }; // A container of hashed_value's that itself acts like a hashed_value.