symconst.pas 16 KB

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