2
0

symdefh.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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 : tdefstabstatus;
  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;virtual;
  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. defaultvalue : psym; { pconstsym }
  87. end;
  88. { this is only here to override the count method,
  89. which can't be used }
  90. pparalinkedlist = ^tparalinkedlist;
  91. tparalinkedlist = object(tlinkedlist)
  92. function count:longint;
  93. end;
  94. tfiletyp = (ft_text,ft_typed,ft_untyped);
  95. pfiledef = ^tfiledef;
  96. tfiledef = object(tdef)
  97. filetyp : tfiletyp;
  98. typedfiletype : ttype;
  99. constructor inittext;
  100. constructor inituntyped;
  101. constructor inittyped(const tt : ttype);
  102. constructor inittypeddef(p : pdef);
  103. constructor load;
  104. procedure write;virtual;
  105. procedure deref;virtual;
  106. function gettypename:string;virtual;
  107. procedure setsize;
  108. { debug }
  109. {$ifdef GDB}
  110. function stabstring : pchar;virtual;
  111. procedure concatstabto(asmlist : paasmoutput);virtual;
  112. {$endif GDB}
  113. end;
  114. pformaldef = ^tformaldef;
  115. tformaldef = object(tdef)
  116. constructor init;
  117. constructor load;
  118. procedure write;virtual;
  119. function gettypename:string;virtual;
  120. {$ifdef GDB}
  121. function stabstring : pchar;virtual;
  122. procedure concatstabto(asmlist : paasmoutput);virtual;
  123. {$endif GDB}
  124. end;
  125. pforwarddef = ^tforwarddef;
  126. tforwarddef = object(tdef)
  127. tosymname : string;
  128. forwardpos : tfileposinfo;
  129. constructor init(const s:string;const pos : tfileposinfo);
  130. function gettypename:string;virtual;
  131. end;
  132. perrordef = ^terrordef;
  133. terrordef = object(tdef)
  134. constructor init;
  135. function gettypename:string;virtual;
  136. { debug }
  137. {$ifdef GDB}
  138. function stabstring : pchar;virtual;
  139. {$endif GDB}
  140. end;
  141. { tpointerdef and tclassrefdef should get a common
  142. base class, but I derived tclassrefdef from tpointerdef
  143. to avoid problems with bugs (FK)
  144. }
  145. ppointerdef = ^tpointerdef;
  146. tpointerdef = object(tdef)
  147. pointertype : ttype;
  148. is_far : boolean;
  149. constructor init(const tt : ttype);
  150. constructor initfar(const tt : ttype);
  151. constructor initdef(p : pdef);
  152. constructor initfardef(p : pdef);
  153. constructor load;
  154. destructor done;virtual;
  155. procedure write;virtual;
  156. procedure deref;virtual;
  157. function gettypename:string;virtual;
  158. { debug }
  159. {$ifdef GDB}
  160. function stabstring : pchar;virtual;
  161. procedure concatstabto(asmlist : paasmoutput);virtual;
  162. {$endif GDB}
  163. end;
  164. pprocdef = ^tprocdef;
  165. pobjectdef = ^tobjectdef;
  166. tobjectdef = object(tdef)
  167. childof : pobjectdef;
  168. objname : pstring;
  169. symtable : psymtable;
  170. objectoptions : tobjectoptions;
  171. { to be able to have a variable vmt position }
  172. { and no vmt field for objects without virtuals }
  173. vmt_offset : longint;
  174. {$ifdef GDB}
  175. classglobalnb,
  176. classptrglobalnb : word;
  177. writing_stabs : boolean;
  178. {$endif GDB}
  179. constructor init(const n : string;c : pobjectdef);
  180. constructor load;
  181. destructor done;virtual;
  182. procedure write;virtual;
  183. procedure deref;virtual;
  184. function size : longint;virtual;
  185. function alignment:longint;virtual;
  186. function vmtmethodoffset(index:longint):longint;
  187. function is_publishable : boolean;virtual;
  188. function vmt_mangledname : string;
  189. function rtti_name : string;
  190. procedure check_forwards;
  191. function is_related(d : pobjectdef) : boolean;
  192. function is_class : boolean;
  193. function is_interface : boolean;
  194. function is_cppclass : boolean;
  195. function is_object : boolean;
  196. function next_free_name_index : longint;
  197. procedure insertvmt;
  198. procedure set_parent(c : pobjectdef);
  199. function searchdestructor : pprocdef;
  200. { debug }
  201. {$ifdef GDB}
  202. function stabstring : pchar;virtual;
  203. procedure set_globalnb;virtual;
  204. function classnumberstring : string;
  205. function classptrnumberstring : string;
  206. procedure concatstabto(asmlist : paasmoutput);virtual;
  207. {$endif GDB}
  208. { init/final }
  209. function needs_inittable : boolean;virtual;
  210. procedure write_init_data;virtual;
  211. procedure write_child_init_data;virtual;
  212. { rtti }
  213. function get_rtti_label : string;virtual;
  214. procedure generate_rtti;virtual;
  215. procedure write_rtti_data;virtual;
  216. procedure write_child_rtti_data;virtual;
  217. function generate_field_table : pasmlabel;
  218. end;
  219. pclassrefdef = ^tclassrefdef;
  220. tclassrefdef = object(tpointerdef)
  221. constructor init(def : pdef);
  222. constructor load;
  223. procedure write;virtual;
  224. function gettypename:string;virtual;
  225. { debug }
  226. {$ifdef GDB}
  227. function stabstring : pchar;virtual;
  228. procedure concatstabto(asmlist : paasmoutput);virtual;
  229. {$endif GDB}
  230. end;
  231. parraydef = ^tarraydef;
  232. tarraydef = object(tdef)
  233. private
  234. rangenr : longint;
  235. public
  236. lowrange,
  237. highrange : longint;
  238. elementtype,
  239. rangetype : ttype;
  240. IsVariant,
  241. IsConstructor,
  242. IsArrayOfConst : boolean;
  243. function gettypename:string;virtual;
  244. function elesize : longint;
  245. constructor init(l,h : longint;rd : pdef);
  246. constructor load;
  247. procedure write;virtual;
  248. {$ifdef GDB}
  249. function stabstring : pchar;virtual;
  250. procedure concatstabto(asmlist : paasmoutput);virtual;
  251. {$endif GDB}
  252. procedure deref;virtual;
  253. function size : longint;virtual;
  254. function alignment : longint;virtual;
  255. { generates the ranges needed by the asm instruction BOUND (i386)
  256. or CMP2 (Motorola) }
  257. procedure genrangecheck;
  258. { returns the label of the range check string }
  259. function getrangecheckstring : string;
  260. function needs_inittable : boolean;virtual;
  261. procedure write_rtti_data;virtual;
  262. procedure write_child_rtti_data;virtual;
  263. end;
  264. precorddef = ^trecorddef;
  265. trecorddef = object(tdef)
  266. symtable : psymtable;
  267. constructor init(p : psymtable);
  268. constructor load;
  269. destructor done;virtual;
  270. procedure write;virtual;
  271. procedure deref;virtual;
  272. function size:longint;virtual;
  273. function alignment : longint;virtual;
  274. function gettypename:string;virtual;
  275. { debug }
  276. {$ifdef GDB}
  277. function stabstring : pchar;virtual;
  278. procedure concatstabto(asmlist : paasmoutput);virtual;
  279. {$endif GDB}
  280. { init/final }
  281. procedure write_init_data;virtual;
  282. procedure write_child_init_data;virtual;
  283. function needs_inittable : boolean;virtual;
  284. { rtti }
  285. procedure write_rtti_data;virtual;
  286. procedure write_child_rtti_data;virtual;
  287. end;
  288. porddef = ^torddef;
  289. torddef = object(tdef)
  290. private
  291. rangenr : longint;
  292. public
  293. low,high : longint;
  294. typ : tbasetype;
  295. constructor init(t : tbasetype;v,b : longint);
  296. constructor load;
  297. procedure write;virtual;
  298. function is_publishable : boolean;virtual;
  299. function gettypename:string;virtual;
  300. procedure setsize;
  301. { generates the ranges needed by the asm instruction BOUND }
  302. { or CMP2 (Motorola) }
  303. procedure genrangecheck;
  304. function getrangecheckstring : string;
  305. { debug }
  306. {$ifdef GDB}
  307. function stabstring : pchar;virtual;
  308. {$endif GDB}
  309. { rtti }
  310. procedure write_rtti_data;virtual;
  311. end;
  312. pfloatdef = ^tfloatdef;
  313. tfloatdef = object(tdef)
  314. typ : tfloattype;
  315. constructor init(t : tfloattype);
  316. constructor load;
  317. procedure write;virtual;
  318. function gettypename:string;virtual;
  319. function is_publishable : boolean;virtual;
  320. procedure setsize;
  321. { debug }
  322. {$ifdef GDB}
  323. function stabstring : pchar;virtual;
  324. {$endif GDB}
  325. { rtti }
  326. procedure write_rtti_data;virtual;
  327. end;
  328. pabstractprocdef = ^tabstractprocdef;
  329. tabstractprocdef = object(tdef)
  330. { saves a definition to the return type }
  331. rettype : ttype;
  332. proctypeoption : tproctypeoption;
  333. proccalloptions : tproccalloptions;
  334. procoptions : tprocoptions;
  335. para : pparalinkedlist;
  336. maxparacount,
  337. minparacount : longint;
  338. symtablelevel : byte;
  339. fpu_used : byte; { how many stack fpu must be empty }
  340. constructor init;
  341. constructor load;
  342. destructor done;virtual;
  343. procedure write;virtual;
  344. procedure deref;virtual;
  345. procedure concatpara(tt:ttype;vsp : tvarspez;defval:psym);
  346. function para_size(alignsize:longint) : longint;
  347. function demangled_paras : string;
  348. function proccalloption2str : string;
  349. procedure test_if_fpu_result;
  350. { debug }
  351. {$ifdef GDB}
  352. function stabstring : pchar;virtual;
  353. procedure concatstabto(asmlist : paasmoutput);virtual;
  354. {$endif GDB}
  355. end;
  356. pprocvardef = ^tprocvardef;
  357. tprocvardef = object(tabstractprocdef)
  358. constructor init;
  359. constructor load;
  360. procedure write;virtual;
  361. function size : longint;virtual;
  362. function gettypename:string;virtual;
  363. function is_publishable : boolean;virtual;
  364. { debug }
  365. {$ifdef GDB}
  366. function stabstring : pchar;virtual;
  367. procedure concatstabto(asmlist : paasmoutput); virtual;
  368. {$endif GDB}
  369. { rtti }
  370. procedure write_child_rtti_data;virtual;
  371. procedure write_rtti_data;virtual;
  372. end;
  373. tmessageinf = record
  374. case integer of
  375. 0 : (str : pchar);
  376. 1 : (i : longint);
  377. end;
  378. tprocdef = object(tabstractprocdef)
  379. private
  380. _mangledname : pstring;
  381. public
  382. extnumber : longint;
  383. messageinf : tmessageinf;
  384. nextoverloaded : pprocdef;
  385. { where is this function defined, needed here because there
  386. is only one symbol for all overloaded functions }
  387. fileinfo : tfileposinfo;
  388. { pointer to the local symbol table }
  389. localst : psymtable;
  390. { pointer to the parameter symbol table }
  391. parast : psymtable;
  392. { symbol owning this definition }
  393. procsym : pprocsym;
  394. { browser info }
  395. lastref,
  396. defref,
  397. crossref,
  398. lastwritten : pref;
  399. refcount : longint;
  400. _class : pobjectdef;
  401. { it's a tree, but this not easy to handle }
  402. { used for inlined procs }
  403. code : pointer;
  404. { info about register variables (JM) }
  405. regvarinfo: pointer;
  406. { true, if the procedure is only declared }
  407. { (forward procedure) }
  408. forwarddef,
  409. { true if the procedure is declared in the interface }
  410. interfacedef : boolean;
  411. { true if the procedure has a forward declaration }
  412. hasforward : boolean;
  413. { check the problems of manglednames }
  414. count : boolean;
  415. is_used : boolean;
  416. { small set which contains the modified registers }
  417. {$ifdef newcg}
  418. usedregisters : tregisterset;
  419. {$else newcg}
  420. usedregisters : longint;
  421. {$endif newcg}
  422. constructor init;
  423. constructor load;
  424. destructor done;virtual;
  425. procedure write;virtual;
  426. procedure deref;virtual;
  427. function haspara:boolean;
  428. function mangledname : string;
  429. procedure setmangledname(const s : string);
  430. procedure load_references;
  431. function write_references : boolean;
  432. {$ifdef dummy}
  433. function procname: string;
  434. {$endif dummy}
  435. function cplusplusmangledname(const rn : string) : string;
  436. { debug }
  437. {$ifdef GDB}
  438. function stabstring : pchar;virtual;
  439. procedure concatstabto(asmlist : paasmoutput);virtual;
  440. {$endif GDB}
  441. { browser }
  442. {$ifdef BrowserLog}
  443. procedure add_to_browserlog;
  444. {$endif BrowserLog}
  445. end;
  446. pstringdef = ^tstringdef;
  447. tstringdef = object(tdef)
  448. string_typ : tstringtype;
  449. len : longint;
  450. constructor shortinit(l : byte);
  451. constructor shortload;
  452. constructor longinit(l : longint);
  453. constructor longload;
  454. constructor ansiinit(l : longint);
  455. constructor ansiload;
  456. constructor wideinit(l : longint);
  457. constructor wideload;
  458. function stringtypname:string;
  459. function size : longint;virtual;
  460. procedure write;virtual;
  461. function gettypename:string;virtual;
  462. function is_publishable : boolean;virtual;
  463. { debug }
  464. {$ifdef GDB}
  465. function stabstring : pchar;virtual;
  466. procedure concatstabto(asmlist : paasmoutput);virtual;
  467. {$endif GDB}
  468. { init/final }
  469. function needs_inittable : boolean;virtual;
  470. { rtti }
  471. procedure write_rtti_data;virtual;
  472. end;
  473. penumdef = ^tenumdef;
  474. tenumdef = object(tdef)
  475. rangenr,
  476. minval,
  477. maxval : longint;
  478. has_jumps : boolean;
  479. firstenum : penumsym;
  480. basedef : penumdef;
  481. constructor init;
  482. constructor init_subrange(_basedef:penumdef;_min,_max:longint);
  483. constructor load;
  484. destructor done;virtual;
  485. procedure write;virtual;
  486. procedure deref;virtual;
  487. function gettypename:string;virtual;
  488. function is_publishable : boolean;virtual;
  489. procedure calcsavesize;
  490. procedure setmax(_max:longint);
  491. procedure setmin(_min:longint);
  492. function min:longint;
  493. function max:longint;
  494. function getrangecheckstring:string;
  495. procedure genrangecheck;
  496. { debug }
  497. {$ifdef GDB}
  498. function stabstring : pchar;virtual;
  499. {$endif GDB}
  500. { rtti }
  501. procedure write_child_rtti_data;virtual;
  502. procedure write_rtti_data;virtual;
  503. end;
  504. psetdef = ^tsetdef;
  505. tsetdef = object(tdef)
  506. elementtype : ttype;
  507. settype : tsettype;
  508. constructor init(s : pdef;high : longint);
  509. constructor load;
  510. destructor done;virtual;
  511. procedure write;virtual;
  512. procedure deref;virtual;
  513. function gettypename:string;virtual;
  514. function is_publishable : boolean;virtual;
  515. { debug }
  516. {$ifdef GDB}
  517. function stabstring : pchar;virtual;
  518. procedure concatstabto(asmlist : paasmoutput);virtual;
  519. {$endif GDB}
  520. { rtti }
  521. procedure write_rtti_data;virtual;
  522. procedure write_child_rtti_data;virtual;
  523. end;
  524. {
  525. $Log$
  526. Revision 1.12 2000-10-15 07:47:52 peter
  527. * unit names and procedure names are stored mixed case
  528. Revision 1.11 2000/10/14 10:14:53 peter
  529. * moehrendorf oct 2000 rewrite
  530. Revision 1.10 2000/09/24 15:06:29 peter
  531. * use defines.inc
  532. Revision 1.9 2000/09/19 23:08:03 pierre
  533. * fixes for local class debuggging problem (merged)
  534. Revision 1.8 2000/08/21 11:27:44 pierre
  535. * fix the stabs problems
  536. Revision 1.7 2000/08/06 19:39:28 peter
  537. * default parameters working !
  538. Revision 1.6 2000/08/06 14:17:15 peter
  539. * overload fixes (merged)
  540. Revision 1.5 2000/08/03 13:17:26 jonas
  541. + allow regvars to be used inside inlined procs, which required the
  542. following changes:
  543. + load regvars in genentrycode/free them in genexitcode (cgai386)
  544. * moved all regvar related code to new regvars unit
  545. + added pregvarinfo type to hcodegen
  546. + added regvarinfo field to tprocinfo (symdef/symdefh)
  547. * deallocate the regvars of the caller in secondprocinline before
  548. inlining the called procedure and reallocate them afterwards
  549. Revision 1.4 2000/08/02 19:49:59 peter
  550. * first things for default parameters
  551. Revision 1.3 2000/07/13 12:08:27 michael
  552. + patched to 1.1.0 with former 1.09patch from peter
  553. Revision 1.2 2000/07/13 11:32:49 michael
  554. + removed logs
  555. }