symconst.pas 16 KB

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