symdefh.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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(tsymtableentry)
  28. deftype : tdeftype;
  29. savesize : longint;
  30. sym : ptypesym; { which type the definition was generated this def }
  31. has_inittable : boolean;
  32. { adress of init informations }
  33. inittable_label : plabel;
  34. has_rtti : boolean;
  35. { address of rtti }
  36. rtti_label : plabel;
  37. nextglobal,
  38. previousglobal : pdef;
  39. {$ifdef GDB}
  40. globalnb : word;
  41. is_def_stab_written : boolean;
  42. {$endif GDB}
  43. constructor init;
  44. constructor load;
  45. destructor done;virtual;
  46. { registers enumdef inside objects or
  47. record directly in the owner symtable !! }
  48. procedure correct_owner_symtable;
  49. function typename:string;
  50. procedure write;virtual;
  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. procedure symderef;virtual;
  61. { init. tables }
  62. function needs_inittable : boolean;virtual;
  63. procedure generate_inittable;
  64. function get_inittable_label : plabel;
  65. { the default implemenation calls write_rtti_data }
  66. { if init and rtti data is different these procedures }
  67. { must be overloaded }
  68. procedure write_init_data;virtual;
  69. { writes rtti of child to avoid mixup of rtti }
  70. procedure write_child_init_data;virtual;
  71. { rtti }
  72. procedure write_rtti_name;
  73. function get_rtti_label : string;virtual;
  74. procedure generate_rtti;virtual;
  75. procedure write_rtti_data;virtual;
  76. procedure write_child_rtti_data;virtual;
  77. { returns true, if the definition can be published }
  78. function is_publishable : boolean;virtual;
  79. function is_in_current : boolean;
  80. function gettypename:string;virtual;
  81. end;
  82. targconvtyp = (act_convertable,act_equal,act_exact);
  83. tvarspez = (vs_value,vs_const,vs_var);
  84. pdefcoll = ^tdefcoll;
  85. tdefcoll = record
  86. data : pdef;
  87. next : pdefcoll;
  88. paratyp : tvarspez;
  89. argconvtyp : targconvtyp;
  90. convertlevel : byte;
  91. end;
  92. tfiletype = (ft_text,ft_typed,ft_untyped);
  93. pfiledef = ^tfiledef;
  94. tfiledef = object(tdef)
  95. filetype : tfiletype;
  96. typed_as : pdef;
  97. constructor init(ft : tfiletype;tas : pdef);
  98. constructor load;
  99. procedure write;virtual;
  100. procedure deref;virtual;
  101. procedure setsize;
  102. {$ifdef GDB}
  103. function stabstring : pchar;virtual;
  104. procedure concatstabto(asmlist : paasmoutput);virtual;
  105. {$endif GDB}
  106. function gettypename:string;virtual;
  107. end;
  108. pformaldef = ^tformaldef;
  109. tformaldef = object(tdef)
  110. constructor init;
  111. constructor load;
  112. procedure write;virtual;
  113. {$ifdef GDB}
  114. function stabstring : pchar;virtual;
  115. procedure concatstabto(asmlist : paasmoutput);virtual;
  116. {$endif GDB}
  117. function gettypename:string;virtual;
  118. end;
  119. perrordef = ^terrordef;
  120. terrordef = object(tdef)
  121. constructor init;
  122. {$ifdef GDB}
  123. function stabstring : pchar;virtual;
  124. {$endif GDB}
  125. end;
  126. { tpointerdef and tclassrefdef should get a common
  127. base class, but I derived tclassrefdef from tpointerdef
  128. to avoid problems with bugs (FK)
  129. }
  130. ppointerdef = ^tpointerdef;
  131. tpointerdef = object(tdef)
  132. definition : pdef;
  133. defsym : ptypesym;
  134. is_far : boolean;
  135. constructor init(def : pdef);
  136. constructor initfar(def : pdef);
  137. constructor load;
  138. procedure write;virtual;
  139. {$ifdef GDB}
  140. function stabstring : pchar;virtual;
  141. procedure concatstabto(asmlist : paasmoutput);virtual;
  142. {$endif GDB}
  143. procedure deref;virtual;
  144. function gettypename:string;virtual;
  145. end;
  146. pobjectdef = ^tobjectdef;
  147. tobjectdef = object(tdef)
  148. childof : pobjectdef;
  149. objname : pstring;
  150. { privatesyms : psymtable;
  151. protectedsyms : psymtable; }
  152. publicsyms : psymtable;
  153. options : longint;
  154. { to be able to have a variable vmt position }
  155. { and no vmt field for objects without virtuals }
  156. vmt_offset : longint;
  157. constructor init(const n : string;c : pobjectdef);
  158. destructor done;virtual;
  159. procedure check_forwards;
  160. function isrelated(d : pobjectdef) : boolean;
  161. function size : longint;virtual;
  162. constructor load;
  163. procedure write;virtual;
  164. function vmt_mangledname : string;
  165. function rtti_name : string;
  166. function isclass : boolean;
  167. procedure insertvmt;
  168. procedure set_parent(c : pobjectdef);
  169. {$ifdef GDB}
  170. function stabstring : pchar;virtual;
  171. {$endif GDB}
  172. procedure deref;virtual;
  173. function needs_inittable : boolean;virtual;
  174. procedure write_init_data;virtual;
  175. procedure write_child_init_data;virtual;
  176. { rtti }
  177. function get_rtti_label : string;virtual;
  178. procedure generate_rtti;virtual;
  179. procedure write_rtti_data;virtual;
  180. procedure write_child_rtti_data;virtual;
  181. function next_free_name_index : longint;
  182. function is_publishable : boolean;virtual;
  183. end;
  184. pclassrefdef = ^tclassrefdef;
  185. tclassrefdef = object(tpointerdef)
  186. constructor init(def : pdef);
  187. constructor load;
  188. procedure write;virtual;
  189. {$ifdef GDB}
  190. function stabstring : pchar;virtual;
  191. procedure concatstabto(asmlist : paasmoutput);virtual;
  192. {$endif GDB}
  193. function gettypename:string;virtual;
  194. end;
  195. parraydef = ^tarraydef;
  196. tarraydef = object(tdef)
  197. private
  198. rangenr : longint;
  199. public
  200. lowrange,
  201. highrange : longint;
  202. definition : pdef;
  203. rangedef : pdef;
  204. IsVariant,
  205. IsConstructor,
  206. IsArrayOfConst : boolean;
  207. function gettypename:string;virtual;
  208. function elesize : longint;
  209. constructor init(l,h : longint;rd : pdef);
  210. constructor load;
  211. procedure write;virtual;
  212. {$ifdef GDB}
  213. function stabstring : pchar;virtual;
  214. procedure concatstabto(asmlist : paasmoutput);virtual;
  215. {$endif GDB}
  216. procedure deref;virtual;
  217. function size : longint;virtual;
  218. { generates the ranges needed by the asm instruction BOUND (i386)
  219. or CMP2 (Motorola) }
  220. procedure genrangecheck;
  221. { returns the label of the range check string }
  222. function getrangecheckstring : string;
  223. function needs_inittable : boolean;virtual;
  224. procedure write_rtti_data;virtual;
  225. procedure write_child_rtti_data;virtual;
  226. end;
  227. precdef = ^trecdef;
  228. trecdef = object(tdef)
  229. symtable : psymtable;
  230. constructor init(p : psymtable);
  231. constructor load;
  232. destructor done;virtual;
  233. procedure write;virtual;
  234. {$ifdef GDB}
  235. function stabstring : pchar;virtual;
  236. procedure concatstabto(asmlist : paasmoutput);virtual;
  237. {$endif GDB}
  238. procedure deref;virtual;
  239. function needs_inittable : boolean;virtual;
  240. procedure write_rtti_data;virtual;
  241. procedure write_init_data;virtual;
  242. procedure write_child_rtti_data;virtual;
  243. procedure write_child_init_data;virtual;
  244. function gettypename:string;virtual;
  245. end;
  246. { base types }
  247. tbasetype = (uauto,uvoid,uchar,
  248. u8bit,u16bit,u32bit,
  249. s8bit,s16bit,s32bit,
  250. bool8bit,bool16bit,bool32bit { uwchar,bool1bit,bitfield},
  251. u64bit,s64bitint);
  252. porddef = ^torddef;
  253. torddef = object(tdef)
  254. low,high : longint;
  255. rangenr : longint;
  256. typ : tbasetype;
  257. {
  258. bits : byte;
  259. }
  260. constructor init(t : tbasetype;v,b : longint);
  261. constructor load;
  262. procedure write;virtual;
  263. {$ifdef GDB}
  264. function stabstring : pchar;virtual;
  265. {$endif GDB}
  266. procedure setsize;
  267. { generates the ranges needed by the asm instruction BOUND }
  268. { or CMP2 (Motorola) }
  269. procedure genrangecheck;
  270. { returns the label of the range check string }
  271. function getrangecheckstring : string;
  272. procedure write_rtti_data;virtual;
  273. function is_publishable : boolean;virtual;
  274. function gettypename:string;virtual;
  275. end;
  276. { sextreal is dependant on the cpu, s64bit is also }
  277. { dependant on the size (tp = 80bit for both) }
  278. { The EXTENDED format exists on the motorola FPU }
  279. { but it uses 96 bits instead of 80, with some }
  280. { unused bits within the number itself! Pretty }
  281. { complicated to support, so no support for the }
  282. { moment. }
  283. { s64 bit is considered as a real because all }
  284. { calculations are done by the fpu. }
  285. tfloattype = (s32real,s64real,s80real,s64comp,f16bit,f32bit);
  286. pfloatdef = ^tfloatdef;
  287. tfloatdef = object(tdef)
  288. typ : tfloattype;
  289. constructor init(t : tfloattype);
  290. constructor load;
  291. procedure write;virtual;
  292. {$ifdef GDB}
  293. function stabstring : pchar;virtual;
  294. {$endif GDB}
  295. procedure setsize;
  296. function is_publishable : boolean;virtual;
  297. procedure write_rtti_data;virtual;
  298. function gettypename:string;virtual;
  299. end;
  300. pabstractprocdef = ^tabstractprocdef;
  301. tabstractprocdef = object(tdef)
  302. { saves a definition to the return type }
  303. retdef : pdef;
  304. fpu_used : byte; { how many stack fpu must be empty }
  305. options : longint; { save the procedure options }
  306. para1 : pdefcoll;
  307. constructor init;
  308. constructor load;
  309. destructor done;virtual;
  310. procedure concatdef(p : pdef;vsp : tvarspez);
  311. procedure deref;virtual;
  312. function para_size : longint;
  313. function demangled_paras : string;
  314. {$ifdef GDB}
  315. function stabstring : pchar;virtual;
  316. procedure concatstabto(asmlist : paasmoutput);virtual;
  317. {$endif GDB}
  318. procedure test_if_fpu_result;
  319. procedure write;virtual;
  320. end;
  321. pprocvardef = ^tprocvardef;
  322. tprocvardef = object(tabstractprocdef)
  323. constructor init;
  324. constructor load;
  325. procedure write;virtual;
  326. function size : longint;virtual;
  327. {$ifdef GDB}
  328. function stabstring : pchar;virtual;
  329. procedure concatstabto(asmlist : paasmoutput); virtual;
  330. {$endif GDB}
  331. procedure write_child_rtti_data;virtual;
  332. function is_publishable : boolean;virtual;
  333. procedure write_rtti_data;virtual;
  334. function gettypename:string;virtual;
  335. end;
  336. tmessageinf = record
  337. case integer of
  338. 0 : (str : pchar);
  339. 1 : (i : longint);
  340. end;
  341. pprocdef = ^tprocdef;
  342. tprocdef = object(tabstractprocdef)
  343. extnumber : longint;
  344. messageinf : tmessageinf;
  345. nextoverloaded : pprocdef;
  346. { where is this function defined, needed here because there
  347. is only one symbol for all overloaded functions }
  348. fileinfo : tfileposinfo;
  349. { pointer to the local symbol table }
  350. localst : psymtable;
  351. { pointer to the parameter symbol table }
  352. parast : psymtable;
  353. { browser info }
  354. lastref,
  355. defref,
  356. lastwritten : pref;
  357. refcount : longint;
  358. _class : pobjectdef;
  359. _mangledname : pchar;
  360. { it's a tree, but this not easy to handle }
  361. { used for inlined procs }
  362. code : pointer;
  363. { true, if the procedure is only declared }
  364. { (forward procedure) }
  365. forwarddef : boolean;
  366. { check the problems of manglednames }
  367. count : boolean;
  368. is_used : boolean;
  369. { set which contains the modified registers }
  370. {$ifdef i386}
  371. usedregisters : byte;
  372. {$endif}
  373. {$ifdef m68k}
  374. usedregisters : word;
  375. {$endif}
  376. {$ifdef alpha}
  377. usedregisters_int : longint;
  378. usedregisters_fpu : longint;
  379. {$endif}
  380. constructor init;
  381. destructor done;virtual;
  382. constructor load;
  383. procedure write;virtual;
  384. {$ifdef GDB}
  385. function cplusplusmangledname : string;
  386. function stabstring : pchar;virtual;
  387. procedure concatstabto(asmlist : paasmoutput);virtual;
  388. {$endif GDB}
  389. procedure deref;virtual;
  390. function mangledname : string;
  391. procedure setmangledname(const s : string);
  392. procedure load_references;
  393. function write_references : boolean;
  394. {$ifdef BrowserLog}
  395. procedure add_to_browserlog;
  396. {$endif BrowserLog}
  397. function haspara:boolean;
  398. end;
  399. tstringtype = (st_shortstring, st_longstring, st_ansistring, st_widestring);
  400. pstringdef = ^tstringdef;
  401. tstringdef = object(tdef)
  402. string_typ : tstringtype;
  403. len : longint;
  404. constructor shortinit(l : byte);
  405. constructor shortload;
  406. constructor longinit(l : longint);
  407. constructor longload;
  408. constructor ansiinit(l : longint);
  409. constructor ansiload;
  410. constructor wideinit(l : longint);
  411. constructor wideload;
  412. function stringtypname:string;
  413. function size : longint;virtual;
  414. procedure write;virtual;
  415. {$ifdef GDB}
  416. function stabstring : pchar;virtual;
  417. procedure concatstabto(asmlist : paasmoutput);virtual;
  418. {$endif GDB}
  419. function needs_inittable : boolean;virtual;
  420. procedure write_rtti_data;virtual;
  421. function is_publishable : boolean;virtual;
  422. function gettypename:string;virtual;
  423. end;
  424. penumdef = ^tenumdef;
  425. tenumdef = object(tdef)
  426. rangenr,
  427. minval,
  428. maxval : longint;
  429. has_jumps : boolean;
  430. firstenum : penumsym;
  431. basedef : penumdef;
  432. constructor init;
  433. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  434. constructor load;
  435. destructor done;virtual;
  436. procedure write;virtual;
  437. procedure deref;virtual;
  438. procedure calcsavesize;
  439. procedure setmax(_max:longint);
  440. procedure setmin(_min:longint);
  441. function min:longint;
  442. function max:longint;
  443. function getrangecheckstring:string;
  444. procedure genrangecheck;
  445. {$ifdef GDB}
  446. function stabstring : pchar;virtual;
  447. {$endif GDB}
  448. procedure write_child_rtti_data;virtual;
  449. procedure write_rtti_data;virtual;
  450. function is_publishable : boolean;virtual;
  451. function gettypename:string;virtual;
  452. end;
  453. tsettype = (normset,smallset,varset);
  454. psetdef = ^tsetdef;
  455. tsetdef = object(tdef)
  456. setof : pdef;
  457. settype : tsettype;
  458. constructor init(s : pdef;high : longint);
  459. constructor load;
  460. procedure write;virtual;
  461. {$ifdef GDB}
  462. function stabstring : pchar;virtual;
  463. procedure concatstabto(asmlist : paasmoutput);virtual;
  464. {$endif GDB}
  465. procedure deref;virtual;
  466. function is_publishable : boolean;virtual;
  467. procedure write_rtti_data;virtual;
  468. procedure write_child_rtti_data;virtual;
  469. function gettypename:string;virtual;
  470. end;
  471. {
  472. $Log$
  473. Revision 1.28 1999-05-19 16:48:28 florian
  474. * tdef.typename: returns a now a proper type name for the most types
  475. Revision 1.27 1999/05/13 21:59:42 peter
  476. * removed oldppu code
  477. * warning if objpas is loaded from uses
  478. * first things for new deref writing
  479. Revision 1.26 1999/05/12 00:19:59 peter
  480. * removed R_DEFAULT_SEG
  481. * uniform float names
  482. Revision 1.25 1999/05/08 19:52:37 peter
  483. + MessagePos() which is enhanced Message() function but also gets the
  484. position info
  485. * Removed comp warnings
  486. Revision 1.24 1999/05/06 09:05:30 peter
  487. * generic write_float and str_float
  488. * fixed constant float conversions
  489. Revision 1.23 1999/04/26 18:30:02 peter
  490. * farpointerdef moved into pointerdef.is_far
  491. Revision 1.22 1999/04/26 13:31:49 peter
  492. * release storenumber,double_checksum
  493. Revision 1.21 1999/04/21 09:43:52 peter
  494. * storenumber works
  495. * fixed some typos in double_checksum
  496. + incompatible types type1 and type2 message (with storenumber)
  497. Revision 1.20 1999/04/14 09:15:00 peter
  498. * first things to store the symbol/def number in the ppu
  499. Revision 1.19 1999/04/08 15:57:52 peter
  500. + subrange checking for readln()
  501. Revision 1.18 1999/03/02 18:24:21 peter
  502. * fixed overloading of array of char
  503. Revision 1.17 1999/03/01 13:45:06 pierre
  504. + added staticppusymtable symtable type for local browsing
  505. Revision 1.16 1999/02/22 20:13:39 florian
  506. + first implementation of message keyword
  507. Revision 1.15 1999/01/20 14:18:40 pierre
  508. * bugs related to mangledname solved
  509. - linux external without name
  510. -external procs already used
  511. (added count and is_used boolean fiels in tprocvar)
  512. Revision 1.14 1999/01/12 14:25:33 peter
  513. + BrowserLog for browser.log generation
  514. + BrowserCol for browser info in TCollections
  515. * released all other UseBrowser
  516. Revision 1.13 1998/12/30 22:15:53 peter
  517. + farpointer type
  518. * absolutesym now also stores if its far
  519. Revision 1.12 1998/12/10 09:47:28 florian
  520. + basic operations with int64/qord (compiler with -dint64)
  521. + rtti of enumerations extended: names are now written
  522. Revision 1.11 1998/11/29 21:45:49 florian
  523. * problem with arrays with init tables fixed
  524. Revision 1.10 1998/11/20 15:36:00 florian
  525. * problems with rtti fixed, hope it works
  526. Revision 1.9 1998/11/10 10:09:14 peter
  527. * va_list -> array of const
  528. Revision 1.8 1998/11/09 11:44:37 peter
  529. + va_list for printf support
  530. Revision 1.7 1998/11/05 12:02:59 peter
  531. * released useansistring
  532. * removed -Sv, its now available in fpc modes
  533. Revision 1.6 1998/10/22 17:11:23 pierre
  534. + terminated the include exclude implementation for i386
  535. * enums inside records fixed
  536. Revision 1.5 1998/10/16 13:12:55 pierre
  537. * added vmt_offsets in destructors code also !!!
  538. * vmt_offset code for m68k
  539. Revision 1.4 1998/10/16 08:51:52 peter
  540. + target_os.stackalignment
  541. + stack can be aligned at 2 or 4 byte boundaries
  542. Revision 1.3 1998/10/05 21:33:30 peter
  543. * fixed 161,165,166,167,168
  544. Revision 1.2 1998/10/02 07:20:40 florian
  545. * range checking in units doesn't work if the units are smartlinked, fixed
  546. Revision 1.1 1998/09/23 12:03:57 peter
  547. * overloading fix for array of const
  548. }