symconst.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. { unique type which is declared by <id> = type <another id>; }
  112. df_unique
  113. );
  114. tdefoptions=set of tdefoption;
  115. { tsymlist entry types }
  116. tsltype = (sl_none,
  117. sl_load,
  118. sl_call,
  119. sl_subscript,
  120. sl_vec
  121. );
  122. { base types for orddef }
  123. tbasetype = (
  124. uvoid,
  125. u8bit,u16bit,u32bit,u64bit,
  126. s8bit,s16bit,s32bit,s64bit,
  127. bool8bit,bool16bit,bool32bit,
  128. uchar,uwidechar
  129. );
  130. { float types }
  131. tfloattype = (
  132. s32real,s64real,s80real,
  133. s64comp,s64currency
  134. );
  135. { string types }
  136. tstringtype = (st_default,
  137. st_shortstring, st_longstring, st_ansistring, st_widestring
  138. );
  139. { set types }
  140. tsettype = (
  141. normset,smallset,varset
  142. );
  143. { basic type for tprocdef and tprocvardef }
  144. tproctypeoption=(potype_none,
  145. potype_proginit, { Program initialization }
  146. potype_unitinit, { unit initialization }
  147. potype_unitfinalize, { unit finalization }
  148. potype_constructor, { Procedure is a constructor }
  149. potype_destructor, { Procedure is a destructor }
  150. potype_operator { Procedure defines an operator }
  151. );
  152. tproctypeoptions=set of tproctypeoption;
  153. { other options for tprocdef and tprocvardef }
  154. tprocoption=(po_none,
  155. po_classmethod, { class method }
  156. po_virtualmethod, { Procedure is a virtual method }
  157. po_abstractmethod, { Procedure is an abstract method }
  158. po_staticmethod, { static method }
  159. po_overridingmethod, { method with override directive }
  160. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  161. po_containsself, { self is passed explicit to the compiler }
  162. po_interrupt, { Procedure is an interrupt handler }
  163. po_iocheck, { IO checking should be done after a call to the procedure }
  164. po_assembler, { Procedure is written in assembler }
  165. po_msgstr, { method for string message handling }
  166. po_msgint, { method for int message handling }
  167. po_exports, { Procedure has export directive (needed for OS/2) }
  168. po_external, { Procedure is external (in other object or lib)}
  169. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  170. po_saveregisters, { save all registers }
  171. po_overload, { procedure is declared with overload directive }
  172. po_varargs, { printf like arguments }
  173. po_leftright, { push arguments from left to right }
  174. po_clearstack, { caller clears the stack }
  175. po_internconst { procedure has constant evaluator intern }
  176. );
  177. tprocoptions=set of tprocoption;
  178. { options for objects and classes }
  179. tobjectdeftype = (odt_none,
  180. odt_class,
  181. odt_object,
  182. odt_interfacecom,
  183. odt_interfacecorba,
  184. odt_cppclass
  185. );
  186. { options for objects and classes }
  187. tobjectoption=(oo_none,
  188. oo_is_forward, { the class is only a forward declared yet }
  189. oo_has_virtual, { the object/class has virtual methods }
  190. oo_has_private,
  191. oo_has_protected,
  192. oo_has_constructor, { the object/class has a constructor }
  193. oo_has_destructor, { the object/class has a destructor }
  194. oo_has_vmt, { the object/class has a vmt }
  195. oo_has_msgstr,
  196. oo_has_msgint,
  197. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  198. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  199. );
  200. tobjectoptions=set of tobjectoption;
  201. { options for properties }
  202. tpropertyoption=(ppo_none,
  203. ppo_indexed,
  204. ppo_defaultproperty,
  205. ppo_stored,
  206. ppo_hasparameters,
  207. ppo_is_override
  208. );
  209. tpropertyoptions=set of tpropertyoption;
  210. { options for variables }
  211. tvaroption=(vo_none,
  212. vo_regable,
  213. vo_is_C_var,
  214. vo_is_external,
  215. vo_is_dll_var,
  216. vo_is_thread_var,
  217. vo_fpuregable,
  218. vo_is_local_copy,
  219. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  220. vo_is_exported
  221. );
  222. tvaroptions=set of tvaroption;
  223. { types of the symtables }
  224. tsymtabletype = (abstractsymtable,
  225. globalsymtable,staticsymtable,
  226. objectsymtable,recordsymtable,
  227. localsymtable,parasymtable,
  228. withsymtable,stt_exceptsymtable,
  229. { used for inline detection }
  230. inlineparasymtable,inlinelocalsymtable
  231. );
  232. { definition contains the informations about a type }
  233. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  234. stringdef,enumdef,procdef,objectdef,errordef,
  235. filedef,formaldef,setdef,procvardef,floatdef,
  236. classrefdef,forwarddef,variantdef);
  237. { possible types for symtable entries }
  238. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  239. constsym,enumsym,typedconstsym,errorsym,syssym,
  240. labelsym,absolutesym,propertysym,funcretsym,
  241. macrosym,rttisym);
  242. { State of the variable, if it's declared, assigned or used }
  243. tvarstate=(vs_none,
  244. vs_declared,vs_declared_and_first_found,
  245. vs_set_but_first_not_passed,vs_assigned,vs_used
  246. );
  247. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  248. targconvtyp = (act_convertable,act_equal,act_exact);
  249. absolutetyp = (tovar,toasm,toaddr);
  250. tconsttyp = (constnone,
  251. constord,conststring,constreal,constbool,
  252. constint,constchar,constset,constpointer,constnil,
  253. constresourcestring,constwstring,constwchar,constguid
  254. );
  255. { RTTI information to store }
  256. trttitype = (
  257. fullrtti,initrtti
  258. );
  259. {$ifdef GDB}
  260. type
  261. tdefstabstatus = (
  262. not_written,
  263. being_written,
  264. written);
  265. const
  266. tagtypes : Set of tdeftype =
  267. [recorddef,enumdef,
  268. {$IfNDef GDBKnowsStrings}
  269. stringdef,
  270. {$EndIf not GDBKnowsStrings}
  271. {$IfNDef GDBKnowsFiles}
  272. filedef,
  273. {$EndIf not GDBKnowsFiles}
  274. objectdef];
  275. {$endif GDB}
  276. const
  277. { relevant options for assigning a proc or a procvar to a procvar }
  278. po_compatibility_options = [
  279. po_classmethod,
  280. po_staticmethod,
  281. po_methodpointer,
  282. po_containsself,
  283. po_interrupt,
  284. po_iocheck,
  285. po_varargs,
  286. po_exports
  287. ];
  288. const
  289. SymTypeName : array[tsymtyp] of string[12] =
  290. ('abstractsym','variable','type','proc','unit',
  291. 'const','enum','typed const','errorsym','system sym',
  292. 'label','absolute','property','funcret',
  293. 'macrosym','rttisym');
  294. implementation
  295. end.
  296. {
  297. $Log$
  298. Revision 1.35 2002-10-06 12:25:05 florian
  299. + proper support of type <id> = type <another id>;
  300. Revision 1.34 2002/08/19 19:36:44 peter
  301. * More fixes for cross unit inlining, all tnodes are now implemented
  302. * Moved pocall_internconst to po_internconst because it is not a
  303. calling type at all and it conflicted when inlining of these small
  304. functions was requested
  305. Revision 1.33 2002/07/01 16:23:54 peter
  306. * cg64 patch
  307. * basics for currency
  308. * asnode updates for class and interface (not finished)
  309. Revision 1.32 2002/05/18 13:34:18 peter
  310. * readded missing revisions
  311. Revision 1.31 2002/05/16 19:46:44 carl
  312. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  313. + try to fix temp allocation (still in ifdef)
  314. + generic constructor calls
  315. + start of tassembler / tmodulebase class cleanup
  316. Revision 1.30 2002/05/14 19:34:50 peter
  317. * removed old logs and updated copyright year
  318. Revision 1.29 2002/05/12 16:53:10 peter
  319. * moved entry and exitcode to ncgutil and cgobj
  320. * foreach gets extra argument for passing local data to the
  321. iterator function
  322. * -CR checks also class typecasts at runtime by changing them
  323. into as
  324. * fixed compiler to cycle with the -CR option
  325. * fixed stabs with elf writer, finally the global variables can
  326. be watched
  327. * removed a lot of routines from cga unit and replaced them by
  328. calls to cgobj
  329. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  330. u32bit then the other is typecasted also to u32bit without giving
  331. a rangecheck warning/error.
  332. * fixed pascal calling method with reversing also the high tree in
  333. the parast, detected by tcalcst3 test
  334. Revision 1.28 2002/01/06 12:08:15 peter
  335. * removed uauto from orddef, use new range_to_basetype generating
  336. the correct ordinal type for a range
  337. }