symconst.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  3. Symbol table constants
  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 symconst;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype;
  22. const
  23. def_alignment = 4;
  24. { if you change one of the following contants, }
  25. { you have also to change the typinfo unit}
  26. { and the rtl/i386,template/rttip.inc files }
  27. tkUnknown = 0;
  28. tkInteger = 1;
  29. tkChar = 2;
  30. tkEnumeration = 3;
  31. tkFloat = 4;
  32. tkSet = 5;
  33. tkMethod = 6;
  34. tkSString = 7;
  35. tkString = tkSString;
  36. tkLString = 8;
  37. {$ifdef ansistring_bits}
  38. tkA32String = 9;
  39. {$else}
  40. tkAString = 9;
  41. {$endif}
  42. tkWString = 10;
  43. tkVariant = 11;
  44. tkArray = 12;
  45. tkRecord = 13;
  46. tkInterface= 14;
  47. tkClass = 15;
  48. tkObject = 16;
  49. tkWChar = 17;
  50. tkBool = 18;
  51. tkInt64 = 19;
  52. tkQWord = 20;
  53. tkDynArray = 21;
  54. tkInterfaceCorba = 22;
  55. {$ifdef ansistring_bits}
  56. tkA16string = 23;
  57. tkA64string = 24;
  58. {$endif}
  59. otSByte = 0;
  60. otUByte = 1;
  61. otSWord = 2;
  62. otUWord = 3;
  63. otSLong = 4;
  64. otULong = 5;
  65. ftSingle = 0;
  66. ftDouble = 1;
  67. ftExtended = 2;
  68. ftComp = 3;
  69. ftCurr = 4;
  70. ftFloat128 = 5;
  71. mkProcedure= 0;
  72. mkFunction = 1;
  73. mkConstructor = 2;
  74. mkDestructor = 3;
  75. mkClassProcedure= 4;
  76. mkClassFunction = 5;
  77. pfvar = 1;
  78. pfConst = 2;
  79. pfArray = 4;
  80. pfAddress = 8;
  81. pfReference= 16;
  82. pfOut = 32;
  83. unknown_level = 0;
  84. main_program_level = 1;
  85. normal_function_level = 2;
  86. { implicit parameter positions, normal parameters start at 10
  87. and will increase with 10 for each parameter. The high parameters
  88. will be inserted with n+1 }
  89. paranr_parentfp = 1;
  90. paranr_result = 2;
  91. paranr_self = 3;
  92. paranr_vmt = 4;
  93. { Required to support variations of syscalls on MorphOS }
  94. paranr_syscall_basesysv = 9;
  95. paranr_syscall_sysvbase = high(word)-4;
  96. paranr_syscall_r12base = high(word)-3;
  97. paranr_syscall_legacy = high(word)-2;
  98. paranr_result_leftright = high(word)-1;
  99. type
  100. { keep this in sync with TIntfFlag in rtl/objpas/typinfo.pp }
  101. TCompilerIntfFlag = (ifHasGuid,ifDispInterface,ifDispatch,ifHasStrGUID);
  102. { Deref entry options }
  103. tdereftype = (deref_nil,
  104. deref_sym,
  105. deref_def,
  106. deref_aktrecord,
  107. deref_aktstatic,
  108. deref_aktglobal,
  109. deref_aktlocal,
  110. deref_aktpara,
  111. deref_unit,
  112. deref_record,
  113. deref_local,
  114. deref_para,
  115. deref_parent_object
  116. );
  117. { symbol options }
  118. tsymoption=(sp_none,
  119. sp_public,
  120. sp_private,
  121. sp_published,
  122. sp_protected,
  123. sp_static,
  124. sp_hint_deprecated,
  125. sp_hint_platform,
  126. sp_hint_library,
  127. sp_hint_unimplemented,
  128. sp_has_overloaded,
  129. sp_internal { internal symbol, not reported as unused }
  130. );
  131. tsymoptions=set of tsymoption;
  132. { flags for a definition }
  133. tdefoption=(df_none,
  134. { init data has been generated }
  135. df_has_inittable,
  136. { rtti data has been generated }
  137. df_has_rttitable,
  138. { type is unique, i.e. declared with type = type <tdef>; }
  139. df_unique
  140. );
  141. tdefoptions=set of tdefoption;
  142. { tsymlist entry types }
  143. tsltype = (sl_none,
  144. sl_load,
  145. sl_call,
  146. sl_subscript,
  147. sl_vec,
  148. sl_typeconv,
  149. sl_absolutetype
  150. );
  151. { base types for orddef }
  152. tbasetype = (
  153. uvoid,
  154. u8bit,u16bit,u32bit,u64bit,
  155. s8bit,s16bit,s32bit,s64bit,
  156. bool8bit,bool16bit,bool32bit,
  157. uchar,uwidechar,scurrency
  158. );
  159. { float types }
  160. tfloattype = (
  161. s32real,s64real,s80real,
  162. s64comp,s64currency,s128real
  163. );
  164. { string types }
  165. tstringtype = (st_default,
  166. st_shortstring,
  167. st_longstring,
  168. {$ifndef ansistring_bits}
  169. st_ansistring,
  170. {$else}
  171. st_ansistring16,
  172. st_ansistring32,
  173. st_ansistring64,
  174. {$endif}
  175. st_widestring
  176. );
  177. { set types }
  178. tsettype = (
  179. normset,smallset,varset
  180. );
  181. tvarianttype = (
  182. vt_normalvariant,vt_olevariant
  183. );
  184. tcallercallee = (callerside,calleeside);
  185. { basic type for tprocdef and tprocvardef }
  186. tproctypeoption=(potype_none,
  187. potype_proginit, { Program initialization }
  188. potype_unitinit, { unit initialization }
  189. potype_unitfinalize, { unit finalization }
  190. potype_constructor, { Procedure is a constructor }
  191. potype_destructor, { Procedure is a destructor }
  192. potype_operator { Procedure defines an operator }
  193. );
  194. tproctypeoptions=set of tproctypeoption;
  195. { other options for tprocdef and tprocvardef }
  196. tprocoption=(po_none,
  197. po_classmethod, { class method }
  198. po_virtualmethod, { Procedure is a virtual method }
  199. po_abstractmethod, { Procedure is an abstract method }
  200. po_staticmethod, { static method }
  201. po_overridingmethod, { method with override directive }
  202. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  203. po_interrupt, { Procedure is an interrupt handler }
  204. po_iocheck, { IO checking should be done after a call to the procedure }
  205. po_assembler, { Procedure is written in assembler }
  206. po_msgstr, { method for string message handling }
  207. po_msgint, { method for int message handling }
  208. po_exports, { Procedure has export directive (needed for OS/2) }
  209. po_external, { Procedure is external (in other object or lib)}
  210. po_overload, { procedure is declared with overload directive }
  211. po_varargs, { printf like arguments }
  212. po_internconst, { procedure has constant evaluator intern }
  213. { flag that only the address of a method is returned and not a full methodpointer }
  214. po_addressonly,
  215. { procedure is exported }
  216. po_public,
  217. { calling convention is specified explicitly }
  218. po_hascallingconvention,
  219. { reintroduce flag }
  220. po_reintroduce,
  221. { location of parameters is given explicitly as it is necessary for some syscall
  222. conventions like that one of MorphOS }
  223. po_explicitparaloc,
  224. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  225. po_nostackframe,
  226. po_has_mangledname,
  227. po_has_public_name,
  228. po_forward,
  229. po_global,
  230. po_has_inlininginfo,
  231. { The different kind of syscalls on MorphOS }
  232. po_syscall_legacy,
  233. po_syscall_sysv,
  234. po_syscall_basesysv,
  235. po_syscall_sysvbase,
  236. po_syscall_r12base,
  237. po_local
  238. );
  239. tprocoptions=set of tprocoption;
  240. { options for objects and classes }
  241. tobjectdeftype = (odt_none,
  242. odt_class,
  243. odt_object,
  244. odt_interfacecom,
  245. odt_interfacecorba,
  246. odt_cppclass,
  247. odt_dispinterface
  248. );
  249. { options for objects and classes }
  250. tobjectoption=(oo_none,
  251. oo_is_forward, { the class is only a forward declared yet }
  252. oo_has_virtual, { the object/class has virtual methods }
  253. oo_has_private,
  254. oo_has_protected,
  255. oo_has_constructor, { the object/class has a constructor }
  256. oo_has_destructor, { the object/class has a destructor }
  257. oo_has_vmt, { the object/class has a vmt }
  258. oo_has_msgstr,
  259. oo_has_msgint,
  260. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  261. oo_has_default_property
  262. );
  263. tobjectoptions=set of tobjectoption;
  264. { options for properties }
  265. tpropertyoption=(ppo_none,
  266. ppo_indexed,
  267. ppo_defaultproperty,
  268. ppo_stored,
  269. ppo_hasparameters,
  270. ppo_is_override
  271. );
  272. tpropertyoptions=set of tpropertyoption;
  273. { options for variables }
  274. tvaroption=(vo_none,
  275. vo_is_C_var,
  276. vo_is_external,
  277. vo_is_dll_var,
  278. vo_is_thread_var,
  279. vo_has_local_copy,
  280. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  281. vo_is_exported,
  282. vo_is_high_para,
  283. vo_is_funcret,
  284. vo_is_self,
  285. vo_is_vmt,
  286. vo_is_result, { special result variable }
  287. vo_is_parentfp,
  288. vo_is_loop_counter, { used to detect assignments to loop counter }
  289. vo_is_hidden_para,
  290. vo_has_explicit_paraloc,
  291. vo_is_syscall_lib,
  292. vo_has_mangledname
  293. );
  294. tvaroptions=set of tvaroption;
  295. { register variable }
  296. tvarregable=(vr_none,
  297. vr_intreg,
  298. vr_fpureg,
  299. vr_mmreg
  300. );
  301. { types of the symtables }
  302. tsymtabletype = (abstractsymtable,
  303. globalsymtable,staticsymtable,
  304. objectsymtable,recordsymtable,
  305. localsymtable,parasymtable,
  306. withsymtable,stt_exceptsymtable,
  307. exportedmacrosymtable, localmacrosymtable
  308. );
  309. { definition contains the informations about a type }
  310. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  311. stringdef,enumdef,procdef,objectdef,errordef,
  312. filedef,formaldef,setdef,procvardef,floatdef,
  313. classrefdef,forwarddef,variantdef);
  314. { possible types for symtable entries }
  315. tsymtyp = (abstractsym,globalvarsym,localvarsym,paravarsym,fieldvarsym,
  316. typesym,procsym,unitsym,constsym,enumsym,typedconstsym,
  317. errorsym,syssym,labelsym,absolutevarsym,propertysym,
  318. macrosym,rttisym);
  319. { State of the variable, if it's declared, assigned or used }
  320. tvarstate=(vs_none,
  321. vs_declared,vs_assigned,vs_used
  322. );
  323. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  324. absolutetyp = (tovar,toasm,toaddr);
  325. tconsttyp = (constnone,
  326. constord,conststring,constreal,
  327. constset,constpointer,constnil,
  328. constresourcestring,constwstring,constguid
  329. );
  330. { RTTI information to store }
  331. trttitype = (
  332. fullrtti,initrtti
  333. );
  334. { The order is from low priority to high priority,
  335. Note: the operators > and < are used on this list }
  336. tequaltype = (
  337. te_incompatible,
  338. te_convert_operator,
  339. te_convert_l3, { compatible conversion with possible loss of data }
  340. te_convert_l2, { compatible less prefered conversion }
  341. te_convert_l1, { compatible conversion }
  342. te_equal, { the definitions are equal }
  343. te_exact
  344. );
  345. {$ifdef GDB}
  346. type
  347. tdefstabstatus = (
  348. stab_state_unused,
  349. stab_state_used,
  350. stab_state_writing,
  351. stab_state_written
  352. );
  353. const
  354. tagtypes : Set of tdeftype =
  355. [recorddef,enumdef,
  356. {$IfNDef GDBKnowsStrings}
  357. stringdef,
  358. {$EndIf not GDBKnowsStrings}
  359. {$IfNDef GDBKnowsFiles}
  360. filedef,
  361. {$EndIf not GDBKnowsFiles}
  362. objectdef];
  363. {$endif GDB}
  364. const
  365. clearstack_pocalls = [
  366. pocall_cdecl,pocall_cppdecl,pocall_syscall
  367. ];
  368. pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal,pocall_mwpascal];
  369. SymTypeName : array[tsymtyp] of string[12] = (
  370. 'abstractsym','globalvar','localvar','paravar','fieldvar',
  371. 'type','proc','unit','const','enum','typed const',
  372. 'errorsym','system sym','label','absolutevar','property',
  373. 'macrosym','rttisym'
  374. );
  375. DefTypeName : array[tdeftype] of string[12] = (
  376. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  377. 'stringdef','enumdef','procdef','objectdef','errordef',
  378. 'filedef','formaldef','setdef','procvardef','floatdef',
  379. 'classrefdef','forwarddef','variantdef'
  380. );
  381. EqualTypeName : array[tequaltype] of string[16] = (
  382. 'incompatible','convert_operator','convert_l3','convert_l2',
  383. 'convert_l1','equal','exact'
  384. );
  385. implementation
  386. initialization
  387. if pocall_default in [pocall_register,pocall_internproc] then
  388. include(pushleftright_pocalls,pocall_compilerproc);
  389. end.