| |||
| Home > Using the Inline and Embedded Assemblers > Embedded assembler > Keywords for member function classes | |||
The following keywords facilitate the calling of virtual and
non-virtual member functions from an __asm function.
The keywords beginning with __mcall can be used
for both virtual and non-virtual functions. The keywords beginning
with __vcall can be used only with virtual functions.
The keywords do not particularly help in calling static member functions.
For examples of how to use these keywords, see Calling non‑static member functions.
__mcall_is_virtual(D,
f)Results in {TRUE} if f is
a virtual member function found in D, or a base class
of D, otherwise {FALSE}. If
it returns {TRUE} the call can be done using
virtual dispatch, otherwise the call must be done directly.
__mcall_is_in_vbase(D,
f)Results in {TRUE} if f is
a non-static member function found in a virtual base class of D,
otherwise {FALSE}. If it returns {TRUE} the this adjustment must
be done using __mcall_offsetof_vbase(D, f),
otherwise it must be done with __mcall_this_offset(D,
f).
__mcall_offsetof_vbase(D,
f)Where D class
type and f is a non-static member function defined
in a virtual base class of D, in other words __mcall_is_in_vbase(D,f) returns true.
This returns at which negative offset in the vtable of the
vtable slot that holds the base offset (from the beginning of a D object
to the start of the base in which f is defined).
This is the this adjustment necessary when
making a call to f with a pointer to a D.
The offset returns a positive number that then has to be subtracted from the vtable pointer.
__mcall_this_offset(D,
f)Where D class
type and f is a non-static member function defined
in D or a non-virtual base class of D.
This returns the offset from the beginning of a D object
to the start of the base in which f is defined.
This is the this adjustment necessary when making
a call to f with a pointer to a D.
It is either zero if f is found in D or
the same as __offsetof_base(D,B), where B is
a non-virtual base class of D that contains f.
If __mcall_this_offset(D,f) is used when f is
found in a virtual base class of D it returns
an arbitrary value designed to cause an assembly error if used.
This is so that such invalid uses of __mcall_this_offset can
occur in sections of assembly code that are to be skipped.
__vcall_offsetof_vfunc(D,
f)Where D is
a class and f is a virtual function defined in D,
or a base class of D.
The function returns the negative offset of the slot in the
vtable that holds the base offset. The base offset is calculated
as the distance between a D object to the start
of the base in which f is defined.
If __vcall_offsetof_vfunc(D, f) is used
when f is not a virtual member function it returns
an arbitrary value designed to cause an assembly error if used.