2
0

symdefh.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. lowrange,
  184. highrange : longint;
  185. definition : pdef;
  186. rangedef : pdef;
  187. IsVariant,
  188. IsConstructor,
  189. IsArrayOfConst : boolean;
  190. rangenr : longint;
  191. function elesize : longint;
  192. constructor init(l,h : longint;rd : pdef);
  193. constructor load;
  194. procedure write;virtual;
  195. {$ifdef GDB}
  196. function stabstring : pchar;virtual;
  197. procedure concatstabto(asmlist : paasmoutput);virtual;
  198. {$endif GDB}
  199. procedure deref;virtual;
  200. function size : longint;virtual;
  201. { generates the ranges needed by the asm instruction BOUND (i386)
  202. or CMP2 (Motorola) }
  203. procedure genrangecheck;
  204. function needs_inittable : boolean;virtual;
  205. procedure write_rtti_data;virtual;
  206. procedure write_child_rtti_table;virtual;
  207. end;
  208. precdef = ^trecdef;
  209. trecdef = object(tdef)
  210. symtable : psymtable;
  211. constructor init(p : psymtable);
  212. constructor load;
  213. destructor done;virtual;
  214. procedure write;virtual;
  215. {$ifdef GDB}
  216. function stabstring : pchar;virtual;
  217. procedure concatstabto(asmlist : paasmoutput);virtual;
  218. {$endif GDB}
  219. procedure deref;virtual;
  220. function needs_inittable : boolean;virtual;
  221. procedure write_rtti_data;virtual;
  222. procedure write_init_data;virtual;
  223. procedure write_child_rtti_data;virtual;
  224. procedure write_child_init_data;virtual;
  225. end;
  226. { base types }
  227. tbasetype = (uauto,uvoid,uchar,
  228. u8bit,u16bit,u32bit,
  229. s8bit,s16bit,s32bit,
  230. bool8bit,bool16bit,bool32bit { uwchar,bool1bit,bitfield});
  231. porddef = ^torddef;
  232. torddef = object(tdef)
  233. low,high : longint;
  234. rangenr : longint;
  235. typ : tbasetype;
  236. {
  237. bits : byte;
  238. }
  239. constructor init(t : tbasetype;v,b : longint);
  240. constructor load;
  241. procedure write;virtual;
  242. {$ifdef GDB}
  243. function stabstring : pchar;virtual;
  244. {$endif GDB}
  245. procedure setsize;
  246. { generates the ranges needed by the asm instruction BOUND }
  247. { or CMP2 (Motorola) }
  248. procedure genrangecheck;
  249. procedure write_rtti_data;virtual;
  250. function is_publishable : boolean;virtual;
  251. end;
  252. { sextreal is dependant on the cpu, s64bit is also }
  253. { dependant on the size (tp = 80bit for both) }
  254. { The EXTENDED format exists on the motorola FPU }
  255. { but it uses 96 bits instead of 80, with some }
  256. { unused bits within the number itself! Pretty }
  257. { complicated to support, so no support for the }
  258. { moment. }
  259. { s64 bit is considered as a real because all }
  260. { calculations are done by the fpu. }
  261. tfloattype = (f32bit,s32real,s64real,s80real,s64bit,f16bit);
  262. pfloatdef = ^tfloatdef;
  263. tfloatdef = object(tdef)
  264. typ : tfloattype;
  265. constructor init(t : tfloattype);
  266. constructor load;
  267. procedure write;virtual;
  268. {$ifdef GDB}
  269. function stabstring : pchar;virtual;
  270. {$endif GDB}
  271. procedure setsize;
  272. function is_publishable : boolean;virtual;
  273. procedure write_rtti_data;virtual;
  274. end;
  275. pabstractprocdef = ^tabstractprocdef;
  276. tabstractprocdef = object(tdef)
  277. { saves a definition to the return type }
  278. retdef : pdef;
  279. fpu_used : byte; { how many stack fpu must be empty }
  280. { save the procedure options }
  281. options : longint;
  282. para1 : pdefcoll;
  283. constructor init;
  284. constructor load;
  285. destructor done;virtual;
  286. procedure concatdef(p : pdef;vsp : tvarspez);
  287. procedure deref;virtual;
  288. function para_size : longint;
  289. function demangled_paras : string;
  290. {$ifdef GDB}
  291. function stabstring : pchar;virtual;
  292. procedure concatstabto(asmlist : paasmoutput);virtual;
  293. {$endif GDB}
  294. procedure test_if_fpu_result;
  295. procedure write;virtual;
  296. end;
  297. pprocvardef = ^tprocvardef;
  298. tprocvardef = object(tabstractprocdef)
  299. constructor init;
  300. constructor load;
  301. procedure write;virtual;
  302. function size : longint;virtual;
  303. {$ifdef GDB}
  304. function stabstring : pchar;virtual;
  305. procedure concatstabto(asmlist : paasmoutput); virtual;
  306. {$endif GDB}
  307. procedure write_child_rtti_data;virtual;
  308. function is_publishable : boolean;virtual;
  309. procedure write_rtti_data;virtual;
  310. end;
  311. pprocdef = ^tprocdef;
  312. tprocdef = object(tabstractprocdef)
  313. extnumber : longint;
  314. nextoverloaded : pprocdef;
  315. { pointer to the local symbol table }
  316. localst : psymtable;
  317. { pointer to the parameter symbol table }
  318. parast : psymtable;
  319. {$ifdef UseBrowser}
  320. lastref,
  321. defref,
  322. lastwritten : pref;
  323. refcount : longint;
  324. {$endif UseBrowser}
  325. _class : pobjectdef;
  326. _mangledname : pchar;
  327. { it's a tree, but this not easy to handle }
  328. { used for inlined procs }
  329. code : pointer;
  330. { true, if the procedure is only declared }
  331. { (forward procedure) }
  332. forwarddef : boolean;
  333. { set which contains the modified registers }
  334. {$ifdef i386}
  335. usedregisters : byte;
  336. {$endif}
  337. {$ifdef m68k}
  338. usedregisters : word;
  339. {$endif}
  340. {$ifdef alpha}
  341. usedregisters_int : longint;
  342. usedregisters_fpu : longint;
  343. {$endif}
  344. constructor init;
  345. destructor done;virtual;
  346. constructor load;
  347. procedure write;virtual;
  348. {$ifdef GDB}
  349. function cplusplusmangledname : string;
  350. function stabstring : pchar;virtual;
  351. procedure concatstabto(asmlist : paasmoutput);virtual;
  352. {$endif GDB}
  353. procedure deref;virtual;
  354. function mangledname : string;
  355. procedure setmangledname(const s : string);
  356. {$ifdef UseBrowser}
  357. procedure load_references;
  358. function write_references : boolean;
  359. procedure add_to_browserlog;
  360. {$endif UseBrowser}
  361. end;
  362. tstringtype = (st_shortstring, st_longstring, st_ansistring, st_widestring);
  363. pstringdef = ^tstringdef;
  364. tstringdef = object(tdef)
  365. string_typ : tstringtype;
  366. len : longint;
  367. constructor init(l : byte);
  368. constructor load;
  369. constructor longinit(l : longint);
  370. constructor longload;
  371. constructor ansiinit(l : longint);
  372. constructor ansiload;
  373. constructor wideinit(l : longint);
  374. constructor wideload;
  375. function size : longint;virtual;
  376. procedure write;virtual;
  377. {$ifdef GDB}
  378. function stabstring : pchar;virtual;
  379. procedure concatstabto(asmlist : paasmoutput);virtual;
  380. {$endif GDB}
  381. function needs_inittable : boolean;virtual;
  382. procedure write_rtti_data;virtual;
  383. function is_publishable : boolean;virtual;
  384. end;
  385. penumdef = ^tenumdef;
  386. tenumdef = object(tdef)
  387. minval,
  388. maxval : longint;
  389. has_jumps : boolean;
  390. first : penumsym;
  391. basedef : penumdef;
  392. constructor init;
  393. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  394. constructor load;
  395. destructor done;virtual;
  396. procedure write;virtual;
  397. procedure deref;virtual;
  398. procedure calcsavesize;
  399. procedure setmax(_max:longint);
  400. procedure setmin(_min:longint);
  401. function min:longint;
  402. function max:longint;
  403. {$ifdef GDB}
  404. function stabstring : pchar;virtual;
  405. {$endif GDB}
  406. procedure write_child_rtti_data;virtual;
  407. procedure write_rtti_data;virtual;
  408. function is_publishable : boolean;virtual;
  409. end;
  410. tsettype = (normset,smallset,varset);
  411. psetdef = ^tsetdef;
  412. tsetdef = object(tdef)
  413. setof : pdef;
  414. settype : tsettype;
  415. constructor init(s : pdef;high : longint);
  416. constructor load;
  417. procedure write;virtual;
  418. {$ifdef GDB}
  419. function stabstring : pchar;virtual;
  420. procedure concatstabto(asmlist : paasmoutput);virtual;
  421. {$endif GDB}
  422. procedure deref;virtual;
  423. function is_publishable : boolean;virtual;
  424. procedure write_rtti_data;virtual;
  425. procedure write_child_rtti_data;virtual;
  426. end;
  427. {
  428. $Log$
  429. Revision 1.1 1998-09-23 12:03:57 peter
  430. * overloading fix for array of const
  431. }