symconst.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Symbol table constants
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit symconst;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. globtype;
  23. const
  24. def_alignment = 4;
  25. { if you change one of the following contants, }
  26. { you have also to change the typinfo unit}
  27. { and the rtl/i386,template/rttip.inc files }
  28. tkUnknown = 0;
  29. tkInteger = 1;
  30. tkChar = 2;
  31. tkEnumeration = 3;
  32. tkFloat = 4;
  33. tkSet = 5;
  34. tkMethod = 6;
  35. tkSString = 7;
  36. tkString = tkSString;
  37. tkLString = 8;
  38. {$ifdef ansistring_bits}
  39. tkA32String = 9;
  40. {$else}
  41. tkAString = 9;
  42. {$endif}
  43. tkWString = 10;
  44. tkVariant = 11;
  45. tkArray = 12;
  46. tkRecord = 13;
  47. tkInterface= 14;
  48. tkClass = 15;
  49. tkObject = 16;
  50. tkWChar = 17;
  51. tkBool = 18;
  52. tkInt64 = 19;
  53. tkQWord = 20;
  54. tkDynArray = 21;
  55. tkInterfaceCorba = 22;
  56. {$ifdef ansistring_bits}
  57. tkA16string = 23;
  58. tkA64string = 24;
  59. {$endif}
  60. otSByte = 0;
  61. otUByte = 1;
  62. otSWord = 2;
  63. otUWord = 3;
  64. otSLong = 4;
  65. otULong = 5;
  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. pfvar = 1;
  79. pfConst = 2;
  80. pfArray = 4;
  81. pfAddress = 8;
  82. pfReference= 16;
  83. pfOut = 32;
  84. unknown_level = 0;
  85. main_program_level = 1;
  86. normal_function_level = 2;
  87. { implicit parameter positions, normal parameters start at 10
  88. and will increase with 10 for each parameter. The high parameters
  89. will be inserted with n+1 }
  90. paranr_parentfp = 1;
  91. paranr_result = 2;
  92. paranr_self = 3;
  93. paranr_vmt = 4;
  94. paranr_syscall = high(word)-2;
  95. paranr_result_leftright = high(word)-1;
  96. type
  97. { Deref entry options }
  98. tdereftype = (deref_nil,
  99. deref_sym,
  100. deref_def,
  101. deref_aktrecord,
  102. deref_aktstatic,
  103. deref_aktglobal,
  104. deref_aktlocal,
  105. deref_aktpara,
  106. deref_unit,
  107. deref_record,
  108. deref_local,
  109. deref_para,
  110. deref_parent_object
  111. );
  112. { symbol options }
  113. tsymoption=(sp_none,
  114. sp_public,
  115. sp_private,
  116. sp_published,
  117. sp_protected,
  118. sp_static,
  119. sp_hint_deprecated,
  120. sp_hint_platform,
  121. sp_hint_library,
  122. sp_hint_unimplemented,
  123. sp_has_overloaded,
  124. sp_internal { internal symbol, not reported as unused }
  125. );
  126. tsymoptions=set of tsymoption;
  127. { flags for a definition }
  128. tdefoption=(df_none,
  129. { init data has been generated }
  130. df_has_inittable,
  131. { rtti data has been generated }
  132. df_has_rttitable,
  133. { type is unique, i.e. declared with type = type <tdef>; }
  134. df_unique
  135. );
  136. tdefoptions=set of tdefoption;
  137. { tsymlist entry types }
  138. tsltype = (sl_none,
  139. sl_load,
  140. sl_call,
  141. sl_subscript,
  142. sl_vec,
  143. sl_typeconv,
  144. sl_absolutetype
  145. );
  146. { base types for orddef }
  147. tbasetype = (
  148. uvoid,
  149. u8bit,u16bit,u32bit,u64bit,
  150. s8bit,s16bit,s32bit,s64bit,
  151. bool8bit,bool16bit,bool32bit,
  152. uchar,uwidechar,scurrency
  153. );
  154. { float types }
  155. tfloattype = (
  156. s32real,s64real,s80real,
  157. s64comp,s64currency,s128real
  158. );
  159. { string types }
  160. tstringtype = (st_default,
  161. st_shortstring,
  162. st_longstring,
  163. {$ifndef ansistring_bits}
  164. st_ansistring,
  165. {$else}
  166. st_ansistring16,
  167. st_ansistring32,
  168. st_ansistring64,
  169. {$endif}
  170. st_widestring
  171. );
  172. { set types }
  173. tsettype = (
  174. normset,smallset,varset
  175. );
  176. tvarianttype = (
  177. vt_normalvariant,vt_olevariant
  178. );
  179. tcallercallee = (callerside,calleeside);
  180. { basic type for tprocdef and tprocvardef }
  181. tproctypeoption=(potype_none,
  182. potype_proginit, { Program initialization }
  183. potype_unitinit, { unit initialization }
  184. potype_unitfinalize, { unit finalization }
  185. potype_constructor, { Procedure is a constructor }
  186. potype_destructor, { Procedure is a destructor }
  187. potype_operator { Procedure defines an operator }
  188. );
  189. tproctypeoptions=set of tproctypeoption;
  190. { other options for tprocdef and tprocvardef }
  191. tprocoption=(po_none,
  192. po_classmethod, { class method }
  193. po_virtualmethod, { Procedure is a virtual method }
  194. po_abstractmethod, { Procedure is an abstract method }
  195. po_staticmethod, { static method }
  196. po_overridingmethod, { method with override directive }
  197. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  198. po_interrupt, { Procedure is an interrupt handler }
  199. po_iocheck, { IO checking should be done after a call to the procedure }
  200. po_assembler, { Procedure is written in assembler }
  201. po_msgstr, { method for string message handling }
  202. po_msgint, { method for int message handling }
  203. po_exports, { Procedure has export directive (needed for OS/2) }
  204. po_external, { Procedure is external (in other object or lib)}
  205. po_overload, { procedure is declared with overload directive }
  206. po_varargs, { printf like arguments }
  207. po_internconst, { procedure has constant evaluator intern }
  208. { flag that only the address of a method is returned and not a full methodpointer }
  209. po_addressonly,
  210. { procedure is exported }
  211. po_public,
  212. { calling convention is specified explicitly }
  213. po_hascallingconvention,
  214. { reintroduce flag }
  215. po_reintroduce,
  216. { location of parameters is given explicitly as it is necessary for some syscall
  217. conventions like that one of MorphOS }
  218. po_explicitparaloc,
  219. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  220. po_nostackframe,
  221. po_has_mangledname,
  222. po_has_public_name,
  223. po_forward,
  224. po_global,
  225. po_has_inlininginfo
  226. );
  227. tprocoptions=set of tprocoption;
  228. { options for objects and classes }
  229. tobjectdeftype = (odt_none,
  230. odt_class,
  231. odt_object,
  232. odt_interfacecom,
  233. odt_interfacecorba,
  234. odt_cppclass,
  235. odt_dispinterface
  236. );
  237. { options for objects and classes }
  238. tobjectoption=(oo_none,
  239. oo_is_forward, { the class is only a forward declared yet }
  240. oo_has_virtual, { the object/class has virtual methods }
  241. oo_has_private,
  242. oo_has_protected,
  243. oo_has_constructor, { the object/class has a constructor }
  244. oo_has_destructor, { the object/class has a destructor }
  245. oo_has_vmt, { the object/class has a vmt }
  246. oo_has_msgstr,
  247. oo_has_msgint,
  248. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  249. oo_has_default_property
  250. );
  251. tobjectoptions=set of tobjectoption;
  252. { options for properties }
  253. tpropertyoption=(ppo_none,
  254. ppo_indexed,
  255. ppo_defaultproperty,
  256. ppo_stored,
  257. ppo_hasparameters,
  258. ppo_is_override
  259. );
  260. tpropertyoptions=set of tpropertyoption;
  261. { options for variables }
  262. tvaroption=(vo_none,
  263. vo_is_C_var,
  264. vo_is_external,
  265. vo_is_dll_var,
  266. vo_is_thread_var,
  267. vo_has_local_copy,
  268. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  269. vo_is_exported,
  270. vo_is_high_para,
  271. vo_is_funcret,
  272. vo_is_self,
  273. vo_is_vmt,
  274. vo_is_result, { special result variable }
  275. vo_is_parentfp,
  276. vo_is_loop_counter, { used to detect assignments to loop counter }
  277. vo_is_hidden_para,
  278. vo_has_explicit_paraloc,
  279. vo_is_syscall_lib,
  280. vo_has_mangledname
  281. );
  282. tvaroptions=set of tvaroption;
  283. { register variable }
  284. tvarregable=(vr_none,
  285. vr_intreg,
  286. vr_fpureg,
  287. vr_mmreg
  288. );
  289. { types of the symtables }
  290. tsymtabletype = (abstractsymtable,
  291. globalsymtable,staticsymtable,
  292. objectsymtable,recordsymtable,
  293. localsymtable,parasymtable,
  294. withsymtable,stt_exceptsymtable
  295. );
  296. { definition contains the informations about a type }
  297. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  298. stringdef,enumdef,procdef,objectdef,errordef,
  299. filedef,formaldef,setdef,procvardef,floatdef,
  300. classrefdef,forwarddef,variantdef);
  301. { possible types for symtable entries }
  302. tsymtyp = (abstractsym,globalvarsym,localvarsym,paravarsym,fieldvarsym,
  303. typesym,procsym,unitsym,constsym,enumsym,typedconstsym,
  304. errorsym,syssym,labelsym,absolutevarsym,propertysym,
  305. macrosym,rttisym);
  306. { State of the variable, if it's declared, assigned or used }
  307. tvarstate=(vs_none,
  308. vs_declared,vs_assigned,vs_used
  309. );
  310. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  311. absolutetyp = (tovar,toasm,toaddr);
  312. tconsttyp = (constnone,
  313. constord,conststring,constreal,
  314. constset,constpointer,constnil,
  315. constresourcestring,constwstring,constguid
  316. );
  317. { RTTI information to store }
  318. trttitype = (
  319. fullrtti,initrtti
  320. );
  321. { The order is from low priority to high priority,
  322. Note: the operators > and < are used on this list }
  323. tequaltype = (
  324. te_incompatible,
  325. te_convert_operator,
  326. te_convert_l3, { compatible conversion with possible loss of data }
  327. te_convert_l2, { compatible less prefered conversion }
  328. te_convert_l1, { compatible conversion }
  329. te_equal, { the definitions are equal }
  330. te_exact
  331. );
  332. {$ifdef GDB}
  333. type
  334. tdefstabstatus = (
  335. stab_state_unused,
  336. stab_state_used,
  337. stab_state_writing,
  338. stab_state_written
  339. );
  340. const
  341. tagtypes : Set of tdeftype =
  342. [recorddef,enumdef,
  343. {$IfNDef GDBKnowsStrings}
  344. stringdef,
  345. {$EndIf not GDBKnowsStrings}
  346. {$IfNDef GDBKnowsFiles}
  347. filedef,
  348. {$EndIf not GDBKnowsFiles}
  349. objectdef];
  350. {$endif GDB}
  351. const
  352. clearstack_pocalls = [
  353. pocall_cdecl,pocall_cppdecl,pocall_syscall
  354. ];
  355. pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal];
  356. SymTypeName : array[tsymtyp] of string[12] = (
  357. 'abstractsym','globalvar','localvar','paravar','fieldvar',
  358. 'type','proc','unit','const','enum','typed const',
  359. 'errorsym','system sym','label','absolutevar','property',
  360. 'macrosym','rttisym'
  361. );
  362. DefTypeName : array[tdeftype] of string[12] = (
  363. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  364. 'stringdef','enumdef','procdef','objectdef','errordef',
  365. 'filedef','formaldef','setdef','procvardef','floatdef',
  366. 'classrefdef','forwarddef','variantdef'
  367. );
  368. EqualTypeName : array[tequaltype] of string[16] = (
  369. 'incompatible','convert_operator','convert_l3','convert_l2',
  370. 'convert_l1','equal','exact'
  371. );
  372. implementation
  373. initialization
  374. if pocall_default in [pocall_register,pocall_internproc] then
  375. include(pushleftright_pocalls,pocall_compilerproc);
  376. end.
  377. {
  378. $Log$
  379. Revision 1.96 2004-12-05 12:28:11 peter
  380. * procvar handling for tp procvar mode fixed
  381. * proc to procvar moved from addrnode to typeconvnode
  382. * inlininginfo is now allocated only for inline routines that
  383. can be inlined, introduced a new flag po_has_inlining_info
  384. Revision 1.95 2004/11/19 08:17:02 michael
  385. * Split po_public into po_public and po_global (Peter)
  386. Revision 1.94 2004/11/17 22:21:35 peter
  387. mangledname setting moved to place after the complete proc declaration is read
  388. import generation moved to place where body is also parsed (still gives problems with win32)
  389. Revision 1.93 2004/11/15 23:35:31 peter
  390. * tparaitem removed, use tparavarsym instead
  391. * parameter order is now calculated from paranr value in tparavarsym
  392. Revision 1.92 2004/11/08 22:09:59 peter
  393. * tvarsym splitted
  394. Revision 1.91 2004/11/01 10:33:01 peter
  395. * symlist typeconv for absolute fixed
  396. Revision 1.90 2004/10/24 20:01:08 peter
  397. * remove saveregister calling convention
  398. Revision 1.89 2004/10/08 17:09:43 peter
  399. * tvarsym.varregable added, split vo_regable from varoptions
  400. Revision 1.88 2004/09/13 20:30:22 peter
  401. * vo_is_loop_counter added
  402. Revision 1.87 2004/08/25 15:57:04 peter
  403. * allow only 1 default property
  404. Revision 1.86 2004/07/09 22:17:32 peter
  405. * revert has_localst patch
  406. * replace aktstaticsymtable/aktglobalsymtable with current_module
  407. Revision 1.85 2004/07/06 19:52:04 peter
  408. * fix storing of localst in ppu
  409. Revision 1.84 2004/06/20 08:55:30 florian
  410. * logs truncated
  411. Revision 1.83 2004/06/16 20:07:09 florian
  412. * dwarf branch merged
  413. Revision 1.82 2004/05/23 14:32:17 peter
  414. * tprocinfoflag moved to globtype
  415. Revision 1.81 2004/04/29 19:56:37 daniel
  416. * Prepare compiler infrastructure for multiple ansistring types
  417. Revision 1.80 2004/04/28 15:19:03 florian
  418. + syscall directive support for MorphOS added
  419. Revision 1.79 2004/04/18 15:22:24 florian
  420. + location support for arguments, currently PowerPC/MorphOS only
  421. }