symdefh.inc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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. tdef = object(tsymtableentry)
  22. deftype : tdeftype;
  23. typesym : ptypesym; { which type the definition was generated this def }
  24. has_inittable : boolean;
  25. { adress of init informations }
  26. inittable_label : pasmlabel;
  27. has_rtti : boolean;
  28. { address of rtti }
  29. rtti_label : pasmlabel;
  30. nextglobal,
  31. previousglobal : pdef;
  32. {$ifdef GDB}
  33. globalnb : word;
  34. is_def_stab_written : boolean;
  35. {$endif GDB}
  36. constructor init;
  37. constructor load;
  38. destructor done;virtual;
  39. procedure deref;virtual;
  40. function typename:string;
  41. procedure write;virtual;
  42. function size:longint;virtual;
  43. function alignment:longint;virtual;
  44. function gettypename:string;virtual;
  45. function is_publishable : boolean;virtual;
  46. function is_in_current : boolean;
  47. procedure correct_owner_symtable; { registers enumdef inside objects or
  48. record directly in the owner symtable !! }
  49. { debug }
  50. {$ifdef GDB}
  51. function stabstring : pchar;virtual;
  52. procedure concatstabto(asmlist : paasmoutput);virtual;
  53. function NumberString:string;
  54. procedure set_globalnb;
  55. function allstabstring : pchar;
  56. {$endif GDB}
  57. { init. tables }
  58. function needs_inittable : boolean;virtual;
  59. procedure generate_inittable;
  60. function get_inittable_label : pasmlabel;
  61. { the default implemenation calls write_rtti_data }
  62. { if init and rtti data is different these procedures }
  63. { must be overloaded }
  64. procedure write_init_data;virtual;
  65. procedure write_child_init_data;virtual;
  66. { rtti }
  67. procedure write_rtti_name;
  68. function get_rtti_label : string;virtual;
  69. procedure generate_rtti;virtual;
  70. procedure write_rtti_data;virtual;
  71. procedure write_child_rtti_data;virtual;
  72. function is_intregable : boolean;
  73. function is_fpuregable : boolean;
  74. private
  75. savesize : longint;
  76. end;
  77. targconvtyp = (act_convertable,act_equal,act_exact);
  78. tvarspez = (vs_value,vs_const,vs_var,vs_out);
  79. pparaitem = ^tparaitem;
  80. tparaitem = object(tlinkedlist_item)
  81. paratype : ttype;
  82. paratyp : tvarspez;
  83. argconvtyp : targconvtyp;
  84. convertlevel : byte;
  85. register : tregister;
  86. end;
  87. tfiletyp = (ft_text,ft_typed,ft_untyped);
  88. pfiledef = ^tfiledef;
  89. tfiledef = object(tdef)
  90. filetyp : tfiletyp;
  91. typedfiletype : ttype;
  92. constructor inittext;
  93. constructor inituntyped;
  94. constructor inittyped(const tt : ttype);
  95. constructor inittypeddef(p : pdef);
  96. constructor load;
  97. procedure write;virtual;
  98. procedure deref;virtual;
  99. function gettypename:string;virtual;
  100. procedure setsize;
  101. { debug }
  102. {$ifdef GDB}
  103. function stabstring : pchar;virtual;
  104. procedure concatstabto(asmlist : paasmoutput);virtual;
  105. {$endif GDB}
  106. end;
  107. pformaldef = ^tformaldef;
  108. tformaldef = object(tdef)
  109. constructor init;
  110. constructor load;
  111. procedure write;virtual;
  112. function gettypename:string;virtual;
  113. {$ifdef GDB}
  114. function stabstring : pchar;virtual;
  115. procedure concatstabto(asmlist : paasmoutput);virtual;
  116. {$endif GDB}
  117. end;
  118. pforwarddef = ^tforwarddef;
  119. tforwarddef = object(tdef)
  120. tosymname : string;
  121. forwardpos : tfileposinfo;
  122. constructor init(const s:string;const pos : tfileposinfo);
  123. function gettypename:string;virtual;
  124. end;
  125. perrordef = ^terrordef;
  126. terrordef = object(tdef)
  127. constructor init;
  128. function gettypename:string;virtual;
  129. { debug }
  130. {$ifdef GDB}
  131. function stabstring : pchar;virtual;
  132. {$endif GDB}
  133. end;
  134. { tpointerdef and tclassrefdef should get a common
  135. base class, but I derived tclassrefdef from tpointerdef
  136. to avoid problems with bugs (FK)
  137. }
  138. ppointerdef = ^tpointerdef;
  139. tpointerdef = object(tdef)
  140. pointertype : ttype;
  141. is_far : boolean;
  142. constructor init(const tt : ttype);
  143. constructor initfar(const tt : ttype);
  144. constructor initdef(p : pdef);
  145. constructor initfardef(p : pdef);
  146. constructor load;
  147. destructor done;virtual;
  148. procedure write;virtual;
  149. procedure deref;virtual;
  150. function gettypename:string;virtual;
  151. { debug }
  152. {$ifdef GDB}
  153. function stabstring : pchar;virtual;
  154. procedure concatstabto(asmlist : paasmoutput);virtual;
  155. {$endif GDB}
  156. end;
  157. pprocdef = ^tprocdef;
  158. pobjectdef = ^tobjectdef;
  159. tobjectdef = object(tdef)
  160. childof : pobjectdef;
  161. objname : pstring;
  162. symtable : psymtable;
  163. objectoptions : tobjectoptions;
  164. { to be able to have a variable vmt position }
  165. { and no vmt field for objects without virtuals }
  166. vmt_offset : longint;
  167. constructor init(const n : string;c : pobjectdef);
  168. constructor load;
  169. destructor done;virtual;
  170. procedure write;virtual;
  171. procedure deref;virtual;
  172. function size : longint;virtual;
  173. function alignment:longint;virtual;
  174. function vmtmethodoffset(index:longint):longint;
  175. function is_publishable : boolean;virtual;
  176. function vmt_mangledname : string;
  177. function rtti_name : string;
  178. procedure check_forwards;
  179. function is_related(d : pobjectdef) : boolean;
  180. function is_class : boolean;
  181. function is_interface : boolean;
  182. function is_cppclass : boolean;
  183. function is_object : boolean;
  184. function next_free_name_index : longint;
  185. procedure insertvmt;
  186. procedure set_parent(c : pobjectdef);
  187. function searchdestructor : pprocdef;
  188. { debug }
  189. {$ifdef GDB}
  190. function stabstring : pchar;virtual;
  191. {$endif GDB}
  192. { init/final }
  193. function needs_inittable : boolean;virtual;
  194. procedure write_init_data;virtual;
  195. procedure write_child_init_data;virtual;
  196. { rtti }
  197. function get_rtti_label : string;virtual;
  198. procedure generate_rtti;virtual;
  199. procedure write_rtti_data;virtual;
  200. procedure write_child_rtti_data;virtual;
  201. function generate_field_table : pasmlabel;
  202. end;
  203. pclassrefdef = ^tclassrefdef;
  204. tclassrefdef = object(tpointerdef)
  205. constructor init(def : pdef);
  206. constructor load;
  207. procedure write;virtual;
  208. function gettypename:string;virtual;
  209. { debug }
  210. {$ifdef GDB}
  211. function stabstring : pchar;virtual;
  212. procedure concatstabto(asmlist : paasmoutput);virtual;
  213. {$endif GDB}
  214. end;
  215. parraydef = ^tarraydef;
  216. tarraydef = object(tdef)
  217. private
  218. rangenr : longint;
  219. public
  220. lowrange,
  221. highrange : longint;
  222. elementtype,
  223. rangetype : ttype;
  224. IsVariant,
  225. IsConstructor,
  226. IsArrayOfConst : boolean;
  227. function gettypename:string;virtual;
  228. function elesize : longint;
  229. constructor init(l,h : longint;rd : pdef);
  230. constructor load;
  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 size : longint;virtual;
  238. function alignment : longint;virtual;
  239. { generates the ranges needed by the asm instruction BOUND (i386)
  240. or CMP2 (Motorola) }
  241. procedure genrangecheck;
  242. { returns the label of the range check string }
  243. function getrangecheckstring : string;
  244. function needs_inittable : boolean;virtual;
  245. procedure write_rtti_data;virtual;
  246. procedure write_child_rtti_data;virtual;
  247. end;
  248. precorddef = ^trecorddef;
  249. trecorddef = object(tdef)
  250. symtable : psymtable;
  251. constructor init(p : psymtable);
  252. constructor load;
  253. destructor done;virtual;
  254. procedure write;virtual;
  255. procedure deref;virtual;
  256. function size:longint;virtual;
  257. function alignment : longint;virtual;
  258. function gettypename:string;virtual;
  259. { debug }
  260. {$ifdef GDB}
  261. function stabstring : pchar;virtual;
  262. procedure concatstabto(asmlist : paasmoutput);virtual;
  263. {$endif GDB}
  264. { init/final }
  265. procedure write_init_data;virtual;
  266. procedure write_child_init_data;virtual;
  267. function needs_inittable : boolean;virtual;
  268. { rtti }
  269. procedure write_rtti_data;virtual;
  270. procedure write_child_rtti_data;virtual;
  271. end;
  272. porddef = ^torddef;
  273. torddef = object(tdef)
  274. private
  275. rangenr : longint;
  276. public
  277. low,high : longint;
  278. typ : tbasetype;
  279. constructor init(t : tbasetype;v,b : longint);
  280. constructor load;
  281. procedure write;virtual;
  282. function is_publishable : boolean;virtual;
  283. function gettypename:string;virtual;
  284. procedure setsize;
  285. { generates the ranges needed by the asm instruction BOUND }
  286. { or CMP2 (Motorola) }
  287. procedure genrangecheck;
  288. function getrangecheckstring : string;
  289. { debug }
  290. {$ifdef GDB}
  291. function stabstring : pchar;virtual;
  292. {$endif GDB}
  293. { rtti }
  294. procedure write_rtti_data;virtual;
  295. end;
  296. pfloatdef = ^tfloatdef;
  297. tfloatdef = object(tdef)
  298. typ : tfloattype;
  299. constructor init(t : tfloattype);
  300. constructor load;
  301. procedure write;virtual;
  302. function gettypename:string;virtual;
  303. function is_publishable : boolean;virtual;
  304. procedure setsize;
  305. { debug }
  306. {$ifdef GDB}
  307. function stabstring : pchar;virtual;
  308. {$endif GDB}
  309. { rtti }
  310. procedure write_rtti_data;virtual;
  311. end;
  312. pabstractprocdef = ^tabstractprocdef;
  313. tabstractprocdef = object(tdef)
  314. { saves a definition to the return type }
  315. rettype : ttype;
  316. proctypeoption : tproctypeoption;
  317. proccalloptions : tproccalloptions;
  318. procoptions : tprocoptions;
  319. para : plinkedlist;
  320. symtablelevel : byte;
  321. fpu_used : byte; { how many stack fpu must be empty }
  322. constructor init;
  323. constructor load;
  324. destructor done;virtual;
  325. procedure write;virtual;
  326. procedure deref;virtual;
  327. procedure concatpara(tt:ttype;vsp : tvarspez);
  328. function para_size(alignsize:longint) : longint;
  329. function demangled_paras : string;
  330. function proccalloption2str : string;
  331. procedure test_if_fpu_result;
  332. { debug }
  333. {$ifdef GDB}
  334. function stabstring : pchar;virtual;
  335. procedure concatstabto(asmlist : paasmoutput);virtual;
  336. {$endif GDB}
  337. end;
  338. pprocvardef = ^tprocvardef;
  339. tprocvardef = object(tabstractprocdef)
  340. constructor init;
  341. constructor load;
  342. procedure write;virtual;
  343. function size : longint;virtual;
  344. function gettypename:string;virtual;
  345. function is_publishable : boolean;virtual;
  346. { debug }
  347. {$ifdef GDB}
  348. function stabstring : pchar;virtual;
  349. procedure concatstabto(asmlist : paasmoutput); virtual;
  350. {$endif GDB}
  351. { rtti }
  352. procedure write_child_rtti_data;virtual;
  353. procedure write_rtti_data;virtual;
  354. end;
  355. tmessageinf = record
  356. case integer of
  357. 0 : (str : pchar);
  358. 1 : (i : longint);
  359. end;
  360. tprocdef = object(tabstractprocdef)
  361. private
  362. _mangledname : pchar;
  363. public
  364. extnumber : longint;
  365. messageinf : tmessageinf;
  366. nextoverloaded : pprocdef;
  367. { where is this function defined, needed here because there
  368. is only one symbol for all overloaded functions }
  369. fileinfo : tfileposinfo;
  370. { pointer to the local symbol table }
  371. localst : psymtable;
  372. { pointer to the parameter symbol table }
  373. parast : psymtable;
  374. { symbol owning this definition }
  375. procsym : pprocsym;
  376. { browser info }
  377. lastref,
  378. defref,
  379. crossref,
  380. lastwritten : pref;
  381. refcount : longint;
  382. _class : pobjectdef;
  383. { it's a tree, but this not easy to handle }
  384. { used for inlined procs }
  385. code : pointer;
  386. { true, if the procedure is only declared }
  387. { (forward procedure) }
  388. forwarddef,
  389. { true if the procedure is declared in the interface }
  390. interfacedef : boolean;
  391. { check the problems of manglednames }
  392. count : boolean;
  393. is_used : boolean;
  394. { small set which contains the modified registers }
  395. {$ifdef newcg}
  396. usedregisters : tregisterset;
  397. {$else newcg}
  398. usedregisters : longint;
  399. {$endif newcg}
  400. constructor init;
  401. constructor load;
  402. destructor done;virtual;
  403. procedure write;virtual;
  404. procedure deref;virtual;
  405. function haspara:boolean;
  406. function mangledname : string;
  407. procedure setmangledname(const s : string);
  408. procedure load_references;
  409. function write_references : boolean;
  410. function procname: string;
  411. { debug }
  412. {$ifdef GDB}
  413. function cplusplusmangledname : string;
  414. function stabstring : pchar;virtual;
  415. procedure concatstabto(asmlist : paasmoutput);virtual;
  416. {$endif GDB}
  417. { browser }
  418. {$ifdef BrowserLog}
  419. procedure add_to_browserlog;
  420. {$endif BrowserLog}
  421. end;
  422. pstringdef = ^tstringdef;
  423. tstringdef = object(tdef)
  424. string_typ : tstringtype;
  425. len : longint;
  426. constructor shortinit(l : byte);
  427. constructor shortload;
  428. constructor longinit(l : longint);
  429. constructor longload;
  430. constructor ansiinit(l : longint);
  431. constructor ansiload;
  432. constructor wideinit(l : longint);
  433. constructor wideload;
  434. function stringtypname:string;
  435. function size : longint;virtual;
  436. procedure write;virtual;
  437. function gettypename:string;virtual;
  438. function is_publishable : boolean;virtual;
  439. { debug }
  440. {$ifdef GDB}
  441. function stabstring : pchar;virtual;
  442. procedure concatstabto(asmlist : paasmoutput);virtual;
  443. {$endif GDB}
  444. { init/final }
  445. function needs_inittable : boolean;virtual;
  446. { rtti }
  447. procedure write_rtti_data;virtual;
  448. end;
  449. penumdef = ^tenumdef;
  450. tenumdef = object(tdef)
  451. rangenr,
  452. minval,
  453. maxval : longint;
  454. has_jumps : boolean;
  455. firstenum : penumsym;
  456. basedef : penumdef;
  457. constructor init;
  458. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  459. constructor load;
  460. destructor done;virtual;
  461. procedure write;virtual;
  462. procedure deref;virtual;
  463. function gettypename:string;virtual;
  464. function is_publishable : boolean;virtual;
  465. procedure calcsavesize;
  466. procedure setmax(_max:longint);
  467. procedure setmin(_min:longint);
  468. function min:longint;
  469. function max:longint;
  470. function getrangecheckstring:string;
  471. procedure genrangecheck;
  472. { debug }
  473. {$ifdef GDB}
  474. function stabstring : pchar;virtual;
  475. {$endif GDB}
  476. { rtti }
  477. procedure write_child_rtti_data;virtual;
  478. procedure write_rtti_data;virtual;
  479. end;
  480. psetdef = ^tsetdef;
  481. tsetdef = object(tdef)
  482. elementtype : ttype;
  483. settype : tsettype;
  484. constructor init(s : pdef;high : longint);
  485. constructor load;
  486. destructor done;virtual;
  487. procedure write;virtual;
  488. procedure deref;virtual;
  489. function gettypename:string;virtual;
  490. function is_publishable : boolean;virtual;
  491. { debug }
  492. {$ifdef GDB}
  493. function stabstring : pchar;virtual;
  494. procedure concatstabto(asmlist : paasmoutput);virtual;
  495. {$endif GDB}
  496. { rtti }
  497. procedure write_rtti_data;virtual;
  498. procedure write_child_rtti_data;virtual;
  499. end;
  500. {
  501. $Log$
  502. Revision 1.3 2000-07-13 12:08:27 michael
  503. + patched to 1.1.0 with former 1.09patch from peter
  504. Revision 1.2 2000/07/13 11:32:49 michael
  505. + removed logs
  506. }