ncal.pas 120 KB

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