symdefh.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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 : string;virtual;
  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. function get_rtti_label : string;virtual;
  171. procedure generate_rtti;virtual;
  172. procedure write_rtti_data;virtual;
  173. procedure write_child_rtti_data;virtual;
  174. function next_free_name_index : longint;
  175. function is_publishable : boolean;virtual;
  176. end;
  177. pclassrefdef = ^tclassrefdef;
  178. tclassrefdef = object(tpointerdef)
  179. constructor init(def : pdef);
  180. constructor load;
  181. procedure write;virtual;
  182. {$ifdef GDB}
  183. function stabstring : pchar;virtual;
  184. procedure concatstabto(asmlist : paasmoutput);virtual;
  185. {$endif GDB}
  186. end;
  187. parraydef = ^tarraydef;
  188. tarraydef = object(tdef)
  189. private
  190. rangenr : longint;
  191. public
  192. lowrange,
  193. highrange : longint;
  194. definition : pdef;
  195. rangedef : pdef;
  196. IsVariant,
  197. IsConstructor,
  198. IsArrayOfConst : boolean;
  199. function elesize : longint;
  200. constructor init(l,h : longint;rd : pdef);
  201. constructor load;
  202. procedure write;virtual;
  203. {$ifdef GDB}
  204. function stabstring : pchar;virtual;
  205. procedure concatstabto(asmlist : paasmoutput);virtual;
  206. {$endif GDB}
  207. procedure deref;virtual;
  208. function size : longint;virtual;
  209. { generates the ranges needed by the asm instruction BOUND (i386)
  210. or CMP2 (Motorola) }
  211. procedure genrangecheck;
  212. { returns the label of the range check string }
  213. function getrangecheckstring : string;
  214. function needs_inittable : boolean;virtual;
  215. procedure write_rtti_data;virtual;
  216. procedure write_child_rtti_data;virtual;
  217. end;
  218. precdef = ^trecdef;
  219. trecdef = object(tdef)
  220. symtable : psymtable;
  221. constructor init(p : psymtable);
  222. constructor load;
  223. destructor done;virtual;
  224. procedure write;virtual;
  225. {$ifdef GDB}
  226. function stabstring : pchar;virtual;
  227. procedure concatstabto(asmlist : paasmoutput);virtual;
  228. {$endif GDB}
  229. procedure deref;virtual;
  230. function needs_inittable : boolean;virtual;
  231. procedure write_rtti_data;virtual;
  232. procedure write_init_data;virtual;
  233. procedure write_child_rtti_data;virtual;
  234. procedure write_child_init_data;virtual;
  235. end;
  236. { base types }
  237. tbasetype = (uauto,uvoid,uchar,
  238. u8bit,u16bit,u32bit,
  239. s8bit,s16bit,s32bit,
  240. bool8bit,bool16bit,bool32bit { uwchar,bool1bit,bitfield});
  241. porddef = ^torddef;
  242. torddef = object(tdef)
  243. low,high : longint;
  244. rangenr : longint;
  245. typ : tbasetype;
  246. {
  247. bits : byte;
  248. }
  249. constructor init(t : tbasetype;v,b : longint);
  250. constructor load;
  251. procedure write;virtual;
  252. {$ifdef GDB}
  253. function stabstring : pchar;virtual;
  254. {$endif GDB}
  255. procedure setsize;
  256. { generates the ranges needed by the asm instruction BOUND }
  257. { or CMP2 (Motorola) }
  258. procedure genrangecheck;
  259. { returns the label of the range check string }
  260. function getrangecheckstring : string;
  261. procedure write_rtti_data;virtual;
  262. function is_publishable : boolean;virtual;
  263. end;
  264. { sextreal is dependant on the cpu, s64bit is also }
  265. { dependant on the size (tp = 80bit for both) }
  266. { The EXTENDED format exists on the motorola FPU }
  267. { but it uses 96 bits instead of 80, with some }
  268. { unused bits within the number itself! Pretty }
  269. { complicated to support, so no support for the }
  270. { moment. }
  271. { s64 bit is considered as a real because all }
  272. { calculations are done by the fpu. }
  273. tfloattype = (f32bit,s32real,s64real,s80real,s64bit,f16bit);
  274. pfloatdef = ^tfloatdef;
  275. tfloatdef = object(tdef)
  276. typ : tfloattype;
  277. constructor init(t : tfloattype);
  278. constructor load;
  279. procedure write;virtual;
  280. {$ifdef GDB}
  281. function stabstring : pchar;virtual;
  282. {$endif GDB}
  283. procedure setsize;
  284. function is_publishable : boolean;virtual;
  285. procedure write_rtti_data;virtual;
  286. end;
  287. pabstractprocdef = ^tabstractprocdef;
  288. tabstractprocdef = object(tdef)
  289. { saves a definition to the return type }
  290. retdef : pdef;
  291. fpu_used : byte; { how many stack fpu must be empty }
  292. options : longint; { save the procedure options }
  293. para1 : pdefcoll;
  294. constructor init;
  295. constructor load;
  296. destructor done;virtual;
  297. procedure concatdef(p : pdef;vsp : tvarspez);
  298. procedure deref;virtual;
  299. function para_size : longint;
  300. function demangled_paras : string;
  301. {$ifdef GDB}
  302. function stabstring : pchar;virtual;
  303. procedure concatstabto(asmlist : paasmoutput);virtual;
  304. {$endif GDB}
  305. procedure test_if_fpu_result;
  306. procedure write;virtual;
  307. end;
  308. pprocvardef = ^tprocvardef;
  309. tprocvardef = object(tabstractprocdef)
  310. constructor init;
  311. constructor load;
  312. procedure write;virtual;
  313. function size : longint;virtual;
  314. {$ifdef GDB}
  315. function stabstring : pchar;virtual;
  316. procedure concatstabto(asmlist : paasmoutput); virtual;
  317. {$endif GDB}
  318. procedure write_child_rtti_data;virtual;
  319. function is_publishable : boolean;virtual;
  320. procedure write_rtti_data;virtual;
  321. end;
  322. pprocdef = ^tprocdef;
  323. tprocdef = object(tabstractprocdef)
  324. extnumber : longint;
  325. nextoverloaded : pprocdef;
  326. { pointer to the local symbol table }
  327. localst : psymtable;
  328. { pointer to the parameter symbol table }
  329. parast : psymtable;
  330. {$ifdef UseBrowser}
  331. lastref,
  332. defref,
  333. lastwritten : pref;
  334. refcount : longint;
  335. {$endif UseBrowser}
  336. _class : pobjectdef;
  337. _mangledname : pchar;
  338. { it's a tree, but this not easy to handle }
  339. { used for inlined procs }
  340. code : pointer;
  341. { true, if the procedure is only declared }
  342. { (forward procedure) }
  343. forwarddef : boolean;
  344. { set which contains the modified registers }
  345. {$ifdef i386}
  346. usedregisters : byte;
  347. {$endif}
  348. {$ifdef m68k}
  349. usedregisters : word;
  350. {$endif}
  351. {$ifdef alpha}
  352. usedregisters_int : longint;
  353. usedregisters_fpu : longint;
  354. {$endif}
  355. constructor init;
  356. destructor done;virtual;
  357. constructor load;
  358. procedure write;virtual;
  359. {$ifdef GDB}
  360. function cplusplusmangledname : string;
  361. function stabstring : pchar;virtual;
  362. procedure concatstabto(asmlist : paasmoutput);virtual;
  363. {$endif GDB}
  364. procedure deref;virtual;
  365. function mangledname : string;
  366. procedure setmangledname(const s : string);
  367. {$ifdef UseBrowser}
  368. procedure load_references;
  369. function write_references : boolean;
  370. procedure add_to_browserlog;
  371. {$endif UseBrowser}
  372. end;
  373. tstringtype = (st_shortstring, st_longstring, st_ansistring, st_widestring);
  374. pstringdef = ^tstringdef;
  375. tstringdef = object(tdef)
  376. string_typ : tstringtype;
  377. len : longint;
  378. constructor shortinit(l : byte);
  379. constructor shortload;
  380. constructor longinit(l : longint);
  381. constructor longload;
  382. constructor ansiinit(l : longint);
  383. constructor ansiload;
  384. constructor wideinit(l : longint);
  385. constructor wideload;
  386. function size : longint;virtual;
  387. procedure write;virtual;
  388. {$ifdef GDB}
  389. function stabstring : pchar;virtual;
  390. procedure concatstabto(asmlist : paasmoutput);virtual;
  391. {$endif GDB}
  392. function needs_inittable : boolean;virtual;
  393. procedure write_rtti_data;virtual;
  394. function is_publishable : boolean;virtual;
  395. end;
  396. penumdef = ^tenumdef;
  397. tenumdef = object(tdef)
  398. rangenr,
  399. minval,
  400. maxval : longint;
  401. has_jumps : boolean;
  402. first : penumsym;
  403. basedef : penumdef;
  404. constructor init;
  405. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  406. constructor load;
  407. destructor done;virtual;
  408. procedure write;virtual;
  409. procedure deref;virtual;
  410. procedure calcsavesize;
  411. procedure setmax(_max:longint);
  412. procedure setmin(_min:longint);
  413. function min:longint;
  414. function max:longint;
  415. function getrangecheckstring:string;
  416. procedure genrangecheck;
  417. {$ifdef GDB}
  418. function stabstring : pchar;virtual;
  419. {$endif GDB}
  420. procedure write_child_rtti_data;virtual;
  421. procedure write_rtti_data;virtual;
  422. function is_publishable : boolean;virtual;
  423. end;
  424. tsettype = (normset,smallset,varset);
  425. psetdef = ^tsetdef;
  426. tsetdef = object(tdef)
  427. setof : pdef;
  428. settype : tsettype;
  429. constructor init(s : pdef;high : longint);
  430. constructor load;
  431. procedure write;virtual;
  432. {$ifdef GDB}
  433. function stabstring : pchar;virtual;
  434. procedure concatstabto(asmlist : paasmoutput);virtual;
  435. {$endif GDB}
  436. procedure deref;virtual;
  437. function is_publishable : boolean;virtual;
  438. procedure write_rtti_data;virtual;
  439. procedure write_child_rtti_data;virtual;
  440. end;
  441. {
  442. $Log$
  443. Revision 1.11 1998-11-29 21:45:49 florian
  444. * problem with arrays with init tables fixed
  445. Revision 1.10 1998/11/20 15:36:00 florian
  446. * problems with rtti fixed, hope it works
  447. Revision 1.9 1998/11/10 10:09:14 peter
  448. * va_list -> array of const
  449. Revision 1.8 1998/11/09 11:44:37 peter
  450. + va_list for printf support
  451. Revision 1.7 1998/11/05 12:02:59 peter
  452. * released useansistring
  453. * removed -Sv, its now available in fpc modes
  454. Revision 1.6 1998/10/22 17:11:23 pierre
  455. + terminated the include exclude implementation for i386
  456. * enums inside records fixed
  457. Revision 1.5 1998/10/16 13:12:55 pierre
  458. * added vmt_offsets in destructors code also !!!
  459. * vmt_offset code for m68k
  460. Revision 1.4 1998/10/16 08:51:52 peter
  461. + target_os.stackalignment
  462. + stack can be aligned at 2 or 4 byte boundaries
  463. Revision 1.3 1998/10/05 21:33:30 peter
  464. * fixed 161,165,166,167,168
  465. Revision 1.2 1998/10/02 07:20:40 florian
  466. * range checking in units doesn't work if the units are smartlinked, fixed
  467. Revision 1.1 1998/09/23 12:03:57 peter
  468. * overloading fix for array of const
  469. }