symconst.pas 17 KB

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