]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
All leaf value types nominally there.
authorRoland McGrath <roland@redhat.com>
Mon, 6 Jul 2009 12:00:22 +0000 (05:00 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 6 Jul 2009 12:00:22 +0000 (05:00 -0700)
libdw/c++/dwarf_data
libdw/c++/dwarf_output
libdw/c++/subr.hh

index 91d4e663d967244c7ffacecd2789188098403f55..dc98e6d7d1e3db5c3719da25b1d0787fdbffe115 100644 (file)
@@ -516,6 +516,9 @@ namespace elfutils
       typedef std::pair<directory_table, line_table> _base;
 
     public:
+      friend class subr::base_hasher<line_info_table, _base>;
+      typedef subr::base_hasher<line_info_table, _base> hasher;
+
       inline line_info_table () : _base () {}
 
       template<typename table>
@@ -574,14 +577,8 @@ namespace elfutils
       {}
 
     public:
-      struct hasher
-       : public std::unary_function<dwarf_enum, size_t>
-      {
-       size_t operator () (const dwarf_enum &v) const
-       {
-         return subr::hash_this<_base> (v);
-       }
-      };
+      friend class subr::base_hasher<dwarf_enum, _base>;
+      typedef subr::base_hasher<dwarf_enum, _base> 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<typename loc>
+       inline value_location (const loc &other)
+         : location_attr (other)
+       {}
       };
     };
 
index bd9b63b7d7b98fbf539083057ea51e0a12342c15..832a1075aacf4d5601fc874aef99ed53e4ae636d 100644 (file)
@@ -317,14 +317,6 @@ namespace elfutils
        throw std::logic_error ("dwarf_output cannot be default-constructed");
       }
 
-      // XXX temporary
-      template<typename flavor, typename input, typename input_dw>
-      static inline value_dispatch *
-      make (flavor *&result, const input &x, copier<input_dw> &c)
-      {
-       return result = new flavor (x, c);
-      }
-
       template<typename input, typename input_dw>
       static inline const value_dispatch *
       make (value_string *&, const input &x, copier<input_dw> &c)
@@ -339,7 +331,12 @@ namespace elfutils
        return c.add_identifier (x);
       }
 
-      // XXX reference
+      template<typename input, typename input_dw>
+      static inline const value_dispatch *
+      make (value_reference *&, const input &x, copier<input_dw> &c)
+      {
+       return c.add_reference (x);
+      }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
@@ -362,14 +359,12 @@ namespace elfutils
        return c.add_ranges (x);
       }
 
-      /* XXX lineptr
       template<typename input, typename input_dw>
       static inline const value_dispatch *
       make (value_lineptr *&, const input &x, copier<input_dw> &c)
       {
        return c.add_line_info (x);
       }
-      */
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
@@ -414,7 +409,14 @@ namespace elfutils
       }
 
       // XXX macptr
-      // XXX location
+
+      template<typename input, typename input_dw>
+      static inline const value_dispatch *
+      make (value_location *&, const input &x, copier<input_dw> &c)
+      {
+       return c.add_location (x);
+      }
+
     };
 
   public:
@@ -646,12 +648,14 @@ namespace elfutils
     subr::value_set<dwarf_output::value::value_identifier> _m_identifiers;
     subr::value_set<dwarf_output::value::value_address> _m_address;
     subr::value_set<dwarf_output::value::value_rangelistptr> _m_ranges;
+    subr::value_set<dwarf_output::value::value_lineptr> _m_line_info;
     subr::value_set<dwarf_output::value::value_constant> _m_constants;
     subr::value_set<dwarf_output::value::value_constant_block> _m_const_block;
     subr::value_set<dwarf_output::value::value_dwarf_constant> _m_dwarf_const;
     subr::value_set<dwarf_output::value::value_source_file> _m_source_file;
     subr::value_set<dwarf_output::value::value_source_line> _m_source_line;
     subr::value_set<dwarf_output::value::value_source_column> _m_source_column;
+    subr::value_set<dwarf_output::value::value_location> _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<typename input>
+    inline const value::value_reference *add_reference (const input &x)
+    {
+      // XXX temporary kludge
+      return new value::value_reference (x, *this);
+    }
+
     template<typename input>
     inline const value::value_flag *add_flag (const input &x)
     {
@@ -714,6 +725,12 @@ namespace elfutils
       return _m_collector->_m_ranges.add (x);
     }
 
+    template<typename input>
+    inline const value::value_lineptr *add_line_info (const input &x)
+    {
+      return _m_collector->_m_line_info.add (x, *_m_collector);
+    }
+
     template<typename input>
     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<typename input>
+    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.
index 694b9b21502e82a7f9b13bf7948274e8250c904c..5b6859f092a772403fa96811ab6f4e6af924a8c1 100644 (file)
@@ -42,6 +42,15 @@ namespace elfutils
       hash_combine (seed, v.second);
     }
 
+    template<typename T, typename B>
+    struct base_hasher : public std::unary_function<T, size_t>
+    {
+      size_t operator () (const T &v) const
+      {
+       return subr::hash_this<B> (v);
+      }
+    };
+
     template<typename T>
     struct integer_hash : public std::unary_function<T, size_t>
     {
@@ -438,6 +447,12 @@ namespace elfutils
       {
        return add (value_type (v));
       }
+
+      template<typename input, typename arg_type>
+      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.