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ə262/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   258   259   260   261   262   263   264   265   ...   294
DelphiLanguageGuide

Passing Parameters
Parameters are transferred to procedures and functions via CPU registers or the stack, depending on the routine's
calling convention. For information about calling conventions, see the topic on Calling Conventions.
By Value vs. By Reference
Variable (var) parameters are always passed by reference, as 32-bit pointers that point to the actual storage location.
Value and constant (const) parameters are passed by value or by reference, depending on the type and size of the
parameter:
An ordinal parameter is passed as an 8-bit, 16-bit, 32-bit, or 64-bit value, using the same format as a variable
of the corresponding type.
A real parameter is always passed on the stack. A Single parameter occupies 4 bytes, and a Double, Comp, or
Currency parameter occupies 8 bytes. A Real48 occupies 8 bytes, with the Real48 value stored in the lower 6
bytes. An Extended occupies 12 bytes, with the Extended value stored in the lower 10 bytes.
A short-string parameter is passed as a 32-bit pointer to a short string.
A long-string or dynamic-array parameter is passed as a 32-bit pointer to the dynamic memory block allocated
for the long string. The value nil is passed for an empty long string.
A pointer, class, class-reference, or procedure-pointer parameter is passed as a 32-bit pointer.
A method pointer is passed on the stack as two 32-bit pointers. The instance pointer is pushed before the method
pointer so that the method pointer occupies the lowest address.
Under the register and pascal conventions, a variant parameter is passed as a 32bit pointer to a Variant value.
Sets, records, and static arrays of 1, 2, or 4 bytes are passed as 8-bit, 16-bit, and 32bit values. Larger sets,
records, and static arrays are passed as 32-bit pointers to the value. An exception to this rule is that records
are always passed directly on the stack under the cdecl, stdcall, and safecall conventions; the size of a record
passed this way is rounded upward to the nearest double-word boundary.
An open-array parameter is passed as two 32-bit values. The first value is a pointer to the array data, and the
second value is one less than the number of elements in the array.
When two parameters are passed on the stack, each parameter occupies a multiple of 4 bytes (a whole number of
double words). For an 8-bit or 16-bit parameter, even though the parameter occupies only a byte or a word, it is
passed as a double word. The contents of the unused parts of the double word are undefined.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   258   259   260   261   262   263   264   265   ...   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