typinfo.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { This unit provides the same Functionality as the TypInfo Unit }
  13. { of Delphi }
  14. { ---------------------------------------------------------------------
  15. This include contains cpu-specific Low-level calling of methods.
  16. ---------------------------------------------------------------------}
  17. {$ASMMODE ATT}
  18. Function CallIntegerFunc(s: Pointer; Address: Pointer; Index, IValue: LongInt): Int64; assembler;
  19. asm
  20. // ? Indexed Function
  21. movl Index,%eax
  22. testl %eax,%eax
  23. je .LINoPush
  24. movl IValue,%eax
  25. pushl %eax
  26. .LINoPush:
  27. push s
  28. // reset EDX for routines that return only EAX
  29. xorl %edx,%edx
  30. call Address
  31. // now the result is in EDX:EAX
  32. end;
  33. Function CallIntegerProc(s : Pointer;Address : Pointer;Value : Integer; INdex,IValue : Longint) : Integer;assembler;
  34. asm
  35. // Push value to set
  36. movl Value,%eax
  37. pushl %eax
  38. // ? Indexed Procedure
  39. movl Index,%eax
  40. testl %eax,%eax
  41. je .LIPNoPush
  42. movl IValue,%eax
  43. pushl %eax
  44. .LIPNoPush:
  45. pushl s
  46. call Address
  47. end;
  48. Function CallSingleFunc(s : Pointer; Address : Pointer;
  49. Index, IValue : Longint) : Single; assembler;
  50. asm
  51. // ? Indexed Function
  52. movl Index,%eax
  53. testl %eax,%eax
  54. je .LINoPush
  55. movl IValue,%eax
  56. pushl %eax
  57. .LINoPush:
  58. pushl s
  59. call Address
  60. //
  61. end;
  62. Function CallDoubleFunc(s : Pointer; Address : Pointer;
  63. Index, IValue : Longint) : Double; assembler;
  64. asm
  65. // ? Indexed Function
  66. movl Index,%eax
  67. testl %eax,%eax
  68. je .LINoPush
  69. movl IValue,%eax
  70. pushl %eax
  71. .LINoPush:
  72. pushl s
  73. call Address
  74. //
  75. end;
  76. Function CallExtendedFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint) : Extended;assembler;
  77. asm
  78. // ? Indexed Function
  79. movl Index,%eax
  80. testl %eax,%eax
  81. je .LINoPush
  82. movl IValue,%eax
  83. pushl %eax
  84. .LINoPush:
  85. pushl s
  86. call Address
  87. //
  88. end;
  89. Function CallBooleanFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Boolean;assembler;
  90. asm
  91. // ? Indexed Function
  92. movl Index,%eax
  93. testl %eax,%eax
  94. je .LBNoPush
  95. movl IValue,%eax
  96. pushl %eax
  97. .LBNoPush:
  98. pushl s
  99. call Address
  100. end;
  101. // Assembler Functions can't have short stringreturn values.
  102. // So we make a Procedure with var parameter.
  103. // That's not true (FK)
  104. Procedure CallSStringFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint;
  105. Var Res: Shortstring);assembler;
  106. asm
  107. // ? Indexed Function
  108. movl Index,%eax
  109. testl %eax,%eax
  110. jnz .LSSNoPush
  111. movl IValue,%eax
  112. pushl %eax
  113. // the result is stored in an invisible parameter
  114. pushl Res
  115. .LSSNoPush:
  116. pushl s
  117. call Address
  118. end;
  119. Procedure CallSStringProc(s : Pointer;Address : Pointer;Const Value : ShortString; INdex,IVAlue : Longint);assembler;
  120. asm
  121. // Push value to set
  122. movl Value,%eax
  123. pushl %eax
  124. // ? Indexed Procedure
  125. movl Index,%eax
  126. testl %eax,%eax
  127. // BUG 1 (jnz)
  128. je .LSSPNoPush
  129. movl IValue,%eax
  130. pushl %eax
  131. .LSSPNoPush:
  132. // BUG 2 (push)
  133. pushl s
  134. call Address
  135. end;
  136. {
  137. $Log$
  138. Revision 1.6 2003-09-08 18:21:37 peter
  139. * save edi,esi,ebx
  140. Revision 1.5 2003/03/29 16:55:56 michael
  141. + Patch from Mattias Gaertner for single typeinfo
  142. Revision 1.4 2002/09/07 16:01:19 peter
  143. * old logs removed and tabs fixed
  144. }