ncal.pas 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668
  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,
  25. node,nbas,
  26. {$ifdef state_tracking}
  27. nstate,
  28. {$endif state_tracking}
  29. symbase,symtype,symsym,symdef,symtable;
  30. type
  31. tcallnodeflags = (
  32. cnf_restypeset
  33. );
  34. tcallnodeflagset = set of tcallnodeflags;
  35. tcallnode = class(tbinarynode)
  36. private
  37. { number of parameters passed from the source, this does not include the hidden parameters }
  38. paralength : smallint;
  39. function gen_self_tree_methodpointer:tnode;
  40. function gen_self_tree:tnode;
  41. function gen_vmt_tree:tnode;
  42. procedure bind_paraitem;
  43. { function return node, this is used to pass the data for a
  44. ret_in_param return value }
  45. _funcretnode : tnode;
  46. procedure setfuncretnode(const returnnode: tnode);
  47. procedure convert_carg_array_of_const;
  48. procedure order_parameters;
  49. public
  50. { the symbol containing the definition of the procedure }
  51. { to call }
  52. symtableprocentry : tprocsym;
  53. symtableprocentryderef : tderef;
  54. { symtable where the entry was found, needed for with support }
  55. symtableproc : tsymtable;
  56. { the definition of the procedure to call }
  57. procdefinition : tabstractprocdef;
  58. procdefinitionderef : tderef;
  59. { tree that contains the pointer to the object for this method }
  60. methodpointer : tnode;
  61. { inline function body }
  62. inlinecode : tnode;
  63. { varargs tparaitems }
  64. varargsparas : tvarargspara;
  65. { node that specifies where the result should be put for calls }
  66. { that return their result in a parameter }
  67. property funcretnode: tnode read _funcretnode write setfuncretnode;
  68. { separately specified resulttype for some compilerprocs (e.g. }
  69. { you can't have a function with an "array of char" resulttype }
  70. { the RTL) (JM) }
  71. restype: ttype;
  72. callnodeflags : tcallnodeflagset;
  73. { only the processor specific nodes need to override this }
  74. { constructor }
  75. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
  76. constructor create_def(l:tnode;def:tprocdef;mp:tnode);virtual;
  77. constructor create_procvar(l,r:tnode);
  78. constructor createintern(const name: string; params: tnode);
  79. constructor createinternres(const name: string; params: tnode; const res: ttype);
  80. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  81. destructor destroy;override;
  82. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;
  84. procedure buildderefimpl;override;
  85. procedure derefimpl;override;
  86. function getcopy : tnode;override;
  87. { Goes through all symbols in a class and subclasses and calls
  88. verify abstract for each .
  89. }
  90. procedure verifyabstractcalls;
  91. { called for each definition in a class and verifies if a method
  92. is abstract or not, if it is abstract, give out a warning
  93. }
  94. procedure verifyabstract(p : tnamedindexitem;arg:pointer);
  95. procedure insertintolist(l : tnodelist);override;
  96. function pass_1 : tnode;override;
  97. function det_resulttype:tnode;override;
  98. {$ifdef state_tracking}
  99. function track_state_pass(exec_known:boolean):boolean;override;
  100. {$endif state_tracking}
  101. function docompare(p: tnode): boolean; override;
  102. procedure printnodedata(var t:text);override;
  103. function para_count:longint;
  104. private
  105. AbstractMethodsList : TStringList;
  106. end;
  107. tcallnodeclass = class of tcallnode;
  108. tcallparaflags = (
  109. { flags used by tcallparanode }
  110. cpf_is_colon_para
  111. );
  112. tcallparanode = class(tbinarynode)
  113. public
  114. callparaflags : set of tcallparaflags;
  115. paraitem : tparaitem;
  116. used_by_callnode : boolean;
  117. { only the processor specific nodes need to override this }
  118. { constructor }
  119. constructor create(expr,next : tnode);virtual;
  120. destructor destroy;override;
  121. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  122. procedure ppuwrite(ppufile:tcompilerppufile);override;
  123. function getcopy : tnode;override;
  124. procedure insertintolist(l : tnodelist);override;
  125. procedure get_paratype;
  126. procedure insert_typeconv(do_count : boolean);
  127. procedure det_registers;
  128. procedure firstcallparan;
  129. procedure secondcallparan;virtual;abstract;
  130. function docompare(p: tnode): boolean; override;
  131. procedure printnodetree(var t:text);override;
  132. end;
  133. tcallparanodeclass = class of tcallparanode;
  134. function reverseparameters(p: tcallparanode): tcallparanode;
  135. var
  136. ccallnode : tcallnodeclass;
  137. ccallparanode : tcallparanodeclass;
  138. { Current callnode, this is needed for having a link
  139. between the callparanodes and the callnode they belong to }
  140. aktcallnode : tcallnode;
  141. implementation
  142. uses
  143. systems,
  144. verbose,globals,
  145. symconst,defutil,defcmp,
  146. htypechk,pass_1,
  147. ncnv,nld,ninl,nadd,ncon,nmem,nutils,
  148. procinfo,
  149. cgbase
  150. ;
  151. type
  152. tobjectinfoitem = class(tlinkedlistitem)
  153. objinfo : tobjectdef;
  154. constructor create(def : tobjectdef);
  155. end;
  156. {****************************************************************************
  157. HELPERS
  158. ****************************************************************************}
  159. function reverseparameters(p: tcallparanode): tcallparanode;
  160. var
  161. hp1, hp2: tcallparanode;
  162. begin
  163. hp1:=nil;
  164. while assigned(p) do
  165. begin
  166. { pull out }
  167. hp2:=p;
  168. p:=tcallparanode(p.right);
  169. { pull in }
  170. hp2.right:=hp1;
  171. hp1:=hp2;
  172. end;
  173. reverseparameters:=hp1;
  174. end;
  175. function gen_high_tree(p:tnode;openstring:boolean):tnode;
  176. var
  177. temp: tnode;
  178. len : integer;
  179. loadconst : boolean;
  180. hightree : tnode;
  181. begin
  182. len:=-1;
  183. loadconst:=true;
  184. hightree:=nil;
  185. case p.resulttype.def.deftype of
  186. arraydef :
  187. begin
  188. { handle via a normal inline in_high_x node }
  189. loadconst := false;
  190. hightree := geninlinenode(in_high_x,false,p.getcopy);
  191. { only substract low(array) if it's <> 0 }
  192. temp := geninlinenode(in_low_x,false,p.getcopy);
  193. resulttypepass(temp);
  194. if (temp.nodetype <> ordconstn) or
  195. (tordconstnode(temp).value <> 0) then
  196. hightree := caddnode.create(subn,hightree,temp)
  197. else
  198. temp.free;
  199. end;
  200. stringdef :
  201. begin
  202. if openstring then
  203. begin
  204. { handle via a normal inline in_high_x node }
  205. loadconst := false;
  206. hightree := geninlinenode(in_high_x,false,p.getcopy);
  207. end
  208. else
  209. begin
  210. { passing a string to an array of char }
  211. if (p.nodetype=stringconstn) then
  212. begin
  213. len:=str_length(p);
  214. if len>0 then
  215. dec(len);
  216. end
  217. else
  218. begin
  219. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
  220. cordconstnode.create(1,s32inttype,false));
  221. loadconst:=false;
  222. end;
  223. end;
  224. end;
  225. else
  226. len:=0;
  227. end;
  228. if loadconst then
  229. hightree:=cordconstnode.create(len,s32inttype,true)
  230. else
  231. begin
  232. if not assigned(hightree) then
  233. internalerror(200304071);
  234. { Need to use explicit, because it can also be a enum }
  235. hightree:=ctypeconvnode.create_explicit(hightree,s32inttype);
  236. end;
  237. result:=hightree;
  238. end;
  239. {****************************************************************************
  240. TOBJECTINFOITEM
  241. ****************************************************************************}
  242. constructor tobjectinfoitem.create(def : tobjectdef);
  243. begin
  244. inherited create;
  245. objinfo := def;
  246. end;
  247. {****************************************************************************
  248. TCALLPARANODE
  249. ****************************************************************************}
  250. constructor tcallparanode.create(expr,next : tnode);
  251. begin
  252. inherited create(callparan,expr,next);
  253. if not assigned(expr) then
  254. internalerror(200305091);
  255. expr.set_file_line(self);
  256. callparaflags:=[];
  257. end;
  258. destructor tcallparanode.destroy;
  259. begin
  260. { When the node is used by callnode then
  261. we don't destroy left, the callnode takes care of it }
  262. if used_by_callnode then
  263. left:=nil;
  264. inherited destroy;
  265. end;
  266. constructor tcallparanode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  267. begin
  268. inherited ppuload(t,ppufile);
  269. ppufile.getsmallset(callparaflags);
  270. end;
  271. procedure tcallparanode.ppuwrite(ppufile:tcompilerppufile);
  272. begin
  273. inherited ppuwrite(ppufile);
  274. ppufile.putsmallset(callparaflags);
  275. end;
  276. function tcallparanode.getcopy : tnode;
  277. var
  278. n : tcallparanode;
  279. begin
  280. n:=tcallparanode(inherited getcopy);
  281. n.callparaflags:=callparaflags;
  282. n.paraitem:=paraitem;
  283. result:=n;
  284. end;
  285. procedure tcallparanode.insertintolist(l : tnodelist);
  286. begin
  287. end;
  288. procedure tcallparanode.get_paratype;
  289. var
  290. old_array_constructor : boolean;
  291. begin
  292. inc(parsing_para_level);
  293. if assigned(right) then
  294. tcallparanode(right).get_paratype;
  295. old_array_constructor:=allow_array_constructor;
  296. allow_array_constructor:=true;
  297. resulttypepass(left);
  298. allow_array_constructor:=old_array_constructor;
  299. if codegenerror then
  300. resulttype:=generrortype
  301. else
  302. resulttype:=left.resulttype;
  303. dec(parsing_para_level);
  304. end;
  305. procedure tcallparanode.insert_typeconv(do_count : boolean);
  306. var
  307. oldtype : ttype;
  308. {$ifdef extdebug}
  309. store_count_ref : boolean;
  310. {$endif def extdebug}
  311. begin
  312. inc(parsing_para_level);
  313. {$ifdef extdebug}
  314. if do_count then
  315. begin
  316. store_count_ref:=count_ref;
  317. count_ref:=true;
  318. end;
  319. {$endif def extdebug}
  320. { Be sure to have the resulttype }
  321. if not assigned(left.resulttype.def) then
  322. resulttypepass(left);
  323. if (left.nodetype<>nothingn) then
  324. begin
  325. { Convert tp procvars, this is needs to be done
  326. here to make the change permanent. in the overload
  327. choosing the changes are only made temporary }
  328. if (left.resulttype.def.deftype=procvardef) and
  329. (paraitem.paratype.def.deftype<>procvardef) then
  330. begin
  331. if maybe_call_procvar(left,true) then
  332. resulttype:=left.resulttype;
  333. end;
  334. { Handle varargs and hidden paras directly, no typeconvs or }
  335. { typechecking needed }
  336. if (nf_varargs_para in flags) then
  337. begin
  338. { convert pascal to C types }
  339. case left.resulttype.def.deftype of
  340. stringdef :
  341. inserttypeconv(left,charpointertype);
  342. floatdef :
  343. inserttypeconv(left,s64floattype);
  344. end;
  345. set_varstate(left,vs_used,true);
  346. resulttype:=left.resulttype;
  347. end
  348. else
  349. if (paraitem.is_hidden) then
  350. begin
  351. set_varstate(left,vs_used,true);
  352. resulttype:=left.resulttype;
  353. end
  354. else
  355. begin
  356. { Do we need arrayconstructor -> set conversion, then insert
  357. it here before the arrayconstructor node breaks the tree
  358. with its conversions of enum->ord }
  359. if (left.nodetype=arrayconstructorn) and
  360. (paraitem.paratype.def.deftype=setdef) then
  361. inserttypeconv(left,paraitem.paratype);
  362. { set some settings needed for arrayconstructor }
  363. if is_array_constructor(left.resulttype.def) then
  364. begin
  365. if is_array_of_const(paraitem.paratype.def) then
  366. begin
  367. { force variant array }
  368. include(left.flags,nf_forcevaria);
  369. end
  370. else
  371. begin
  372. include(left.flags,nf_novariaallowed);
  373. { now that the resultting type is know we can insert the required
  374. typeconvs for the array constructor }
  375. tarrayconstructornode(left).force_type(tarraydef(paraitem.paratype.def).elementtype);
  376. end;
  377. end;
  378. { check if local proc/func is assigned to procvar }
  379. if left.resulttype.def.deftype=procvardef then
  380. test_local_to_procvar(tprocvardef(left.resulttype.def),paraitem.paratype.def);
  381. { test conversions }
  382. if not(is_shortstring(left.resulttype.def) and
  383. is_shortstring(paraitem.paratype.def)) and
  384. (paraitem.paratype.def.deftype<>formaldef) then
  385. begin
  386. { Process open parameters }
  387. if paramanager.push_high_param(paraitem.paratyp,paraitem.paratype.def,aktcallnode.procdefinition.proccalloption) then
  388. begin
  389. { insert type conv but hold the ranges of the array }
  390. oldtype:=left.resulttype;
  391. inserttypeconv(left,paraitem.paratype);
  392. left.resulttype:=oldtype;
  393. end
  394. else
  395. begin
  396. { for ordinals, floats and enums, verify if we might cause
  397. some range-check errors. }
  398. if (paraitem.paratype.def.deftype in [enumdef,orddef,floatdef]) and
  399. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) and
  400. (left.nodetype in [vecn,loadn,calln]) then
  401. begin
  402. if (left.resulttype.def.size>paraitem.paratype.def.size) then
  403. begin
  404. if (cs_check_range in aktlocalswitches) then
  405. Message(type_w_smaller_possible_range_check)
  406. else
  407. Message(type_h_smaller_possible_range_check);
  408. end;
  409. end;
  410. inserttypeconv(left,paraitem.paratype);
  411. end;
  412. if codegenerror then
  413. begin
  414. dec(parsing_para_level);
  415. exit;
  416. end;
  417. end;
  418. { check var strings }
  419. if (cs_strict_var_strings in aktlocalswitches) and
  420. is_shortstring(left.resulttype.def) and
  421. is_shortstring(paraitem.paratype.def) and
  422. (paraitem.paratyp in [vs_out,vs_var]) and
  423. not(is_open_string(paraitem.paratype.def)) and
  424. not(equal_defs(left.resulttype.def,paraitem.paratype.def)) then
  425. begin
  426. aktfilepos:=left.fileinfo;
  427. CGMessage(type_e_strict_var_string_violation);
  428. end;
  429. { Handle formal parameters separate }
  430. if (paraitem.paratype.def.deftype=formaldef) then
  431. begin
  432. { load procvar if a procedure is passed }
  433. if (m_tp_procvar in aktmodeswitches) and
  434. (left.nodetype=calln) and
  435. (is_void(left.resulttype.def)) then
  436. load_procvar_from_calln(left);
  437. case paraitem.paratyp of
  438. vs_var,
  439. vs_out :
  440. begin
  441. if not valid_for_formal_var(left) then
  442. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  443. end;
  444. vs_const :
  445. begin
  446. if not valid_for_formal_const(left) then
  447. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  448. end;
  449. end;
  450. end
  451. else
  452. begin
  453. { check if the argument is allowed }
  454. if (paraitem.paratyp in [vs_out,vs_var]) then
  455. valid_for_var(left);
  456. end;
  457. if paraitem.paratyp in [vs_var,vs_const] then
  458. begin
  459. { Causes problems with const ansistrings if also }
  460. { done for vs_const (JM) }
  461. if paraitem.paratyp = vs_var then
  462. set_unique(left);
  463. make_not_regable(left);
  464. end;
  465. { ansistrings out paramaters doesn't need to be }
  466. { unique, they are finalized }
  467. if paraitem.paratyp=vs_out then
  468. make_not_regable(left);
  469. if do_count then
  470. begin
  471. if paraitem.paratyp in [vs_var,vs_out] then
  472. set_varstate(left,vs_used,false)
  473. else
  474. set_varstate(left,vs_used,true);
  475. end;
  476. { must only be done after typeconv PM }
  477. resulttype:=paraitem.paratype;
  478. end;
  479. end;
  480. { process next node }
  481. if assigned(right) then
  482. tcallparanode(right).insert_typeconv(do_count);
  483. dec(parsing_para_level);
  484. {$ifdef extdebug}
  485. if do_count then
  486. count_ref:=store_count_ref;
  487. {$endif def extdebug}
  488. end;
  489. procedure tcallparanode.det_registers;
  490. begin
  491. if assigned(right) then
  492. begin
  493. tcallparanode(right).det_registers;
  494. registersint:=right.registersint;
  495. registersfpu:=right.registersfpu;
  496. {$ifdef SUPPORT_MMX}
  497. registersmmx:=right.registersmmx;
  498. {$endif}
  499. end;
  500. firstpass(left);
  501. if left.registersint>registersint then
  502. registersint:=left.registersint;
  503. if left.registersfpu>registersfpu then
  504. registersfpu:=left.registersfpu;
  505. {$ifdef SUPPORT_MMX}
  506. if left.registersmmx>registersmmx then
  507. registersmmx:=left.registersmmx;
  508. {$endif SUPPORT_MMX}
  509. end;
  510. procedure tcallparanode.firstcallparan;
  511. begin
  512. if not assigned(left.resulttype.def) then
  513. get_paratype;
  514. det_registers;
  515. end;
  516. function tcallparanode.docompare(p: tnode): boolean;
  517. begin
  518. docompare :=
  519. inherited docompare(p) and
  520. (callparaflags = tcallparanode(p).callparaflags)
  521. ;
  522. end;
  523. procedure tcallparanode.printnodetree(var t:text);
  524. begin
  525. printnodelist(t);
  526. end;
  527. {****************************************************************************
  528. TCALLNODE
  529. ****************************************************************************}
  530. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
  531. begin
  532. inherited create(calln,l,nil);
  533. symtableprocentry:=v;
  534. symtableproc:=st;
  535. include(flags,nf_return_value_used);
  536. methodpointer:=mp;
  537. procdefinition:=nil;
  538. callnodeflags:=[];
  539. _funcretnode:=nil;
  540. inlinecode:=nil;
  541. paralength:=-1;
  542. varargsparas:=nil;
  543. end;
  544. constructor tcallnode.create_def(l:tnode;def:tprocdef;mp:tnode);
  545. begin
  546. inherited create(calln,l,nil);
  547. symtableprocentry:=nil;
  548. symtableproc:=nil;
  549. include(flags,nf_return_value_used);
  550. methodpointer:=mp;
  551. procdefinition:=def;
  552. callnodeflags:=[];
  553. _funcretnode:=nil;
  554. inlinecode:=nil;
  555. paralength:=-1;
  556. varargsparas:=nil;
  557. end;
  558. constructor tcallnode.create_procvar(l,r:tnode);
  559. begin
  560. inherited create(calln,l,r);
  561. symtableprocentry:=nil;
  562. symtableproc:=nil;
  563. include(flags,nf_return_value_used);
  564. methodpointer:=nil;
  565. procdefinition:=nil;
  566. callnodeflags:=[];
  567. _funcretnode:=nil;
  568. inlinecode:=nil;
  569. paralength:=-1;
  570. varargsparas:=nil;
  571. end;
  572. constructor tcallnode.createintern(const name: string; params: tnode);
  573. var
  574. srsym: tsym;
  575. symowner: tsymtable;
  576. begin
  577. if not (cs_compilesystem in aktmoduleswitches) then
  578. begin
  579. srsym := searchsymonlyin(systemunit,name);
  580. symowner := systemunit;
  581. end
  582. else
  583. begin
  584. searchsym(name,srsym,symowner);
  585. if not assigned(srsym) then
  586. searchsym(upper(name),srsym,symowner);
  587. end;
  588. if not assigned(srsym) or
  589. (srsym.typ <> procsym) then
  590. begin
  591. {$ifdef EXTDEBUG}
  592. Comment(V_Error,'unknown compilerproc '+name);
  593. {$endif EXTDEBUG}
  594. internalerror(200107271);
  595. end;
  596. self.create(params,tprocsym(srsym),symowner,nil);
  597. end;
  598. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  599. begin
  600. self.createintern(name,params);
  601. restype := res;
  602. include(callnodeflags,cnf_restypeset);
  603. { both the normal and specified resulttype either have to be returned via a }
  604. { parameter or not, but no mixing (JM) }
  605. if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
  606. paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  607. internalerror(200108291);
  608. end;
  609. constructor tcallnode.createinternreturn(const name: string; params: tnode; returnnode : tnode);
  610. begin
  611. self.createintern(name,params);
  612. _funcretnode:=returnnode;
  613. if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  614. internalerror(200204247);
  615. end;
  616. procedure tcallnode.setfuncretnode(const returnnode: tnode);
  617. var
  618. para: tcallparanode;
  619. begin
  620. if assigned(_funcretnode) then
  621. _funcretnode.free;
  622. _funcretnode := returnnode;
  623. { if the resulttype pass hasn't occurred yet, that one will do }
  624. { everything }
  625. if assigned(resulttype.def) then
  626. begin
  627. { these are returned as values, but we can optimize their loading }
  628. { as well }
  629. if is_ansistring(resulttype.def) or
  630. is_widestring(resulttype.def) then
  631. exit;
  632. para := tcallparanode(left);
  633. while assigned(para) do
  634. begin
  635. if para.paraitem.is_hidden and
  636. (vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) then
  637. begin
  638. para.left.free;
  639. para.left := _funcretnode.getcopy;
  640. exit;
  641. end;
  642. para := tcallparanode(para.right);
  643. end;
  644. { no hidden resultpara found, error! }
  645. internalerror(200306087);
  646. end;
  647. end;
  648. destructor tcallnode.destroy;
  649. begin
  650. methodpointer.free;
  651. _funcretnode.free;
  652. inlinecode.free;
  653. if assigned(varargsparas) then
  654. varargsparas.free;
  655. inherited destroy;
  656. end;
  657. constructor tcallnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  658. begin
  659. inherited ppuload(t,ppufile);
  660. ppufile.getderef(symtableprocentryderef);
  661. {$ifdef fpc}
  662. {$warning FIXME: No withsymtable support}
  663. {$endif}
  664. symtableproc:=nil;
  665. ppufile.getderef(procdefinitionderef);
  666. ppufile.getsmallset(callnodeflags);
  667. methodpointer:=ppuloadnode(ppufile);
  668. _funcretnode:=ppuloadnode(ppufile);
  669. inlinecode:=ppuloadnode(ppufile);
  670. end;
  671. procedure tcallnode.ppuwrite(ppufile:tcompilerppufile);
  672. begin
  673. inherited ppuwrite(ppufile);
  674. ppufile.putderef(symtableprocentryderef);
  675. ppufile.putderef(procdefinitionderef);
  676. ppufile.putsmallset(callnodeflags);
  677. ppuwritenode(ppufile,methodpointer);
  678. ppuwritenode(ppufile,_funcretnode);
  679. ppuwritenode(ppufile,inlinecode);
  680. end;
  681. procedure tcallnode.buildderefimpl;
  682. begin
  683. inherited buildderefimpl;
  684. symtableprocentryderef.build(symtableprocentry);
  685. procdefinitionderef.build(procdefinition);
  686. if assigned(methodpointer) then
  687. methodpointer.buildderefimpl;
  688. if assigned(_funcretnode) then
  689. _funcretnode.buildderefimpl;
  690. if assigned(inlinecode) then
  691. inlinecode.buildderefimpl;
  692. end;
  693. procedure tcallnode.derefimpl;
  694. var
  695. pt : tcallparanode;
  696. currpara : tparaitem;
  697. begin
  698. inherited derefimpl;
  699. symtableprocentry:=tprocsym(symtableprocentryderef.resolve);
  700. symtableproc:=symtableprocentry.owner;
  701. procdefinition:=tprocdef(procdefinitionderef.resolve);
  702. if assigned(methodpointer) then
  703. methodpointer.derefimpl;
  704. if assigned(_funcretnode) then
  705. _funcretnode.derefimpl;
  706. if assigned(inlinecode) then
  707. inlinecode.derefimpl;
  708. { Connect paraitems }
  709. pt:=tcallparanode(left);
  710. while assigned(pt) and
  711. (nf_varargs_para in pt.flags) do
  712. pt:=tcallparanode(pt.right);
  713. currpara:=tparaitem(procdefinition.Para.last);
  714. while assigned(currpara) do
  715. begin
  716. if not assigned(pt) then
  717. internalerror(200311077);
  718. pt.paraitem:=currpara;
  719. pt:=tcallparanode(pt.right);
  720. currpara:=tparaitem(currpara.previous);
  721. end;
  722. if assigned(currpara) or assigned(pt) then
  723. internalerror(200311078);
  724. end;
  725. function tcallnode.getcopy : tnode;
  726. var
  727. n : tcallnode;
  728. hp : tparaitem;
  729. begin
  730. n:=tcallnode(inherited getcopy);
  731. n.symtableprocentry:=symtableprocentry;
  732. n.symtableproc:=symtableproc;
  733. n.procdefinition:=procdefinition;
  734. n.restype := restype;
  735. n.callnodeflags := callnodeflags;
  736. if assigned(methodpointer) then
  737. n.methodpointer:=methodpointer.getcopy
  738. else
  739. n.methodpointer:=nil;
  740. if assigned(_funcretnode) then
  741. n._funcretnode:=_funcretnode.getcopy
  742. else
  743. n._funcretnode:=nil;
  744. if assigned(inlinecode) then
  745. n.inlinecode:=inlinecode.getcopy
  746. else
  747. n.inlinecode:=nil;
  748. if assigned(varargsparas) then
  749. begin
  750. n.varargsparas:=tvarargspara.create;
  751. hp:=tparaitem(varargsparas.first);
  752. while assigned(hp) do
  753. begin
  754. n.varargsparas.concat(hp.getcopy);
  755. hp:=tparaitem(hp.next);
  756. end;
  757. end
  758. else
  759. n.varargsparas:=nil;
  760. result:=n;
  761. end;
  762. procedure tcallnode.insertintolist(l : tnodelist);
  763. begin
  764. end;
  765. procedure tcallnode.convert_carg_array_of_const;
  766. var
  767. hp : tarrayconstructornode;
  768. oldleft : tcallparanode;
  769. begin
  770. oldleft:=tcallparanode(left);
  771. if oldleft.left.nodetype<>arrayconstructorn then
  772. begin
  773. CGMessage1(type_e_wrong_type_in_array_constructor,oldleft.left.resulttype.def.typename);
  774. exit;
  775. end;
  776. { Get arrayconstructor node and insert typeconvs }
  777. hp:=tarrayconstructornode(oldleft.left);
  778. hp.insert_typeconvs;
  779. { Add c args parameters }
  780. { It could be an empty set }
  781. if assigned(hp) and
  782. assigned(hp.left) then
  783. begin
  784. while assigned(hp) do
  785. begin
  786. left:=ccallparanode.create(hp.left,left);
  787. { set callparanode resulttype and flags }
  788. left.resulttype:=hp.left.resulttype;
  789. include(left.flags,nf_varargs_para);
  790. hp.left:=nil;
  791. hp:=tarrayconstructornode(hp.right);
  792. end;
  793. end;
  794. { Remove value of old array of const parameter, but keep it
  795. in the list because it is required for bind_paraitem.
  796. Generate a nothign to keep callparanoed.left valid }
  797. oldleft.left.free;
  798. oldleft.left:=cnothingnode.create;
  799. end;
  800. procedure tcallnode.verifyabstract(p : tnamedindexitem;arg:pointer);
  801. var
  802. hp : tprocdef;
  803. j: integer;
  804. begin
  805. if (tsym(p).typ=procsym) then
  806. begin
  807. for j:=1 to tprocsym(p).procdef_count do
  808. begin
  809. { index starts at 1 }
  810. hp:=tprocsym(p).procdef[j];
  811. { If this is an abstract method insert into the list }
  812. if (po_abstractmethod in hp.procoptions) then
  813. AbstractMethodsList.Insert(hp.procsym.name)
  814. else
  815. { If this symbol is already in the list, and it is
  816. an overriding method or dynamic, then remove it from the list
  817. }
  818. begin
  819. { symbol was found }
  820. if AbstractMethodsList.Find(hp.procsym.name) <> nil then
  821. begin
  822. if po_overridingmethod in hp.procoptions then
  823. AbstractMethodsList.Remove(hp.procsym.name);
  824. end;
  825. end;
  826. end;
  827. end;
  828. end;
  829. procedure tcallnode.verifyabstractcalls;
  830. var
  831. objectdf : tobjectdef;
  832. parents : tlinkedlist;
  833. objectinfo : tobjectinfoitem;
  834. stritem : tstringlistitem;
  835. begin
  836. objectdf := nil;
  837. { verify if trying to create an instance of a class which contains
  838. non-implemented abstract methods }
  839. { first verify this class type, no class than exit }
  840. { also, this checking can only be done if the constructor is directly
  841. called, indirect constructor calls cannot be checked.
  842. }
  843. if assigned(methodpointer) then
  844. begin
  845. if (methodpointer.resulttype.def.deftype = objectdef) then
  846. objectdf:=tobjectdef(methodpointer.resulttype.def)
  847. else
  848. if (methodpointer.resulttype.def.deftype = classrefdef) and
  849. (tclassrefdef(methodpointer.resulttype.def).pointertype.def.deftype = objectdef) and
  850. (methodpointer.nodetype in [typen,loadvmtaddrn]) then
  851. objectdf:=tobjectdef(tclassrefdef(methodpointer.resulttype.def).pointertype.def);
  852. end;
  853. if not assigned(objectdf) then
  854. exit;
  855. parents := tlinkedlist.create;
  856. AbstractMethodsList := tstringlist.create;
  857. { insert all parents in this class : the first item in the
  858. list will be the base parent of the class .
  859. }
  860. while assigned(objectdf) do
  861. begin
  862. objectinfo:=tobjectinfoitem.create(objectdf);
  863. parents.insert(objectinfo);
  864. objectdf := objectdf.childof;
  865. end;
  866. { now all parents are in the correct order
  867. insert all abstract methods in the list, and remove
  868. those which are overriden by parent classes.
  869. }
  870. objectinfo:=tobjectinfoitem(parents.first);
  871. while assigned(objectinfo) do
  872. begin
  873. objectdf := objectinfo.objinfo;
  874. if assigned(objectdf.symtable) then
  875. objectdf.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}verifyabstract,nil);
  876. objectinfo:=tobjectinfoitem(objectinfo.next);
  877. end;
  878. if assigned(parents) then
  879. parents.free;
  880. { Finally give out a warning for each abstract method still in the list }
  881. stritem := tstringlistitem(AbstractMethodsList.first);
  882. if assigned(stritem) then
  883. Message1(type_w_instance_with_abstract,objectdf.objname^);
  884. while assigned(stritem) do
  885. begin
  886. if assigned(stritem.fpstr) then
  887. Message1(sym_h_param_list,stritem.str);
  888. stritem := tstringlistitem(stritem.next);
  889. end;
  890. if assigned(AbstractMethodsList) then
  891. AbstractMethodsList.Free;
  892. end;
  893. function tcallnode.gen_self_tree_methodpointer:tnode;
  894. var
  895. hsym : tvarsym;
  896. begin
  897. { find self field in methodpointer record }
  898. hsym:=tvarsym(trecorddef(methodpointertype.def).symtable.search('self'));
  899. if not assigned(hsym) then
  900. internalerror(200305251);
  901. { Load tmehodpointer(right).self }
  902. result:=csubscriptnode.create(
  903. hsym,
  904. ctypeconvnode.create_explicit(right.getcopy,methodpointertype));
  905. end;
  906. function tcallnode.gen_self_tree:tnode;
  907. var
  908. selftree : tnode;
  909. begin
  910. selftree:=nil;
  911. { inherited }
  912. if (nf_inherited in flags) then
  913. selftree:=load_self_node
  914. else
  915. { constructors }
  916. if (procdefinition.proctypeoption=potype_constructor) then
  917. begin
  918. { push 0 as self when allocation is needed }
  919. if (methodpointer.resulttype.def.deftype=classrefdef) or
  920. (nf_new_call in flags) then
  921. selftree:=cpointerconstnode.create(0,voidpointertype)
  922. else
  923. begin
  924. if methodpointer.nodetype=typen then
  925. selftree:=load_self_node
  926. else
  927. selftree:=methodpointer.getcopy;
  928. end;
  929. end
  930. else
  931. { Calling a static/class method }
  932. if (po_classmethod in procdefinition.procoptions) or
  933. (po_staticmethod in procdefinition.procoptions) then
  934. begin
  935. if (procdefinition.deftype<>procdef) then
  936. internalerror(200305062);
  937. if (oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  938. begin
  939. { we only need the vmt, loading self is not required and there is no
  940. need to check for typen, because that will always get the
  941. loadvmtaddrnode added }
  942. selftree:=methodpointer.getcopy;
  943. if methodpointer.resulttype.def.deftype<>classrefdef then
  944. selftree:=cloadvmtaddrnode.create(selftree);
  945. end
  946. else
  947. selftree:=cpointerconstnode.create(0,voidpointertype);
  948. end
  949. else
  950. begin
  951. if methodpointer.nodetype=typen then
  952. selftree:=load_self_node
  953. else
  954. selftree:=methodpointer.getcopy;
  955. end;
  956. result:=selftree;
  957. end;
  958. function tcallnode.gen_vmt_tree:tnode;
  959. var
  960. vmttree : tnode;
  961. begin
  962. vmttree:=nil;
  963. if not(procdefinition.proctypeoption in [potype_constructor,potype_destructor]) then
  964. internalerror(200305051);
  965. { inherited call, no create/destroy }
  966. if (nf_inherited in flags) then
  967. vmttree:=cpointerconstnode.create(0,voidpointertype)
  968. else
  969. { do not create/destroy when called from member function
  970. without specifying self explicit }
  971. if (nf_member_call in flags) then
  972. begin
  973. if (methodpointer.resulttype.def.deftype=classrefdef) and
  974. (procdefinition.proctypeoption=potype_constructor) then
  975. vmttree:=methodpointer.getcopy
  976. else
  977. vmttree:=cpointerconstnode.create(0,voidpointertype);
  978. end
  979. else
  980. { constructor with extended syntax called from new }
  981. if (nf_new_call in flags) then
  982. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  983. else
  984. { destructor with extended syntax called from dispose }
  985. if (nf_dispose_call in flags) then
  986. vmttree:=cloadvmtaddrnode.create(methodpointer.getcopy)
  987. else
  988. if (methodpointer.resulttype.def.deftype=classrefdef) then
  989. begin
  990. { constructor call via classreference => allocate memory }
  991. if (procdefinition.proctypeoption=potype_constructor) and
  992. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  993. begin
  994. vmttree:=methodpointer.getcopy;
  995. { Only a typenode can be passed when it is called with <class of xx>.create }
  996. if vmttree.nodetype=typen then
  997. vmttree:=cloadvmtaddrnode.create(vmttree);
  998. end
  999. else
  1000. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1001. end
  1002. else
  1003. { class }
  1004. if is_class(methodpointer.resulttype.def) then
  1005. begin
  1006. { destructor: release instance, flag(vmt)=1
  1007. constructor: direct call, do nothing, leave vmt=0 }
  1008. if (procdefinition.proctypeoption=potype_destructor) then
  1009. vmttree:=cpointerconstnode.create(1,voidpointertype)
  1010. else
  1011. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1012. end
  1013. else
  1014. { object }
  1015. begin
  1016. { destructor: direct call, no dispose, vmt=0
  1017. constructor: initialize object, load vmt }
  1018. if (procdefinition.proctypeoption=potype_constructor) then
  1019. { old styled inherited call? }
  1020. if (methodpointer.nodetype=typen) then
  1021. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1022. else
  1023. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1024. else
  1025. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1026. end;
  1027. result:=vmttree;
  1028. end;
  1029. procedure tcallnode.bind_paraitem;
  1030. var
  1031. i : integer;
  1032. pt : tcallparanode;
  1033. oldppt : ^tcallparanode;
  1034. varargspara,
  1035. currpara : tparaitem;
  1036. used_by_callnode : boolean;
  1037. hiddentree : tnode;
  1038. newstatement : tstatementnode;
  1039. temp : ttempcreatenode;
  1040. begin
  1041. pt:=tcallparanode(left);
  1042. oldppt:=@left;
  1043. { flag all callparanodes that belong to the varargs }
  1044. i:=paralength;
  1045. while (i>procdefinition.maxparacount) do
  1046. begin
  1047. include(pt.flags,nf_varargs_para);
  1048. oldppt:[email protected];
  1049. pt:=tcallparanode(pt.right);
  1050. dec(i);
  1051. end;
  1052. { skip varargs that are inserted by array of const }
  1053. while assigned(pt) and
  1054. (nf_varargs_para in pt.flags) do
  1055. pt:=tcallparanode(pt.right);
  1056. { process normal parameters and insert hidden parameters }
  1057. currpara:=tparaitem(procdefinition.Para.last);
  1058. while assigned(currpara) do
  1059. begin
  1060. if currpara.is_hidden then
  1061. begin
  1062. { generate hidden tree }
  1063. used_by_callnode:=false;
  1064. hiddentree:=nil;
  1065. if (vo_is_funcret in tvarsym(currpara.parasym).varoptions) then
  1066. begin
  1067. { Generate funcretnode if not specified }
  1068. if assigned(funcretnode) then
  1069. begin
  1070. hiddentree:=funcretnode.getcopy;
  1071. end
  1072. else
  1073. begin
  1074. hiddentree:=internalstatements(newstatement);
  1075. { need to use resulttype instead of procdefinition.rettype,
  1076. because they can be different }
  1077. temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
  1078. addstatement(newstatement,temp);
  1079. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  1080. addstatement(newstatement,ctemprefnode.create(temp));
  1081. end;
  1082. end
  1083. else
  1084. if vo_is_high_value in tvarsym(currpara.parasym).varoptions then
  1085. begin
  1086. if not assigned(pt) then
  1087. internalerror(200304082);
  1088. { we need the information of the next parameter }
  1089. hiddentree:=gen_high_tree(pt.left,is_open_string(tparaitem(currpara.previous).paratype.def));
  1090. end
  1091. else
  1092. if vo_is_self in tvarsym(currpara.parasym).varoptions then
  1093. begin
  1094. if assigned(right) then
  1095. hiddentree:=gen_self_tree_methodpointer
  1096. else
  1097. hiddentree:=gen_self_tree;
  1098. end
  1099. else
  1100. if vo_is_vmt in tvarsym(currpara.parasym).varoptions then
  1101. begin
  1102. hiddentree:=gen_vmt_tree;
  1103. end
  1104. else
  1105. if vo_is_parentfp in tvarsym(currpara.parasym).varoptions then
  1106. begin
  1107. if not(assigned(procdefinition.owner.defowner)) then
  1108. internalerror(200309287);
  1109. hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
  1110. end;
  1111. { add the hidden parameter }
  1112. if not assigned(hiddentree) then
  1113. internalerror(200304073);
  1114. { Already insert para and let the previous node point to
  1115. this new node }
  1116. pt:=ccallparanode.create(hiddentree,oldppt^);
  1117. pt.used_by_callnode:=used_by_callnode;
  1118. oldppt^:=pt;
  1119. end;
  1120. if not assigned(pt) then
  1121. internalerror(200310052);
  1122. pt.paraitem:=currpara;
  1123. oldppt:[email protected];
  1124. pt:=tcallparanode(pt.right);
  1125. currpara:=tparaitem(currpara.previous)
  1126. end;
  1127. { Create paraitems for varargs }
  1128. pt:=tcallparanode(left);
  1129. while assigned(pt) do
  1130. begin
  1131. if nf_varargs_para in pt.flags then
  1132. begin
  1133. if not assigned(varargsparas) then
  1134. varargsparas:=tvarargspara.create;
  1135. varargspara:=tparaitem.create;
  1136. varargspara.paratyp:=vs_value;
  1137. varargspara.paratype:=pt.resulttype;
  1138. { varargspara is left-right, use insert
  1139. instead of concat }
  1140. varargsparas.insert(varargspara);
  1141. pt.paraitem:=varargspara;
  1142. end;
  1143. pt:=tcallparanode(pt.right);
  1144. end;
  1145. end;
  1146. function tcallnode.det_resulttype:tnode;
  1147. var
  1148. candidates : tcallcandidates;
  1149. oldcallnode : tcallnode;
  1150. hpt : tnode;
  1151. pt : tcallparanode;
  1152. lastpara : longint;
  1153. currpara : tparaitem;
  1154. cand_cnt : integer;
  1155. i : longint;
  1156. method_must_be_valid,
  1157. is_const : boolean;
  1158. label
  1159. errorexit;
  1160. begin
  1161. result:=nil;
  1162. candidates:=nil;
  1163. oldcallnode:=aktcallnode;
  1164. aktcallnode:=nil;
  1165. { determine length of parameter list }
  1166. pt:=tcallparanode(left);
  1167. paralength:=0;
  1168. while assigned(pt) do
  1169. begin
  1170. inc(paralength);
  1171. pt:=tcallparanode(pt.right);
  1172. end;
  1173. { determine the type of the parameters }
  1174. if assigned(left) then
  1175. begin
  1176. tcallparanode(left).get_paratype;
  1177. if codegenerror then
  1178. goto errorexit;
  1179. end;
  1180. { procedure variable ? }
  1181. if assigned(right) then
  1182. begin
  1183. set_varstate(right,vs_used,true);
  1184. resulttypepass(right);
  1185. if codegenerror then
  1186. exit;
  1187. procdefinition:=tabstractprocdef(right.resulttype.def);
  1188. { Compare parameters from right to left }
  1189. currpara:=tparaitem(procdefinition.Para.last);
  1190. { Skip default parameters }
  1191. if not(po_varargs in procdefinition.procoptions) then
  1192. begin
  1193. { ignore hidden parameters }
  1194. while assigned(currpara) and (currpara.is_hidden) do
  1195. currpara:=tparaitem(currpara.previous);
  1196. for i:=1 to procdefinition.maxparacount-paralength do
  1197. begin
  1198. if not assigned(currpara) then
  1199. internalerror(200402261);
  1200. if not assigned(currpara.defaultvalue) then
  1201. begin
  1202. CGMessage(parser_e_wrong_parameter_size);
  1203. goto errorexit;
  1204. end;
  1205. currpara:=tparaitem(currpara.previous);
  1206. end;
  1207. end;
  1208. while assigned(currpara) and (currpara.is_hidden) do
  1209. currpara:=tparaitem(currpara.previous);
  1210. pt:=tcallparanode(left);
  1211. lastpara:=paralength;
  1212. while assigned(currpara) and assigned(pt) do
  1213. begin
  1214. { only goto next para if we're out of the varargs }
  1215. if not(po_varargs in procdefinition.procoptions) or
  1216. (lastpara<=procdefinition.maxparacount) then
  1217. begin
  1218. repeat
  1219. currpara:=tparaitem(currpara.previous);
  1220. until (not assigned(currpara)) or (not currpara.is_hidden);
  1221. end;
  1222. pt:=tcallparanode(pt.right);
  1223. dec(lastpara);
  1224. end;
  1225. if assigned(pt) or
  1226. (assigned(currpara) and
  1227. not assigned(currpara.defaultvalue)) then
  1228. begin
  1229. if assigned(pt) then
  1230. aktfilepos:=pt.fileinfo;
  1231. CGMessage(parser_e_wrong_parameter_size);
  1232. goto errorexit;
  1233. end;
  1234. end
  1235. else
  1236. { not a procedure variable }
  1237. begin
  1238. { do we know the procedure to call ? }
  1239. if not(assigned(procdefinition)) then
  1240. begin
  1241. candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,(nf_isproperty in flags));
  1242. { no procedures found? then there is something wrong
  1243. with the parameter size or the procedures are
  1244. not accessible }
  1245. if candidates.count=0 then
  1246. begin
  1247. { when it's an auto inherited call and there
  1248. is no procedure found, but the procedures
  1249. were defined with overload directive and at
  1250. least two procedures are defined then we ignore
  1251. this inherited by inserting a nothingn. Only
  1252. do this ugly hack in Delphi mode as it looks more
  1253. like a bug. It's also not documented }
  1254. if (m_delphi in aktmodeswitches) and
  1255. (nf_anon_inherited in flags) and
  1256. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1257. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1258. (symtableprocentry.procdef_count>=2) then
  1259. result:=cnothingnode.create
  1260. else
  1261. begin
  1262. { in tp mode we can try to convert to procvar if
  1263. there are no parameters specified. Only try it
  1264. when there is only one proc definition, else the
  1265. loadnode will give a strange error }
  1266. if not(assigned(left)) and
  1267. not(nf_inherited in flags) and
  1268. (m_tp_procvar in aktmodeswitches) and
  1269. (symtableprocentry.procdef_count=1) then
  1270. begin
  1271. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1272. if assigned(methodpointer) then
  1273. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1274. resulttypepass(hpt);
  1275. result:=hpt;
  1276. end
  1277. else
  1278. begin
  1279. if assigned(left) then
  1280. aktfilepos:=left.fileinfo;
  1281. CGMessage(parser_e_wrong_parameter_size);
  1282. symtableprocentry.write_parameter_lists(nil);
  1283. end;
  1284. end;
  1285. goto errorexit;
  1286. end;
  1287. { Retrieve information about the candidates }
  1288. candidates.get_information;
  1289. {$ifdef EXTDEBUG}
  1290. { Display info when multiple candidates are found }
  1291. if candidates.count>1 then
  1292. candidates.dump_info(V_Debug);
  1293. {$endif EXTDEBUG}
  1294. { Choose the best candidate and count the number of
  1295. candidates left }
  1296. cand_cnt:=candidates.choose_best(procdefinition);
  1297. { All parameters are checked, check if there are any
  1298. procedures left }
  1299. if cand_cnt>0 then
  1300. begin
  1301. { Multiple candidates left? }
  1302. if cand_cnt>1 then
  1303. begin
  1304. CGMessage(cg_e_cant_choose_overload_function);
  1305. {$ifdef EXTDEBUG}
  1306. candidates.dump_info(V_Hint);
  1307. {$else EXTDEBUG}
  1308. candidates.list(false);
  1309. {$endif EXTDEBUG}
  1310. { we'll just use the first candidate to make the
  1311. call }
  1312. end;
  1313. { assign procdefinition }
  1314. if symtableproc=nil then
  1315. symtableproc:=procdefinition.owner;
  1316. { update browser information }
  1317. if make_ref then
  1318. begin
  1319. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1320. inc(tprocdef(procdefinition).refcount);
  1321. if tprocdef(procdefinition).defref=nil then
  1322. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1323. end;
  1324. end
  1325. else
  1326. begin
  1327. { No candidates left, this must be a type error,
  1328. because wrong size is already checked. procdefinition
  1329. is filled with the first (random) definition that is
  1330. found. We use this definition to display a nice error
  1331. message that the wrong type is passed }
  1332. candidates.find_wrong_para;
  1333. candidates.list(true);
  1334. {$ifdef EXTDEBUG}
  1335. candidates.dump_info(V_Hint);
  1336. {$endif EXTDEBUG}
  1337. { We can not proceed, release all procs and exit }
  1338. candidates.free;
  1339. goto errorexit;
  1340. end;
  1341. candidates.free;
  1342. end; { end of procedure to call determination }
  1343. end;
  1344. { add needed default parameters }
  1345. if assigned(procdefinition) and
  1346. (paralength<procdefinition.maxparacount) then
  1347. begin
  1348. currpara:=tparaitem(procdefinition.Para.first);
  1349. i:=0;
  1350. while (i<paralength) do
  1351. begin
  1352. if not assigned(currpara) then
  1353. internalerror(200306181);
  1354. if not currpara.is_hidden then
  1355. inc(i);
  1356. currpara:=tparaitem(currpara.next);
  1357. end;
  1358. while assigned(currpara) and currpara.is_hidden do
  1359. currpara:=tparaitem(currpara.next);
  1360. while assigned(currpara) do
  1361. begin
  1362. if not assigned(currpara.defaultvalue) then
  1363. internalerror(200212142);
  1364. left:=ccallparanode.create(genconstsymtree(tconstsym(currpara.defaultvalue)),left);
  1365. { Ignore vs_hidden parameters }
  1366. repeat
  1367. currpara:=tparaitem(currpara.next);
  1368. until (not assigned(currpara)) or (not currpara.is_hidden);
  1369. end;
  1370. end;
  1371. { handle predefined procedures }
  1372. is_const:=(po_internconst in procdefinition.procoptions) and
  1373. ((block_type in [bt_const,bt_type]) or
  1374. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1375. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1376. begin
  1377. if assigned(left) then
  1378. begin
  1379. { ptr and settextbuf needs two args }
  1380. if assigned(tcallparanode(left).right) then
  1381. begin
  1382. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1383. left:=nil;
  1384. end
  1385. else
  1386. begin
  1387. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1388. tcallparanode(left).left:=nil;
  1389. end;
  1390. end
  1391. else
  1392. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1393. result:=hpt;
  1394. goto errorexit;
  1395. end;
  1396. { ensure that the result type is set }
  1397. if not(cnf_restypeset in callnodeflags) then
  1398. begin
  1399. { constructors return their current class type, not the type where the
  1400. constructor is declared, this can be different because of inheritance }
  1401. if (procdefinition.proctypeoption=potype_constructor) and
  1402. assigned(methodpointer) and
  1403. assigned(methodpointer.resulttype.def) and
  1404. (methodpointer.resulttype.def.deftype=classrefdef) then
  1405. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype
  1406. else
  1407. resulttype:=procdefinition.rettype;
  1408. end
  1409. else
  1410. resulttype:=restype;
  1411. if resulttype.def.needs_inittable then
  1412. include(current_procinfo.flags,pi_needs_implicit_finally);
  1413. if assigned(methodpointer) then
  1414. begin
  1415. resulttypepass(methodpointer);
  1416. { direct call to inherited abstract method, then we
  1417. can already give a error in the compiler instead
  1418. of a runtime error }
  1419. if (nf_inherited in flags) and
  1420. (po_abstractmethod in procdefinition.procoptions) then
  1421. CGMessage(cg_e_cant_call_abstract_method);
  1422. { if an inherited con- or destructor should be }
  1423. { called in a con- or destructor then a warning }
  1424. { will be made }
  1425. { con- and destructors need a pointer to the vmt }
  1426. if (nf_inherited in flags) and
  1427. (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1428. is_object(methodpointer.resulttype.def) and
  1429. not(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) then
  1430. CGMessage(cg_w_member_cd_call_from_method);
  1431. if methodpointer.nodetype<>typen then
  1432. begin
  1433. hpt:=methodpointer;
  1434. while assigned(hpt) and (hpt.nodetype in [subscriptn,vecn]) do
  1435. hpt:=tunarynode(hpt).left;
  1436. if (procdefinition.proctypeoption=potype_constructor) and
  1437. assigned(symtableproc) and
  1438. (symtableproc.symtabletype=withsymtable) and
  1439. (tnode(twithsymtable(symtableproc).withrefnode).nodetype=temprefn) then
  1440. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1441. { R.Init then R will be initialized by the constructor,
  1442. Also allow it for simple loads }
  1443. if (procdefinition.proctypeoption=potype_constructor) or
  1444. ((hpt.nodetype=loadn) and
  1445. (
  1446. (methodpointer.resulttype.def.deftype=classrefdef) or
  1447. (
  1448. (methodpointer.resulttype.def.deftype=objectdef) and
  1449. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1450. )
  1451. )
  1452. ) then
  1453. method_must_be_valid:=false
  1454. else
  1455. method_must_be_valid:=true;
  1456. set_varstate(methodpointer,vs_used,method_must_be_valid);
  1457. { The object is already used if it is called once }
  1458. if (hpt.nodetype=loadn) and
  1459. (tloadnode(hpt).symtableentry.typ=varsym) then
  1460. tvarsym(tloadnode(hpt).symtableentry).varstate:=vs_used;
  1461. end;
  1462. { if we are calling the constructor check for abstract
  1463. methods. Ignore inherited and member calls, because the
  1464. class is then already created }
  1465. if (procdefinition.proctypeoption=potype_constructor) and
  1466. not(nf_inherited in flags) and
  1467. not(nf_member_call in flags) then
  1468. verifyabstractcalls;
  1469. end
  1470. else
  1471. begin
  1472. { When this is method the methodpointer must be available }
  1473. if (right=nil) and
  1474. (procdefinition.owner.symtabletype=objectsymtable) then
  1475. internalerror(200305061);
  1476. end;
  1477. { Change loading of array of const to varargs }
  1478. if assigned(left) and
  1479. is_array_of_const(tparaitem(procdefinition.para.last).paratype.def) and
  1480. (procdefinition.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  1481. convert_carg_array_of_const;
  1482. { bind paraitems to the callparanodes and insert hidden parameters }
  1483. aktcallnode:=self;
  1484. bind_paraitem;
  1485. { methodpointer is only needed for virtual calls, and
  1486. it should then be loaded with the VMT }
  1487. if (po_virtualmethod in procdefinition.procoptions) and
  1488. not(assigned(methodpointer) and
  1489. (methodpointer.nodetype=typen)) then
  1490. begin
  1491. if not assigned(methodpointer) then
  1492. internalerror(200305063);
  1493. if (methodpointer.resulttype.def.deftype<>classrefdef) then
  1494. begin
  1495. methodpointer:=cloadvmtaddrnode.create(methodpointer);
  1496. resulttypepass(methodpointer);
  1497. end;
  1498. end
  1499. else
  1500. begin
  1501. { not needed anymore }
  1502. methodpointer.free;
  1503. methodpointer:=nil;
  1504. end;
  1505. { insert type conversions for parameters }
  1506. if assigned(left) then
  1507. tcallparanode(left).insert_typeconv(true);
  1508. errorexit:
  1509. aktcallnode:=oldcallnode;
  1510. end;
  1511. procedure tcallnode.order_parameters;
  1512. var
  1513. hp,hpcurr,hpnext,hpfirst,hpprev : tcallparanode;
  1514. currloc : tcgloc;
  1515. begin
  1516. hpfirst:=nil;
  1517. hpcurr:=tcallparanode(left);
  1518. while assigned(hpcurr) do
  1519. begin
  1520. { pull out }
  1521. hpnext:=tcallparanode(hpcurr.right);
  1522. { pull in at the correct place.
  1523. Used order:
  1524. 1. LOC_REFERENCE with smallest offset (x86 only)
  1525. 2. LOC_REFERENCE with most registers
  1526. 3. LOC_REGISTER with most registers }
  1527. currloc:=hpcurr.paraitem.paraloc[callerside].loc;
  1528. hpprev:=nil;
  1529. hp:=hpfirst;
  1530. while assigned(hp) do
  1531. begin
  1532. case currloc of
  1533. LOC_REFERENCE :
  1534. begin
  1535. case hp.paraitem.paraloc[callerside].loc of
  1536. LOC_REFERENCE :
  1537. begin
  1538. { Offset is calculated like:
  1539. sub esp,12
  1540. mov [esp+8],para3
  1541. mov [esp+4],para2
  1542. mov [esp],para1
  1543. call function
  1544. That means the for pushes the para with the
  1545. highest offset (see para3) needs to be pushed first
  1546. }
  1547. if (hpcurr.registersint>hp.registersint)
  1548. {$ifdef x86}
  1549. or (hpcurr.paraitem.paraloc[callerside].reference.offset>hp.paraitem.paraloc[callerside].reference.offset)
  1550. {$endif x86}
  1551. then
  1552. break;
  1553. end;
  1554. LOC_REGISTER,
  1555. LOC_FPUREGISTER :
  1556. break;
  1557. end;
  1558. end;
  1559. LOC_FPUREGISTER,
  1560. LOC_REGISTER :
  1561. begin
  1562. if (hp.paraitem.paraloc[callerside].loc=currloc) and
  1563. (hpcurr.registersint>hp.registersint) then
  1564. break;
  1565. end;
  1566. end;
  1567. hpprev:=hp;
  1568. hp:=tcallparanode(hp.right);
  1569. end;
  1570. hpcurr.right:=hp;
  1571. if assigned(hpprev) then
  1572. hpprev.right:=hpcurr
  1573. else
  1574. hpfirst:=hpcurr;
  1575. { next }
  1576. hpcurr:=hpnext;
  1577. end;
  1578. left:=hpfirst;
  1579. end;
  1580. function tcallnode.pass_1 : tnode;
  1581. {$ifdef m68k}
  1582. var
  1583. regi : tregister;
  1584. {$endif}
  1585. label
  1586. errorexit;
  1587. begin
  1588. result:=nil;
  1589. { calculate the parameter info for the procdef }
  1590. if not procdefinition.has_paraloc_info then
  1591. begin
  1592. procdefinition.requiredargarea:=paramanager.create_paraloc_info(procdefinition,callerside);
  1593. procdefinition.has_paraloc_info:=true;
  1594. end;
  1595. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,procdefinition.requiredargarea);
  1596. { calculate the parameter info for varargs }
  1597. if assigned(varargsparas) then
  1598. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,
  1599. paramanager.create_varargs_paraloc_info(procdefinition,varargsparas));
  1600. { work trough all parameters to get the register requirements }
  1601. if assigned(left) then
  1602. tcallparanode(left).det_registers;
  1603. { order parameters }
  1604. order_parameters;
  1605. { function result node }
  1606. if assigned(_funcretnode) then
  1607. firstpass(_funcretnode);
  1608. { procedure variable ? }
  1609. if assigned(right) then
  1610. begin
  1611. firstpass(right);
  1612. { procedure does a call }
  1613. if not (block_type in [bt_const,bt_type]) then
  1614. include(current_procinfo.flags,pi_do_call);
  1615. end
  1616. else
  1617. { not a procedure variable }
  1618. begin
  1619. { calc the correture value for the register }
  1620. { handle predefined procedures }
  1621. if (procdefinition.proccalloption=pocall_inline) then
  1622. begin
  1623. { inherit flags }
  1624. current_procinfo.flags:=current_procinfo.flags+((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  1625. if assigned(methodpointer) then
  1626. CGMessage(cg_e_unable_inline_object_methods);
  1627. if assigned(right) then
  1628. CGMessage(cg_e_unable_inline_procvar);
  1629. if not assigned(inlinecode) then
  1630. begin
  1631. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  1632. inlinecode:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  1633. else
  1634. CGMessage(cg_e_no_code_for_inline_stored);
  1635. if assigned(inlinecode) then
  1636. begin
  1637. { consider it has not inlined if called
  1638. again inside the args }
  1639. procdefinition.proccalloption:=pocall_default;
  1640. firstpass(inlinecode);
  1641. end;
  1642. end;
  1643. end
  1644. else
  1645. begin
  1646. if not (block_type in [bt_const,bt_type]) then
  1647. include(current_procinfo.flags,pi_do_call);
  1648. end;
  1649. end;
  1650. { get a register for the return value }
  1651. if (not is_void(resulttype.def)) then
  1652. begin
  1653. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1654. begin
  1655. expectloc:=LOC_REFERENCE;
  1656. end
  1657. else
  1658. { for win32 records returned in EDX:EAX, we
  1659. move them to memory after ... }
  1660. if (resulttype.def.deftype=recorddef) then
  1661. begin
  1662. expectloc:=LOC_CREFERENCE;
  1663. end
  1664. else
  1665. { ansi/widestrings must be registered, so we can dispose them }
  1666. if is_ansistring(resulttype.def) or
  1667. is_widestring(resulttype.def) then
  1668. begin
  1669. expectloc:=LOC_CREFERENCE;
  1670. registersint:=1;
  1671. end
  1672. else
  1673. { we have only to handle the result if it is used }
  1674. if (nf_return_value_used in flags) then
  1675. begin
  1676. case resulttype.def.deftype of
  1677. enumdef,
  1678. orddef :
  1679. begin
  1680. if (procdefinition.proctypeoption=potype_constructor) then
  1681. begin
  1682. expectloc:=LOC_REGISTER;
  1683. registersint:=1;
  1684. end
  1685. else
  1686. begin
  1687. expectloc:=LOC_REGISTER;
  1688. if is_64bit(resulttype.def) then
  1689. registersint:=2
  1690. else
  1691. registersint:=1;
  1692. end;
  1693. end;
  1694. floatdef :
  1695. begin
  1696. expectloc:=LOC_FPUREGISTER;
  1697. {$ifdef cpufpemu}
  1698. if (cs_fp_emulation in aktmoduleswitches) then
  1699. registersint:=1
  1700. else
  1701. {$endif cpufpemu}
  1702. {$ifdef m68k}
  1703. if (tfloatdef(resulttype.def).typ=s32real) then
  1704. registersint:=1
  1705. else
  1706. {$endif m68k}
  1707. registersfpu:=1;
  1708. end;
  1709. else
  1710. begin
  1711. expectloc:=LOC_REGISTER;
  1712. registersint:=1;
  1713. end;
  1714. end;
  1715. end
  1716. else
  1717. expectloc:=LOC_VOID;
  1718. end
  1719. else
  1720. expectloc:=LOC_VOID;
  1721. {$ifdef m68k}
  1722. { we need one more address register for virtual calls on m68k }
  1723. if (po_virtualmethod in procdefinition.procoptions) then
  1724. inc(registersint);
  1725. {$endif m68k}
  1726. { a fpu can be used in any procedure !! }
  1727. {$ifdef i386}
  1728. registersfpu:=procdefinition.fpu_used;
  1729. {$endif i386}
  1730. { if this is a call to a method calc the registers }
  1731. if (methodpointer<>nil) then
  1732. begin
  1733. if methodpointer.nodetype<>typen then
  1734. begin
  1735. firstpass(methodpointer);
  1736. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1737. registersint:=max(methodpointer.registersint,registersint);
  1738. {$ifdef SUPPORT_MMX }
  1739. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1740. {$endif SUPPORT_MMX}
  1741. end;
  1742. end;
  1743. { determine the registers of the procedure variable }
  1744. { is this OK for inlined procs also ?? (PM) }
  1745. if assigned(inlinecode) then
  1746. begin
  1747. registersfpu:=max(inlinecode.registersfpu,registersfpu);
  1748. registersint:=max(inlinecode.registersint,registersint);
  1749. {$ifdef SUPPORT_MMX}
  1750. registersmmx:=max(inlinecode.registersmmx,registersmmx);
  1751. {$endif SUPPORT_MMX}
  1752. end;
  1753. { determine the registers of the procedure variable }
  1754. { is this OK for inlined procs also ?? (PM) }
  1755. if assigned(right) then
  1756. begin
  1757. registersfpu:=max(right.registersfpu,registersfpu);
  1758. registersint:=max(right.registersint,registersint);
  1759. {$ifdef SUPPORT_MMX}
  1760. registersmmx:=max(right.registersmmx,registersmmx);
  1761. {$endif SUPPORT_MMX}
  1762. end;
  1763. { determine the registers of the procedure }
  1764. if assigned(left) then
  1765. begin
  1766. registersfpu:=max(left.registersfpu,registersfpu);
  1767. registersint:=max(left.registersint,registersint);
  1768. {$ifdef SUPPORT_MMX}
  1769. registersmmx:=max(left.registersmmx,registersmmx);
  1770. {$endif SUPPORT_MMX}
  1771. end;
  1772. errorexit:
  1773. if assigned(inlinecode) then
  1774. procdefinition.proccalloption:=pocall_inline;
  1775. end;
  1776. {$ifdef state_tracking}
  1777. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  1778. var hp:Tcallparanode;
  1779. value:Tnode;
  1780. begin
  1781. track_state_pass:=false;
  1782. hp:=Tcallparanode(left);
  1783. while assigned(hp) do
  1784. begin
  1785. if left.track_state_pass(exec_known) then
  1786. begin
  1787. left.resulttype.def:=nil;
  1788. do_resulttypepass(left);
  1789. end;
  1790. value:=aktstate.find_fact(hp.left);
  1791. if value<>nil then
  1792. begin
  1793. track_state_pass:=true;
  1794. hp.left.destroy;
  1795. hp.left:=value.getcopy;
  1796. do_resulttypepass(hp.left);
  1797. end;
  1798. hp:=Tcallparanode(hp.right);
  1799. end;
  1800. end;
  1801. {$endif}
  1802. function tcallnode.para_count:longint;
  1803. var
  1804. ppn : tcallparanode;
  1805. begin
  1806. result:=0;
  1807. ppn:=tcallparanode(left);
  1808. while assigned(ppn) do
  1809. begin
  1810. if not(assigned(ppn.paraitem) and
  1811. ppn.paraitem.is_hidden) then
  1812. inc(result);
  1813. ppn:=tcallparanode(ppn.right);
  1814. end;
  1815. end;
  1816. function tcallnode.docompare(p: tnode): boolean;
  1817. begin
  1818. docompare :=
  1819. inherited docompare(p) and
  1820. (symtableprocentry = tcallnode(p).symtableprocentry) and
  1821. (procdefinition = tcallnode(p).procdefinition) and
  1822. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  1823. (((cnf_restypeset in callnodeflags) and (cnf_restypeset in tcallnode(p).callnodeflags) and
  1824. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  1825. (not(cnf_restypeset in callnodeflags) and not(cnf_restypeset in tcallnode(p).callnodeflags)));
  1826. end;
  1827. procedure tcallnode.printnodedata(var t:text);
  1828. begin
  1829. if assigned(procdefinition) and
  1830. (procdefinition.deftype=procdef) then
  1831. writeln(t,printnodeindention,'proc = ',tprocdef(procdefinition).fullprocname(true))
  1832. else
  1833. begin
  1834. if assigned(symtableprocentry) then
  1835. writeln(t,printnodeindention,'proc = ',symtableprocentry.name)
  1836. else
  1837. writeln(t,printnodeindention,'proc = <nil>');
  1838. end;
  1839. printnode(t,methodpointer);
  1840. printnode(t,right);
  1841. printnode(t,left);
  1842. end;
  1843. begin
  1844. ccallnode:=tcallnode;
  1845. ccallparanode:=tcallparanode;
  1846. end.
  1847. {
  1848. $Log$
  1849. Revision 1.231 2004-03-14 20:07:13 peter
  1850. * removed unused paravisible
  1851. Revision 1.230 2004/03/04 17:25:16 peter
  1852. * fix check for parameter length when calling procvar, broken by the
  1853. previous default parameter for procvar fix
  1854. Revision 1.229 2004/02/26 16:09:49 peter
  1855. * fix procvars with default paras
  1856. Revision 1.228 2004/02/24 16:12:39 peter
  1857. * operator overload chooses rewrite
  1858. * overload choosing is now generic and moved to htypechk
  1859. Revision 1.227 2004/02/20 21:55:59 peter
  1860. * procvar cleanup
  1861. Revision 1.226 2004/02/19 17:07:42 florian
  1862. * fixed arg. area calculation
  1863. Revision 1.225 2004/02/13 15:42:21 peter
  1864. * compare_defs_ext has now a options argument
  1865. * fixes for variants
  1866. Revision 1.224 2004/02/12 15:54:03 peter
  1867. * make extcycle is working again
  1868. Revision 1.223 2004/02/05 01:24:08 florian
  1869. * several fixes to compile x86-64 system
  1870. Revision 1.222 2004/02/03 22:32:54 peter
  1871. * renamed xNNbittype to xNNinttype
  1872. * renamed registers32 to registersint
  1873. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1874. Revision 1.221 2004/01/26 16:12:27 daniel
  1875. * reginfo now also only allocated during register allocation
  1876. * third round of gdb cleanups: kick out most of concatstabto
  1877. Revision 1.220 2004/01/15 15:16:18 daniel
  1878. * Some minor stuff
  1879. * Managed to eliminate speed effects of string compression
  1880. Revision 1.219 2004/01/14 17:53:58 peter
  1881. * ignore hidden parameters when default parameters are used
  1882. Revision 1.218 2004/01/11 23:56:19 daniel
  1883. * Experiment: Compress strings to save memory
  1884. Did not save a single byte of mem; clearly the core size is boosted by
  1885. temporary memory usage...
  1886. Revision 1.217 2003/12/28 22:09:12 florian
  1887. + setting of bit 6 of cr for c var args on ppc implemented
  1888. Revision 1.216 2003/12/21 19:42:42 florian
  1889. * fixed ppc inlining stuff
  1890. * fixed wrong unit writing
  1891. + added some sse stuff
  1892. Revision 1.215 2003/12/20 12:38:51 florian
  1893. * some x86-64 compilation fixe
  1894. Revision 1.214 2003/12/16 22:09:31 florian
  1895. * better inheritence of procinfo flags of inlined procedures
  1896. Revision 1.213 2003/12/16 21:29:24 florian
  1897. + inlined procedures inherit procinfo flags
  1898. Revision 1.212 2003/12/08 22:37:28 peter
  1899. * paralength is private again
  1900. Revision 1.211 2003/12/08 16:34:23 peter
  1901. * varargspara is left-right, so adding paraitems needs insert
  1902. instead of concat
  1903. Revision 1.210 2003/12/01 18:44:15 peter
  1904. * fixed some crashes
  1905. * fixed varargs and register calling probs
  1906. Revision 1.209 2003/11/28 17:24:22 peter
  1907. * reversed offset calculation for caller side so it works
  1908. correctly for interfaces
  1909. Revision 1.208 2003/11/23 17:05:15 peter
  1910. * register calling is left-right
  1911. * parameter ordering
  1912. * left-right calling inserts result parameter last
  1913. Revision 1.207 2003/11/10 22:02:52 peter
  1914. * cross unit inlining fixed
  1915. Revision 1.206 2003/11/10 19:09:29 peter
  1916. * procvar default value support
  1917. Revision 1.205 2003/11/06 15:54:32 peter
  1918. * fixed calling classmethod for other object from classmethod
  1919. Revision 1.204 2003/11/01 16:17:48 peter
  1920. * use explicit typecast when generating the high value
  1921. Revision 1.203 2003/10/31 15:52:58 peter
  1922. * support creating classes using <class of tobject>.create
  1923. Revision 1.202 2003/10/30 16:23:13 peter
  1924. * don't search for overloads in parents for constructors
  1925. Revision 1.201 2003/10/29 22:01:20 florian
  1926. * fixed passing of dyn. arrays to open array parameters
  1927. Revision 1.200 2003/10/23 14:44:07 peter
  1928. * splitted buildderef and buildderefimpl to fix interface crc
  1929. calculation
  1930. Revision 1.199 2003/10/22 20:40:00 peter
  1931. * write derefdata in a separate ppu entry
  1932. Revision 1.198 2003/10/21 18:17:02 peter
  1933. * only search for overloaded constructors in classes
  1934. Revision 1.197 2003/10/21 15:14:55 peter
  1935. * also search in parents for overloads when calling a constructor
  1936. Revision 1.196 2003/10/13 14:05:12 peter
  1937. * removed is_visible_for_proc
  1938. * search also for class overloads when finding interface
  1939. implementations
  1940. Revision 1.195 2003/10/09 21:31:37 daniel
  1941. * Register allocator splitted, ans abstract now
  1942. Revision 1.194 2003/10/09 15:00:13 florian
  1943. * fixed constructor call in class methods
  1944. Revision 1.193 2003/10/08 19:19:45 peter
  1945. * set_varstate cleanup
  1946. Revision 1.192 2003/10/07 21:14:32 peter
  1947. * compare_paras() has a parameter to ignore hidden parameters
  1948. * cross unit overload searching ignores hidden parameters when
  1949. comparing parameter lists. Now function(string):string is
  1950. not overriden with procedure(string) which has the same visible
  1951. parameter list
  1952. Revision 1.191 2003/10/05 21:21:52 peter
  1953. * c style array of const generates callparanodes
  1954. * varargs paraloc fixes
  1955. Revision 1.190 2003/10/05 12:54:17 peter
  1956. * don't check for abstract methods when the constructor is called
  1957. by inherited
  1958. * fix private member error instead of wrong number of parameters
  1959. Revision 1.189 2003/10/04 19:00:52 florian
  1960. * fixed TP 6.0 styled inherited call; fixes IDE with 1.1
  1961. Revision 1.188 2003/10/03 22:00:33 peter
  1962. * parameter alignment fixes
  1963. Revision 1.187 2003/10/03 14:44:38 peter
  1964. * fix IE when callnode was firstpassed twice
  1965. Revision 1.186 2003/10/02 21:13:46 peter
  1966. * protected visibility fixes
  1967. Revision 1.185 2003/10/01 20:34:48 peter
  1968. * procinfo unit contains tprocinfo
  1969. * cginfo renamed to cgbase
  1970. * moved cgmessage to verbose
  1971. * fixed ppc and sparc compiles
  1972. Revision 1.184 2003/09/28 21:44:55 peter
  1973. * fix check that filedef needs var para
  1974. Revision 1.183 2003/09/28 17:55:03 peter
  1975. * parent framepointer changed to hidden parameter
  1976. * tloadparentfpnode added
  1977. Revision 1.182 2003/09/25 21:28:00 peter
  1978. * parameter fixes
  1979. Revision 1.181 2003/09/23 17:56:05 peter
  1980. * locals and paras are allocated in the code generation
  1981. * tvarsym.localloc contains the location of para/local when
  1982. generating code for the current procedure
  1983. Revision 1.180 2003/09/16 16:17:01 peter
  1984. * varspez in calls to push_addr_param
  1985. Revision 1.179 2003/09/07 22:09:35 peter
  1986. * preparations for different default calling conventions
  1987. * various RA fixes
  1988. Revision 1.178 2003/09/06 22:27:08 florian
  1989. * fixed web bug 2669
  1990. * cosmetic fix in printnode
  1991. * tobjectdef.gettypename implemented
  1992. Revision 1.177 2003/09/03 15:55:00 peter
  1993. * NEWRA branch merged
  1994. Revision 1.176.2.3 2003/08/31 21:07:44 daniel
  1995. * callparatemp ripped
  1996. Revision 1.176.2.2 2003/08/27 20:23:55 peter
  1997. * remove old ra code
  1998. Revision 1.176.2.1 2003/08/27 19:55:54 peter
  1999. * first tregister patch
  2000. Revision 1.176 2003/08/23 18:42:57 peter
  2001. * only check for size matches when parameter is enum,ord,float
  2002. Revision 1.175 2003/08/10 17:25:23 peter
  2003. * fixed some reported bugs
  2004. Revision 1.174 2003/07/25 09:54:57 jonas
  2005. * fixed bogus abstract method warnings
  2006. Revision 1.173 2003/06/25 18:31:23 peter
  2007. * sym,def resolving partly rewritten to support also parent objects
  2008. not directly available through the uses clause
  2009. Revision 1.172 2003/06/17 16:34:44 jonas
  2010. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  2011. * renamed all_intregisters to volatile_intregisters and made it
  2012. processor dependent
  2013. Revision 1.171 2003/06/15 16:47:33 jonas
  2014. * fixed revious commit
  2015. Revision 1.170 2003/06/15 15:10:57 jonas
  2016. * callparatemp fix: if a threadvar is a parameter, that paramter also
  2017. does a call
  2018. Revision 1.169 2003/06/13 21:19:30 peter
  2019. * current_procdef removed, use current_procinfo.procdef instead
  2020. Revision 1.168 2003/06/08 20:01:53 jonas
  2021. * optimized assignments with on the right side a function that returns
  2022. an ansi- or widestring
  2023. Revision 1.167 2003/06/08 18:27:15 jonas
  2024. + ability to change the location of a ttempref node with changelocation()
  2025. method. Useful to use instead of copying the contents from one temp to
  2026. another
  2027. + some shortstring optimizations in tassignmentnode that avoid some
  2028. copying (required some shortstring optimizations to be moved from
  2029. resulttype to firstpass, because they work on callnodes and string
  2030. addnodes are only changed to callnodes in the firstpass)
  2031. * allow setting/changing the funcretnode of callnodes after the
  2032. resulttypepass has been done, funcretnode is now a property
  2033. (all of the above should have a quite big effect on callparatemp)
  2034. Revision 1.166 2003/06/08 11:42:33 peter
  2035. * creating class with abstract call checking fixed
  2036. * there will be only one warning for each class, the methods
  2037. are listed as hint
  2038. Revision 1.165 2003/06/07 20:26:32 peter
  2039. * re-resolving added instead of reloading from ppu
  2040. * tderef object added to store deref info for resolving
  2041. Revision 1.164 2003/06/03 21:05:48 peter
  2042. * fix check for procedure without parameters
  2043. * calling constructor as member will not allocate memory
  2044. Revision 1.163 2003/06/03 13:01:59 daniel
  2045. * Register allocator finished
  2046. Revision 1.162 2003/05/26 21:17:17 peter
  2047. * procinlinenode removed
  2048. * aktexit2label removed, fast exit removed
  2049. + tcallnode.inlined_pass_2 added
  2050. Revision 1.161 2003/05/25 11:34:17 peter
  2051. * methodpointer self pushing fixed
  2052. Revision 1.160 2003/05/25 08:59:16 peter
  2053. * inline fixes
  2054. Revision 1.159 2003/05/24 17:16:37 jonas
  2055. * added missing firstpass for callparatemp code
  2056. Revision 1.158 2003/05/23 14:27:35 peter
  2057. * remove some unit dependencies
  2058. * current_procinfo changes to store more info
  2059. Revision 1.157 2003/05/17 14:05:58 jonas
  2060. * fixed callparatemp for ansi/widestring and interfacecoms
  2061. Revision 1.156 2003/05/17 13:30:08 jonas
  2062. * changed tt_persistant to tt_persistent :)
  2063. * tempcreatenode now doesn't accept a boolean anymore for persistent
  2064. temps, but a ttemptype, so you can also create ansistring temps etc
  2065. Revision 1.155 2003/05/16 14:33:31 peter
  2066. * regvar fixes
  2067. Revision 1.154 2003/05/14 19:35:50 jonas
  2068. * fixed callparatemp so it works with vs_var, vs_out and formal const
  2069. parameters
  2070. Revision 1.153 2003/05/13 20:53:41 peter
  2071. * constructors return in register
  2072. Revision 1.152 2003/05/13 15:18:49 peter
  2073. * fixed various crashes
  2074. Revision 1.151 2003/05/11 21:37:03 peter
  2075. * moved implicit exception frame from ncgutil to psub
  2076. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2077. Revision 1.150 2003/05/11 14:45:12 peter
  2078. * tloadnode does not support objectsymtable,withsymtable anymore
  2079. * withnode cleanup
  2080. * direct with rewritten to use temprefnode
  2081. Revision 1.149 2003/05/09 17:47:02 peter
  2082. * self moved to hidden parameter
  2083. * removed hdisposen,hnewn,selfn
  2084. Revision 1.148 2003/05/05 14:53:16 peter
  2085. * vs_hidden replaced by is_hidden boolean
  2086. Revision 1.147 2003/04/27 11:21:33 peter
  2087. * aktprocdef renamed to current_procinfo.procdef
  2088. * procinfo renamed to current_procinfo
  2089. * procinfo will now be stored in current_module so it can be
  2090. cleaned up properly
  2091. * gen_main_procsym changed to create_main_proc and release_main_proc
  2092. to also generate a tprocinfo structure
  2093. * fixed unit implicit initfinal
  2094. Revision 1.146 2003/04/27 09:08:44 jonas
  2095. * do callparatemp stuff only after the parameters have been firstpassed,
  2096. because some nodes are turned into calls during the firstpass
  2097. Revision 1.145 2003/04/27 07:29:50 peter
  2098. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2099. a new procdef declaration
  2100. * aktprocsym removed
  2101. * lexlevel removed, use symtable.symtablelevel instead
  2102. * implicit init/final code uses the normal genentry/genexit
  2103. * funcret state checking updated for new funcret handling
  2104. Revision 1.144 2003/04/25 20:59:33 peter
  2105. * removed funcretn,funcretsym, function result is now in varsym
  2106. and aliases for result and function name are added using absolutesym
  2107. * vs_hidden parameter for funcret passed in parameter
  2108. * vs_hidden fixes
  2109. * writenode changed to printnode and released from extdebug
  2110. * -vp option added to generate a tree.log with the nodetree
  2111. * nicer printnode for statements, callnode
  2112. Revision 1.143 2002/04/25 20:15:39 florian
  2113. * block nodes within expressions shouldn't release the used registers,
  2114. fixed using a flag till the new rg is ready
  2115. Revision 1.142 2003/04/23 20:16:04 peter
  2116. + added currency support based on int64
  2117. + is_64bit for use in cg units instead of is_64bitint
  2118. * removed cgmessage from n386add, replace with internalerrors
  2119. Revision 1.141 2003/04/23 13:21:06 peter
  2120. * fix warning for calling constructor inside constructor
  2121. Revision 1.140 2003/04/23 12:35:34 florian
  2122. * fixed several issues with powerpc
  2123. + applied a patch from Jonas for nested function calls (PowerPC only)
  2124. * ...
  2125. Revision 1.139 2003/04/22 23:50:22 peter
  2126. * firstpass uses expectloc
  2127. * checks if there are differences between the expectloc and
  2128. location.loc from secondpass in EXTDEBUG
  2129. Revision 1.138 2003/04/22 09:53:33 peter
  2130. * fix insert_typeconv to handle new varargs which don't have a
  2131. paraitem set
  2132. Revision 1.137 2003/04/11 16:02:05 peter
  2133. * don't firstpass typen
  2134. Revision 1.136 2003/04/11 15:51:04 peter
  2135. * support subscript,vec for setting methodpointer varstate
  2136. Revision 1.135 2003/04/10 17:57:52 peter
  2137. * vs_hidden released
  2138. Revision 1.134 2003/04/07 11:58:22 jonas
  2139. * more vs_invisible fixes
  2140. Revision 1.133 2003/04/07 10:40:21 jonas
  2141. * fixed VS_HIDDEN for high parameter so it works again
  2142. Revision 1.132 2003/04/04 15:38:56 peter
  2143. * moved generic code from n386cal to ncgcal, i386 now also
  2144. uses the generic ncgcal
  2145. Revision 1.131 2003/03/17 18:54:23 peter
  2146. * fix missing self setting for method to procvar conversion in
  2147. tp_procvar mode
  2148. Revision 1.130 2003/03/17 16:54:41 peter
  2149. * support DefaultHandler and anonymous inheritance fixed
  2150. for message methods
  2151. Revision 1.129 2003/03/17 15:54:22 peter
  2152. * store symoptions also for procdef
  2153. * check symoptions (private,public) when calculating possible
  2154. overload candidates
  2155. Revision 1.128 2003/02/19 22:00:14 daniel
  2156. * Code generator converted to new register notation
  2157. - Horribily outdated todo.txt removed
  2158. Revision 1.127 2003/01/16 22:13:52 peter
  2159. * convert_l3 convertlevel added. This level is used for conversions
  2160. where information can be lost like converting widestring->ansistring
  2161. or dword->byte
  2162. Revision 1.126 2003/01/15 01:44:32 peter
  2163. * merged methodpointer fixes from 1.0.x
  2164. Revision 1.125 2003/01/12 17:52:07 peter
  2165. * only check for auto inherited in objectsymtable
  2166. Revision 1.124 2003/01/09 21:45:46 peter
  2167. * extended information about overloaded candidates when compiled
  2168. with EXTDEBUG
  2169. Revision 1.123 2002/12/26 18:24:33 jonas
  2170. * fixed check for whether or not a high parameter was already generated
  2171. * no type checking/conversions for invisible parameters
  2172. Revision 1.122 2002/12/15 22:50:00 florian
  2173. + some stuff for the new hidden parameter handling added
  2174. Revision 1.121 2002/12/15 21:34:15 peter
  2175. * give sign difference between ordinals a small penalty. This is
  2176. needed to get word->[longword|longint] working
  2177. Revision 1.120 2002/12/15 21:30:12 florian
  2178. * tcallnode.paraitem introduced, all references to defcoll removed
  2179. Revision 1.119 2002/12/15 20:59:58 peter
  2180. * fix crash with default parameters
  2181. Revision 1.118 2002/12/15 11:26:02 peter
  2182. * ignore vs_hidden parameters when choosing overloaded proc
  2183. Revision 1.117 2002/12/11 22:42:28 peter
  2184. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2185. the old code. The new code collects the information about possible
  2186. candidates only once resultting in much less calls to type compare
  2187. routines
  2188. Revision 1.116 2002/12/07 14:27:07 carl
  2189. * 3% memory optimization
  2190. * changed some types
  2191. + added type checking with different size for call node and for
  2192. parameters
  2193. Revision 1.115 2002/12/06 17:51:10 peter
  2194. * merged cdecl and array fixes
  2195. Revision 1.114 2002/12/06 16:56:58 peter
  2196. * only compile cs_fp_emulation support when cpufpuemu is defined
  2197. * define cpufpuemu for m68k only
  2198. Revision 1.113 2002/11/27 20:04:38 peter
  2199. * cdecl array of const fixes
  2200. Revision 1.112 2002/11/27 15:33:46 peter
  2201. * the never ending story of tp procvar hacks
  2202. Revision 1.111 2002/11/27 02:31:17 peter
  2203. * fixed inlinetree parsing in det_resulttype
  2204. Revision 1.110 2002/11/25 18:43:32 carl
  2205. - removed the invalid if <> checking (Delphi is strange on this)
  2206. + implemented abstract warning on instance creation of class with
  2207. abstract methods.
  2208. * some error message cleanups
  2209. Revision 1.109 2002/11/25 17:43:17 peter
  2210. * splitted defbase in defutil,symutil,defcmp
  2211. * merged isconvertable and is_equal into compare_defs(_ext)
  2212. * made operator search faster by walking the list only once
  2213. Revision 1.108 2002/11/18 17:31:54 peter
  2214. * pass proccalloption to ret_in_xxx and push_xxx functions
  2215. Revision 1.107 2002/11/15 01:58:50 peter
  2216. * merged changes from 1.0.7 up to 04-11
  2217. - -V option for generating bug report tracing
  2218. - more tracing for option parsing
  2219. - errors for cdecl and high()
  2220. - win32 import stabs
  2221. - win32 records<=8 are returned in eax:edx (turned off by default)
  2222. - heaptrc update
  2223. - more info for temp management in .s file with EXTDEBUG
  2224. Revision 1.106 2002/10/14 18:20:30 carl
  2225. * var parameter checking for classes and interfaces in Delphi mode
  2226. Revision 1.105 2002/10/06 21:02:17 peter
  2227. * fixed limit checking for qword
  2228. Revision 1.104 2002/10/05 15:15:45 peter
  2229. * Write unknwon compiler proc using Comment and only in Extdebug
  2230. Revision 1.103 2002/10/05 12:43:25 carl
  2231. * fixes for Delphi 6 compilation
  2232. (warning : Some features do not work under Delphi)
  2233. Revision 1.102 2002/10/05 00:48:57 peter
  2234. * support inherited; support for overload as it is handled by
  2235. delphi. This is only for delphi mode as it is working is
  2236. undocumented and hard to predict what is done
  2237. Revision 1.101 2002/09/16 14:11:12 peter
  2238. * add argument to equal_paras() to support default values or not
  2239. Revision 1.100 2002/09/15 17:49:59 peter
  2240. * don't have strict var parameter checking for procedures in the
  2241. system unit
  2242. Revision 1.99 2002/09/09 19:30:34 peter
  2243. * don't allow convertable parameters for var and out parameters in
  2244. delphi and tp mode
  2245. Revision 1.98 2002/09/07 15:25:02 peter
  2246. * old logs removed and tabs fixed
  2247. Revision 1.97 2002/09/07 12:16:05 carl
  2248. * second part bug report 1996 fix, testrange in cordconstnode
  2249. only called if option is set (also make parsing a tiny faster)
  2250. Revision 1.96 2002/09/05 14:53:41 peter
  2251. * fixed old callnode.det_resulttype code
  2252. * old ncal code is default again
  2253. Revision 1.95 2002/09/03 21:32:49 daniel
  2254. * Small bugfix for procdef selection
  2255. Revision 1.94 2002/09/03 19:27:22 daniel
  2256. * Activated new ncal code
  2257. Revision 1.93 2002/09/03 16:26:26 daniel
  2258. * Make Tprocdef.defs protected
  2259. Revision 1.92 2002/09/01 13:28:37 daniel
  2260. - write_access fields removed in favor of a flag
  2261. Revision 1.91 2002/09/01 12:14:15 peter
  2262. * remove debug line
  2263. * containself methods can be called directly
  2264. Revision 1.90 2002/09/01 08:01:16 daniel
  2265. * Removed sets from Tcallnode.det_resulttype
  2266. + Added read/write notifications of variables. These will be usefull
  2267. for providing information for several optimizations. For example
  2268. the value of the loop variable of a for loop does matter is the
  2269. variable is read after the for loop, but if it's no longer used
  2270. or written, it doesn't matter and this can be used to optimize
  2271. the loop code generation.
  2272. Revision 1.89 2002/08/23 16:13:16 peter
  2273. * also firstpass funcretrefnode if available. This was breaking the
  2274. asnode compilerproc code
  2275. Revision 1.88 2002/08/20 10:31:26 daniel
  2276. * Tcallnode.det_resulttype rewritten
  2277. Revision 1.87 2002/08/19 19:36:42 peter
  2278. * More fixes for cross unit inlining, all tnodes are now implemented
  2279. * Moved pocall_internconst to po_internconst because it is not a
  2280. calling type at all and it conflicted when inlining of these small
  2281. functions was requested
  2282. Revision 1.86 2002/08/17 22:09:44 florian
  2283. * result type handling in tcgcal.pass_2 overhauled
  2284. * better tnode.dowrite
  2285. * some ppc stuff fixed
  2286. Revision 1.85 2002/08/17 09:23:34 florian
  2287. * first part of current_procinfo rewrite
  2288. Revision 1.84 2002/08/16 14:24:57 carl
  2289. * issameref() to test if two references are the same (then emit no opcodes)
  2290. + ret_in_reg to replace ret_in_acc
  2291. (fix some register allocation bugs at the same time)
  2292. + save_std_register now has an extra parameter which is the
  2293. usedinproc registers
  2294. Revision 1.83 2002/07/20 11:57:53 florian
  2295. * types.pas renamed to defbase.pas because D6 contains a types
  2296. unit so this would conflicts if D6 programms are compiled
  2297. + Willamette/SSE2 instructions to assembler added
  2298. Revision 1.82 2002/07/19 11:41:35 daniel
  2299. * State tracker work
  2300. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2301. allows the state tracker to change while nodes automatically into
  2302. repeat nodes.
  2303. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2304. 'not(a>b)' is optimized into 'a<=b'.
  2305. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2306. by removing the notn and later switchting the true and falselabels. The
  2307. same is done with 'repeat until not a'.
  2308. Revision 1.81 2002/07/15 18:03:14 florian
  2309. * readded removed changes
  2310. Revision 1.79 2002/07/11 14:41:27 florian
  2311. * start of the new generic parameter handling
  2312. Revision 1.80 2002/07/14 18:00:43 daniel
  2313. + Added the beginning of a state tracker. This will track the values of
  2314. variables through procedures and optimize things away.
  2315. Revision 1.78 2002/07/04 20:43:00 florian
  2316. * first x86-64 patches
  2317. }