Originale-mail to me for new edition

 

Method calls

 

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.

 

Constructors and destructors

 

Topic groups

 

See also

Mehods: Overview

Parameter passing

Parameter semantics: Overview

Parameters and function results: Overview

Parameters: Overview

Procedures and functions: Overview

Self

 

 

译文

 

方法调用

 

除了每个方法有一个额外的隐含参数Self之外,方法与一般的过程和函数使用相同的调用约定。这里的Self是一个调用方法的实例或类。Self作为32位指针传递。

·    register约定下,Self就象声明在所有其他参数之前。因此它总是在EAX寄存器中传递。

·    pascal约定下,Self就象声明在所有其他参数(包括有时作为额外参数的函数结果)之后。因此它总是最后被推入栈,结束于比其他参数都低的地址。

·    cdeclstdcallsafecall约定下,Self就象声明在所有其他参数之前、但在作为函数结果传递的额外的var参数(如果有)之后。因此除额外的var参数之外,它最后被推入栈。

 

构造器和析构器

 

主题组

 

相关主题

方法:概述

参数传递

参数语义:概述

参数和函数结果:概述

参数:概述

过程和函数:概述

Self