Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə267/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   263   264   265   266   267   268   269   270   ...   294
DelphiLanguageGuide

Handling 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 use the same calling conventions as other methods, except that an additional Boolean
flag parameter is passed to indicate the context of the constructor or destructor call.
A value of False in the flag parameter of a constructor call indicates that the constructor was invoked through an
instance object or using the inheritedinherited keyword. In this case, the constructor behaves like an ordinary method.
A value of True in the flag parameter of a constructor call indicates that the constructor was invoked through a class
reference. In this case, the constructor creates an instance of the class given by Self, and returns a reference to the
newly created object in EAX.
A value of False in the flag parameter of a destructor call indicates that the destructor was invoked using the inherited
keyword. In this case, the destructor behaves like an ordinary method. A value of True in the flag parameter of a
destructor call indicates that the destructor was invoked through an instance object. In this case, the destructor
deallocates the instance given by Self just before returning.
The flag parameter behaves as if it were declared before all other parameters. Under the register convention, it is
passed in the DL register. Under the pascal convention, it is pushed before all other parameters. Under the cdecl,
stdcall, and safecall conventions, it is pushed just before the Self parameter.
Since the DL register indicates whether the constructor or destructor is the outermost in the call stack, you must
restore the value of DL before exiting so that BeforeDestruction or AfterConstruction can be called properly.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   263   264   265   266   267   268   269   270   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin