globtype.pas 11 KB

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