symconst.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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. C_alignment = -1;
  25. bit_alignment = -2;
  26. { if you change one of the following contants, }
  27. { you have also to change the typinfo unit}
  28. { and the rtl/i386,template/rttip.inc files }
  29. tkUnknown = 0;
  30. tkInteger = 1;
  31. tkChar = 2;
  32. tkEnumeration = 3;
  33. tkFloat = 4;
  34. tkSet = 5;
  35. tkMethod = 6;
  36. tkSString = 7;
  37. tkString = tkSString;
  38. tkLString = 8;
  39. tkAString = 9;
  40. tkWString = 10;
  41. tkVariant = 11;
  42. tkArray = 12;
  43. tkRecord = 13;
  44. tkInterface= 14;
  45. tkClass = 15;
  46. tkObject = 16;
  47. tkWChar = 17;
  48. tkBool = 18;
  49. tkInt64 = 19;
  50. tkQWord = 20;
  51. tkDynArray = 21;
  52. tkInterfaceCorba = 22;
  53. tkProcVar = 23;
  54. tkUString = 24;
  55. tkUChar = 25;
  56. otSByte = 0;
  57. otUByte = 1;
  58. otSWord = 2;
  59. otUWord = 3;
  60. otSLong = 4;
  61. otULong = 5;
  62. ftSingle = 0;
  63. ftDouble = 1;
  64. ftExtended = 2;
  65. ftComp = 3;
  66. ftCurr = 4;
  67. ftFloat128 = 5;
  68. mkProcedure= 0;
  69. mkFunction = 1;
  70. mkConstructor = 2;
  71. mkDestructor = 3;
  72. mkClassProcedure= 4;
  73. mkClassFunction = 5;
  74. pfvar = 1;
  75. pfConst = 2;
  76. pfArray = 4;
  77. pfAddress = 8;
  78. pfReference= 16;
  79. pfOut = 32;
  80. unknown_level = 0;
  81. main_program_level = 1;
  82. normal_function_level = 2;
  83. { implicit parameter positions, normal parameters start at 10
  84. and will increase with 10 for each parameter. The high parameters
  85. will be inserted with n+1 }
  86. paranr_parentfp = 1;
  87. paranr_self = 2;
  88. paranr_result = 3;
  89. paranr_vmt = 4;
  90. { Required to support variations of syscalls on MorphOS }
  91. paranr_syscall_basesysv = 9;
  92. paranr_syscall_sysvbase = high(word)-4;
  93. paranr_syscall_r12base = high(word)-3;
  94. paranr_syscall_legacy = high(word)-2;
  95. paranr_result_leftright = high(word)-1;
  96. type
  97. { keep this in sync with TIntfFlag in rtl/objpas/typinfo.pp }
  98. TCompilerIntfFlag = (ifHasGuid,ifDispInterface,ifDispatch,ifHasStrGUID);
  99. { Deref entry options }
  100. tdereftype = (deref_nil,
  101. deref_unit,
  102. deref_symid,
  103. deref_defid
  104. );
  105. { symbol options }
  106. tsymoption=(sp_none,
  107. sp_public,
  108. sp_private,
  109. sp_published,
  110. sp_protected,
  111. sp_static,
  112. sp_hint_deprecated,
  113. sp_hint_platform,
  114. sp_hint_library,
  115. sp_hint_unimplemented,
  116. sp_has_overloaded,
  117. sp_internal, { internal symbol, not reported as unused }
  118. sp_strictprivate,
  119. sp_strictprotected,
  120. sp_implicitrename,
  121. sp_hidden,
  122. sp_hint_experimental,
  123. sp_generic_para
  124. );
  125. tsymoptions=set of tsymoption;
  126. { flags for a definition }
  127. tdefoption=(df_none,
  128. { type is unique, i.e. declared with type = type <tdef>; }
  129. df_unique,
  130. { type is a generic }
  131. df_generic,
  132. { type is a specialization of a generic type }
  133. df_specialization,
  134. { def has been copied from another def so symtable is not owned }
  135. df_copied_def
  136. );
  137. tdefoptions=set of tdefoption;
  138. tdefstate=(ds_none,
  139. ds_vmt_written,
  140. ds_rtti_table_used,
  141. ds_init_table_used,
  142. ds_rtti_table_written,
  143. ds_init_table_written,
  144. ds_dwarf_dbg_info_used,
  145. ds_dwarf_dbg_info_written
  146. );
  147. tdefstates=set of tdefstate;
  148. { tsymlist entry types }
  149. tsltype = (sl_none,
  150. sl_load,
  151. sl_call,
  152. sl_subscript,
  153. sl_vec,
  154. sl_typeconv,
  155. sl_absolutetype
  156. );
  157. { base types for orddef }
  158. tordtype = (
  159. uvoid,
  160. u8bit,u16bit,u32bit,u64bit,
  161. s8bit,s16bit,s32bit,s64bit,
  162. pasbool,bool8bit,bool16bit,bool32bit,bool64bit,
  163. uchar,uwidechar,scurrency
  164. );
  165. { string types }
  166. tstringtype = (
  167. st_shortstring,
  168. st_longstring,
  169. st_ansistring,
  170. st_widestring,
  171. st_unicodestring
  172. );
  173. tvarianttype = (
  174. vt_normalvariant,vt_olevariant
  175. );
  176. tcallercallee = (callerside,calleeside);
  177. { basic type for tprocdef and tprocvardef }
  178. tproctypeoption=(potype_none,
  179. potype_proginit, { Program initialization }
  180. potype_unitinit, { unit initialization }
  181. potype_unitfinalize, { unit finalization }
  182. potype_constructor, { Procedure is a constructor }
  183. potype_destructor, { Procedure is a destructor }
  184. potype_operator, { Procedure defines an operator }
  185. potype_procedure,
  186. potype_function
  187. );
  188. tproctypeoptions=set of tproctypeoption;
  189. { other options for tprocdef and tprocvardef }
  190. tprocoption=(po_none,
  191. po_classmethod, { class method }
  192. po_virtualmethod, { Procedure is a virtual method }
  193. po_abstractmethod, { Procedure is an abstract method }
  194. po_staticmethod, { static method }
  195. po_overridingmethod, { method with override directive }
  196. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  197. po_interrupt, { Procedure is an interrupt handler }
  198. po_iocheck, { IO checking should be done after a call to the procedure }
  199. po_assembler, { Procedure is written in assembler }
  200. po_msgstr, { method for string message handling }
  201. po_msgint, { method for int message handling }
  202. po_exports, { Procedure has export directive (needed for OS/2) }
  203. po_external, { Procedure is external (in other object or lib)}
  204. po_overload, { procedure is declared with overload directive }
  205. po_varargs, { printf like arguments }
  206. po_internconst, { procedure has constant evaluator intern }
  207. { flag that only the address of a method is returned and not a full methodpointer }
  208. po_addressonly,
  209. { procedure is exported }
  210. po_public,
  211. { calling convention is specified explicitly }
  212. po_hascallingconvention,
  213. { reintroduce flag }
  214. po_reintroduce,
  215. { location of parameters is given explicitly as it is necessary for some syscall
  216. conventions like that one of MorphOS }
  217. po_explicitparaloc,
  218. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  219. po_nostackframe,
  220. po_has_mangledname,
  221. po_has_public_name,
  222. po_forward,
  223. po_global,
  224. po_has_inlininginfo,
  225. { The different kind of syscalls on MorphOS }
  226. po_syscall_legacy,
  227. po_syscall_sysv,
  228. po_syscall_basesysv,
  229. po_syscall_sysvbase,
  230. po_syscall_r12base,
  231. po_local,
  232. { Procedure can be inlined }
  233. po_inline,
  234. { Procedure is used for internal compiler calls }
  235. po_compilerproc,
  236. { importing }
  237. po_has_importdll,
  238. po_has_importname,
  239. po_kylixlocal,
  240. po_dispid,
  241. { weakly linked (i.e., may or may not exist at run time) }
  242. po_weakexternal
  243. );
  244. tprocoptions=set of tprocoption;
  245. { options for objects and classes }
  246. tobjecttyp = (odt_none,
  247. odt_class,
  248. odt_object,
  249. odt_interfacecom,
  250. odt_interfacecom_property,
  251. odt_interfacecom_function,
  252. odt_interfacecorba,
  253. odt_cppclass,
  254. odt_dispinterface
  255. );
  256. { Variations in interfaces implementation }
  257. { Beware, this data is duplicated in the compiler and rtl. }
  258. { Do not change the order of the fields. }
  259. tinterfaceentrytype = (etStandard,
  260. etVirtualMethodResult,
  261. etStaticMethodResult,
  262. etFieldValue
  263. );
  264. { options for objects and classes }
  265. tobjectoption=(oo_none,
  266. oo_is_forward, { the class is only a forward declared yet }
  267. oo_has_virtual, { the object/class has virtual methods }
  268. oo_has_private,
  269. oo_has_protected,
  270. oo_has_strictprivate,
  271. oo_has_strictprotected,
  272. oo_has_constructor, { the object/class has a constructor }
  273. oo_has_destructor, { the object/class has a destructor }
  274. oo_has_vmt, { the object/class has a vmt }
  275. oo_has_msgstr,
  276. oo_has_msgint,
  277. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  278. oo_has_default_property,
  279. oo_has_valid_guid
  280. );
  281. tobjectoptions=set of tobjectoption;
  282. tarraydefoption=(ado_none,
  283. ado_IsConvertedPointer,
  284. ado_IsDynamicArray,
  285. ado_IsVariant,
  286. ado_IsConstructor,
  287. ado_IsArrayOfConst,
  288. ado_IsConstString,
  289. ado_IsBitPacked
  290. );
  291. tarraydefoptions=set of tarraydefoption;
  292. { options for properties }
  293. tpropertyoption=(ppo_none,
  294. ppo_indexed,
  295. ppo_defaultproperty,
  296. ppo_stored,
  297. ppo_hasparameters,
  298. ppo_implements
  299. );
  300. tpropertyoptions=set of tpropertyoption;
  301. { options for variables }
  302. tvaroption=(vo_none,
  303. vo_is_external,
  304. vo_is_dll_var,
  305. vo_is_thread_var,
  306. vo_has_local_copy,
  307. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  308. vo_is_public,
  309. vo_is_high_para,
  310. vo_is_funcret,
  311. vo_is_self,
  312. vo_is_vmt,
  313. vo_is_result, { special result variable }
  314. vo_is_parentfp,
  315. vo_is_loop_counter, { used to detect assignments to loop counter }
  316. vo_is_hidden_para,
  317. vo_has_explicit_paraloc,
  318. vo_is_syscall_lib,
  319. vo_has_mangledname,
  320. vo_is_typed_const,
  321. vo_is_range_check,
  322. vo_is_overflow_check,
  323. vo_is_typinfo_para,
  324. vo_is_weak_external
  325. );
  326. tvaroptions=set of tvaroption;
  327. { register variable }
  328. tvarregable=(vr_none,
  329. vr_intreg,
  330. vr_fpureg,
  331. vr_mmreg,
  332. { does not mean "needs address register", but "if it's a parameter which is }
  333. { passed by reference, then its address can be put in a register }
  334. vr_addr
  335. );
  336. { types of the symtables }
  337. TSymtabletype = (abstracTSymtable,
  338. globalsymtable,staticsymtable,
  339. ObjectSymtable,recordsymtable,
  340. localsymtable,parasymtable,
  341. withsymtable,stt_excepTSymtable,
  342. exportedmacrosymtable, localmacrosymtable
  343. );
  344. { definition contains the informations about a type }
  345. tdeftyp = (abstractdef,
  346. arraydef,recorddef,pointerdef,orddef,
  347. stringdef,enumdef,procdef,objectdef,errordef,
  348. filedef,formaldef,setdef,procvardef,floatdef,
  349. classrefdef,forwarddef,variantdef,undefineddef
  350. );
  351. { possible types for symtable entries }
  352. tsymtyp = (abstractsym,
  353. staticvarsym,localvarsym,paravarsym,fieldvarsym,
  354. typesym,procsym,unitsym,constsym,enumsym,
  355. errorsym,syssym,labelsym,absolutevarsym,propertysym,
  356. macrosym
  357. );
  358. { State of the variable:
  359. vs_declared: variable has been declared, not initialised
  360. (e.g. normal variable, out parameter)
  361. vs_initialised: variable has been declared and is valid
  362. (e.g. typed constant, var/const parameter)
  363. vs_read: variable has been read and the read was checked for validity
  364. (so a warning has been given if necessary)
  365. vs_read_not_warned: variable has been read, but we didn't warn about
  366. whether or not the variable was valid
  367. (e.g. read of global variable -> warn at end of compilation unit if
  368. the state is vs_read_not_warned, since that means it's only read and
  369. never written)
  370. vs_referred_not_inited: variable has been used in length/low/high/@/...
  371. expression, was not yet initialised and needn't be at that time
  372. (e.g. length() of a statically allocated array, or sizeof(variable))
  373. vs_written: variable has been assigned/written to, but not yet read
  374. (e.g. assigning something to a variable/parameter)
  375. vs_readwritten: variable has been written to and read from }
  376. tvarstate=(vs_none,
  377. vs_declared,vs_initialised,vs_read,vs_read_not_warned,
  378. vs_referred_not_inited,vs_written,vs_readwritten
  379. );
  380. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  381. absolutetyp = (tovar,toasm,toaddr);
  382. tconsttyp = (constnone,
  383. constord,conststring,constreal,
  384. constset,constpointer,constnil,
  385. constresourcestring,constwstring,constguid
  386. );
  387. { RTTI information to store }
  388. trttitype = (
  389. fullrtti,initrtti
  390. );
  391. { The order is from low priority to high priority,
  392. Note: the operators > and < are used on this list }
  393. tequaltype = (
  394. te_incompatible,
  395. te_convert_operator,
  396. te_convert_l5, { ad infinitum... }
  397. te_convert_l4, { and yet even less preferred conversion }
  398. te_convert_l3, { even less preferred conversion (possibly with loss of data) }
  399. te_convert_l2, { compatible less preferred conversion }
  400. te_convert_l1, { compatible conversion }
  401. te_equal, { the definitions are equal }
  402. te_exact
  403. );
  404. tvariantequaltype = (
  405. tve_incompatible,
  406. tve_chari64,
  407. tve_ustring,
  408. tve_wstring,
  409. tve_astring,
  410. tve_sstring,
  411. tve_boolformal,
  412. tve_extended,
  413. tve_dblcurrency,
  414. tve_single,
  415. tve_cardinal,
  416. tve_longint,
  417. tve_smallint,
  418. tve_word,
  419. tve_shortint,
  420. tve_byte
  421. );
  422. tvariantequaltypes = set of tvariantequaltype;
  423. tdefdbgstatus = (
  424. dbg_state_unused,
  425. dbg_state_used,
  426. dbg_state_writing,
  427. dbg_state_written,
  428. dbg_state_queued
  429. );
  430. const
  431. inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has_protected,
  432. oo_has_strictprotected,oo_has_strictprivate,oo_has_constructor,oo_has_destructor];
  433. clearstack_pocalls = [
  434. pocall_cdecl,pocall_cppdecl,pocall_syscall,pocall_mwpascal
  435. ];
  436. pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal];
  437. SymTypeName : array[tsymtyp] of string[12] = (
  438. 'abstractsym','globalvar','localvar','paravar','fieldvar',
  439. 'type','proc','unit','const','enum',
  440. 'errorsym','system sym','label','absolutevar','property',
  441. 'macrosym'
  442. );
  443. typName : array[tdeftyp] of string[12] = (
  444. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  445. 'stringdef','enumdef','procdef','objectdef','errordef',
  446. 'filedef','formaldef','setdef','procvardef','floatdef',
  447. 'classrefdef','forwarddef','variantdef','undefineddef'
  448. );
  449. EqualTypeName : array[tequaltype] of string[16] = (
  450. 'incompatible','convert_operator','convert_l5','convert_l4','convert_l3','convert_l2',
  451. 'convert_l1','equal','exact'
  452. );
  453. implementation
  454. end.