ncal.pas 97 KB

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