ncal.pas 118 KB

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