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