symdefh.inc 21 KB

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