ncal.pas 97 KB

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