symdefh.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Interface for the definition types of the symtable
  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. {************************************************
  19. TDef
  20. ************************************************}
  21. { definition contains the informations about a type }
  22. tdeftype = (abstractdef,arraydef,recorddef,pointerdef,orddef,
  23. stringdef,enumdef,procdef,objectdef,errordef,
  24. filedef,formaldef,setdef,procvardef,floatdef,
  25. classrefdef);
  26. pdef = ^tdef;
  27. tdef = object
  28. deftype : tdeftype;
  29. indexnb : longint;
  30. savesize : longint;
  31. next : pdef;
  32. owner : psymtable;
  33. sym : ptypesym; { which type the definition was generated this def }
  34. has_inittable : boolean;
  35. { adress of init informations }
  36. inittable_label : plabel;
  37. has_rtti : boolean;
  38. { address of rtti }
  39. rtti_label : plabel;
  40. nextglobal,
  41. previousglobal : pdef;
  42. {$ifdef GDB}
  43. globalnb : word;
  44. is_def_stab_written : boolean;
  45. {$endif GDB}
  46. constructor init;
  47. constructor load;
  48. destructor done;virtual;
  49. { registers enumdef inside objects or
  50. record directly in the owner symtable !! }
  51. procedure correct_owner_symtable;
  52. procedure write;virtual;
  53. procedure writename;
  54. function size:longint;virtual;
  55. {$ifdef GDB}
  56. function NumberString:string;
  57. procedure set_globalnb;
  58. function stabstring : pchar;virtual;
  59. function allstabstring : pchar;
  60. procedure concatstabto(asmlist : paasmoutput);virtual;
  61. {$endif GDB}
  62. procedure deref;virtual;
  63. { init. tables }
  64. function needs_inittable : boolean;virtual;
  65. procedure generate_inittable;
  66. function get_inittable_label : plabel;
  67. { the default implemenation calls write_rtti_data }
  68. { if init and rtti data is different these procedures }
  69. { must be overloaded }
  70. procedure write_init_data;virtual;
  71. { writes rtti of child to avoid mixup of rtti }
  72. procedure write_child_init_data;virtual;
  73. { rtti }
  74. function get_rtti_label : plabel;
  75. procedure generate_rtti;virtual;
  76. procedure write_rtti_data;virtual;
  77. procedure write_child_rtti_data;virtual;
  78. { returns true, if the definition can be published }
  79. function is_publishable : boolean;virtual;
  80. end;
  81. targconvtyp = (act_convertable,act_equal,act_exact);
  82. tvarspez = (vs_value,vs_const,vs_var);
  83. pdefcoll = ^tdefcoll;
  84. tdefcoll = record
  85. data : pdef;
  86. next : pdefcoll;
  87. paratyp : tvarspez;
  88. argconvtyp : targconvtyp;
  89. end;
  90. tfiletype = (ft_text,ft_typed,ft_untyped);
  91. pfiledef = ^tfiledef;
  92. tfiledef = object(tdef)
  93. filetype : tfiletype;
  94. typed_as : pdef;
  95. constructor init(ft : tfiletype;tas : pdef);
  96. constructor load;
  97. procedure write;virtual;
  98. procedure deref;virtual;
  99. procedure setsize;
  100. {$ifdef GDB}
  101. function stabstring : pchar;virtual;
  102. procedure concatstabto(asmlist : paasmoutput);virtual;
  103. {$endif GDB}
  104. end;
  105. pformaldef = ^tformaldef;
  106. tformaldef = object(tdef)
  107. constructor init;
  108. constructor load;
  109. procedure write;virtual;
  110. {$ifdef GDB}
  111. function stabstring : pchar;virtual;
  112. procedure concatstabto(asmlist : paasmoutput);virtual;
  113. {$endif GDB}
  114. end;
  115. perrordef = ^terrordef;
  116. terrordef = object(tdef)
  117. constructor init;
  118. {$ifdef GDB}
  119. function stabstring : pchar;virtual;
  120. {$endif GDB}
  121. end;
  122. { tpointerdef and tclassrefdef should get a common
  123. base class, but I derived tclassrefdef from tpointerdef
  124. to avoid problems with bugs (FK)
  125. }
  126. ppointerdef = ^tpointerdef;
  127. tpointerdef = object(tdef)
  128. definition : pdef;
  129. defsym : ptypesym;
  130. constructor init(def : pdef);
  131. constructor load;
  132. procedure write;virtual;
  133. {$ifdef GDB}
  134. function stabstring : pchar;virtual;
  135. procedure concatstabto(asmlist : paasmoutput);virtual;
  136. {$endif GDB}
  137. procedure deref;virtual;
  138. end;
  139. pobjectdef = ^tobjectdef;
  140. tobjectdef = object(tdef)
  141. childof : pobjectdef;
  142. name : pstring;
  143. { privatesyms : psymtable;
  144. protectedsyms : psymtable; }
  145. publicsyms : psymtable;
  146. options : longint;
  147. { to be able to have a variable vmt position }
  148. { and no vmt field for objects without virtuals }
  149. vmt_offset : longint;
  150. constructor init(const n : string;c : pobjectdef);
  151. destructor done;virtual;
  152. procedure check_forwards;
  153. function isrelated(d : pobjectdef) : boolean;
  154. function size : longint;virtual;
  155. constructor load;
  156. procedure write;virtual;
  157. function vmt_mangledname : string;
  158. function rtti_name : string;
  159. function isclass : boolean;
  160. procedure insertvmt;
  161. procedure set_parent(c : pobjectdef);
  162. {$ifdef GDB}
  163. function stabstring : pchar;virtual;
  164. {$endif GDB}
  165. procedure deref;virtual;
  166. function needs_inittable : boolean;virtual;
  167. procedure write_init_data;virtual;
  168. procedure write_child_init_data;virtual;
  169. { rtti }
  170. procedure generate_rtti;virtual;
  171. procedure write_rtti_data;virtual;
  172. procedure write_child_rtti_data;virtual;
  173. function next_free_name_index : longint;
  174. function is_publishable : boolean;virtual;
  175. end;
  176. pclassrefdef = ^tclassrefdef;
  177. tclassrefdef = object(tpointerdef)
  178. constructor init(def : pdef);
  179. constructor load;
  180. procedure write;virtual;
  181. {$ifdef GDB}
  182. function stabstring : pchar;virtual;
  183. procedure concatstabto(asmlist : paasmoutput);virtual;
  184. {$endif GDB}
  185. end;
  186. parraydef = ^tarraydef;
  187. tarraydef = object(tdef)
  188. private
  189. rangenr : longint;
  190. public
  191. lowrange,
  192. highrange : longint;
  193. definition : pdef;
  194. rangedef : pdef;
  195. IsVariant,
  196. IsConstructor,
  197. IsArrayOfConst : boolean;
  198. function elesize : longint;
  199. constructor init(l,h : longint;rd : pdef);
  200. constructor load;
  201. procedure write;virtual;
  202. {$ifdef GDB}
  203. function stabstring : pchar;virtual;
  204. procedure concatstabto(asmlist : paasmoutput);virtual;
  205. {$endif GDB}
  206. procedure deref;virtual;
  207. function size : longint;virtual;
  208. { generates the ranges needed by the asm instruction BOUND (i386)
  209. or CMP2 (Motorola) }
  210. procedure genrangecheck;
  211. { returns the label of the range check string }
  212. function getrangecheckstring : string;
  213. function needs_inittable : boolean;virtual;
  214. procedure write_rtti_data;virtual;
  215. procedure write_child_rtti_table;virtual;
  216. end;
  217. precdef = ^trecdef;
  218. trecdef = object(tdef)
  219. symtable : psymtable;
  220. constructor init(p : psymtable);
  221. constructor load;
  222. destructor done;virtual;
  223. procedure write;virtual;
  224. {$ifdef GDB}
  225. function stabstring : pchar;virtual;
  226. procedure concatstabto(asmlist : paasmoutput);virtual;
  227. {$endif GDB}
  228. procedure deref;virtual;
  229. function needs_inittable : boolean;virtual;
  230. procedure write_rtti_data;virtual;
  231. procedure write_init_data;virtual;
  232. procedure write_child_rtti_data;virtual;
  233. procedure write_child_init_data;virtual;
  234. end;
  235. { base types }
  236. tbasetype = (uauto,uvoid,uchar,
  237. u8bit,u16bit,u32bit,
  238. s8bit,s16bit,s32bit,
  239. bool8bit,bool16bit,bool32bit { uwchar,bool1bit,bitfield});
  240. porddef = ^torddef;
  241. torddef = object(tdef)
  242. low,high : longint;
  243. rangenr : longint;
  244. typ : tbasetype;
  245. {
  246. bits : byte;
  247. }
  248. constructor init(t : tbasetype;v,b : longint);
  249. constructor load;
  250. procedure write;virtual;
  251. {$ifdef GDB}
  252. function stabstring : pchar;virtual;
  253. {$endif GDB}
  254. procedure setsize;
  255. { generates the ranges needed by the asm instruction BOUND }
  256. { or CMP2 (Motorola) }
  257. procedure genrangecheck;
  258. { returns the label of the range check string }
  259. function getrangecheckstring : string;
  260. procedure write_rtti_data;virtual;
  261. function is_publishable : boolean;virtual;
  262. end;
  263. { sextreal is dependant on the cpu, s64bit is also }
  264. { dependant on the size (tp = 80bit for both) }
  265. { The EXTENDED format exists on the motorola FPU }
  266. { but it uses 96 bits instead of 80, with some }
  267. { unused bits within the number itself! Pretty }
  268. { complicated to support, so no support for the }
  269. { moment. }
  270. { s64 bit is considered as a real because all }
  271. { calculations are done by the fpu. }
  272. tfloattype = (f32bit,s32real,s64real,s80real,s64bit,f16bit);
  273. pfloatdef = ^tfloatdef;
  274. tfloatdef = object(tdef)
  275. typ : tfloattype;
  276. constructor init(t : tfloattype);
  277. constructor load;
  278. procedure write;virtual;
  279. {$ifdef GDB}
  280. function stabstring : pchar;virtual;
  281. {$endif GDB}
  282. procedure setsize;
  283. function is_publishable : boolean;virtual;
  284. procedure write_rtti_data;virtual;
  285. end;
  286. pabstractprocdef = ^tabstractprocdef;
  287. tabstractprocdef = object(tdef)
  288. { saves a definition to the return type }
  289. retdef : pdef;
  290. fpu_used : byte; { how many stack fpu must be empty }
  291. options : longint; { save the procedure options }
  292. para1 : pdefcoll;
  293. constructor init;
  294. constructor load;
  295. destructor done;virtual;
  296. procedure concatdef(p : pdef;vsp : tvarspez);
  297. procedure deref;virtual;
  298. function para_size : longint;
  299. function demangled_paras : string;
  300. {$ifdef GDB}
  301. function stabstring : pchar;virtual;
  302. procedure concatstabto(asmlist : paasmoutput);virtual;
  303. {$endif GDB}
  304. procedure test_if_fpu_result;
  305. procedure write;virtual;
  306. end;
  307. pprocvardef = ^tprocvardef;
  308. tprocvardef = object(tabstractprocdef)
  309. constructor init;
  310. constructor load;
  311. procedure write;virtual;
  312. function size : longint;virtual;
  313. {$ifdef GDB}
  314. function stabstring : pchar;virtual;
  315. procedure concatstabto(asmlist : paasmoutput); virtual;
  316. {$endif GDB}
  317. procedure write_child_rtti_data;virtual;
  318. function is_publishable : boolean;virtual;
  319. procedure write_rtti_data;virtual;
  320. end;
  321. pprocdef = ^tprocdef;
  322. tprocdef = object(tabstractprocdef)
  323. extnumber : longint;
  324. nextoverloaded : pprocdef;
  325. { pointer to the local symbol table }
  326. localst : psymtable;
  327. { pointer to the parameter symbol table }
  328. parast : psymtable;
  329. {$ifdef UseBrowser}
  330. lastref,
  331. defref,
  332. lastwritten : pref;
  333. refcount : longint;
  334. {$endif UseBrowser}
  335. _class : pobjectdef;
  336. _mangledname : pchar;
  337. { it's a tree, but this not easy to handle }
  338. { used for inlined procs }
  339. code : pointer;
  340. { true, if the procedure is only declared }
  341. { (forward procedure) }
  342. forwarddef : boolean;
  343. { set which contains the modified registers }
  344. {$ifdef i386}
  345. usedregisters : byte;
  346. {$endif}
  347. {$ifdef m68k}
  348. usedregisters : word;
  349. {$endif}
  350. {$ifdef alpha}
  351. usedregisters_int : longint;
  352. usedregisters_fpu : longint;
  353. {$endif}
  354. constructor init;
  355. destructor done;virtual;
  356. constructor load;
  357. procedure write;virtual;
  358. {$ifdef GDB}
  359. function cplusplusmangledname : string;
  360. function stabstring : pchar;virtual;
  361. procedure concatstabto(asmlist : paasmoutput);virtual;
  362. {$endif GDB}
  363. procedure deref;virtual;
  364. function mangledname : string;
  365. procedure setmangledname(const s : string);
  366. {$ifdef UseBrowser}
  367. procedure load_references;
  368. function write_references : boolean;
  369. procedure add_to_browserlog;
  370. {$endif UseBrowser}
  371. end;
  372. tstringtype = (st_shortstring, st_longstring, st_ansistring, st_widestring);
  373. pstringdef = ^tstringdef;
  374. tstringdef = object(tdef)
  375. string_typ : tstringtype;
  376. len : longint;
  377. constructor shortinit(l : byte);
  378. constructor shortload;
  379. constructor longinit(l : longint);
  380. constructor longload;
  381. constructor ansiinit(l : longint);
  382. constructor ansiload;
  383. constructor wideinit(l : longint);
  384. constructor wideload;
  385. function size : longint;virtual;
  386. procedure write;virtual;
  387. {$ifdef GDB}
  388. function stabstring : pchar;virtual;
  389. procedure concatstabto(asmlist : paasmoutput);virtual;
  390. {$endif GDB}
  391. function needs_inittable : boolean;virtual;
  392. procedure write_rtti_data;virtual;
  393. function is_publishable : boolean;virtual;
  394. end;
  395. penumdef = ^tenumdef;
  396. tenumdef = object(tdef)
  397. rangenr,
  398. minval,
  399. maxval : longint;
  400. has_jumps : boolean;
  401. first : penumsym;
  402. basedef : penumdef;
  403. constructor init;
  404. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  405. constructor load;
  406. destructor done;virtual;
  407. procedure write;virtual;
  408. procedure deref;virtual;
  409. procedure calcsavesize;
  410. procedure setmax(_max:longint);
  411. procedure setmin(_min:longint);
  412. function min:longint;
  413. function max:longint;
  414. function getrangecheckstring:string;
  415. procedure genrangecheck;
  416. {$ifdef GDB}
  417. function stabstring : pchar;virtual;
  418. {$endif GDB}
  419. procedure write_child_rtti_data;virtual;
  420. procedure write_rtti_data;virtual;
  421. function is_publishable : boolean;virtual;
  422. end;
  423. tsettype = (normset,smallset,varset);
  424. psetdef = ^tsetdef;
  425. tsetdef = object(tdef)
  426. setof : pdef;
  427. settype : tsettype;
  428. constructor init(s : pdef;high : longint);
  429. constructor load;
  430. procedure write;virtual;
  431. {$ifdef GDB}
  432. function stabstring : pchar;virtual;
  433. procedure concatstabto(asmlist : paasmoutput);virtual;
  434. {$endif GDB}
  435. procedure deref;virtual;
  436. function is_publishable : boolean;virtual;
  437. procedure write_rtti_data;virtual;
  438. procedure write_child_rtti_data;virtual;
  439. end;
  440. {
  441. $Log$
  442. Revision 1.9 1998-11-10 10:09:14 peter
  443. * va_list -> array of const
  444. Revision 1.8 1998/11/09 11:44:37 peter
  445. + va_list for printf support
  446. Revision 1.7 1998/11/05 12:02:59 peter
  447. * released useansistring
  448. * removed -Sv, its now available in fpc modes
  449. Revision 1.6 1998/10/22 17:11:23 pierre
  450. + terminated the include exclude implementation for i386
  451. * enums inside records fixed
  452. Revision 1.5 1998/10/16 13:12:55 pierre
  453. * added vmt_offsets in destructors code also !!!
  454. * vmt_offset code for m68k
  455. Revision 1.4 1998/10/16 08:51:52 peter
  456. + target_os.stackalignment
  457. + stack can be aligned at 2 or 4 byte boundaries
  458. Revision 1.3 1998/10/05 21:33:30 peter
  459. * fixed 161,165,166,167,168
  460. Revision 1.2 1998/10/02 07:20:40 florian
  461. * range checking in units doesn't work if the units are smartlinked, fixed
  462. Revision 1.1 1998/09/23 12:03:57 peter
  463. * overloading fix for array of const
  464. }