symconst.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. uses
  22. globtype;
  23. const
  24. def_alignment = 4;
  25. { if you change one of the following contants, }
  26. { you have also to change the typinfo unit}
  27. { and the rtl/i386,template/rttip.inc files }
  28. tkUnknown = 0;
  29. tkInteger = 1;
  30. tkChar = 2;
  31. tkEnumeration = 3;
  32. tkFloat = 4;
  33. tkSet = 5;
  34. tkMethod = 6;
  35. tkSString = 7;
  36. tkString = tkSString;
  37. tkLString = 8;
  38. {$ifdef ansistring_bits}
  39. tkA32String = 9;
  40. {$else}
  41. tkAString = 9;
  42. {$endif}
  43. tkWString = 10;
  44. tkVariant = 11;
  45. tkArray = 12;
  46. tkRecord = 13;
  47. tkInterface= 14;
  48. tkClass = 15;
  49. tkObject = 16;
  50. tkWChar = 17;
  51. tkBool = 18;
  52. tkInt64 = 19;
  53. tkQWord = 20;
  54. tkDynArray = 21;
  55. tkInterfaceCorba = 22;
  56. {$ifdef ansistring_bits}
  57. tkA16string = 23;
  58. tkA64string = 24;
  59. {$endif}
  60. otSByte = 0;
  61. otUByte = 1;
  62. otSWord = 2;
  63. otUWord = 3;
  64. otSLong = 4;
  65. otULong = 5;
  66. ftSingle = 0;
  67. ftDouble = 1;
  68. ftExtended = 2;
  69. ftComp = 3;
  70. ftCurr = 4;
  71. ftFloat128 = 5;
  72. mkProcedure= 0;
  73. mkFunction = 1;
  74. mkConstructor = 2;
  75. mkDestructor = 3;
  76. mkClassProcedure= 4;
  77. mkClassFunction = 5;
  78. pfvar = 1;
  79. pfConst = 2;
  80. pfArray = 4;
  81. pfAddress = 8;
  82. pfReference= 16;
  83. pfOut = 32;
  84. unknown_level = 0;
  85. main_program_level = 1;
  86. normal_function_level = 2;
  87. { implicit parameter positions, normal parameters start at 10
  88. and will increase with 10 for each parameter. The high parameters
  89. will be inserted with n+1 }
  90. paranr_parentfp = 1;
  91. paranr_result = 2;
  92. paranr_self = 3;
  93. paranr_vmt = 4;
  94. { Required to support variations of syscalls on MorphOS }
  95. paranr_syscall_basesysv = 9;
  96. paranr_syscall_sysvbase = high(word)-4;
  97. paranr_syscall_r12base = high(word)-3;
  98. paranr_syscall_legacy = high(word)-2;
  99. paranr_result_leftright = high(word)-1;
  100. type
  101. { Deref entry options }
  102. tdereftype = (deref_nil,
  103. deref_sym,
  104. deref_def,
  105. deref_aktrecord,
  106. deref_aktstatic,
  107. deref_aktglobal,
  108. deref_aktlocal,
  109. deref_aktpara,
  110. deref_unit,
  111. deref_record,
  112. deref_local,
  113. deref_para,
  114. deref_parent_object
  115. );
  116. { symbol options }
  117. tsymoption=(sp_none,
  118. sp_public,
  119. sp_private,
  120. sp_published,
  121. sp_protected,
  122. sp_static,
  123. sp_hint_deprecated,
  124. sp_hint_platform,
  125. sp_hint_library,
  126. sp_hint_unimplemented,
  127. sp_has_overloaded,
  128. sp_internal { internal symbol, not reported as unused }
  129. );
  130. tsymoptions=set of tsymoption;
  131. { flags for a definition }
  132. tdefoption=(df_none,
  133. { init data has been generated }
  134. df_has_inittable,
  135. { rtti data has been generated }
  136. df_has_rttitable,
  137. { type is unique, i.e. declared with type = type <tdef>; }
  138. df_unique
  139. );
  140. tdefoptions=set of tdefoption;
  141. { tsymlist entry types }
  142. tsltype = (sl_none,
  143. sl_load,
  144. sl_call,
  145. sl_subscript,
  146. sl_vec,
  147. sl_typeconv,
  148. sl_absolutetype
  149. );
  150. { base types for orddef }
  151. tbasetype = (
  152. uvoid,
  153. u8bit,u16bit,u32bit,u64bit,
  154. s8bit,s16bit,s32bit,s64bit,
  155. bool8bit,bool16bit,bool32bit,
  156. uchar,uwidechar,scurrency
  157. );
  158. { float types }
  159. tfloattype = (
  160. s32real,s64real,s80real,
  161. s64comp,s64currency,s128real
  162. );
  163. { string types }
  164. tstringtype = (st_default,
  165. st_shortstring,
  166. st_longstring,
  167. {$ifndef ansistring_bits}
  168. st_ansistring,
  169. {$else}
  170. st_ansistring16,
  171. st_ansistring32,
  172. st_ansistring64,
  173. {$endif}
  174. st_widestring
  175. );
  176. { set types }
  177. tsettype = (
  178. normset,smallset,varset
  179. );
  180. tvarianttype = (
  181. vt_normalvariant,vt_olevariant
  182. );
  183. tcallercallee = (callerside,calleeside);
  184. { basic type for tprocdef and tprocvardef }
  185. tproctypeoption=(potype_none,
  186. potype_proginit, { Program initialization }
  187. potype_unitinit, { unit initialization }
  188. potype_unitfinalize, { unit finalization }
  189. potype_constructor, { Procedure is a constructor }
  190. potype_destructor, { Procedure is a destructor }
  191. potype_operator { Procedure defines an operator }
  192. );
  193. tproctypeoptions=set of tproctypeoption;
  194. { other options for tprocdef and tprocvardef }
  195. tprocoption=(po_none,
  196. po_classmethod, { class method }
  197. po_virtualmethod, { Procedure is a virtual method }
  198. po_abstractmethod, { Procedure is an abstract method }
  199. po_staticmethod, { static method }
  200. po_overridingmethod, { method with override directive }
  201. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  202. po_interrupt, { Procedure is an interrupt handler }
  203. po_iocheck, { IO checking should be done after a call to the procedure }
  204. po_assembler, { Procedure is written in assembler }
  205. po_msgstr, { method for string message handling }
  206. po_msgint, { method for int message handling }
  207. po_exports, { Procedure has export directive (needed for OS/2) }
  208. po_external, { Procedure is external (in other object or lib)}
  209. po_overload, { procedure is declared with overload directive }
  210. po_varargs, { printf like arguments }
  211. po_internconst, { procedure has constant evaluator intern }
  212. { flag that only the address of a method is returned and not a full methodpointer }
  213. po_addressonly,
  214. { procedure is exported }
  215. po_public,
  216. { calling convention is specified explicitly }
  217. po_hascallingconvention,
  218. { reintroduce flag }
  219. po_reintroduce,
  220. { location of parameters is given explicitly as it is necessary for some syscall
  221. conventions like that one of MorphOS }
  222. po_explicitparaloc,
  223. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  224. po_nostackframe,
  225. po_has_mangledname,
  226. po_has_public_name,
  227. po_forward,
  228. po_global,
  229. po_has_inlininginfo,
  230. { The different kind of syscalls on MorphOS }
  231. po_syscall_legacy,
  232. po_syscall_sysv,
  233. po_syscall_basesysv,
  234. po_syscall_sysvbase,
  235. po_syscall_r12base,
  236. po_local
  237. );
  238. tprocoptions=set of tprocoption;
  239. { options for objects and classes }
  240. tobjectdeftype = (odt_none,
  241. odt_class,
  242. odt_object,
  243. odt_interfacecom,
  244. odt_interfacecorba,
  245. odt_cppclass,
  246. odt_dispinterface
  247. );
  248. { options for objects and classes }
  249. tobjectoption=(oo_none,
  250. oo_is_forward, { the class is only a forward declared yet }
  251. oo_has_virtual, { the object/class has virtual methods }
  252. oo_has_private,
  253. oo_has_protected,
  254. oo_has_constructor, { the object/class has a constructor }
  255. oo_has_destructor, { the object/class has a destructor }
  256. oo_has_vmt, { the object/class has a vmt }
  257. oo_has_msgstr,
  258. oo_has_msgint,
  259. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  260. oo_has_default_property
  261. );
  262. tobjectoptions=set of tobjectoption;
  263. { options for properties }
  264. tpropertyoption=(ppo_none,
  265. ppo_indexed,
  266. ppo_defaultproperty,
  267. ppo_stored,
  268. ppo_hasparameters,
  269. ppo_is_override
  270. );
  271. tpropertyoptions=set of tpropertyoption;
  272. { options for variables }
  273. tvaroption=(vo_none,
  274. vo_is_C_var,
  275. vo_is_external,
  276. vo_is_dll_var,
  277. vo_is_thread_var,
  278. vo_has_local_copy,
  279. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  280. vo_is_exported,
  281. vo_is_high_para,
  282. vo_is_funcret,
  283. vo_is_self,
  284. vo_is_vmt,
  285. vo_is_result, { special result variable }
  286. vo_is_parentfp,
  287. vo_is_loop_counter, { used to detect assignments to loop counter }
  288. vo_is_hidden_para,
  289. vo_has_explicit_paraloc,
  290. vo_is_syscall_lib,
  291. vo_has_mangledname
  292. );
  293. tvaroptions=set of tvaroption;
  294. { register variable }
  295. tvarregable=(vr_none,
  296. vr_intreg,
  297. vr_fpureg,
  298. vr_mmreg
  299. );
  300. { types of the symtables }
  301. tsymtabletype = (abstractsymtable,
  302. globalsymtable,staticsymtable,
  303. objectsymtable,recordsymtable,
  304. localsymtable,parasymtable,
  305. withsymtable,stt_exceptsymtable,
  306. exportedmacrosymtable, localmacrosymtable
  307. );
  308. { definition contains the informations about a type }
  309. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  310. stringdef,enumdef,procdef,objectdef,errordef,
  311. filedef,formaldef,setdef,procvardef,floatdef,
  312. classrefdef,forwarddef,variantdef);
  313. { possible types for symtable entries }
  314. tsymtyp = (abstractsym,globalvarsym,localvarsym,paravarsym,fieldvarsym,
  315. typesym,procsym,unitsym,constsym,enumsym,typedconstsym,
  316. errorsym,syssym,labelsym,absolutevarsym,propertysym,
  317. macrosym,rttisym);
  318. { State of the variable, if it's declared, assigned or used }
  319. tvarstate=(vs_none,
  320. vs_declared,vs_assigned,vs_used
  321. );
  322. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  323. absolutetyp = (tovar,toasm,toaddr);
  324. tconsttyp = (constnone,
  325. constord,conststring,constreal,
  326. constset,constpointer,constnil,
  327. constresourcestring,constwstring,constguid
  328. );
  329. { RTTI information to store }
  330. trttitype = (
  331. fullrtti,initrtti
  332. );
  333. { The order is from low priority to high priority,
  334. Note: the operators > and < are used on this list }
  335. tequaltype = (
  336. te_incompatible,
  337. te_convert_operator,
  338. te_convert_l3, { compatible conversion with possible loss of data }
  339. te_convert_l2, { compatible less prefered conversion }
  340. te_convert_l1, { compatible conversion }
  341. te_equal, { the definitions are equal }
  342. te_exact
  343. );
  344. {$ifdef GDB}
  345. type
  346. tdefstabstatus = (
  347. stab_state_unused,
  348. stab_state_used,
  349. stab_state_writing,
  350. stab_state_written
  351. );
  352. const
  353. tagtypes : Set of tdeftype =
  354. [recorddef,enumdef,
  355. {$IfNDef GDBKnowsStrings}
  356. stringdef,
  357. {$EndIf not GDBKnowsStrings}
  358. {$IfNDef GDBKnowsFiles}
  359. filedef,
  360. {$EndIf not GDBKnowsFiles}
  361. objectdef];
  362. {$endif GDB}
  363. const
  364. clearstack_pocalls = [
  365. pocall_cdecl,pocall_cppdecl,pocall_syscall
  366. ];
  367. pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal];
  368. SymTypeName : array[tsymtyp] of string[12] = (
  369. 'abstractsym','globalvar','localvar','paravar','fieldvar',
  370. 'type','proc','unit','const','enum','typed const',
  371. 'errorsym','system sym','label','absolutevar','property',
  372. 'macrosym','rttisym'
  373. );
  374. DefTypeName : array[tdeftype] of string[12] = (
  375. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  376. 'stringdef','enumdef','procdef','objectdef','errordef',
  377. 'filedef','formaldef','setdef','procvardef','floatdef',
  378. 'classrefdef','forwarddef','variantdef'
  379. );
  380. EqualTypeName : array[tequaltype] of string[16] = (
  381. 'incompatible','convert_operator','convert_l3','convert_l2',
  382. 'convert_l1','equal','exact'
  383. );
  384. implementation
  385. initialization
  386. if pocall_default in [pocall_register,pocall_internproc] then
  387. include(pushleftright_pocalls,pocall_compilerproc);
  388. end.
  389. {
  390. $Log$
  391. Revision 1.101 2005-01-30 11:26:40 peter
  392. * add info that a procedure is local in error messages
  393. Revision 1.100 2005/01/09 20:24:43 olle
  394. * rework of macro subsystem
  395. + exportable macros for mode macpas
  396. Revision 1.99 2005/01/06 02:13:03 karoly
  397. * more SysV call support stuff for MorphOS
  398. Revision 1.98 2005/01/05 02:31:06 karoly
  399. * fixed SysV syscall support (MorphOS)
  400. Revision 1.97 2005/01/04 17:40:33 karoly
  401. + sysv style syscalls added for MorphOS
  402. Revision 1.96 2004/12/05 12:28:11 peter
  403. * procvar handling for tp procvar mode fixed
  404. * proc to procvar moved from addrnode to typeconvnode
  405. * inlininginfo is now allocated only for inline routines that
  406. can be inlined, introduced a new flag po_has_inlining_info
  407. Revision 1.95 2004/11/19 08:17:02 michael
  408. * Split po_public into po_public and po_global (Peter)
  409. Revision 1.94 2004/11/17 22:21:35 peter
  410. mangledname setting moved to place after the complete proc declaration is read
  411. import generation moved to place where body is also parsed (still gives problems with win32)
  412. Revision 1.93 2004/11/15 23:35:31 peter
  413. * tparaitem removed, use tparavarsym instead
  414. * parameter order is now calculated from paranr value in tparavarsym
  415. Revision 1.92 2004/11/08 22:09:59 peter
  416. * tvarsym splitted
  417. Revision 1.91 2004/11/01 10:33:01 peter
  418. * symlist typeconv for absolute fixed
  419. Revision 1.90 2004/10/24 20:01:08 peter
  420. * remove saveregister calling convention
  421. Revision 1.89 2004/10/08 17:09:43 peter
  422. * tvarsym.varregable added, split vo_regable from varoptions
  423. Revision 1.88 2004/09/13 20:30:22 peter
  424. * vo_is_loop_counter added
  425. Revision 1.87 2004/08/25 15:57:04 peter
  426. * allow only 1 default property
  427. Revision 1.86 2004/07/09 22:17:32 peter
  428. * revert has_localst patch
  429. * replace aktstaticsymtable/aktglobalsymtable with current_module
  430. Revision 1.85 2004/07/06 19:52:04 peter
  431. * fix storing of localst in ppu
  432. Revision 1.84 2004/06/20 08:55:30 florian
  433. * logs truncated
  434. Revision 1.83 2004/06/16 20:07:09 florian
  435. * dwarf branch merged
  436. Revision 1.82 2004/05/23 14:32:17 peter
  437. * tprocinfoflag moved to globtype
  438. Revision 1.81 2004/04/29 19:56:37 daniel
  439. * Prepare compiler infrastructure for multiple ansistring types
  440. Revision 1.80 2004/04/28 15:19:03 florian
  441. + syscall directive support for MorphOS added
  442. Revision 1.79 2004/04/18 15:22:24 florian
  443. + location support for arguments, currently PowerPC/MorphOS only
  444. }