symconst.pas 15 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. const
  22. def_alignment = 4;
  23. { if you change one of the following contants, }
  24. { you have also to change the typinfo unit}
  25. { and the rtl/i386,template/rttip.inc files }
  26. tkUnknown = 0;
  27. tkInteger = 1;
  28. tkChar = 2;
  29. tkEnumeration = 3;
  30. tkFloat = 4;
  31. tkSet = 5;
  32. tkMethod = 6;
  33. tkSString = 7;
  34. tkString = tkSString;
  35. tkLString = 8;
  36. tkAString = 9;
  37. tkWString = 10;
  38. tkVariant = 11;
  39. tkArray = 12;
  40. tkRecord = 13;
  41. tkInterface= 14;
  42. tkClass = 15;
  43. tkObject = 16;
  44. tkWChar = 17;
  45. tkBool = 18;
  46. tkInt64 = 19;
  47. tkQWord = 20;
  48. tkDynArray = 21;
  49. tkInterfaceCorba = 22;
  50. otSByte = 0;
  51. otUByte = 1;
  52. otSWord = 2;
  53. otUWord = 3;
  54. otSLong = 4;
  55. otULong = 5;
  56. ftSingle = 0;
  57. ftDouble = 1;
  58. ftExtended = 2;
  59. ftComp = 3;
  60. ftCurr = 4;
  61. ftFloat128 = 5;
  62. mkProcedure= 0;
  63. mkFunction = 1;
  64. mkConstructor = 2;
  65. mkDestructor = 3;
  66. mkClassProcedure= 4;
  67. mkClassFunction = 5;
  68. pfvar = 1;
  69. pfConst = 2;
  70. pfArray = 4;
  71. pfAddress = 8;
  72. pfReference= 16;
  73. pfOut = 32;
  74. unknown_level = 0;
  75. main_program_level = 1;
  76. normal_function_level = 2;
  77. type
  78. { Deref entry options }
  79. tdereftype = (derefnil,
  80. derefaktrecordindex,
  81. derefaktstaticindex,
  82. derefunit,
  83. derefrecord,
  84. derefindex,
  85. dereflocal,
  86. derefpara,
  87. derefaktlocal
  88. );
  89. { symbol options }
  90. tsymoption=(sp_none,
  91. sp_public,
  92. sp_private,
  93. sp_published,
  94. sp_protected,
  95. sp_static,
  96. sp_hint_deprecated,
  97. sp_hint_platform,
  98. sp_hint_library,
  99. sp_hint_unimplemented,
  100. sp_has_overloaded
  101. );
  102. tsymoptions=set of tsymoption;
  103. { flags for a definition }
  104. tdefoption=(df_none,
  105. { init data has been generated }
  106. df_has_inittable,
  107. { rtti data has been generated }
  108. df_has_rttitable,
  109. { type is unique, i.e. declared with type = type <tdef>; }
  110. df_unique
  111. );
  112. tdefoptions=set of tdefoption;
  113. { tsymlist entry types }
  114. tsltype = (sl_none,
  115. sl_load,
  116. sl_call,
  117. sl_subscript,
  118. sl_vec
  119. );
  120. { base types for orddef }
  121. tbasetype = (
  122. uvoid,
  123. u8bit,u16bit,u32bit,u64bit,
  124. s8bit,s16bit,s32bit,s64bit,
  125. bool8bit,bool16bit,bool32bit,
  126. uchar,uwidechar,scurrency
  127. );
  128. { float types }
  129. tfloattype = (
  130. s32real,s64real,s80real,
  131. s64comp,s64currency,s128real
  132. );
  133. { string types }
  134. tstringtype = (st_default,
  135. st_shortstring, st_longstring, st_ansistring, st_widestring
  136. );
  137. { set types }
  138. tsettype = (
  139. normset,smallset,varset
  140. );
  141. { basic type for tprocdef and tprocvardef }
  142. tproctypeoption=(potype_none,
  143. potype_proginit, { Program initialization }
  144. potype_unitinit, { unit initialization }
  145. potype_unitfinalize, { unit finalization }
  146. potype_constructor, { Procedure is a constructor }
  147. potype_destructor, { Procedure is a destructor }
  148. potype_operator { Procedure defines an operator }
  149. );
  150. tproctypeoptions=set of tproctypeoption;
  151. { other options for tprocdef and tprocvardef }
  152. tprocoption=(po_none,
  153. po_classmethod, { class method }
  154. po_virtualmethod, { Procedure is a virtual method }
  155. po_abstractmethod, { Procedure is an abstract method }
  156. po_staticmethod, { static method }
  157. po_overridingmethod, { method with override directive }
  158. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  159. po_interrupt, { Procedure is an interrupt handler }
  160. po_iocheck, { IO checking should be done after a call to the procedure }
  161. po_assembler, { Procedure is written in assembler }
  162. po_msgstr, { method for string message handling }
  163. po_msgint, { method for int message handling }
  164. po_exports, { Procedure has export directive (needed for OS/2) }
  165. po_external, { Procedure is external (in other object or lib)}
  166. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  167. po_saveregisters, { save all registers }
  168. po_overload, { procedure is declared with overload directive }
  169. po_varargs, { printf like arguments }
  170. po_leftright, { push arguments from left to right }
  171. po_clearstack, { caller clears the stack }
  172. po_internconst, { procedure has constant evaluator intern }
  173. po_addressonly { flag that only the address of a method is returned and not a full methodpointer }
  174. );
  175. tprocoptions=set of tprocoption;
  176. { options for objects and classes }
  177. tobjectdeftype = (odt_none,
  178. odt_class,
  179. odt_object,
  180. odt_interfacecom,
  181. odt_interfacecorba,
  182. odt_cppclass,
  183. odt_dispinterface
  184. );
  185. { options for objects and classes }
  186. tobjectoption=(oo_none,
  187. oo_is_forward, { the class is only a forward declared yet }
  188. oo_has_virtual, { the object/class has virtual methods }
  189. oo_has_private,
  190. oo_has_protected,
  191. oo_has_constructor, { the object/class has a constructor }
  192. oo_has_destructor, { the object/class has a destructor }
  193. oo_has_vmt, { the object/class has a vmt }
  194. oo_has_msgstr,
  195. oo_has_msgint,
  196. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  197. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  198. );
  199. tobjectoptions=set of tobjectoption;
  200. { options for properties }
  201. tpropertyoption=(ppo_none,
  202. ppo_indexed,
  203. ppo_defaultproperty,
  204. ppo_stored,
  205. ppo_hasparameters,
  206. ppo_is_override
  207. );
  208. tpropertyoptions=set of tpropertyoption;
  209. { options for variables }
  210. tvaroption=(vo_none,
  211. vo_regable,
  212. vo_is_C_var,
  213. vo_is_external,
  214. vo_is_dll_var,
  215. vo_is_thread_var,
  216. vo_fpuregable,
  217. vo_is_local_copy,
  218. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  219. vo_is_exported,
  220. vo_is_high_value,
  221. vo_is_funcret,
  222. vo_is_self,
  223. vo_is_vmt,
  224. vo_is_result { special result variable }
  225. );
  226. tvaroptions=set of tvaroption;
  227. { types of the symtables }
  228. tsymtabletype = (abstractsymtable,
  229. globalsymtable,staticsymtable,
  230. objectsymtable,recordsymtable,
  231. localsymtable,parasymtable,
  232. withsymtable,stt_exceptsymtable,
  233. { used for inline detection }
  234. inlineparasymtable,inlinelocalsymtable
  235. );
  236. { definition contains the informations about a type }
  237. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  238. stringdef,enumdef,procdef,objectdef,errordef,
  239. filedef,formaldef,setdef,procvardef,floatdef,
  240. classrefdef,forwarddef,variantdef);
  241. { possible types for symtable entries }
  242. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  243. constsym,enumsym,typedconstsym,errorsym,syssym,
  244. labelsym,absolutesym,propertysym,macrosym,rttisym);
  245. { State of the variable, if it's declared, assigned or used }
  246. tvarstate=(vs_none,
  247. vs_declared,vs_declared_and_first_found,
  248. vs_set_but_first_not_passed,vs_assigned,vs_used
  249. );
  250. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  251. absolutetyp = (tovar,toasm,toaddr);
  252. tconsttyp = (constnone,
  253. constord,conststring,constreal,constbool,
  254. constint,constchar,constset,constpointer,constnil,
  255. constresourcestring,constwstring,constwchar,constguid
  256. );
  257. { RTTI information to store }
  258. trttitype = (
  259. fullrtti,initrtti
  260. );
  261. { The order is from low priority to high priority,
  262. Note: the operators > and < are used on this list }
  263. tequaltype = (
  264. te_incompatible,
  265. te_convert_operator,
  266. te_convert_l3, { compatible conversion with possible loss of data }
  267. te_convert_l2, { compatible less prefered conversion }
  268. te_convert_l1, { compatible conversion }
  269. te_equal, { the definitions are equal }
  270. te_exact
  271. );
  272. {$ifdef GDB}
  273. type
  274. tdefstabstatus = (
  275. not_written,
  276. being_written,
  277. written);
  278. const
  279. tagtypes : Set of tdeftype =
  280. [recorddef,enumdef,
  281. {$IfNDef GDBKnowsStrings}
  282. stringdef,
  283. {$EndIf not GDBKnowsStrings}
  284. {$IfNDef GDBKnowsFiles}
  285. filedef,
  286. {$EndIf not GDBKnowsFiles}
  287. objectdef];
  288. {$endif GDB}
  289. const
  290. SymTypeName : array[tsymtyp] of string[12] = (
  291. 'abstractsym','variable','type','proc','unit',
  292. 'const','enum','typed const','errorsym','system sym',
  293. 'label','absolute','property','macrosym','rttisym'
  294. );
  295. DefTypeName : array[tdeftype] of string[12] = (
  296. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  297. 'stringdef','enumdef','procdef','objectdef','errordef',
  298. 'filedef','formaldef','setdef','procvardef','floatdef',
  299. 'classrefdef','forwarddef','variantdef'
  300. );
  301. EqualTypeName : array[tequaltype] of string[16] = (
  302. 'incompatible','convert_operator','convert_l3','convert_l2',
  303. 'convert_l1','equal','exact'
  304. );
  305. implementation
  306. end.
  307. {
  308. $Log$
  309. Revision 1.55 2003-05-15 21:10:32 peter
  310. * remove po_containsself
  311. Revision 1.54 2003/05/09 17:47:03 peter
  312. * self moved to hidden parameter
  313. * removed hdisposen,hnewn,selfn
  314. Revision 1.53 2003/05/05 14:53:16 peter
  315. * vs_hidden replaced by is_hidden boolean
  316. Revision 1.52 2003/04/27 11:21:34 peter
  317. * aktprocdef renamed to current_procdef
  318. * procinfo renamed to current_procinfo
  319. * procinfo will now be stored in current_module so it can be
  320. cleaned up properly
  321. * gen_main_procsym changed to create_main_proc and release_main_proc
  322. to also generate a tprocinfo structure
  323. * fixed unit implicit initfinal
  324. Revision 1.51 2003/04/27 07:29:51 peter
  325. * current_procdef cleanup, current_procdef is now always nil when parsing
  326. a new procdef declaration
  327. * aktprocsym removed
  328. * lexlevel removed, use symtable.symtablelevel instead
  329. * implicit init/final code uses the normal genentry/genexit
  330. * funcret state checking updated for new funcret handling
  331. Revision 1.50 2003/04/26 00:33:07 peter
  332. * vo_is_result flag added for the special RESULT symbol
  333. Revision 1.49 2003/04/25 20:59:35 peter
  334. * removed funcretn,funcretsym, function result is now in varsym
  335. and aliases for result and function name are added using absolutesym
  336. * vs_hidden parameter for funcret passed in parameter
  337. * vs_hidden fixes
  338. * writenode changed to printnode and released from extdebug
  339. * -vp option added to generate a tree.log with the nodetree
  340. * nicer printnode for statements, callnode
  341. Revision 1.48 2003/04/23 20:16:04 peter
  342. + added currency support based on int64
  343. + is_64bit for use in cg units instead of is_64bitint
  344. * removed cgmessage from n386add, replace with internalerrors
  345. Revision 1.47 2003/04/23 11:37:33 peter
  346. * po_comp for proc to procvar fixed
  347. Revision 1.46 2003/01/16 22:13:52 peter
  348. * convert_l3 convertlevel added. This level is used for conversions
  349. where information can be lost like converting widestring->ansistring
  350. or dword->byte
  351. Revision 1.45 2003/01/09 21:52:37 peter
  352. * merged some verbosity options.
  353. * V_LineInfo is a verbosity flag to include line info
  354. Revision 1.44 2003/01/06 21:16:52 peter
  355. * po_addressonly added to retrieve the address of a methodpointer
  356. only, this is used for @tclass.method which has no self pointer
  357. Revision 1.43 2003/01/05 15:54:15 florian
  358. + added proper support of type = type <type>; for simple types
  359. Revision 1.42 2003/01/05 13:36:53 florian
  360. * x86-64 compiles
  361. + very basic support for float128 type (x86-64 only)
  362. Revision 1.41 2003/01/01 22:51:03 peter
  363. * high value insertion changed so it works also when 2 parameters
  364. are passed
  365. Revision 1.40 2002/12/29 14:57:50 peter
  366. * unit loading changed to first register units and load them
  367. afterwards. This is needed to support uses xxx in yyy correctly
  368. * unit dependency check fixed
  369. Revision 1.39 2002/12/15 11:26:02 peter
  370. * ignore vs_hidden parameters when choosing overloaded proc
  371. Revision 1.38 2002/12/05 14:44:38 florian
  372. + oo_dispinterface added
  373. Revision 1.37 2002/11/29 22:31:20 carl
  374. + unimplemented hint directive added
  375. * hint directive parsing implemented
  376. * warning on these directives
  377. Revision 1.36 2002/10/20 15:34:16 peter
  378. * removed df_unique flag. It breaks code. For a good type=type <id>
  379. a def copy is required
  380. Revision 1.35 2002/10/06 12:25:05 florian
  381. + proper support of type <id> = type <another id>;
  382. Revision 1.34 2002/08/19 19:36:44 peter
  383. * More fixes for cross unit inlining, all tnodes are now implemented
  384. * Moved pocall_internconst to po_internconst because it is not a
  385. calling type at all and it conflicted when inlining of these small
  386. functions was requested
  387. Revision 1.33 2002/07/01 16:23:54 peter
  388. * cg64 patch
  389. * basics for currency
  390. * asnode updates for class and interface (not finished)
  391. Revision 1.32 2002/05/18 13:34:18 peter
  392. * readded missing revisions
  393. Revision 1.31 2002/05/16 19:46:44 carl
  394. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  395. + try to fix temp allocation (still in ifdef)
  396. + generic constructor calls
  397. + start of tassembler / tmodulebase class cleanup
  398. Revision 1.30 2002/05/14 19:34:50 peter
  399. * removed old logs and updated copyright year
  400. Revision 1.29 2002/05/12 16:53:10 peter
  401. * moved entry and exitcode to ncgutil and cgobj
  402. * foreach gets extra argument for passing local data to the
  403. iterator function
  404. * -CR checks also class typecasts at runtime by changing them
  405. into as
  406. * fixed compiler to cycle with the -CR option
  407. * fixed stabs with elf writer, finally the global variables can
  408. be watched
  409. * removed a lot of routines from cga unit and replaced them by
  410. calls to cgobj
  411. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  412. u32bit then the other is typecasted also to u32bit without giving
  413. a rangecheck warning/error.
  414. * fixed pascal calling method with reversing also the high tree in
  415. the parast, detected by tcalcst3 test
  416. Revision 1.28 2002/01/06 12:08:15 peter
  417. * removed uauto from orddef, use new range_to_basetype generating
  418. the correct ordinal type for a range
  419. }