struct reference_match
{
- inline bool quick_match (const die2 &)
+ inline bool cannot_match () const
{
return false;
}
-
- inline void notice_match (const die2 &, bool)
+ inline void notice_match (const die2 &, bool) const
{
}
};
- inline reference_match reference_matched (const die1 &)
+
+ inline bool reference_matched (reference_match &,
+ const left_context_type &, const die1 &,
+ const right_context_type &, const die2 &)
{
- return reference_match ();
+ return false;
}
inline dwarf_tracker_base ()
= _m_tracker.right_context (ref2);
// Maybe the tracker has already cached a correspondence of references.
- typename tracker::reference_match matched
- = _m_tracker.reference_matched (ref1);
- if (matched.quick_match (ref2))
+ typename tracker::reference_match matched;
+ if (_m_tracker.reference_matched (matched, lhs, ref1, rhs, ref2))
return true;
+ if (matched.cannot_match ())
+ return false;
+
std::cout << "considering ref "
<< std::hex << a.offset () << " vs "
<< std::hex << b.offset () << std::endl;
tracker2 _m_right;
typedef std::tr1::unordered_map<
- ::Dwarf_Off, std::pair<dwarf_ref_tracker *,
+ ::Dwarf_Off, std::pair<const std::list<die2> *,
std::tr1::unordered_set< ::Dwarf_Off> >
> equiv_map;
equiv_map *_m_equiv;
private:
typename equiv_map::mapped_type *_m_elt;
- inline reference_match (dwarf_ref_tracker *tracker,
- typename equiv_map::mapped_type *elt)
- : _m_elt (elt)
- {
- _m_elt->first = tracker;
- }
-
public:
inline reference_match ()
inline ~reference_match ()
{
- _m_elt->first = NULL;
+ if (_m_elt != NULL)
+ _m_elt->first = NULL;
}
- inline bool quick_match (const die2 &b)
+ inline bool cannot_match () const
{
- return _m_elt->second.find (b->identity ()) != _m_elt->second.end ();
+ return _m_elt == NULL;
}
- inline void notice_match (const die2 &b, bool matches)
+ inline void notice_match (const die2 &b, bool matches) const
{
- if (matches)
+ if (matches && _m_elt != NULL)
_m_elt->second.insert (b->identity ());
}
};
- inline reference_match reference_matched (const die1 &a)
+ inline bool
+ reference_matched (reference_match &matched,
+ const left_context_type &lhs, const die1 &a,
+ const right_context_type &rhs, const die2 &b)
{
typename equiv_map::mapped_type *elt = &(*_m_equiv)[a->identity ()];
if (elt->first == NULL)
- return reference_match (this, elt);
+ {
+ elt->first = &rhs;
+ matched._m_elt = elt;
+ return elt->second.find (b->identity ()) != elt->second.end ();
+ }
- // We have a circularity.
std::cout << "recursing? on " << std::hex << a->offset () << std::endl;
+ // We have a circularity.
+ return elt->first == &rhs; // ???
+
throw std::logic_error ("XXX can't handle circularity");
}