ncal.pas 100 KB

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