ncal.pas 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288
  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,symppu,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. for i:=1 to pd.maxparacount-paralength do
  1119. hp^.firstpara:=tparaitem(hp^.firstPara.previous);
  1120. end;
  1121. end;
  1122. begin
  1123. procs:=nil;
  1124. { when the definition has overload directive set, we search for
  1125. overloaded definitions in the class, this only needs to be done once
  1126. for class entries as the tree keeps always the same }
  1127. if (not symtableprocentry.overloadchecked) and
  1128. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1129. (po_overload in symtableprocentry.first_procdef.procoptions) then
  1130. search_class_overloads(symtableprocentry);
  1131. { when the class passed is defined in this unit we
  1132. need to use the scope of that class. This is a trick
  1133. that can be used to access protected members in other
  1134. units. At least kylix supports it this way (PFV) }
  1135. if assigned(symtableproc) and
  1136. (symtableproc.symtabletype=objectsymtable) and
  1137. (symtableproc.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1138. (symtableproc.defowner.owner.unitid=0) then
  1139. topclassh:=tobjectdef(symtableproc.defowner)
  1140. else
  1141. begin
  1142. if assigned(current_procinfo) then
  1143. topclassh:=current_procinfo.procdef._class
  1144. else
  1145. topclassh:=nil;
  1146. end;
  1147. { link all procedures which have the same # of parameters }
  1148. paravisible:=false;
  1149. for j:=1 to symtableprocentry.procdef_count do
  1150. begin
  1151. pd:=symtableprocentry.procdef[j];
  1152. { Is the procdef visible? This needs to be checked on
  1153. procdef level since a symbol can contain both private and
  1154. public declarations. But the check should not be done
  1155. when the callnode is generated by a property }
  1156. if (nf_isproperty in flags) or
  1157. (pd.owner.symtabletype<>objectsymtable) or
  1158. pd.is_visible_for_object(topclassh) then
  1159. begin
  1160. { we have at least one procedure that is visible }
  1161. paravisible:=true;
  1162. { only when the # of parameter are supported by the
  1163. procedure }
  1164. if (paralength>=pd.minparacount) and
  1165. ((po_varargs in pd.procoptions) or { varargs }
  1166. (paralength<=pd.maxparacount)) then
  1167. proc_add(pd);
  1168. end;
  1169. end;
  1170. { remember if the procedure is declared with the overload directive,
  1171. it's information is still needed also after all procs are removed }
  1172. has_overload_directive:=(po_overload in symtableprocentry.first_procdef.procoptions);
  1173. { when the definition has overload directive set, we search for
  1174. overloaded definitions in the symtablestack. The found
  1175. entries are only added to the procs list and not the procsym, because
  1176. the list can change in every situation }
  1177. if has_overload_directive and
  1178. (symtableprocentry.owner.symtabletype<>objectsymtable) then
  1179. begin
  1180. srsymtable:=symtableprocentry.owner.next;
  1181. while assigned(srsymtable) do
  1182. begin
  1183. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1184. begin
  1185. {$ifdef compress}
  1186. srprocsym:=tprocsym(srsymtable.speedsearch(minilzw_encode(symtableprocentry.name),symtableprocentry.speedvalue));
  1187. {$else}
  1188. srprocsym:=tprocsym(srsymtable.speedsearch(minilzw_encode(symtableprocentry.name),symtableprocentry.speedvalue));
  1189. {$endif}
  1190. { process only visible procsyms }
  1191. if assigned(srprocsym) and
  1192. (srprocsym.typ=procsym) and
  1193. srprocsym.is_visible_for_object(topclassh) then
  1194. begin
  1195. { if this procedure doesn't have overload we can stop
  1196. searching }
  1197. if not(po_overload in srprocsym.first_procdef.procoptions) then
  1198. break;
  1199. { process all overloaded definitions }
  1200. for j:=1 to srprocsym.procdef_count do
  1201. begin
  1202. pd:=srprocsym.procdef[j];
  1203. { only when the # of parameter are supported by the
  1204. procedure }
  1205. if (paralength>=pd.minparacount) and
  1206. ((po_varargs in pd.procoptions) or { varargs }
  1207. (paralength<=pd.maxparacount)) then
  1208. begin
  1209. found:=false;
  1210. hp:=procs;
  1211. while assigned(hp) do
  1212. begin
  1213. { Only compare visible parameters for the user }
  1214. if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,[cpo_ignorehidden])>=te_equal then
  1215. begin
  1216. found:=true;
  1217. break;
  1218. end;
  1219. hp:=hp^.next;
  1220. end;
  1221. if not found then
  1222. proc_add(pd);
  1223. end;
  1224. end;
  1225. end;
  1226. end;
  1227. srsymtable:=srsymtable.next;
  1228. end;
  1229. end;
  1230. candidates_find:=procs;
  1231. end;
  1232. procedure tcallnode.candidates_free(procs:pcandidate);
  1233. var
  1234. hpnext,
  1235. hp : pcandidate;
  1236. begin
  1237. hp:=procs;
  1238. while assigned(hp) do
  1239. begin
  1240. hpnext:=hp^.next;
  1241. dispose(hp);
  1242. hp:=hpnext;
  1243. end;
  1244. end;
  1245. procedure tcallnode.candidates_list(procs:pcandidate;all:boolean);
  1246. var
  1247. hp : pcandidate;
  1248. begin
  1249. hp:=procs;
  1250. while assigned(hp) do
  1251. begin
  1252. if all or
  1253. (not hp^.invalid) then
  1254. MessagePos1(hp^.data.fileinfo,sym_h_param_list,hp^.data.fullprocname(false));
  1255. hp:=hp^.next;
  1256. end;
  1257. end;
  1258. {$ifdef EXTDEBUG}
  1259. procedure Tcallnode.candidates_dump_info(lvl:longint;procs:pcandidate);
  1260. function ParaTreeStr(p:tcallparanode):string;
  1261. begin
  1262. result:='';
  1263. while assigned(p) do
  1264. begin
  1265. if result<>'' then
  1266. result:=result+',';
  1267. result:=result+p.resulttype.def.typename;
  1268. p:=tcallparanode(p.right);
  1269. end;
  1270. end;
  1271. var
  1272. hp : pcandidate;
  1273. currpara : tparaitem;
  1274. begin
  1275. if not CheckVerbosity(lvl) then
  1276. exit;
  1277. Comment(lvl+V_LineInfo,'Overloaded callnode: '+symtableprocentry.name+'('+ParaTreeStr(tcallparanode(left))+')');
  1278. hp:=procs;
  1279. while assigned(hp) do
  1280. begin
  1281. Comment(lvl,' '+hp^.data.fullprocname(false));
  1282. if (hp^.invalid) then
  1283. Comment(lvl,' invalid')
  1284. else
  1285. begin
  1286. Comment(lvl,' ex: '+tostr(hp^.exact_count)+
  1287. ' eq: '+tostr(hp^.equal_count)+
  1288. ' l1: '+tostr(hp^.cl1_count)+
  1289. ' l2: '+tostr(hp^.cl2_count)+
  1290. ' l3: '+tostr(hp^.cl3_count)+
  1291. ' oper: '+tostr(hp^.coper_count)+
  1292. ' ord: '+realtostr(hp^.exact_count));
  1293. { Print parameters in left-right order }
  1294. currpara:=hp^.firstpara;
  1295. if assigned(currpara) then
  1296. begin
  1297. while assigned(currpara.next) do
  1298. currpara:=tparaitem(currpara.next);
  1299. end;
  1300. while assigned(currpara) do
  1301. begin
  1302. if (not currpara.is_hidden) then
  1303. Comment(lvl,' - '+currpara.paratype.def.typename+' : '+EqualTypeName[currpara.eqval]);
  1304. currpara:=tparaitem(currpara.previous);
  1305. end;
  1306. end;
  1307. hp:=hp^.next;
  1308. end;
  1309. end;
  1310. {$endif EXTDEBUG}
  1311. procedure Tcallnode.candidates_get_information(procs:pcandidate);
  1312. var
  1313. hp : pcandidate;
  1314. currpara : tparaitem;
  1315. currparanr : byte;
  1316. def_from,
  1317. def_to : tdef;
  1318. pt : tcallparanode;
  1319. eq : tequaltype;
  1320. convtype : tconverttype;
  1321. pdoper : tprocdef;
  1322. begin
  1323. { process all procs }
  1324. hp:=procs;
  1325. while assigned(hp) do
  1326. begin
  1327. { We compare parameters in reverse order (right to left),
  1328. the firstpara is already pointing to the last parameter
  1329. were we need to start comparing }
  1330. currparanr:=paralength;
  1331. currpara:=hp^.firstpara;
  1332. while assigned(currpara) and (currpara.is_hidden) do
  1333. currpara:=tparaitem(currpara.previous);
  1334. pt:=tcallparanode(left);
  1335. while assigned(pt) and assigned(currpara) do
  1336. begin
  1337. { retrieve current parameter definitions to compares }
  1338. eq:=te_incompatible;
  1339. def_from:=pt.resulttype.def;
  1340. def_to:=currpara.paratype.def;
  1341. if not(assigned(def_from)) then
  1342. internalerror(200212091);
  1343. if not(
  1344. assigned(def_to) or
  1345. ((po_varargs in hp^.data.procoptions) and
  1346. (currparanr>hp^.data.minparacount))
  1347. ) then
  1348. internalerror(200212092);
  1349. { varargs are always equal, but not exact }
  1350. if (po_varargs in hp^.data.procoptions) and
  1351. (currparanr>hp^.data.minparacount) then
  1352. begin
  1353. inc(hp^.equal_count);
  1354. eq:=te_equal;
  1355. end
  1356. else
  1357. { same definition -> exact }
  1358. if (def_from=def_to) then
  1359. begin
  1360. inc(hp^.exact_count);
  1361. eq:=te_exact;
  1362. end
  1363. else
  1364. { for value and const parameters check if a integer is constant or
  1365. included in other integer -> equal and calc ordinal_distance }
  1366. if not(currpara.paratyp in [vs_var,vs_out]) and
  1367. is_integer(def_from) and
  1368. is_integer(def_to) and
  1369. is_in_limit(def_from,def_to) then
  1370. begin
  1371. inc(hp^.equal_count);
  1372. eq:=te_equal;
  1373. hp^.ordinal_distance:=hp^.ordinal_distance+
  1374. abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
  1375. hp^.ordinal_distance:=hp^.ordinal_distance+
  1376. abs(bestreal(torddef(def_to).high)-bestreal(torddef(def_from).high));
  1377. { Give wrong sign a small penalty, this is need to get a diffrence
  1378. from word->[longword,longint] }
  1379. if is_signed(def_from)<>is_signed(def_to) then
  1380. hp^.ordinal_distance:=hp^.ordinal_distance+1.0;
  1381. end
  1382. else
  1383. { generic type comparision }
  1384. begin
  1385. eq:=compare_defs_ext(def_from,def_to,pt.left.nodetype,
  1386. false,true,convtype,pdoper);
  1387. { when the types are not equal we need to check
  1388. some special case for parameter passing }
  1389. if (eq<te_equal) then
  1390. begin
  1391. if currpara.paratyp in [vs_var,vs_out] then
  1392. begin
  1393. { para requires an equal type so the previous found
  1394. match was not good enough, reset to incompatible }
  1395. eq:=te_incompatible;
  1396. { var_para_allowed will return te_equal and te_convert_l1 to
  1397. make a difference for best matching }
  1398. var_para_allowed(eq,pt.resulttype.def,currpara.paratype.def)
  1399. end
  1400. else
  1401. para_allowed(eq,pt,def_to);
  1402. end;
  1403. case eq of
  1404. te_exact :
  1405. internalerror(200212071); { already checked }
  1406. te_equal :
  1407. inc(hp^.equal_count);
  1408. te_convert_l1 :
  1409. inc(hp^.cl1_count);
  1410. te_convert_l2 :
  1411. inc(hp^.cl2_count);
  1412. te_convert_l3 :
  1413. inc(hp^.cl3_count);
  1414. te_convert_operator :
  1415. inc(hp^.coper_count);
  1416. te_incompatible :
  1417. hp^.invalid:=true;
  1418. else
  1419. internalerror(200212072);
  1420. end;
  1421. end;
  1422. { stop checking when an incompatible parameter is found }
  1423. if hp^.invalid then
  1424. begin
  1425. { store the current parameter info for
  1426. a nice error message when no procedure is found }
  1427. hp^.wrongpara:=currpara;
  1428. hp^.wrongparanr:=currparanr;
  1429. break;
  1430. end;
  1431. {$ifdef EXTDEBUG}
  1432. { store equal in node tree for dump }
  1433. currpara.eqval:=eq;
  1434. {$endif EXTDEBUG}
  1435. { next parameter in the call tree }
  1436. pt:=tcallparanode(pt.right);
  1437. { next parameter for definition, only goto next para
  1438. if we're out of the varargs }
  1439. if not(po_varargs in hp^.data.procoptions) or
  1440. (currparanr<=hp^.data.maxparacount) then
  1441. begin
  1442. { Ignore vs_hidden parameters }
  1443. repeat
  1444. currpara:=tparaitem(currpara.previous);
  1445. until (not assigned(currpara)) or (not currpara.is_hidden);
  1446. end;
  1447. dec(currparanr);
  1448. end;
  1449. if not(hp^.invalid) and
  1450. (assigned(pt) or assigned(currpara) or (currparanr<>0)) then
  1451. internalerror(200212141);
  1452. { next candidate }
  1453. hp:=hp^.next;
  1454. end;
  1455. end;
  1456. function Tcallnode.candidates_choose_best(procs:pcandidate;var bestpd:tprocdef):integer;
  1457. var
  1458. besthpstart,
  1459. hp : pcandidate;
  1460. cntpd,
  1461. res : integer;
  1462. begin
  1463. {
  1464. Returns the number of candidates left and the
  1465. first candidate is returned in pdbest
  1466. }
  1467. { Setup the first procdef as best, only count it as a result
  1468. when it is valid }
  1469. bestpd:=procs^.data;
  1470. if procs^.invalid then
  1471. cntpd:=0
  1472. else
  1473. cntpd:=1;
  1474. if assigned(procs^.next) then
  1475. begin
  1476. besthpstart:=procs;
  1477. hp:=procs^.next;
  1478. while assigned(hp) do
  1479. begin
  1480. res:=is_better_candidate(hp,besthpstart);
  1481. if (res>0) then
  1482. begin
  1483. { hp is better, flag all procs to be incompatible }
  1484. while (besthpstart<>hp) do
  1485. begin
  1486. besthpstart^.invalid:=true;
  1487. besthpstart:=besthpstart^.next;
  1488. end;
  1489. { besthpstart is already set to hp }
  1490. bestpd:=besthpstart^.data;
  1491. cntpd:=1;
  1492. end
  1493. else
  1494. if (res<0) then
  1495. begin
  1496. { besthpstart is better, flag current hp to be incompatible }
  1497. hp^.invalid:=true;
  1498. end
  1499. else
  1500. begin
  1501. { res=0, both are valid }
  1502. if not hp^.invalid then
  1503. inc(cntpd);
  1504. end;
  1505. hp:=hp^.next;
  1506. end;
  1507. end;
  1508. candidates_choose_best:=cntpd;
  1509. end;
  1510. procedure tcallnode.candidates_find_wrong_para(procs:pcandidate);
  1511. var
  1512. currparanr : smallint;
  1513. hp : pcandidate;
  1514. pt : tcallparanode;
  1515. begin
  1516. { Only process the first overloaded procdef }
  1517. hp:=procs;
  1518. { Find callparanode corresponding to the argument }
  1519. pt:=tcallparanode(left);
  1520. currparanr:=paralength;
  1521. while assigned(pt) and
  1522. (currparanr>hp^.wrongparanr) do
  1523. begin
  1524. pt:=tcallparanode(pt.right);
  1525. dec(currparanr);
  1526. end;
  1527. if (currparanr<>hp^.wrongparanr) or
  1528. not assigned(pt) then
  1529. internalerror(200212094);
  1530. { Show error message, when it was a var or out parameter
  1531. guess that it is a missing typeconv }
  1532. if hp^.wrongpara.paratyp in [vs_var,vs_out] then
  1533. CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
  1534. pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename)
  1535. else
  1536. CGMessagePos3(pt.fileinfo,type_e_wrong_parameter_type,
  1537. tostr(hp^.wrongparanr),pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename);
  1538. end;
  1539. function tcallnode.gen_self_tree_methodpointer:tnode;
  1540. var
  1541. hsym : tvarsym;
  1542. begin
  1543. { find self field in methodpointer record }
  1544. hsym:=tvarsym(trecorddef(methodpointertype.def).symtable.search('self'));
  1545. if not assigned(hsym) then
  1546. internalerror(200305251);
  1547. { Load tmehodpointer(right).self }
  1548. result:=csubscriptnode.create(
  1549. hsym,
  1550. ctypeconvnode.create_explicit(right.getcopy,methodpointertype));
  1551. end;
  1552. function tcallnode.gen_self_tree:tnode;
  1553. var
  1554. selftree : tnode;
  1555. begin
  1556. selftree:=nil;
  1557. { inherited }
  1558. if (nf_inherited in flags) then
  1559. selftree:=load_self_node
  1560. else
  1561. { constructors }
  1562. if (procdefinition.proctypeoption=potype_constructor) then
  1563. begin
  1564. { push 0 as self when allocation is needed }
  1565. if (methodpointer.resulttype.def.deftype=classrefdef) or
  1566. (nf_new_call in flags) then
  1567. selftree:=cpointerconstnode.create(0,voidpointertype)
  1568. else
  1569. begin
  1570. if methodpointer.nodetype=typen then
  1571. selftree:=load_self_node
  1572. else
  1573. selftree:=methodpointer.getcopy;
  1574. end;
  1575. end
  1576. else
  1577. { Calling a static/class method }
  1578. if (po_classmethod in procdefinition.procoptions) or
  1579. (po_staticmethod in procdefinition.procoptions) then
  1580. begin
  1581. if (procdefinition.deftype<>procdef) then
  1582. internalerror(200305062);
  1583. if (oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  1584. begin
  1585. { we only need the vmt, loading self is not required and there is no
  1586. need to check for typen, because that will always get the
  1587. loadvmtaddrnode added }
  1588. selftree:=methodpointer.getcopy;
  1589. if methodpointer.resulttype.def.deftype<>classrefdef then
  1590. selftree:=cloadvmtaddrnode.create(selftree);
  1591. end
  1592. else
  1593. selftree:=cpointerconstnode.create(0,voidpointertype);
  1594. end
  1595. else
  1596. begin
  1597. if methodpointer.nodetype=typen then
  1598. selftree:=load_self_node
  1599. else
  1600. selftree:=methodpointer.getcopy;
  1601. end;
  1602. result:=selftree;
  1603. end;
  1604. function tcallnode.gen_vmt_tree:tnode;
  1605. var
  1606. vmttree : tnode;
  1607. begin
  1608. vmttree:=nil;
  1609. if not(procdefinition.proctypeoption in [potype_constructor,potype_destructor]) then
  1610. internalerror(200305051);
  1611. { inherited call, no create/destroy }
  1612. if (nf_inherited in flags) then
  1613. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1614. else
  1615. { do not create/destroy when called from member function
  1616. without specifying self explicit }
  1617. if (nf_member_call in flags) then
  1618. begin
  1619. if (methodpointer.resulttype.def.deftype=classrefdef) and
  1620. (procdefinition.proctypeoption=potype_constructor) then
  1621. vmttree:=methodpointer.getcopy
  1622. else
  1623. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1624. end
  1625. else
  1626. { constructor with extended syntax called from new }
  1627. if (nf_new_call in flags) then
  1628. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1629. else
  1630. { destructor with extended syntax called from dispose }
  1631. if (nf_dispose_call in flags) then
  1632. vmttree:=cloadvmtaddrnode.create(methodpointer.getcopy)
  1633. else
  1634. if (methodpointer.resulttype.def.deftype=classrefdef) then
  1635. begin
  1636. { constructor call via classreference => allocate memory }
  1637. if (procdefinition.proctypeoption=potype_constructor) and
  1638. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  1639. begin
  1640. vmttree:=methodpointer.getcopy;
  1641. { Only a typenode can be passed when it is called with <class of xx>.create }
  1642. if vmttree.nodetype=typen then
  1643. vmttree:=cloadvmtaddrnode.create(vmttree);
  1644. end
  1645. else
  1646. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1647. end
  1648. else
  1649. { class }
  1650. if is_class(methodpointer.resulttype.def) then
  1651. begin
  1652. { destructor: release instance, flag(vmt)=1
  1653. constructor: direct call, do nothing, leave vmt=0 }
  1654. if (procdefinition.proctypeoption=potype_destructor) then
  1655. vmttree:=cpointerconstnode.create(1,voidpointertype)
  1656. else
  1657. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1658. end
  1659. else
  1660. { object }
  1661. begin
  1662. { destructor: direct call, no dispose, vmt=0
  1663. constructor: initialize object, load vmt }
  1664. if (procdefinition.proctypeoption=potype_constructor) then
  1665. { old styled inherited call? }
  1666. if (methodpointer.nodetype=typen) then
  1667. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1668. else
  1669. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1670. else
  1671. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1672. end;
  1673. result:=vmttree;
  1674. end;
  1675. procedure tcallnode.bind_paraitem;
  1676. var
  1677. i : integer;
  1678. pt : tcallparanode;
  1679. oldppt : ^tcallparanode;
  1680. varargspara,
  1681. currpara : tparaitem;
  1682. used_by_callnode : boolean;
  1683. hiddentree : tnode;
  1684. newstatement : tstatementnode;
  1685. temp : ttempcreatenode;
  1686. begin
  1687. pt:=tcallparanode(left);
  1688. oldppt:=@left;
  1689. { flag all callparanodes that belong to the varargs }
  1690. i:=paralength;
  1691. while (i>procdefinition.maxparacount) do
  1692. begin
  1693. include(pt.flags,nf_varargs_para);
  1694. oldppt:[email protected];
  1695. pt:=tcallparanode(pt.right);
  1696. dec(i);
  1697. end;
  1698. { skip varargs that are inserted by array of const }
  1699. while assigned(pt) and
  1700. (nf_varargs_para in pt.flags) do
  1701. pt:=tcallparanode(pt.right);
  1702. { process normal parameters and insert hidden parameters }
  1703. currpara:=tparaitem(procdefinition.Para.last);
  1704. while assigned(currpara) do
  1705. begin
  1706. if currpara.is_hidden then
  1707. begin
  1708. { generate hidden tree }
  1709. used_by_callnode:=false;
  1710. hiddentree:=nil;
  1711. if (vo_is_funcret in tvarsym(currpara.parasym).varoptions) then
  1712. begin
  1713. { Generate funcretnode if not specified }
  1714. if assigned(funcretnode) then
  1715. begin
  1716. hiddentree:=funcretnode.getcopy;
  1717. end
  1718. else
  1719. begin
  1720. hiddentree:=internalstatements(newstatement);
  1721. { need to use resulttype instead of procdefinition.rettype,
  1722. because they can be different }
  1723. temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
  1724. addstatement(newstatement,temp);
  1725. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  1726. addstatement(newstatement,ctemprefnode.create(temp));
  1727. end;
  1728. end
  1729. else
  1730. if vo_is_high_value in tvarsym(currpara.parasym).varoptions then
  1731. begin
  1732. if not assigned(pt) then
  1733. internalerror(200304082);
  1734. { we need the information of the next parameter }
  1735. hiddentree:=gen_high_tree(pt.left,is_open_string(tparaitem(currpara.previous).paratype.def));
  1736. end
  1737. else
  1738. if vo_is_self in tvarsym(currpara.parasym).varoptions then
  1739. begin
  1740. if assigned(right) then
  1741. hiddentree:=gen_self_tree_methodpointer
  1742. else
  1743. hiddentree:=gen_self_tree;
  1744. end
  1745. else
  1746. if vo_is_vmt in tvarsym(currpara.parasym).varoptions then
  1747. begin
  1748. hiddentree:=gen_vmt_tree;
  1749. end
  1750. else
  1751. if vo_is_parentfp in tvarsym(currpara.parasym).varoptions then
  1752. begin
  1753. if not(assigned(procdefinition.owner.defowner)) then
  1754. internalerror(200309287);
  1755. hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
  1756. end;
  1757. { add the hidden parameter }
  1758. if not assigned(hiddentree) then
  1759. internalerror(200304073);
  1760. { Already insert para and let the previous node point to
  1761. this new node }
  1762. pt:=ccallparanode.create(hiddentree,oldppt^);
  1763. pt.used_by_callnode:=used_by_callnode;
  1764. oldppt^:=pt;
  1765. end;
  1766. if not assigned(pt) then
  1767. internalerror(200310052);
  1768. pt.paraitem:=currpara;
  1769. oldppt:[email protected];
  1770. pt:=tcallparanode(pt.right);
  1771. currpara:=tparaitem(currpara.previous)
  1772. end;
  1773. { Create paraitems for varargs }
  1774. pt:=tcallparanode(left);
  1775. while assigned(pt) do
  1776. begin
  1777. if nf_varargs_para in pt.flags then
  1778. begin
  1779. if not assigned(varargsparas) then
  1780. varargsparas:=tvarargspara.create;
  1781. varargspara:=tparaitem.create;
  1782. varargspara.paratyp:=vs_value;
  1783. varargspara.paratype:=pt.resulttype;
  1784. { varargspara is left-right, use insert
  1785. instead of concat }
  1786. varargsparas.insert(varargspara);
  1787. pt.paraitem:=varargspara;
  1788. end;
  1789. pt:=tcallparanode(pt.right);
  1790. end;
  1791. end;
  1792. function tcallnode.det_resulttype:tnode;
  1793. var
  1794. procs : pcandidate;
  1795. oldcallnode : tcallnode;
  1796. hpt : tnode;
  1797. pt : tcallparanode;
  1798. lastpara : longint;
  1799. currpara : tparaitem;
  1800. cand_cnt : integer;
  1801. i : longint;
  1802. method_must_be_valid,
  1803. is_const : boolean;
  1804. label
  1805. errorexit;
  1806. begin
  1807. result:=nil;
  1808. procs:=nil;
  1809. oldcallnode:=aktcallnode;
  1810. aktcallnode:=nil;
  1811. { determine length of parameter list }
  1812. pt:=tcallparanode(left);
  1813. paralength:=0;
  1814. while assigned(pt) do
  1815. begin
  1816. inc(paralength);
  1817. pt:=tcallparanode(pt.right);
  1818. end;
  1819. { determine the type of the parameters }
  1820. if assigned(left) then
  1821. begin
  1822. tcallparanode(left).get_paratype;
  1823. if codegenerror then
  1824. goto errorexit;
  1825. end;
  1826. { procedure variable ? }
  1827. if assigned(right) then
  1828. begin
  1829. set_varstate(right,vs_used,true);
  1830. resulttypepass(right);
  1831. if codegenerror then
  1832. exit;
  1833. procdefinition:=tabstractprocdef(right.resulttype.def);
  1834. { Compare parameters from right to left }
  1835. currpara:=tparaitem(procdefinition.Para.last);
  1836. while assigned(currpara) and (currpara.is_hidden) do
  1837. currpara:=tparaitem(currpara.previous);
  1838. pt:=tcallparanode(left);
  1839. lastpara:=paralength;
  1840. while assigned(currpara) and assigned(pt) do
  1841. begin
  1842. { only goto next para if we're out of the varargs }
  1843. if not(po_varargs in procdefinition.procoptions) or
  1844. (lastpara<=procdefinition.maxparacount) then
  1845. begin
  1846. repeat
  1847. currpara:=tparaitem(currpara.previous);
  1848. until (not assigned(currpara)) or (not currpara.is_hidden);
  1849. end;
  1850. pt:=tcallparanode(pt.right);
  1851. dec(lastpara);
  1852. end;
  1853. if assigned(pt) or
  1854. (assigned(currpara) and
  1855. not assigned(currpara.defaultvalue)) then
  1856. begin
  1857. if assigned(pt) then
  1858. aktfilepos:=pt.fileinfo;
  1859. CGMessage(parser_e_wrong_parameter_size);
  1860. goto errorexit;
  1861. end;
  1862. end
  1863. else
  1864. { not a procedure variable }
  1865. begin
  1866. { do we know the procedure to call ? }
  1867. if not(assigned(procdefinition)) then
  1868. begin
  1869. procs:=candidates_find;
  1870. { no procedures found? then there is something wrong
  1871. with the parameter size or the procedures are
  1872. not accessible }
  1873. if not assigned(procs) then
  1874. begin
  1875. { when it's an auto inherited call and there
  1876. is no procedure found, but the procedures
  1877. were defined with overload directive and at
  1878. least two procedures are defined then we ignore
  1879. this inherited by inserting a nothingn. Only
  1880. do this ugly hack in Delphi mode as it looks more
  1881. like a bug. It's also not documented }
  1882. if (m_delphi in aktmodeswitches) and
  1883. (nf_anon_inherited in flags) and
  1884. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1885. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1886. (symtableprocentry.procdef_count>=2) then
  1887. result:=cnothingnode.create
  1888. else
  1889. begin
  1890. { in tp mode we can try to convert to procvar if
  1891. there are no parameters specified. Only try it
  1892. when there is only one proc definition, else the
  1893. loadnode will give a strange error }
  1894. if not(assigned(left)) and
  1895. not(nf_inherited in flags) and
  1896. (m_tp_procvar in aktmodeswitches) and
  1897. (symtableprocentry.procdef_count=1) then
  1898. begin
  1899. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1900. if assigned(methodpointer) then
  1901. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1902. resulttypepass(hpt);
  1903. result:=hpt;
  1904. end
  1905. else
  1906. begin
  1907. if assigned(left) then
  1908. aktfilepos:=left.fileinfo;
  1909. if paravisible then
  1910. begin
  1911. CGMessage(parser_e_wrong_parameter_size);
  1912. symtableprocentry.write_parameter_lists(nil);
  1913. end
  1914. else
  1915. CGMessage(parser_e_cant_access_private_member);
  1916. end;
  1917. end;
  1918. goto errorexit;
  1919. end;
  1920. { Retrieve information about the candidates }
  1921. candidates_get_information(procs);
  1922. {$ifdef EXTDEBUG}
  1923. { Display info when multiple candidates are found }
  1924. if assigned(procs^.next) then
  1925. candidates_dump_info(V_Debug,procs);
  1926. {$endif EXTDEBUG}
  1927. { Choose the best candidate and count the number of
  1928. candidates left }
  1929. cand_cnt:=candidates_choose_best(procs,tprocdef(procdefinition));
  1930. { All parameters are checked, check if there are any
  1931. procedures left }
  1932. if cand_cnt>0 then
  1933. begin
  1934. { Multiple candidates left? }
  1935. if cand_cnt>1 then
  1936. begin
  1937. CGMessage(cg_e_cant_choose_overload_function);
  1938. {$ifdef EXTDEBUG}
  1939. candidates_dump_info(V_Hint,procs);
  1940. {$else}
  1941. candidates_list(procs,false);
  1942. {$endif EXTDEBUG}
  1943. { we'll just use the first candidate to make the
  1944. call }
  1945. end;
  1946. { assign procdefinition }
  1947. if symtableproc=nil then
  1948. symtableproc:=procdefinition.owner;
  1949. { update browser information }
  1950. if make_ref then
  1951. begin
  1952. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1953. inc(tprocdef(procdefinition).refcount);
  1954. if tprocdef(procdefinition).defref=nil then
  1955. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1956. end;
  1957. end
  1958. else
  1959. begin
  1960. { No candidates left, this must be a type error,
  1961. because wrong size is already checked. procdefinition
  1962. is filled with the first (random) definition that is
  1963. found. We use this definition to display a nice error
  1964. message that the wrong type is passed }
  1965. candidates_find_wrong_para(procs);
  1966. candidates_list(procs,true);
  1967. {$ifdef EXTDEBUG}
  1968. candidates_dump_info(V_Hint,procs);
  1969. {$endif EXTDEBUG}
  1970. { We can not proceed, release all procs and exit }
  1971. candidates_free(procs);
  1972. goto errorexit;
  1973. end;
  1974. candidates_free(procs);
  1975. end; { end of procedure to call determination }
  1976. end;
  1977. { add needed default parameters }
  1978. if assigned(procdefinition) and
  1979. (paralength<procdefinition.maxparacount) then
  1980. begin
  1981. currpara:=tparaitem(procdefinition.Para.first);
  1982. i:=0;
  1983. while (i<paralength) do
  1984. begin
  1985. if not assigned(currpara) then
  1986. internalerror(200306181);
  1987. if not currpara.is_hidden then
  1988. inc(i);
  1989. currpara:=tparaitem(currpara.next);
  1990. end;
  1991. while assigned(currpara) and
  1992. currpara.is_hidden do
  1993. currpara:=tparaitem(currpara.next);
  1994. while assigned(currpara) do
  1995. begin
  1996. if not assigned(currpara.defaultvalue) then
  1997. internalerror(200212142);
  1998. left:=ccallparanode.create(genconstsymtree(tconstsym(currpara.defaultvalue)),left);
  1999. currpara:=tparaitem(currpara.next);
  2000. end;
  2001. end;
  2002. { handle predefined procedures }
  2003. is_const:=(po_internconst in procdefinition.procoptions) and
  2004. ((block_type in [bt_const,bt_type]) or
  2005. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  2006. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  2007. begin
  2008. if assigned(left) then
  2009. begin
  2010. { ptr and settextbuf needs two args }
  2011. if assigned(tcallparanode(left).right) then
  2012. begin
  2013. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  2014. left:=nil;
  2015. end
  2016. else
  2017. begin
  2018. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  2019. tcallparanode(left).left:=nil;
  2020. end;
  2021. end
  2022. else
  2023. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  2024. result:=hpt;
  2025. goto errorexit;
  2026. end;
  2027. { ensure that the result type is set }
  2028. if not restypeset then
  2029. begin
  2030. { constructors return their current class type, not the type where the
  2031. constructor is declared, this can be different because of inheritance }
  2032. if (procdefinition.proctypeoption=potype_constructor) and
  2033. assigned(methodpointer) and
  2034. assigned(methodpointer.resulttype.def) and
  2035. (methodpointer.resulttype.def.deftype=classrefdef) then
  2036. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype
  2037. else
  2038. resulttype:=procdefinition.rettype;
  2039. end
  2040. else
  2041. resulttype:=restype;
  2042. if resulttype.def.needs_inittable then
  2043. include(current_procinfo.flags,pi_needs_implicit_finally);
  2044. if assigned(methodpointer) then
  2045. begin
  2046. resulttypepass(methodpointer);
  2047. { direct call to inherited abstract method, then we
  2048. can already give a error in the compiler instead
  2049. of a runtime error }
  2050. if (nf_inherited in flags) and
  2051. (po_abstractmethod in procdefinition.procoptions) then
  2052. CGMessage(cg_e_cant_call_abstract_method);
  2053. { if an inherited con- or destructor should be }
  2054. { called in a con- or destructor then a warning }
  2055. { will be made }
  2056. { con- and destructors need a pointer to the vmt }
  2057. if (nf_inherited in flags) and
  2058. (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  2059. is_object(methodpointer.resulttype.def) and
  2060. not(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) then
  2061. CGMessage(cg_w_member_cd_call_from_method);
  2062. if methodpointer.nodetype<>typen then
  2063. begin
  2064. hpt:=methodpointer;
  2065. while assigned(hpt) and (hpt.nodetype in [subscriptn,vecn]) do
  2066. hpt:=tunarynode(hpt).left;
  2067. if (procdefinition.proctypeoption=potype_constructor) and
  2068. assigned(symtableproc) and
  2069. (symtableproc.symtabletype=withsymtable) and
  2070. (tnode(twithsymtable(symtableproc).withrefnode).nodetype=temprefn) then
  2071. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  2072. { R.Init then R will be initialized by the constructor,
  2073. Also allow it for simple loads }
  2074. if (procdefinition.proctypeoption=potype_constructor) or
  2075. ((hpt.nodetype=loadn) and
  2076. (
  2077. (methodpointer.resulttype.def.deftype=classrefdef) or
  2078. (
  2079. (methodpointer.resulttype.def.deftype=objectdef) and
  2080. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  2081. )
  2082. )
  2083. ) then
  2084. method_must_be_valid:=false
  2085. else
  2086. method_must_be_valid:=true;
  2087. set_varstate(methodpointer,vs_used,method_must_be_valid);
  2088. { The object is already used if it is called once }
  2089. if (hpt.nodetype=loadn) and
  2090. (tloadnode(hpt).symtableentry.typ=varsym) then
  2091. tvarsym(tloadnode(hpt).symtableentry).varstate:=vs_used;
  2092. end;
  2093. { if we are calling the constructor check for abstract
  2094. methods. Ignore inherited and member calls, because the
  2095. class is then already created }
  2096. if (procdefinition.proctypeoption=potype_constructor) and
  2097. not(nf_inherited in flags) and
  2098. not(nf_member_call in flags) then
  2099. verifyabstractcalls;
  2100. end
  2101. else
  2102. begin
  2103. { When this is method the methodpointer must be available }
  2104. if (right=nil) and
  2105. (procdefinition.owner.symtabletype=objectsymtable) then
  2106. internalerror(200305061);
  2107. end;
  2108. { Change loading of array of const to varargs }
  2109. if assigned(left) and
  2110. is_array_of_const(tparaitem(procdefinition.para.last).paratype.def) and
  2111. (procdefinition.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  2112. convert_carg_array_of_const;
  2113. { bind paraitems to the callparanodes and insert hidden parameters }
  2114. aktcallnode:=self;
  2115. bind_paraitem;
  2116. { methodpointer is only needed for virtual calls, and
  2117. it should then be loaded with the VMT }
  2118. if (po_virtualmethod in procdefinition.procoptions) and
  2119. not(assigned(methodpointer) and
  2120. (methodpointer.nodetype=typen)) then
  2121. begin
  2122. if not assigned(methodpointer) then
  2123. internalerror(200305063);
  2124. if (methodpointer.resulttype.def.deftype<>classrefdef) then
  2125. begin
  2126. methodpointer:=cloadvmtaddrnode.create(methodpointer);
  2127. resulttypepass(methodpointer);
  2128. end;
  2129. end
  2130. else
  2131. begin
  2132. { not needed anymore }
  2133. methodpointer.free;
  2134. methodpointer:=nil;
  2135. end;
  2136. { insert type conversions for parameters }
  2137. if assigned(left) then
  2138. tcallparanode(left).insert_typeconv(true);
  2139. errorexit:
  2140. aktcallnode:=oldcallnode;
  2141. end;
  2142. procedure tcallnode.order_parameters;
  2143. var
  2144. hp,hpcurr,hpnext,hpfirst,hpprev : tcallparanode;
  2145. currloc : tcgloc;
  2146. begin
  2147. hpfirst:=nil;
  2148. hpcurr:=tcallparanode(left);
  2149. while assigned(hpcurr) do
  2150. begin
  2151. { pull out }
  2152. hpnext:=tcallparanode(hpcurr.right);
  2153. { pull in at the correct place.
  2154. Used order:
  2155. 1. LOC_REFERENCE with smallest offset (x86 only)
  2156. 2. LOC_REFERENCE with most registers
  2157. 3. LOC_REGISTER with most registers }
  2158. currloc:=hpcurr.paraitem.paraloc[callerside].loc;
  2159. hpprev:=nil;
  2160. hp:=hpfirst;
  2161. while assigned(hp) do
  2162. begin
  2163. case currloc of
  2164. LOC_REFERENCE :
  2165. begin
  2166. case hp.paraitem.paraloc[callerside].loc of
  2167. LOC_REFERENCE :
  2168. begin
  2169. { Offset is calculated like:
  2170. sub esp,12
  2171. mov [esp+8],para3
  2172. mov [esp+4],para2
  2173. mov [esp],para1
  2174. call function
  2175. That means the for pushes the para with the
  2176. highest offset (see para3) needs to be pushed first
  2177. }
  2178. if (hpcurr.registers32>hp.registers32)
  2179. {$ifdef x86}
  2180. or (hpcurr.paraitem.paraloc[callerside].reference.offset>hp.paraitem.paraloc[callerside].reference.offset)
  2181. {$endif x86}
  2182. then
  2183. break;
  2184. end;
  2185. LOC_REGISTER,
  2186. LOC_FPUREGISTER :
  2187. break;
  2188. end;
  2189. end;
  2190. LOC_FPUREGISTER,
  2191. LOC_REGISTER :
  2192. begin
  2193. if (hp.paraitem.paraloc[callerside].loc=currloc) and
  2194. (hpcurr.registers32>hp.registers32) then
  2195. break;
  2196. end;
  2197. end;
  2198. hpprev:=hp;
  2199. hp:=tcallparanode(hp.right);
  2200. end;
  2201. hpcurr.right:=hp;
  2202. if assigned(hpprev) then
  2203. hpprev.right:=hpcurr
  2204. else
  2205. hpfirst:=hpcurr;
  2206. { next }
  2207. hpcurr:=hpnext;
  2208. end;
  2209. left:=hpfirst;
  2210. end;
  2211. function tcallnode.pass_1 : tnode;
  2212. {$ifdef m68k}
  2213. var
  2214. regi : tregister;
  2215. {$endif}
  2216. label
  2217. errorexit;
  2218. begin
  2219. result:=nil;
  2220. { calculate the parameter info for the procdef }
  2221. if not procdefinition.has_paraloc_info then
  2222. begin
  2223. paramanager.create_paraloc_info(procdefinition,callerside);
  2224. procdefinition.has_paraloc_info:=true;
  2225. end;
  2226. { calculate the parameter info for varargs }
  2227. if assigned(varargsparas) then
  2228. paramanager.create_varargs_paraloc_info(procdefinition,varargsparas);
  2229. { work trough all parameters to get the register requirements }
  2230. if assigned(left) then
  2231. tcallparanode(left).det_registers;
  2232. { order parameters }
  2233. order_parameters;
  2234. { function result node }
  2235. if assigned(_funcretnode) then
  2236. firstpass(_funcretnode);
  2237. { procedure variable ? }
  2238. if assigned(right) then
  2239. begin
  2240. firstpass(right);
  2241. { procedure does a call }
  2242. if not (block_type in [bt_const,bt_type]) then
  2243. include(current_procinfo.flags,pi_do_call);
  2244. end
  2245. else
  2246. { not a procedure variable }
  2247. begin
  2248. { calc the correture value for the register }
  2249. { handle predefined procedures }
  2250. if (procdefinition.proccalloption=pocall_inline) then
  2251. begin
  2252. { inherit flags }
  2253. current_procinfo.flags:=current_procinfo.flags+((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  2254. if assigned(methodpointer) then
  2255. CGMessage(cg_e_unable_inline_object_methods);
  2256. if assigned(right) then
  2257. CGMessage(cg_e_unable_inline_procvar);
  2258. if not assigned(inlinecode) then
  2259. begin
  2260. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  2261. inlinecode:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  2262. else
  2263. CGMessage(cg_e_no_code_for_inline_stored);
  2264. if assigned(inlinecode) then
  2265. begin
  2266. { consider it has not inlined if called
  2267. again inside the args }
  2268. procdefinition.proccalloption:=pocall_default;
  2269. firstpass(inlinecode);
  2270. end;
  2271. end;
  2272. end
  2273. else
  2274. begin
  2275. if not (block_type in [bt_const,bt_type]) then
  2276. include(current_procinfo.flags,pi_do_call);
  2277. end;
  2278. end;
  2279. { get a register for the return value }
  2280. if (not is_void(resulttype.def)) then
  2281. begin
  2282. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  2283. begin
  2284. expectloc:=LOC_REFERENCE;
  2285. end
  2286. else
  2287. { for win32 records returned in EDX:EAX, we
  2288. move them to memory after ... }
  2289. if (resulttype.def.deftype=recorddef) then
  2290. begin
  2291. expectloc:=LOC_CREFERENCE;
  2292. end
  2293. else
  2294. { ansi/widestrings must be registered, so we can dispose them }
  2295. if is_ansistring(resulttype.def) or
  2296. is_widestring(resulttype.def) then
  2297. begin
  2298. expectloc:=LOC_CREFERENCE;
  2299. registers32:=1;
  2300. end
  2301. else
  2302. { we have only to handle the result if it is used }
  2303. if (nf_return_value_used in flags) then
  2304. begin
  2305. case resulttype.def.deftype of
  2306. enumdef,
  2307. orddef :
  2308. begin
  2309. if (procdefinition.proctypeoption=potype_constructor) then
  2310. begin
  2311. expectloc:=LOC_REGISTER;
  2312. registers32:=1;
  2313. end
  2314. else
  2315. begin
  2316. expectloc:=LOC_REGISTER;
  2317. if is_64bit(resulttype.def) then
  2318. registers32:=2
  2319. else
  2320. registers32:=1;
  2321. end;
  2322. end;
  2323. floatdef :
  2324. begin
  2325. expectloc:=LOC_FPUREGISTER;
  2326. {$ifdef cpufpemu}
  2327. if (cs_fp_emulation in aktmoduleswitches) then
  2328. registers32:=1
  2329. else
  2330. {$endif cpufpemu}
  2331. {$ifdef m68k}
  2332. if (tfloatdef(resulttype.def).typ=s32real) then
  2333. registers32:=1
  2334. else
  2335. {$endif m68k}
  2336. registersfpu:=1;
  2337. end;
  2338. else
  2339. begin
  2340. expectloc:=LOC_REGISTER;
  2341. registers32:=1;
  2342. end;
  2343. end;
  2344. end
  2345. else
  2346. expectloc:=LOC_VOID;
  2347. end
  2348. else
  2349. expectloc:=LOC_VOID;
  2350. {$ifdef m68k}
  2351. { we need one more address register for virtual calls on m68k }
  2352. if (po_virtualmethod in procdefinition.procoptions) then
  2353. inc(registers32);
  2354. {$endif m68k}
  2355. { a fpu can be used in any procedure !! }
  2356. {$ifdef i386}
  2357. registersfpu:=procdefinition.fpu_used;
  2358. {$endif i386}
  2359. { if this is a call to a method calc the registers }
  2360. if (methodpointer<>nil) then
  2361. begin
  2362. if methodpointer.nodetype<>typen then
  2363. begin
  2364. firstpass(methodpointer);
  2365. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  2366. registers32:=max(methodpointer.registers32,registers32);
  2367. {$ifdef SUPPORT_MMX }
  2368. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  2369. {$endif SUPPORT_MMX}
  2370. end;
  2371. end;
  2372. { determine the registers of the procedure variable }
  2373. { is this OK for inlined procs also ?? (PM) }
  2374. if assigned(inlinecode) then
  2375. begin
  2376. registersfpu:=max(inlinecode.registersfpu,registersfpu);
  2377. registers32:=max(inlinecode.registers32,registers32);
  2378. {$ifdef SUPPORT_MMX}
  2379. registersmmx:=max(inlinecode.registersmmx,registersmmx);
  2380. {$endif SUPPORT_MMX}
  2381. end;
  2382. { determine the registers of the procedure variable }
  2383. { is this OK for inlined procs also ?? (PM) }
  2384. if assigned(right) then
  2385. begin
  2386. registersfpu:=max(right.registersfpu,registersfpu);
  2387. registers32:=max(right.registers32,registers32);
  2388. {$ifdef SUPPORT_MMX}
  2389. registersmmx:=max(right.registersmmx,registersmmx);
  2390. {$endif SUPPORT_MMX}
  2391. end;
  2392. { determine the registers of the procedure }
  2393. if assigned(left) then
  2394. begin
  2395. registersfpu:=max(left.registersfpu,registersfpu);
  2396. registers32:=max(left.registers32,registers32);
  2397. {$ifdef SUPPORT_MMX}
  2398. registersmmx:=max(left.registersmmx,registersmmx);
  2399. {$endif SUPPORT_MMX}
  2400. end;
  2401. errorexit:
  2402. if assigned(inlinecode) then
  2403. procdefinition.proccalloption:=pocall_inline;
  2404. end;
  2405. {$ifdef state_tracking}
  2406. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  2407. var hp:Tcallparanode;
  2408. value:Tnode;
  2409. begin
  2410. track_state_pass:=false;
  2411. hp:=Tcallparanode(left);
  2412. while assigned(hp) do
  2413. begin
  2414. if left.track_state_pass(exec_known) then
  2415. begin
  2416. left.resulttype.def:=nil;
  2417. do_resulttypepass(left);
  2418. end;
  2419. value:=aktstate.find_fact(hp.left);
  2420. if value<>nil then
  2421. begin
  2422. track_state_pass:=true;
  2423. hp.left.destroy;
  2424. hp.left:=value.getcopy;
  2425. do_resulttypepass(hp.left);
  2426. end;
  2427. hp:=Tcallparanode(hp.right);
  2428. end;
  2429. end;
  2430. {$endif}
  2431. function tcallnode.para_count:longint;
  2432. var
  2433. ppn : tcallparanode;
  2434. begin
  2435. result:=0;
  2436. ppn:=tcallparanode(left);
  2437. while assigned(ppn) do
  2438. begin
  2439. if not(assigned(ppn.paraitem) and
  2440. ppn.paraitem.is_hidden) then
  2441. inc(result);
  2442. ppn:=tcallparanode(ppn.right);
  2443. end;
  2444. end;
  2445. function tcallnode.docompare(p: tnode): boolean;
  2446. begin
  2447. docompare :=
  2448. inherited docompare(p) and
  2449. (symtableprocentry = tcallnode(p).symtableprocentry) and
  2450. (procdefinition = tcallnode(p).procdefinition) and
  2451. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  2452. ((restypeset and tcallnode(p).restypeset and
  2453. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  2454. (not restypeset and not tcallnode(p).restypeset));
  2455. end;
  2456. procedure tcallnode.printnodedata(var t:text);
  2457. begin
  2458. if assigned(procdefinition) and
  2459. (procdefinition.deftype=procdef) then
  2460. writeln(t,printnodeindention,'proc = ',tprocdef(procdefinition).fullprocname(true))
  2461. else
  2462. begin
  2463. if assigned(symtableprocentry) then
  2464. writeln(t,printnodeindention,'proc = ',symtableprocentry.name)
  2465. else
  2466. writeln(t,printnodeindention,'proc = <nil>');
  2467. end;
  2468. printnode(t,methodpointer);
  2469. printnode(t,right);
  2470. printnode(t,left);
  2471. end;
  2472. begin
  2473. ccallnode:=tcallnode;
  2474. ccallparanode:=tcallparanode;
  2475. end.
  2476. {
  2477. $Log$
  2478. Revision 1.218 2004-01-11 23:56:19 daniel
  2479. * Experiment: Compress strings to save memory
  2480. Did not save a single byte of mem; clearly the core size is boosted by
  2481. temporary memory usage...
  2482. Revision 1.217 2003/12/28 22:09:12 florian
  2483. + setting of bit 6 of cr for c var args on ppc implemented
  2484. Revision 1.216 2003/12/21 19:42:42 florian
  2485. * fixed ppc inlining stuff
  2486. * fixed wrong unit writing
  2487. + added some sse stuff
  2488. Revision 1.215 2003/12/20 12:38:51 florian
  2489. * some x86-64 compilation fixe
  2490. Revision 1.214 2003/12/16 22:09:31 florian
  2491. * better inheritence of procinfo flags of inlined procedures
  2492. Revision 1.213 2003/12/16 21:29:24 florian
  2493. + inlined procedures inherit procinfo flags
  2494. Revision 1.212 2003/12/08 22:37:28 peter
  2495. * paralength is private again
  2496. Revision 1.211 2003/12/08 16:34:23 peter
  2497. * varargspara is left-right, so adding paraitems needs insert
  2498. instead of concat
  2499. Revision 1.210 2003/12/01 18:44:15 peter
  2500. * fixed some crashes
  2501. * fixed varargs and register calling probs
  2502. Revision 1.209 2003/11/28 17:24:22 peter
  2503. * reversed offset calculation for caller side so it works
  2504. correctly for interfaces
  2505. Revision 1.208 2003/11/23 17:05:15 peter
  2506. * register calling is left-right
  2507. * parameter ordering
  2508. * left-right calling inserts result parameter last
  2509. Revision 1.207 2003/11/10 22:02:52 peter
  2510. * cross unit inlining fixed
  2511. Revision 1.206 2003/11/10 19:09:29 peter
  2512. * procvar default value support
  2513. Revision 1.205 2003/11/06 15:54:32 peter
  2514. * fixed calling classmethod for other object from classmethod
  2515. Revision 1.204 2003/11/01 16:17:48 peter
  2516. * use explicit typecast when generating the high value
  2517. Revision 1.203 2003/10/31 15:52:58 peter
  2518. * support creating classes using <class of tobject>.create
  2519. Revision 1.202 2003/10/30 16:23:13 peter
  2520. * don't search for overloads in parents for constructors
  2521. Revision 1.201 2003/10/29 22:01:20 florian
  2522. * fixed passing of dyn. arrays to open array parameters
  2523. Revision 1.200 2003/10/23 14:44:07 peter
  2524. * splitted buildderef and buildderefimpl to fix interface crc
  2525. calculation
  2526. Revision 1.199 2003/10/22 20:40:00 peter
  2527. * write derefdata in a separate ppu entry
  2528. Revision 1.198 2003/10/21 18:17:02 peter
  2529. * only search for overloaded constructors in classes
  2530. Revision 1.197 2003/10/21 15:14:55 peter
  2531. * also search in parents for overloads when calling a constructor
  2532. Revision 1.196 2003/10/13 14:05:12 peter
  2533. * removed is_visible_for_proc
  2534. * search also for class overloads when finding interface
  2535. implementations
  2536. Revision 1.195 2003/10/09 21:31:37 daniel
  2537. * Register allocator splitted, ans abstract now
  2538. Revision 1.194 2003/10/09 15:00:13 florian
  2539. * fixed constructor call in class methods
  2540. Revision 1.193 2003/10/08 19:19:45 peter
  2541. * set_varstate cleanup
  2542. Revision 1.192 2003/10/07 21:14:32 peter
  2543. * compare_paras() has a parameter to ignore hidden parameters
  2544. * cross unit overload searching ignores hidden parameters when
  2545. comparing parameter lists. Now function(string):string is
  2546. not overriden with procedure(string) which has the same visible
  2547. parameter list
  2548. Revision 1.191 2003/10/05 21:21:52 peter
  2549. * c style array of const generates callparanodes
  2550. * varargs paraloc fixes
  2551. Revision 1.190 2003/10/05 12:54:17 peter
  2552. * don't check for abstract methods when the constructor is called
  2553. by inherited
  2554. * fix private member error instead of wrong number of parameters
  2555. Revision 1.189 2003/10/04 19:00:52 florian
  2556. * fixed TP 6.0 styled inherited call; fixes IDE with 1.1
  2557. Revision 1.188 2003/10/03 22:00:33 peter
  2558. * parameter alignment fixes
  2559. Revision 1.187 2003/10/03 14:44:38 peter
  2560. * fix IE when callnode was firstpassed twice
  2561. Revision 1.186 2003/10/02 21:13:46 peter
  2562. * protected visibility fixes
  2563. Revision 1.185 2003/10/01 20:34:48 peter
  2564. * procinfo unit contains tprocinfo
  2565. * cginfo renamed to cgbase
  2566. * moved cgmessage to verbose
  2567. * fixed ppc and sparc compiles
  2568. Revision 1.184 2003/09/28 21:44:55 peter
  2569. * fix check that filedef needs var para
  2570. Revision 1.183 2003/09/28 17:55:03 peter
  2571. * parent framepointer changed to hidden parameter
  2572. * tloadparentfpnode added
  2573. Revision 1.182 2003/09/25 21:28:00 peter
  2574. * parameter fixes
  2575. Revision 1.181 2003/09/23 17:56:05 peter
  2576. * locals and paras are allocated in the code generation
  2577. * tvarsym.localloc contains the location of para/local when
  2578. generating code for the current procedure
  2579. Revision 1.180 2003/09/16 16:17:01 peter
  2580. * varspez in calls to push_addr_param
  2581. Revision 1.179 2003/09/07 22:09:35 peter
  2582. * preparations for different default calling conventions
  2583. * various RA fixes
  2584. Revision 1.178 2003/09/06 22:27:08 florian
  2585. * fixed web bug 2669
  2586. * cosmetic fix in printnode
  2587. * tobjectdef.gettypename implemented
  2588. Revision 1.177 2003/09/03 15:55:00 peter
  2589. * NEWRA branch merged
  2590. Revision 1.176.2.3 2003/08/31 21:07:44 daniel
  2591. * callparatemp ripped
  2592. Revision 1.176.2.2 2003/08/27 20:23:55 peter
  2593. * remove old ra code
  2594. Revision 1.176.2.1 2003/08/27 19:55:54 peter
  2595. * first tregister patch
  2596. Revision 1.176 2003/08/23 18:42:57 peter
  2597. * only check for size matches when parameter is enum,ord,float
  2598. Revision 1.175 2003/08/10 17:25:23 peter
  2599. * fixed some reported bugs
  2600. Revision 1.174 2003/07/25 09:54:57 jonas
  2601. * fixed bogus abstract method warnings
  2602. Revision 1.173 2003/06/25 18:31:23 peter
  2603. * sym,def resolving partly rewritten to support also parent objects
  2604. not directly available through the uses clause
  2605. Revision 1.172 2003/06/17 16:34:44 jonas
  2606. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  2607. * renamed all_intregisters to volatile_intregisters and made it
  2608. processor dependent
  2609. Revision 1.171 2003/06/15 16:47:33 jonas
  2610. * fixed revious commit
  2611. Revision 1.170 2003/06/15 15:10:57 jonas
  2612. * callparatemp fix: if a threadvar is a parameter, that paramter also
  2613. does a call
  2614. Revision 1.169 2003/06/13 21:19:30 peter
  2615. * current_procdef removed, use current_procinfo.procdef instead
  2616. Revision 1.168 2003/06/08 20:01:53 jonas
  2617. * optimized assignments with on the right side a function that returns
  2618. an ansi- or widestring
  2619. Revision 1.167 2003/06/08 18:27:15 jonas
  2620. + ability to change the location of a ttempref node with changelocation()
  2621. method. Useful to use instead of copying the contents from one temp to
  2622. another
  2623. + some shortstring optimizations in tassignmentnode that avoid some
  2624. copying (required some shortstring optimizations to be moved from
  2625. resulttype to firstpass, because they work on callnodes and string
  2626. addnodes are only changed to callnodes in the firstpass)
  2627. * allow setting/changing the funcretnode of callnodes after the
  2628. resulttypepass has been done, funcretnode is now a property
  2629. (all of the above should have a quite big effect on callparatemp)
  2630. Revision 1.166 2003/06/08 11:42:33 peter
  2631. * creating class with abstract call checking fixed
  2632. * there will be only one warning for each class, the methods
  2633. are listed as hint
  2634. Revision 1.165 2003/06/07 20:26:32 peter
  2635. * re-resolving added instead of reloading from ppu
  2636. * tderef object added to store deref info for resolving
  2637. Revision 1.164 2003/06/03 21:05:48 peter
  2638. * fix check for procedure without parameters
  2639. * calling constructor as member will not allocate memory
  2640. Revision 1.163 2003/06/03 13:01:59 daniel
  2641. * Register allocator finished
  2642. Revision 1.162 2003/05/26 21:17:17 peter
  2643. * procinlinenode removed
  2644. * aktexit2label removed, fast exit removed
  2645. + tcallnode.inlined_pass_2 added
  2646. Revision 1.161 2003/05/25 11:34:17 peter
  2647. * methodpointer self pushing fixed
  2648. Revision 1.160 2003/05/25 08:59:16 peter
  2649. * inline fixes
  2650. Revision 1.159 2003/05/24 17:16:37 jonas
  2651. * added missing firstpass for callparatemp code
  2652. Revision 1.158 2003/05/23 14:27:35 peter
  2653. * remove some unit dependencies
  2654. * current_procinfo changes to store more info
  2655. Revision 1.157 2003/05/17 14:05:58 jonas
  2656. * fixed callparatemp for ansi/widestring and interfacecoms
  2657. Revision 1.156 2003/05/17 13:30:08 jonas
  2658. * changed tt_persistant to tt_persistent :)
  2659. * tempcreatenode now doesn't accept a boolean anymore for persistent
  2660. temps, but a ttemptype, so you can also create ansistring temps etc
  2661. Revision 1.155 2003/05/16 14:33:31 peter
  2662. * regvar fixes
  2663. Revision 1.154 2003/05/14 19:35:50 jonas
  2664. * fixed callparatemp so it works with vs_var, vs_out and formal const
  2665. parameters
  2666. Revision 1.153 2003/05/13 20:53:41 peter
  2667. * constructors return in register
  2668. Revision 1.152 2003/05/13 15:18:49 peter
  2669. * fixed various crashes
  2670. Revision 1.151 2003/05/11 21:37:03 peter
  2671. * moved implicit exception frame from ncgutil to psub
  2672. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2673. Revision 1.150 2003/05/11 14:45:12 peter
  2674. * tloadnode does not support objectsymtable,withsymtable anymore
  2675. * withnode cleanup
  2676. * direct with rewritten to use temprefnode
  2677. Revision 1.149 2003/05/09 17:47:02 peter
  2678. * self moved to hidden parameter
  2679. * removed hdisposen,hnewn,selfn
  2680. Revision 1.148 2003/05/05 14:53:16 peter
  2681. * vs_hidden replaced by is_hidden boolean
  2682. Revision 1.147 2003/04/27 11:21:33 peter
  2683. * aktprocdef renamed to current_procinfo.procdef
  2684. * procinfo renamed to current_procinfo
  2685. * procinfo will now be stored in current_module so it can be
  2686. cleaned up properly
  2687. * gen_main_procsym changed to create_main_proc and release_main_proc
  2688. to also generate a tprocinfo structure
  2689. * fixed unit implicit initfinal
  2690. Revision 1.146 2003/04/27 09:08:44 jonas
  2691. * do callparatemp stuff only after the parameters have been firstpassed,
  2692. because some nodes are turned into calls during the firstpass
  2693. Revision 1.145 2003/04/27 07:29:50 peter
  2694. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2695. a new procdef declaration
  2696. * aktprocsym removed
  2697. * lexlevel removed, use symtable.symtablelevel instead
  2698. * implicit init/final code uses the normal genentry/genexit
  2699. * funcret state checking updated for new funcret handling
  2700. Revision 1.144 2003/04/25 20:59:33 peter
  2701. * removed funcretn,funcretsym, function result is now in varsym
  2702. and aliases for result and function name are added using absolutesym
  2703. * vs_hidden parameter for funcret passed in parameter
  2704. * vs_hidden fixes
  2705. * writenode changed to printnode and released from extdebug
  2706. * -vp option added to generate a tree.log with the nodetree
  2707. * nicer printnode for statements, callnode
  2708. Revision 1.143 2002/04/25 20:15:39 florian
  2709. * block nodes within expressions shouldn't release the used registers,
  2710. fixed using a flag till the new rg is ready
  2711. Revision 1.142 2003/04/23 20:16:04 peter
  2712. + added currency support based on int64
  2713. + is_64bit for use in cg units instead of is_64bitint
  2714. * removed cgmessage from n386add, replace with internalerrors
  2715. Revision 1.141 2003/04/23 13:21:06 peter
  2716. * fix warning for calling constructor inside constructor
  2717. Revision 1.140 2003/04/23 12:35:34 florian
  2718. * fixed several issues with powerpc
  2719. + applied a patch from Jonas for nested function calls (PowerPC only)
  2720. * ...
  2721. Revision 1.139 2003/04/22 23:50:22 peter
  2722. * firstpass uses expectloc
  2723. * checks if there are differences between the expectloc and
  2724. location.loc from secondpass in EXTDEBUG
  2725. Revision 1.138 2003/04/22 09:53:33 peter
  2726. * fix insert_typeconv to handle new varargs which don't have a
  2727. paraitem set
  2728. Revision 1.137 2003/04/11 16:02:05 peter
  2729. * don't firstpass typen
  2730. Revision 1.136 2003/04/11 15:51:04 peter
  2731. * support subscript,vec for setting methodpointer varstate
  2732. Revision 1.135 2003/04/10 17:57:52 peter
  2733. * vs_hidden released
  2734. Revision 1.134 2003/04/07 11:58:22 jonas
  2735. * more vs_invisible fixes
  2736. Revision 1.133 2003/04/07 10:40:21 jonas
  2737. * fixed VS_HIDDEN for high parameter so it works again
  2738. Revision 1.132 2003/04/04 15:38:56 peter
  2739. * moved generic code from n386cal to ncgcal, i386 now also
  2740. uses the generic ncgcal
  2741. Revision 1.131 2003/03/17 18:54:23 peter
  2742. * fix missing self setting for method to procvar conversion in
  2743. tp_procvar mode
  2744. Revision 1.130 2003/03/17 16:54:41 peter
  2745. * support DefaultHandler and anonymous inheritance fixed
  2746. for message methods
  2747. Revision 1.129 2003/03/17 15:54:22 peter
  2748. * store symoptions also for procdef
  2749. * check symoptions (private,public) when calculating possible
  2750. overload candidates
  2751. Revision 1.128 2003/02/19 22:00:14 daniel
  2752. * Code generator converted to new register notation
  2753. - Horribily outdated todo.txt removed
  2754. Revision 1.127 2003/01/16 22:13:52 peter
  2755. * convert_l3 convertlevel added. This level is used for conversions
  2756. where information can be lost like converting widestring->ansistring
  2757. or dword->byte
  2758. Revision 1.126 2003/01/15 01:44:32 peter
  2759. * merged methodpointer fixes from 1.0.x
  2760. Revision 1.125 2003/01/12 17:52:07 peter
  2761. * only check for auto inherited in objectsymtable
  2762. Revision 1.124 2003/01/09 21:45:46 peter
  2763. * extended information about overloaded candidates when compiled
  2764. with EXTDEBUG
  2765. Revision 1.123 2002/12/26 18:24:33 jonas
  2766. * fixed check for whether or not a high parameter was already generated
  2767. * no type checking/conversions for invisible parameters
  2768. Revision 1.122 2002/12/15 22:50:00 florian
  2769. + some stuff for the new hidden parameter handling added
  2770. Revision 1.121 2002/12/15 21:34:15 peter
  2771. * give sign difference between ordinals a small penalty. This is
  2772. needed to get word->[longword|longint] working
  2773. Revision 1.120 2002/12/15 21:30:12 florian
  2774. * tcallnode.paraitem introduced, all references to defcoll removed
  2775. Revision 1.119 2002/12/15 20:59:58 peter
  2776. * fix crash with default parameters
  2777. Revision 1.118 2002/12/15 11:26:02 peter
  2778. * ignore vs_hidden parameters when choosing overloaded proc
  2779. Revision 1.117 2002/12/11 22:42:28 peter
  2780. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2781. the old code. The new code collects the information about possible
  2782. candidates only once resultting in much less calls to type compare
  2783. routines
  2784. Revision 1.116 2002/12/07 14:27:07 carl
  2785. * 3% memory optimization
  2786. * changed some types
  2787. + added type checking with different size for call node and for
  2788. parameters
  2789. Revision 1.115 2002/12/06 17:51:10 peter
  2790. * merged cdecl and array fixes
  2791. Revision 1.114 2002/12/06 16:56:58 peter
  2792. * only compile cs_fp_emulation support when cpufpuemu is defined
  2793. * define cpufpuemu for m68k only
  2794. Revision 1.113 2002/11/27 20:04:38 peter
  2795. * cdecl array of const fixes
  2796. Revision 1.112 2002/11/27 15:33:46 peter
  2797. * the never ending story of tp procvar hacks
  2798. Revision 1.111 2002/11/27 02:31:17 peter
  2799. * fixed inlinetree parsing in det_resulttype
  2800. Revision 1.110 2002/11/25 18:43:32 carl
  2801. - removed the invalid if <> checking (Delphi is strange on this)
  2802. + implemented abstract warning on instance creation of class with
  2803. abstract methods.
  2804. * some error message cleanups
  2805. Revision 1.109 2002/11/25 17:43:17 peter
  2806. * splitted defbase in defutil,symutil,defcmp
  2807. * merged isconvertable and is_equal into compare_defs(_ext)
  2808. * made operator search faster by walking the list only once
  2809. Revision 1.108 2002/11/18 17:31:54 peter
  2810. * pass proccalloption to ret_in_xxx and push_xxx functions
  2811. Revision 1.107 2002/11/15 01:58:50 peter
  2812. * merged changes from 1.0.7 up to 04-11
  2813. - -V option for generating bug report tracing
  2814. - more tracing for option parsing
  2815. - errors for cdecl and high()
  2816. - win32 import stabs
  2817. - win32 records<=8 are returned in eax:edx (turned off by default)
  2818. - heaptrc update
  2819. - more info for temp management in .s file with EXTDEBUG
  2820. Revision 1.106 2002/10/14 18:20:30 carl
  2821. * var parameter checking for classes and interfaces in Delphi mode
  2822. Revision 1.105 2002/10/06 21:02:17 peter
  2823. * fixed limit checking for qword
  2824. Revision 1.104 2002/10/05 15:15:45 peter
  2825. * Write unknwon compiler proc using Comment and only in Extdebug
  2826. Revision 1.103 2002/10/05 12:43:25 carl
  2827. * fixes for Delphi 6 compilation
  2828. (warning : Some features do not work under Delphi)
  2829. Revision 1.102 2002/10/05 00:48:57 peter
  2830. * support inherited; support for overload as it is handled by
  2831. delphi. This is only for delphi mode as it is working is
  2832. undocumented and hard to predict what is done
  2833. Revision 1.101 2002/09/16 14:11:12 peter
  2834. * add argument to equal_paras() to support default values or not
  2835. Revision 1.100 2002/09/15 17:49:59 peter
  2836. * don't have strict var parameter checking for procedures in the
  2837. system unit
  2838. Revision 1.99 2002/09/09 19:30:34 peter
  2839. * don't allow convertable parameters for var and out parameters in
  2840. delphi and tp mode
  2841. Revision 1.98 2002/09/07 15:25:02 peter
  2842. * old logs removed and tabs fixed
  2843. Revision 1.97 2002/09/07 12:16:05 carl
  2844. * second part bug report 1996 fix, testrange in cordconstnode
  2845. only called if option is set (also make parsing a tiny faster)
  2846. Revision 1.96 2002/09/05 14:53:41 peter
  2847. * fixed old callnode.det_resulttype code
  2848. * old ncal code is default again
  2849. Revision 1.95 2002/09/03 21:32:49 daniel
  2850. * Small bugfix for procdef selection
  2851. Revision 1.94 2002/09/03 19:27:22 daniel
  2852. * Activated new ncal code
  2853. Revision 1.93 2002/09/03 16:26:26 daniel
  2854. * Make Tprocdef.defs protected
  2855. Revision 1.92 2002/09/01 13:28:37 daniel
  2856. - write_access fields removed in favor of a flag
  2857. Revision 1.91 2002/09/01 12:14:15 peter
  2858. * remove debug line
  2859. * containself methods can be called directly
  2860. Revision 1.90 2002/09/01 08:01:16 daniel
  2861. * Removed sets from Tcallnode.det_resulttype
  2862. + Added read/write notifications of variables. These will be usefull
  2863. for providing information for several optimizations. For example
  2864. the value of the loop variable of a for loop does matter is the
  2865. variable is read after the for loop, but if it's no longer used
  2866. or written, it doesn't matter and this can be used to optimize
  2867. the loop code generation.
  2868. Revision 1.89 2002/08/23 16:13:16 peter
  2869. * also firstpass funcretrefnode if available. This was breaking the
  2870. asnode compilerproc code
  2871. Revision 1.88 2002/08/20 10:31:26 daniel
  2872. * Tcallnode.det_resulttype rewritten
  2873. Revision 1.87 2002/08/19 19:36:42 peter
  2874. * More fixes for cross unit inlining, all tnodes are now implemented
  2875. * Moved pocall_internconst to po_internconst because it is not a
  2876. calling type at all and it conflicted when inlining of these small
  2877. functions was requested
  2878. Revision 1.86 2002/08/17 22:09:44 florian
  2879. * result type handling in tcgcal.pass_2 overhauled
  2880. * better tnode.dowrite
  2881. * some ppc stuff fixed
  2882. Revision 1.85 2002/08/17 09:23:34 florian
  2883. * first part of current_procinfo rewrite
  2884. Revision 1.84 2002/08/16 14:24:57 carl
  2885. * issameref() to test if two references are the same (then emit no opcodes)
  2886. + ret_in_reg to replace ret_in_acc
  2887. (fix some register allocation bugs at the same time)
  2888. + save_std_register now has an extra parameter which is the
  2889. usedinproc registers
  2890. Revision 1.83 2002/07/20 11:57:53 florian
  2891. * types.pas renamed to defbase.pas because D6 contains a types
  2892. unit so this would conflicts if D6 programms are compiled
  2893. + Willamette/SSE2 instructions to assembler added
  2894. Revision 1.82 2002/07/19 11:41:35 daniel
  2895. * State tracker work
  2896. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2897. allows the state tracker to change while nodes automatically into
  2898. repeat nodes.
  2899. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2900. 'not(a>b)' is optimized into 'a<=b'.
  2901. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2902. by removing the notn and later switchting the true and falselabels. The
  2903. same is done with 'repeat until not a'.
  2904. Revision 1.81 2002/07/15 18:03:14 florian
  2905. * readded removed changes
  2906. Revision 1.79 2002/07/11 14:41:27 florian
  2907. * start of the new generic parameter handling
  2908. Revision 1.80 2002/07/14 18:00:43 daniel
  2909. + Added the beginning of a state tracker. This will track the values of
  2910. variables through procedures and optimize things away.
  2911. Revision 1.78 2002/07/04 20:43:00 florian
  2912. * first x86-64 patches
  2913. }