Methods use the same calling
conventions as ordinary procedures and functions, except that every method has
an additional implicit parameter Self, which is a reference to the
instance or class in which the method is called. The Self parameter is
passed as a 32-bit pointer.
· Under the register convention, Self behaves as if it
were declared before all other parameters. It is therefore always passed
in the EAX register.
· Under the pascal convention, Self behaves as if it were
declared after all other parameters (including the additional var
parameter sometimes passed for a function result). It is therefore pushed last,
ending up at a lower address than all other parameters.
· Under the cdecl, stdcall, and safecall
conventions, Self behaves as if it were declared before all other
parameters, but after the additional var parameter (if any) passed
for a function result. It is therefore the last to be pushed, except for the
additional var parameter.
Parameters and function results: Overview
Procedures and functions: Overview
除了每个方法有一个额外的隐含参数Self之外,方法与一般的过程和函数使用相同的调用约定。这里的Self是一个调用方法的实例或类。Self作为32位指针传递。
· 在register约定下,Self就象声明在所有其他参数之前。因此它总是在EAX寄存器中传递。
· 在pascal约定下,Self就象声明在所有其他参数(包括有时作为额外参数的函数结果)之后。因此它总是最后被推入栈,结束于比其他参数都低的地址。
· 在cdecl、stdcall和safecall约定下,Self就象声明在所有其他参数之前、但在作为函数结果传递的额外的var参数(如果有)之后。因此除额外的var参数之外,它最后被推入栈。