symdefh.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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. {$ifndef OLDPPU}
  28. tdef = object(tnamedindexobject)
  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. is_far : boolean;
  139. constructor init(def : pdef);
  140. constructor initfar(def : pdef);
  141. constructor load;
  142. procedure write;virtual;
  143. {$ifdef GDB}
  144. function stabstring : pchar;virtual;
  145. procedure concatstabto(asmlist : paasmoutput);virtual;
  146. {$endif GDB}
  147. procedure deref;virtual;
  148. end;
  149. pobjectdef = ^tobjectdef;
  150. tobjectdef = object(tdef)
  151. childof : pobjectdef;
  152. objname : pstring;
  153. { privatesyms : psymtable;
  154. protectedsyms : psymtable; }
  155. publicsyms : psymtable;
  156. options : longint;
  157. { to be able to have a variable vmt position }
  158. { and no vmt field for objects without virtuals }
  159. vmt_offset : longint;
  160. constructor init(const n : string;c : pobjectdef);
  161. destructor done;virtual;
  162. procedure check_forwards;
  163. function isrelated(d : pobjectdef) : boolean;
  164. function size : longint;virtual;
  165. constructor load;
  166. procedure write;virtual;
  167. function vmt_mangledname : string;
  168. function rtti_name : string;
  169. function isclass : boolean;
  170. procedure insertvmt;
  171. procedure set_parent(c : pobjectdef);
  172. {$ifdef GDB}
  173. function stabstring : pchar;virtual;
  174. {$endif GDB}
  175. procedure deref;virtual;
  176. function needs_inittable : boolean;virtual;
  177. procedure write_init_data;virtual;
  178. procedure write_child_init_data;virtual;
  179. { rtti }
  180. function get_rtti_label : string;virtual;
  181. procedure generate_rtti;virtual;
  182. procedure write_rtti_data;virtual;
  183. procedure write_child_rtti_data;virtual;
  184. function next_free_name_index : longint;
  185. function is_publishable : boolean;virtual;
  186. end;
  187. pclassrefdef = ^tclassrefdef;
  188. tclassrefdef = object(tpointerdef)
  189. constructor init(def : pdef);
  190. constructor load;
  191. procedure write;virtual;
  192. {$ifdef GDB}
  193. function stabstring : pchar;virtual;
  194. procedure concatstabto(asmlist : paasmoutput);virtual;
  195. {$endif GDB}
  196. end;
  197. parraydef = ^tarraydef;
  198. tarraydef = object(tdef)
  199. private
  200. rangenr : longint;
  201. public
  202. lowrange,
  203. highrange : longint;
  204. definition : pdef;
  205. rangedef : pdef;
  206. IsVariant,
  207. IsConstructor,
  208. IsArrayOfConst : boolean;
  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. 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. end;
  275. { sextreal is dependant on the cpu, s64bit is also }
  276. { dependant on the size (tp = 80bit for both) }
  277. { The EXTENDED format exists on the motorola FPU }
  278. { but it uses 96 bits instead of 80, with some }
  279. { unused bits within the number itself! Pretty }
  280. { complicated to support, so no support for the }
  281. { moment. }
  282. { s64 bit is considered as a real because all }
  283. { calculations are done by the fpu. }
  284. tfloattype = (s32real,s64real,s80real,s64bitcomp,f16bit,f32bit);
  285. pfloatdef = ^tfloatdef;
  286. tfloatdef = object(tdef)
  287. typ : tfloattype;
  288. constructor init(t : tfloattype);
  289. constructor load;
  290. procedure write;virtual;
  291. {$ifdef GDB}
  292. function stabstring : pchar;virtual;
  293. {$endif GDB}
  294. procedure setsize;
  295. function is_publishable : boolean;virtual;
  296. procedure write_rtti_data;virtual;
  297. end;
  298. pabstractprocdef = ^tabstractprocdef;
  299. tabstractprocdef = object(tdef)
  300. { saves a definition to the return type }
  301. retdef : pdef;
  302. fpu_used : byte; { how many stack fpu must be empty }
  303. options : longint; { save the procedure options }
  304. para1 : pdefcoll;
  305. constructor init;
  306. constructor load;
  307. destructor done;virtual;
  308. procedure concatdef(p : pdef;vsp : tvarspez);
  309. procedure deref;virtual;
  310. function para_size : longint;
  311. function demangled_paras : string;
  312. {$ifdef GDB}
  313. function stabstring : pchar;virtual;
  314. procedure concatstabto(asmlist : paasmoutput);virtual;
  315. {$endif GDB}
  316. procedure test_if_fpu_result;
  317. procedure write;virtual;
  318. end;
  319. pprocvardef = ^tprocvardef;
  320. tprocvardef = object(tabstractprocdef)
  321. constructor init;
  322. constructor load;
  323. procedure write;virtual;
  324. function size : longint;virtual;
  325. {$ifdef GDB}
  326. function stabstring : pchar;virtual;
  327. procedure concatstabto(asmlist : paasmoutput); virtual;
  328. {$endif GDB}
  329. procedure write_child_rtti_data;virtual;
  330. function is_publishable : boolean;virtual;
  331. procedure write_rtti_data;virtual;
  332. end;
  333. tmessageinf = record
  334. case integer of
  335. 0 : (str : pchar);
  336. 1 : (i : longint);
  337. end;
  338. pprocdef = ^tprocdef;
  339. tprocdef = object(tabstractprocdef)
  340. extnumber : longint;
  341. messageinf : tmessageinf;
  342. nextoverloaded : pprocdef;
  343. { pointer to the local symbol table }
  344. localst : psymtable;
  345. { pointer to the parameter symbol table }
  346. parast : psymtable;
  347. { browser info }
  348. lastref,
  349. defref,
  350. lastwritten : pref;
  351. refcount : longint;
  352. _class : pobjectdef;
  353. _mangledname : pchar;
  354. { it's a tree, but this not easy to handle }
  355. { used for inlined procs }
  356. code : pointer;
  357. { true, if the procedure is only declared }
  358. { (forward procedure) }
  359. forwarddef : boolean;
  360. { check the problems of manglednames }
  361. count : boolean;
  362. is_used : boolean;
  363. { set which contains the modified registers }
  364. {$ifdef i386}
  365. usedregisters : byte;
  366. {$endif}
  367. {$ifdef m68k}
  368. usedregisters : word;
  369. {$endif}
  370. {$ifdef alpha}
  371. usedregisters_int : longint;
  372. usedregisters_fpu : longint;
  373. {$endif}
  374. constructor init;
  375. destructor done;virtual;
  376. constructor load;
  377. procedure write;virtual;
  378. {$ifdef GDB}
  379. function cplusplusmangledname : string;
  380. function stabstring : pchar;virtual;
  381. procedure concatstabto(asmlist : paasmoutput);virtual;
  382. {$endif GDB}
  383. procedure deref;virtual;
  384. function mangledname : string;
  385. procedure setmangledname(const s : string);
  386. procedure load_references;
  387. function write_references : boolean;
  388. {$ifdef BrowserLog}
  389. procedure add_to_browserlog;
  390. {$endif BrowserLog}
  391. end;
  392. tstringtype = (st_shortstring, st_longstring, st_ansistring, st_widestring);
  393. pstringdef = ^tstringdef;
  394. tstringdef = object(tdef)
  395. string_typ : tstringtype;
  396. len : longint;
  397. constructor shortinit(l : byte);
  398. constructor shortload;
  399. constructor longinit(l : longint);
  400. constructor longload;
  401. constructor ansiinit(l : longint);
  402. constructor ansiload;
  403. constructor wideinit(l : longint);
  404. constructor wideload;
  405. function stringtypname:string;
  406. function size : longint;virtual;
  407. procedure write;virtual;
  408. {$ifdef GDB}
  409. function stabstring : pchar;virtual;
  410. procedure concatstabto(asmlist : paasmoutput);virtual;
  411. {$endif GDB}
  412. function needs_inittable : boolean;virtual;
  413. procedure write_rtti_data;virtual;
  414. function is_publishable : boolean;virtual;
  415. end;
  416. penumdef = ^tenumdef;
  417. tenumdef = object(tdef)
  418. rangenr,
  419. minval,
  420. maxval : longint;
  421. has_jumps : boolean;
  422. firstenum : penumsym;
  423. basedef : penumdef;
  424. constructor init;
  425. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  426. constructor load;
  427. destructor done;virtual;
  428. procedure write;virtual;
  429. procedure deref;virtual;
  430. procedure calcsavesize;
  431. procedure setmax(_max:longint);
  432. procedure setmin(_min:longint);
  433. function min:longint;
  434. function max:longint;
  435. function getrangecheckstring:string;
  436. procedure genrangecheck;
  437. {$ifdef GDB}
  438. function stabstring : pchar;virtual;
  439. {$endif GDB}
  440. procedure write_child_rtti_data;virtual;
  441. procedure write_rtti_data;virtual;
  442. function is_publishable : boolean;virtual;
  443. end;
  444. tsettype = (normset,smallset,varset);
  445. psetdef = ^tsetdef;
  446. tsetdef = object(tdef)
  447. setof : pdef;
  448. settype : tsettype;
  449. constructor init(s : pdef;high : longint);
  450. constructor load;
  451. procedure write;virtual;
  452. {$ifdef GDB}
  453. function stabstring : pchar;virtual;
  454. procedure concatstabto(asmlist : paasmoutput);virtual;
  455. {$endif GDB}
  456. procedure deref;virtual;
  457. function is_publishable : boolean;virtual;
  458. procedure write_rtti_data;virtual;
  459. procedure write_child_rtti_data;virtual;
  460. end;
  461. {
  462. $Log$
  463. Revision 1.24 1999-05-06 09:05:30 peter
  464. * generic write_float and str_float
  465. * fixed constant float conversions
  466. Revision 1.23 1999/04/26 18:30:02 peter
  467. * farpointerdef moved into pointerdef.is_far
  468. Revision 1.22 1999/04/26 13:31:49 peter
  469. * release storenumber,double_checksum
  470. Revision 1.21 1999/04/21 09:43:52 peter
  471. * storenumber works
  472. * fixed some typos in double_checksum
  473. + incompatible types type1 and type2 message (with storenumber)
  474. Revision 1.20 1999/04/14 09:15:00 peter
  475. * first things to store the symbol/def number in the ppu
  476. Revision 1.19 1999/04/08 15:57:52 peter
  477. + subrange checking for readln()
  478. Revision 1.18 1999/03/02 18:24:21 peter
  479. * fixed overloading of array of char
  480. Revision 1.17 1999/03/01 13:45:06 pierre
  481. + added staticppusymtable symtable type for local browsing
  482. Revision 1.16 1999/02/22 20:13:39 florian
  483. + first implementation of message keyword
  484. Revision 1.15 1999/01/20 14:18:40 pierre
  485. * bugs related to mangledname solved
  486. - linux external without name
  487. -external procs already used
  488. (added count and is_used boolean fiels in tprocvar)
  489. Revision 1.14 1999/01/12 14:25:33 peter
  490. + BrowserLog for browser.log generation
  491. + BrowserCol for browser info in TCollections
  492. * released all other UseBrowser
  493. Revision 1.13 1998/12/30 22:15:53 peter
  494. + farpointer type
  495. * absolutesym now also stores if its far
  496. Revision 1.12 1998/12/10 09:47:28 florian
  497. + basic operations with int64/qord (compiler with -dint64)
  498. + rtti of enumerations extended: names are now written
  499. Revision 1.11 1998/11/29 21:45:49 florian
  500. * problem with arrays with init tables fixed
  501. Revision 1.10 1998/11/20 15:36:00 florian
  502. * problems with rtti fixed, hope it works
  503. Revision 1.9 1998/11/10 10:09:14 peter
  504. * va_list -> array of const
  505. Revision 1.8 1998/11/09 11:44:37 peter
  506. + va_list for printf support
  507. Revision 1.7 1998/11/05 12:02:59 peter
  508. * released useansistring
  509. * removed -Sv, its now available in fpc modes
  510. Revision 1.6 1998/10/22 17:11:23 pierre
  511. + terminated the include exclude implementation for i386
  512. * enums inside records fixed
  513. Revision 1.5 1998/10/16 13:12:55 pierre
  514. * added vmt_offsets in destructors code also !!!
  515. * vmt_offset code for m68k
  516. Revision 1.4 1998/10/16 08:51:52 peter
  517. + target_os.stackalignment
  518. + stack can be aligned at 2 or 4 byte boundaries
  519. Revision 1.3 1998/10/05 21:33:30 peter
  520. * fixed 161,165,166,167,168
  521. Revision 1.2 1998/10/02 07:20:40 florian
  522. * range checking in units doesn't work if the units are smartlinked, fixed
  523. Revision 1.1 1998/09/23 12:03:57 peter
  524. * overloading fix for array of const
  525. }