symdefh.inc 16 KB

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