symdefh.inc 18 KB

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