ncal.pas 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This file implements the node for sub procedure calling.
  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. unit ncal;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,cclasses,
  23. globtype,cpuinfo,
  24. paramgr,
  25. node,nbas,
  26. {$ifdef state_tracking}
  27. nstate,
  28. {$endif state_tracking}
  29. symbase,symtype,symsym,symdef,symtable;
  30. type
  31. tcallnodeflags = (
  32. cnf_restypeset
  33. );
  34. tcallnodeflagset = set of tcallnodeflags;
  35. tcallnode = class(tbinarynode)
  36. private
  37. { number of parameters passed from the source, this does not include the hidden parameters }
  38. paralength : smallint;
  39. paravisible : boolean;
  40. function gen_self_tree_methodpointer:tnode;
  41. function gen_self_tree:tnode;
  42. function gen_vmt_tree:tnode;
  43. procedure bind_paraitem;
  44. { function return node, this is used to pass the data for a
  45. ret_in_param return value }
  46. _funcretnode : tnode;
  47. procedure setfuncretnode(const returnnode: tnode);
  48. procedure convert_carg_array_of_const;
  49. procedure order_parameters;
  50. public
  51. { the symbol containing the definition of the procedure }
  52. { to call }
  53. symtableprocentry : tprocsym;
  54. symtableprocentryderef : tderef;
  55. { symtable where the entry was found, needed for with support }
  56. symtableproc : tsymtable;
  57. { the definition of the procedure to call }
  58. procdefinition : tabstractprocdef;
  59. procdefinitionderef : tderef;
  60. { tree that contains the pointer to the object for this method }
  61. methodpointer : tnode;
  62. { inline function body }
  63. inlinecode : tnode;
  64. { varargs tparaitems }
  65. varargsparas : tvarargspara;
  66. { node that specifies where the result should be put for calls }
  67. { that return their result in a parameter }
  68. property funcretnode: tnode read _funcretnode write setfuncretnode;
  69. { separately specified resulttype for some compilerprocs (e.g. }
  70. { you can't have a function with an "array of char" resulttype }
  71. { the RTL) (JM) }
  72. restype: ttype;
  73. callnodeflags : tcallnodeflagset;
  74. { only the processor specific nodes need to override this }
  75. { constructor }
  76. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
  77. constructor create_def(l:tnode;def:tprocdef;mp:tnode);virtual;
  78. constructor create_procvar(l,r:tnode);
  79. constructor createintern(const name: string; params: tnode);
  80. constructor createinternres(const name: string; params: tnode; const res: ttype);
  81. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  82. destructor destroy;override;
  83. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  84. procedure ppuwrite(ppufile:tcompilerppufile);override;
  85. procedure buildderefimpl;override;
  86. procedure derefimpl;override;
  87. function getcopy : tnode;override;
  88. { Goes through all symbols in a class and subclasses and calls
  89. verify abstract for each .
  90. }
  91. procedure verifyabstractcalls;
  92. { called for each definition in a class and verifies if a method
  93. is abstract or not, if it is abstract, give out a warning
  94. }
  95. procedure verifyabstract(p : tnamedindexitem;arg:pointer);
  96. procedure insertintolist(l : tnodelist);override;
  97. function pass_1 : tnode;override;
  98. function det_resulttype:tnode;override;
  99. {$ifdef state_tracking}
  100. function track_state_pass(exec_known:boolean):boolean;override;
  101. {$endif state_tracking}
  102. function docompare(p: tnode): boolean; override;
  103. procedure printnodedata(var t:text);override;
  104. function para_count:longint;
  105. private
  106. AbstractMethodsList : TStringList;
  107. end;
  108. tcallnodeclass = class of tcallnode;
  109. tcallparaflags = (
  110. { flags used by tcallparanode }
  111. cpf_is_colon_para
  112. );
  113. tcallparanode = class(tbinarynode)
  114. public
  115. callparaflags : set of tcallparaflags;
  116. paraitem : tparaitem;
  117. used_by_callnode : boolean;
  118. { only the processor specific nodes need to override this }
  119. { constructor }
  120. constructor create(expr,next : tnode);virtual;
  121. destructor destroy;override;
  122. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  123. procedure ppuwrite(ppufile:tcompilerppufile);override;
  124. function getcopy : tnode;override;
  125. procedure insertintolist(l : tnodelist);override;
  126. procedure get_paratype;
  127. procedure insert_typeconv(do_count : boolean);
  128. procedure det_registers;
  129. procedure firstcallparan;
  130. procedure secondcallparan;virtual;abstract;
  131. function docompare(p: tnode): boolean; override;
  132. procedure printnodetree(var t:text);override;
  133. end;
  134. tcallparanodeclass = class of tcallparanode;
  135. function reverseparameters(p: tcallparanode): tcallparanode;
  136. var
  137. ccallnode : tcallnodeclass;
  138. ccallparanode : tcallparanodeclass;
  139. { Current callnode, this is needed for having a link
  140. between the callparanodes and the callnode they belong to }
  141. aktcallnode : tcallnode;
  142. implementation
  143. uses
  144. systems,
  145. verbose,globals,
  146. symconst,defutil,defcmp,
  147. htypechk,pass_1,
  148. ncnv,nld,ninl,nadd,ncon,nmem,nutils,
  149. procinfo,
  150. cgbase
  151. ;
  152. type
  153. tobjectinfoitem = class(tlinkedlistitem)
  154. objinfo : tobjectdef;
  155. constructor create(def : tobjectdef);
  156. end;
  157. {****************************************************************************
  158. HELPERS
  159. ****************************************************************************}
  160. function reverseparameters(p: tcallparanode): tcallparanode;
  161. var
  162. hp1, hp2: tcallparanode;
  163. begin
  164. hp1:=nil;
  165. while assigned(p) do
  166. begin
  167. { pull out }
  168. hp2:=p;
  169. p:=tcallparanode(p.right);
  170. { pull in }
  171. hp2.right:=hp1;
  172. hp1:=hp2;
  173. end;
  174. reverseparameters:=hp1;
  175. end;
  176. function gen_high_tree(p:tnode;openstring:boolean):tnode;
  177. var
  178. temp: tnode;
  179. len : integer;
  180. loadconst : boolean;
  181. hightree : tnode;
  182. begin
  183. len:=-1;
  184. loadconst:=true;
  185. hightree:=nil;
  186. case p.resulttype.def.deftype of
  187. arraydef :
  188. begin
  189. { handle via a normal inline in_high_x node }
  190. loadconst := false;
  191. hightree := geninlinenode(in_high_x,false,p.getcopy);
  192. { only substract low(array) if it's <> 0 }
  193. temp := geninlinenode(in_low_x,false,p.getcopy);
  194. resulttypepass(temp);
  195. if (temp.nodetype <> ordconstn) or
  196. (tordconstnode(temp).value <> 0) then
  197. hightree := caddnode.create(subn,hightree,temp)
  198. else
  199. temp.free;
  200. end;
  201. stringdef :
  202. begin
  203. if openstring then
  204. begin
  205. { handle via a normal inline in_high_x node }
  206. loadconst := false;
  207. hightree := geninlinenode(in_high_x,false,p.getcopy);
  208. end
  209. else
  210. begin
  211. { passing a string to an array of char }
  212. if (p.nodetype=stringconstn) then
  213. begin
  214. len:=str_length(p);
  215. if len>0 then
  216. dec(len);
  217. end
  218. else
  219. begin
  220. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
  221. cordconstnode.create(1,s32inttype,false));
  222. loadconst:=false;
  223. end;
  224. end;
  225. end;
  226. else
  227. len:=0;
  228. end;
  229. if loadconst then
  230. hightree:=cordconstnode.create(len,s32inttype,true)
  231. else
  232. begin
  233. if not assigned(hightree) then
  234. internalerror(200304071);
  235. { Need to use explicit, because it can also be a enum }
  236. hightree:=ctypeconvnode.create_explicit(hightree,s32inttype);
  237. end;
  238. result:=hightree;
  239. end;
  240. {****************************************************************************
  241. TOBJECTINFOITEM
  242. ****************************************************************************}
  243. constructor tobjectinfoitem.create(def : tobjectdef);
  244. begin
  245. inherited create;
  246. objinfo := def;
  247. end;
  248. {****************************************************************************
  249. TCALLPARANODE
  250. ****************************************************************************}
  251. constructor tcallparanode.create(expr,next : tnode);
  252. begin
  253. inherited create(callparan,expr,next);
  254. if not assigned(expr) then
  255. internalerror(200305091);
  256. expr.set_file_line(self);
  257. callparaflags:=[];
  258. end;
  259. destructor tcallparanode.destroy;
  260. begin
  261. { When the node is used by callnode then
  262. we don't destroy left, the callnode takes care of it }
  263. if used_by_callnode then
  264. left:=nil;
  265. inherited destroy;
  266. end;
  267. constructor tcallparanode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  268. begin
  269. inherited ppuload(t,ppufile);
  270. ppufile.getsmallset(callparaflags);
  271. end;
  272. procedure tcallparanode.ppuwrite(ppufile:tcompilerppufile);
  273. begin
  274. inherited ppuwrite(ppufile);
  275. ppufile.putsmallset(callparaflags);
  276. end;
  277. function tcallparanode.getcopy : tnode;
  278. var
  279. n : tcallparanode;
  280. begin
  281. n:=tcallparanode(inherited getcopy);
  282. n.callparaflags:=callparaflags;
  283. n.paraitem:=paraitem;
  284. result:=n;
  285. end;
  286. procedure tcallparanode.insertintolist(l : tnodelist);
  287. begin
  288. end;
  289. procedure tcallparanode.get_paratype;
  290. var
  291. old_array_constructor : boolean;
  292. begin
  293. inc(parsing_para_level);
  294. if assigned(right) then
  295. tcallparanode(right).get_paratype;
  296. old_array_constructor:=allow_array_constructor;
  297. allow_array_constructor:=true;
  298. resulttypepass(left);
  299. allow_array_constructor:=old_array_constructor;
  300. if codegenerror then
  301. resulttype:=generrortype
  302. else
  303. resulttype:=left.resulttype;
  304. dec(parsing_para_level);
  305. end;
  306. procedure tcallparanode.insert_typeconv(do_count : boolean);
  307. var
  308. oldtype : ttype;
  309. {$ifdef extdebug}
  310. store_count_ref : boolean;
  311. {$endif def extdebug}
  312. begin
  313. inc(parsing_para_level);
  314. {$ifdef extdebug}
  315. if do_count then
  316. begin
  317. store_count_ref:=count_ref;
  318. count_ref:=true;
  319. end;
  320. {$endif def extdebug}
  321. { Be sure to have the resulttype }
  322. if not assigned(left.resulttype.def) then
  323. resulttypepass(left);
  324. if (left.nodetype<>nothingn) then
  325. begin
  326. { Convert tp procvars, this is needs to be done
  327. here to make the change permanent. in the overload
  328. choosing the changes are only made temporary }
  329. if (left.resulttype.def.deftype=procvardef) and
  330. (paraitem.paratype.def.deftype<>procvardef) then
  331. begin
  332. if maybe_call_procvar(left,true) then
  333. resulttype:=left.resulttype;
  334. end;
  335. { Handle varargs and hidden paras directly, no typeconvs or }
  336. { typechecking needed }
  337. if (nf_varargs_para in flags) then
  338. begin
  339. { convert pascal to C types }
  340. case left.resulttype.def.deftype of
  341. stringdef :
  342. inserttypeconv(left,charpointertype);
  343. floatdef :
  344. inserttypeconv(left,s64floattype);
  345. end;
  346. set_varstate(left,vs_used,true);
  347. resulttype:=left.resulttype;
  348. end
  349. else
  350. if (paraitem.is_hidden) then
  351. begin
  352. set_varstate(left,vs_used,true);
  353. resulttype:=left.resulttype;
  354. end
  355. else
  356. begin
  357. { Do we need arrayconstructor -> set conversion, then insert
  358. it here before the arrayconstructor node breaks the tree
  359. with its conversions of enum->ord }
  360. if (left.nodetype=arrayconstructorn) and
  361. (paraitem.paratype.def.deftype=setdef) then
  362. inserttypeconv(left,paraitem.paratype);
  363. { set some settings needed for arrayconstructor }
  364. if is_array_constructor(left.resulttype.def) then
  365. begin
  366. if is_array_of_const(paraitem.paratype.def) then
  367. begin
  368. { force variant array }
  369. include(left.flags,nf_forcevaria);
  370. end
  371. else
  372. begin
  373. include(left.flags,nf_novariaallowed);
  374. { now that the resultting type is know we can insert the required
  375. typeconvs for the array constructor }
  376. tarrayconstructornode(left).force_type(tarraydef(paraitem.paratype.def).elementtype);
  377. end;
  378. end;
  379. { check if local proc/func is assigned to procvar }
  380. if left.resulttype.def.deftype=procvardef then
  381. test_local_to_procvar(tprocvardef(left.resulttype.def),paraitem.paratype.def);
  382. { test conversions }
  383. if not(is_shortstring(left.resulttype.def) and
  384. is_shortstring(paraitem.paratype.def)) and
  385. (paraitem.paratype.def.deftype<>formaldef) then
  386. begin
  387. { Process open parameters }
  388. if paramanager.push_high_param(paraitem.paratyp,paraitem.paratype.def,aktcallnode.procdefinition.proccalloption) then
  389. begin
  390. { insert type conv but hold the ranges of the array }
  391. oldtype:=left.resulttype;
  392. inserttypeconv(left,paraitem.paratype);
  393. left.resulttype:=oldtype;
  394. end
  395. else
  396. begin
  397. { for ordinals, floats and enums, verify if we might cause
  398. some range-check errors. }
  399. if (paraitem.paratype.def.deftype in [enumdef,orddef,floatdef]) and
  400. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) and
  401. (left.nodetype in [vecn,loadn,calln]) then
  402. begin
  403. if (left.resulttype.def.size>paraitem.paratype.def.size) then
  404. begin
  405. if (cs_check_range in aktlocalswitches) then
  406. Message(type_w_smaller_possible_range_check)
  407. else
  408. Message(type_h_smaller_possible_range_check);
  409. end;
  410. end;
  411. inserttypeconv(left,paraitem.paratype);
  412. end;
  413. if codegenerror then
  414. begin
  415. dec(parsing_para_level);
  416. exit;
  417. end;
  418. end;
  419. { check var strings }
  420. if (cs_strict_var_strings in aktlocalswitches) and
  421. is_shortstring(left.resulttype.def) and
  422. is_shortstring(paraitem.paratype.def) and
  423. (paraitem.paratyp in [vs_out,vs_var]) and
  424. not(is_open_string(paraitem.paratype.def)) and
  425. not(equal_defs(left.resulttype.def,paraitem.paratype.def)) then
  426. begin
  427. aktfilepos:=left.fileinfo;
  428. CGMessage(type_e_strict_var_string_violation);
  429. end;
  430. { Handle formal parameters separate }
  431. if (paraitem.paratype.def.deftype=formaldef) then
  432. begin
  433. { load procvar if a procedure is passed }
  434. if (m_tp_procvar in aktmodeswitches) and
  435. (left.nodetype=calln) and
  436. (is_void(left.resulttype.def)) then
  437. load_procvar_from_calln(left);
  438. case paraitem.paratyp of
  439. vs_var,
  440. vs_out :
  441. begin
  442. if not valid_for_formal_var(left) then
  443. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  444. end;
  445. vs_const :
  446. begin
  447. if not valid_for_formal_const(left) then
  448. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  449. end;
  450. end;
  451. end
  452. else
  453. begin
  454. { check if the argument is allowed }
  455. if (paraitem.paratyp in [vs_out,vs_var]) then
  456. valid_for_var(left);
  457. end;
  458. if paraitem.paratyp in [vs_var,vs_const] then
  459. begin
  460. { Causes problems with const ansistrings if also }
  461. { done for vs_const (JM) }
  462. if paraitem.paratyp = vs_var then
  463. set_unique(left);
  464. make_not_regable(left);
  465. end;
  466. { ansistrings out paramaters doesn't need to be }
  467. { unique, they are finalized }
  468. if paraitem.paratyp=vs_out then
  469. make_not_regable(left);
  470. if do_count then
  471. begin
  472. if paraitem.paratyp in [vs_var,vs_out] then
  473. set_varstate(left,vs_used,false)
  474. else
  475. set_varstate(left,vs_used,true);
  476. end;
  477. { must only be done after typeconv PM }
  478. resulttype:=paraitem.paratype;
  479. end;
  480. end;
  481. { process next node }
  482. if assigned(right) then
  483. tcallparanode(right).insert_typeconv(do_count);
  484. dec(parsing_para_level);
  485. {$ifdef extdebug}
  486. if do_count then
  487. count_ref:=store_count_ref;
  488. {$endif def extdebug}
  489. end;
  490. procedure tcallparanode.det_registers;
  491. begin
  492. if assigned(right) then
  493. begin
  494. tcallparanode(right).det_registers;
  495. registersint:=right.registersint;
  496. registersfpu:=right.registersfpu;
  497. {$ifdef SUPPORT_MMX}
  498. registersmmx:=right.registersmmx;
  499. {$endif}
  500. end;
  501. firstpass(left);
  502. if left.registersint>registersint then
  503. registersint:=left.registersint;
  504. if left.registersfpu>registersfpu then
  505. registersfpu:=left.registersfpu;
  506. {$ifdef SUPPORT_MMX}
  507. if left.registersmmx>registersmmx then
  508. registersmmx:=left.registersmmx;
  509. {$endif SUPPORT_MMX}
  510. end;
  511. procedure tcallparanode.firstcallparan;
  512. begin
  513. if not assigned(left.resulttype.def) then
  514. get_paratype;
  515. det_registers;
  516. end;
  517. function tcallparanode.docompare(p: tnode): boolean;
  518. begin
  519. docompare :=
  520. inherited docompare(p) and
  521. (callparaflags = tcallparanode(p).callparaflags)
  522. ;
  523. end;
  524. procedure tcallparanode.printnodetree(var t:text);
  525. begin
  526. printnodelist(t);
  527. end;
  528. {****************************************************************************
  529. TCALLNODE
  530. ****************************************************************************}
  531. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
  532. begin
  533. inherited create(calln,l,nil);
  534. symtableprocentry:=v;
  535. symtableproc:=st;
  536. include(flags,nf_return_value_used);
  537. methodpointer:=mp;
  538. procdefinition:=nil;
  539. callnodeflags:=[];
  540. _funcretnode:=nil;
  541. inlinecode:=nil;
  542. paralength:=-1;
  543. varargsparas:=nil;
  544. end;
  545. constructor tcallnode.create_def(l:tnode;def:tprocdef;mp:tnode);
  546. begin
  547. inherited create(calln,l,nil);
  548. symtableprocentry:=nil;
  549. symtableproc:=nil;
  550. include(flags,nf_return_value_used);
  551. methodpointer:=mp;
  552. procdefinition:=def;
  553. callnodeflags:=[];
  554. _funcretnode:=nil;
  555. inlinecode:=nil;
  556. paralength:=-1;
  557. varargsparas:=nil;
  558. end;
  559. constructor tcallnode.create_procvar(l,r:tnode);
  560. begin
  561. inherited create(calln,l,r);
  562. symtableprocentry:=nil;
  563. symtableproc:=nil;
  564. include(flags,nf_return_value_used);
  565. methodpointer:=nil;
  566. procdefinition:=nil;
  567. callnodeflags:=[];
  568. _funcretnode:=nil;
  569. inlinecode:=nil;
  570. paralength:=-1;
  571. varargsparas:=nil;
  572. end;
  573. constructor tcallnode.createintern(const name: string; params: tnode);
  574. var
  575. srsym: tsym;
  576. symowner: tsymtable;
  577. begin
  578. if not (cs_compilesystem in aktmoduleswitches) then
  579. begin
  580. srsym := searchsymonlyin(systemunit,name);
  581. symowner := systemunit;
  582. end
  583. else
  584. begin
  585. searchsym(name,srsym,symowner);
  586. if not assigned(srsym) then
  587. searchsym(upper(name),srsym,symowner);
  588. end;
  589. if not assigned(srsym) or
  590. (srsym.typ <> procsym) then
  591. begin
  592. {$ifdef EXTDEBUG}
  593. Comment(V_Error,'unknown compilerproc '+name);
  594. {$endif EXTDEBUG}
  595. internalerror(200107271);
  596. end;
  597. self.create(params,tprocsym(srsym),symowner,nil);
  598. end;
  599. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  600. begin
  601. self.createintern(name,params);
  602. restype := res;
  603. include(callnodeflags,cnf_restypeset);
  604. { both the normal and specified resulttype either have to be returned via a }
  605. { parameter or not, but no mixing (JM) }
  606. if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
  607. paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  608. internalerror(200108291);
  609. end;
  610. constructor tcallnode.createinternreturn(const name: string; params: tnode; returnnode : tnode);
  611. begin
  612. self.createintern(name,params);
  613. _funcretnode:=returnnode;
  614. if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  615. internalerror(200204247);
  616. end;
  617. procedure tcallnode.setfuncretnode(const returnnode: tnode);
  618. var
  619. para: tcallparanode;
  620. begin
  621. if assigned(_funcretnode) then
  622. _funcretnode.free;
  623. _funcretnode := returnnode;
  624. { if the resulttype pass hasn't occurred yet, that one will do }
  625. { everything }
  626. if assigned(resulttype.def) then
  627. begin
  628. { these are returned as values, but we can optimize their loading }
  629. { as well }
  630. if is_ansistring(resulttype.def) or
  631. is_widestring(resulttype.def) then
  632. exit;
  633. para := tcallparanode(left);
  634. while assigned(para) do
  635. begin
  636. if para.paraitem.is_hidden and
  637. (vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) then
  638. begin
  639. para.left.free;
  640. para.left := _funcretnode.getcopy;
  641. exit;
  642. end;
  643. para := tcallparanode(para.right);
  644. end;
  645. { no hidden resultpara found, error! }
  646. internalerror(200306087);
  647. end;
  648. end;
  649. destructor tcallnode.destroy;
  650. begin
  651. methodpointer.free;
  652. _funcretnode.free;
  653. inlinecode.free;
  654. if assigned(varargsparas) then
  655. varargsparas.free;
  656. inherited destroy;
  657. end;
  658. constructor tcallnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  659. begin
  660. inherited ppuload(t,ppufile);
  661. ppufile.getderef(symtableprocentryderef);
  662. {$ifdef fpc}
  663. {$warning FIXME: No withsymtable support}
  664. {$endif}
  665. symtableproc:=nil;
  666. ppufile.getderef(procdefinitionderef);
  667. ppufile.getsmallset(callnodeflags);
  668. methodpointer:=ppuloadnode(ppufile);
  669. _funcretnode:=ppuloadnode(ppufile);
  670. inlinecode:=ppuloadnode(ppufile);
  671. end;
  672. procedure tcallnode.ppuwrite(ppufile:tcompilerppufile);
  673. begin
  674. inherited ppuwrite(ppufile);
  675. ppufile.putderef(symtableprocentryderef);
  676. ppufile.putderef(procdefinitionderef);
  677. ppufile.putsmallset(callnodeflags);
  678. ppuwritenode(ppufile,methodpointer);
  679. ppuwritenode(ppufile,_funcretnode);
  680. ppuwritenode(ppufile,inlinecode);
  681. end;
  682. procedure tcallnode.buildderefimpl;
  683. begin
  684. inherited buildderefimpl;
  685. symtableprocentryderef.build(symtableprocentry);
  686. procdefinitionderef.build(procdefinition);
  687. if assigned(methodpointer) then
  688. methodpointer.buildderefimpl;
  689. if assigned(_funcretnode) then
  690. _funcretnode.buildderefimpl;
  691. if assigned(inlinecode) then
  692. inlinecode.buildderefimpl;
  693. end;
  694. procedure tcallnode.derefimpl;
  695. var
  696. pt : tcallparanode;
  697. currpara : tparaitem;
  698. begin
  699. inherited derefimpl;
  700. symtableprocentry:=tprocsym(symtableprocentryderef.resolve);
  701. symtableproc:=symtableprocentry.owner;
  702. procdefinition:=tprocdef(procdefinitionderef.resolve);
  703. if assigned(methodpointer) then
  704. methodpointer.derefimpl;
  705. if assigned(_funcretnode) then
  706. _funcretnode.derefimpl;
  707. if assigned(inlinecode) then
  708. inlinecode.derefimpl;
  709. { Connect paraitems }
  710. pt:=tcallparanode(left);
  711. while assigned(pt) and
  712. (nf_varargs_para in pt.flags) do
  713. pt:=tcallparanode(pt.right);
  714. currpara:=tparaitem(procdefinition.Para.last);
  715. while assigned(currpara) do
  716. begin
  717. if not assigned(pt) then
  718. internalerror(200311077);
  719. pt.paraitem:=currpara;
  720. pt:=tcallparanode(pt.right);
  721. currpara:=tparaitem(currpara.previous);
  722. end;
  723. if assigned(currpara) or assigned(pt) then
  724. internalerror(200311078);
  725. end;
  726. function tcallnode.getcopy : tnode;
  727. var
  728. n : tcallnode;
  729. hp : tparaitem;
  730. begin
  731. n:=tcallnode(inherited getcopy);
  732. n.symtableprocentry:=symtableprocentry;
  733. n.symtableproc:=symtableproc;
  734. n.procdefinition:=procdefinition;
  735. n.restype := restype;
  736. n.callnodeflags := callnodeflags;
  737. if assigned(methodpointer) then
  738. n.methodpointer:=methodpointer.getcopy
  739. else
  740. n.methodpointer:=nil;
  741. if assigned(_funcretnode) then
  742. n._funcretnode:=_funcretnode.getcopy
  743. else
  744. n._funcretnode:=nil;
  745. if assigned(inlinecode) then
  746. n.inlinecode:=inlinecode.getcopy
  747. else
  748. n.inlinecode:=nil;
  749. if assigned(varargsparas) then
  750. begin
  751. n.varargsparas:=tvarargspara.create;
  752. hp:=tparaitem(varargsparas.first);
  753. while assigned(hp) do
  754. begin
  755. n.varargsparas.concat(hp.getcopy);
  756. hp:=tparaitem(hp.next);
  757. end;
  758. end
  759. else
  760. n.varargsparas:=nil;
  761. result:=n;
  762. end;
  763. procedure tcallnode.insertintolist(l : tnodelist);
  764. begin
  765. end;
  766. procedure tcallnode.convert_carg_array_of_const;
  767. var
  768. hp : tarrayconstructornode;
  769. oldleft : tcallparanode;
  770. begin
  771. oldleft:=tcallparanode(left);
  772. if oldleft.left.nodetype<>arrayconstructorn then
  773. begin
  774. CGMessage1(type_e_wrong_type_in_array_constructor,oldleft.left.resulttype.def.typename);
  775. exit;
  776. end;
  777. { Get arrayconstructor node and insert typeconvs }
  778. hp:=tarrayconstructornode(oldleft.left);
  779. hp.insert_typeconvs;
  780. { Add c args parameters }
  781. { It could be an empty set }
  782. if assigned(hp) and
  783. assigned(hp.left) then
  784. begin
  785. while assigned(hp) do
  786. begin
  787. left:=ccallparanode.create(hp.left,left);
  788. { set callparanode resulttype and flags }
  789. left.resulttype:=hp.left.resulttype;
  790. include(left.flags,nf_varargs_para);
  791. hp.left:=nil;
  792. hp:=tarrayconstructornode(hp.right);
  793. end;
  794. end;
  795. { Remove value of old array of const parameter, but keep it
  796. in the list because it is required for bind_paraitem.
  797. Generate a nothign to keep callparanoed.left valid }
  798. oldleft.left.free;
  799. oldleft.left:=cnothingnode.create;
  800. end;
  801. procedure tcallnode.verifyabstract(p : tnamedindexitem;arg:pointer);
  802. var
  803. hp : tprocdef;
  804. j: integer;
  805. begin
  806. if (tsym(p).typ=procsym) then
  807. begin
  808. for j:=1 to tprocsym(p).procdef_count do
  809. begin
  810. { index starts at 1 }
  811. hp:=tprocsym(p).procdef[j];
  812. { If this is an abstract method insert into the list }
  813. if (po_abstractmethod in hp.procoptions) then
  814. AbstractMethodsList.Insert(hp.procsym.name)
  815. else
  816. { If this symbol is already in the list, and it is
  817. an overriding method or dynamic, then remove it from the list
  818. }
  819. begin
  820. { symbol was found }
  821. if AbstractMethodsList.Find(hp.procsym.name) <> nil then
  822. begin
  823. if po_overridingmethod in hp.procoptions then
  824. AbstractMethodsList.Remove(hp.procsym.name);
  825. end;
  826. end;
  827. end;
  828. end;
  829. end;
  830. procedure tcallnode.verifyabstractcalls;
  831. var
  832. objectdf : tobjectdef;
  833. parents : tlinkedlist;
  834. objectinfo : tobjectinfoitem;
  835. stritem : tstringlistitem;
  836. begin
  837. objectdf := nil;
  838. { verify if trying to create an instance of a class which contains
  839. non-implemented abstract methods }
  840. { first verify this class type, no class than exit }
  841. { also, this checking can only be done if the constructor is directly
  842. called, indirect constructor calls cannot be checked.
  843. }
  844. if assigned(methodpointer) then
  845. begin
  846. if (methodpointer.resulttype.def.deftype = objectdef) then
  847. objectdf:=tobjectdef(methodpointer.resulttype.def)
  848. else
  849. if (methodpointer.resulttype.def.deftype = classrefdef) and
  850. (tclassrefdef(methodpointer.resulttype.def).pointertype.def.deftype = objectdef) and
  851. (methodpointer.nodetype in [typen,loadvmtaddrn]) then
  852. objectdf:=tobjectdef(tclassrefdef(methodpointer.resulttype.def).pointertype.def);
  853. end;
  854. if not assigned(objectdf) then
  855. exit;
  856. parents := tlinkedlist.create;
  857. AbstractMethodsList := tstringlist.create;
  858. { insert all parents in this class : the first item in the
  859. list will be the base parent of the class .
  860. }
  861. while assigned(objectdf) do
  862. begin
  863. objectinfo:=tobjectinfoitem.create(objectdf);
  864. parents.insert(objectinfo);
  865. objectdf := objectdf.childof;
  866. end;
  867. { now all parents are in the correct order
  868. insert all abstract methods in the list, and remove
  869. those which are overriden by parent classes.
  870. }
  871. objectinfo:=tobjectinfoitem(parents.first);
  872. while assigned(objectinfo) do
  873. begin
  874. objectdf := objectinfo.objinfo;
  875. if assigned(objectdf.symtable) then
  876. objectdf.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}verifyabstract,nil);
  877. objectinfo:=tobjectinfoitem(objectinfo.next);
  878. end;
  879. if assigned(parents) then
  880. parents.free;
  881. { Finally give out a warning for each abstract method still in the list }
  882. stritem := tstringlistitem(AbstractMethodsList.first);
  883. if assigned(stritem) then
  884. Message1(type_w_instance_with_abstract,objectdf.objname^);
  885. while assigned(stritem) do
  886. begin
  887. if assigned(stritem.fpstr) then
  888. Message1(sym_h_param_list,stritem.str);
  889. stritem := tstringlistitem(stritem.next);
  890. end;
  891. if assigned(AbstractMethodsList) then
  892. AbstractMethodsList.Free;
  893. end;
  894. function tcallnode.gen_self_tree_methodpointer:tnode;
  895. var
  896. hsym : tvarsym;
  897. begin
  898. { find self field in methodpointer record }
  899. hsym:=tvarsym(trecorddef(methodpointertype.def).symtable.search('self'));
  900. if not assigned(hsym) then
  901. internalerror(200305251);
  902. { Load tmehodpointer(right).self }
  903. result:=csubscriptnode.create(
  904. hsym,
  905. ctypeconvnode.create_explicit(right.getcopy,methodpointertype));
  906. end;
  907. function tcallnode.gen_self_tree:tnode;
  908. var
  909. selftree : tnode;
  910. begin
  911. selftree:=nil;
  912. { inherited }
  913. if (nf_inherited in flags) then
  914. selftree:=load_self_node
  915. else
  916. { constructors }
  917. if (procdefinition.proctypeoption=potype_constructor) then
  918. begin
  919. { push 0 as self when allocation is needed }
  920. if (methodpointer.resulttype.def.deftype=classrefdef) or
  921. (nf_new_call in flags) then
  922. selftree:=cpointerconstnode.create(0,voidpointertype)
  923. else
  924. begin
  925. if methodpointer.nodetype=typen then
  926. selftree:=load_self_node
  927. else
  928. selftree:=methodpointer.getcopy;
  929. end;
  930. end
  931. else
  932. { Calling a static/class method }
  933. if (po_classmethod in procdefinition.procoptions) or
  934. (po_staticmethod in procdefinition.procoptions) then
  935. begin
  936. if (procdefinition.deftype<>procdef) then
  937. internalerror(200305062);
  938. if (oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  939. begin
  940. { we only need the vmt, loading self is not required and there is no
  941. need to check for typen, because that will always get the
  942. loadvmtaddrnode added }
  943. selftree:=methodpointer.getcopy;
  944. if methodpointer.resulttype.def.deftype<>classrefdef then
  945. selftree:=cloadvmtaddrnode.create(selftree);
  946. end
  947. else
  948. selftree:=cpointerconstnode.create(0,voidpointertype);
  949. end
  950. else
  951. begin
  952. if methodpointer.nodetype=typen then
  953. selftree:=load_self_node
  954. else
  955. selftree:=methodpointer.getcopy;
  956. end;
  957. result:=selftree;
  958. end;
  959. function tcallnode.gen_vmt_tree:tnode;
  960. var
  961. vmttree : tnode;
  962. begin
  963. vmttree:=nil;
  964. if not(procdefinition.proctypeoption in [potype_constructor,potype_destructor]) then
  965. internalerror(200305051);
  966. { inherited call, no create/destroy }
  967. if (nf_inherited in flags) then
  968. vmttree:=cpointerconstnode.create(0,voidpointertype)
  969. else
  970. { do not create/destroy when called from member function
  971. without specifying self explicit }
  972. if (nf_member_call in flags) then
  973. begin
  974. if (methodpointer.resulttype.def.deftype=classrefdef) and
  975. (procdefinition.proctypeoption=potype_constructor) then
  976. vmttree:=methodpointer.getcopy
  977. else
  978. vmttree:=cpointerconstnode.create(0,voidpointertype);
  979. end
  980. else
  981. { constructor with extended syntax called from new }
  982. if (nf_new_call in flags) then
  983. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  984. else
  985. { destructor with extended syntax called from dispose }
  986. if (nf_dispose_call in flags) then
  987. vmttree:=cloadvmtaddrnode.create(methodpointer.getcopy)
  988. else
  989. if (methodpointer.resulttype.def.deftype=classrefdef) then
  990. begin
  991. { constructor call via classreference => allocate memory }
  992. if (procdefinition.proctypeoption=potype_constructor) and
  993. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  994. begin
  995. vmttree:=methodpointer.getcopy;
  996. { Only a typenode can be passed when it is called with <class of xx>.create }
  997. if vmttree.nodetype=typen then
  998. vmttree:=cloadvmtaddrnode.create(vmttree);
  999. end
  1000. else
  1001. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1002. end
  1003. else
  1004. { class }
  1005. if is_class(methodpointer.resulttype.def) then
  1006. begin
  1007. { destructor: release instance, flag(vmt)=1
  1008. constructor: direct call, do nothing, leave vmt=0 }
  1009. if (procdefinition.proctypeoption=potype_destructor) then
  1010. vmttree:=cpointerconstnode.create(1,voidpointertype)
  1011. else
  1012. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1013. end
  1014. else
  1015. { object }
  1016. begin
  1017. { destructor: direct call, no dispose, vmt=0
  1018. constructor: initialize object, load vmt }
  1019. if (procdefinition.proctypeoption=potype_constructor) then
  1020. { old styled inherited call? }
  1021. if (methodpointer.nodetype=typen) then
  1022. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1023. else
  1024. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1025. else
  1026. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1027. end;
  1028. result:=vmttree;
  1029. end;
  1030. procedure tcallnode.bind_paraitem;
  1031. var
  1032. i : integer;
  1033. pt : tcallparanode;
  1034. oldppt : ^tcallparanode;
  1035. varargspara,
  1036. currpara : tparaitem;
  1037. used_by_callnode : boolean;
  1038. hiddentree : tnode;
  1039. newstatement : tstatementnode;
  1040. temp : ttempcreatenode;
  1041. begin
  1042. pt:=tcallparanode(left);
  1043. oldppt:=@left;
  1044. { flag all callparanodes that belong to the varargs }
  1045. i:=paralength;
  1046. while (i>procdefinition.maxparacount) do
  1047. begin
  1048. include(pt.flags,nf_varargs_para);
  1049. oldppt:[email protected];
  1050. pt:=tcallparanode(pt.right);
  1051. dec(i);
  1052. end;
  1053. { skip varargs that are inserted by array of const }
  1054. while assigned(pt) and
  1055. (nf_varargs_para in pt.flags) do
  1056. pt:=tcallparanode(pt.right);
  1057. { process normal parameters and insert hidden parameters }
  1058. currpara:=tparaitem(procdefinition.Para.last);
  1059. while assigned(currpara) do
  1060. begin
  1061. if currpara.is_hidden then
  1062. begin
  1063. { generate hidden tree }
  1064. used_by_callnode:=false;
  1065. hiddentree:=nil;
  1066. if (vo_is_funcret in tvarsym(currpara.parasym).varoptions) then
  1067. begin
  1068. { Generate funcretnode if not specified }
  1069. if assigned(funcretnode) then
  1070. begin
  1071. hiddentree:=funcretnode.getcopy;
  1072. end
  1073. else
  1074. begin
  1075. hiddentree:=internalstatements(newstatement);
  1076. { need to use resulttype instead of procdefinition.rettype,
  1077. because they can be different }
  1078. temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
  1079. addstatement(newstatement,temp);
  1080. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  1081. addstatement(newstatement,ctemprefnode.create(temp));
  1082. end;
  1083. end
  1084. else
  1085. if vo_is_high_value in tvarsym(currpara.parasym).varoptions then
  1086. begin
  1087. if not assigned(pt) then
  1088. internalerror(200304082);
  1089. { we need the information of the next parameter }
  1090. hiddentree:=gen_high_tree(pt.left,is_open_string(tparaitem(currpara.previous).paratype.def));
  1091. end
  1092. else
  1093. if vo_is_self in tvarsym(currpara.parasym).varoptions then
  1094. begin
  1095. if assigned(right) then
  1096. hiddentree:=gen_self_tree_methodpointer
  1097. else
  1098. hiddentree:=gen_self_tree;
  1099. end
  1100. else
  1101. if vo_is_vmt in tvarsym(currpara.parasym).varoptions then
  1102. begin
  1103. hiddentree:=gen_vmt_tree;
  1104. end
  1105. else
  1106. if vo_is_parentfp in tvarsym(currpara.parasym).varoptions then
  1107. begin
  1108. if not(assigned(procdefinition.owner.defowner)) then
  1109. internalerror(200309287);
  1110. hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
  1111. end;
  1112. { add the hidden parameter }
  1113. if not assigned(hiddentree) then
  1114. internalerror(200304073);
  1115. { Already insert para and let the previous node point to
  1116. this new node }
  1117. pt:=ccallparanode.create(hiddentree,oldppt^);
  1118. pt.used_by_callnode:=used_by_callnode;
  1119. oldppt^:=pt;
  1120. end;
  1121. if not assigned(pt) then
  1122. internalerror(200310052);
  1123. pt.paraitem:=currpara;
  1124. oldppt:[email protected];
  1125. pt:=tcallparanode(pt.right);
  1126. currpara:=tparaitem(currpara.previous)
  1127. end;
  1128. { Create paraitems for varargs }
  1129. pt:=tcallparanode(left);
  1130. while assigned(pt) do
  1131. begin
  1132. if nf_varargs_para in pt.flags then
  1133. begin
  1134. if not assigned(varargsparas) then
  1135. varargsparas:=tvarargspara.create;
  1136. varargspara:=tparaitem.create;
  1137. varargspara.paratyp:=vs_value;
  1138. varargspara.paratype:=pt.resulttype;
  1139. { varargspara is left-right, use insert
  1140. instead of concat }
  1141. varargsparas.insert(varargspara);
  1142. pt.paraitem:=varargspara;
  1143. end;
  1144. pt:=tcallparanode(pt.right);
  1145. end;
  1146. end;
  1147. function tcallnode.det_resulttype:tnode;
  1148. var
  1149. candidates : tcallcandidates;
  1150. oldcallnode : tcallnode;
  1151. hpt : tnode;
  1152. pt : tcallparanode;
  1153. lastpara : longint;
  1154. currpara : tparaitem;
  1155. cand_cnt : integer;
  1156. i : longint;
  1157. method_must_be_valid,
  1158. is_const : boolean;
  1159. label
  1160. errorexit;
  1161. begin
  1162. result:=nil;
  1163. candidates:=nil;
  1164. oldcallnode:=aktcallnode;
  1165. aktcallnode:=nil;
  1166. { determine length of parameter list }
  1167. pt:=tcallparanode(left);
  1168. paralength:=0;
  1169. while assigned(pt) do
  1170. begin
  1171. inc(paralength);
  1172. pt:=tcallparanode(pt.right);
  1173. end;
  1174. { determine the type of the parameters }
  1175. if assigned(left) then
  1176. begin
  1177. tcallparanode(left).get_paratype;
  1178. if codegenerror then
  1179. goto errorexit;
  1180. end;
  1181. { procedure variable ? }
  1182. if assigned(right) then
  1183. begin
  1184. set_varstate(right,vs_used,true);
  1185. resulttypepass(right);
  1186. if codegenerror then
  1187. exit;
  1188. procdefinition:=tabstractprocdef(right.resulttype.def);
  1189. { Compare parameters from right to left }
  1190. currpara:=tparaitem(procdefinition.Para.last);
  1191. { Skip default parameters }
  1192. if not(po_varargs in procdefinition.procoptions) then
  1193. begin
  1194. { ignore hidden parameters }
  1195. while assigned(currpara) and (currpara.is_hidden) do
  1196. currpara:=tparaitem(currpara.previous);
  1197. for i:=1 to procdefinition.maxparacount-paralength do
  1198. begin
  1199. if not assigned(currpara) then
  1200. internalerror(200402261);
  1201. currpara:=tparaitem(currpara.previous);
  1202. end;
  1203. end;
  1204. while assigned(currpara) and (currpara.is_hidden) do
  1205. currpara:=tparaitem(currpara.previous);
  1206. pt:=tcallparanode(left);
  1207. lastpara:=paralength;
  1208. while assigned(currpara) and assigned(pt) do
  1209. begin
  1210. { only goto next para if we're out of the varargs }
  1211. if not(po_varargs in procdefinition.procoptions) or
  1212. (lastpara<=procdefinition.maxparacount) then
  1213. begin
  1214. repeat
  1215. currpara:=tparaitem(currpara.previous);
  1216. until (not assigned(currpara)) or (not currpara.is_hidden);
  1217. end;
  1218. pt:=tcallparanode(pt.right);
  1219. dec(lastpara);
  1220. end;
  1221. if assigned(pt) or
  1222. (assigned(currpara) and
  1223. not assigned(currpara.defaultvalue)) then
  1224. begin
  1225. if assigned(pt) then
  1226. aktfilepos:=pt.fileinfo;
  1227. CGMessage(parser_e_wrong_parameter_size);
  1228. goto errorexit;
  1229. end;
  1230. end
  1231. else
  1232. { not a procedure variable }
  1233. begin
  1234. { do we know the procedure to call ? }
  1235. if not(assigned(procdefinition)) then
  1236. begin
  1237. candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,(nf_isproperty in flags));
  1238. { no procedures found? then there is something wrong
  1239. with the parameter size or the procedures are
  1240. not accessible }
  1241. if candidates.count=0 then
  1242. begin
  1243. { when it's an auto inherited call and there
  1244. is no procedure found, but the procedures
  1245. were defined with overload directive and at
  1246. least two procedures are defined then we ignore
  1247. this inherited by inserting a nothingn. Only
  1248. do this ugly hack in Delphi mode as it looks more
  1249. like a bug. It's also not documented }
  1250. if (m_delphi in aktmodeswitches) and
  1251. (nf_anon_inherited in flags) and
  1252. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1253. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1254. (symtableprocentry.procdef_count>=2) then
  1255. result:=cnothingnode.create
  1256. else
  1257. begin
  1258. { in tp mode we can try to convert to procvar if
  1259. there are no parameters specified. Only try it
  1260. when there is only one proc definition, else the
  1261. loadnode will give a strange error }
  1262. if not(assigned(left)) and
  1263. not(nf_inherited in flags) and
  1264. (m_tp_procvar in aktmodeswitches) and
  1265. (symtableprocentry.procdef_count=1) then
  1266. begin
  1267. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1268. if assigned(methodpointer) then
  1269. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1270. resulttypepass(hpt);
  1271. result:=hpt;
  1272. end
  1273. else
  1274. begin
  1275. if assigned(left) then
  1276. aktfilepos:=left.fileinfo;
  1277. if paravisible then
  1278. begin
  1279. CGMessage(parser_e_wrong_parameter_size);
  1280. symtableprocentry.write_parameter_lists(nil);
  1281. end
  1282. else
  1283. CGMessage(parser_e_cant_access_private_member);
  1284. end;
  1285. end;
  1286. goto errorexit;
  1287. end;
  1288. { Retrieve information about the candidates }
  1289. candidates.get_information;
  1290. {$ifdef EXTDEBUG}
  1291. { Display info when multiple candidates are found }
  1292. if candidates.count>1 then
  1293. candidates.dump_info(V_Debug);
  1294. {$endif EXTDEBUG}
  1295. { Choose the best candidate and count the number of
  1296. candidates left }
  1297. cand_cnt:=candidates.choose_best(procdefinition);
  1298. { All parameters are checked, check if there are any
  1299. procedures left }
  1300. if cand_cnt>0 then
  1301. begin
  1302. { Multiple candidates left? }
  1303. if cand_cnt>1 then
  1304. begin
  1305. CGMessage(cg_e_cant_choose_overload_function);
  1306. {$ifdef EXTDEBUG}
  1307. candidates.dump_info(V_Hint);
  1308. {$else EXTDEBUG}
  1309. candidates.list(false);
  1310. {$endif EXTDEBUG}
  1311. { we'll just use the first candidate to make the
  1312. call }
  1313. end;
  1314. { assign procdefinition }
  1315. if symtableproc=nil then
  1316. symtableproc:=procdefinition.owner;
  1317. { update browser information }
  1318. if make_ref then
  1319. begin
  1320. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1321. inc(tprocdef(procdefinition).refcount);
  1322. if tprocdef(procdefinition).defref=nil then
  1323. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1324. end;
  1325. end
  1326. else
  1327. begin
  1328. { No candidates left, this must be a type error,
  1329. because wrong size is already checked. procdefinition
  1330. is filled with the first (random) definition that is
  1331. found. We use this definition to display a nice error
  1332. message that the wrong type is passed }
  1333. candidates.find_wrong_para;
  1334. candidates.list(true);
  1335. {$ifdef EXTDEBUG}
  1336. candidates.dump_info(V_Hint);
  1337. {$endif EXTDEBUG}
  1338. { We can not proceed, release all procs and exit }
  1339. candidates.free;
  1340. goto errorexit;
  1341. end;
  1342. candidates.free;
  1343. end; { end of procedure to call determination }
  1344. end;
  1345. { add needed default parameters }
  1346. if assigned(procdefinition) and
  1347. (paralength<procdefinition.maxparacount) then
  1348. begin
  1349. currpara:=tparaitem(procdefinition.Para.first);
  1350. i:=0;
  1351. while (i<paralength) do
  1352. begin
  1353. if not assigned(currpara) then
  1354. internalerror(200306181);
  1355. if not currpara.is_hidden then
  1356. inc(i);
  1357. currpara:=tparaitem(currpara.next);
  1358. end;
  1359. while assigned(currpara) and currpara.is_hidden do
  1360. currpara:=tparaitem(currpara.next);
  1361. while assigned(currpara) do
  1362. begin
  1363. if not assigned(currpara.defaultvalue) then
  1364. internalerror(200212142);
  1365. left:=ccallparanode.create(genconstsymtree(tconstsym(currpara.defaultvalue)),left);
  1366. { Ignore vs_hidden parameters }
  1367. repeat
  1368. currpara:=tparaitem(currpara.next);
  1369. until (not assigned(currpara)) or (not currpara.is_hidden);
  1370. end;
  1371. end;
  1372. { handle predefined procedures }
  1373. is_const:=(po_internconst in procdefinition.procoptions) and
  1374. ((block_type in [bt_const,bt_type]) or
  1375. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1376. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1377. begin
  1378. if assigned(left) then
  1379. begin
  1380. { ptr and settextbuf needs two args }
  1381. if assigned(tcallparanode(left).right) then
  1382. begin
  1383. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1384. left:=nil;
  1385. end
  1386. else
  1387. begin
  1388. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1389. tcallparanode(left).left:=nil;
  1390. end;
  1391. end
  1392. else
  1393. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1394. result:=hpt;
  1395. goto errorexit;
  1396. end;
  1397. { ensure that the result type is set }
  1398. if not(cnf_restypeset in callnodeflags) then
  1399. begin
  1400. { constructors return their current class type, not the type where the
  1401. constructor is declared, this can be different because of inheritance }
  1402. if (procdefinition.proctypeoption=potype_constructor) and
  1403. assigned(methodpointer) and
  1404. assigned(methodpointer.resulttype.def) and
  1405. (methodpointer.resulttype.def.deftype=classrefdef) then
  1406. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype
  1407. else
  1408. resulttype:=procdefinition.rettype;
  1409. end
  1410. else
  1411. resulttype:=restype;
  1412. if resulttype.def.needs_inittable then
  1413. include(current_procinfo.flags,pi_needs_implicit_finally);
  1414. if assigned(methodpointer) then
  1415. begin
  1416. resulttypepass(methodpointer);
  1417. { direct call to inherited abstract method, then we
  1418. can already give a error in the compiler instead
  1419. of a runtime error }
  1420. if (nf_inherited in flags) and
  1421. (po_abstractmethod in procdefinition.procoptions) then
  1422. CGMessage(cg_e_cant_call_abstract_method);
  1423. { if an inherited con- or destructor should be }
  1424. { called in a con- or destructor then a warning }
  1425. { will be made }
  1426. { con- and destructors need a pointer to the vmt }
  1427. if (nf_inherited in flags) and
  1428. (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1429. is_object(methodpointer.resulttype.def) and
  1430. not(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) then
  1431. CGMessage(cg_w_member_cd_call_from_method);
  1432. if methodpointer.nodetype<>typen then
  1433. begin
  1434. hpt:=methodpointer;
  1435. while assigned(hpt) and (hpt.nodetype in [subscriptn,vecn]) do
  1436. hpt:=tunarynode(hpt).left;
  1437. if (procdefinition.proctypeoption=potype_constructor) and
  1438. assigned(symtableproc) and
  1439. (symtableproc.symtabletype=withsymtable) and
  1440. (tnode(twithsymtable(symtableproc).withrefnode).nodetype=temprefn) then
  1441. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1442. { R.Init then R will be initialized by the constructor,
  1443. Also allow it for simple loads }
  1444. if (procdefinition.proctypeoption=potype_constructor) or
  1445. ((hpt.nodetype=loadn) and
  1446. (
  1447. (methodpointer.resulttype.def.deftype=classrefdef) or
  1448. (
  1449. (methodpointer.resulttype.def.deftype=objectdef) and
  1450. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1451. )
  1452. )
  1453. ) then
  1454. method_must_be_valid:=false
  1455. else
  1456. method_must_be_valid:=true;
  1457. set_varstate(methodpointer,vs_used,method_must_be_valid);
  1458. { The object is already used if it is called once }
  1459. if (hpt.nodetype=loadn) and
  1460. (tloadnode(hpt).symtableentry.typ=varsym) then
  1461. tvarsym(tloadnode(hpt).symtableentry).varstate:=vs_used;
  1462. end;
  1463. { if we are calling the constructor check for abstract
  1464. methods. Ignore inherited and member calls, because the
  1465. class is then already created }
  1466. if (procdefinition.proctypeoption=potype_constructor) and
  1467. not(nf_inherited in flags) and
  1468. not(nf_member_call in flags) then
  1469. verifyabstractcalls;
  1470. end
  1471. else
  1472. begin
  1473. { When this is method the methodpointer must be available }
  1474. if (right=nil) and
  1475. (procdefinition.owner.symtabletype=objectsymtable) then
  1476. internalerror(200305061);
  1477. end;
  1478. { Change loading of array of const to varargs }
  1479. if assigned(left) and
  1480. is_array_of_const(tparaitem(procdefinition.para.last).paratype.def) and
  1481. (procdefinition.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  1482. convert_carg_array_of_const;
  1483. { bind paraitems to the callparanodes and insert hidden parameters }
  1484. aktcallnode:=self;
  1485. bind_paraitem;
  1486. { methodpointer is only needed for virtual calls, and
  1487. it should then be loaded with the VMT }
  1488. if (po_virtualmethod in procdefinition.procoptions) and
  1489. not(assigned(methodpointer) and
  1490. (methodpointer.nodetype=typen)) then
  1491. begin
  1492. if not assigned(methodpointer) then
  1493. internalerror(200305063);
  1494. if (methodpointer.resulttype.def.deftype<>classrefdef) then
  1495. begin
  1496. methodpointer:=cloadvmtaddrnode.create(methodpointer);
  1497. resulttypepass(methodpointer);
  1498. end;
  1499. end
  1500. else
  1501. begin
  1502. { not needed anymore }
  1503. methodpointer.free;
  1504. methodpointer:=nil;
  1505. end;
  1506. { insert type conversions for parameters }
  1507. if assigned(left) then
  1508. tcallparanode(left).insert_typeconv(true);
  1509. errorexit:
  1510. aktcallnode:=oldcallnode;
  1511. end;
  1512. procedure tcallnode.order_parameters;
  1513. var
  1514. hp,hpcurr,hpnext,hpfirst,hpprev : tcallparanode;
  1515. currloc : tcgloc;
  1516. begin
  1517. hpfirst:=nil;
  1518. hpcurr:=tcallparanode(left);
  1519. while assigned(hpcurr) do
  1520. begin
  1521. { pull out }
  1522. hpnext:=tcallparanode(hpcurr.right);
  1523. { pull in at the correct place.
  1524. Used order:
  1525. 1. LOC_REFERENCE with smallest offset (x86 only)
  1526. 2. LOC_REFERENCE with most registers
  1527. 3. LOC_REGISTER with most registers }
  1528. currloc:=hpcurr.paraitem.paraloc[callerside].loc;
  1529. hpprev:=nil;
  1530. hp:=hpfirst;
  1531. while assigned(hp) do
  1532. begin
  1533. case currloc of
  1534. LOC_REFERENCE :
  1535. begin
  1536. case hp.paraitem.paraloc[callerside].loc of
  1537. LOC_REFERENCE :
  1538. begin
  1539. { Offset is calculated like:
  1540. sub esp,12
  1541. mov [esp+8],para3
  1542. mov [esp+4],para2
  1543. mov [esp],para1
  1544. call function
  1545. That means the for pushes the para with the
  1546. highest offset (see para3) needs to be pushed first
  1547. }
  1548. if (hpcurr.registersint>hp.registersint)
  1549. {$ifdef x86}
  1550. or (hpcurr.paraitem.paraloc[callerside].reference.offset>hp.paraitem.paraloc[callerside].reference.offset)
  1551. {$endif x86}
  1552. then
  1553. break;
  1554. end;
  1555. LOC_REGISTER,
  1556. LOC_FPUREGISTER :
  1557. break;
  1558. end;
  1559. end;
  1560. LOC_FPUREGISTER,
  1561. LOC_REGISTER :
  1562. begin
  1563. if (hp.paraitem.paraloc[callerside].loc=currloc) and
  1564. (hpcurr.registersint>hp.registersint) then
  1565. break;
  1566. end;
  1567. end;
  1568. hpprev:=hp;
  1569. hp:=tcallparanode(hp.right);
  1570. end;
  1571. hpcurr.right:=hp;
  1572. if assigned(hpprev) then
  1573. hpprev.right:=hpcurr
  1574. else
  1575. hpfirst:=hpcurr;
  1576. { next }
  1577. hpcurr:=hpnext;
  1578. end;
  1579. left:=hpfirst;
  1580. end;
  1581. function tcallnode.pass_1 : tnode;
  1582. {$ifdef m68k}
  1583. var
  1584. regi : tregister;
  1585. {$endif}
  1586. label
  1587. errorexit;
  1588. begin
  1589. result:=nil;
  1590. { calculate the parameter info for the procdef }
  1591. if not procdefinition.has_paraloc_info then
  1592. begin
  1593. procdefinition.requiredargarea:=paramanager.create_paraloc_info(procdefinition,callerside);
  1594. procdefinition.has_paraloc_info:=true;
  1595. end;
  1596. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,procdefinition.requiredargarea);
  1597. { calculate the parameter info for varargs }
  1598. if assigned(varargsparas) then
  1599. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,
  1600. paramanager.create_varargs_paraloc_info(procdefinition,varargsparas));
  1601. { work trough all parameters to get the register requirements }
  1602. if assigned(left) then
  1603. tcallparanode(left).det_registers;
  1604. { order parameters }
  1605. order_parameters;
  1606. { function result node }
  1607. if assigned(_funcretnode) then
  1608. firstpass(_funcretnode);
  1609. { procedure variable ? }
  1610. if assigned(right) then
  1611. begin
  1612. firstpass(right);
  1613. { procedure does a call }
  1614. if not (block_type in [bt_const,bt_type]) then
  1615. include(current_procinfo.flags,pi_do_call);
  1616. end
  1617. else
  1618. { not a procedure variable }
  1619. begin
  1620. { calc the correture value for the register }
  1621. { handle predefined procedures }
  1622. if (procdefinition.proccalloption=pocall_inline) then
  1623. begin
  1624. { inherit flags }
  1625. current_procinfo.flags:=current_procinfo.flags+((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  1626. if assigned(methodpointer) then
  1627. CGMessage(cg_e_unable_inline_object_methods);
  1628. if assigned(right) then
  1629. CGMessage(cg_e_unable_inline_procvar);
  1630. if not assigned(inlinecode) then
  1631. begin
  1632. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  1633. inlinecode:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  1634. else
  1635. CGMessage(cg_e_no_code_for_inline_stored);
  1636. if assigned(inlinecode) then
  1637. begin
  1638. { consider it has not inlined if called
  1639. again inside the args }
  1640. procdefinition.proccalloption:=pocall_default;
  1641. firstpass(inlinecode);
  1642. end;
  1643. end;
  1644. end
  1645. else
  1646. begin
  1647. if not (block_type in [bt_const,bt_type]) then
  1648. include(current_procinfo.flags,pi_do_call);
  1649. end;
  1650. end;
  1651. { get a register for the return value }
  1652. if (not is_void(resulttype.def)) then
  1653. begin
  1654. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1655. begin
  1656. expectloc:=LOC_REFERENCE;
  1657. end
  1658. else
  1659. { for win32 records returned in EDX:EAX, we
  1660. move them to memory after ... }
  1661. if (resulttype.def.deftype=recorddef) then
  1662. begin
  1663. expectloc:=LOC_CREFERENCE;
  1664. end
  1665. else
  1666. { ansi/widestrings must be registered, so we can dispose them }
  1667. if is_ansistring(resulttype.def) or
  1668. is_widestring(resulttype.def) then
  1669. begin
  1670. expectloc:=LOC_CREFERENCE;
  1671. registersint:=1;
  1672. end
  1673. else
  1674. { we have only to handle the result if it is used }
  1675. if (nf_return_value_used in flags) then
  1676. begin
  1677. case resulttype.def.deftype of
  1678. enumdef,
  1679. orddef :
  1680. begin
  1681. if (procdefinition.proctypeoption=potype_constructor) then
  1682. begin
  1683. expectloc:=LOC_REGISTER;
  1684. registersint:=1;
  1685. end
  1686. else
  1687. begin
  1688. expectloc:=LOC_REGISTER;
  1689. if is_64bit(resulttype.def) then
  1690. registersint:=2
  1691. else
  1692. registersint:=1;
  1693. end;
  1694. end;
  1695. floatdef :
  1696. begin
  1697. expectloc:=LOC_FPUREGISTER;
  1698. {$ifdef cpufpemu}
  1699. if (cs_fp_emulation in aktmoduleswitches) then
  1700. registersint:=1
  1701. else
  1702. {$endif cpufpemu}
  1703. {$ifdef m68k}
  1704. if (tfloatdef(resulttype.def).typ=s32real) then
  1705. registersint:=1
  1706. else
  1707. {$endif m68k}
  1708. registersfpu:=1;
  1709. end;
  1710. else
  1711. begin
  1712. expectloc:=LOC_REGISTER;
  1713. registersint:=1;
  1714. end;
  1715. end;
  1716. end
  1717. else
  1718. expectloc:=LOC_VOID;
  1719. end
  1720. else
  1721. expectloc:=LOC_VOID;
  1722. {$ifdef m68k}
  1723. { we need one more address register for virtual calls on m68k }
  1724. if (po_virtualmethod in procdefinition.procoptions) then
  1725. inc(registersint);
  1726. {$endif m68k}
  1727. { a fpu can be used in any procedure !! }
  1728. {$ifdef i386}
  1729. registersfpu:=procdefinition.fpu_used;
  1730. {$endif i386}
  1731. { if this is a call to a method calc the registers }
  1732. if (methodpointer<>nil) then
  1733. begin
  1734. if methodpointer.nodetype<>typen then
  1735. begin
  1736. firstpass(methodpointer);
  1737. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1738. registersint:=max(methodpointer.registersint,registersint);
  1739. {$ifdef SUPPORT_MMX }
  1740. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1741. {$endif SUPPORT_MMX}
  1742. end;
  1743. end;
  1744. { determine the registers of the procedure variable }
  1745. { is this OK for inlined procs also ?? (PM) }
  1746. if assigned(inlinecode) then
  1747. begin
  1748. registersfpu:=max(inlinecode.registersfpu,registersfpu);
  1749. registersint:=max(inlinecode.registersint,registersint);
  1750. {$ifdef SUPPORT_MMX}
  1751. registersmmx:=max(inlinecode.registersmmx,registersmmx);
  1752. {$endif SUPPORT_MMX}
  1753. end;
  1754. { determine the registers of the procedure variable }
  1755. { is this OK for inlined procs also ?? (PM) }
  1756. if assigned(right) then
  1757. begin
  1758. registersfpu:=max(right.registersfpu,registersfpu);
  1759. registersint:=max(right.registersint,registersint);
  1760. {$ifdef SUPPORT_MMX}
  1761. registersmmx:=max(right.registersmmx,registersmmx);
  1762. {$endif SUPPORT_MMX}
  1763. end;
  1764. { determine the registers of the procedure }
  1765. if assigned(left) then
  1766. begin
  1767. registersfpu:=max(left.registersfpu,registersfpu);
  1768. registersint:=max(left.registersint,registersint);
  1769. {$ifdef SUPPORT_MMX}
  1770. registersmmx:=max(left.registersmmx,registersmmx);
  1771. {$endif SUPPORT_MMX}
  1772. end;
  1773. errorexit:
  1774. if assigned(inlinecode) then
  1775. procdefinition.proccalloption:=pocall_inline;
  1776. end;
  1777. {$ifdef state_tracking}
  1778. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  1779. var hp:Tcallparanode;
  1780. value:Tnode;
  1781. begin
  1782. track_state_pass:=false;
  1783. hp:=Tcallparanode(left);
  1784. while assigned(hp) do
  1785. begin
  1786. if left.track_state_pass(exec_known) then
  1787. begin
  1788. left.resulttype.def:=nil;
  1789. do_resulttypepass(left);
  1790. end;
  1791. value:=aktstate.find_fact(hp.left);
  1792. if value<>nil then
  1793. begin
  1794. track_state_pass:=true;
  1795. hp.left.destroy;
  1796. hp.left:=value.getcopy;
  1797. do_resulttypepass(hp.left);
  1798. end;
  1799. hp:=Tcallparanode(hp.right);
  1800. end;
  1801. end;
  1802. {$endif}
  1803. function tcallnode.para_count:longint;
  1804. var
  1805. ppn : tcallparanode;
  1806. begin
  1807. result:=0;
  1808. ppn:=tcallparanode(left);
  1809. while assigned(ppn) do
  1810. begin
  1811. if not(assigned(ppn.paraitem) and
  1812. ppn.paraitem.is_hidden) then
  1813. inc(result);
  1814. ppn:=tcallparanode(ppn.right);
  1815. end;
  1816. end;
  1817. function tcallnode.docompare(p: tnode): boolean;
  1818. begin
  1819. docompare :=
  1820. inherited docompare(p) and
  1821. (symtableprocentry = tcallnode(p).symtableprocentry) and
  1822. (procdefinition = tcallnode(p).procdefinition) and
  1823. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  1824. (((cnf_restypeset in callnodeflags) and (cnf_restypeset in tcallnode(p).callnodeflags) and
  1825. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  1826. (not(cnf_restypeset in callnodeflags) and not(cnf_restypeset in tcallnode(p).callnodeflags)));
  1827. end;
  1828. procedure tcallnode.printnodedata(var t:text);
  1829. begin
  1830. if assigned(procdefinition) and
  1831. (procdefinition.deftype=procdef) then
  1832. writeln(t,printnodeindention,'proc = ',tprocdef(procdefinition).fullprocname(true))
  1833. else
  1834. begin
  1835. if assigned(symtableprocentry) then
  1836. writeln(t,printnodeindention,'proc = ',symtableprocentry.name)
  1837. else
  1838. writeln(t,printnodeindention,'proc = <nil>');
  1839. end;
  1840. printnode(t,methodpointer);
  1841. printnode(t,right);
  1842. printnode(t,left);
  1843. end;
  1844. begin
  1845. ccallnode:=tcallnode;
  1846. ccallparanode:=tcallparanode;
  1847. end.
  1848. {
  1849. $Log$
  1850. Revision 1.229 2004-02-26 16:09:49 peter
  1851. * fix procvars with default paras
  1852. Revision 1.228 2004/02/24 16:12:39 peter
  1853. * operator overload chooses rewrite
  1854. * overload choosing is now generic and moved to htypechk
  1855. Revision 1.227 2004/02/20 21:55:59 peter
  1856. * procvar cleanup
  1857. Revision 1.226 2004/02/19 17:07:42 florian
  1858. * fixed arg. area calculation
  1859. Revision 1.225 2004/02/13 15:42:21 peter
  1860. * compare_defs_ext has now a options argument
  1861. * fixes for variants
  1862. Revision 1.224 2004/02/12 15:54:03 peter
  1863. * make extcycle is working again
  1864. Revision 1.223 2004/02/05 01:24:08 florian
  1865. * several fixes to compile x86-64 system
  1866. Revision 1.222 2004/02/03 22:32:54 peter
  1867. * renamed xNNbittype to xNNinttype
  1868. * renamed registers32 to registersint
  1869. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1870. Revision 1.221 2004/01/26 16:12:27 daniel
  1871. * reginfo now also only allocated during register allocation
  1872. * third round of gdb cleanups: kick out most of concatstabto
  1873. Revision 1.220 2004/01/15 15:16:18 daniel
  1874. * Some minor stuff
  1875. * Managed to eliminate speed effects of string compression
  1876. Revision 1.219 2004/01/14 17:53:58 peter
  1877. * ignore hidden parameters when default parameters are used
  1878. Revision 1.218 2004/01/11 23:56:19 daniel
  1879. * Experiment: Compress strings to save memory
  1880. Did not save a single byte of mem; clearly the core size is boosted by
  1881. temporary memory usage...
  1882. Revision 1.217 2003/12/28 22:09:12 florian
  1883. + setting of bit 6 of cr for c var args on ppc implemented
  1884. Revision 1.216 2003/12/21 19:42:42 florian
  1885. * fixed ppc inlining stuff
  1886. * fixed wrong unit writing
  1887. + added some sse stuff
  1888. Revision 1.215 2003/12/20 12:38:51 florian
  1889. * some x86-64 compilation fixe
  1890. Revision 1.214 2003/12/16 22:09:31 florian
  1891. * better inheritence of procinfo flags of inlined procedures
  1892. Revision 1.213 2003/12/16 21:29:24 florian
  1893. + inlined procedures inherit procinfo flags
  1894. Revision 1.212 2003/12/08 22:37:28 peter
  1895. * paralength is private again
  1896. Revision 1.211 2003/12/08 16:34:23 peter
  1897. * varargspara is left-right, so adding paraitems needs insert
  1898. instead of concat
  1899. Revision 1.210 2003/12/01 18:44:15 peter
  1900. * fixed some crashes
  1901. * fixed varargs and register calling probs
  1902. Revision 1.209 2003/11/28 17:24:22 peter
  1903. * reversed offset calculation for caller side so it works
  1904. correctly for interfaces
  1905. Revision 1.208 2003/11/23 17:05:15 peter
  1906. * register calling is left-right
  1907. * parameter ordering
  1908. * left-right calling inserts result parameter last
  1909. Revision 1.207 2003/11/10 22:02:52 peter
  1910. * cross unit inlining fixed
  1911. Revision 1.206 2003/11/10 19:09:29 peter
  1912. * procvar default value support
  1913. Revision 1.205 2003/11/06 15:54:32 peter
  1914. * fixed calling classmethod for other object from classmethod
  1915. Revision 1.204 2003/11/01 16:17:48 peter
  1916. * use explicit typecast when generating the high value
  1917. Revision 1.203 2003/10/31 15:52:58 peter
  1918. * support creating classes using <class of tobject>.create
  1919. Revision 1.202 2003/10/30 16:23:13 peter
  1920. * don't search for overloads in parents for constructors
  1921. Revision 1.201 2003/10/29 22:01:20 florian
  1922. * fixed passing of dyn. arrays to open array parameters
  1923. Revision 1.200 2003/10/23 14:44:07 peter
  1924. * splitted buildderef and buildderefimpl to fix interface crc
  1925. calculation
  1926. Revision 1.199 2003/10/22 20:40:00 peter
  1927. * write derefdata in a separate ppu entry
  1928. Revision 1.198 2003/10/21 18:17:02 peter
  1929. * only search for overloaded constructors in classes
  1930. Revision 1.197 2003/10/21 15:14:55 peter
  1931. * also search in parents for overloads when calling a constructor
  1932. Revision 1.196 2003/10/13 14:05:12 peter
  1933. * removed is_visible_for_proc
  1934. * search also for class overloads when finding interface
  1935. implementations
  1936. Revision 1.195 2003/10/09 21:31:37 daniel
  1937. * Register allocator splitted, ans abstract now
  1938. Revision 1.194 2003/10/09 15:00:13 florian
  1939. * fixed constructor call in class methods
  1940. Revision 1.193 2003/10/08 19:19:45 peter
  1941. * set_varstate cleanup
  1942. Revision 1.192 2003/10/07 21:14:32 peter
  1943. * compare_paras() has a parameter to ignore hidden parameters
  1944. * cross unit overload searching ignores hidden parameters when
  1945. comparing parameter lists. Now function(string):string is
  1946. not overriden with procedure(string) which has the same visible
  1947. parameter list
  1948. Revision 1.191 2003/10/05 21:21:52 peter
  1949. * c style array of const generates callparanodes
  1950. * varargs paraloc fixes
  1951. Revision 1.190 2003/10/05 12:54:17 peter
  1952. * don't check for abstract methods when the constructor is called
  1953. by inherited
  1954. * fix private member error instead of wrong number of parameters
  1955. Revision 1.189 2003/10/04 19:00:52 florian
  1956. * fixed TP 6.0 styled inherited call; fixes IDE with 1.1
  1957. Revision 1.188 2003/10/03 22:00:33 peter
  1958. * parameter alignment fixes
  1959. Revision 1.187 2003/10/03 14:44:38 peter
  1960. * fix IE when callnode was firstpassed twice
  1961. Revision 1.186 2003/10/02 21:13:46 peter
  1962. * protected visibility fixes
  1963. Revision 1.185 2003/10/01 20:34:48 peter
  1964. * procinfo unit contains tprocinfo
  1965. * cginfo renamed to cgbase
  1966. * moved cgmessage to verbose
  1967. * fixed ppc and sparc compiles
  1968. Revision 1.184 2003/09/28 21:44:55 peter
  1969. * fix check that filedef needs var para
  1970. Revision 1.183 2003/09/28 17:55:03 peter
  1971. * parent framepointer changed to hidden parameter
  1972. * tloadparentfpnode added
  1973. Revision 1.182 2003/09/25 21:28:00 peter
  1974. * parameter fixes
  1975. Revision 1.181 2003/09/23 17:56:05 peter
  1976. * locals and paras are allocated in the code generation
  1977. * tvarsym.localloc contains the location of para/local when
  1978. generating code for the current procedure
  1979. Revision 1.180 2003/09/16 16:17:01 peter
  1980. * varspez in calls to push_addr_param
  1981. Revision 1.179 2003/09/07 22:09:35 peter
  1982. * preparations for different default calling conventions
  1983. * various RA fixes
  1984. Revision 1.178 2003/09/06 22:27:08 florian
  1985. * fixed web bug 2669
  1986. * cosmetic fix in printnode
  1987. * tobjectdef.gettypename implemented
  1988. Revision 1.177 2003/09/03 15:55:00 peter
  1989. * NEWRA branch merged
  1990. Revision 1.176.2.3 2003/08/31 21:07:44 daniel
  1991. * callparatemp ripped
  1992. Revision 1.176.2.2 2003/08/27 20:23:55 peter
  1993. * remove old ra code
  1994. Revision 1.176.2.1 2003/08/27 19:55:54 peter
  1995. * first tregister patch
  1996. Revision 1.176 2003/08/23 18:42:57 peter
  1997. * only check for size matches when parameter is enum,ord,float
  1998. Revision 1.175 2003/08/10 17:25:23 peter
  1999. * fixed some reported bugs
  2000. Revision 1.174 2003/07/25 09:54:57 jonas
  2001. * fixed bogus abstract method warnings
  2002. Revision 1.173 2003/06/25 18:31:23 peter
  2003. * sym,def resolving partly rewritten to support also parent objects
  2004. not directly available through the uses clause
  2005. Revision 1.172 2003/06/17 16:34:44 jonas
  2006. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  2007. * renamed all_intregisters to volatile_intregisters and made it
  2008. processor dependent
  2009. Revision 1.171 2003/06/15 16:47:33 jonas
  2010. * fixed revious commit
  2011. Revision 1.170 2003/06/15 15:10:57 jonas
  2012. * callparatemp fix: if a threadvar is a parameter, that paramter also
  2013. does a call
  2014. Revision 1.169 2003/06/13 21:19:30 peter
  2015. * current_procdef removed, use current_procinfo.procdef instead
  2016. Revision 1.168 2003/06/08 20:01:53 jonas
  2017. * optimized assignments with on the right side a function that returns
  2018. an ansi- or widestring
  2019. Revision 1.167 2003/06/08 18:27:15 jonas
  2020. + ability to change the location of a ttempref node with changelocation()
  2021. method. Useful to use instead of copying the contents from one temp to
  2022. another
  2023. + some shortstring optimizations in tassignmentnode that avoid some
  2024. copying (required some shortstring optimizations to be moved from
  2025. resulttype to firstpass, because they work on callnodes and string
  2026. addnodes are only changed to callnodes in the firstpass)
  2027. * allow setting/changing the funcretnode of callnodes after the
  2028. resulttypepass has been done, funcretnode is now a property
  2029. (all of the above should have a quite big effect on callparatemp)
  2030. Revision 1.166 2003/06/08 11:42:33 peter
  2031. * creating class with abstract call checking fixed
  2032. * there will be only one warning for each class, the methods
  2033. are listed as hint
  2034. Revision 1.165 2003/06/07 20:26:32 peter
  2035. * re-resolving added instead of reloading from ppu
  2036. * tderef object added to store deref info for resolving
  2037. Revision 1.164 2003/06/03 21:05:48 peter
  2038. * fix check for procedure without parameters
  2039. * calling constructor as member will not allocate memory
  2040. Revision 1.163 2003/06/03 13:01:59 daniel
  2041. * Register allocator finished
  2042. Revision 1.162 2003/05/26 21:17:17 peter
  2043. * procinlinenode removed
  2044. * aktexit2label removed, fast exit removed
  2045. + tcallnode.inlined_pass_2 added
  2046. Revision 1.161 2003/05/25 11:34:17 peter
  2047. * methodpointer self pushing fixed
  2048. Revision 1.160 2003/05/25 08:59:16 peter
  2049. * inline fixes
  2050. Revision 1.159 2003/05/24 17:16:37 jonas
  2051. * added missing firstpass for callparatemp code
  2052. Revision 1.158 2003/05/23 14:27:35 peter
  2053. * remove some unit dependencies
  2054. * current_procinfo changes to store more info
  2055. Revision 1.157 2003/05/17 14:05:58 jonas
  2056. * fixed callparatemp for ansi/widestring and interfacecoms
  2057. Revision 1.156 2003/05/17 13:30:08 jonas
  2058. * changed tt_persistant to tt_persistent :)
  2059. * tempcreatenode now doesn't accept a boolean anymore for persistent
  2060. temps, but a ttemptype, so you can also create ansistring temps etc
  2061. Revision 1.155 2003/05/16 14:33:31 peter
  2062. * regvar fixes
  2063. Revision 1.154 2003/05/14 19:35:50 jonas
  2064. * fixed callparatemp so it works with vs_var, vs_out and formal const
  2065. parameters
  2066. Revision 1.153 2003/05/13 20:53:41 peter
  2067. * constructors return in register
  2068. Revision 1.152 2003/05/13 15:18:49 peter
  2069. * fixed various crashes
  2070. Revision 1.151 2003/05/11 21:37:03 peter
  2071. * moved implicit exception frame from ncgutil to psub
  2072. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2073. Revision 1.150 2003/05/11 14:45:12 peter
  2074. * tloadnode does not support objectsymtable,withsymtable anymore
  2075. * withnode cleanup
  2076. * direct with rewritten to use temprefnode
  2077. Revision 1.149 2003/05/09 17:47:02 peter
  2078. * self moved to hidden parameter
  2079. * removed hdisposen,hnewn,selfn
  2080. Revision 1.148 2003/05/05 14:53:16 peter
  2081. * vs_hidden replaced by is_hidden boolean
  2082. Revision 1.147 2003/04/27 11:21:33 peter
  2083. * aktprocdef renamed to current_procinfo.procdef
  2084. * procinfo renamed to current_procinfo
  2085. * procinfo will now be stored in current_module so it can be
  2086. cleaned up properly
  2087. * gen_main_procsym changed to create_main_proc and release_main_proc
  2088. to also generate a tprocinfo structure
  2089. * fixed unit implicit initfinal
  2090. Revision 1.146 2003/04/27 09:08:44 jonas
  2091. * do callparatemp stuff only after the parameters have been firstpassed,
  2092. because some nodes are turned into calls during the firstpass
  2093. Revision 1.145 2003/04/27 07:29:50 peter
  2094. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2095. a new procdef declaration
  2096. * aktprocsym removed
  2097. * lexlevel removed, use symtable.symtablelevel instead
  2098. * implicit init/final code uses the normal genentry/genexit
  2099. * funcret state checking updated for new funcret handling
  2100. Revision 1.144 2003/04/25 20:59:33 peter
  2101. * removed funcretn,funcretsym, function result is now in varsym
  2102. and aliases for result and function name are added using absolutesym
  2103. * vs_hidden parameter for funcret passed in parameter
  2104. * vs_hidden fixes
  2105. * writenode changed to printnode and released from extdebug
  2106. * -vp option added to generate a tree.log with the nodetree
  2107. * nicer printnode for statements, callnode
  2108. Revision 1.143 2002/04/25 20:15:39 florian
  2109. * block nodes within expressions shouldn't release the used registers,
  2110. fixed using a flag till the new rg is ready
  2111. Revision 1.142 2003/04/23 20:16:04 peter
  2112. + added currency support based on int64
  2113. + is_64bit for use in cg units instead of is_64bitint
  2114. * removed cgmessage from n386add, replace with internalerrors
  2115. Revision 1.141 2003/04/23 13:21:06 peter
  2116. * fix warning for calling constructor inside constructor
  2117. Revision 1.140 2003/04/23 12:35:34 florian
  2118. * fixed several issues with powerpc
  2119. + applied a patch from Jonas for nested function calls (PowerPC only)
  2120. * ...
  2121. Revision 1.139 2003/04/22 23:50:22 peter
  2122. * firstpass uses expectloc
  2123. * checks if there are differences between the expectloc and
  2124. location.loc from secondpass in EXTDEBUG
  2125. Revision 1.138 2003/04/22 09:53:33 peter
  2126. * fix insert_typeconv to handle new varargs which don't have a
  2127. paraitem set
  2128. Revision 1.137 2003/04/11 16:02:05 peter
  2129. * don't firstpass typen
  2130. Revision 1.136 2003/04/11 15:51:04 peter
  2131. * support subscript,vec for setting methodpointer varstate
  2132. Revision 1.135 2003/04/10 17:57:52 peter
  2133. * vs_hidden released
  2134. Revision 1.134 2003/04/07 11:58:22 jonas
  2135. * more vs_invisible fixes
  2136. Revision 1.133 2003/04/07 10:40:21 jonas
  2137. * fixed VS_HIDDEN for high parameter so it works again
  2138. Revision 1.132 2003/04/04 15:38:56 peter
  2139. * moved generic code from n386cal to ncgcal, i386 now also
  2140. uses the generic ncgcal
  2141. Revision 1.131 2003/03/17 18:54:23 peter
  2142. * fix missing self setting for method to procvar conversion in
  2143. tp_procvar mode
  2144. Revision 1.130 2003/03/17 16:54:41 peter
  2145. * support DefaultHandler and anonymous inheritance fixed
  2146. for message methods
  2147. Revision 1.129 2003/03/17 15:54:22 peter
  2148. * store symoptions also for procdef
  2149. * check symoptions (private,public) when calculating possible
  2150. overload candidates
  2151. Revision 1.128 2003/02/19 22:00:14 daniel
  2152. * Code generator converted to new register notation
  2153. - Horribily outdated todo.txt removed
  2154. Revision 1.127 2003/01/16 22:13:52 peter
  2155. * convert_l3 convertlevel added. This level is used for conversions
  2156. where information can be lost like converting widestring->ansistring
  2157. or dword->byte
  2158. Revision 1.126 2003/01/15 01:44:32 peter
  2159. * merged methodpointer fixes from 1.0.x
  2160. Revision 1.125 2003/01/12 17:52:07 peter
  2161. * only check for auto inherited in objectsymtable
  2162. Revision 1.124 2003/01/09 21:45:46 peter
  2163. * extended information about overloaded candidates when compiled
  2164. with EXTDEBUG
  2165. Revision 1.123 2002/12/26 18:24:33 jonas
  2166. * fixed check for whether or not a high parameter was already generated
  2167. * no type checking/conversions for invisible parameters
  2168. Revision 1.122 2002/12/15 22:50:00 florian
  2169. + some stuff for the new hidden parameter handling added
  2170. Revision 1.121 2002/12/15 21:34:15 peter
  2171. * give sign difference between ordinals a small penalty. This is
  2172. needed to get word->[longword|longint] working
  2173. Revision 1.120 2002/12/15 21:30:12 florian
  2174. * tcallnode.paraitem introduced, all references to defcoll removed
  2175. Revision 1.119 2002/12/15 20:59:58 peter
  2176. * fix crash with default parameters
  2177. Revision 1.118 2002/12/15 11:26:02 peter
  2178. * ignore vs_hidden parameters when choosing overloaded proc
  2179. Revision 1.117 2002/12/11 22:42:28 peter
  2180. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2181. the old code. The new code collects the information about possible
  2182. candidates only once resultting in much less calls to type compare
  2183. routines
  2184. Revision 1.116 2002/12/07 14:27:07 carl
  2185. * 3% memory optimization
  2186. * changed some types
  2187. + added type checking with different size for call node and for
  2188. parameters
  2189. Revision 1.115 2002/12/06 17:51:10 peter
  2190. * merged cdecl and array fixes
  2191. Revision 1.114 2002/12/06 16:56:58 peter
  2192. * only compile cs_fp_emulation support when cpufpuemu is defined
  2193. * define cpufpuemu for m68k only
  2194. Revision 1.113 2002/11/27 20:04:38 peter
  2195. * cdecl array of const fixes
  2196. Revision 1.112 2002/11/27 15:33:46 peter
  2197. * the never ending story of tp procvar hacks
  2198. Revision 1.111 2002/11/27 02:31:17 peter
  2199. * fixed inlinetree parsing in det_resulttype
  2200. Revision 1.110 2002/11/25 18:43:32 carl
  2201. - removed the invalid if <> checking (Delphi is strange on this)
  2202. + implemented abstract warning on instance creation of class with
  2203. abstract methods.
  2204. * some error message cleanups
  2205. Revision 1.109 2002/11/25 17:43:17 peter
  2206. * splitted defbase in defutil,symutil,defcmp
  2207. * merged isconvertable and is_equal into compare_defs(_ext)
  2208. * made operator search faster by walking the list only once
  2209. Revision 1.108 2002/11/18 17:31:54 peter
  2210. * pass proccalloption to ret_in_xxx and push_xxx functions
  2211. Revision 1.107 2002/11/15 01:58:50 peter
  2212. * merged changes from 1.0.7 up to 04-11
  2213. - -V option for generating bug report tracing
  2214. - more tracing for option parsing
  2215. - errors for cdecl and high()
  2216. - win32 import stabs
  2217. - win32 records<=8 are returned in eax:edx (turned off by default)
  2218. - heaptrc update
  2219. - more info for temp management in .s file with EXTDEBUG
  2220. Revision 1.106 2002/10/14 18:20:30 carl
  2221. * var parameter checking for classes and interfaces in Delphi mode
  2222. Revision 1.105 2002/10/06 21:02:17 peter
  2223. * fixed limit checking for qword
  2224. Revision 1.104 2002/10/05 15:15:45 peter
  2225. * Write unknwon compiler proc using Comment and only in Extdebug
  2226. Revision 1.103 2002/10/05 12:43:25 carl
  2227. * fixes for Delphi 6 compilation
  2228. (warning : Some features do not work under Delphi)
  2229. Revision 1.102 2002/10/05 00:48:57 peter
  2230. * support inherited; support for overload as it is handled by
  2231. delphi. This is only for delphi mode as it is working is
  2232. undocumented and hard to predict what is done
  2233. Revision 1.101 2002/09/16 14:11:12 peter
  2234. * add argument to equal_paras() to support default values or not
  2235. Revision 1.100 2002/09/15 17:49:59 peter
  2236. * don't have strict var parameter checking for procedures in the
  2237. system unit
  2238. Revision 1.99 2002/09/09 19:30:34 peter
  2239. * don't allow convertable parameters for var and out parameters in
  2240. delphi and tp mode
  2241. Revision 1.98 2002/09/07 15:25:02 peter
  2242. * old logs removed and tabs fixed
  2243. Revision 1.97 2002/09/07 12:16:05 carl
  2244. * second part bug report 1996 fix, testrange in cordconstnode
  2245. only called if option is set (also make parsing a tiny faster)
  2246. Revision 1.96 2002/09/05 14:53:41 peter
  2247. * fixed old callnode.det_resulttype code
  2248. * old ncal code is default again
  2249. Revision 1.95 2002/09/03 21:32:49 daniel
  2250. * Small bugfix for procdef selection
  2251. Revision 1.94 2002/09/03 19:27:22 daniel
  2252. * Activated new ncal code
  2253. Revision 1.93 2002/09/03 16:26:26 daniel
  2254. * Make Tprocdef.defs protected
  2255. Revision 1.92 2002/09/01 13:28:37 daniel
  2256. - write_access fields removed in favor of a flag
  2257. Revision 1.91 2002/09/01 12:14:15 peter
  2258. * remove debug line
  2259. * containself methods can be called directly
  2260. Revision 1.90 2002/09/01 08:01:16 daniel
  2261. * Removed sets from Tcallnode.det_resulttype
  2262. + Added read/write notifications of variables. These will be usefull
  2263. for providing information for several optimizations. For example
  2264. the value of the loop variable of a for loop does matter is the
  2265. variable is read after the for loop, but if it's no longer used
  2266. or written, it doesn't matter and this can be used to optimize
  2267. the loop code generation.
  2268. Revision 1.89 2002/08/23 16:13:16 peter
  2269. * also firstpass funcretrefnode if available. This was breaking the
  2270. asnode compilerproc code
  2271. Revision 1.88 2002/08/20 10:31:26 daniel
  2272. * Tcallnode.det_resulttype rewritten
  2273. Revision 1.87 2002/08/19 19:36:42 peter
  2274. * More fixes for cross unit inlining, all tnodes are now implemented
  2275. * Moved pocall_internconst to po_internconst because it is not a
  2276. calling type at all and it conflicted when inlining of these small
  2277. functions was requested
  2278. Revision 1.86 2002/08/17 22:09:44 florian
  2279. * result type handling in tcgcal.pass_2 overhauled
  2280. * better tnode.dowrite
  2281. * some ppc stuff fixed
  2282. Revision 1.85 2002/08/17 09:23:34 florian
  2283. * first part of current_procinfo rewrite
  2284. Revision 1.84 2002/08/16 14:24:57 carl
  2285. * issameref() to test if two references are the same (then emit no opcodes)
  2286. + ret_in_reg to replace ret_in_acc
  2287. (fix some register allocation bugs at the same time)
  2288. + save_std_register now has an extra parameter which is the
  2289. usedinproc registers
  2290. Revision 1.83 2002/07/20 11:57:53 florian
  2291. * types.pas renamed to defbase.pas because D6 contains a types
  2292. unit so this would conflicts if D6 programms are compiled
  2293. + Willamette/SSE2 instructions to assembler added
  2294. Revision 1.82 2002/07/19 11:41:35 daniel
  2295. * State tracker work
  2296. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2297. allows the state tracker to change while nodes automatically into
  2298. repeat nodes.
  2299. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2300. 'not(a>b)' is optimized into 'a<=b'.
  2301. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2302. by removing the notn and later switchting the true and falselabels. The
  2303. same is done with 'repeat until not a'.
  2304. Revision 1.81 2002/07/15 18:03:14 florian
  2305. * readded removed changes
  2306. Revision 1.79 2002/07/11 14:41:27 florian
  2307. * start of the new generic parameter handling
  2308. Revision 1.80 2002/07/14 18:00:43 daniel
  2309. + Added the beginning of a state tracker. This will track the values of
  2310. variables through procedures and optimize things away.
  2311. Revision 1.78 2002/07/04 20:43:00 florian
  2312. * first x86-64 patches
  2313. }