symdefh.inc 19 KB

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