Quick start manual
13-6
Delphi Language Guide
Assembler statement syntax
DMTINDEX retrieves the dynamic method table index of the passed dynamic
method. This directive also needs a fully specified class name with a method name as
a parameter, for example, TExample.DynamicMethod. To invoke the dynamic
method, call System.@CallDynaInst with the (E)SI register containing the value
obtained from DMTINDEX.
Note
Methods with the message directive are implemented as dynamic methods and can
also be called using the DMTINDEX technique. For example:
TMyClass = class
procedure x; message MYMESSAGE;
end;
The following example uses both DMTINDEX and VMTOFFSET to access dynamic
and virtual methods:
program Project2;
type
TExample = class
procedure DynamicMethod; dynamic;
procedure VirtualMethod; virtual;
end;
procedure TExample.DynamicMethod;
begin
end;
procedure TExample.VirtualMethod;
begin
end;
procedure CallDynamicMethod(e: TExample);
asm
// Save ESI register
PUSH ESI
// Instance pointer needs to be in EAX
MOV EAX, e
// DMT entry index needs to be in (E)SI
MOV ESI, DMTINDEX TExample.DynamicMethod
// Now call the method
CALL System.@CallDynaInst
// Restore ESI register
POP ESI
end;