symconst.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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_7
  99. ,sp_8
  100. ,sp_9
  101. ,sp_10
  102. ,sp_11
  103. ,sp_12
  104. ,sp_13
  105. ,sp_14
  106. ,sp_15
  107. ,sp_16
  108. ,sp_17
  109. ,sp_18
  110. ,sp_19
  111. ,sp_20
  112. ,sp_21
  113. ,sp_22
  114. ,sp_23
  115. ,sp_24
  116. );
  117. tsymoptions=set of tsymoption;
  118. { flags for a definition }
  119. tdefoption=(df_none,
  120. df_need_rtti, { the definitions needs rtti }
  121. df_has_rtti { the rtti is generated }
  122. ,df_3
  123. ,df_4
  124. ,df_5
  125. ,df_6
  126. ,df_7
  127. ,df_8
  128. ,df_9
  129. ,df_10
  130. ,df_11
  131. ,df_12
  132. ,df_13
  133. ,df_14
  134. ,df_15
  135. ,df_16
  136. ,df_17
  137. ,df_18
  138. ,df_19
  139. ,df_20
  140. ,df_21
  141. ,df_22
  142. ,df_23
  143. ,df_24
  144. );
  145. tdefoptions=set of tdefoption;
  146. { base types for orddef }
  147. tbasetype = (
  148. uauto,uvoid,uchar,
  149. u8bit,u16bit,u32bit,
  150. s8bit,s16bit,s32bit,
  151. bool8bit,bool16bit,bool32bit,
  152. u64bit,s64bit,uwidechar
  153. );
  154. { float types }
  155. tfloattype = (
  156. s32real,s64real,s80real,
  157. s64comp
  158. );
  159. { string types }
  160. tstringtype = (st_default,
  161. st_shortstring, st_longstring, st_ansistring, st_widestring
  162. );
  163. { set types }
  164. tsettype = (
  165. normset,smallset,varset
  166. );
  167. { calling convention for tprocdef and tprocvardef }
  168. tproccalloption=(pocall_none,
  169. pocall_clearstack, { Use IBM flat calling convention. (Used by GCC.) }
  170. pocall_leftright, { Push parameters from left to right }
  171. pocall_cdecl, { procedure uses C styled calling }
  172. pocall_register, { procedure uses register (fastcall) calling }
  173. pocall_stdcall, { procedure uses stdcall call }
  174. pocall_safecall, { safe call calling conventions }
  175. pocall_palmossyscall, { procedure is a PalmOS system call }
  176. pocall_system,
  177. pocall_inline, { Procedure is an assembler macro }
  178. pocall_internproc, { Procedure has compiler magic}
  179. pocall_internconst, { procedure has constant evaluator intern }
  180. pocall_cppdecl, { C++ calling conventions }
  181. pocall_compilerproc { Procedure is used for internal compiler calls }
  182. ,pocall_14
  183. ,pocall_15
  184. ,pocall_16
  185. ,pocall_17
  186. ,pocall_18
  187. ,pocall_19
  188. ,pocall_20
  189. ,pocall_21
  190. ,pocall_22
  191. ,pocall_23
  192. ,pocall_24
  193. );
  194. tproccalloptions=set of tproccalloption;
  195. { basic type for tprocdef and tprocvardef }
  196. tproctypeoption=(potype_none,
  197. potype_proginit, { Program initialization }
  198. potype_unitinit, { unit initialization }
  199. potype_unitfinalize, { unit finalization }
  200. potype_constructor, { Procedure is a constructor }
  201. potype_destructor, { Procedure is a destructor }
  202. potype_operator { Procedure defines an operator }
  203. ,potype_7
  204. ,potype_8
  205. ,potype_9
  206. ,potype_10
  207. ,potype_11
  208. ,potype_12
  209. ,potype_13
  210. ,potype_14
  211. ,potype_15
  212. ,potype_16
  213. ,potype_17
  214. ,potype_18
  215. ,potype_19
  216. ,potype_20
  217. ,potype_21
  218. ,potype_22
  219. ,potype_23
  220. ,potype_24
  221. );
  222. tproctypeoptions=set of tproctypeoption;
  223. { other options for tprocdef and tprocvardef }
  224. tprocoption=(po_none,
  225. po_classmethod, { class method }
  226. po_virtualmethod, { Procedure is a virtual method }
  227. po_abstractmethod, { Procedure is an abstract method }
  228. po_staticmethod, { static method }
  229. po_overridingmethod, { method with override directive }
  230. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  231. po_containsself, { self is passed explicit to the compiler }
  232. po_interrupt, { Procedure is an interrupt handler }
  233. po_iocheck, { IO checking should be done after a call to the procedure }
  234. po_assembler, { Procedure is written in assembler }
  235. po_msgstr, { method for string message handling }
  236. po_msgint, { method for int message handling }
  237. po_exports, { Procedure has export directive (needed for OS/2) }
  238. po_external, { Procedure is external (in other object or lib)}
  239. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  240. po_saveregisters, { save all registers }
  241. po_overload, { procedure is declared with overload directive }
  242. po_varargs { printf like arguments }
  243. ,po_19
  244. ,po_20
  245. ,po_21
  246. ,po_22
  247. ,po_23
  248. ,po_24
  249. );
  250. tprocoptions=set of tprocoption;
  251. { options for objects and classes }
  252. tobjectdeftype = (odt_none,
  253. odt_class,
  254. odt_object,
  255. odt_interfacecom,
  256. odt_interfacecorba,
  257. odt_cppclass
  258. );
  259. { options for objects and classes }
  260. tobjectoption=(oo_none,
  261. oo_is_forward, { the class is only a forward declared yet }
  262. oo_has_virtual, { the object/class has virtual methods }
  263. oo_has_private,
  264. oo_has_protected,
  265. oo_has_constructor, { the object/class has a constructor }
  266. oo_has_destructor, { the object/class has a destructor }
  267. oo_has_vmt, { the object/class has a vmt }
  268. oo_has_msgstr,
  269. oo_has_msgint,
  270. oo_has_abstract, { the object/class has an abstract method => no instances can be created }
  271. oo_can_have_published { the class has rtti, i.e. you can publish properties }
  272. ,oo_12
  273. ,oo_13
  274. ,oo_14
  275. ,oo_15
  276. ,oo_16
  277. ,oo_17
  278. ,oo_18
  279. ,oo_19
  280. ,oo_20
  281. ,oo_21
  282. ,oo_22
  283. ,oo_23
  284. ,oo_24
  285. );
  286. tobjectoptions=set of tobjectoption;
  287. { options for properties }
  288. tpropertyoption=(ppo_none,
  289. ppo_indexed,
  290. ppo_defaultproperty,
  291. ppo_stored,
  292. ppo_hasparameters,
  293. ppo_is_override
  294. ,ppo_6
  295. ,ppo_7
  296. ,ppo_8
  297. ,ppo_9
  298. ,ppo_10
  299. ,ppo_11
  300. ,ppo_12
  301. ,ppo_13
  302. ,ppo_14
  303. ,ppo_15
  304. ,ppo_16
  305. ,ppo_17
  306. ,ppo_18
  307. ,ppo_19
  308. ,ppo_20
  309. ,ppo_21
  310. ,ppo_22
  311. ,ppo_23
  312. ,ppo_24
  313. );
  314. tpropertyoptions=set of tpropertyoption;
  315. { options for variables }
  316. tvaroption=(vo_none,
  317. vo_regable,
  318. vo_is_C_var,
  319. vo_is_external,
  320. vo_is_dll_var,
  321. vo_is_thread_var,
  322. vo_fpuregable,
  323. vo_is_local_copy,
  324. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  325. vo_is_exported
  326. ,vo_10
  327. ,vo_11
  328. ,vo_12
  329. ,vo_13
  330. ,vo_14
  331. ,vo_15
  332. ,vo_16
  333. ,vo_17
  334. ,vo_18
  335. ,vo_19
  336. ,vo_20
  337. ,vo_21
  338. ,vo_22
  339. ,vo_23
  340. ,vo_24
  341. );
  342. tvaroptions=set of tvaroption;
  343. { types of the symtables }
  344. tsymtabletype = (abstractsymtable,
  345. globalsymtable,staticsymtable,
  346. objectsymtable,recordsymtable,
  347. localsymtable,parasymtable,
  348. withsymtable,stt_exceptsymtable,
  349. { used for inline detection }
  350. inlineparasymtable,inlinelocalsymtable
  351. );
  352. { definition contains the informations about a type }
  353. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  354. stringdef,enumdef,procdef,objectdef,errordef,
  355. filedef,formaldef,setdef,procvardef,floatdef,
  356. classrefdef,forwarddef,variantdef);
  357. { possible types for symtable entries }
  358. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,
  359. constsym,enumsym,typedconstsym,errorsym,syssym,
  360. labelsym,absolutesym,propertysym,funcretsym,
  361. macrosym);
  362. { State of the variable, if it's declared, assigned or used }
  363. tvarstate=(vs_none,
  364. vs_declared,vs_declared_and_first_found,
  365. vs_set_but_first_not_passed,vs_assigned,vs_used
  366. );
  367. absolutetyp = (tovar,toasm,toaddr);
  368. tconsttyp = (constnone,
  369. constord,conststring,constreal,constbool,
  370. constint,constchar,constset,constpointer,constnil,
  371. constresourcestring,constwstring,constwchar
  372. );
  373. {$ifdef GDB}
  374. type
  375. tdefstabstatus = (
  376. not_written,
  377. being_written,
  378. written);
  379. const
  380. tagtypes : Set of tdeftype =
  381. [recorddef,enumdef,
  382. {$IfNDef GDBKnowsStrings}
  383. stringdef,
  384. {$EndIf not GDBKnowsStrings}
  385. {$IfNDef GDBKnowsFiles}
  386. filedef,
  387. {$EndIf not GDBKnowsFiles}
  388. objectdef];
  389. {$endif GDB}
  390. const
  391. { relevant options for assigning a proc or a procvar to a procvar }
  392. po_compatibility_options = [
  393. po_classmethod,
  394. po_staticmethod,
  395. po_methodpointer,
  396. po_containsself,
  397. po_interrupt,
  398. po_iocheck,
  399. po_varargs,
  400. po_exports
  401. ];
  402. const
  403. SymTypeName : array[tsymtyp] of string[12] =
  404. ('abstractsym','variable','type','proc','unit',
  405. 'const','enum','typed const','errorsym','system sym',
  406. 'label','absolute','property','funcret',
  407. 'macrosym');
  408. implementation
  409. end.
  410. {
  411. $Log$
  412. Revision 1.21 2001-08-01 15:07:29 jonas
  413. + "compilerproc" directive support, which turns both the public and mangled
  414. name to lowercase(declaration_name). This prevents a normal user from
  415. accessing the routine, but they can still be easily looked up within
  416. the compiler. This is used for helper procedures and should facilitate
  417. the writing of more processor independent code in the code generator
  418. itself (mostly written by Peter)
  419. + new "createintern" constructor for tcal nodes to create a call to
  420. helper exported using the "compilerproc" directive
  421. + support for high(dynamic_array) using the the above new things
  422. + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
  423. compiler and rtl whether the "compilerproc" directive is supported)
  424. Revision 1.20 2001/06/04 18:14:54 peter
  425. * varargs added for proc to procvar comparison
  426. Revision 1.19 2001/06/04 11:53:13 peter
  427. + varargs directive
  428. Revision 1.18 2001/06/03 21:57:38 peter
  429. + hint directive parsing support
  430. Revision 1.17 2001/05/08 21:06:31 florian
  431. * some more support for widechars commited especially
  432. regarding type casting and constants
  433. Revision 1.16 2001/04/13 01:22:15 peter
  434. * symtable change to classes
  435. * range check generation and errors fixed, make cycle DEBUG=1 works
  436. * memory leaks fixed
  437. Revision 1.15 2001/04/02 21:20:34 peter
  438. * resulttype rewrite
  439. Revision 1.14 2001/03/22 00:10:58 florian
  440. + basic variant type support in the compiler
  441. Revision 1.13 2001/02/26 19:44:55 peter
  442. * merged generic m68k updates from fixes branch
  443. Revision 1.12 2000/11/04 14:25:21 florian
  444. + merged Attila's changes for interfaces, not tested yet
  445. Revision 1.11 2000/10/31 22:02:51 peter
  446. * symtable splitted, no real code changes
  447. Revision 1.9 2000/10/15 07:47:52 peter
  448. * unit names and procedure names are stored mixed case
  449. Revision 1.8 2000/10/14 10:14:52 peter
  450. * moehrendorf oct 2000 rewrite
  451. Revision 1.7 2000/09/24 15:06:28 peter
  452. * use defines.inc
  453. Revision 1.6 2000/08/21 11:27:44 pierre
  454. * fix the stabs problems
  455. Revision 1.5 2000/08/06 19:39:28 peter
  456. * default parameters working !
  457. Revision 1.4 2000/08/05 13:25:06 peter
  458. * packenum 1 fixes (merged)
  459. Revision 1.3 2000/07/13 12:08:27 michael
  460. + patched to 1.1.0 with former 1.09patch from peter
  461. Revision 1.2 2000/07/13 11:32:49 michael
  462. + removed logs
  463. }