ncal.pas 97 KB

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