symconst.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. mkProcedure= 0;
  62. mkFunction = 1;
  63. mkConstructor = 2;
  64. mkDestructor = 3;
  65. mkClassProcedure= 4;
  66. mkClassFunction = 5;
  67. pfvar = 1;
  68. pfConst = 2;
  69. pfArray = 4;
  70. pfAddress = 8;
  71. pfReference= 16;
  72. pfOut = 32;
  73. {# These are the different possible base values that can
  74. be taken from the lexlevel variable when parsing. The
  75. lexlevel can be bigger if parsding recursive routines.
  76. }
  77. main_program_level = 1;
  78. unit_init_level = 1;
  79. normal_function_level = 2;
  80. type
  81. { Deref entry options }
  82. tdereftype = (derefnil,
  83. derefaktrecordindex,
  84. derefaktstaticindex,
  85. derefunit,
  86. derefrecord,
  87. derefindex,
  88. dereflocal,
  89. derefpara,
  90. derefaktlocal
  91. );
  92. { symbol options }
  93. tsymoption=(sp_none,
  94. sp_public,
  95. sp_private,
  96. sp_published,
  97. sp_protected,
  98. sp_static,
  99. sp_hint_deprecated,
  100. sp_hint_platform,
  101. sp_hint_library,
  102. sp_has_overloaded
  103. );
  104. tsymoptions=set of tsymoption;
  105. { flags for a definition }
  106. tdefoption=(df_none,
  107. { init data has been generated }
  108. df_has_inittable,
  109. { rtti data has been generated }
  110. df_has_rttitable
  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
  127. );
  128. { float types }
  129. tfloattype = (
  130. s32real,s64real,s80real,
  131. s64comp,s64currency
  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_containsself, { self is passed explicit to the compiler }
  160. po_interrupt, { Procedure is an interrupt handler }
  161. po_iocheck, { IO checking should be done after a call to the procedure }
  162. po_assembler, { Procedure is written in assembler }
  163. po_msgstr, { method for string message handling }
  164. po_msgint, { method for int message handling }
  165. po_exports, { Procedure has export directive (needed for OS/2) }
  166. po_external, { Procedure is external (in other object or lib)}
  167. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  168. po_saveregisters, { save all registers }
  169. po_overload, { procedure is declared with overload directive }
  170. po_varargs, { printf like arguments }
  171. po_leftright, { push arguments from left to right }
  172. po_clearstack, { caller clears the stack }
  173. po_internconst { procedure has constant evaluator intern }
  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. );
  184. { options for objects and classes }
  185. tobjectoption=(oo_none,
  186. oo_is_forward, { the class is only a forward declared yet }
  187. oo_has_virtual, { the object/class has virtual methods }
  188. oo_has_private,
  189. oo_has_protected,
  190. oo_has_constructor, { the object/class has a constructor }
  191. oo_has_destructor, { the object/class has a destructor }
  192. oo_has_vmt, { the object/class has a vmt }
  193. oo_has_msgstr,
  194. oo_has_msgint,
  195. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  196. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  197. );
  198. tobjectoptions=set of tobjectoption;
  199. { options for properties }
  200. tpropertyoption=(ppo_none,
  201. ppo_indexed,
  202. ppo_defaultproperty,
  203. ppo_stored,
  204. ppo_hasparameters,
  205. ppo_is_override
  206. );
  207. tpropertyoptions=set of tpropertyoption;
  208. { options for variables }
  209. tvaroption=(vo_none,
  210. vo_regable,
  211. vo_is_C_var,
  212. vo_is_external,
  213. vo_is_dll_var,
  214. vo_is_thread_var,
  215. vo_fpuregable,
  216. vo_is_local_copy,
  217. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  218. vo_is_exported
  219. );
  220. tvaroptions=set of tvaroption;
  221. { types of the symtables }
  222. tsymtabletype = (abstractsymtable,
  223. globalsymtable,staticsymtable,
  224. objectsymtable,recordsymtable,
  225. localsymtable,parasymtable,
  226. withsymtable,stt_exceptsymtable,
  227. { used for inline detection }
  228. inlineparasymtable,inlinelocalsymtable
  229. );
  230. { definition contains the informations about a type }
  231. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  232. stringdef,enumdef,procdef,objectdef,errordef,
  233. filedef,formaldef,setdef,procvardef,floatdef,
  234. classrefdef,forwarddef,variantdef);
  235. { possible types for symtable entries }
  236. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  237. constsym,enumsym,typedconstsym,errorsym,syssym,
  238. labelsym,absolutesym,propertysym,funcretsym,
  239. macrosym,rttisym);
  240. { State of the variable, if it's declared, assigned or used }
  241. tvarstate=(vs_none,
  242. vs_declared,vs_declared_and_first_found,
  243. vs_set_but_first_not_passed,vs_assigned,vs_used
  244. );
  245. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  246. targconvtyp = (act_convertable,act_equal,act_exact);
  247. absolutetyp = (tovar,toasm,toaddr);
  248. tconsttyp = (constnone,
  249. constord,conststring,constreal,constbool,
  250. constint,constchar,constset,constpointer,constnil,
  251. constresourcestring,constwstring,constwchar,constguid
  252. );
  253. { RTTI information to store }
  254. trttitype = (
  255. fullrtti,initrtti
  256. );
  257. {$ifdef GDB}
  258. type
  259. tdefstabstatus = (
  260. not_written,
  261. being_written,
  262. written);
  263. const
  264. tagtypes : Set of tdeftype =
  265. [recorddef,enumdef,
  266. {$IfNDef GDBKnowsStrings}
  267. stringdef,
  268. {$EndIf not GDBKnowsStrings}
  269. {$IfNDef GDBKnowsFiles}
  270. filedef,
  271. {$EndIf not GDBKnowsFiles}
  272. objectdef];
  273. {$endif GDB}
  274. const
  275. { relevant options for assigning a proc or a procvar to a procvar }
  276. po_compatibility_options = [
  277. po_classmethod,
  278. po_staticmethod,
  279. po_methodpointer,
  280. po_containsself,
  281. po_interrupt,
  282. po_iocheck,
  283. po_varargs,
  284. po_exports
  285. ];
  286. const
  287. SymTypeName : array[tsymtyp] of string[12] =
  288. ('abstractsym','variable','type','proc','unit',
  289. 'const','enum','typed const','errorsym','system sym',
  290. 'label','absolute','property','funcret',
  291. 'macrosym','rttisym');
  292. implementation
  293. end.
  294. {
  295. $Log$
  296. Revision 1.36 2002-10-20 15:34:16 peter
  297. * removed df_unique flag. It breaks code. For a good type=type <id>
  298. a def copy is required
  299. Revision 1.35 2002/10/06 12:25:05 florian
  300. + proper support of type <id> = type <another id>;
  301. Revision 1.34 2002/08/19 19:36:44 peter
  302. * More fixes for cross unit inlining, all tnodes are now implemented
  303. * Moved pocall_internconst to po_internconst because it is not a
  304. calling type at all and it conflicted when inlining of these small
  305. functions was requested
  306. Revision 1.33 2002/07/01 16:23:54 peter
  307. * cg64 patch
  308. * basics for currency
  309. * asnode updates for class and interface (not finished)
  310. Revision 1.32 2002/05/18 13:34:18 peter
  311. * readded missing revisions
  312. Revision 1.31 2002/05/16 19:46:44 carl
  313. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  314. + try to fix temp allocation (still in ifdef)
  315. + generic constructor calls
  316. + start of tassembler / tmodulebase class cleanup
  317. Revision 1.30 2002/05/14 19:34:50 peter
  318. * removed old logs and updated copyright year
  319. Revision 1.29 2002/05/12 16:53:10 peter
  320. * moved entry and exitcode to ncgutil and cgobj
  321. * foreach gets extra argument for passing local data to the
  322. iterator function
  323. * -CR checks also class typecasts at runtime by changing them
  324. into as
  325. * fixed compiler to cycle with the -CR option
  326. * fixed stabs with elf writer, finally the global variables can
  327. be watched
  328. * removed a lot of routines from cga unit and replaced them by
  329. calls to cgobj
  330. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  331. u32bit then the other is typecasted also to u32bit without giving
  332. a rangecheck warning/error.
  333. * fixed pascal calling method with reversing also the high tree in
  334. the parast, detected by tcalcst3 test
  335. Revision 1.28 2002/01/06 12:08:15 peter
  336. * removed uauto from orddef, use new range_to_basetype generating
  337. the correct ordinal type for a range
  338. }