nobj.pas 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Routines for the code generation of data structures
  5. like VMT, Messages, VTables, Interfaces descs
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit nobj;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. cutils,cclasses,
  24. symdef,aasm;
  25. type
  26. pprocdeftree = ^tprocdeftree;
  27. tprocdeftree = record
  28. data : tprocdef;
  29. nl : tasmlabel;
  30. l,r : pprocdeftree;
  31. end;
  32. pprocdefcoll = ^tprocdefcoll;
  33. tprocdefcoll = record
  34. data : tprocdef;
  35. hidden : boolean;
  36. next : pprocdefcoll;
  37. end;
  38. psymcoll = ^tsymcoll;
  39. tsymcoll = record
  40. name : pstring;
  41. data : pprocdefcoll;
  42. next : psymcoll;
  43. end;
  44. tclassheader=class
  45. private
  46. _Class : tobjectdef;
  47. count : integer;
  48. private
  49. { message tables }
  50. root : pprocdeftree;
  51. procedure disposeprocdeftree(p : pprocdeftree);
  52. procedure insertmsgint(p : tnamedindexitem;arg:pointer);
  53. procedure insertmsgstr(p : tnamedindexitem;arg:pointer);
  54. procedure insertint(p : pprocdeftree;var at : pprocdeftree);
  55. procedure insertstr(p : pprocdeftree;var at : pprocdeftree);
  56. procedure writenames(p : pprocdeftree);
  57. procedure writeintentry(p : pprocdeftree);
  58. procedure writestrentry(p : pprocdeftree);
  59. {$ifdef WITHDMT}
  60. private
  61. { dmt }
  62. procedure insertdmtentry(p : tnamedindexitem;arg:pointer);
  63. procedure writedmtindexentry(p : pprocdeftree);
  64. procedure writedmtaddressentry(p : pprocdeftree);
  65. {$endif}
  66. private
  67. { published methods }
  68. procedure do_count(p : tnamedindexitem;arg:pointer);
  69. procedure genpubmethodtableentry(p : tnamedindexitem;arg:pointer);
  70. private
  71. { vmt }
  72. wurzel : psymcoll;
  73. nextvirtnumber : integer;
  74. has_constructor,
  75. has_virtual_method : boolean;
  76. procedure eachsym(sym : tnamedindexitem;arg:pointer);
  77. procedure disposevmttree;
  78. procedure writevirtualmethods(List:TAAsmoutput);
  79. private
  80. { interface tables }
  81. function gintfgetvtbllabelname(intfindex: integer): string;
  82. procedure gintfcreatevtbl(intfindex: integer; rawdata,rawcode: TAAsmoutput);
  83. procedure gintfgenentry(intfindex, contintfindex: integer; rawdata: TAAsmoutput);
  84. procedure gintfoptimizevtbls(implvtbl : plongint);
  85. procedure gintfwritedata;
  86. function gintfgetcprocdef(proc: tprocdef;const name: string): tprocdef;
  87. procedure gintfdoonintf(intf: tobjectdef; intfindex: longint);
  88. procedure gintfwalkdowninterface(intf: tobjectdef; intfindex: longint);
  89. protected
  90. procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);virtual;abstract;
  91. public
  92. constructor create(c:tobjectdef);
  93. destructor destroy;override;
  94. { generates the message tables for a class }
  95. function genstrmsgtab : tasmlabel;
  96. function genintmsgtab : tasmlabel;
  97. function genpublishedmethodstable : tasmlabel;
  98. { generates a VMT entries }
  99. procedure genvmt;
  100. {$ifdef WITHDMT}
  101. { generates a DMT for _class }
  102. function gendmt : tasmlabel;
  103. {$endif WITHDMT}
  104. { interfaces }
  105. function genintftable: tasmlabel;
  106. { write the VMT to datasegment }
  107. procedure writevmt;
  108. procedure writeinterfaceids;
  109. end;
  110. tclassheaderclass=class of tclassheader;
  111. var
  112. cclassheader : tclassheaderclass;
  113. implementation
  114. uses
  115. {$ifdef delphi}
  116. sysutils,
  117. {$else}
  118. strings,
  119. {$endif}
  120. globtype,globals,verbose,
  121. symtable,symconst,symtype,symsym,types,
  122. {$ifdef GDB}
  123. gdb,
  124. {$endif GDB}
  125. cpuinfo
  126. ;
  127. {*****************************************************************************
  128. TClassHeader
  129. *****************************************************************************}
  130. constructor tclassheader.create(c:tobjectdef);
  131. begin
  132. inherited Create;
  133. _Class:=c;
  134. end;
  135. destructor tclassheader.destroy;
  136. begin
  137. disposevmttree;
  138. end;
  139. {**************************************
  140. Message Tables
  141. **************************************}
  142. procedure tclassheader.disposeprocdeftree(p : pprocdeftree);
  143. begin
  144. if assigned(p^.l) then
  145. disposeprocdeftree(p^.l);
  146. if assigned(p^.r) then
  147. disposeprocdeftree(p^.r);
  148. dispose(p);
  149. end;
  150. procedure tclassheader.insertint(p : pprocdeftree;var at : pprocdeftree);
  151. begin
  152. if at=nil then
  153. begin
  154. at:=p;
  155. inc(count);
  156. end
  157. else
  158. begin
  159. if p^.data.messageinf.i<at^.data.messageinf.i then
  160. insertint(p,at^.l)
  161. else if p^.data.messageinf.i>at^.data.messageinf.i then
  162. insertint(p,at^.r)
  163. else
  164. Message1(parser_e_duplicate_message_label,tostr(p^.data.messageinf.i));
  165. end;
  166. end;
  167. procedure tclassheader.insertstr(p : pprocdeftree;var at : pprocdeftree);
  168. var
  169. i : integer;
  170. begin
  171. if at=nil then
  172. begin
  173. at:=p;
  174. inc(count);
  175. end
  176. else
  177. begin
  178. i:=strcomp(p^.data.messageinf.str,at^.data.messageinf.str);
  179. if i<0 then
  180. insertstr(p,at^.l)
  181. else if i>0 then
  182. insertstr(p,at^.r)
  183. else
  184. Message1(parser_e_duplicate_message_label,strpas(p^.data.messageinf.str));
  185. end;
  186. end;
  187. procedure tclassheader.insertmsgint(p : tnamedindexitem;arg:pointer);
  188. var
  189. hp : pprocdeflist;
  190. pt : pprocdeftree;
  191. begin
  192. if tsym(p).typ=procsym then
  193. begin
  194. hp:=tprocsym(p).defs;
  195. while assigned(hp) do
  196. begin
  197. if (po_msgint in hp^.def.procoptions) then
  198. begin
  199. new(pt);
  200. pt^.data:=hp^.def;
  201. pt^.l:=nil;
  202. pt^.r:=nil;
  203. insertint(pt,root);
  204. end;
  205. hp:=hp^.next;
  206. end;
  207. end;
  208. end;
  209. procedure tclassheader.insertmsgstr(p : tnamedindexitem;arg:pointer);
  210. var
  211. hp : pprocdeflist;
  212. pt : pprocdeftree;
  213. begin
  214. if tsym(p).typ=procsym then
  215. begin
  216. hp:=tprocsym(p).defs;
  217. while assigned(hp) do
  218. begin
  219. if (po_msgstr in hp^.def.procoptions) then
  220. begin
  221. new(pt);
  222. pt^.data:=hp^.def;
  223. pt^.l:=nil;
  224. pt^.r:=nil;
  225. insertstr(pt,root);
  226. end;
  227. hp:=hp^.next;
  228. end;
  229. end;
  230. end;
  231. procedure tclassheader.writenames(p : pprocdeftree);
  232. begin
  233. getdatalabel(p^.nl);
  234. if assigned(p^.l) then
  235. writenames(p^.l);
  236. dataSegment.concat(Tai_label.Create(p^.nl));
  237. dataSegment.concat(Tai_const.Create_8bit(strlen(p^.data.messageinf.str)));
  238. dataSegment.concat(Tai_string.Create_pchar(p^.data.messageinf.str));
  239. if assigned(p^.r) then
  240. writenames(p^.r);
  241. end;
  242. procedure tclassheader.writestrentry(p : pprocdeftree);
  243. begin
  244. if assigned(p^.l) then
  245. writestrentry(p^.l);
  246. { write name label }
  247. dataSegment.concat(Tai_const_symbol.Create(p^.nl));
  248. dataSegment.concat(Tai_const_symbol.Createname(p^.data.mangledname));
  249. if assigned(p^.r) then
  250. writestrentry(p^.r);
  251. end;
  252. function tclassheader.genstrmsgtab : tasmlabel;
  253. var
  254. r : tasmlabel;
  255. begin
  256. root:=nil;
  257. count:=0;
  258. { insert all message handlers into a tree, sorted by name }
  259. _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}insertmsgstr,nil);
  260. { write all names }
  261. if assigned(root) then
  262. writenames(root);
  263. { now start writing of the message string table }
  264. getdatalabel(r);
  265. dataSegment.concat(Tai_label.Create(r));
  266. genstrmsgtab:=r;
  267. dataSegment.concat(Tai_const.Create_32bit(count));
  268. if assigned(root) then
  269. begin
  270. writestrentry(root);
  271. disposeprocdeftree(root);
  272. end;
  273. end;
  274. procedure tclassheader.writeintentry(p : pprocdeftree);
  275. begin
  276. if assigned(p^.l) then
  277. writeintentry(p^.l);
  278. { write name label }
  279. dataSegment.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
  280. dataSegment.concat(Tai_const_symbol.Createname(p^.data.mangledname));
  281. if assigned(p^.r) then
  282. writeintentry(p^.r);
  283. end;
  284. function tclassheader.genintmsgtab : tasmlabel;
  285. var
  286. r : tasmlabel;
  287. begin
  288. root:=nil;
  289. count:=0;
  290. { insert all message handlers into a tree, sorted by name }
  291. _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}insertmsgint,nil);
  292. { now start writing of the message string table }
  293. getdatalabel(r);
  294. dataSegment.concat(Tai_label.Create(r));
  295. genintmsgtab:=r;
  296. dataSegment.concat(Tai_const.Create_32bit(count));
  297. if assigned(root) then
  298. begin
  299. writeintentry(root);
  300. disposeprocdeftree(root);
  301. end;
  302. end;
  303. {$ifdef WITHDMT}
  304. {**************************************
  305. DMT
  306. **************************************}
  307. procedure tclassheader.insertdmtentry(p : tnamedindexitem;arg:pointer);
  308. var
  309. hp : tprocdef;
  310. pt : pprocdeftree;
  311. begin
  312. if tsym(p).typ=procsym then
  313. begin
  314. hp:=tprocsym(p).definition;
  315. while assigned(hp) do
  316. begin
  317. if (po_msgint in hp.procoptions) then
  318. begin
  319. new(pt);
  320. pt^.p:=hp;
  321. pt^.l:=nil;
  322. pt^.r:=nil;
  323. insertint(pt,root);
  324. end;
  325. hp:=hp.nextoverloaded;
  326. end;
  327. end;
  328. end;
  329. procedure tclassheader.writedmtindexentry(p : pprocdeftree);
  330. begin
  331. if assigned(p^.l) then
  332. writedmtindexentry(p^.l);
  333. dataSegment.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
  334. if assigned(p^.r) then
  335. writedmtindexentry(p^.r);
  336. end;
  337. procedure tclassheader.writedmtaddressentry(p : pprocdeftree);
  338. begin
  339. if assigned(p^.l) then
  340. writedmtaddressentry(p^.l);
  341. dataSegment.concat(Tai_const_symbol.Createname(p^.data.mangledname));
  342. if assigned(p^.r) then
  343. writedmtaddressentry(p^.r);
  344. end;
  345. function tclassheader.gendmt : tasmlabel;
  346. var
  347. r : tasmlabel;
  348. begin
  349. root:=nil;
  350. count:=0;
  351. gendmt:=nil;
  352. { insert all message handlers into a tree, sorted by number }
  353. _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}insertdmtentry);
  354. if count>0 then
  355. begin
  356. getdatalabel(r);
  357. gendmt:=r;
  358. dataSegment.concat(Tai_label.Create(r));
  359. { entries for caching }
  360. dataSegment.concat(Tai_const.Create_32bit(0));
  361. dataSegment.concat(Tai_const.Create_32bit(0));
  362. dataSegment.concat(Tai_const.Create_32bit(count));
  363. if assigned(root) then
  364. begin
  365. writedmtindexentry(root);
  366. writedmtaddressentry(root);
  367. disposeprocdeftree(root);
  368. end;
  369. end;
  370. end;
  371. {$endif WITHDMT}
  372. {**************************************
  373. Published Methods
  374. **************************************}
  375. procedure tclassheader.do_count(p : tnamedindexitem;arg:pointer);
  376. begin
  377. if (tsym(p).typ=procsym) and (sp_published in tsym(p).symoptions) then
  378. inc(count);
  379. end;
  380. procedure tclassheader.genpubmethodtableentry(p : tnamedindexitem;arg:pointer);
  381. var
  382. hp : tprocdef;
  383. l : tasmlabel;
  384. begin
  385. if (tsym(p).typ=procsym) and (sp_published in tsym(p).symoptions) then
  386. begin
  387. if assigned(tprocsym(p).defs^.next) then
  388. internalerror(1209992);
  389. hp:=tprocsym(p).defs^.def;
  390. getdatalabel(l);
  391. Consts.concat(Tai_label.Create(l));
  392. Consts.concat(Tai_const.Create_8bit(length(p.name)));
  393. Consts.concat(Tai_string.Create(p.name));
  394. dataSegment.concat(Tai_const_symbol.Create(l));
  395. dataSegment.concat(Tai_const_symbol.Createname(hp.mangledname));
  396. end;
  397. end;
  398. function tclassheader.genpublishedmethodstable : tasmlabel;
  399. var
  400. l : tasmlabel;
  401. begin
  402. count:=0;
  403. _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}do_count,nil);
  404. if count>0 then
  405. begin
  406. getdatalabel(l);
  407. dataSegment.concat(Tai_label.Create(l));
  408. dataSegment.concat(Tai_const.Create_32bit(count));
  409. _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}genpubmethodtableentry,nil);
  410. genpublishedmethodstable:=l;
  411. end
  412. else
  413. genpublishedmethodstable:=nil;
  414. end;
  415. {**************************************
  416. VMT
  417. **************************************}
  418. procedure tclassheader.eachsym(sym : tnamedindexitem;arg:pointer);
  419. var
  420. procdefcoll : pprocdefcoll;
  421. hp : pprocdeflist;
  422. symcoll : psymcoll;
  423. _name : string;
  424. procedure newdefentry(pd:tprocdef);
  425. begin
  426. new(procdefcoll);
  427. procdefcoll^.data:=pd;
  428. procdefcoll^.hidden:=false;
  429. procdefcoll^.next:=symcoll^.data;
  430. symcoll^.data:=procdefcoll;
  431. { if it's a virtual method }
  432. if (po_virtualmethod in pd.procoptions) then
  433. begin
  434. { then it gets a number ... }
  435. pd.extnumber:=nextvirtnumber;
  436. { and we inc the number }
  437. inc(nextvirtnumber);
  438. has_virtual_method:=true;
  439. end;
  440. if (pd.proctypeoption=potype_constructor) then
  441. has_constructor:=true;
  442. { check, if a method should be overridden }
  443. if (pd._class=_class) and
  444. (po_overridingmethod in pd.procoptions) then
  445. MessagePos1(pd.fileinfo,parser_e_nothing_to_be_overridden,pd.fullprocname);
  446. end;
  447. { creates a new entry in the procsym list }
  448. procedure newentry;
  449. begin
  450. { if not, generate a new symbol item }
  451. new(symcoll);
  452. symcoll^.name:=stringdup(sym.name);
  453. symcoll^.next:=wurzel;
  454. symcoll^.data:=nil;
  455. wurzel:=symcoll;
  456. { inserts all definitions }
  457. hp:=tprocsym(sym).defs;
  458. while assigned(hp) do
  459. begin
  460. newdefentry(hp^.def);
  461. hp:=hp^.next;
  462. end;
  463. end;
  464. label
  465. handlenextdef;
  466. var
  467. pd : tprocdef;
  468. pdoverload : boolean;
  469. begin
  470. { put only sub routines into the VMT }
  471. if tsym(sym).typ=procsym then
  472. begin
  473. { check the current list of symbols }
  474. _name:=sym.name;
  475. symcoll:=wurzel;
  476. while assigned(symcoll) do
  477. begin
  478. { does the symbol already exist in the list ? }
  479. if _name=symcoll^.name^ then
  480. begin
  481. { walk through all defs of the symbol }
  482. hp:=tprocsym(sym).defs;
  483. while assigned(hp) do
  484. begin
  485. pd:=hp^.def;
  486. if pd.procsym=sym then
  487. begin
  488. pdoverload:=(po_overload in pd.procoptions);
  489. { compare with all stored definitions }
  490. procdefcoll:=symcoll^.data;
  491. while assigned(procdefcoll) do
  492. begin
  493. { compare only if the definition is not hidden }
  494. if not procdefcoll^.hidden then
  495. begin
  496. { check if one of the two methods has virtual }
  497. if (po_virtualmethod in procdefcoll^.data.procoptions) or
  498. (po_virtualmethod in pd.procoptions) then
  499. begin
  500. { if the current definition has no virtual then hide the
  501. old virtual if the new definition has the same arguments or
  502. has no overload directive }
  503. if not(po_virtualmethod in pd.procoptions) then
  504. begin
  505. if (not pdoverload or
  506. equal_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const)) and
  507. (tstoredsym(procdefcoll^.data.procsym).is_visible_for_object(pd._class)) then
  508. begin
  509. procdefcoll^.hidden:=true;
  510. if _class=pd._class then
  511. MessagePos1(pd.fileinfo,parser_w_should_use_override,pd.fullprocname);
  512. end;
  513. end
  514. { if both are virtual we check the header }
  515. else if (po_virtualmethod in pd.procoptions) and
  516. (po_virtualmethod in procdefcoll^.data.procoptions) then
  517. begin
  518. { new one has not override }
  519. if is_class(_class) and
  520. not(po_overridingmethod in pd.procoptions) then
  521. begin
  522. { we start a new virtual tree, hide the old }
  523. if (not pdoverload or
  524. equal_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const)) and
  525. (tstoredsym(procdefcoll^.data.procsym).is_visible_for_object(pd._class)) then
  526. begin
  527. procdefcoll^.hidden:=true;
  528. if _class=pd._class then
  529. MessagePos1(pd.fileinfo,parser_w_should_use_override,pd.fullprocname);
  530. end;
  531. end
  532. { check if the method to override is visible }
  533. else if (po_overridingmethod in pd.procoptions) and
  534. (not tstoredsym(procdefcoll^.data.procsym).is_visible_for_object(pd._class)) then
  535. begin
  536. { do nothing, the error will follow when adding the entry }
  537. end
  538. { same parameters }
  539. else if (equal_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const)) then
  540. begin
  541. { overload is inherited }
  542. if (po_overload in procdefcoll^.data.procoptions) then
  543. include(pd.procoptions,po_overload);
  544. { the flags have to match except abstract and override }
  545. { only if both are virtual !! }
  546. if (procdefcoll^.data.proccalloption<>pd.proccalloption) or
  547. (procdefcoll^.data.proctypeoption<>pd.proctypeoption) or
  548. ((procdefcoll^.data.procoptions-
  549. [po_abstractmethod,po_overridingmethod,po_assembler,po_overload])<>
  550. (pd.procoptions-[po_abstractmethod,po_overridingmethod,po_assembler,po_overload])) then
  551. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,pd.fullprocname);
  552. { error, if the return types aren't equal }
  553. if not(is_equal(procdefcoll^.data.rettype.def,pd.rettype.def)) and
  554. not((procdefcoll^.data.rettype.def.deftype=objectdef) and
  555. (pd.rettype.def.deftype=objectdef) and
  556. is_class(procdefcoll^.data.rettype.def) and
  557. is_class(pd.rettype.def) and
  558. (tobjectdef(pd.rettype.def).is_related(
  559. tobjectdef(procdefcoll^.data.rettype.def)))) then
  560. Message2(parser_e_overridden_methods_not_same_ret,pd.fullprocnamewithret,
  561. procdefcoll^.data.fullprocnamewithret);
  562. { now set the number }
  563. pd.extnumber:=procdefcoll^.data.extnumber;
  564. { and exchange }
  565. procdefcoll^.data:=pd;
  566. goto handlenextdef;
  567. end
  568. { different parameters }
  569. else
  570. begin
  571. { when we got an override directive then can search futher for
  572. the procedure to override.
  573. If we are starting a new virtual tree then hide the old tree }
  574. if not(po_overridingmethod in pd.procoptions) and
  575. not pdoverload then
  576. begin
  577. procdefcoll^.hidden:=true;
  578. if _class=pd._class then
  579. MessagePos1(pd.fileinfo,parser_w_should_use_override,pd.fullprocname);
  580. end;
  581. end;
  582. end
  583. else
  584. begin
  585. { the new definition is virtual and the old static, we hide the old one
  586. if the new defintion has not the overload directive }
  587. if not pdoverload or
  588. equal_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const) then
  589. procdefcoll^.hidden:=true;
  590. end;
  591. end
  592. else
  593. begin
  594. { both are static, we hide the old one if the new defintion
  595. has not the overload directive }
  596. if equal_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const) or
  597. not pdoverload then
  598. procdefcoll^.hidden:=true;
  599. end;
  600. end; { not hidden }
  601. procdefcoll:=procdefcoll^.next;
  602. end;
  603. { if it isn't saved in the list we create a new entry }
  604. newdefentry(pd);
  605. end;
  606. handlenextdef:
  607. hp:=hp^.next;
  608. end;
  609. exit;
  610. end;
  611. symcoll:=symcoll^.next;
  612. end;
  613. newentry;
  614. end;
  615. end;
  616. procedure tclassheader.disposevmttree;
  617. var
  618. symcoll : psymcoll;
  619. procdefcoll : pprocdefcoll;
  620. begin
  621. { disposes the above generated tree }
  622. symcoll:=wurzel;
  623. while assigned(symcoll) do
  624. begin
  625. wurzel:=symcoll^.next;
  626. stringdispose(symcoll^.name);
  627. procdefcoll:=symcoll^.data;
  628. while assigned(procdefcoll) do
  629. begin
  630. symcoll^.data:=procdefcoll^.next;
  631. dispose(procdefcoll);
  632. procdefcoll:=symcoll^.data;
  633. end;
  634. dispose(symcoll);
  635. symcoll:=wurzel;
  636. end;
  637. end;
  638. procedure tclassheader.genvmt;
  639. procedure do_genvmt(p : tobjectdef);
  640. begin
  641. { start with the base class }
  642. if assigned(p.childof) then
  643. do_genvmt(p.childof);
  644. { walk through all public syms }
  645. p.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}eachsym,nil);
  646. end;
  647. begin
  648. wurzel:=nil;
  649. nextvirtnumber:=0;
  650. has_constructor:=false;
  651. has_virtual_method:=false;
  652. { generates a tree of all used methods }
  653. do_genvmt(_class);
  654. if not(is_interface(_class)) and
  655. has_virtual_method and
  656. not(has_constructor) then
  657. Message1(parser_w_virtual_without_constructor,_class.objrealname^);
  658. end;
  659. {**************************************
  660. Interface tables
  661. **************************************}
  662. function tclassheader.gintfgetvtbllabelname(intfindex: integer): string;
  663. begin
  664. gintfgetvtbllabelname:=mangledname_prefix('VTBL',_class.owner)+_class.objname^+
  665. '_$_'+_class.implementedinterfaces.interfaces(intfindex).objname^;
  666. end;
  667. procedure tclassheader.gintfcreatevtbl(intfindex: integer; rawdata,rawcode: TAAsmoutput);
  668. var
  669. implintf: timplementedinterfaces;
  670. curintf: tobjectdef;
  671. proccount: integer;
  672. tmps: string;
  673. i: longint;
  674. begin
  675. implintf:=_class.implementedinterfaces;
  676. curintf:=implintf.interfaces(intfindex);
  677. if (cs_create_smart in aktmoduleswitches) then
  678. rawdata.concat(Tai_symbol.Createname_global(gintfgetvtbllabelname(intfindex),0))
  679. else
  680. rawdata.concat(Tai_symbol.Createname(gintfgetvtbllabelname(intfindex),0));
  681. proccount:=implintf.implproccount(intfindex);
  682. for i:=1 to proccount do
  683. begin
  684. tmps:=implintf.implprocs(intfindex,i).mangledname+'_$_'+curintf.objname^;
  685. { create wrapper code }
  686. cgintfwrapper(rawcode,implintf.implprocs(intfindex,i),tmps,implintf.ioffsets(intfindex)^);
  687. { create reference }
  688. rawdata.concat(Tai_const_symbol.Createname(tmps));
  689. end;
  690. end;
  691. procedure tclassheader.gintfgenentry(intfindex, contintfindex: integer; rawdata: TAAsmoutput);
  692. var
  693. implintf: timplementedinterfaces;
  694. curintf: tobjectdef;
  695. tmplabel: tasmlabel;
  696. i: longint;
  697. begin
  698. implintf:=_class.implementedinterfaces;
  699. curintf:=implintf.interfaces(intfindex);
  700. { GUID }
  701. if curintf.objecttype in [odt_interfacecom] then
  702. begin
  703. { label for GUID }
  704. getdatalabel(tmplabel);
  705. rawdata.concat(Tai_label.Create(tmplabel));
  706. rawdata.concat(Tai_const.Create_32bit(curintf.iidguid.D1));
  707. rawdata.concat(Tai_const.Create_16bit(curintf.iidguid.D2));
  708. rawdata.concat(Tai_const.Create_16bit(curintf.iidguid.D3));
  709. for i:=Low(curintf.iidguid.D4) to High(curintf.iidguid.D4) do
  710. rawdata.concat(Tai_const.Create_8bit(curintf.iidguid.D4[i]));
  711. dataSegment.concat(Tai_const_symbol.Create(tmplabel));
  712. end
  713. else
  714. begin
  715. { nil for Corba interfaces }
  716. dataSegment.concat(Tai_const.Create_32bit(0)); { nil }
  717. end;
  718. { VTable }
  719. dataSegment.concat(Tai_const_symbol.Createname(gintfgetvtbllabelname(contintfindex)));
  720. { IOffset field }
  721. dataSegment.concat(Tai_const.Create_32bit(implintf.ioffsets(contintfindex)^));
  722. { IIDStr }
  723. getdatalabel(tmplabel);
  724. rawdata.concat(Tai_label.Create(tmplabel));
  725. rawdata.concat(Tai_const.Create_8bit(length(curintf.iidstr^)));
  726. if curintf.objecttype=odt_interfacecom then
  727. rawdata.concat(Tai_string.Create(upper(curintf.iidstr^)))
  728. else
  729. rawdata.concat(Tai_string.Create(curintf.iidstr^));
  730. dataSegment.concat(Tai_const_symbol.Create(tmplabel));
  731. end;
  732. procedure tclassheader.gintfoptimizevtbls(implvtbl : plongint);
  733. type
  734. tcompintfentry = record
  735. weight: longint;
  736. compintf: longint;
  737. end;
  738. { Max 1000 interface in the class header interfaces it's enough imho }
  739. tcompintfs = packed array[1..1000] of tcompintfentry;
  740. pcompintfs = ^tcompintfs;
  741. tequals = packed array[1..1000] of longint;
  742. pequals = ^tequals;
  743. var
  744. max: longint;
  745. equals: pequals;
  746. compats: pcompintfs;
  747. i: longint;
  748. j: longint;
  749. w: longint;
  750. cij: boolean;
  751. cji: boolean;
  752. begin
  753. max:=_class.implementedinterfaces.count;
  754. if max>High(tequals) then
  755. Internalerror(200006135);
  756. getmem(compats,sizeof(tcompintfentry)*max);
  757. getmem(equals,sizeof(longint)*max);
  758. fillchar(compats^,sizeof(tcompintfentry)*max,0);
  759. fillchar(equals^,sizeof(longint)*max,0);
  760. { ismergepossible is a containing relation
  761. meaning of ismergepossible(a,b,w) =
  762. if implementorfunction map of a is contained implementorfunction map of b
  763. imp(a,b) and imp(b,c) => imp(a,c) ; imp(a,b) and imp(b,a) => a == b
  764. }
  765. { the order is very important for correct allocation }
  766. for i:=1 to max do
  767. begin
  768. for j:=i+1 to max do
  769. begin
  770. cij:=_class.implementedinterfaces.isimplmergepossible(i,j,w);
  771. cji:=_class.implementedinterfaces.isimplmergepossible(j,i,w);
  772. if cij and cji then { i equal j }
  773. begin
  774. { get minimum index of equal }
  775. if equals^[j]=0 then
  776. equals^[j]:=i;
  777. end
  778. else if cij then
  779. begin
  780. { get minimum index of maximum weight }
  781. if compats^[i].weight<w then
  782. begin
  783. compats^[i].weight:=w;
  784. compats^[i].compintf:=j;
  785. end;
  786. end
  787. else if cji then
  788. begin
  789. { get minimum index of maximum weight }
  790. if (compats^[j].weight<w) then
  791. begin
  792. compats^[j].weight:=w;
  793. compats^[j].compintf:=i;
  794. end;
  795. end;
  796. end;
  797. end;
  798. for i:=1 to max do
  799. begin
  800. if compats^[i].compintf<>0 then
  801. implvtbl[i]:=compats^[i].compintf
  802. else if equals^[i]<>0 then
  803. implvtbl[i]:=equals^[i]
  804. else
  805. implvtbl[i]:=i;
  806. end;
  807. freemem(compats,sizeof(tcompintfentry)*max);
  808. freemem(equals,sizeof(longint)*max);
  809. end;
  810. procedure tclassheader.gintfwritedata;
  811. var
  812. rawdata,rawcode: taasmoutput;
  813. impintfindexes: plongint;
  814. max: longint;
  815. i: longint;
  816. begin
  817. max:=_class.implementedinterfaces.count;
  818. getmem(impintfindexes,(max+1)*sizeof(longint));
  819. gintfoptimizevtbls(impintfindexes);
  820. rawdata:=TAAsmOutput.Create;
  821. rawcode:=TAAsmOutput.Create;
  822. dataSegment.concat(Tai_const.Create_16bit(max));
  823. { Two pass, one for allocation and vtbl creation }
  824. for i:=1 to max do
  825. begin
  826. if impintfindexes[i]=i then { if implement itself }
  827. begin
  828. { allocate a pointer in the object memory }
  829. with tstoredsymtable(_class.symtable) do
  830. begin
  831. if (dataalignment>=pointer_size) then
  832. datasize:=align(datasize,dataalignment)
  833. else
  834. datasize:=align(datasize,pointer_size);
  835. _class.implementedinterfaces.ioffsets(i)^:=datasize;
  836. datasize:=datasize+pointer_size;
  837. end;
  838. { write vtbl }
  839. gintfcreatevtbl(i,rawdata,rawcode);
  840. end;
  841. end;
  842. { second pass: for fill interfacetable and remained ioffsets }
  843. for i:=1 to max do
  844. begin
  845. if i<>impintfindexes[i] then { why execute x:=x ? }
  846. with _class.implementedinterfaces do
  847. ioffsets(i)^:=ioffsets(impintfindexes[i])^;
  848. gintfgenentry(i,impintfindexes[i],rawdata);
  849. end;
  850. dataSegment.concatlist(rawdata);
  851. rawdata.free;
  852. codeSegment.concatlist(rawcode);
  853. rawcode.free;
  854. freemem(impintfindexes,(max+1)*sizeof(longint));
  855. end;
  856. function tclassheader.gintfgetcprocdef(proc: tprocdef;const name: string): tprocdef;
  857. var
  858. sym: tprocsym;
  859. implprocdef : pprocdeflist;
  860. begin
  861. gintfgetcprocdef:=nil;
  862. sym:=tprocsym(search_class_member(_class,name));
  863. if assigned(sym) and (sym.typ=procsym) then
  864. begin
  865. implprocdef:=sym.defs;
  866. while assigned(implprocdef) do
  867. begin
  868. if equal_paras(proc.para,implprocdef^.def.para,cp_none) and
  869. (proc.proccalloption=implprocdef^.def.proccalloption) then
  870. begin
  871. gintfgetcprocdef:=implprocdef^.def;
  872. exit;
  873. end;
  874. implprocdef:=implprocdef^.next;
  875. end;
  876. end;
  877. end;
  878. procedure tclassheader.gintfdoonintf(intf: tobjectdef; intfindex: longint);
  879. var
  880. i: longint;
  881. proc: tprocdef;
  882. procname: string; { for error }
  883. mappedname: string;
  884. nextexist: pointer;
  885. implprocdef: tprocdef;
  886. begin
  887. for i:=1 to intf.symtable.defindex.count do
  888. begin
  889. proc:=tprocdef(intf.symtable.defindex.search(i));
  890. if proc.deftype=procdef then
  891. begin
  892. procname:='';
  893. implprocdef:=nil;
  894. nextexist:=nil;
  895. repeat
  896. mappedname:=_class.implementedinterfaces.getmappings(intfindex,proc.procsym.name,nextexist);
  897. if procname='' then
  898. procname:=proc.procsym.name;
  899. //mappedname; { for error messages }
  900. if mappedname<>'' then
  901. implprocdef:=gintfgetcprocdef(proc,mappedname);
  902. until assigned(implprocdef) or not assigned(nextexist);
  903. if not assigned(implprocdef) then
  904. implprocdef:=gintfgetcprocdef(proc,proc.procsym.name);
  905. if procname='' then
  906. procname:=proc.procsym.name;
  907. if assigned(implprocdef) then
  908. _class.implementedinterfaces.addimplproc(intfindex,implprocdef)
  909. else
  910. Message1(sym_e_id_not_found,procname);
  911. end;
  912. end;
  913. end;
  914. procedure tclassheader.gintfwalkdowninterface(intf: tobjectdef; intfindex: longint);
  915. begin
  916. if assigned(intf.childof) then
  917. gintfwalkdowninterface(intf.childof,intfindex);
  918. gintfdoonintf(intf,intfindex);
  919. end;
  920. function tclassheader.genintftable: tasmlabel;
  921. var
  922. intfindex: longint;
  923. curintf: tobjectdef;
  924. intftable: tasmlabel;
  925. begin
  926. { 1. step collect implementor functions into the implementedinterfaces.implprocs }
  927. for intfindex:=1 to _class.implementedinterfaces.count do
  928. begin
  929. curintf:=_class.implementedinterfaces.interfaces(intfindex);
  930. gintfwalkdowninterface(curintf,intfindex);
  931. end;
  932. { 2. step calc required fieldcount and their offsets in the object memory map
  933. and write data }
  934. getdatalabel(intftable);
  935. dataSegment.concat(Tai_label.Create(intftable));
  936. gintfwritedata;
  937. _class.implementedinterfaces.clearimplprocs; { release temporary information }
  938. genintftable:=intftable;
  939. end;
  940. { Write interface identifiers to the data section }
  941. procedure tclassheader.writeinterfaceids;
  942. var
  943. i: longint;
  944. begin
  945. if _class.isiidguidvalid then
  946. begin
  947. if (cs_create_smart in aktmoduleswitches) then
  948. dataSegment.concat(Tai_cut.Create);
  949. dataSegment.concat(Tai_symbol.Createname_global(mangledname_prefix('IID',_class.owner)+_class.objname^,0));
  950. dataSegment.concat(Tai_const.Create_32bit(longint(_class.iidguid.D1)));
  951. dataSegment.concat(Tai_const.Create_16bit(_class.iidguid.D2));
  952. dataSegment.concat(Tai_const.Create_16bit(_class.iidguid.D3));
  953. for i:=Low(_class.iidguid.D4) to High(_class.iidguid.D4) do
  954. dataSegment.concat(Tai_const.Create_8bit(_class.iidguid.D4[i]));
  955. end;
  956. if (cs_create_smart in aktmoduleswitches) then
  957. dataSegment.concat(Tai_cut.Create);
  958. dataSegment.concat(Tai_symbol.Createname_global(mangledname_prefix('IIDSTR',_class.owner)+_class.objname^,0));
  959. dataSegment.concat(Tai_const.Create_8bit(length(_class.iidstr^)));
  960. dataSegment.concat(Tai_string.Create(_class.iidstr^));
  961. end;
  962. procedure tclassheader.writevirtualmethods(List:TAAsmoutput);
  963. var
  964. symcoll : psymcoll;
  965. procdefcoll : pprocdefcoll;
  966. i : longint;
  967. begin
  968. { walk trough all numbers for virtual methods and search }
  969. { the method }
  970. for i:=0 to nextvirtnumber-1 do
  971. begin
  972. symcoll:=wurzel;
  973. { walk trough all symbols }
  974. while assigned(symcoll) do
  975. begin
  976. { walk trough all methods }
  977. procdefcoll:=symcoll^.data;
  978. while assigned(procdefcoll) do
  979. begin
  980. { writes the addresses to the VMT }
  981. { but only this which are declared as virtual }
  982. if procdefcoll^.data.extnumber=i then
  983. begin
  984. if (po_virtualmethod in procdefcoll^.data.procoptions) then
  985. begin
  986. { if a method is abstract, then is also the }
  987. { class abstract and it's not allow to }
  988. { generates an instance }
  989. if (po_abstractmethod in procdefcoll^.data.procoptions) then
  990. begin
  991. include(_class.objectoptions,oo_has_abstract);
  992. List.concat(Tai_const_symbol.Createname('FPC_ABSTRACTERROR'));
  993. end
  994. else
  995. begin
  996. List.concat(Tai_const_symbol.createname(procdefcoll^.data.mangledname));
  997. end;
  998. end;
  999. end;
  1000. procdefcoll:=procdefcoll^.next;
  1001. end;
  1002. symcoll:=symcoll^.next;
  1003. end;
  1004. end;
  1005. end;
  1006. { generates the vmt for classes as well as for objects }
  1007. procedure tclassheader.writevmt;
  1008. var
  1009. methodnametable,intmessagetable,
  1010. strmessagetable,classnamelabel,
  1011. fieldtablelabel : tasmlabel;
  1012. {$ifdef WITHDMT}
  1013. dmtlabel : tasmlabel;
  1014. {$endif WITHDMT}
  1015. interfacetable : tasmlabel;
  1016. begin
  1017. {$ifdef WITHDMT}
  1018. dmtlabel:=gendmt;
  1019. {$endif WITHDMT}
  1020. if (cs_create_smart in aktmoduleswitches) then
  1021. dataSegment.concat(Tai_cut.Create);
  1022. { write tables for classes, this must be done before the actual
  1023. class is written, because we need the labels defined }
  1024. if is_class(_class) then
  1025. begin
  1026. { interface table }
  1027. if _class.implementedinterfaces.count>0 then
  1028. begin
  1029. if (cs_create_smart in aktmoduleswitches) then
  1030. codeSegment.concat(Tai_cut.Create);
  1031. interfacetable:=genintftable;
  1032. end;
  1033. methodnametable:=genpublishedmethodstable;
  1034. fieldtablelabel:=_class.generate_field_table;
  1035. { write class name }
  1036. getdatalabel(classnamelabel);
  1037. dataSegment.concat(Tai_label.Create(classnamelabel));
  1038. dataSegment.concat(Tai_const.Create_8bit(length(_class.objrealname^)));
  1039. dataSegment.concat(Tai_string.Create(_class.objrealname^));
  1040. { generate message and dynamic tables }
  1041. if (oo_has_msgstr in _class.objectoptions) then
  1042. strmessagetable:=genstrmsgtab;
  1043. if (oo_has_msgint in _class.objectoptions) then
  1044. intmessagetable:=genintmsgtab
  1045. else
  1046. dataSegment.concat(Tai_const.Create_32bit(0));
  1047. end;
  1048. { write debug info }
  1049. {$ifdef GDB}
  1050. if (cs_debuginfo in aktmoduleswitches) then
  1051. begin
  1052. do_count_dbx:=true;
  1053. if assigned(_class.owner) and assigned(_class.owner.name) then
  1054. dataSegment.concat(Tai_stabs.Create(strpnew('"vmt_'+_class.owner.name^+_class.name+':S'+
  1055. typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+_class.vmt_mangledname)));
  1056. end;
  1057. {$endif GDB}
  1058. dataSegment.concat(Tai_symbol.Createdataname_global(_class.vmt_mangledname,0));
  1059. { determine the size with symtable.datasize, because }
  1060. { size gives back 4 for classes }
  1061. dataSegment.concat(Tai_const.Create_32bit(_class.symtable.datasize));
  1062. dataSegment.concat(Tai_const.Create_32bit(-_class.symtable.datasize));
  1063. {$ifdef WITHDMT}
  1064. if _class.classtype=ct_object then
  1065. begin
  1066. if assigned(dmtlabel) then
  1067. dataSegment.concat(Tai_const_symbol.Create(dmtlabel)))
  1068. else
  1069. dataSegment.concat(Tai_const.Create_32bit(0));
  1070. end;
  1071. {$endif WITHDMT}
  1072. { write pointer to parent VMT, this isn't implemented in TP }
  1073. { but this is not used in FPC ? (PM) }
  1074. { it's not used yet, but the delphi-operators as and is need it (FK) }
  1075. { it is not written for parents that don't have any vmt !! }
  1076. if assigned(_class.childof) and
  1077. (oo_has_vmt in _class.childof.objectoptions) then
  1078. dataSegment.concat(Tai_const_symbol.Createname(_class.childof.vmt_mangledname))
  1079. else
  1080. dataSegment.concat(Tai_const.Create_32bit(0));
  1081. { write extended info for classes, for the order see rtl/inc/objpash.inc }
  1082. if is_class(_class) then
  1083. begin
  1084. { pointer to class name string }
  1085. dataSegment.concat(Tai_const_symbol.Create(classnamelabel));
  1086. { pointer to dynamic table }
  1087. if (oo_has_msgint in _class.objectoptions) then
  1088. dataSegment.concat(Tai_const_symbol.Create(intmessagetable))
  1089. else
  1090. dataSegment.concat(Tai_const.Create_32bit(0));
  1091. { pointer to method table }
  1092. if assigned(methodnametable) then
  1093. dataSegment.concat(Tai_const_symbol.Create(methodnametable))
  1094. else
  1095. dataSegment.concat(Tai_const.Create_32bit(0));
  1096. { pointer to field table }
  1097. dataSegment.concat(Tai_const_symbol.Create(fieldtablelabel));
  1098. { pointer to type info of published section }
  1099. if (oo_can_have_published in _class.objectoptions) then
  1100. dataSegment.concat(Tai_const_symbol.Create(_class.get_rtti_label(fullrtti)))
  1101. else
  1102. dataSegment.concat(Tai_const.Create_32bit(0));
  1103. { inittable for con-/destruction, for classes this is always generated }
  1104. dataSegment.concat(Tai_const_symbol.Create(_class.get_rtti_label(initrtti)));
  1105. { auto table }
  1106. dataSegment.concat(Tai_const.Create_32bit(0));
  1107. { interface table }
  1108. if _class.implementedinterfaces.count>0 then
  1109. dataSegment.concat(Tai_const_symbol.Create(interfacetable))
  1110. else
  1111. dataSegment.concat(Tai_const.Create_32bit(0));
  1112. { table for string messages }
  1113. if (oo_has_msgstr in _class.objectoptions) then
  1114. dataSegment.concat(Tai_const_symbol.Create(strmessagetable))
  1115. else
  1116. dataSegment.concat(Tai_const.Create_32bit(0));
  1117. end;
  1118. { write virtual methods }
  1119. writevirtualmethods(dataSegment);
  1120. { write the size of the VMT }
  1121. dataSegment.concat(Tai_symbol_end.Createname(_class.vmt_mangledname));
  1122. end;
  1123. initialization
  1124. cclassheader:=tclassheader;
  1125. end.
  1126. {
  1127. $Log$
  1128. Revision 1.19 2002-05-16 19:46:39 carl
  1129. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1130. + try to fix temp allocation (still in ifdef)
  1131. + generic constructor calls
  1132. + start of tassembler / tmodulebase class cleanup
  1133. Revision 1.17 2002/05/12 16:53:08 peter
  1134. * moved entry and exitcode to ncgutil and cgobj
  1135. * foreach gets extra argument for passing local data to the
  1136. iterator function
  1137. * -CR checks also class typecasts at runtime by changing them
  1138. into as
  1139. * fixed compiler to cycle with the -CR option
  1140. * fixed stabs with elf writer, finally the global variables can
  1141. be watched
  1142. * removed a lot of routines from cga unit and replaced them by
  1143. calls to cgobj
  1144. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1145. u32bit then the other is typecasted also to u32bit without giving
  1146. a rangecheck warning/error.
  1147. * fixed pascal calling method with reversing also the high tree in
  1148. the parast, detected by tcalcst3 test
  1149. Revision 1.16 2002/04/20 21:32:24 carl
  1150. + generic FPC_CHECKPOINTER
  1151. + first parameter offset in stack now portable
  1152. * rename some constants
  1153. + move some cpu stuff to other units
  1154. - remove unused constents
  1155. * fix stacksize for some targets
  1156. * fix generic size problems which depend now on EXTEND_SIZE constant
  1157. Revision 1.15 2002/04/19 15:46:01 peter
  1158. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  1159. in most cases and not written to the ppu
  1160. * add mangeledname_prefix() routine to generate the prefix of
  1161. manglednames depending on the current procedure, object and module
  1162. * removed static procprefix since the mangledname is now build only
  1163. on demand from tprocdef.mangledname
  1164. Revision 1.14 2002/04/15 18:59:07 carl
  1165. + target_info.size_of_pointer -> pointer_Size
  1166. Revision 1.13 2002/02/11 18:51:35 peter
  1167. * fixed vmt generation for private procedures that were skipped after
  1168. my previous changes
  1169. Revision 1.12 2001/12/31 16:59:41 peter
  1170. * protected/private symbols parsing fixed
  1171. Revision 1.11 2001/11/20 18:49:43 peter
  1172. * require overload for cross object overloading
  1173. Revision 1.10 2001/11/18 20:18:54 peter
  1174. * use cp_value_equal_const instead of cp_all
  1175. Revision 1.9 2001/11/18 18:43:14 peter
  1176. * overloading supported in child classes
  1177. * fixed parsing of classes with private and virtual and overloaded
  1178. so it is compatible with delphi
  1179. Revision 1.8 2001/11/02 22:58:02 peter
  1180. * procsym definition rewrite
  1181. Revision 1.7 2001/10/25 21:22:35 peter
  1182. * calling convention rewrite
  1183. Revision 1.6 2001/10/20 19:28:38 peter
  1184. * interface 2 guid support
  1185. * guid constants support
  1186. Revision 1.5 2001/10/20 17:20:14 peter
  1187. * fixed generation of rtti for virtualmethods
  1188. Revision 1.4 2001/09/19 11:04:42 michael
  1189. * Smartlinking with interfaces fixed
  1190. * Better smartlinking for rtti and init tables
  1191. Revision 1.3 2001/08/30 20:13:53 peter
  1192. * rtti/init table updates
  1193. * rttisym for reusable global rtti/init info
  1194. * support published for interfaces
  1195. Revision 1.2 2001/08/22 21:16:20 florian
  1196. * some interfaces related problems regarding
  1197. mapping of interface implementions fixed
  1198. Revision 1.1 2001/04/21 13:37:16 peter
  1199. * made tclassheader using class of to implement cpu dependent code
  1200. Revision 1.20 2001/04/18 22:01:54 peter
  1201. * registration of targets and assemblers
  1202. Revision 1.19 2001/04/13 01:22:07 peter
  1203. * symtable change to classes
  1204. * range check generation and errors fixed, make cycle DEBUG=1 works
  1205. * memory leaks fixed
  1206. Revision 1.18 2001/04/04 21:30:43 florian
  1207. * applied several fixes to get the DD8 Delphi Unit compiled
  1208. e.g. "forward"-interfaces are working now
  1209. Revision 1.17 2000/12/25 00:07:26 peter
  1210. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1211. tlinkedlist objects)
  1212. Revision 1.16 2000/11/29 00:30:30 florian
  1213. * unused units removed from uses clause
  1214. * some changes for widestrings
  1215. Revision 1.15 2000/11/19 16:23:35 florian
  1216. *** empty log message ***
  1217. Revision 1.14 2000/11/12 23:24:10 florian
  1218. * interfaces are basically running
  1219. Revision 1.13 2000/11/08 00:07:40 florian
  1220. * potential range check error fixed
  1221. Revision 1.12 2000/11/06 23:13:53 peter
  1222. * uppercase manglednames
  1223. Revision 1.11 2000/11/04 17:31:00 florian
  1224. * fixed some problems of previous commit
  1225. Revision 1.10 2000/11/04 14:25:19 florian
  1226. + merged Attila's changes for interfaces, not tested yet
  1227. Revision 1.9 2000/11/01 23:04:37 peter
  1228. * tprocdef.fullprocname added for better casesensitve writing of
  1229. procedures
  1230. Revision 1.8 2000/10/31 22:02:47 peter
  1231. * symtable splitted, no real code changes
  1232. Revision 1.7 2000/10/14 10:14:47 peter
  1233. * moehrendorf oct 2000 rewrite
  1234. Revision 1.6 2000/09/24 21:19:50 peter
  1235. * delphi compile fixes
  1236. Revision 1.5 2000/09/24 15:06:17 peter
  1237. * use defines.inc
  1238. Revision 1.4 2000/08/27 16:11:51 peter
  1239. * moved some util functions from globals,cobjects to cutils
  1240. * splitted files into finput,fmodule
  1241. Revision 1.3 2000/07/13 12:08:26 michael
  1242. + patched to 1.1.0 with former 1.09patch from peter
  1243. Revision 1.2 2000/07/13 11:32:41 michael
  1244. + removed logs
  1245. }