RValue reference support
Milian Wolff
mail at milianw.de
Thu Jun 2 18:40:26 UTC 2011
Milian Wolff, 02.06.2011:
> David Nolden, 02.06.2011:
> > Yes, I fear you will have to modify both. You will also have to make
> > sure that they translate properly into each other, and are printed
> > correctly (see Cpp::shortenedTypeIdentifier(..), this will need a few
> > unit tests).
> >
> > In general, since rvalue-references are nearly like normal references,
> > the best thing would be to just add an additional flag "isRValue" to
> > ReferenceType and TypeIdentifier, and only do rvalue-reference special
> > treatment if "isRValue && isReference". It's most important that
> > isReference is always true for rvalue-references, so the majority of
> > code will simply keep working.
>
> Ok, will do.
>
> Though I have a question. How am I supposed to extend e.g.
> IndexedTypeIdentifier::hash when I add a new member? The hash needs to be
> unique, so much I gather - but these numbers in there are looking totally
> random to me. Should I just generate another random number and multiply
> that with m_isRValue ?
I have it working locally now, just the hash question refrains me from pushing
it yet. Can you review this, I just used random numbers though ;-)
uint IndexedTypeIdentifier::hash() const {
- return m_identifier.getIndex() * 13 + (m_isConstant ? 17 : 0) +
(m_isReference ? 12371 : 0) + m_pointerConstMask * 89321 + m_pointerDepth *
1023;
+ return m_identifier.getIndex() * 13 + (m_isConstant ? 17 : 0) +
(m_isReference ? 12371 : 0) + (m_isRValue ? 4543 : 0) + m_pointerConstMask *
89321 + m_pointerDepth * 1023;
}
...
uint ReferenceType::hash() const
{
- return AbstractType::hash() + (d_func()->m_baseType.hash()+1) * 29;
+ return AbstractType::hash() + (d_func()->m_baseType.hash()+1) * 29 +
(d_func()->m_isRValue ? 43768 : 0);
}
If that is OK I'll push it.
Thanks
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110602/f21eea37/attachment.sig>
More information about the KDevelop-devel
mailing list