symconst.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. {# These are the different possible base values that can
  75. be taken from the lexlevel variable when parsing. The
  76. lexlevel can be bigger if parsding recursive routines.
  77. }
  78. main_program_level = 1;
  79. unit_init_level = 1;
  80. normal_function_level = 2;
  81. type
  82. { Deref entry options }
  83. tdereftype = (derefnil,
  84. derefaktrecordindex,
  85. derefaktstaticindex,
  86. derefunit,
  87. derefrecord,
  88. derefindex,
  89. dereflocal,
  90. derefpara,
  91. derefaktlocal
  92. );
  93. { symbol options }
  94. tsymoption=(sp_none,
  95. sp_public,
  96. sp_private,
  97. sp_published,
  98. sp_protected,
  99. sp_static,
  100. sp_hint_deprecated,
  101. sp_hint_platform,
  102. sp_hint_library,
  103. sp_hint_unimplemented,
  104. sp_has_overloaded
  105. );
  106. tsymoptions=set of tsymoption;
  107. { flags for a definition }
  108. tdefoption=(df_none,
  109. { init data has been generated }
  110. df_has_inittable,
  111. { rtti data has been generated }
  112. df_has_rttitable,
  113. { type is unique, i.e. declared with type = type <tdef>; }
  114. df_unique
  115. );
  116. tdefoptions=set of tdefoption;
  117. { tsymlist entry types }
  118. tsltype = (sl_none,
  119. sl_load,
  120. sl_call,
  121. sl_subscript,
  122. sl_vec
  123. );
  124. { base types for orddef }
  125. tbasetype = (
  126. uvoid,
  127. u8bit,u16bit,u32bit,u64bit,
  128. s8bit,s16bit,s32bit,s64bit,
  129. bool8bit,bool16bit,bool32bit,
  130. uchar,uwidechar
  131. );
  132. { float types }
  133. tfloattype = (
  134. s32real,s64real,s80real,
  135. s64comp,s64currency,s128real
  136. );
  137. { string types }
  138. tstringtype = (st_default,
  139. st_shortstring, st_longstring, st_ansistring, st_widestring
  140. );
  141. { set types }
  142. tsettype = (
  143. normset,smallset,varset
  144. );
  145. { basic type for tprocdef and tprocvardef }
  146. tproctypeoption=(potype_none,
  147. potype_proginit, { Program initialization }
  148. potype_unitinit, { unit initialization }
  149. potype_unitfinalize, { unit finalization }
  150. potype_constructor, { Procedure is a constructor }
  151. potype_destructor, { Procedure is a destructor }
  152. potype_operator { Procedure defines an operator }
  153. );
  154. tproctypeoptions=set of tproctypeoption;
  155. { other options for tprocdef and tprocvardef }
  156. tprocoption=(po_none,
  157. po_classmethod, { class method }
  158. po_virtualmethod, { Procedure is a virtual method }
  159. po_abstractmethod, { Procedure is an abstract method }
  160. po_staticmethod, { static method }
  161. po_overridingmethod, { method with override directive }
  162. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  163. po_containsself, { self is passed explicit to the compiler }
  164. po_interrupt, { Procedure is an interrupt handler }
  165. po_iocheck, { IO checking should be done after a call to the procedure }
  166. po_assembler, { Procedure is written in assembler }
  167. po_msgstr, { method for string message handling }
  168. po_msgint, { method for int message handling }
  169. po_exports, { Procedure has export directive (needed for OS/2) }
  170. po_external, { Procedure is external (in other object or lib)}
  171. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  172. po_saveregisters, { save all registers }
  173. po_overload, { procedure is declared with overload directive }
  174. po_varargs, { printf like arguments }
  175. po_leftright, { push arguments from left to right }
  176. po_clearstack, { caller clears the stack }
  177. po_internconst, { procedure has constant evaluator intern }
  178. po_addressonly { flag that only the address of a method is returned and not a full methodpointer }
  179. );
  180. tprocoptions=set of tprocoption;
  181. { options for objects and classes }
  182. tobjectdeftype = (odt_none,
  183. odt_class,
  184. odt_object,
  185. odt_interfacecom,
  186. odt_interfacecorba,
  187. odt_cppclass,
  188. odt_dispinterface
  189. );
  190. { options for objects and classes }
  191. tobjectoption=(oo_none,
  192. oo_is_forward, { the class is only a forward declared yet }
  193. oo_has_virtual, { the object/class has virtual methods }
  194. oo_has_private,
  195. oo_has_protected,
  196. oo_has_constructor, { the object/class has a constructor }
  197. oo_has_destructor, { the object/class has a destructor }
  198. oo_has_vmt, { the object/class has a vmt }
  199. oo_has_msgstr,
  200. oo_has_msgint,
  201. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  202. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  203. );
  204. tobjectoptions=set of tobjectoption;
  205. { options for properties }
  206. tpropertyoption=(ppo_none,
  207. ppo_indexed,
  208. ppo_defaultproperty,
  209. ppo_stored,
  210. ppo_hasparameters,
  211. ppo_is_override
  212. );
  213. tpropertyoptions=set of tpropertyoption;
  214. { options for variables }
  215. tvaroption=(vo_none,
  216. vo_regable,
  217. vo_is_C_var,
  218. vo_is_external,
  219. vo_is_dll_var,
  220. vo_is_thread_var,
  221. vo_fpuregable,
  222. vo_is_local_copy,
  223. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  224. vo_is_exported,
  225. vo_is_high_value
  226. );
  227. tvaroptions=set of tvaroption;
  228. { types of the symtables }
  229. tsymtabletype = (abstractsymtable,
  230. globalsymtable,staticsymtable,
  231. objectsymtable,recordsymtable,
  232. localsymtable,parasymtable,
  233. withsymtable,stt_exceptsymtable,
  234. { used for inline detection }
  235. inlineparasymtable,inlinelocalsymtable
  236. );
  237. { definition contains the informations about a type }
  238. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  239. stringdef,enumdef,procdef,objectdef,errordef,
  240. filedef,formaldef,setdef,procvardef,floatdef,
  241. classrefdef,forwarddef,variantdef);
  242. { possible types for symtable entries }
  243. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  244. constsym,enumsym,typedconstsym,errorsym,syssym,
  245. labelsym,absolutesym,propertysym,funcretsym,
  246. macrosym,rttisym);
  247. { State of the variable, if it's declared, assigned or used }
  248. tvarstate=(vs_none,
  249. vs_declared,vs_declared_and_first_found,
  250. vs_set_but_first_not_passed,vs_assigned,vs_used
  251. );
  252. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_hidden);
  253. targconvtyp = (act_convertable,act_equal,act_exact);
  254. absolutetyp = (tovar,toasm,toaddr);
  255. tconsttyp = (constnone,
  256. constord,conststring,constreal,constbool,
  257. constint,constchar,constset,constpointer,constnil,
  258. constresourcestring,constwstring,constwchar,constguid
  259. );
  260. { RTTI information to store }
  261. trttitype = (
  262. fullrtti,initrtti
  263. );
  264. {$ifdef GDB}
  265. type
  266. tdefstabstatus = (
  267. not_written,
  268. being_written,
  269. written);
  270. const
  271. tagtypes : Set of tdeftype =
  272. [recorddef,enumdef,
  273. {$IfNDef GDBKnowsStrings}
  274. stringdef,
  275. {$EndIf not GDBKnowsStrings}
  276. {$IfNDef GDBKnowsFiles}
  277. filedef,
  278. {$EndIf not GDBKnowsFiles}
  279. objectdef];
  280. {$endif GDB}
  281. const
  282. { relevant options for assigning a proc or a procvar to a procvar }
  283. po_compatibility_options = [
  284. po_staticmethod,
  285. po_methodpointer,
  286. po_containsself,
  287. po_interrupt,
  288. po_iocheck,
  289. po_varargs,
  290. po_exports
  291. ];
  292. const
  293. SymTypeName : array[tsymtyp] of string[12] =
  294. ('abstractsym','variable','type','proc','unit',
  295. 'const','enum','typed const','errorsym','system sym',
  296. 'label','absolute','property','funcret',
  297. 'macrosym','rttisym');
  298. implementation
  299. end.
  300. {
  301. $Log$
  302. Revision 1.44 2003-01-06 21:16:52 peter
  303. * po_addressonly added to retrieve the address of a methodpointer
  304. only, this is used for @tclass.method which has no self pointer
  305. Revision 1.43 2003/01/05 15:54:15 florian
  306. + added proper support of type = type <type>; for simple types
  307. Revision 1.42 2003/01/05 13:36:53 florian
  308. * x86-64 compiles
  309. + very basic support for float128 type (x86-64 only)
  310. Revision 1.41 2003/01/01 22:51:03 peter
  311. * high value insertion changed so it works also when 2 parameters
  312. are passed
  313. Revision 1.40 2002/12/29 14:57:50 peter
  314. * unit loading changed to first register units and load them
  315. afterwards. This is needed to support uses xxx in yyy correctly
  316. * unit dependency check fixed
  317. Revision 1.39 2002/12/15 11:26:02 peter
  318. * ignore vs_hidden parameters when choosing overloaded proc
  319. Revision 1.38 2002/12/05 14:44:38 florian
  320. + oo_dispinterface added
  321. Revision 1.37 2002/11/29 22:31:20 carl
  322. + unimplemented hint directive added
  323. * hint directive parsing implemented
  324. * warning on these directives
  325. Revision 1.36 2002/10/20 15:34:16 peter
  326. * removed df_unique flag. It breaks code. For a good type=type <id>
  327. a def copy is required
  328. Revision 1.35 2002/10/06 12:25:05 florian
  329. + proper support of type <id> = type <another id>;
  330. Revision 1.34 2002/08/19 19:36:44 peter
  331. * More fixes for cross unit inlining, all tnodes are now implemented
  332. * Moved pocall_internconst to po_internconst because it is not a
  333. calling type at all and it conflicted when inlining of these small
  334. functions was requested
  335. Revision 1.33 2002/07/01 16:23:54 peter
  336. * cg64 patch
  337. * basics for currency
  338. * asnode updates for class and interface (not finished)
  339. Revision 1.32 2002/05/18 13:34:18 peter
  340. * readded missing revisions
  341. Revision 1.31 2002/05/16 19:46:44 carl
  342. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  343. + try to fix temp allocation (still in ifdef)
  344. + generic constructor calls
  345. + start of tassembler / tmodulebase class cleanup
  346. Revision 1.30 2002/05/14 19:34:50 peter
  347. * removed old logs and updated copyright year
  348. Revision 1.29 2002/05/12 16:53:10 peter
  349. * moved entry and exitcode to ncgutil and cgobj
  350. * foreach gets extra argument for passing local data to the
  351. iterator function
  352. * -CR checks also class typecasts at runtime by changing them
  353. into as
  354. * fixed compiler to cycle with the -CR option
  355. * fixed stabs with elf writer, finally the global variables can
  356. be watched
  357. * removed a lot of routines from cga unit and replaced them by
  358. calls to cgobj
  359. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  360. u32bit then the other is typecasted also to u32bit without giving
  361. a rangecheck warning/error.
  362. * fixed pascal calling method with reversing also the high tree in
  363. the parast, detected by tcalcst3 test
  364. Revision 1.28 2002/01/06 12:08:15 peter
  365. * removed uauto from orddef, use new range_to_basetype generating
  366. the correct ordinal type for a range
  367. }