globtype.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Global types
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit globtype;
  19. {$i fpcdefs.inc}
  20. interface
  21. const
  22. maxidlen = 64;
  23. type
  24. {TCmdStr is used to pass command line parameters to an external program to be
  25. executed from the FPC application. In some circomstances, this can be more
  26. than 255 characters. That's why using Ansi Strings}
  27. {$IFDEF USE_SYSUTILS}
  28. TCmdStr = AnsiString;
  29. PathStr = String;
  30. DirStr = String;
  31. NameStr = String;
  32. ExtStr = String;
  33. {$ELSE USE_SYSUTILS}
  34. TCmdStr = String;
  35. {$ENDIF USE_SYSUTILS}
  36. {$ifndef fpc}
  37. qword = int64;
  38. {$endif fpc}
  39. {$ifdef ver1_0}
  40. { Bootstrapping }
  41. PtrInt = DWord;
  42. SizeInt = Longint;
  43. {$endif ver1_0}
  44. { Natural integer register type and size for the target machine }
  45. {$ifdef cpu64bit}
  46. AWord = qword;
  47. AInt = Int64;
  48. {$else cpu64bit}
  49. AWord = longword;
  50. AInt = longint;
  51. {$endif cpu64bit}
  52. PAWord = ^AWord;
  53. PAInt = ^AInt;
  54. { the ordinal type used when evaluating constant integer expressions }
  55. TConstExprInt = int64;
  56. { ... the same unsigned }
  57. TConstExprUInt = qword;
  58. { This must be an ordinal type with the same size as a pointer
  59. Note: Must be unsigned! Otherwise, ugly code like
  60. pointer(-1) will result in a pointer with the value
  61. $fffffffffffffff on a 32bit machine if the compiler uses
  62. int64 constants internally (JM) }
  63. TConstPtrUInt = AWord;
  64. tdoublearray = array[0..7] of byte;
  65. textendedarray = array[0..9] of byte;
  66. { Switches which can be changed locally }
  67. tlocalswitch = (cs_localnone,
  68. { codegen }
  69. cs_check_overflow,cs_check_range,cs_check_object,
  70. cs_check_io,cs_check_stack,
  71. cs_checkpointer,
  72. cs_omitstackframe,cs_do_assertion,cs_generate_rtti,
  73. cs_full_boolean_eval,cs_typed_const_writable,cs_allow_enum_calc,
  74. { mmx }
  75. cs_mmx,cs_mmx_saturation,
  76. { parser }
  77. cs_typed_addresses,cs_strict_var_strings,cs_ansistrings,
  78. { macpas specific}
  79. cs_external_var, cs_externally_visible
  80. );
  81. tlocalswitches = set of tlocalswitch;
  82. { Switches which can be changed only at the beginning of a new module }
  83. tmoduleswitch = (cs_modulenone,
  84. { parser }
  85. cs_fp_emulation,cs_extsyntax,cs_openstring,
  86. { support }
  87. cs_support_inline,cs_support_goto,cs_support_macro,
  88. cs_support_c_operators,cs_static_keyword,
  89. { generation }
  90. cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
  91. cs_lineinfo,cs_implicit_exceptions,
  92. { linking }
  93. cs_create_smart,cs_create_dynamic,cs_create_pic
  94. );
  95. tmoduleswitches = set of tmoduleswitch;
  96. { Switches which can be changed only for a whole program/compilation,
  97. mostly set with commandline }
  98. tglobalswitch = (cs_globalnone,
  99. { parameter switches }
  100. cs_check_unit_name,cs_constructor_name,
  101. { units }
  102. cs_load_objpas_unit,
  103. cs_load_gpc_unit,
  104. { optimizer }
  105. cs_regvars,cs_no_regalloc,cs_uncertainopts,cs_littlesize,
  106. cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_align,
  107. { browser }
  108. cs_browser_log,
  109. { debugger }
  110. cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,cs_gdb_lineinfo,
  111. cs_gdb_valgrind,cs_gdb_dwarf,
  112. { assembling }
  113. cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
  114. cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
  115. { linking }
  116. cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
  117. cs_link_strip,cs_link_staticflag,cs_link_on_target,cs_link_internal,
  118. cs_link_map,cs_link_pthread
  119. );
  120. tglobalswitches = set of tglobalswitch;
  121. { Switches which can be changed by a mode (fpc,tp7,delphi) }
  122. tmodeswitch = (m_none,m_all, { needed for keyword }
  123. { generic }
  124. m_fpc,m_objfpc,m_delphi,m_tp7,m_gpc,m_mac,
  125. { more specific }
  126. m_class, { delphi class model }
  127. m_objpas, { load objpas unit }
  128. m_result, { result in functions }
  129. m_string_pchar, { pchar 2 string conversion }
  130. m_cvar_support, { cvar variable directive }
  131. m_nested_comment, { nested comments }
  132. m_tp_procvar, { tp style procvars (no @ needed) }
  133. m_repeat_forward, { repeating forward declarations is needed }
  134. m_pointer_2_procedure, { allows the assignement of pointers to
  135. procedure variables }
  136. m_autoderef, { does auto dereferencing of struct. vars }
  137. m_initfinal, { initialization/finalization for units }
  138. m_add_pointer, { allow pointer add/sub operations }
  139. m_default_ansistring, { ansistring turned on by default }
  140. m_out, { support the calling convention OUT }
  141. m_default_para, { support default parameters }
  142. m_hintdirective, { support hint directives }
  143. m_duplicate_names { allow locals/paras to have duplicate names of globals }
  144. );
  145. tmodeswitches = set of tmodeswitch;
  146. { Win32, OS/2 & MacOS application types }
  147. tapptype = (
  148. app_none,
  149. app_gui, { graphic user-interface application}
  150. app_cui, { console application}
  151. app_fs, { full-screen type application (OS/2 and EMX only) }
  152. app_tool { tool application, (MPW tool for MacOS, MacOS only)}
  153. );
  154. { interface types }
  155. tinterfacetypes = (
  156. it_interfacecom,
  157. it_interfacecorba
  158. );
  159. { currently parsed block type }
  160. tblock_type = (bt_none,
  161. bt_general,bt_type,bt_const,bt_except,bt_body
  162. );
  163. { Temp types }
  164. ttemptype = (tt_none,
  165. tt_free,tt_normal,tt_persistent,
  166. tt_noreuse,tt_freenoreuse);
  167. ttemptypeset = set of ttemptype;
  168. { calling convention for tprocdef and tprocvardef }
  169. tproccalloption=(pocall_none,
  170. { procedure uses C styled calling }
  171. pocall_cdecl,
  172. { C++ calling conventions }
  173. pocall_cppdecl,
  174. { Procedure is used for internal compiler calls }
  175. pocall_compilerproc,
  176. { Far16 for OS/2 }
  177. pocall_far16,
  178. { Old style FPC default calling }
  179. pocall_oldfpccall,
  180. { Procedure is an assembler macro }
  181. pocall_inline,
  182. { Procedure has compiler magic}
  183. pocall_internproc,
  184. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  185. pocall_syscall,
  186. { pascal standard left to right }
  187. pocall_pascal,
  188. { procedure uses register (fastcall) calling }
  189. pocall_register,
  190. { safe call calling conventions }
  191. pocall_safecall,
  192. { procedure uses stdcall call }
  193. pocall_stdcall,
  194. { Special calling convention for cpus without a floating point
  195. unit. Floating point numbers are passed in integer registers
  196. instead of floating point registers. Depending on the other
  197. available calling conventions available for the cpu
  198. this replaces either pocall_fastcall or pocall_stdcall.
  199. }
  200. pocall_softfloat,
  201. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  202. { constant records by reference. }
  203. pocall_mwpascal
  204. );
  205. tproccalloptions = set of tproccalloption;
  206. tprocinfoflag=(
  207. { procedure has at least one assembler block }
  208. pi_has_assembler_block,
  209. { procedure does a call }
  210. pi_do_call,
  211. { procedure has a try statement = no register optimization }
  212. pi_uses_exceptions,
  213. { procedure is declared as @var(assembler), don't optimize}
  214. pi_is_assembler,
  215. { procedure contains data which needs to be finalized }
  216. pi_needs_implicit_finally,
  217. { procedure has the implicit try..finally generated }
  218. pi_has_implicit_finally,
  219. { procedure uses fpu}
  220. pi_uses_fpu,
  221. { procedure uses GOT for PIC code }
  222. pi_needs_got,
  223. { references var/proc/type/const in static symtable,
  224. i.e. not allowed for inlining from other units }
  225. pi_uses_static_symtable
  226. );
  227. tprocinfoflags=set of tprocinfoflag;
  228. {$ifdef ansistring_bits}
  229. Tstringbits=(sb_16,sb_32,sb_64);
  230. {$endif}
  231. const
  232. proccalloptionStr : array[tproccalloption] of string[14]=('',
  233. 'CDecl',
  234. 'CPPDecl',
  235. 'CompilerProc',
  236. 'Far16',
  237. 'OldFPCCall',
  238. 'Inline',
  239. 'InternProc',
  240. 'SysCall',
  241. 'Pascal',
  242. 'Register',
  243. 'SafeCall',
  244. 'StdCall',
  245. 'SoftFloat',
  246. 'MWPascal'
  247. );
  248. { Default calling convention }
  249. {$ifdef x86}
  250. pocall_default = pocall_register;
  251. {$else}
  252. pocall_default = pocall_stdcall;
  253. {$endif}
  254. type
  255. stringid = string[maxidlen];
  256. tnormalset = set of byte; { 256 elements set }
  257. pnormalset = ^tnormalset;
  258. pboolean = ^boolean;
  259. pdouble = ^double;
  260. pbyte = ^byte;
  261. pword = ^word;
  262. plongint = ^longint;
  263. plongintarray = plongint;
  264. Tconstant=record
  265. case signed:boolean of
  266. false:
  267. (valueu:cardinal);
  268. true:
  269. (values:longint);
  270. end;
  271. {$ifndef xFPC}
  272. type
  273. pguid = ^tguid;
  274. tguid = packed record
  275. D1: LongWord;
  276. D2: Word;
  277. D3: Word;
  278. D4: array[0..7] of Byte;
  279. end;
  280. {$endif}
  281. const
  282. { link options }
  283. link_none = $0;
  284. link_allways = $1;
  285. link_static = $2;
  286. link_smart = $4;
  287. link_shared = $8;
  288. implementation
  289. end.
  290. {
  291. $Log$
  292. Revision 1.72 2005-03-27 14:10:52 jonas
  293. * const record parameters > 8 bytes are now passed by reference for non
  294. cdecl/cppdecl procedures on Mac OS/Mac OS X to fix compatibility with
  295. GPC (slightly more efficient than Metrowerks behaviour below, but
  296. less efficient in most cases than our previous scheme)
  297. + "mwpascal" procedure directive to support the const record parameter
  298. behaviour of Metrowerks Pascal, which passes all const records by
  299. reference
  300. Revision 1.71 2005/02/17 17:52:39 peter
  301. * allow enum arithmetics inside an enum def, compatible with delphi
  302. Revision 1.70 2005/02/14 17:13:06 peter
  303. * truncate log
  304. Revision 1.69 2005/02/06 11:15:31 peter
  305. * removed $threading
  306. Revision 1.68 2005/01/23 21:09:12 florian
  307. + added pi bit pattern to the compiler, so pi should always be correct
  308. Revision 1.67 2005/01/04 16:20:51 florian
  309. * fixed nan et al. handling on arm
  310. }