symdefh.inc 20 KB

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