ncal.pas 95 KB

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