ncal.pas 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512
  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,parabase,
  25. node,nbas,nutils,
  26. {$ifdef state_tracking}
  27. nstate,
  28. {$endif state_tracking}
  29. symbase,symtype,symsym,symdef,symtable;
  30. type
  31. tcallnodeflag = (
  32. cnf_restypeset,
  33. cnf_return_value_used,
  34. cnf_inherited,
  35. cnf_anon_inherited,
  36. cnf_new_call,
  37. cnf_dispose_call,
  38. cnf_member_call { called with implicit methodpointer tree }
  39. );
  40. tcallnodeflags = set of tcallnodeflag;
  41. tcallnode = class(tbinarynode)
  42. private
  43. {$ifndef VER1_0}
  44. { info for inlining }
  45. inlinelocals: array of tnode;
  46. {$endif VER1_0}
  47. { number of parameters passed from the source, this does not include the hidden parameters }
  48. paralength : smallint;
  49. function gen_self_tree_methodpointer:tnode;
  50. function gen_self_tree:tnode;
  51. function gen_vmt_tree:tnode;
  52. procedure bind_paraitem;
  53. { function return node, this is used to pass the data for a
  54. ret_in_param return value }
  55. _funcretnode : tnode;
  56. procedure setfuncretnode(const returnnode: tnode);
  57. procedure convert_carg_array_of_const;
  58. procedure order_parameters;
  59. procedure createinlineparas(var createstatement, deletestatement: tstatementnode);
  60. function replaceparaload(var n: tnode; arg: pointer): foreachnoderesult;
  61. {$ifndef VER1_0}
  62. procedure createlocaltemps(p:TNamedIndexItem;arg:pointer);
  63. {$endif VER1_0}
  64. protected
  65. pushedparasize : longint;
  66. public
  67. { the symbol containing the definition of the procedure }
  68. { to call }
  69. symtableprocentry : tprocsym;
  70. symtableprocentryderef : tderef;
  71. { symtable where the entry was found, needed for with support }
  72. symtableproc : tsymtable;
  73. { the definition of the procedure to call }
  74. procdefinition : tabstractprocdef;
  75. procdefinitionderef : tderef;
  76. { tree that contains the pointer to the object for this method }
  77. methodpointerinit,
  78. methodpointerdone : tblocknode;
  79. methodpointer : tnode;
  80. { inline function body }
  81. inlinecode : tnode;
  82. { varargs tparaitems }
  83. varargsparas : tvarargspara;
  84. { node that specifies where the result should be put for calls }
  85. { that return their result in a parameter }
  86. property funcretnode: tnode read _funcretnode write setfuncretnode;
  87. { separately specified resulttype for some compilerprocs (e.g. }
  88. { you can't have a function with an "array of char" resulttype }
  89. { the RTL) (JM) }
  90. restype: ttype;
  91. callnodeflags : tcallnodeflags;
  92. { only the processor specific nodes need to override this }
  93. { constructor }
  94. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp: tnode; callflags:tcallnodeflags);virtual;
  95. constructor create_procvar(l,r:tnode);
  96. constructor createintern(const name: string; params: tnode);
  97. constructor createinternres(const name: string; params: tnode; const res: ttype);
  98. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  99. destructor destroy;override;
  100. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  101. procedure ppuwrite(ppufile:tcompilerppufile);override;
  102. procedure buildderefimpl;override;
  103. procedure derefimpl;override;
  104. function getcopy : tnode;override;
  105. { Goes through all symbols in a class and subclasses and calls
  106. verify abstract for each .
  107. }
  108. procedure verifyabstractcalls;
  109. { called for each definition in a class and verifies if a method
  110. is abstract or not, if it is abstract, give out a warning
  111. }
  112. procedure verifyabstract(p : tnamedindexitem;arg:pointer);
  113. procedure insertintolist(l : tnodelist);override;
  114. function pass_1 : tnode;override;
  115. function det_resulttype:tnode;override;
  116. {$ifdef state_tracking}
  117. function track_state_pass(exec_known:boolean):boolean;override;
  118. {$endif state_tracking}
  119. function docompare(p: tnode): boolean; override;
  120. procedure printnodedata(var t:text);override;
  121. function para_count:longint;
  122. private
  123. AbstractMethodsList : TStringList;
  124. end;
  125. tcallnodeclass = class of tcallnode;
  126. tcallparaflag = (
  127. cpf_is_colon_para,
  128. cpf_varargs_para { belongs this para to varargs }
  129. );
  130. tcallparaflags = set of tcallparaflag;
  131. tcallparanode = class(tbinarynode)
  132. public
  133. callparaflags : tcallparaflags;
  134. paraitem : tparaitem;
  135. used_by_callnode : boolean;
  136. { only the processor specific nodes need to override this }
  137. { constructor }
  138. constructor create(expr,next : tnode);virtual;
  139. destructor destroy;override;
  140. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  141. procedure ppuwrite(ppufile:tcompilerppufile);override;
  142. function getcopy : tnode;override;
  143. procedure insertintolist(l : tnodelist);override;
  144. procedure get_paratype;
  145. procedure insert_typeconv(do_count : boolean);
  146. procedure det_registers;
  147. procedure firstcallparan;
  148. procedure secondcallparan;virtual;abstract;
  149. function docompare(p: tnode): boolean; override;
  150. procedure printnodetree(var t:text);override;
  151. end;
  152. tcallparanodeclass = class of tcallparanode;
  153. function reverseparameters(p: tcallparanode): tcallparanode;
  154. var
  155. ccallnode : tcallnodeclass;
  156. ccallparanode : tcallparanodeclass;
  157. { Current callnode, this is needed for having a link
  158. between the callparanodes and the callnode they belong to }
  159. aktcallnode : tcallnode;
  160. implementation
  161. uses
  162. systems,
  163. verbose,globals,
  164. symconst,defutil,defcmp,
  165. htypechk,pass_1,
  166. ncnv,nld,ninl,nadd,ncon,nmem,
  167. procinfo,
  168. cgbase
  169. ;
  170. type
  171. tobjectinfoitem = class(tlinkedlistitem)
  172. objinfo : tobjectdef;
  173. constructor create(def : tobjectdef);
  174. end;
  175. {****************************************************************************
  176. HELPERS
  177. ****************************************************************************}
  178. function reverseparameters(p: tcallparanode): tcallparanode;
  179. var
  180. hp1, hp2: tcallparanode;
  181. begin
  182. hp1:=nil;
  183. while assigned(p) do
  184. begin
  185. { pull out }
  186. hp2:=p;
  187. p:=tcallparanode(p.right);
  188. { pull in }
  189. hp2.right:=hp1;
  190. hp1:=hp2;
  191. end;
  192. reverseparameters:=hp1;
  193. end;
  194. procedure maybe_load_para_in_temp(var p:tnode);
  195. var
  196. hp : tnode;
  197. ptemp : ttempcreatenode;
  198. newinitstatement,
  199. newdonestatement : tstatementnode;
  200. begin
  201. if not assigned(aktcallnode) then
  202. internalerror(200410121);
  203. hp:=p;
  204. while assigned(hp) and
  205. (hp.nodetype=typeconvn) do
  206. hp:=tunarynode(hp).left;
  207. if assigned(hp) and
  208. (
  209. { call result must always be loaded in temp to prevent
  210. double creation }
  211. (hp.nodetype=calln)
  212. { Also optimize also complex loads }
  213. {$warning Complex loads can also be optimized}
  214. // or not(hp.nodetype in [typen,loadvmtaddrn,loadn])
  215. ) then
  216. begin
  217. if not assigned(aktcallnode.methodpointerinit) then
  218. begin
  219. aktcallnode.methodpointerinit:=internalstatements(newinitstatement);
  220. aktcallnode.methodpointerdone:=internalstatements(newdonestatement);
  221. end
  222. else
  223. begin
  224. newinitstatement:=laststatement(aktcallnode.methodpointerinit);
  225. newdonestatement:=laststatement(aktcallnode.methodpointerdone);
  226. end;
  227. { temp create }
  228. ptemp:=ctempcreatenode.create_reg(p.resulttype,p.resulttype.def.size,tt_persistent);
  229. addstatement(newinitstatement,ptemp);
  230. addstatement(newinitstatement,cassignmentnode.create(
  231. ctemprefnode.create(ptemp),
  232. p));
  233. resulttypepass(aktcallnode.methodpointerinit);
  234. { new tree is only a temp reference }
  235. p:=ctemprefnode.create(ptemp);
  236. resulttypepass(p);
  237. { temp release }
  238. addstatement(newdonestatement,ctempdeletenode.create(ptemp));
  239. resulttypepass(aktcallnode.methodpointerdone);
  240. end;
  241. end;
  242. function gen_high_tree(var p:tnode;paradef:tdef):tnode;
  243. var
  244. temp: tnode;
  245. len : integer;
  246. loadconst : boolean;
  247. hightree : tnode;
  248. begin
  249. len:=-1;
  250. loadconst:=true;
  251. hightree:=nil;
  252. case p.resulttype.def.deftype of
  253. arraydef :
  254. begin
  255. if (paradef.deftype<>arraydef) then
  256. internalerror(200405241);
  257. { handle special case of passing an single array to an array of array }
  258. if compare_defs(tarraydef(paradef).elementtype.def,p.resulttype.def,nothingn)>=te_equal then
  259. len:=0
  260. else
  261. begin
  262. maybe_load_para_in_temp(p);
  263. { handle via a normal inline in_high_x node }
  264. loadconst := false;
  265. hightree := geninlinenode(in_high_x,false,p.getcopy);
  266. resulttypepass(hightree);
  267. { only substract low(array) if it's <> 0 }
  268. temp := geninlinenode(in_low_x,false,p.getcopy);
  269. resulttypepass(temp);
  270. if (temp.nodetype <> ordconstn) or
  271. (tordconstnode(temp).value <> 0) then
  272. hightree := caddnode.create(subn,hightree,temp)
  273. else
  274. temp.free;
  275. end;
  276. end;
  277. stringdef :
  278. begin
  279. if is_open_string(paradef) then
  280. begin
  281. maybe_load_para_in_temp(p);
  282. { handle via a normal inline in_high_x node }
  283. loadconst := false;
  284. hightree := geninlinenode(in_high_x,false,p.getcopy);
  285. end
  286. else
  287. begin
  288. { passing a string to an array of char }
  289. if (p.nodetype=stringconstn) then
  290. begin
  291. len:=str_length(p);
  292. if len>0 then
  293. dec(len);
  294. end
  295. else
  296. begin
  297. maybe_load_para_in_temp(p);
  298. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
  299. cordconstnode.create(1,s32inttype,false));
  300. loadconst:=false;
  301. end;
  302. end;
  303. end;
  304. else
  305. len:=0;
  306. end;
  307. if loadconst then
  308. hightree:=cordconstnode.create(len,s32inttype,true)
  309. else
  310. begin
  311. if not assigned(hightree) then
  312. internalerror(200304071);
  313. { Need to use explicit, because it can also be a enum }
  314. hightree:=ctypeconvnode.create_explicit(hightree,s32inttype);
  315. end;
  316. result:=hightree;
  317. end;
  318. {****************************************************************************
  319. TOBJECTINFOITEM
  320. ****************************************************************************}
  321. constructor tobjectinfoitem.create(def : tobjectdef);
  322. begin
  323. inherited create;
  324. objinfo := def;
  325. end;
  326. {****************************************************************************
  327. TCALLPARANODE
  328. ****************************************************************************}
  329. constructor tcallparanode.create(expr,next : tnode);
  330. begin
  331. inherited create(callparan,expr,next);
  332. if not assigned(expr) then
  333. internalerror(200305091);
  334. expr.set_file_line(self);
  335. callparaflags:=[];
  336. end;
  337. destructor tcallparanode.destroy;
  338. begin
  339. { When the node is used by callnode then
  340. we don't destroy left, the callnode takes care of it }
  341. if used_by_callnode then
  342. left:=nil;
  343. inherited destroy;
  344. end;
  345. constructor tcallparanode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  346. begin
  347. inherited ppuload(t,ppufile);
  348. ppufile.getsmallset(callparaflags);
  349. end;
  350. procedure tcallparanode.ppuwrite(ppufile:tcompilerppufile);
  351. begin
  352. inherited ppuwrite(ppufile);
  353. ppufile.putsmallset(callparaflags);
  354. end;
  355. function tcallparanode.getcopy : tnode;
  356. var
  357. n : tcallparanode;
  358. begin
  359. n:=tcallparanode(inherited getcopy);
  360. n.callparaflags:=callparaflags;
  361. n.paraitem:=paraitem;
  362. result:=n;
  363. end;
  364. procedure tcallparanode.insertintolist(l : tnodelist);
  365. begin
  366. end;
  367. procedure tcallparanode.get_paratype;
  368. var
  369. old_array_constructor : boolean;
  370. begin
  371. inc(parsing_para_level);
  372. if assigned(right) then
  373. tcallparanode(right).get_paratype;
  374. old_array_constructor:=allow_array_constructor;
  375. allow_array_constructor:=true;
  376. resulttypepass(left);
  377. allow_array_constructor:=old_array_constructor;
  378. if codegenerror then
  379. resulttype:=generrortype
  380. else
  381. resulttype:=left.resulttype;
  382. dec(parsing_para_level);
  383. end;
  384. procedure tcallparanode.insert_typeconv(do_count : boolean);
  385. var
  386. oldtype : ttype;
  387. {$ifdef extdebug}
  388. store_count_ref : boolean;
  389. {$endif def extdebug}
  390. begin
  391. inc(parsing_para_level);
  392. {$ifdef extdebug}
  393. if do_count then
  394. begin
  395. store_count_ref:=count_ref;
  396. count_ref:=true;
  397. end;
  398. {$endif def extdebug}
  399. { Be sure to have the resulttype }
  400. if not assigned(left.resulttype.def) then
  401. resulttypepass(left);
  402. if (left.nodetype<>nothingn) then
  403. begin
  404. { Convert tp procvars, this is needs to be done
  405. here to make the change permanent. in the overload
  406. choosing the changes are only made temporary }
  407. if (left.resulttype.def.deftype=procvardef) and
  408. (paraitem.paratype.def.deftype<>procvardef) then
  409. begin
  410. if maybe_call_procvar(left,true) then
  411. resulttype:=left.resulttype;
  412. end;
  413. { Handle varargs and hidden paras directly, no typeconvs or }
  414. { typechecking needed }
  415. if (cpf_varargs_para in callparaflags) then
  416. begin
  417. { convert pascal to C types }
  418. case left.resulttype.def.deftype of
  419. stringdef :
  420. inserttypeconv(left,charpointertype);
  421. floatdef :
  422. inserttypeconv(left,s64floattype);
  423. end;
  424. set_varstate(left,vs_used,true);
  425. resulttype:=left.resulttype;
  426. { also update paraitem type to get the correct parameter location
  427. for the new types }
  428. paraitem.paratype:=left.resulttype;
  429. end
  430. else
  431. if (paraitem.is_hidden) then
  432. begin
  433. set_varstate(left,vs_used,true);
  434. resulttype:=left.resulttype;
  435. end
  436. else
  437. begin
  438. { Do we need arrayconstructor -> set conversion, then insert
  439. it here before the arrayconstructor node breaks the tree
  440. with its conversions of enum->ord }
  441. if (left.nodetype=arrayconstructorn) and
  442. (paraitem.paratype.def.deftype=setdef) then
  443. inserttypeconv(left,paraitem.paratype);
  444. { set some settings needed for arrayconstructor }
  445. if is_array_constructor(left.resulttype.def) then
  446. begin
  447. if is_array_of_const(paraitem.paratype.def) then
  448. begin
  449. { force variant array }
  450. include(left.flags,nf_forcevaria);
  451. end
  452. else
  453. begin
  454. include(left.flags,nf_novariaallowed);
  455. { now that the resultting type is know we can insert the required
  456. typeconvs for the array constructor }
  457. if paraitem.paratype.def.deftype=arraydef then
  458. tarrayconstructornode(left).force_type(tarraydef(paraitem.paratype.def).elementtype);
  459. end;
  460. end;
  461. { check if local proc/func is assigned to procvar }
  462. if left.resulttype.def.deftype=procvardef then
  463. test_local_to_procvar(tprocvardef(left.resulttype.def),paraitem.paratype.def);
  464. { test conversions }
  465. if not(is_shortstring(left.resulttype.def) and
  466. is_shortstring(paraitem.paratype.def)) and
  467. (paraitem.paratype.def.deftype<>formaldef) then
  468. begin
  469. { Process open parameters }
  470. if paramanager.push_high_param(paraitem.paratyp,paraitem.paratype.def,aktcallnode.procdefinition.proccalloption) then
  471. begin
  472. { insert type conv but hold the ranges of the array }
  473. oldtype:=left.resulttype;
  474. inserttypeconv(left,paraitem.paratype);
  475. left.resulttype:=oldtype;
  476. end
  477. else
  478. begin
  479. { for ordinals, floats and enums, verify if we might cause
  480. some range-check errors. }
  481. if (paraitem.paratype.def.deftype in [enumdef,orddef,floatdef]) and
  482. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) and
  483. (left.nodetype in [vecn,loadn,calln]) then
  484. begin
  485. if (left.resulttype.def.size>paraitem.paratype.def.size) then
  486. begin
  487. if (cs_check_range in aktlocalswitches) then
  488. Message(type_w_smaller_possible_range_check)
  489. else
  490. Message(type_h_smaller_possible_range_check);
  491. end;
  492. end;
  493. inserttypeconv(left,paraitem.paratype);
  494. end;
  495. if codegenerror then
  496. begin
  497. dec(parsing_para_level);
  498. exit;
  499. end;
  500. end;
  501. { check var strings }
  502. if (cs_strict_var_strings in aktlocalswitches) and
  503. is_shortstring(left.resulttype.def) and
  504. is_shortstring(paraitem.paratype.def) and
  505. (paraitem.paratyp in [vs_out,vs_var]) and
  506. not(is_open_string(paraitem.paratype.def)) and
  507. not(equal_defs(left.resulttype.def,paraitem.paratype.def)) then
  508. begin
  509. aktfilepos:=left.fileinfo;
  510. CGMessage(type_e_strict_var_string_violation);
  511. end;
  512. { Handle formal parameters separate }
  513. if (paraitem.paratype.def.deftype=formaldef) then
  514. begin
  515. { load procvar if a procedure is passed }
  516. if (m_tp_procvar in aktmodeswitches) and
  517. (left.nodetype=calln) and
  518. (is_void(left.resulttype.def)) then
  519. load_procvar_from_calln(left);
  520. case paraitem.paratyp of
  521. vs_var,
  522. vs_out :
  523. begin
  524. if not valid_for_formal_var(left) then
  525. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  526. end;
  527. vs_const :
  528. begin
  529. if not valid_for_formal_const(left) then
  530. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  531. end;
  532. end;
  533. end
  534. else
  535. begin
  536. { check if the argument is allowed }
  537. if (paraitem.paratyp in [vs_out,vs_var]) then
  538. valid_for_var(left);
  539. end;
  540. if paraitem.paratyp = vs_var then
  541. set_unique(left);
  542. { When the address needs to be pushed then the register is
  543. not regable. Exception is when the location is also a var
  544. parameter and we can pass the address transparently }
  545. if (
  546. not(
  547. paraitem.is_hidden and
  548. (left.resulttype.def.deftype in [pointerdef,classrefdef])
  549. ) and
  550. paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,
  551. aktcallnode.procdefinition.proccalloption) and
  552. not(
  553. (left.nodetype=loadn) and
  554. (tloadnode(left).is_addr_param_load)
  555. )
  556. ) then
  557. make_not_regable(left);
  558. if do_count then
  559. begin
  560. if paraitem.paratyp in [vs_var,vs_out] then
  561. set_varstate(left,vs_used,false)
  562. else
  563. set_varstate(left,vs_used,true);
  564. end;
  565. { must only be done after typeconv PM }
  566. resulttype:=paraitem.paratype;
  567. end;
  568. end;
  569. { process next node }
  570. if assigned(right) then
  571. tcallparanode(right).insert_typeconv(do_count);
  572. dec(parsing_para_level);
  573. {$ifdef extdebug}
  574. if do_count then
  575. count_ref:=store_count_ref;
  576. {$endif def extdebug}
  577. end;
  578. procedure tcallparanode.det_registers;
  579. begin
  580. if assigned(right) then
  581. begin
  582. tcallparanode(right).det_registers;
  583. registersint:=right.registersint;
  584. registersfpu:=right.registersfpu;
  585. {$ifdef SUPPORT_MMX}
  586. registersmmx:=right.registersmmx;
  587. {$endif}
  588. end;
  589. firstpass(left);
  590. if left.registersint>registersint then
  591. registersint:=left.registersint;
  592. if left.registersfpu>registersfpu then
  593. registersfpu:=left.registersfpu;
  594. {$ifdef SUPPORT_MMX}
  595. if left.registersmmx>registersmmx then
  596. registersmmx:=left.registersmmx;
  597. {$endif SUPPORT_MMX}
  598. end;
  599. procedure tcallparanode.firstcallparan;
  600. begin
  601. if not assigned(left.resulttype.def) then
  602. get_paratype;
  603. det_registers;
  604. end;
  605. function tcallparanode.docompare(p: tnode): boolean;
  606. begin
  607. docompare :=
  608. inherited docompare(p) and
  609. (callparaflags = tcallparanode(p).callparaflags)
  610. ;
  611. end;
  612. procedure tcallparanode.printnodetree(var t:text);
  613. begin
  614. printnodelist(t);
  615. end;
  616. {****************************************************************************
  617. TCALLNODE
  618. ****************************************************************************}
  619. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp: tnode; callflags:tcallnodeflags);
  620. begin
  621. inherited create(calln,l,nil);
  622. symtableprocentry:=v;
  623. symtableproc:=st;
  624. callnodeflags:=callflags+[cnf_return_value_used];
  625. methodpointer:=mp;
  626. methodpointerinit:=nil;
  627. methodpointerdone:=nil;
  628. procdefinition:=nil;
  629. _funcretnode:=nil;
  630. inlinecode:=nil;
  631. paralength:=-1;
  632. varargsparas:=nil;
  633. end;
  634. constructor tcallnode.create_procvar(l,r:tnode);
  635. begin
  636. inherited create(calln,l,r);
  637. symtableprocentry:=nil;
  638. symtableproc:=nil;
  639. methodpointer:=nil;
  640. methodpointerinit:=nil;
  641. methodpointerdone:=nil;
  642. procdefinition:=nil;
  643. callnodeflags:=[cnf_return_value_used];
  644. _funcretnode:=nil;
  645. inlinecode:=nil;
  646. paralength:=-1;
  647. varargsparas:=nil;
  648. end;
  649. constructor tcallnode.createintern(const name: string; params: tnode);
  650. var
  651. srsym: tsym;
  652. symowner: tsymtable;
  653. begin
  654. if not (cs_compilesystem in aktmoduleswitches) then
  655. begin
  656. srsym := searchsymonlyin(systemunit,name);
  657. symowner := systemunit;
  658. end
  659. else
  660. begin
  661. searchsym(name,srsym,symowner);
  662. if not assigned(srsym) then
  663. searchsym(upper(name),srsym,symowner);
  664. end;
  665. if not assigned(srsym) or
  666. (srsym.typ <> procsym) then
  667. begin
  668. {$ifdef EXTDEBUG}
  669. Comment(V_Error,'unknown compilerproc '+name);
  670. {$endif EXTDEBUG}
  671. internalerror(200107271);
  672. end;
  673. self.create(params,tprocsym(srsym),symowner,nil,[]);
  674. end;
  675. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  676. begin
  677. self.createintern(name,params);
  678. restype := res;
  679. include(callnodeflags,cnf_restypeset);
  680. { both the normal and specified resulttype either have to be returned via a }
  681. { parameter or not, but no mixing (JM) }
  682. if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
  683. paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  684. internalerror(200108291);
  685. end;
  686. constructor tcallnode.createinternreturn(const name: string; params: tnode; returnnode : tnode);
  687. begin
  688. self.createintern(name,params);
  689. _funcretnode:=returnnode;
  690. if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  691. internalerror(200204247);
  692. end;
  693. procedure tcallnode.setfuncretnode(const returnnode: tnode);
  694. var
  695. para: tcallparanode;
  696. begin
  697. if assigned(_funcretnode) then
  698. _funcretnode.free;
  699. _funcretnode := returnnode;
  700. { if the resulttype pass hasn't occurred yet, that one will do }
  701. { everything }
  702. if assigned(resulttype.def) then
  703. begin
  704. { these are returned as values, but we can optimize their loading }
  705. { as well }
  706. if is_ansistring(resulttype.def) or
  707. is_widestring(resulttype.def) then
  708. exit;
  709. para := tcallparanode(left);
  710. while assigned(para) do
  711. begin
  712. if para.paraitem.is_hidden and
  713. (vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) then
  714. begin
  715. para.left.free;
  716. para.left := _funcretnode.getcopy;
  717. exit;
  718. end;
  719. para := tcallparanode(para.right);
  720. end;
  721. { no hidden resultpara found, error! }
  722. if not(procdefinition.proccalloption = pocall_inline) then
  723. internalerror(200306087);
  724. end;
  725. end;
  726. destructor tcallnode.destroy;
  727. begin
  728. methodpointer.free;
  729. methodpointerinit.free;
  730. methodpointerdone.free;
  731. _funcretnode.free;
  732. inlinecode.free;
  733. if assigned(varargsparas) then
  734. varargsparas.free;
  735. inherited destroy;
  736. end;
  737. constructor tcallnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  738. begin
  739. inherited ppuload(t,ppufile);
  740. ppufile.getderef(symtableprocentryderef);
  741. {$ifdef fpc}
  742. {$warning FIXME: No withsymtable support}
  743. {$endif}
  744. symtableproc:=nil;
  745. ppufile.getderef(procdefinitionderef);
  746. ppufile.getsmallset(callnodeflags);
  747. methodpointer:=ppuloadnode(ppufile);
  748. methodpointerinit:=tblocknode(ppuloadnode(ppufile));
  749. methodpointerdone:=tblocknode(ppuloadnode(ppufile));
  750. _funcretnode:=ppuloadnode(ppufile);
  751. inlinecode:=ppuloadnode(ppufile);
  752. end;
  753. procedure tcallnode.ppuwrite(ppufile:tcompilerppufile);
  754. begin
  755. inherited ppuwrite(ppufile);
  756. ppufile.putderef(symtableprocentryderef);
  757. ppufile.putderef(procdefinitionderef);
  758. ppufile.putsmallset(callnodeflags);
  759. ppuwritenode(ppufile,methodpointer);
  760. ppuwritenode(ppufile,methodpointerinit);
  761. ppuwritenode(ppufile,methodpointerdone);
  762. ppuwritenode(ppufile,_funcretnode);
  763. ppuwritenode(ppufile,inlinecode);
  764. end;
  765. procedure tcallnode.buildderefimpl;
  766. begin
  767. inherited buildderefimpl;
  768. symtableprocentryderef.build(symtableprocentry);
  769. procdefinitionderef.build(procdefinition);
  770. if assigned(methodpointer) then
  771. methodpointer.buildderefimpl;
  772. if assigned(methodpointerinit) then
  773. methodpointerinit.buildderefimpl;
  774. if assigned(methodpointerdone) then
  775. methodpointerdone.buildderefimpl;
  776. if assigned(_funcretnode) then
  777. _funcretnode.buildderefimpl;
  778. if assigned(inlinecode) then
  779. inlinecode.buildderefimpl;
  780. end;
  781. procedure tcallnode.derefimpl;
  782. var
  783. pt : tcallparanode;
  784. currpara : tparaitem;
  785. begin
  786. inherited derefimpl;
  787. symtableprocentry:=tprocsym(symtableprocentryderef.resolve);
  788. symtableproc:=symtableprocentry.owner;
  789. procdefinition:=tprocdef(procdefinitionderef.resolve);
  790. if assigned(methodpointer) then
  791. methodpointer.derefimpl;
  792. if assigned(methodpointerinit) then
  793. methodpointerinit.derefimpl;
  794. if assigned(methodpointerdone) then
  795. methodpointerdone.derefimpl;
  796. if assigned(_funcretnode) then
  797. _funcretnode.derefimpl;
  798. if assigned(inlinecode) then
  799. inlinecode.derefimpl;
  800. { Connect paraitems }
  801. pt:=tcallparanode(left);
  802. while assigned(pt) and
  803. (cpf_varargs_para in pt.callparaflags) do
  804. pt:=tcallparanode(pt.right);
  805. currpara:=tparaitem(procdefinition.Para.last);
  806. while assigned(currpara) do
  807. begin
  808. if not assigned(pt) then
  809. internalerror(200311077);
  810. pt.paraitem:=currpara;
  811. pt:=tcallparanode(pt.right);
  812. currpara:=tparaitem(currpara.previous);
  813. end;
  814. if assigned(currpara) or assigned(pt) then
  815. internalerror(200311078);
  816. end;
  817. function tcallnode.getcopy : tnode;
  818. var
  819. n : tcallnode;
  820. hp : tparaitem;
  821. oldleft : tnode;
  822. begin
  823. { Need to use a hack here to prevent the parameters from being copied.
  824. The parameters must be copied between methodpointerinit/methodpointerdone because
  825. the can reference methodpointer }
  826. oldleft:=left;
  827. left:=nil;
  828. n:=tcallnode(inherited getcopy);
  829. left:=oldleft;
  830. n.symtableprocentry:=symtableprocentry;
  831. n.symtableproc:=symtableproc;
  832. n.procdefinition:=procdefinition;
  833. n.restype := restype;
  834. n.callnodeflags := callnodeflags;
  835. if assigned(methodpointerinit) then
  836. n.methodpointerinit:=tblocknode(methodpointerinit.getcopy)
  837. else
  838. n.methodpointerinit:=nil;
  839. { methodpointerinit is copied, now references to the temp will also be copied
  840. correctly. We can now copy the parameters and methodpointer }
  841. if assigned(left) then
  842. n.left:=left.getcopy
  843. else
  844. n.left:=nil;
  845. if assigned(methodpointer) then
  846. n.methodpointer:=methodpointer.getcopy
  847. else
  848. n.methodpointer:=nil;
  849. if assigned(methodpointerdone) then
  850. n.methodpointerdone:=tblocknode(methodpointerdone.getcopy)
  851. else
  852. n.methodpointerdone:=nil;
  853. if assigned(_funcretnode) then
  854. n._funcretnode:=_funcretnode.getcopy
  855. else
  856. n._funcretnode:=nil;
  857. if assigned(inlinecode) then
  858. n.inlinecode:=inlinecode.getcopy
  859. else
  860. n.inlinecode:=nil;
  861. if assigned(varargsparas) then
  862. begin
  863. n.varargsparas:=tvarargspara.create;
  864. hp:=tparaitem(varargsparas.first);
  865. while assigned(hp) do
  866. begin
  867. n.varargsparas.concat(hp.getcopy);
  868. hp:=tparaitem(hp.next);
  869. end;
  870. end
  871. else
  872. n.varargsparas:=nil;
  873. result:=n;
  874. end;
  875. procedure tcallnode.insertintolist(l : tnodelist);
  876. begin
  877. end;
  878. procedure tcallnode.convert_carg_array_of_const;
  879. var
  880. hp : tarrayconstructornode;
  881. oldleft : tcallparanode;
  882. begin
  883. oldleft:=tcallparanode(left);
  884. if oldleft.left.nodetype<>arrayconstructorn then
  885. begin
  886. CGMessage1(type_e_wrong_type_in_array_constructor,oldleft.left.resulttype.def.typename);
  887. exit;
  888. end;
  889. { Get arrayconstructor node and insert typeconvs }
  890. hp:=tarrayconstructornode(oldleft.left);
  891. hp.insert_typeconvs;
  892. { Add c args parameters }
  893. { It could be an empty set }
  894. if assigned(hp) and
  895. assigned(hp.left) then
  896. begin
  897. while assigned(hp) do
  898. begin
  899. left:=ccallparanode.create(hp.left,left);
  900. { set callparanode resulttype and flags }
  901. left.resulttype:=hp.left.resulttype;
  902. include(tcallparanode(left).callparaflags,cpf_varargs_para);
  903. hp.left:=nil;
  904. hp:=tarrayconstructornode(hp.right);
  905. end;
  906. end;
  907. { Remove value of old array of const parameter, but keep it
  908. in the list because it is required for bind_paraitem.
  909. Generate a nothign to keep callparanoed.left valid }
  910. oldleft.left.free;
  911. oldleft.left:=cnothingnode.create;
  912. end;
  913. procedure tcallnode.verifyabstract(p : tnamedindexitem;arg:pointer);
  914. var
  915. hp : tprocdef;
  916. j: integer;
  917. begin
  918. if (tsym(p).typ=procsym) then
  919. begin
  920. for j:=1 to tprocsym(p).procdef_count do
  921. begin
  922. { index starts at 1 }
  923. hp:=tprocsym(p).procdef[j];
  924. { If this is an abstract method insert into the list }
  925. if (po_abstractmethod in hp.procoptions) then
  926. AbstractMethodsList.Insert(hp.procsym.realname)
  927. else
  928. { If this symbol is a virtual (includes override) method,
  929. then remove it from the list }
  930. if po_virtualmethod in hp.procoptions then
  931. AbstractMethodsList.Remove(hp.procsym.realname);
  932. end;
  933. end;
  934. end;
  935. procedure tcallnode.verifyabstractcalls;
  936. var
  937. objectdf : tobjectdef;
  938. parents : tlinkedlist;
  939. objectinfo : tobjectinfoitem;
  940. stritem : tstringlistitem;
  941. begin
  942. objectdf := nil;
  943. { verify if trying to create an instance of a class which contains
  944. non-implemented abstract methods }
  945. { first verify this class type, no class than exit }
  946. { also, this checking can only be done if the constructor is directly
  947. called, indirect constructor calls cannot be checked.
  948. }
  949. if assigned(methodpointer) then
  950. begin
  951. if (methodpointer.resulttype.def.deftype = objectdef) then
  952. objectdf:=tobjectdef(methodpointer.resulttype.def)
  953. else
  954. if (methodpointer.resulttype.def.deftype = classrefdef) and
  955. (tclassrefdef(methodpointer.resulttype.def).pointertype.def.deftype = objectdef) and
  956. (methodpointer.nodetype in [typen,loadvmtaddrn]) then
  957. objectdf:=tobjectdef(tclassrefdef(methodpointer.resulttype.def).pointertype.def);
  958. end;
  959. if not assigned(objectdf) then
  960. exit;
  961. parents := tlinkedlist.create;
  962. AbstractMethodsList := tstringlist.create;
  963. { insert all parents in this class : the first item in the
  964. list will be the base parent of the class .
  965. }
  966. while assigned(objectdf) do
  967. begin
  968. objectinfo:=tobjectinfoitem.create(objectdf);
  969. parents.insert(objectinfo);
  970. objectdf := objectdf.childof;
  971. end;
  972. { now all parents are in the correct order
  973. insert all abstract methods in the list, and remove
  974. those which are overriden by parent classes.
  975. }
  976. objectinfo:=tobjectinfoitem(parents.first);
  977. while assigned(objectinfo) do
  978. begin
  979. objectdf := objectinfo.objinfo;
  980. if assigned(objectdf.symtable) then
  981. objectdf.symtable.foreach(@verifyabstract,nil);
  982. objectinfo:=tobjectinfoitem(objectinfo.next);
  983. end;
  984. if assigned(parents) then
  985. parents.free;
  986. { Finally give out a warning for each abstract method still in the list }
  987. stritem := tstringlistitem(AbstractMethodsList.first);
  988. if assigned(stritem) then
  989. Message1(type_w_instance_with_abstract,objectdf.objrealname^);
  990. while assigned(stritem) do
  991. begin
  992. if assigned(stritem.fpstr) then
  993. Message1(sym_h_param_list,stritem.str);
  994. stritem := tstringlistitem(stritem.next);
  995. end;
  996. if assigned(AbstractMethodsList) then
  997. AbstractMethodsList.Free;
  998. end;
  999. function tcallnode.gen_self_tree_methodpointer:tnode;
  1000. var
  1001. hsym : tvarsym;
  1002. begin
  1003. { find self field in methodpointer record }
  1004. hsym:=tvarsym(trecorddef(methodpointertype.def).symtable.search('self'));
  1005. if not assigned(hsym) then
  1006. internalerror(200305251);
  1007. { Load tmehodpointer(right).self }
  1008. result:=csubscriptnode.create(
  1009. hsym,
  1010. ctypeconvnode.create_explicit(right.getcopy,methodpointertype));
  1011. end;
  1012. function tcallnode.gen_self_tree:tnode;
  1013. var
  1014. selftree : tnode;
  1015. begin
  1016. selftree:=nil;
  1017. { inherited }
  1018. if (cnf_inherited in callnodeflags) then
  1019. selftree:=load_self_node
  1020. else
  1021. { constructors }
  1022. if (procdefinition.proctypeoption=potype_constructor) then
  1023. begin
  1024. { push 0 as self when allocation is needed }
  1025. if (methodpointer.resulttype.def.deftype=classrefdef) or
  1026. (cnf_new_call in callnodeflags) then
  1027. selftree:=cpointerconstnode.create(0,voidpointertype)
  1028. else
  1029. begin
  1030. if methodpointer.nodetype=typen then
  1031. selftree:=load_self_node
  1032. else
  1033. selftree:=methodpointer.getcopy;
  1034. end;
  1035. end
  1036. else
  1037. { Calling a static/class method }
  1038. if (po_classmethod in procdefinition.procoptions) or
  1039. (po_staticmethod in procdefinition.procoptions) then
  1040. begin
  1041. if (procdefinition.deftype<>procdef) then
  1042. internalerror(200305062);
  1043. if (oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  1044. begin
  1045. { we only need the vmt, loading self is not required and there is no
  1046. need to check for typen, because that will always get the
  1047. loadvmtaddrnode added }
  1048. selftree:=methodpointer.getcopy;
  1049. if methodpointer.resulttype.def.deftype<>classrefdef then
  1050. selftree:=cloadvmtaddrnode.create(selftree);
  1051. end
  1052. else
  1053. selftree:=cpointerconstnode.create(0,voidpointertype);
  1054. end
  1055. else
  1056. begin
  1057. if methodpointer.nodetype=typen then
  1058. selftree:=load_self_node
  1059. else
  1060. selftree:=methodpointer.getcopy;
  1061. end;
  1062. result:=selftree;
  1063. end;
  1064. function tcallnode.gen_vmt_tree:tnode;
  1065. var
  1066. vmttree : tnode;
  1067. begin
  1068. vmttree:=nil;
  1069. if not(procdefinition.proctypeoption in [potype_constructor,potype_destructor]) then
  1070. internalerror(200305051);
  1071. { inherited call, no create/destroy }
  1072. if (cnf_inherited in callnodeflags) then
  1073. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1074. else
  1075. { do not create/destroy when called from member function
  1076. without specifying self explicit }
  1077. if (cnf_member_call in callnodeflags) then
  1078. begin
  1079. if (methodpointer.resulttype.def.deftype=classrefdef) and
  1080. (procdefinition.proctypeoption=potype_constructor) then
  1081. vmttree:=methodpointer.getcopy
  1082. else
  1083. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1084. end
  1085. else
  1086. { constructor with extended syntax called from new }
  1087. if (cnf_new_call in callnodeflags) then
  1088. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1089. else
  1090. { destructor with extended syntax called from dispose }
  1091. if (cnf_dispose_call in callnodeflags) then
  1092. vmttree:=cloadvmtaddrnode.create(methodpointer.getcopy)
  1093. else
  1094. if (methodpointer.resulttype.def.deftype=classrefdef) then
  1095. begin
  1096. { constructor call via classreference => allocate memory }
  1097. if (procdefinition.proctypeoption=potype_constructor) and
  1098. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  1099. begin
  1100. vmttree:=methodpointer.getcopy;
  1101. { Only a typenode can be passed when it is called with <class of xx>.create }
  1102. if vmttree.nodetype=typen then
  1103. vmttree:=cloadvmtaddrnode.create(vmttree);
  1104. end
  1105. else
  1106. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1107. end
  1108. else
  1109. { class }
  1110. if is_class(methodpointer.resulttype.def) then
  1111. begin
  1112. { destructor: release instance, flag(vmt)=1
  1113. constructor: direct call, do nothing, leave vmt=0 }
  1114. if (procdefinition.proctypeoption=potype_destructor) then
  1115. vmttree:=cpointerconstnode.create(1,voidpointertype)
  1116. else
  1117. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1118. end
  1119. else
  1120. { object }
  1121. begin
  1122. { destructor: direct call, no dispose, vmt=0
  1123. constructor: initialize object, load vmt }
  1124. if (procdefinition.proctypeoption=potype_constructor) then
  1125. { old styled inherited call? }
  1126. if (methodpointer.nodetype=typen) then
  1127. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1128. else
  1129. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1130. else
  1131. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1132. end;
  1133. result:=vmttree;
  1134. end;
  1135. procedure tcallnode.bind_paraitem;
  1136. var
  1137. i : integer;
  1138. pt : tcallparanode;
  1139. oldppt : ^tcallparanode;
  1140. varargspara,
  1141. currpara : tparaitem;
  1142. used_by_callnode : boolean;
  1143. hiddentree : tnode;
  1144. newstatement : tstatementnode;
  1145. temp : ttempcreatenode;
  1146. begin
  1147. pt:=tcallparanode(left);
  1148. oldppt:=@left;
  1149. { flag all callparanodes that belong to the varargs }
  1150. i:=paralength;
  1151. while (i>procdefinition.maxparacount) do
  1152. begin
  1153. include(pt.callparaflags,cpf_varargs_para);
  1154. oldppt:[email protected];
  1155. pt:=tcallparanode(pt.right);
  1156. dec(i);
  1157. end;
  1158. { skip varargs that are inserted by array of const }
  1159. while assigned(pt) and
  1160. (cpf_varargs_para in pt.callparaflags) do
  1161. pt:=tcallparanode(pt.right);
  1162. { process normal parameters and insert hidden parameters }
  1163. currpara:=tparaitem(procdefinition.Para.last);
  1164. while assigned(currpara) do
  1165. begin
  1166. if currpara.is_hidden then
  1167. begin
  1168. { generate hidden tree }
  1169. used_by_callnode:=false;
  1170. hiddentree:=nil;
  1171. if (vo_is_funcret in tvarsym(currpara.parasym).varoptions) then
  1172. begin
  1173. { Generate funcretnode if not specified }
  1174. if assigned(funcretnode) then
  1175. begin
  1176. hiddentree:=funcretnode.getcopy;
  1177. end
  1178. else
  1179. begin
  1180. hiddentree:=internalstatements(newstatement);
  1181. { need to use resulttype instead of procdefinition.rettype,
  1182. because they can be different }
  1183. temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
  1184. addstatement(newstatement,temp);
  1185. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  1186. addstatement(newstatement,ctemprefnode.create(temp));
  1187. end;
  1188. end
  1189. else
  1190. if vo_is_high_value in tvarsym(currpara.parasym).varoptions then
  1191. begin
  1192. if not assigned(pt) then
  1193. internalerror(200304082);
  1194. { we need the information of the previous parameter }
  1195. hiddentree:=gen_high_tree(pt.left,tparaitem(currpara.previous).paratype.def);
  1196. end
  1197. else
  1198. if vo_is_self in tvarsym(currpara.parasym).varoptions then
  1199. begin
  1200. if assigned(right) then
  1201. hiddentree:=gen_self_tree_methodpointer
  1202. else
  1203. hiddentree:=gen_self_tree;
  1204. end
  1205. else
  1206. if vo_is_vmt in tvarsym(currpara.parasym).varoptions then
  1207. begin
  1208. hiddentree:=gen_vmt_tree;
  1209. end
  1210. else
  1211. if vo_is_parentfp in tvarsym(currpara.parasym).varoptions then
  1212. begin
  1213. if not(assigned(procdefinition.owner.defowner)) then
  1214. internalerror(200309287);
  1215. hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
  1216. end
  1217. {$ifdef powerpc}
  1218. else
  1219. { lib parameter has no special type but proccalloptions must be a syscall }
  1220. if (target_info.system in [system_powerpc_morphos,system_m68k_amiga]) and
  1221. (procdefinition.proccalloption=pocall_syscall) then
  1222. begin
  1223. hiddentree:=cloadnode.create(tprocdef(procdefinition).libsym,tprocdef(procdefinition).libsym.owner);
  1224. end
  1225. {$endif powerpc}
  1226. else
  1227. { add the hidden parameter }
  1228. if not assigned(hiddentree) then
  1229. internalerror(200304073);
  1230. { Already insert para and let the previous node point to
  1231. this new node }
  1232. pt:=ccallparanode.create(hiddentree,oldppt^);
  1233. pt.used_by_callnode:=used_by_callnode;
  1234. oldppt^:=pt;
  1235. end;
  1236. if not assigned(pt) then
  1237. internalerror(200310052);
  1238. pt.paraitem:=currpara;
  1239. oldppt:[email protected];
  1240. pt:=tcallparanode(pt.right);
  1241. currpara:=tparaitem(currpara.previous)
  1242. end;
  1243. { Create paraitems for varargs }
  1244. pt:=tcallparanode(left);
  1245. while assigned(pt) do
  1246. begin
  1247. if cpf_varargs_para in pt.callparaflags then
  1248. begin
  1249. if not assigned(varargsparas) then
  1250. varargsparas:=tvarargspara.create;
  1251. varargspara:=tparaitem.create;
  1252. varargspara.paratyp:=vs_value;
  1253. varargspara.paratype:=pt.resulttype;
  1254. { varargspara is left-right, use insert
  1255. instead of concat }
  1256. varargsparas.insert(varargspara);
  1257. pt.paraitem:=varargspara;
  1258. end;
  1259. pt:=tcallparanode(pt.right);
  1260. end;
  1261. end;
  1262. function tcallnode.det_resulttype:tnode;
  1263. var
  1264. candidates : tcallcandidates;
  1265. oldcallnode : tcallnode;
  1266. hpt : tnode;
  1267. pt : tcallparanode;
  1268. lastpara : longint;
  1269. currpara : tparaitem;
  1270. cand_cnt : integer;
  1271. i : longint;
  1272. method_must_be_valid,
  1273. is_const : boolean;
  1274. label
  1275. errorexit;
  1276. begin
  1277. result:=nil;
  1278. candidates:=nil;
  1279. if not assigned(symtableprocentry) then
  1280. internalerror(200411014);
  1281. oldcallnode:=aktcallnode;
  1282. aktcallnode:=self;
  1283. { determine length of parameter list }
  1284. pt:=tcallparanode(left);
  1285. paralength:=0;
  1286. while assigned(pt) do
  1287. begin
  1288. inc(paralength);
  1289. pt:=tcallparanode(pt.right);
  1290. end;
  1291. { determine the type of the parameters }
  1292. if assigned(left) then
  1293. begin
  1294. tcallparanode(left).get_paratype;
  1295. if codegenerror then
  1296. goto errorexit;
  1297. end;
  1298. if assigned(methodpointer) then
  1299. begin
  1300. resulttypepass(methodpointer);
  1301. maybe_load_para_in_temp(methodpointer);
  1302. end;
  1303. { procedure variable ? }
  1304. if assigned(right) then
  1305. begin
  1306. set_varstate(right,vs_used,true);
  1307. resulttypepass(right);
  1308. if codegenerror then
  1309. exit;
  1310. procdefinition:=tabstractprocdef(right.resulttype.def);
  1311. { Compare parameters from right to left }
  1312. currpara:=tparaitem(procdefinition.Para.last);
  1313. { Skip default parameters }
  1314. if not(po_varargs in procdefinition.procoptions) then
  1315. begin
  1316. { ignore hidden parameters }
  1317. while assigned(currpara) and (currpara.is_hidden) do
  1318. currpara:=tparaitem(currpara.previous);
  1319. for i:=1 to procdefinition.maxparacount-paralength do
  1320. begin
  1321. if not assigned(currpara) then
  1322. internalerror(200402261);
  1323. if not assigned(currpara.defaultvalue) then
  1324. begin
  1325. CGMessage(parser_e_wrong_parameter_size);
  1326. goto errorexit;
  1327. end;
  1328. currpara:=tparaitem(currpara.previous);
  1329. end;
  1330. end;
  1331. while assigned(currpara) and (currpara.is_hidden) do
  1332. currpara:=tparaitem(currpara.previous);
  1333. pt:=tcallparanode(left);
  1334. lastpara:=paralength;
  1335. while assigned(currpara) and assigned(pt) do
  1336. begin
  1337. { only goto next para if we're out of the varargs }
  1338. if not(po_varargs in procdefinition.procoptions) or
  1339. (lastpara<=procdefinition.maxparacount) then
  1340. begin
  1341. repeat
  1342. currpara:=tparaitem(currpara.previous);
  1343. until (not assigned(currpara)) or (not currpara.is_hidden);
  1344. end;
  1345. pt:=tcallparanode(pt.right);
  1346. dec(lastpara);
  1347. end;
  1348. if assigned(pt) or
  1349. (assigned(currpara) and
  1350. not assigned(currpara.defaultvalue)) then
  1351. begin
  1352. if assigned(pt) then
  1353. aktfilepos:=pt.fileinfo;
  1354. CGMessage(parser_e_wrong_parameter_size);
  1355. goto errorexit;
  1356. end;
  1357. end
  1358. else
  1359. { not a procedure variable }
  1360. begin
  1361. { do we know the procedure to call ? }
  1362. if not(assigned(procdefinition)) then
  1363. begin
  1364. candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,(nf_isproperty in flags));
  1365. { no procedures found? then there is something wrong
  1366. with the parameter size or the procedures are
  1367. not accessible }
  1368. if candidates.count=0 then
  1369. begin
  1370. { when it's an auto inherited call and there
  1371. is no procedure found, but the procedures
  1372. were defined with overload directive and at
  1373. least two procedures are defined then we ignore
  1374. this inherited by inserting a nothingn. Only
  1375. do this ugly hack in Delphi mode as it looks more
  1376. like a bug. It's also not documented }
  1377. if (m_delphi in aktmodeswitches) and
  1378. (cnf_anon_inherited in callnodeflags) and
  1379. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1380. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1381. (symtableprocentry.procdef_count>=2) then
  1382. result:=cnothingnode.create
  1383. else
  1384. begin
  1385. { in tp mode we can try to convert to procvar if
  1386. there are no parameters specified. Only try it
  1387. when there is only one proc definition, else the
  1388. loadnode will give a strange error }
  1389. if not(assigned(left)) and
  1390. not(cnf_inherited in callnodeflags) and
  1391. (m_tp_procvar in aktmodeswitches) and
  1392. (symtableprocentry.procdef_count=1) then
  1393. begin
  1394. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1395. if assigned(methodpointer) then
  1396. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1397. resulttypepass(hpt);
  1398. result:=hpt;
  1399. end
  1400. else
  1401. begin
  1402. if assigned(left) then
  1403. aktfilepos:=left.fileinfo;
  1404. CGMessage(parser_e_wrong_parameter_size);
  1405. symtableprocentry.write_parameter_lists(nil);
  1406. end;
  1407. end;
  1408. goto errorexit;
  1409. end;
  1410. { Retrieve information about the candidates }
  1411. candidates.get_information;
  1412. {$ifdef EXTDEBUG}
  1413. { Display info when multiple candidates are found }
  1414. if candidates.count>1 then
  1415. candidates.dump_info(V_Debug);
  1416. {$endif EXTDEBUG}
  1417. { Choose the best candidate and count the number of
  1418. candidates left }
  1419. cand_cnt:=candidates.choose_best(procdefinition);
  1420. { All parameters are checked, check if there are any
  1421. procedures left }
  1422. if cand_cnt>0 then
  1423. begin
  1424. { Multiple candidates left? }
  1425. if cand_cnt>1 then
  1426. begin
  1427. CGMessage(type_e_cant_choose_overload_function);
  1428. {$ifdef EXTDEBUG}
  1429. candidates.dump_info(V_Hint);
  1430. {$else EXTDEBUG}
  1431. candidates.list(false);
  1432. {$endif EXTDEBUG}
  1433. { we'll just use the first candidate to make the
  1434. call }
  1435. end;
  1436. { assign procdefinition }
  1437. if symtableproc=nil then
  1438. symtableproc:=procdefinition.owner;
  1439. { update browser information }
  1440. if make_ref then
  1441. begin
  1442. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1443. inc(tprocdef(procdefinition).refcount);
  1444. if tprocdef(procdefinition).defref=nil then
  1445. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1446. end;
  1447. end
  1448. else
  1449. begin
  1450. { No candidates left, this must be a type error,
  1451. because wrong size is already checked. procdefinition
  1452. is filled with the first (random) definition that is
  1453. found. We use this definition to display a nice error
  1454. message that the wrong type is passed }
  1455. candidates.find_wrong_para;
  1456. candidates.list(true);
  1457. {$ifdef EXTDEBUG}
  1458. candidates.dump_info(V_Hint);
  1459. {$endif EXTDEBUG}
  1460. { We can not proceed, release all procs and exit }
  1461. candidates.free;
  1462. goto errorexit;
  1463. end;
  1464. candidates.free;
  1465. end; { end of procedure to call determination }
  1466. end;
  1467. { add needed default parameters }
  1468. if assigned(procdefinition) and
  1469. (paralength<procdefinition.maxparacount) then
  1470. begin
  1471. currpara:=tparaitem(procdefinition.Para.first);
  1472. i:=0;
  1473. while (i<paralength) do
  1474. begin
  1475. if not assigned(currpara) then
  1476. internalerror(200306181);
  1477. if not currpara.is_hidden then
  1478. inc(i);
  1479. currpara:=tparaitem(currpara.next);
  1480. end;
  1481. while assigned(currpara) and currpara.is_hidden do
  1482. currpara:=tparaitem(currpara.next);
  1483. while assigned(currpara) do
  1484. begin
  1485. if not assigned(currpara.defaultvalue) then
  1486. internalerror(200212142);
  1487. left:=ccallparanode.create(genconstsymtree(tconstsym(currpara.defaultvalue)),left);
  1488. { Ignore vs_hidden parameters }
  1489. repeat
  1490. currpara:=tparaitem(currpara.next);
  1491. until (not assigned(currpara)) or (not currpara.is_hidden);
  1492. end;
  1493. end;
  1494. { handle predefined procedures }
  1495. is_const:=(po_internconst in procdefinition.procoptions) and
  1496. ((block_type in [bt_const,bt_type]) or
  1497. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1498. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1499. begin
  1500. if assigned(left) then
  1501. begin
  1502. { ptr and settextbuf needs two args }
  1503. if assigned(tcallparanode(left).right) then
  1504. begin
  1505. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1506. left:=nil;
  1507. end
  1508. else
  1509. begin
  1510. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1511. tcallparanode(left).left:=nil;
  1512. end;
  1513. end
  1514. else
  1515. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1516. result:=hpt;
  1517. goto errorexit;
  1518. end;
  1519. { ensure that the result type is set }
  1520. if not(cnf_restypeset in callnodeflags) then
  1521. begin
  1522. { constructors return their current class type, not the type where the
  1523. constructor is declared, this can be different because of inheritance }
  1524. if (procdefinition.proctypeoption=potype_constructor) and
  1525. assigned(methodpointer) and
  1526. assigned(methodpointer.resulttype.def) and
  1527. (methodpointer.resulttype.def.deftype=classrefdef) then
  1528. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype
  1529. else
  1530. resulttype:=procdefinition.rettype;
  1531. end
  1532. else
  1533. resulttype:=restype;
  1534. {if resulttype.def.needs_inittable then
  1535. include(current_procinfo.flags,pi_needs_implicit_finally);}
  1536. if assigned(methodpointer) then
  1537. begin
  1538. { when methodpointer is a callnode we must load it first into a
  1539. temp to prevent the processing callnode twice }
  1540. if (methodpointer.nodetype=calln) then
  1541. internalerror(200405121);
  1542. { direct call to inherited abstract method, then we
  1543. can already give a error in the compiler instead
  1544. of a runtime error }
  1545. if (cnf_inherited in callnodeflags) and
  1546. (po_abstractmethod in procdefinition.procoptions) then
  1547. CGMessage(cg_e_cant_call_abstract_method);
  1548. { if an inherited con- or destructor should be }
  1549. { called in a con- or destructor then a warning }
  1550. { will be made }
  1551. { con- and destructors need a pointer to the vmt }
  1552. if (cnf_inherited in callnodeflags) and
  1553. (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1554. is_object(methodpointer.resulttype.def) and
  1555. not(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) then
  1556. CGMessage(cg_w_member_cd_call_from_method);
  1557. if methodpointer.nodetype<>typen then
  1558. begin
  1559. { Remove all postfix operators }
  1560. hpt:=methodpointer;
  1561. while assigned(hpt) and (hpt.nodetype in [subscriptn,vecn]) do
  1562. hpt:=tunarynode(hpt).left;
  1563. if (procdefinition.proctypeoption=potype_constructor) and
  1564. assigned(symtableproc) and
  1565. (symtableproc.symtabletype=withsymtable) and
  1566. (tnode(twithsymtable(symtableproc).withrefnode).nodetype=temprefn) then
  1567. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1568. { R.Init then R will be initialized by the constructor,
  1569. Also allow it for simple loads }
  1570. if (procdefinition.proctypeoption=potype_constructor) or
  1571. ((hpt.nodetype=loadn) and
  1572. (
  1573. (methodpointer.resulttype.def.deftype=classrefdef) or
  1574. (
  1575. (methodpointer.resulttype.def.deftype=objectdef) and
  1576. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1577. )
  1578. )
  1579. ) then
  1580. method_must_be_valid:=false
  1581. else
  1582. method_must_be_valid:=true;
  1583. set_varstate(methodpointer,vs_used,method_must_be_valid);
  1584. { The object is already used if it is called once }
  1585. if (hpt.nodetype=loadn) and
  1586. (tloadnode(hpt).symtableentry.typ=varsym) then
  1587. tvarsym(tloadnode(hpt).symtableentry).varstate:=vs_used;
  1588. end;
  1589. { if we are calling the constructor check for abstract
  1590. methods. Ignore inherited and member calls, because the
  1591. class is then already created }
  1592. if (procdefinition.proctypeoption=potype_constructor) and
  1593. not(cnf_inherited in callnodeflags) and
  1594. not(cnf_member_call in callnodeflags) then
  1595. verifyabstractcalls;
  1596. end
  1597. else
  1598. begin
  1599. { When this is method the methodpointer must be available }
  1600. if (right=nil) and
  1601. (procdefinition.owner.symtabletype=objectsymtable) then
  1602. internalerror(200305061);
  1603. end;
  1604. { Change loading of array of const to varargs }
  1605. if assigned(left) and
  1606. is_array_of_const(tparaitem(procdefinition.para.last).paratype.def) and
  1607. (procdefinition.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  1608. convert_carg_array_of_const;
  1609. { bind paraitems to the callparanodes and insert hidden parameters }
  1610. bind_paraitem;
  1611. { methodpointer is only needed for virtual calls, and
  1612. it should then be loaded with the VMT }
  1613. if (po_virtualmethod in procdefinition.procoptions) and
  1614. not(assigned(methodpointer) and
  1615. (methodpointer.nodetype=typen)) then
  1616. begin
  1617. if not assigned(methodpointer) then
  1618. internalerror(200305063);
  1619. if (methodpointer.resulttype.def.deftype<>classrefdef) then
  1620. begin
  1621. methodpointer:=cloadvmtaddrnode.create(methodpointer);
  1622. resulttypepass(methodpointer);
  1623. end;
  1624. end
  1625. else
  1626. begin
  1627. { not needed anymore }
  1628. methodpointer.free;
  1629. methodpointer:=nil;
  1630. end;
  1631. { insert type conversions for parameters }
  1632. if assigned(left) then
  1633. tcallparanode(left).insert_typeconv(true);
  1634. errorexit:
  1635. aktcallnode:=oldcallnode;
  1636. end;
  1637. procedure tcallnode.order_parameters;
  1638. var
  1639. hp,hpcurr,hpnext,hpfirst,hpprev : tcallparanode;
  1640. currloc : tcgloc;
  1641. begin
  1642. hpfirst:=nil;
  1643. hpcurr:=tcallparanode(left);
  1644. while assigned(hpcurr) do
  1645. begin
  1646. { pull out }
  1647. hpnext:=tcallparanode(hpcurr.right);
  1648. { pull in at the correct place.
  1649. Used order:
  1650. 1. LOC_REFERENCE with smallest offset (x86 only)
  1651. 2. LOC_REFERENCE with most registers
  1652. 3. LOC_REGISTER with most registers
  1653. For the moment we only look at the first parameter field. Combining it
  1654. with multiple parameter fields will make things a lot complexer (PFV) }
  1655. currloc:=hpcurr.paraitem.paraloc[callerside].location^.loc;
  1656. hpprev:=nil;
  1657. hp:=hpfirst;
  1658. while assigned(hp) do
  1659. begin
  1660. case currloc of
  1661. LOC_REFERENCE :
  1662. begin
  1663. case hp.paraitem.paraloc[callerside].location^.loc of
  1664. LOC_REFERENCE :
  1665. begin
  1666. { Offset is calculated like:
  1667. sub esp,12
  1668. mov [esp+8],para3
  1669. mov [esp+4],para2
  1670. mov [esp],para1
  1671. call function
  1672. That means the for pushes the para with the
  1673. highest offset (see para3) needs to be pushed first
  1674. }
  1675. if (hpcurr.registersint>hp.registersint)
  1676. {$ifdef x86}
  1677. or (hpcurr.paraitem.paraloc[callerside].location^.reference.offset>hp.paraitem.paraloc[callerside].location^.reference.offset)
  1678. {$endif x86}
  1679. then
  1680. break;
  1681. end;
  1682. LOC_REGISTER,
  1683. LOC_FPUREGISTER :
  1684. break;
  1685. end;
  1686. end;
  1687. LOC_FPUREGISTER,
  1688. LOC_REGISTER :
  1689. begin
  1690. if (hp.paraitem.paraloc[callerside].location^.loc=currloc) and
  1691. (hpcurr.registersint>hp.registersint) then
  1692. break;
  1693. end;
  1694. end;
  1695. hpprev:=hp;
  1696. hp:=tcallparanode(hp.right);
  1697. end;
  1698. hpcurr.right:=hp;
  1699. if assigned(hpprev) then
  1700. hpprev.right:=hpcurr
  1701. else
  1702. hpfirst:=hpcurr;
  1703. { next }
  1704. hpcurr:=hpnext;
  1705. end;
  1706. left:=hpfirst;
  1707. end;
  1708. function tcallnode.replaceparaload(var n: tnode; arg: pointer): foreachnoderesult;
  1709. var
  1710. paras: tcallparanode;
  1711. temp: tnode;
  1712. begin
  1713. result := fen_false;
  1714. n.fileinfo := pfileposinfo(arg)^;
  1715. if (n.nodetype = loadn) then
  1716. begin
  1717. paras := tcallparanode(left);
  1718. while assigned(paras) and
  1719. (paras.paraitem.parasym <> tloadnode(n).symtableentry) do
  1720. paras := tcallparanode(paras.right);
  1721. if assigned(paras) then
  1722. begin
  1723. n.free;
  1724. n := paras.left.getcopy;
  1725. resulttypepass(n);
  1726. result := fen_true;
  1727. end
  1728. {$ifndef VER1_0}
  1729. else
  1730. begin
  1731. { local? }
  1732. if (tloadnode(n).symtableentry.typ <> varsym) or
  1733. (tloadnode(n).symtableentry.owner <> tprocdef(procdefinition).localst) then
  1734. exit;
  1735. if (tloadnode(n).symtableentry.indexnr > high(inlinelocals)) or
  1736. not assigned(inlinelocals[tloadnode(n).symtableentry.indexnr]) then
  1737. internalerror(20040720);
  1738. temp := inlinelocals[tloadnode(n).symtableentry.indexnr].getcopy;
  1739. n.free;
  1740. n := temp;
  1741. resulttypepass(n);
  1742. result := fen_true;
  1743. end;
  1744. {$endif ndef VER1_0}
  1745. end;
  1746. end;
  1747. {$ifndef VER1_0}
  1748. type
  1749. ptempnodes = ^ttempnodes;
  1750. ttempnodes = record
  1751. createstatement, deletestatement: tstatementnode;
  1752. end;
  1753. procedure tcallnode.createlocaltemps(p:TNamedIndexItem;arg:pointer);
  1754. var
  1755. tempinfo: ptempnodes absolute ptempnodes(arg);
  1756. tempnode: ttempcreatenode;
  1757. begin
  1758. if (tsymentry(p).typ <> varsym) then
  1759. exit;
  1760. if (p.indexnr > high(inlinelocals)) then
  1761. setlength(inlinelocals,p.indexnr+10);
  1762. {$ifndef VER1_0}
  1763. if (vo_is_funcret in tvarsym(p).varoptions) and
  1764. assigned(funcretnode) then
  1765. begin
  1766. if node_complexity(funcretnode) > 1 then
  1767. begin
  1768. { can this happen? }
  1769. { we may have to replace the funcretnode with the address of funcretnode }
  1770. { loaded in a temp in this case, because the expression may e.g. contain }
  1771. { a global variable that gets changed inside the function }
  1772. internalerror(2004072101);
  1773. end;
  1774. inlinelocals[tvarsym(p).indexnr] := funcretnode.getcopy
  1775. end
  1776. else
  1777. {$endif ndef VER1_0}
  1778. begin
  1779. if (cs_regvars in aktglobalswitches) and
  1780. (tvarsym(p).varregable<>vr_none) and
  1781. (not tvarsym(p).vartype.def.needs_inittable) then
  1782. tempnode := ctempcreatenode.create_reg(tvarsym(p).vartype,tvarsym(p).vartype.def.size,tt_persistent)
  1783. else
  1784. tempnode := ctempcreatenode.create(tvarsym(p).vartype,tvarsym(p).vartype.def.size,tt_persistent);
  1785. addstatement(tempinfo^.createstatement,tempnode);
  1786. if assigned(tvarsym(p).defaultconstsym) then
  1787. begin
  1788. { warning: duplicate from psub.pas:initializevars() -> must refactor }
  1789. addstatement(tempinfo^.createstatement,cassignmentnode.create(
  1790. ctemprefnode.create(tempnode),
  1791. cloadnode.create(tvarsym(p).defaultconstsym,tvarsym(p).defaultconstsym.owner)));
  1792. end;
  1793. if (vo_is_funcret in tvarsym(p).varoptions) then
  1794. begin
  1795. funcretnode := ctemprefnode.create(tempnode);
  1796. addstatement(tempinfo^.deletestatement,ctempdeletenode.create_normal_temp(tempnode));
  1797. end
  1798. else
  1799. addstatement(tempinfo^.deletestatement,ctempdeletenode.create(tempnode));
  1800. inlinelocals[p.indexnr] := ctemprefnode.create(tempnode);
  1801. end;
  1802. end;
  1803. {$endif ndef VER1_0}
  1804. procedure tcallnode.createinlineparas(var createstatement, deletestatement: tstatementnode);
  1805. var
  1806. para: tcallparanode;
  1807. tempnode: ttempcreatenode;
  1808. hp: tnode;
  1809. {$ifndef VER1_0}
  1810. tempnodes: ttempnodes;
  1811. {$endif ndef VER1_0}
  1812. begin
  1813. { parameters }
  1814. para := tcallparanode(left);
  1815. while assigned(para) do
  1816. begin
  1817. if (para.paraitem.parasym.typ = varsym) and
  1818. { para.left will already be the same as funcretnode in the following case, so don't change }
  1819. (not(vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) or
  1820. (not assigned(funcretnode))) then
  1821. begin
  1822. { create temps for value parameters, function result and also for }
  1823. { const parameters which are passed by value instead of by reference }
  1824. if (vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) or
  1825. (para.paraitem.paratyp = vs_value) or
  1826. ((para.paraitem.paratyp = vs_const) and
  1827. (not paramanager.push_addr_param(vs_const,para.left.resulttype.def,procdefinition.proccalloption) or
  1828. { the problem is that we can't take the address of a function result :( }
  1829. (node_complexity(para.left) >= NODE_COMPLEXITY_INF))) then
  1830. begin
  1831. if (cs_regvars in aktglobalswitches) and
  1832. (tvarsym(para.paraitem.parasym).varregable<>vr_none) and
  1833. (not tvarsym(para.paraitem.parasym).vartype.def.needs_inittable) then
  1834. tempnode := ctempcreatenode.create_reg(para.left.resulttype,para.left.resulttype.def.size,tt_persistent)
  1835. else
  1836. tempnode := ctempcreatenode.create(para.left.resulttype,para.left.resulttype.def.size,tt_persistent);
  1837. addstatement(createstatement,tempnode);
  1838. { assign the value of the parameter to the temp, except in case of the function result }
  1839. { (in that case, para.left is a block containing the creation of a new temp, while we }
  1840. { only need a temprefnode, so delete the old stuff) }
  1841. if not(vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) then
  1842. begin
  1843. addstatement(createstatement,cassignmentnode.create(ctemprefnode.create(tempnode),
  1844. para.left));
  1845. para.left := ctemprefnode.create(tempnode);
  1846. addstatement(deletestatement,ctempdeletenode.create(tempnode));
  1847. end
  1848. else
  1849. begin
  1850. if not(assigned(funcretnode)) then
  1851. funcretnode := ctemprefnode.create(tempnode);
  1852. para.left.free;
  1853. para.left := ctemprefnode.create(tempnode);
  1854. addstatement(deletestatement,ctempdeletenode.create_normal_temp(tempnode));
  1855. end
  1856. end
  1857. else if node_complexity(para.left) > 1 then
  1858. begin
  1859. if (cs_regvars in aktglobalswitches) and
  1860. not tvarsym(para.paraitem.parasym).vartype.def.needs_inittable then
  1861. tempnode := ctempcreatenode.create_reg(voidpointertype,voidpointertype.def.size,tt_persistent)
  1862. else
  1863. tempnode := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,tt_persistent);
  1864. addstatement(createstatement,tempnode);
  1865. addstatement(createstatement,cassignmentnode.create(ctemprefnode.create(tempnode),
  1866. caddrnode.create(para.left)));
  1867. hp := cderefnode.create(ctemprefnode.create(tempnode));
  1868. inserttypeconv_explicit(hp,para.left.resulttype);
  1869. para.left := hp;
  1870. addstatement(deletestatement,ctempdeletenode.create(tempnode));
  1871. end;
  1872. para := tcallparanode(para.right);
  1873. end;
  1874. end;
  1875. {$ifndef VER1_0}
  1876. { local variables }
  1877. if not assigned(tprocdef(procdefinition).localst) or
  1878. (tprocdef(procdefinition).localst.symindex.count = 0) then
  1879. exit;
  1880. tempnodes.createstatement := createstatement;
  1881. tempnodes.deletestatement := deletestatement;
  1882. setlength(inlinelocals,tprocdef(procdefinition).localst.symindex.count);
  1883. tprocdef(procdefinition).localst.foreach(@createlocaltemps,@tempnodes);
  1884. createstatement := tempnodes.createstatement;
  1885. deletestatement := tempnodes.deletestatement;
  1886. {$endif ndef VER1_0}
  1887. end;
  1888. function tcallnode.pass_1 : tnode;
  1889. var
  1890. createstatement,deletestatement: tstatementnode;
  1891. createblock,deleteblock: tblocknode;
  1892. i: longint;
  1893. label
  1894. errorexit;
  1895. begin
  1896. result:=nil;
  1897. (*
  1898. if (procdefinition.proccalloption=pocall_inline) and
  1899. { can we inline this procedure at the node level? }
  1900. (tprocdef(procdefinition).inlininginfo^.inlinenode) then
  1901. begin
  1902. { inherit flags }
  1903. current_procinfo.flags := current_procinfo.flags + ((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  1904. if assigned(methodpointer) then
  1905. CGMessage(cg_e_unable_inline_object_methods);
  1906. if assigned(right) then
  1907. CGMessage(cg_e_unable_inline_procvar);
  1908. if assigned(inlinecode) then
  1909. internalerror(2004071110);
  1910. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  1911. result:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  1912. else
  1913. CGMessage(cg_e_no_code_for_inline_stored);
  1914. if assigned(result) then
  1915. begin
  1916. createblock := internalstatements(createstatement);
  1917. deleteblock := internalstatements(deletestatement);
  1918. { replace complex parameters with temps }
  1919. createinlineparas(createstatement,deletestatement);
  1920. { replace the parameter loads with the parameter values }
  1921. foreachnode(result,replaceparaload,@fileinfo);
  1922. { free the temps for the locals }
  1923. for i := 0 to high(inlinelocals) do
  1924. if assigned(inlinelocals[i]) then
  1925. inlinelocals[i].free;
  1926. setlength(inlinelocals,0);
  1927. addstatement(createstatement,result);
  1928. addstatement(createstatement,deleteblock);
  1929. { set function result location if necessary }
  1930. if assigned(funcretnode) and
  1931. (cnf_return_value_used in callnodeflags) then
  1932. addstatement(createstatement,funcretnode.getcopy);
  1933. result := createblock;
  1934. { consider it must not be inlined if called
  1935. again inside the args or itself }
  1936. procdefinition.proccalloption:=pocall_default;
  1937. firstpass(result);
  1938. procdefinition.proccalloption:=pocall_inline;
  1939. exit;
  1940. end;
  1941. end;
  1942. *)
  1943. { calculate the parameter info for the procdef }
  1944. if not procdefinition.has_paraloc_info then
  1945. begin
  1946. procdefinition.requiredargarea:=paramanager.create_paraloc_info(procdefinition,callerside);
  1947. procdefinition.has_paraloc_info:=true;
  1948. end;
  1949. { calculate the parameter size needed for this call include varargs if they are available }
  1950. if assigned(varargsparas) then
  1951. pushedparasize:=paramanager.create_varargs_paraloc_info(procdefinition,varargsparas)
  1952. else
  1953. pushedparasize:=procdefinition.requiredargarea;
  1954. { record maximum parameter size used in this proc }
  1955. current_procinfo.allocate_push_parasize(pushedparasize);
  1956. { work trough all parameters to get the register requirements }
  1957. if assigned(left) then
  1958. tcallparanode(left).det_registers;
  1959. { order parameters }
  1960. order_parameters;
  1961. if assigned(methodpointerinit) then
  1962. firstpass(methodpointerinit);
  1963. if assigned(methodpointerdone) then
  1964. firstpass(methodpointerdone);
  1965. { function result node }
  1966. if assigned(_funcretnode) then
  1967. firstpass(_funcretnode);
  1968. { procedure variable ? }
  1969. if assigned(right) then
  1970. begin
  1971. firstpass(right);
  1972. { procedure does a call }
  1973. if not (block_type in [bt_const,bt_type]) then
  1974. include(current_procinfo.flags,pi_do_call);
  1975. end
  1976. else
  1977. { not a procedure variable }
  1978. begin
  1979. { calc the correture value for the register }
  1980. { handle predefined procedures }
  1981. if (procdefinition.proccalloption=pocall_inline) then
  1982. begin
  1983. { inherit flags }
  1984. current_procinfo.flags := current_procinfo.flags + ((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  1985. if assigned(methodpointer) then
  1986. CGMessage(cg_e_unable_inline_object_methods);
  1987. if assigned(right) then
  1988. CGMessage(cg_e_unable_inline_procvar);
  1989. if not assigned(inlinecode) then
  1990. begin
  1991. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  1992. inlinecode:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  1993. else
  1994. CGMessage(cg_e_no_code_for_inline_stored);
  1995. if assigned(inlinecode) then
  1996. begin
  1997. { consider it has not inlined if called
  1998. again inside the args }
  1999. procdefinition.proccalloption:=pocall_default;
  2000. firstpass(inlinecode);
  2001. end;
  2002. end;
  2003. end
  2004. else
  2005. begin
  2006. if not (block_type in [bt_const,bt_type]) then
  2007. include(current_procinfo.flags,pi_do_call);
  2008. end;
  2009. end;
  2010. { implicit finally needed ? }
  2011. if resulttype.def.needs_inittable and
  2012. not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) and
  2013. not assigned(funcretnode) then
  2014. include(current_procinfo.flags,pi_needs_implicit_finally);
  2015. { get a register for the return value }
  2016. if (not is_void(resulttype.def)) then
  2017. begin
  2018. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  2019. begin
  2020. expectloc:=LOC_REFERENCE;
  2021. end
  2022. else
  2023. { for win32 records returned in EDX:EAX, we
  2024. move them to memory after ... }
  2025. if (resulttype.def.deftype=recorddef) then
  2026. begin
  2027. expectloc:=LOC_REFERENCE;
  2028. end
  2029. else
  2030. { ansi/widestrings must be registered, so we can dispose them }
  2031. if is_ansistring(resulttype.def) or
  2032. is_widestring(resulttype.def) then
  2033. begin
  2034. expectloc:=LOC_REFERENCE;
  2035. registersint:=1;
  2036. end
  2037. else
  2038. { we have only to handle the result if it is used }
  2039. if (cnf_return_value_used in callnodeflags) then
  2040. begin
  2041. case resulttype.def.deftype of
  2042. enumdef,
  2043. orddef :
  2044. begin
  2045. if (procdefinition.proctypeoption=potype_constructor) then
  2046. begin
  2047. expectloc:=LOC_REGISTER;
  2048. registersint:=1;
  2049. end
  2050. else
  2051. begin
  2052. expectloc:=LOC_REGISTER;
  2053. if is_64bit(resulttype.def) then
  2054. registersint:=2
  2055. else
  2056. registersint:=1;
  2057. end;
  2058. end;
  2059. floatdef :
  2060. begin
  2061. expectloc:=LOC_FPUREGISTER;
  2062. {$ifdef cpufpemu}
  2063. if (cs_fp_emulation in aktmoduleswitches) then
  2064. registersint:=1
  2065. else
  2066. {$endif cpufpemu}
  2067. {$ifdef m68k}
  2068. if (tfloatdef(resulttype.def).typ=s32real) then
  2069. registersint:=1
  2070. else
  2071. {$endif m68k}
  2072. registersfpu:=1;
  2073. end;
  2074. else
  2075. begin
  2076. expectloc:=LOC_REGISTER;
  2077. registersint:=1;
  2078. end;
  2079. end;
  2080. end
  2081. else
  2082. expectloc:=LOC_VOID;
  2083. end
  2084. else
  2085. expectloc:=LOC_VOID;
  2086. {$ifdef m68k}
  2087. { we need one more address register for virtual calls on m68k }
  2088. if (po_virtualmethod in procdefinition.procoptions) then
  2089. inc(registersint);
  2090. {$endif m68k}
  2091. { a fpu can be used in any procedure !! }
  2092. {$ifdef i386}
  2093. registersfpu:=procdefinition.fpu_used;
  2094. {$endif i386}
  2095. { if this is a call to a method calc the registers }
  2096. if (methodpointer<>nil) then
  2097. begin
  2098. if methodpointer.nodetype<>typen then
  2099. begin
  2100. firstpass(methodpointer);
  2101. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  2102. registersint:=max(methodpointer.registersint,registersint);
  2103. {$ifdef SUPPORT_MMX }
  2104. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  2105. {$endif SUPPORT_MMX}
  2106. end;
  2107. end;
  2108. { determine the registers of the procedure variable }
  2109. { is this OK for inlined procs also ?? (PM) }
  2110. if assigned(inlinecode) then
  2111. begin
  2112. registersfpu:=max(inlinecode.registersfpu,registersfpu);
  2113. registersint:=max(inlinecode.registersint,registersint);
  2114. {$ifdef SUPPORT_MMX}
  2115. registersmmx:=max(inlinecode.registersmmx,registersmmx);
  2116. {$endif SUPPORT_MMX}
  2117. end;
  2118. { determine the registers of the procedure variable }
  2119. { is this OK for inlined procs also ?? (PM) }
  2120. if assigned(right) then
  2121. begin
  2122. registersfpu:=max(right.registersfpu,registersfpu);
  2123. registersint:=max(right.registersint,registersint);
  2124. {$ifdef SUPPORT_MMX}
  2125. registersmmx:=max(right.registersmmx,registersmmx);
  2126. {$endif SUPPORT_MMX}
  2127. end;
  2128. { determine the registers of the procedure }
  2129. if assigned(left) then
  2130. begin
  2131. registersfpu:=max(left.registersfpu,registersfpu);
  2132. registersint:=max(left.registersint,registersint);
  2133. {$ifdef SUPPORT_MMX}
  2134. registersmmx:=max(left.registersmmx,registersmmx);
  2135. {$endif SUPPORT_MMX}
  2136. end;
  2137. errorexit:
  2138. if assigned(inlinecode) then
  2139. procdefinition.proccalloption:=pocall_inline;
  2140. end;
  2141. {$ifdef state_tracking}
  2142. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  2143. var hp:Tcallparanode;
  2144. value:Tnode;
  2145. begin
  2146. track_state_pass:=false;
  2147. hp:=Tcallparanode(left);
  2148. while assigned(hp) do
  2149. begin
  2150. if left.track_state_pass(exec_known) then
  2151. begin
  2152. left.resulttype.def:=nil;
  2153. do_resulttypepass(left);
  2154. end;
  2155. value:=aktstate.find_fact(hp.left);
  2156. if value<>nil then
  2157. begin
  2158. track_state_pass:=true;
  2159. hp.left.destroy;
  2160. hp.left:=value.getcopy;
  2161. do_resulttypepass(hp.left);
  2162. end;
  2163. hp:=Tcallparanode(hp.right);
  2164. end;
  2165. end;
  2166. {$endif}
  2167. function tcallnode.para_count:longint;
  2168. var
  2169. ppn : tcallparanode;
  2170. begin
  2171. result:=0;
  2172. ppn:=tcallparanode(left);
  2173. while assigned(ppn) do
  2174. begin
  2175. if not(assigned(ppn.paraitem) and
  2176. ppn.paraitem.is_hidden) then
  2177. inc(result);
  2178. ppn:=tcallparanode(ppn.right);
  2179. end;
  2180. end;
  2181. function tcallnode.docompare(p: tnode): boolean;
  2182. begin
  2183. docompare :=
  2184. inherited docompare(p) and
  2185. (symtableprocentry = tcallnode(p).symtableprocentry) and
  2186. (procdefinition = tcallnode(p).procdefinition) and
  2187. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  2188. (((cnf_restypeset in callnodeflags) and (cnf_restypeset in tcallnode(p).callnodeflags) and
  2189. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  2190. (not(cnf_restypeset in callnodeflags) and not(cnf_restypeset in tcallnode(p).callnodeflags)));
  2191. end;
  2192. procedure tcallnode.printnodedata(var t:text);
  2193. begin
  2194. if assigned(procdefinition) and
  2195. (procdefinition.deftype=procdef) then
  2196. writeln(t,printnodeindention,'proc = ',tprocdef(procdefinition).fullprocname(true))
  2197. else
  2198. begin
  2199. if assigned(symtableprocentry) then
  2200. writeln(t,printnodeindention,'proc = ',symtableprocentry.name)
  2201. else
  2202. writeln(t,printnodeindention,'proc = <nil>');
  2203. end;
  2204. printnode(t,methodpointer);
  2205. printnode(t,right);
  2206. printnode(t,left);
  2207. end;
  2208. begin
  2209. ccallnode:=tcallnode;
  2210. ccallparanode:=tcallparanode;
  2211. end.
  2212. {
  2213. $Log$
  2214. Revision 1.255 2004-11-01 16:58:57 peter
  2215. * give IE instead of crash when no procsym is passed for calln
  2216. Revision 1.254 2004/10/31 21:45:03 peter
  2217. * generic tlocation
  2218. * move tlocation to cgutils
  2219. Revision 1.253 2004/10/25 15:38:41 peter
  2220. * heap and heapsize removed
  2221. * checkpointer fixes
  2222. Revision 1.252 2004/10/15 09:14:16 mazen
  2223. - remove $IFDEF DELPHI and related code
  2224. - remove $IFDEF FPCPROCVAR and related code
  2225. Revision 1.251 2004/10/12 14:36:38 peter
  2226. * gen high tree makes copy in temp when there is a calln
  2227. Revision 1.250 2004/10/10 20:22:53 peter
  2228. * symtable allocation rewritten
  2229. * loading of parameters to local temps/regs cleanup
  2230. * regvar support for parameters
  2231. * regvar support for staticsymtable (main body)
  2232. Revision 1.249 2004/10/08 17:09:43 peter
  2233. * tvarsym.varregable added, split vo_regable from varoptions
  2234. Revision 1.248 2004/09/21 17:25:12 peter
  2235. * paraloc branch merged
  2236. Revision 1.247 2004/09/13 20:29:00 peter
  2237. * use realname for abstract procs found
  2238. Revision 1.246.4.1 2004/08/31 20:43:06 peter
  2239. * paraloc patch
  2240. Revision 1.246 2004/08/28 20:00:50 peter
  2241. * use objrealname in Message1
  2242. Revision 1.245 2004/08/22 10:17:13 peter
  2243. * fixed crash when passing array constructor to formal parameter
  2244. Revision 1.244 2004/08/14 14:50:42 florian
  2245. * fixed several sparc alignment issues
  2246. + Jonas' inline node patch; non functional yet
  2247. Revision 1.243 2004/07/16 19:45:15 jonas
  2248. + temps can now also hold fpu values in registers (take care with use,
  2249. bacause of the x86 fpu stack)
  2250. * fpu parameters to node-inlined procedures can now also be put in
  2251. a register
  2252. Revision 1.242 2004/07/15 21:02:05 jonas
  2253. * the condition for when to use a temp in case of reference var/const
  2254. parameters was inverse
  2255. Revision 1.241 2004/07/15 19:55:39 jonas
  2256. + (incomplete) node_complexity function to assess the complexity of a
  2257. tree
  2258. + support for inlining value and const parameters at the node level
  2259. (all procedures without local variables and without formal parameters
  2260. can now be inlined at the node level)
  2261. Revision 1.240 2004/07/12 09:14:04 jonas
  2262. * inline procedures at the node tree level, but only under some very
  2263. limited circumstances for now (only procedures, and only if they have
  2264. no or only vs_out/vs_var parameters).
  2265. * fixed ppudump for inline procedures
  2266. * fixed ppudump for ppc
  2267. Revision 1.239 2004/06/20 08:55:29 florian
  2268. * logs truncated
  2269. Revision 1.238 2004/06/16 20:07:08 florian
  2270. * dwarf branch merged
  2271. Revision 1.237 2004/05/25 18:51:49 peter
  2272. * fix tcallnode.getcopy. the parameters need to be copied after
  2273. methodpointerinit is copied
  2274. Revision 1.236 2004/05/24 17:31:51 peter
  2275. * fix passing of array to open array of array (bug 3113)
  2276. Revision 1.235 2004/05/23 18:28:41 peter
  2277. * methodpointer is loaded into a temp when it was a calln
  2278. Revision 1.234 2004/05/23 15:06:20 peter
  2279. * implicit_finally flag must be set in pass1
  2280. * add check whether the implicit frame is generated when expected
  2281. }