[next] [prev] [prev-tail] [tail] [up]

#### Mangled names for code blocks

The rules for mangled names for routines are as follows:

- All routine names are converted to upper case.
- Routines in a unit have their unit name prepended to them : _UNITNAME$$_
- All Routines in the main program have a _ prepended to them.
- All parameters in a routine are mangled using the type of the parameter (in uppercase) prepended by the $ character. This is done in left to right order for each parameter of the routine.
- Objects and classes use special mangling : The class type or object type is given in the mangled name; The mangled name is as follows: _$$_TYPEDECL_$$ optionally preceded by mangled name of the unit and finishing with the method name.

The following constructs

     unit testman;

     interface
     type
       myobject = object
        constructor init;
        procedure mymethod;
       end;

     implementation

       constructor myobject.init;
       begin
       end;

       procedure myobject.mymethod;
       begin
       end;

       function myfunc: pointer;
       begin
       end;

       procedure myprocedure(var x: integer; y: longint; z : pchar);
       begin
       end;

     end.

will result in the following assembler file for the Intel 80x86 target:

     .file "testman.pas"

     .text
     .balign 16
     .globl _TESTMAN$$_$$_MYOBJECT_$$_INIT
     _TESTMAN$$_$$_MYOBJECT_$$_INIT:
     pushl %ebp
     movl %esp,%ebp
     subl $4,%esp
     movl $0,%edi
     call FPC_HELP_CONSTRUCTOR
     jz .L5
     jmp .L7
     .L5:
     movl 12(%ebp),%esi
     movl $0,%edi
     call FPC_HELP_FAIL
     .L7:
     movl %esi,%eax
     testl %esi,%esi
     leave
     ret $8
     .balign 16
     .globl _TESTMAN$$_$$_MYOBJECT_$$_MYMETHOD
     _TESTMAN$$_$$_MYOBJECT_$$_MYMETHOD:
     pushl %ebp
     movl %esp,%ebp
     leave
     ret $4
     .balign 16
     _TESTMAN$$_MYFUNC:
     pushl %ebp
     movl %esp,%ebp
     subl $4,%esp
     movl -4(%ebp),%eax
     leave
     ret
     .balign 16
     _TESTMAN$$_MYPROCEDURE$INTEGER$LONGINT$PCHAR:
     pushl %ebp
     movl %esp,%ebp
     leave
     ret $12

[next] [prev] [prev-tail] [front] [up]