2016-11-24 20:36:02 +00:00
inline unsigned GetVirtualIndex ( PClass * cls , const char * funcname )
2016-11-19 12:56:29 +00:00
{
// Look up the virtual function index in the defining class because this may have gotten overloaded in subclasses with something different than a virtual override.
auto sym = dyn_cast < PFunction > ( cls - > Symbols . FindSymbol ( funcname , false ) ) ;
assert ( sym ! = nullptr ) ;
auto VIndex = sym - > Variants [ 0 ] . Implementation - > VirtualIndex ;
return VIndex ;
}
2016-11-29 11:17:05 +00:00
# define IFVIRTUALPTR(self, cls, funcname) \
2016-11-24 20:36:02 +00:00
static unsigned VIndex = ~ 0u ; \
if ( VIndex = = ~ 0u ) { \
2016-11-21 13:59:17 +00:00
VIndex = GetVirtualIndex ( RUNTIME_CLASS ( cls ) , # funcname ) ; \
2016-11-24 20:36:02 +00:00
assert ( VIndex ! = ~ 0u ) ; \
} \
2016-11-29 11:17:05 +00:00
auto clss = self - > GetClass ( ) ; \
2016-11-24 20:36:02 +00:00
VMFunction * func = clss - > Virtuals . Size ( ) > VIndex ? clss - > Virtuals [ VIndex ] : nullptr ; \
if ( func ! = nullptr )
2016-11-11 23:33:40 +00:00
2016-11-29 11:17:05 +00:00
# define IFVIRTUAL(cls, funcname) IFVIRTUALPTR(this, cls, funcname)