globtype.pas 10 KB

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