symconst.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 defines.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. main_program_level = 1;
  74. unit_init_level = 1;
  75. normal_function_level = 2;
  76. type
  77. { Deref entry options }
  78. tdereftype = (derefnil,
  79. derefaktrecordindex,
  80. derefaktstaticindex,
  81. derefunit,
  82. derefrecord,
  83. derefindex,
  84. dereflocal,
  85. derefpara,
  86. derefaktlocal
  87. );
  88. { symbol options }
  89. tsymoption=(sp_none,
  90. sp_public,
  91. sp_private,
  92. sp_published,
  93. sp_protected,
  94. sp_static,
  95. sp_hint_deprecated,
  96. sp_hint_platform,
  97. sp_hint_library,
  98. sp_has_overloaded
  99. );
  100. tsymoptions=set of tsymoption;
  101. { flags for a definition }
  102. tdefoption=(df_none,
  103. df_has_inittable, { init data has been generated }
  104. df_has_rttitable { rtti data has been generated }
  105. );
  106. tdefoptions=set of tdefoption;
  107. { tsymlist entry types }
  108. tsltype = (sl_none,
  109. sl_load,
  110. sl_call,
  111. sl_subscript,
  112. sl_vec
  113. );
  114. { base types for orddef }
  115. tbasetype = (
  116. uvoid,
  117. u8bit,u16bit,u32bit,u64bit,
  118. s8bit,s16bit,s32bit,s64bit,
  119. bool8bit,bool16bit,bool32bit,
  120. uchar,uwidechar
  121. );
  122. { float types }
  123. tfloattype = (
  124. s32real,s64real,s80real,
  125. s64comp
  126. );
  127. { string types }
  128. tstringtype = (st_default,
  129. st_shortstring, st_longstring, st_ansistring, st_widestring
  130. );
  131. { set types }
  132. tsettype = (
  133. normset,smallset,varset
  134. );
  135. { basic type for tprocdef and tprocvardef }
  136. tproctypeoption=(potype_none,
  137. potype_proginit, { Program initialization }
  138. potype_unitinit, { unit initialization }
  139. potype_unitfinalize, { unit finalization }
  140. potype_constructor, { Procedure is a constructor }
  141. potype_destructor, { Procedure is a destructor }
  142. potype_operator { Procedure defines an operator }
  143. );
  144. tproctypeoptions=set of tproctypeoption;
  145. { other options for tprocdef and tprocvardef }
  146. tprocoption=(po_none,
  147. po_classmethod, { class method }
  148. po_virtualmethod, { Procedure is a virtual method }
  149. po_abstractmethod, { Procedure is an abstract method }
  150. po_staticmethod, { static method }
  151. po_overridingmethod, { method with override directive }
  152. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  153. po_containsself, { self is passed explicit to the compiler }
  154. po_interrupt, { Procedure is an interrupt handler }
  155. po_iocheck, { IO checking should be done after a call to the procedure }
  156. po_assembler, { Procedure is written in assembler }
  157. po_msgstr, { method for string message handling }
  158. po_msgint, { method for int message handling }
  159. po_exports, { Procedure has export directive (needed for OS/2) }
  160. po_external, { Procedure is external (in other object or lib)}
  161. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  162. po_saveregisters, { save all registers }
  163. po_overload, { procedure is declared with overload directive }
  164. po_varargs, { printf like arguments }
  165. po_leftright, { push arguments from left to right }
  166. po_clearstack { caller clears the stack }
  167. );
  168. tprocoptions=set of tprocoption;
  169. { options for objects and classes }
  170. tobjectdeftype = (odt_none,
  171. odt_class,
  172. odt_object,
  173. odt_interfacecom,
  174. odt_interfacecorba,
  175. odt_cppclass
  176. );
  177. { options for objects and classes }
  178. tobjectoption=(oo_none,
  179. oo_is_forward, { the class is only a forward declared yet }
  180. oo_has_virtual, { the object/class has virtual methods }
  181. oo_has_private,
  182. oo_has_protected,
  183. oo_has_constructor, { the object/class has a constructor }
  184. oo_has_destructor, { the object/class has a destructor }
  185. oo_has_vmt, { the object/class has a vmt }
  186. oo_has_msgstr,
  187. oo_has_msgint,
  188. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  189. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  190. );
  191. tobjectoptions=set of tobjectoption;
  192. { options for properties }
  193. tpropertyoption=(ppo_none,
  194. ppo_indexed,
  195. ppo_defaultproperty,
  196. ppo_stored,
  197. ppo_hasparameters,
  198. ppo_is_override
  199. );
  200. tpropertyoptions=set of tpropertyoption;
  201. { options for variables }
  202. tvaroption=(vo_none,
  203. vo_regable,
  204. vo_is_C_var,
  205. vo_is_external,
  206. vo_is_dll_var,
  207. vo_is_thread_var,
  208. vo_fpuregable,
  209. vo_is_local_copy,
  210. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  211. vo_is_exported
  212. );
  213. tvaroptions=set of tvaroption;
  214. { types of the symtables }
  215. tsymtabletype = (abstractsymtable,
  216. globalsymtable,staticsymtable,
  217. objectsymtable,recordsymtable,
  218. localsymtable,parasymtable,
  219. withsymtable,stt_exceptsymtable,
  220. { used for inline detection }
  221. inlineparasymtable,inlinelocalsymtable
  222. );
  223. { definition contains the informations about a type }
  224. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  225. stringdef,enumdef,procdef,objectdef,errordef,
  226. filedef,formaldef,setdef,procvardef,floatdef,
  227. classrefdef,forwarddef,variantdef);
  228. { possible types for symtable entries }
  229. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  230. constsym,enumsym,typedconstsym,errorsym,syssym,
  231. labelsym,absolutesym,propertysym,funcretsym,
  232. macrosym,rttisym);
  233. { State of the variable, if it's declared, assigned or used }
  234. tvarstate=(vs_none,
  235. vs_declared,vs_declared_and_first_found,
  236. vs_set_but_first_not_passed,vs_assigned,vs_used
  237. );
  238. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  239. targconvtyp = (act_convertable,act_equal,act_exact);
  240. absolutetyp = (tovar,toasm,toaddr);
  241. tconsttyp = (constnone,
  242. constord,conststring,constreal,constbool,
  243. constint,constchar,constset,constpointer,constnil,
  244. constresourcestring,constwstring,constwchar,constguid
  245. );
  246. { RTTI information to store }
  247. trttitype = (
  248. fullrtti,initrtti
  249. );
  250. {$ifdef GDB}
  251. type
  252. tdefstabstatus = (
  253. not_written,
  254. being_written,
  255. written);
  256. const
  257. tagtypes : Set of tdeftype =
  258. [recorddef,enumdef,
  259. {$IfNDef GDBKnowsStrings}
  260. stringdef,
  261. {$EndIf not GDBKnowsStrings}
  262. {$IfNDef GDBKnowsFiles}
  263. filedef,
  264. {$EndIf not GDBKnowsFiles}
  265. objectdef];
  266. {$endif GDB}
  267. const
  268. { relevant options for assigning a proc or a procvar to a procvar }
  269. po_compatibility_options = [
  270. po_classmethod,
  271. po_staticmethod,
  272. po_methodpointer,
  273. po_containsself,
  274. po_interrupt,
  275. po_iocheck,
  276. po_varargs,
  277. po_exports
  278. ];
  279. const
  280. SymTypeName : array[tsymtyp] of string[12] =
  281. ('abstractsym','variable','type','proc','unit',
  282. 'const','enum','typed const','errorsym','system sym',
  283. 'label','absolute','property','funcret',
  284. 'macrosym','rttisym');
  285. implementation
  286. end.
  287. {
  288. $Log$
  289. Revision 1.29 2002-05-12 16:53:10 peter
  290. * moved entry and exitcode to ncgutil and cgobj
  291. * foreach gets extra argument for passing local data to the
  292. iterator function
  293. * -CR checks also class typecasts at runtime by changing them
  294. into as
  295. * fixed compiler to cycle with the -CR option
  296. * fixed stabs with elf writer, finally the global variables can
  297. be watched
  298. * removed a lot of routines from cga unit and replaced them by
  299. calls to cgobj
  300. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  301. u32bit then the other is typecasted also to u32bit without giving
  302. a rangecheck warning/error.
  303. * fixed pascal calling method with reversing also the high tree in
  304. the parast, detected by tcalcst3 test
  305. Revision 1.28 2002/01/06 12:08:15 peter
  306. * removed uauto from orddef, use new range_to_basetype generating
  307. the correct ordinal type for a range
  308. Revision 1.27 2001/10/25 21:22:37 peter
  309. * calling convention rewrite
  310. Revision 1.26 2001/10/23 21:49:43 peter
  311. * $calling directive and -Cc commandline patch added
  312. from Pavel Ozerski
  313. Revision 1.25 2001/10/21 12:33:07 peter
  314. * array access for properties added
  315. Revision 1.24 2001/10/20 20:30:21 peter
  316. * read only typed const support, switch $J-
  317. Revision 1.23 2001/08/30 20:13:54 peter
  318. * rtti/init table updates
  319. * rttisym for reusable global rtti/init info
  320. * support published for interfaces
  321. Revision 1.22 2001/08/19 21:11:21 florian
  322. * some bugs fix:
  323. - overload; with external procedures fixed
  324. - better selection of routine to do an overloaded
  325. type case
  326. - ... some more
  327. Revision 1.21 2001/08/01 15:07:29 jonas
  328. + "compilerproc" directive support, which turns both the public and mangled
  329. name to lowercase(declaration_name). This prevents a normal user from
  330. accessing the routine, but they can still be easily looked up within
  331. the compiler. This is used for helper procedures and should facilitate
  332. the writing of more processor independent code in the code generator
  333. itself (mostly written by Peter)
  334. + new "createintern" constructor for tcal nodes to create a call to
  335. helper exported using the "compilerproc" directive
  336. + support for high(dynamic_array) using the the above new things
  337. + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
  338. compiler and rtl whether the "compilerproc" directive is supported)
  339. Revision 1.20 2001/06/04 18:14:54 peter
  340. * varargs added for proc to procvar comparison
  341. Revision 1.19 2001/06/04 11:53:13 peter
  342. + varargs directive
  343. Revision 1.18 2001/06/03 21:57:38 peter
  344. + hint directive parsing support
  345. Revision 1.17 2001/05/08 21:06:31 florian
  346. * some more support for widechars commited especially
  347. regarding type casting and constants
  348. Revision 1.16 2001/04/13 01:22:15 peter
  349. * symtable change to classes
  350. * range check generation and errors fixed, make cycle DEBUG=1 works
  351. * memory leaks fixed
  352. Revision 1.15 2001/04/02 21:20:34 peter
  353. * resulttype rewrite
  354. Revision 1.14 2001/03/22 00:10:58 florian
  355. + basic variant type support in the compiler
  356. Revision 1.13 2001/02/26 19:44:55 peter
  357. * merged generic m68k updates from fixes branch
  358. Revision 1.12 2000/11/04 14:25:21 florian
  359. + merged Attila's changes for interfaces, not tested yet
  360. Revision 1.11 2000/10/31 22:02:51 peter
  361. * symtable splitted, no real code changes
  362. Revision 1.9 2000/10/15 07:47:52 peter
  363. * unit names and procedure names are stored mixed case
  364. Revision 1.8 2000/10/14 10:14:52 peter
  365. * moehrendorf oct 2000 rewrite
  366. Revision 1.7 2000/09/24 15:06:28 peter
  367. * use defines.inc
  368. Revision 1.6 2000/08/21 11:27:44 pierre
  369. * fix the stabs problems
  370. Revision 1.5 2000/08/06 19:39:28 peter
  371. * default parameters working !
  372. Revision 1.4 2000/08/05 13:25:06 peter
  373. * packenum 1 fixes (merged)
  374. Revision 1.3 2000/07/13 12:08:27 michael
  375. + patched to 1.1.0 with former 1.09patch from peter
  376. Revision 1.2 2000/07/13 11:32:49 michael
  377. + removed logs
  378. }