symdefh.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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. tdef = object
  28. deftype : tdeftype;
  29. indexnb : longint;
  30. savesize : longint;
  31. next : pdef;
  32. owner : psymtable;
  33. sym : ptypesym; { which type the definition was generated this def }
  34. has_inittable : boolean;
  35. { adress of init informations }
  36. inittable_label : plabel;
  37. has_rtti : boolean;
  38. { address of rtti }
  39. rtti_label : plabel;
  40. nextglobal,
  41. previousglobal : pdef;
  42. {$ifdef GDB}
  43. globalnb : word;
  44. is_def_stab_written : boolean;
  45. {$endif GDB}
  46. constructor init;
  47. constructor load;
  48. destructor done;virtual;
  49. { registers enumdef inside objects or
  50. record directly in the owner symtable !! }
  51. procedure correct_owner_symtable;
  52. procedure write;virtual;
  53. procedure writename;
  54. function size:longint;virtual;
  55. {$ifdef GDB}
  56. function NumberString:string;
  57. procedure set_globalnb;
  58. function stabstring : pchar;virtual;
  59. function allstabstring : pchar;
  60. procedure concatstabto(asmlist : paasmoutput);virtual;
  61. {$endif GDB}
  62. procedure deref;virtual;
  63. { init. tables }
  64. function needs_inittable : boolean;virtual;
  65. procedure generate_inittable;
  66. function get_inittable_label : plabel;
  67. { the default implemenation calls write_rtti_data }
  68. { if init and rtti data is different these procedures }
  69. { must be overloaded }
  70. procedure write_init_data;virtual;
  71. { writes rtti of child to avoid mixup of rtti }
  72. procedure write_child_init_data;virtual;
  73. { rtti }
  74. function get_rtti_label : string;virtual;
  75. procedure generate_rtti;virtual;
  76. procedure write_rtti_data;virtual;
  77. procedure write_child_rtti_data;virtual;
  78. { returns true, if the definition can be published }
  79. function is_publishable : boolean;virtual;
  80. function is_in_current : boolean;
  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. 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. constructor init(def : pdef);
  132. constructor load;
  133. procedure write;virtual;
  134. {$ifdef GDB}
  135. function stabstring : pchar;virtual;
  136. procedure concatstabto(asmlist : paasmoutput);virtual;
  137. {$endif GDB}
  138. procedure deref;virtual;
  139. end;
  140. pfarpointerdef = ^tfarpointerdef;
  141. tfarpointerdef = object(tpointerdef)
  142. constructor init(def : pdef);
  143. constructor load;
  144. procedure write;virtual;
  145. end;
  146. pobjectdef = ^tobjectdef;
  147. tobjectdef = object(tdef)
  148. childof : pobjectdef;
  149. name : 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. end;
  194. parraydef = ^tarraydef;
  195. tarraydef = object(tdef)
  196. private
  197. rangenr : longint;
  198. public
  199. lowrange,
  200. highrange : longint;
  201. definition : pdef;
  202. rangedef : pdef;
  203. IsVariant,
  204. IsConstructor,
  205. IsArrayOfConst : boolean;
  206. function elesize : longint;
  207. constructor init(l,h : longint;rd : pdef);
  208. constructor load;
  209. procedure write;virtual;
  210. {$ifdef GDB}
  211. function stabstring : pchar;virtual;
  212. procedure concatstabto(asmlist : paasmoutput);virtual;
  213. {$endif GDB}
  214. procedure deref;virtual;
  215. function size : longint;virtual;
  216. { generates the ranges needed by the asm instruction BOUND (i386)
  217. or CMP2 (Motorola) }
  218. procedure genrangecheck;
  219. { returns the label of the range check string }
  220. function getrangecheckstring : string;
  221. function needs_inittable : boolean;virtual;
  222. procedure write_rtti_data;virtual;
  223. procedure write_child_rtti_data;virtual;
  224. end;
  225. precdef = ^trecdef;
  226. trecdef = object(tdef)
  227. symtable : psymtable;
  228. constructor init(p : psymtable);
  229. constructor load;
  230. destructor done;virtual;
  231. procedure write;virtual;
  232. {$ifdef GDB}
  233. function stabstring : pchar;virtual;
  234. procedure concatstabto(asmlist : paasmoutput);virtual;
  235. {$endif GDB}
  236. procedure deref;virtual;
  237. function needs_inittable : boolean;virtual;
  238. procedure write_rtti_data;virtual;
  239. procedure write_init_data;virtual;
  240. procedure write_child_rtti_data;virtual;
  241. procedure write_child_init_data;virtual;
  242. end;
  243. { base types }
  244. tbasetype = (uauto,uvoid,uchar,
  245. u8bit,u16bit,u32bit,
  246. s8bit,s16bit,s32bit,
  247. bool8bit,bool16bit,bool32bit { uwchar,bool1bit,bitfield},
  248. u64bit,s64bitint);
  249. porddef = ^torddef;
  250. torddef = object(tdef)
  251. low,high : longint;
  252. rangenr : longint;
  253. typ : tbasetype;
  254. {
  255. bits : byte;
  256. }
  257. constructor init(t : tbasetype;v,b : longint);
  258. constructor load;
  259. procedure write;virtual;
  260. {$ifdef GDB}
  261. function stabstring : pchar;virtual;
  262. {$endif GDB}
  263. procedure setsize;
  264. { generates the ranges needed by the asm instruction BOUND }
  265. { or CMP2 (Motorola) }
  266. procedure genrangecheck;
  267. { returns the label of the range check string }
  268. function getrangecheckstring : string;
  269. procedure write_rtti_data;virtual;
  270. function is_publishable : boolean;virtual;
  271. end;
  272. { sextreal is dependant on the cpu, s64bit is also }
  273. { dependant on the size (tp = 80bit for both) }
  274. { The EXTENDED format exists on the motorola FPU }
  275. { but it uses 96 bits instead of 80, with some }
  276. { unused bits within the number itself! Pretty }
  277. { complicated to support, so no support for the }
  278. { moment. }
  279. { s64 bit is considered as a real because all }
  280. { calculations are done by the fpu. }
  281. tfloattype = (f32bit,s32real,s64real,s80real,s64bit,f16bit);
  282. pfloatdef = ^tfloatdef;
  283. tfloatdef = object(tdef)
  284. typ : tfloattype;
  285. constructor init(t : tfloattype);
  286. constructor load;
  287. procedure write;virtual;
  288. {$ifdef GDB}
  289. function stabstring : pchar;virtual;
  290. {$endif GDB}
  291. procedure setsize;
  292. function is_publishable : boolean;virtual;
  293. procedure write_rtti_data;virtual;
  294. end;
  295. pabstractprocdef = ^tabstractprocdef;
  296. tabstractprocdef = object(tdef)
  297. { saves a definition to the return type }
  298. retdef : pdef;
  299. fpu_used : byte; { how many stack fpu must be empty }
  300. options : longint; { save the procedure options }
  301. para1 : pdefcoll;
  302. constructor init;
  303. constructor load;
  304. destructor done;virtual;
  305. procedure concatdef(p : pdef;vsp : tvarspez);
  306. procedure deref;virtual;
  307. function para_size : longint;
  308. function demangled_paras : string;
  309. {$ifdef GDB}
  310. function stabstring : pchar;virtual;
  311. procedure concatstabto(asmlist : paasmoutput);virtual;
  312. {$endif GDB}
  313. procedure test_if_fpu_result;
  314. procedure write;virtual;
  315. end;
  316. pprocvardef = ^tprocvardef;
  317. tprocvardef = object(tabstractprocdef)
  318. constructor init;
  319. constructor load;
  320. procedure write;virtual;
  321. function size : longint;virtual;
  322. {$ifdef GDB}
  323. function stabstring : pchar;virtual;
  324. procedure concatstabto(asmlist : paasmoutput); virtual;
  325. {$endif GDB}
  326. procedure write_child_rtti_data;virtual;
  327. function is_publishable : boolean;virtual;
  328. procedure write_rtti_data;virtual;
  329. end;
  330. tmessageinf = record
  331. case integer of
  332. 0 : (str : pchar);
  333. 1 : (i : longint);
  334. end;
  335. pprocdef = ^tprocdef;
  336. tprocdef = object(tabstractprocdef)
  337. extnumber : longint;
  338. messageinf : tmessageinf;
  339. nextoverloaded : pprocdef;
  340. { pointer to the local symbol table }
  341. localst : psymtable;
  342. { pointer to the parameter symbol table }
  343. parast : psymtable;
  344. { browser info }
  345. lastref,
  346. defref,
  347. lastwritten : pref;
  348. refcount : longint;
  349. _class : pobjectdef;
  350. _mangledname : pchar;
  351. { it's a tree, but this not easy to handle }
  352. { used for inlined procs }
  353. code : pointer;
  354. { true, if the procedure is only declared }
  355. { (forward procedure) }
  356. forwarddef : boolean;
  357. { check the problems of manglednames }
  358. count : boolean;
  359. is_used : boolean;
  360. { set which contains the modified registers }
  361. {$ifdef i386}
  362. usedregisters : byte;
  363. {$endif}
  364. {$ifdef m68k}
  365. usedregisters : word;
  366. {$endif}
  367. {$ifdef alpha}
  368. usedregisters_int : longint;
  369. usedregisters_fpu : longint;
  370. {$endif}
  371. constructor init;
  372. destructor done;virtual;
  373. constructor load;
  374. procedure write;virtual;
  375. {$ifdef GDB}
  376. function cplusplusmangledname : string;
  377. function stabstring : pchar;virtual;
  378. procedure concatstabto(asmlist : paasmoutput);virtual;
  379. {$endif GDB}
  380. procedure deref;virtual;
  381. function mangledname : string;
  382. procedure setmangledname(const s : string);
  383. procedure load_references;
  384. function write_references : boolean;
  385. {$ifdef BrowserLog}
  386. procedure add_to_browserlog;
  387. {$endif BrowserLog}
  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 size : longint;virtual;
  403. procedure write;virtual;
  404. {$ifdef GDB}
  405. function stabstring : pchar;virtual;
  406. procedure concatstabto(asmlist : paasmoutput);virtual;
  407. {$endif GDB}
  408. function needs_inittable : boolean;virtual;
  409. procedure write_rtti_data;virtual;
  410. function is_publishable : boolean;virtual;
  411. end;
  412. penumdef = ^tenumdef;
  413. tenumdef = object(tdef)
  414. rangenr,
  415. minval,
  416. maxval : longint;
  417. has_jumps : boolean;
  418. first : penumsym;
  419. basedef : penumdef;
  420. constructor init;
  421. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  422. constructor load;
  423. destructor done;virtual;
  424. procedure write;virtual;
  425. procedure deref;virtual;
  426. procedure calcsavesize;
  427. procedure setmax(_max:longint);
  428. procedure setmin(_min:longint);
  429. function min:longint;
  430. function max:longint;
  431. function getrangecheckstring:string;
  432. procedure genrangecheck;
  433. {$ifdef GDB}
  434. function stabstring : pchar;virtual;
  435. {$endif GDB}
  436. procedure write_child_rtti_data;virtual;
  437. procedure write_rtti_data;virtual;
  438. function is_publishable : boolean;virtual;
  439. end;
  440. tsettype = (normset,smallset,varset);
  441. psetdef = ^tsetdef;
  442. tsetdef = object(tdef)
  443. setof : pdef;
  444. settype : tsettype;
  445. constructor init(s : pdef;high : longint);
  446. constructor load;
  447. procedure write;virtual;
  448. {$ifdef GDB}
  449. function stabstring : pchar;virtual;
  450. procedure concatstabto(asmlist : paasmoutput);virtual;
  451. {$endif GDB}
  452. procedure deref;virtual;
  453. function is_publishable : boolean;virtual;
  454. procedure write_rtti_data;virtual;
  455. procedure write_child_rtti_data;virtual;
  456. end;
  457. {
  458. $Log$
  459. Revision 1.17 1999-03-01 13:45:06 pierre
  460. + added staticppusymtable symtable type for local browsing
  461. Revision 1.16 1999/02/22 20:13:39 florian
  462. + first implementation of message keyword
  463. Revision 1.15 1999/01/20 14:18:40 pierre
  464. * bugs related to mangledname solved
  465. - linux external without name
  466. -external procs already used
  467. (added count and is_used boolean fiels in tprocvar)
  468. Revision 1.14 1999/01/12 14:25:33 peter
  469. + BrowserLog for browser.log generation
  470. + BrowserCol for browser info in TCollections
  471. * released all other UseBrowser
  472. Revision 1.13 1998/12/30 22:15:53 peter
  473. + farpointer type
  474. * absolutesym now also stores if its far
  475. Revision 1.12 1998/12/10 09:47:28 florian
  476. + basic operations with int64/qord (compiler with -dint64)
  477. + rtti of enumerations extended: names are now written
  478. Revision 1.11 1998/11/29 21:45:49 florian
  479. * problem with arrays with init tables fixed
  480. Revision 1.10 1998/11/20 15:36:00 florian
  481. * problems with rtti fixed, hope it works
  482. Revision 1.9 1998/11/10 10:09:14 peter
  483. * va_list -> array of const
  484. Revision 1.8 1998/11/09 11:44:37 peter
  485. + va_list for printf support
  486. Revision 1.7 1998/11/05 12:02:59 peter
  487. * released useansistring
  488. * removed -Sv, its now available in fpc modes
  489. Revision 1.6 1998/10/22 17:11:23 pierre
  490. + terminated the include exclude implementation for i386
  491. * enums inside records fixed
  492. Revision 1.5 1998/10/16 13:12:55 pierre
  493. * added vmt_offsets in destructors code also !!!
  494. * vmt_offset code for m68k
  495. Revision 1.4 1998/10/16 08:51:52 peter
  496. + target_os.stackalignment
  497. + stack can be aligned at 2 or 4 byte boundaries
  498. Revision 1.3 1998/10/05 21:33:30 peter
  499. * fixed 161,165,166,167,168
  500. Revision 1.2 1998/10/02 07:20:40 florian
  501. * range checking in units doesn't work if the units are smartlinked, fixed
  502. Revision 1.1 1998/09/23 12:03:57 peter
  503. * overloading fix for array of const
  504. }