symconst.pas 15 KB

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