ncal.pas 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This file implements the node for sub procedure calling.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncal;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,cclasses,
  23. globtype,cpuinfo,
  24. node,
  25. {$ifdef state_tracking}
  26. nstate,
  27. {$endif state_tracking}
  28. symbase,symtype,symppu,symsym,symdef,symtable;
  29. type
  30. pcandidate = ^tcandidate;
  31. tcandidate = record
  32. next : pcandidate;
  33. data : tprocdef;
  34. wrongpara,
  35. firstpara : tparaitem;
  36. exact_count,
  37. equal_count,
  38. cl1_count,
  39. cl2_count,
  40. cl3_count,
  41. coper_count : integer; { should be signed }
  42. ordinal_distance : bestreal;
  43. invalid : boolean;
  44. wrongparanr : byte;
  45. end;
  46. tcallnode = class(tbinarynode)
  47. private
  48. paralength : smallint;
  49. function candidates_find:pcandidate;
  50. procedure candidates_free(procs:pcandidate);
  51. procedure candidates_list(procs:pcandidate;all:boolean);
  52. procedure candidates_get_information(procs:pcandidate);
  53. function candidates_choose_best(procs:pcandidate;var bestpd:tprocdef):integer;
  54. procedure candidates_find_wrong_para(procs:pcandidate);
  55. {$ifdef EXTDEBUG}
  56. procedure candidates_dump_info(lvl:longint;procs:pcandidate);
  57. {$endif EXTDEBUG}
  58. public
  59. { the symbol containing the definition of the procedure }
  60. { to call }
  61. symtableprocentry : tprocsym;
  62. { symtable where the entry was found, needed for with support }
  63. symtableproc : tsymtable;
  64. { the definition of the procedure to call }
  65. procdefinition : tabstractprocdef;
  66. methodpointer : tnode;
  67. { separately specified resulttype for some compilerprocs (e.g. }
  68. { you can't have a function with an "array of char" resulttype }
  69. { the RTL) (JM) }
  70. restype: ttype;
  71. restypeset: boolean;
  72. { function return reference node, this is used to pass an already
  73. allocated reference for a ret_in_param return value }
  74. funcretrefnode : tnode;
  75. { only the processor specific nodes need to override this }
  76. { constructor }
  77. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
  78. constructor createintern(const name: string; params: tnode);
  79. constructor createinternres(const name: string; params: tnode; const res: ttype);
  80. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  81. destructor destroy;override;
  82. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;
  84. procedure derefimpl;override;
  85. function getcopy : tnode;override;
  86. { Goes through all symbols in a class and subclasses and calls
  87. verify abstract for each .
  88. }
  89. procedure verifyabstractcalls;
  90. { called for each definition in a class and verifies if a method
  91. is abstract or not, if it is abstract, give out a warning
  92. }
  93. procedure verifyabstract(p : tnamedindexitem;arg:pointer);
  94. procedure insertintolist(l : tnodelist);override;
  95. function pass_1 : tnode;override;
  96. function det_resulttype:tnode;override;
  97. {$ifdef state_tracking}
  98. function track_state_pass(exec_known:boolean):boolean;override;
  99. {$endif state_tracking}
  100. function docompare(p: tnode): boolean; override;
  101. procedure set_procvar(procvar:tnode);
  102. private
  103. AbstractMethodsList : TStringList;
  104. end;
  105. tcallnodeclass = class of tcallnode;
  106. tcallparaflags = (
  107. { flags used by tcallparanode }
  108. cpf_exact_match_found,
  109. cpf_convlevel1found,
  110. cpf_convlevel2found,
  111. cpf_is_colon_para
  112. );
  113. tcallparanode = class(tbinarynode)
  114. callparaflags : set of tcallparaflags;
  115. paraitem : tparaitem;
  116. {$ifndef VS_HIDDEN}
  117. hightree : tnode;
  118. {$endif VS_HIDDEN}
  119. { only the processor specific nodes need to override this }
  120. { constructor }
  121. constructor create(expr,next : tnode);virtual;
  122. destructor destroy;override;
  123. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  124. procedure ppuwrite(ppufile:tcompilerppufile);override;
  125. procedure derefimpl;override;
  126. function getcopy : tnode;override;
  127. procedure insertintolist(l : tnodelist);override;
  128. procedure gen_high_tree(openstring:boolean);
  129. procedure get_paratype;
  130. procedure insert_typeconv(defcoll : tparaitem;do_count : boolean);
  131. procedure det_registers;
  132. procedure firstcallparan(do_count : boolean);
  133. procedure secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;
  134. para_alignment,para_offset : longint);virtual;abstract;
  135. function docompare(p: tnode): boolean; override;
  136. end;
  137. tcallparanodeclass = class of tcallparanode;
  138. tprocinlinenode = class(tnode)
  139. inlinetree : tnode;
  140. inlineprocdef : tprocdef;
  141. retoffset,para_offset,para_size : longint;
  142. constructor create(p:tprocdef);virtual;
  143. destructor destroy;override;
  144. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  145. procedure ppuwrite(ppufile:tcompilerppufile);override;
  146. procedure derefimpl;override;
  147. function getcopy : tnode;override;
  148. function det_resulttype : tnode;override;
  149. procedure insertintolist(l : tnodelist);override;
  150. function pass_1 : tnode;override;
  151. function docompare(p: tnode): boolean; override;
  152. end;
  153. tprocinlinenodeclass = class of tprocinlinenode;
  154. function reverseparameters(p: tcallparanode): tcallparanode;
  155. var
  156. ccallnode : tcallnodeclass;
  157. ccallparanode : tcallparanodeclass;
  158. cprocinlinenode : tprocinlinenodeclass;
  159. implementation
  160. uses
  161. systems,
  162. verbose,globals,
  163. symconst,paramgr,defutil,defcmp,
  164. htypechk,pass_1,cpubase,
  165. nbas,ncnv,nld,ninl,nadd,ncon,
  166. rgobj,cgbase
  167. ;
  168. type
  169. tobjectinfoitem = class(tlinkedlistitem)
  170. objinfo : tobjectdef;
  171. constructor create(def : tobjectdef);
  172. end;
  173. {****************************************************************************
  174. HELPERS
  175. ****************************************************************************}
  176. function reverseparameters(p: tcallparanode): tcallparanode;
  177. var
  178. hp1, hp2: tcallparanode;
  179. begin
  180. hp1:=nil;
  181. while assigned(p) do
  182. begin
  183. { pull out }
  184. hp2:=p;
  185. p:=tcallparanode(p.right);
  186. { pull in }
  187. hp2.right:=hp1;
  188. hp1:=hp2;
  189. end;
  190. reverseparameters:=hp1;
  191. end;
  192. procedure search_class_overloads(aprocsym : tprocsym);
  193. { searches n in symtable of pd and all anchestors }
  194. var
  195. speedvalue : cardinal;
  196. srsym : tprocsym;
  197. s : string;
  198. objdef : tobjectdef;
  199. begin
  200. if aprocsym.overloadchecked then
  201. exit;
  202. aprocsym.overloadchecked:=true;
  203. if (aprocsym.owner.symtabletype<>objectsymtable) then
  204. internalerror(200111021);
  205. objdef:=tobjectdef(aprocsym.owner.defowner);
  206. { we start in the parent }
  207. if not assigned(objdef.childof) then
  208. exit;
  209. objdef:=objdef.childof;
  210. s:=aprocsym.name;
  211. speedvalue:=getspeedvalue(s);
  212. while assigned(objdef) do
  213. begin
  214. srsym:=tprocsym(objdef.symtable.speedsearch(s,speedvalue));
  215. if assigned(srsym) then
  216. begin
  217. if (srsym.typ<>procsym) then
  218. internalerror(200111022);
  219. if srsym.is_visible_for_proc(aktprocdef) then
  220. begin
  221. srsym.add_para_match_to(Aprocsym);
  222. { we can stop if the overloads were already added
  223. for the found symbol }
  224. if srsym.overloadchecked then
  225. break;
  226. end;
  227. end;
  228. { next parent }
  229. objdef:=objdef.childof;
  230. end;
  231. end;
  232. function is_better_candidate(currpd,bestpd:pcandidate):integer;
  233. var
  234. res : integer;
  235. begin
  236. {
  237. Return values:
  238. > 0 when currpd is better than bestpd
  239. < 0 when bestpd is better than currpd
  240. = 0 when both are equal
  241. To choose the best candidate we use the following order:
  242. - Incompatible flag
  243. - (Smaller) Number of convert operator parameters.
  244. - (Smaller) Number of convertlevel 2 parameters.
  245. - (Smaller) Number of convertlevel 1 parameters.
  246. - (Bigger) Number of exact parameters.
  247. - (Smaller) Number of equal parameters.
  248. - (Smaller) Total of ordinal distance. For example, the distance of a word
  249. to a byte is 65535-255=65280.
  250. }
  251. if bestpd^.invalid then
  252. begin
  253. if currpd^.invalid then
  254. res:=0
  255. else
  256. res:=1;
  257. end
  258. else
  259. if currpd^.invalid then
  260. res:=-1
  261. else
  262. begin
  263. { less operator parameters? }
  264. res:=(bestpd^.coper_count-currpd^.coper_count);
  265. if (res=0) then
  266. begin
  267. { less cl3 parameters? }
  268. res:=(bestpd^.cl3_count-currpd^.cl3_count);
  269. if (res=0) then
  270. begin
  271. { less cl2 parameters? }
  272. res:=(bestpd^.cl2_count-currpd^.cl2_count);
  273. if (res=0) then
  274. begin
  275. { less cl1 parameters? }
  276. res:=(bestpd^.cl1_count-currpd^.cl1_count);
  277. if (res=0) then
  278. begin
  279. { more exact parameters? }
  280. res:=(currpd^.exact_count-bestpd^.exact_count);
  281. if (res=0) then
  282. begin
  283. { less equal parameters? }
  284. res:=(bestpd^.equal_count-currpd^.equal_count);
  285. if (res=0) then
  286. begin
  287. { smaller ordinal distance? }
  288. if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
  289. res:=1
  290. else
  291. if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
  292. res:=-1
  293. else
  294. res:=0;
  295. end;
  296. end;
  297. end;
  298. end;
  299. end;
  300. end;
  301. end;
  302. is_better_candidate:=res;
  303. end;
  304. procedure var_para_allowed(var eq:tequaltype;def_from,def_to:Tdef);
  305. begin
  306. { Note: eq must be already valid, it will only be updated! }
  307. case def_to.deftype of
  308. formaldef :
  309. begin
  310. { all types can be passed to a formaldef }
  311. eq:=te_equal;
  312. end;
  313. orddef :
  314. begin
  315. { allows conversion from word to integer and
  316. byte to shortint, but only for TP7 compatibility }
  317. if (m_tp7 in aktmodeswitches) and
  318. (def_from.deftype=orddef) and
  319. (def_from.size=def_to.size) then
  320. eq:=te_convert_l1;
  321. end;
  322. pointerdef :
  323. begin
  324. { an implicit pointer conversion is allowed }
  325. if (def_from.deftype=pointerdef) then
  326. eq:=te_convert_l1;
  327. end;
  328. stringdef :
  329. begin
  330. { all shortstrings are allowed, size is not important }
  331. if is_shortstring(def_from) and
  332. is_shortstring(def_to) then
  333. eq:=te_equal;
  334. end;
  335. objectdef :
  336. begin
  337. { child objects can be also passed }
  338. { in non-delphi mode, otherwise }
  339. { they must match exactly, except }
  340. { if they are objects }
  341. if (def_from.deftype=objectdef) and
  342. (
  343. not(m_delphi in aktmodeswitches) or
  344. (
  345. (tobjectdef(def_from).objecttype=odt_object) and
  346. (tobjectdef(def_to).objecttype=odt_object)
  347. )
  348. ) and
  349. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  350. eq:=te_convert_l1;
  351. end;
  352. filedef :
  353. begin
  354. { an implicit file conversion is also allowed }
  355. { from a typed file to an untyped one }
  356. if (def_from.deftype=filedef) and
  357. (tfiledef(def_from).filetyp = ft_typed) and
  358. (tfiledef(def_to).filetyp = ft_untyped) then
  359. eq:=te_convert_l1;
  360. end;
  361. end;
  362. end;
  363. procedure para_allowed(var eq:tequaltype;p:tcallparanode;def_to:tdef);
  364. begin
  365. { Note: eq must be already valid, it will only be updated! }
  366. case def_to.deftype of
  367. formaldef :
  368. begin
  369. { all types can be passed to a formaldef }
  370. eq:=te_equal;
  371. end;
  372. stringdef :
  373. begin
  374. { to support ansi/long/wide strings in a proper way }
  375. { string and string[10] are assumed as equal }
  376. { when searching the correct overloaded procedure }
  377. if (p.resulttype.def.deftype=stringdef) and
  378. (tstringdef(def_to).string_typ=tstringdef(p.resulttype.def).string_typ) then
  379. eq:=te_equal
  380. else
  381. { Passing a constant char to ansistring or shortstring or
  382. a widechar to widestring then handle it as equal. }
  383. if (p.left.nodetype=ordconstn) and
  384. (
  385. is_char(p.resulttype.def) and
  386. (is_shortstring(def_to) or is_ansistring(def_to))
  387. ) or
  388. (
  389. is_widechar(p.resulttype.def) and
  390. is_widestring(def_to)
  391. ) then
  392. eq:=te_equal
  393. end;
  394. setdef :
  395. begin
  396. { set can also be a not yet converted array constructor }
  397. if (p.resulttype.def.deftype=arraydef) and
  398. (tarraydef(p.resulttype.def).IsConstructor) and
  399. not(tarraydef(p.resulttype.def).IsVariant) then
  400. eq:=te_equal;
  401. end;
  402. procvardef :
  403. begin
  404. { in tp7 mode proc -> procvar is allowed }
  405. if (m_tp_procvar in aktmodeswitches) and
  406. (p.left.nodetype=calln) and
  407. (proc_to_procvar_equal(tprocdef(tcallnode(p.left).procdefinition),tprocvardef(def_to),true)>=te_equal) then
  408. eq:=te_equal;
  409. end;
  410. end;
  411. end;
  412. {****************************************************************************
  413. TOBJECTINFOITEM
  414. ****************************************************************************}
  415. constructor tobjectinfoitem.create(def : tobjectdef);
  416. begin
  417. inherited create;
  418. objinfo := def;
  419. end;
  420. {****************************************************************************
  421. TCALLPARANODE
  422. ****************************************************************************}
  423. constructor tcallparanode.create(expr,next : tnode);
  424. begin
  425. inherited create(callparan,expr,next);
  426. {$ifndef VS_HIDDEN}
  427. hightree:=nil;
  428. {$endif VS_HIDDEN}
  429. if assigned(expr) then
  430. expr.set_file_line(self);
  431. callparaflags:=[];
  432. end;
  433. destructor tcallparanode.destroy;
  434. begin
  435. {$ifndef VS_HIDDEN}
  436. hightree.free;
  437. {$endif VS_HIDDEN}
  438. inherited destroy;
  439. end;
  440. constructor tcallparanode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  441. begin
  442. inherited ppuload(t,ppufile);
  443. ppufile.getsmallset(callparaflags);
  444. {$ifndef VS_HIDDEN}
  445. hightree:=ppuloadnode(ppufile);
  446. {$endif VS_HIDDEN}
  447. end;
  448. procedure tcallparanode.ppuwrite(ppufile:tcompilerppufile);
  449. begin
  450. inherited ppuwrite(ppufile);
  451. ppufile.putsmallset(callparaflags);
  452. {$ifndef VS_HIDDEN}
  453. ppuwritenode(ppufile,hightree);
  454. {$endif VS_HIDDEN}
  455. end;
  456. procedure tcallparanode.derefimpl;
  457. begin
  458. inherited derefimpl;
  459. {$ifndef VS_HIDDEN}
  460. if assigned(hightree) then
  461. hightree.derefimpl;
  462. {$endif VS_HIDDEN}
  463. end;
  464. function tcallparanode.getcopy : tnode;
  465. var
  466. n : tcallparanode;
  467. begin
  468. n:=tcallparanode(inherited getcopy);
  469. n.callparaflags:=callparaflags;
  470. {$ifndef VS_HIDDEN}
  471. if assigned(hightree) then
  472. n.hightree:=hightree.getcopy
  473. else
  474. n.hightree:=nil;
  475. {$endif VS_HIDDEN}
  476. n.paraitem:=paraitem;
  477. result:=n;
  478. end;
  479. procedure tcallparanode.insertintolist(l : tnodelist);
  480. begin
  481. end;
  482. procedure tcallparanode.get_paratype;
  483. var
  484. old_get_para_resulttype : boolean;
  485. old_array_constructor : boolean;
  486. begin
  487. inc(parsing_para_level);
  488. if assigned(right) then
  489. tcallparanode(right).get_paratype;
  490. old_array_constructor:=allow_array_constructor;
  491. old_get_para_resulttype:=get_para_resulttype;
  492. get_para_resulttype:=true;
  493. allow_array_constructor:=true;
  494. resulttypepass(left);
  495. get_para_resulttype:=old_get_para_resulttype;
  496. allow_array_constructor:=old_array_constructor;
  497. if codegenerror then
  498. resulttype:=generrortype
  499. else
  500. resulttype:=left.resulttype;
  501. dec(parsing_para_level);
  502. end;
  503. procedure tcallparanode.insert_typeconv(defcoll : tparaitem;do_count : boolean);
  504. var
  505. oldtype : ttype;
  506. {$ifdef extdebug}
  507. store_count_ref : boolean;
  508. {$endif def extdebug}
  509. begin
  510. inc(parsing_para_level);
  511. paraitem:=defcoll;
  512. if not assigned(paraitem) then
  513. internalerror(200104261);
  514. {$ifdef extdebug}
  515. if do_count then
  516. begin
  517. store_count_ref:=count_ref;
  518. count_ref:=true;
  519. end;
  520. {$endif def extdebug}
  521. if assigned(right) then
  522. begin
  523. { if we are a para that belongs to varargs then keep
  524. the current paraitem }
  525. if (nf_varargs_para in flags) then
  526. tcallparanode(right).insert_typeconv(paraitem,do_count)
  527. else
  528. tcallparanode(right).insert_typeconv(tparaitem(paraitem.next),do_count)
  529. end;
  530. { Be sure to have the resulttype }
  531. if not assigned(left.resulttype.def) then
  532. resulttypepass(left);
  533. { Handle varargs and hidden paras directly, no typeconvs or }
  534. { typechecking needed }
  535. if (nf_varargs_para in flags) or
  536. (paraitem.paratyp = vs_hidden) then
  537. begin
  538. if (paraitem.paratyp <> vs_hidden) then
  539. begin
  540. { convert pascal to C types }
  541. case left.resulttype.def.deftype of
  542. stringdef :
  543. inserttypeconv(left,charpointertype);
  544. floatdef :
  545. inserttypeconv(left,s64floattype);
  546. end;
  547. end;
  548. set_varstate(left,true);
  549. resulttype:=left.resulttype;
  550. dec(parsing_para_level);
  551. exit;
  552. end;
  553. { Do we need arrayconstructor -> set conversion, then insert
  554. it here before the arrayconstructor node breaks the tree
  555. with its conversions of enum->ord }
  556. if (left.nodetype=arrayconstructorn) and
  557. (paraitem.paratype.def.deftype=setdef) then
  558. inserttypeconv(left,paraitem.paratype);
  559. { set some settings needed for arrayconstructor }
  560. if is_array_constructor(left.resulttype.def) then
  561. begin
  562. if is_array_of_const(paraitem.paratype.def) then
  563. begin
  564. if assigned(aktcallprocdef) and
  565. (aktcallprocdef.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  566. include(left.flags,nf_cargs);
  567. { force variant array }
  568. include(left.flags,nf_forcevaria);
  569. end
  570. else
  571. begin
  572. include(left.flags,nf_novariaallowed);
  573. { now that the resultting type is know we can insert the required
  574. typeconvs for the array constructor }
  575. tarrayconstructornode(left).force_type(tarraydef(paraitem.paratype.def).elementtype);
  576. end;
  577. end;
  578. { check if local proc/func is assigned to procvar }
  579. if left.resulttype.def.deftype=procvardef then
  580. test_local_to_procvar(tprocvardef(left.resulttype.def),paraitem.paratype.def);
  581. { generate the high() value tree }
  582. if paramanager.push_high_param(paraitem.paratype.def,aktcallprocdef.proccalloption) then
  583. gen_high_tree(is_open_string(paraitem.paratype.def));
  584. { test conversions }
  585. if not(is_shortstring(left.resulttype.def) and
  586. is_shortstring(paraitem.paratype.def)) and
  587. (paraitem.paratype.def.deftype<>formaldef) then
  588. begin
  589. { Process open parameters }
  590. if paramanager.push_high_param(paraitem.paratype.def,aktcallprocdef.proccalloption) then
  591. begin
  592. { insert type conv but hold the ranges of the array }
  593. oldtype:=left.resulttype;
  594. inserttypeconv(left,paraitem.paratype);
  595. left.resulttype:=oldtype;
  596. end
  597. else
  598. begin
  599. { for ordinals, floats and enums, verify if we might cause
  600. some range-check errors. }
  601. if (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) and
  602. (left.nodetype in [vecn,loadn,calln]) then
  603. begin
  604. if (left.resulttype.def.size>paraitem.paratype.def.size) then
  605. begin
  606. if (cs_check_range in aktlocalswitches) then
  607. Message(type_w_smaller_possible_range_check)
  608. else
  609. Message(type_h_smaller_possible_range_check);
  610. end;
  611. end;
  612. inserttypeconv(left,paraitem.paratype);
  613. end;
  614. if codegenerror then
  615. begin
  616. dec(parsing_para_level);
  617. exit;
  618. end;
  619. end;
  620. { check var strings }
  621. if (cs_strict_var_strings in aktlocalswitches) and
  622. is_shortstring(left.resulttype.def) and
  623. is_shortstring(paraitem.paratype.def) and
  624. (paraitem.paratyp in [vs_out,vs_var]) and
  625. not(is_open_string(paraitem.paratype.def)) and
  626. not(equal_defs(left.resulttype.def,paraitem.paratype.def)) then
  627. begin
  628. aktfilepos:=left.fileinfo;
  629. CGMessage(type_e_strict_var_string_violation);
  630. end;
  631. { Handle formal parameters separate }
  632. if (paraitem.paratype.def.deftype=formaldef) then
  633. begin
  634. { load procvar if a procedure is passed }
  635. if (m_tp_procvar in aktmodeswitches) and
  636. (left.nodetype=calln) and
  637. (is_void(left.resulttype.def)) then
  638. load_procvar_from_calln(left);
  639. case paraitem.paratyp of
  640. vs_var,
  641. vs_out :
  642. begin
  643. if not valid_for_formal_var(left) then
  644. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  645. end;
  646. vs_const :
  647. begin
  648. if not valid_for_formal_const(left) then
  649. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  650. end;
  651. end;
  652. end
  653. else
  654. begin
  655. { check if the argument is allowed }
  656. if (paraitem.paratyp in [vs_out,vs_var]) then
  657. valid_for_var(left);
  658. end;
  659. if paraitem.paratyp in [vs_var,vs_const] then
  660. begin
  661. { Causes problems with const ansistrings if also }
  662. { done for vs_const (JM) }
  663. if paraitem.paratyp = vs_var then
  664. set_unique(left);
  665. make_not_regable(left);
  666. end;
  667. { ansistrings out paramaters doesn't need to be }
  668. { unique, they are finalized }
  669. if paraitem.paratyp=vs_out then
  670. make_not_regable(left);
  671. if do_count then
  672. begin
  673. { not completly proper, but avoids some warnings }
  674. if (paraitem.paratyp in [vs_var,vs_out]) then
  675. set_funcret_is_valid(left);
  676. set_varstate(left,not(paraitem.paratyp in [vs_var,vs_out]));
  677. end;
  678. { must only be done after typeconv PM }
  679. resulttype:=paraitem.paratype;
  680. dec(parsing_para_level);
  681. {$ifdef extdebug}
  682. if do_count then
  683. count_ref:=store_count_ref;
  684. {$endif def extdebug}
  685. end;
  686. procedure tcallparanode.det_registers;
  687. var
  688. old_get_para_resulttype : boolean;
  689. old_array_constructor : boolean;
  690. begin
  691. if assigned(right) then
  692. begin
  693. tcallparanode(right).det_registers;
  694. registers32:=right.registers32;
  695. registersfpu:=right.registersfpu;
  696. {$ifdef SUPPORT_MMX}
  697. registersmmx:=right.registersmmx;
  698. {$endif}
  699. end;
  700. old_array_constructor:=allow_array_constructor;
  701. old_get_para_resulttype:=get_para_resulttype;
  702. get_para_resulttype:=true;
  703. allow_array_constructor:=true;
  704. firstpass(left);
  705. get_para_resulttype:=old_get_para_resulttype;
  706. allow_array_constructor:=old_array_constructor;
  707. if left.registers32>registers32 then
  708. registers32:=left.registers32;
  709. if left.registersfpu>registersfpu then
  710. registersfpu:=left.registersfpu;
  711. {$ifdef SUPPORT_MMX}
  712. if left.registersmmx>registersmmx then
  713. registersmmx:=left.registersmmx;
  714. {$endif SUPPORT_MMX}
  715. end;
  716. procedure tcallparanode.firstcallparan(do_count : boolean);
  717. begin
  718. if not assigned(left.resulttype.def) then
  719. begin
  720. get_paratype;
  721. {
  722. if assigned(defcoll) then
  723. insert_typeconv(defcoll,do_count);
  724. }
  725. end;
  726. det_registers;
  727. end;
  728. {$ifdef VS_HIDDEN}
  729. procedure tcallparanode.gen_high_tree(openstring:boolean);
  730. var
  731. temp: tnode;
  732. len : integer;
  733. loadconst : boolean;
  734. hightree : tnode;
  735. begin
  736. { if assigned(hightree) then
  737. exit;
  738. }
  739. if (nf_hightree_generated in flags) then
  740. exit;
  741. len:=-1;
  742. loadconst:=true;
  743. case left.resulttype.def.deftype of
  744. arraydef :
  745. begin
  746. { handle via a normal inline in_high_x node }
  747. loadconst := false;
  748. hightree := geninlinenode(in_high_x,false,left.getcopy);
  749. { only substract low(array) if it's <> 0 }
  750. temp := geninlinenode(in_low_x,false,left.getcopy);
  751. firstpass(temp);
  752. if (temp.nodetype <> ordconstn) or
  753. (tordconstnode(temp).value <> 0) then
  754. hightree := caddnode.create(subn,hightree,temp)
  755. else
  756. temp.free;
  757. end;
  758. stringdef :
  759. begin
  760. if openstring then
  761. begin
  762. { handle via a normal inline in_high_x node }
  763. loadconst := false;
  764. hightree := geninlinenode(in_high_x,false,left.getcopy);
  765. end
  766. else
  767. { passing a string to an array of char }
  768. begin
  769. if (left.nodetype=stringconstn) then
  770. begin
  771. len:=str_length(left);
  772. if len>0 then
  773. dec(len);
  774. end
  775. else
  776. begin
  777. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,left.getcopy),
  778. cordconstnode.create(1,s32bittype,false));
  779. loadconst:=false;
  780. end;
  781. end;
  782. end;
  783. else
  784. len:=0;
  785. end;
  786. if loadconst then
  787. hightree:=cordconstnode.create(len,s32bittype,true)
  788. else
  789. hightree:=ctypeconvnode.create(hightree,s32bittype);
  790. firstpass(hightree);
  791. temp:=ccallparanode.create(hightree,right);
  792. right:=temp;
  793. include(flags,nf_hightree_generated);
  794. end;
  795. {$else VS_HIDDEN}
  796. procedure tcallparanode.gen_high_tree(openstring:boolean);
  797. var
  798. temp: tnode;
  799. len : integer;
  800. loadconst : boolean;
  801. begin
  802. if assigned(hightree) then
  803. exit;
  804. len:=-1;
  805. loadconst:=true;
  806. case left.resulttype.def.deftype of
  807. arraydef :
  808. begin
  809. { handle via a normal inline in_high_x node }
  810. loadconst := false;
  811. hightree := geninlinenode(in_high_x,false,left.getcopy);
  812. { only substract low(array) if it's <> 0 }
  813. temp := geninlinenode(in_low_x,false,left.getcopy);
  814. firstpass(temp);
  815. if (temp.nodetype <> ordconstn) or
  816. (tordconstnode(temp).value <> 0) then
  817. hightree := caddnode.create(subn,hightree,temp)
  818. else
  819. temp.free;
  820. end;
  821. stringdef :
  822. begin
  823. if openstring then
  824. begin
  825. { handle via a normal inline in_high_x node }
  826. loadconst := false;
  827. hightree := geninlinenode(in_high_x,false,left.getcopy);
  828. end
  829. else
  830. { passing a string to an array of char }
  831. begin
  832. if (left.nodetype=stringconstn) then
  833. begin
  834. len:=str_length(left);
  835. if len>0 then
  836. dec(len);
  837. end
  838. else
  839. begin
  840. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,left.getcopy),
  841. cordconstnode.create(1,s32bittype,false));
  842. loadconst:=false;
  843. end;
  844. end;
  845. end;
  846. else
  847. len:=0;
  848. end;
  849. if loadconst then
  850. hightree:=cordconstnode.create(len,s32bittype,true)
  851. else
  852. hightree:=ctypeconvnode.create(hightree,s32bittype);
  853. firstpass(hightree);
  854. end;
  855. {$endif VS_HIDDEN}
  856. function tcallparanode.docompare(p: tnode): boolean;
  857. begin
  858. docompare :=
  859. inherited docompare(p) and
  860. (callparaflags = tcallparanode(p).callparaflags)
  861. {$ifndef VS_HIDDEN}
  862. and hightree.isequal(tcallparanode(p).hightree)
  863. {$endif VS_HIDDEN}
  864. ;
  865. end;
  866. {****************************************************************************
  867. TCALLNODE
  868. ****************************************************************************}
  869. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
  870. begin
  871. inherited create(calln,l,nil);
  872. symtableprocentry:=v;
  873. symtableproc:=st;
  874. include(flags,nf_return_value_used);
  875. methodpointer:=mp;
  876. procdefinition:=nil;
  877. restypeset := false;
  878. funcretrefnode:=nil;
  879. paralength:=-1;
  880. end;
  881. constructor tcallnode.createintern(const name: string; params: tnode);
  882. var
  883. srsym: tsym;
  884. symowner: tsymtable;
  885. begin
  886. if not (cs_compilesystem in aktmoduleswitches) then
  887. begin
  888. srsym := searchsymonlyin(systemunit,name);
  889. symowner := systemunit;
  890. end
  891. else
  892. begin
  893. searchsym(name,srsym,symowner);
  894. if not assigned(srsym) then
  895. searchsym(upper(name),srsym,symowner);
  896. end;
  897. if not assigned(srsym) or
  898. (srsym.typ <> procsym) then
  899. begin
  900. {$ifdef EXTDEBUG}
  901. Comment(V_Error,'unknown compilerproc '+name);
  902. {$endif EXTDEBUG}
  903. internalerror(200107271);
  904. end;
  905. self.create(params,tprocsym(srsym),symowner,nil);
  906. end;
  907. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  908. begin
  909. self.createintern(name,params);
  910. restype := res;
  911. restypeset := true;
  912. { both the normal and specified resulttype either have to be returned via a }
  913. { parameter or not, but no mixing (JM) }
  914. if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
  915. paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  916. internalerror(200108291);
  917. end;
  918. constructor tcallnode.createinternreturn(const name: string; params: tnode; returnnode : tnode);
  919. begin
  920. self.createintern(name,params);
  921. funcretrefnode:=returnnode;
  922. if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  923. internalerror(200204247);
  924. end;
  925. destructor tcallnode.destroy;
  926. begin
  927. methodpointer.free;
  928. funcretrefnode.free;
  929. inherited destroy;
  930. end;
  931. constructor tcallnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  932. begin
  933. inherited ppuload(t,ppufile);
  934. symtableprocentry:=tprocsym(ppufile.getderef);
  935. {$ifdef fpc}
  936. {$warning FIXME: No withsymtable support}
  937. {$endif}
  938. symtableproc:=nil;
  939. procdefinition:=tprocdef(ppufile.getderef);
  940. restypeset:=boolean(ppufile.getbyte);
  941. methodpointer:=ppuloadnode(ppufile);
  942. funcretrefnode:=ppuloadnode(ppufile);
  943. end;
  944. procedure tcallnode.ppuwrite(ppufile:tcompilerppufile);
  945. begin
  946. inherited ppuwrite(ppufile);
  947. ppufile.putderef(symtableprocentry);
  948. ppufile.putderef(procdefinition);
  949. ppufile.putbyte(byte(restypeset));
  950. ppuwritenode(ppufile,methodpointer);
  951. ppuwritenode(ppufile,funcretrefnode);
  952. end;
  953. procedure tcallnode.derefimpl;
  954. begin
  955. inherited derefimpl;
  956. resolvesym(pointer(symtableprocentry));
  957. symtableproc:=symtableprocentry.owner;
  958. resolvedef(pointer(procdefinition));
  959. if assigned(methodpointer) then
  960. methodpointer.derefimpl;
  961. if assigned(funcretrefnode) then
  962. funcretrefnode.derefimpl;
  963. end;
  964. procedure tcallnode.set_procvar(procvar:tnode);
  965. begin
  966. right:=procvar;
  967. end;
  968. function tcallnode.getcopy : tnode;
  969. var
  970. n : tcallnode;
  971. begin
  972. n:=tcallnode(inherited getcopy);
  973. n.symtableprocentry:=symtableprocentry;
  974. n.symtableproc:=symtableproc;
  975. n.procdefinition:=procdefinition;
  976. n.restype := restype;
  977. n.restypeset := restypeset;
  978. if assigned(methodpointer) then
  979. n.methodpointer:=methodpointer.getcopy
  980. else
  981. n.methodpointer:=nil;
  982. if assigned(funcretrefnode) then
  983. n.funcretrefnode:=funcretrefnode.getcopy
  984. else
  985. n.funcretrefnode:=nil;
  986. result:=n;
  987. end;
  988. procedure tcallnode.insertintolist(l : tnodelist);
  989. begin
  990. end;
  991. procedure tcallnode.verifyabstract(p : tnamedindexitem;arg:pointer);
  992. var
  993. hp : tprocdef;
  994. j: integer;
  995. begin
  996. if (tsym(p).typ=procsym) then
  997. begin
  998. for j:=1 to tprocsym(p).procdef_count do
  999. begin
  1000. { index starts at 1 }
  1001. hp:=tprocsym(p).procdef[j];
  1002. { If this is an abstract method insert into the list }
  1003. if (po_abstractmethod in hp.procoptions) then
  1004. AbstractMethodsList.Insert(hp.procsym.name)
  1005. else
  1006. { If this symbol is already in the list, and it is
  1007. an overriding method or dynamic, then remove it from the list
  1008. }
  1009. begin
  1010. { symbol was found }
  1011. if AbstractMethodsList.Find(hp.procsym.name) <> nil then
  1012. begin
  1013. if po_overridingmethod in hp.procoptions then
  1014. AbstractMethodsList.Remove(hp.procsym.name);
  1015. end;
  1016. end;
  1017. end;
  1018. end;
  1019. end;
  1020. procedure tcallnode.verifyabstractcalls;
  1021. var
  1022. objectdf : tobjectdef;
  1023. parents : tlinkedlist;
  1024. objectinfo : tobjectinfoitem;
  1025. stritem : tstringlistitem;
  1026. _classname : string;
  1027. begin
  1028. objectdf := nil;
  1029. { verify if trying to create an instance of a class which contains
  1030. non-implemented abstract methods }
  1031. { first verify this class type, no class than exit }
  1032. { also, this checking can only be done if the constructor is directly
  1033. called, indirect constructor calls cannot be checked.
  1034. }
  1035. if assigned(methodpointer) and assigned(methodpointer.resulttype.def) then
  1036. if (methodpointer.resulttype.def.deftype = classrefdef) and
  1037. (methodpointer.nodetype in [typen,loadvmtn]) then
  1038. begin
  1039. if (tclassrefdef(methodpointer.resulttype.def).pointertype.def.deftype = objectdef) then
  1040. objectdf := tobjectdef(tclassrefdef(methodpointer.resulttype.def).pointertype.def);
  1041. end;
  1042. if not assigned(objectdf) then exit;
  1043. if assigned(objectdf.symtable.name) then
  1044. _classname := objectdf.symtable.name^
  1045. else
  1046. _classname := '';
  1047. parents := tlinkedlist.create;
  1048. AbstractMethodsList := tstringlist.create;
  1049. { insert all parents in this class : the first item in the
  1050. list will be the base parent of the class .
  1051. }
  1052. while assigned(objectdf) do
  1053. begin
  1054. objectinfo:=tobjectinfoitem.create(objectdf);
  1055. parents.insert(objectinfo);
  1056. objectdf := objectdf.childof;
  1057. end;
  1058. { now all parents are in the correct order
  1059. insert all abstract methods in the list, and remove
  1060. those which are overriden by parent classes.
  1061. }
  1062. objectinfo:=tobjectinfoitem(parents.first);
  1063. while assigned(objectinfo) do
  1064. begin
  1065. objectdf := objectinfo.objinfo;
  1066. if assigned(objectdf.symtable) then
  1067. objectdf.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}verifyabstract,nil);
  1068. objectinfo:=tobjectinfoitem(objectinfo.next);
  1069. end;
  1070. if assigned(parents) then
  1071. parents.free;
  1072. { Finally give out a warning for each abstract method still in the list }
  1073. stritem := tstringlistitem(AbstractMethodsList.first);
  1074. while assigned(stritem) do
  1075. begin
  1076. if assigned(stritem.fpstr) then
  1077. Message2(type_w_instance_with_abstract,lower(_classname),lower(stritem.fpstr^));
  1078. stritem := tstringlistitem(stritem.next);
  1079. end;
  1080. if assigned(AbstractMethodsList) then
  1081. AbstractMethodsList.Free;
  1082. end;
  1083. function Tcallnode.candidates_find:pcandidate;
  1084. var
  1085. j : integer;
  1086. pd : tprocdef;
  1087. procs,hp : pcandidate;
  1088. found,
  1089. has_overload_directive : boolean;
  1090. srsymtable : tsymtable;
  1091. srprocsym : tprocsym;
  1092. procedure proc_add(pd:tprocdef);
  1093. var
  1094. i : integer;
  1095. begin
  1096. { generate new candidate entry }
  1097. new(hp);
  1098. fillchar(hp^,sizeof(tcandidate),0);
  1099. hp^.data:=pd;
  1100. hp^.next:=procs;
  1101. procs:=hp;
  1102. { Setup first parameter, skip all default parameters
  1103. that are not passed. Ignore this skipping for varargs }
  1104. hp^.firstpara:=tparaitem(pd.Para.first);
  1105. if not(po_varargs in pd.procoptions) then
  1106. begin
  1107. for i:=1 to pd.maxparacount-paralength do
  1108. hp^.firstpara:=tparaitem(hp^.firstPara.next);
  1109. end;
  1110. end;
  1111. begin
  1112. procs:=nil;
  1113. { when the definition has overload directive set, we search for
  1114. overloaded definitions in the class, this only needs to be done once
  1115. for class entries as the tree keeps always the same }
  1116. if (not symtableprocentry.overloadchecked) and
  1117. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1118. (symtableprocentry.owner.symtabletype=objectsymtable) then
  1119. search_class_overloads(symtableprocentry);
  1120. { link all procedures which have the same # of parameters }
  1121. for j:=1 to symtableprocentry.procdef_count do
  1122. begin
  1123. pd:=symtableprocentry.procdef[j];
  1124. { Is the procdef visible? This needs to be checked on
  1125. procdef level since a symbol can contain both private and
  1126. public declarations. But the check should not be done
  1127. when the callnode is generated by a property }
  1128. if (nf_isproperty in flags) or
  1129. (pd.owner.symtabletype<>objectsymtable) or
  1130. pd.is_visible_for_proc(aktprocdef) then
  1131. begin
  1132. { only when the # of parameter are supported by the
  1133. procedure }
  1134. if (paralength>=pd.minparacount) and
  1135. ((po_varargs in pd.procoptions) or { varargs }
  1136. (paralength<=pd.maxparacount)) then
  1137. proc_add(pd);
  1138. end;
  1139. end;
  1140. { remember if the procedure is declared with the overload directive,
  1141. it's information is still needed also after all procs are removed }
  1142. has_overload_directive:=(po_overload in symtableprocentry.first_procdef.procoptions);
  1143. { when the definition has overload directive set, we search for
  1144. overloaded definitions in the symtablestack. The found
  1145. entries are only added to the procs list and not the procsym, because
  1146. the list can change in every situation }
  1147. if has_overload_directive and
  1148. (symtableprocentry.owner.symtabletype<>objectsymtable) then
  1149. begin
  1150. srsymtable:=symtableprocentry.owner.next;
  1151. while assigned(srsymtable) do
  1152. begin
  1153. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1154. begin
  1155. srprocsym:=tprocsym(srsymtable.speedsearch(symtableprocentry.name,symtableprocentry.speedvalue));
  1156. { process only visible procsyms }
  1157. if assigned(srprocsym) and
  1158. (srprocsym.typ=procsym) and
  1159. srprocsym.is_visible_for_proc(aktprocdef) then
  1160. begin
  1161. { if this procedure doesn't have overload we can stop
  1162. searching }
  1163. if not(po_overload in srprocsym.first_procdef.procoptions) then
  1164. break;
  1165. { process all overloaded definitions }
  1166. for j:=1 to srprocsym.procdef_count do
  1167. begin
  1168. pd:=srprocsym.procdef[j];
  1169. { only when the # of parameter are supported by the
  1170. procedure }
  1171. if (paralength>=pd.minparacount) and
  1172. ((po_varargs in pd.procoptions) or { varargs }
  1173. (paralength<=pd.maxparacount)) then
  1174. begin
  1175. found:=false;
  1176. hp:=procs;
  1177. while assigned(hp) do
  1178. begin
  1179. if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,false)>=te_equal then
  1180. begin
  1181. found:=true;
  1182. break;
  1183. end;
  1184. hp:=hp^.next;
  1185. end;
  1186. if not found then
  1187. proc_add(pd);
  1188. end;
  1189. end;
  1190. end;
  1191. end;
  1192. srsymtable:=srsymtable.next;
  1193. end;
  1194. end;
  1195. candidates_find:=procs;
  1196. end;
  1197. procedure tcallnode.candidates_free(procs:pcandidate);
  1198. var
  1199. hpnext,
  1200. hp : pcandidate;
  1201. begin
  1202. hp:=procs;
  1203. while assigned(hp) do
  1204. begin
  1205. hpnext:=hp^.next;
  1206. dispose(hp);
  1207. hp:=hpnext;
  1208. end;
  1209. end;
  1210. procedure tcallnode.candidates_list(procs:pcandidate;all:boolean);
  1211. var
  1212. hp : pcandidate;
  1213. begin
  1214. hp:=procs;
  1215. while assigned(hp) do
  1216. begin
  1217. if all or
  1218. (not hp^.invalid) then
  1219. MessagePos1(hp^.data.fileinfo,sym_h_param_list,hp^.data.fullprocname);
  1220. hp:=hp^.next;
  1221. end;
  1222. end;
  1223. {$ifdef EXTDEBUG}
  1224. procedure Tcallnode.candidates_dump_info(lvl:longint;procs:pcandidate);
  1225. function ParaTreeStr(p:tcallparanode):string;
  1226. begin
  1227. result:='';
  1228. while assigned(p) do
  1229. begin
  1230. if result<>'' then
  1231. result:=result+',';
  1232. result:=result+p.resulttype.def.typename;
  1233. p:=tcallparanode(p.right);
  1234. end;
  1235. end;
  1236. var
  1237. hp : pcandidate;
  1238. currpara : tparaitem;
  1239. begin
  1240. if not CheckVerbosity(lvl) then
  1241. exit;
  1242. Comment(lvl+V_LineInfo,'Overloaded callnode: '+symtableprocentry.name+'('+ParaTreeStr(tcallparanode(left))+')');
  1243. hp:=procs;
  1244. while assigned(hp) do
  1245. begin
  1246. Comment(lvl,' '+hp^.data.fullprocname);
  1247. if (hp^.invalid) then
  1248. Comment(lvl,' invalid')
  1249. else
  1250. begin
  1251. Comment(lvl,' ex: '+tostr(hp^.exact_count)+
  1252. ' eq: '+tostr(hp^.equal_count)+
  1253. ' l1: '+tostr(hp^.cl1_count)+
  1254. ' l2: '+tostr(hp^.cl2_count)+
  1255. ' l3: '+tostr(hp^.cl3_count)+
  1256. ' oper: '+tostr(hp^.coper_count)+
  1257. ' ord: '+realtostr(hp^.exact_count));
  1258. { Print parameters in left-right order }
  1259. currpara:=hp^.firstpara;
  1260. if assigned(currpara) then
  1261. begin
  1262. while assigned(currpara.next) do
  1263. currpara:=tparaitem(currpara.next);
  1264. end;
  1265. while assigned(currpara) do
  1266. begin
  1267. if (currpara.paratyp<>vs_hidden) then
  1268. Comment(lvl,' - '+currpara.paratype.def.typename+' : '+EqualTypeName[currpara.eqval]);
  1269. currpara:=tparaitem(currpara.previous);
  1270. end;
  1271. end;
  1272. hp:=hp^.next;
  1273. end;
  1274. end;
  1275. {$endif EXTDEBUG}
  1276. procedure Tcallnode.candidates_get_information(procs:pcandidate);
  1277. var
  1278. hp : pcandidate;
  1279. currpara : tparaitem;
  1280. currparanr : byte;
  1281. def_from,
  1282. def_to : tdef;
  1283. pt : tcallparanode;
  1284. eq : tequaltype;
  1285. convtype : tconverttype;
  1286. pdoper : tprocdef;
  1287. begin
  1288. { process all procs }
  1289. hp:=procs;
  1290. while assigned(hp) do
  1291. begin
  1292. { Setup first parameter to compare }
  1293. currparanr:=paralength;
  1294. currpara:=hp^.firstpara;
  1295. while assigned(currpara) and (currpara.paratyp=vs_hidden) do
  1296. currpara:=tparaitem(currpara.next);
  1297. pt:=tcallparanode(left);
  1298. while assigned(pt) and assigned(currpara) do
  1299. begin
  1300. { retrieve current parameter definitions to compares }
  1301. eq:=te_incompatible;
  1302. def_from:=pt.resulttype.def;
  1303. def_to:=currpara.paratype.def;
  1304. if not(assigned(def_from)) then
  1305. internalerror(200212091);
  1306. if not(
  1307. assigned(def_to) or
  1308. ((po_varargs in hp^.data.procoptions) and
  1309. (currparanr>hp^.data.minparacount))
  1310. ) then
  1311. internalerror(200212092);
  1312. { varargs are always equal, but not exact }
  1313. if (po_varargs in hp^.data.procoptions) and
  1314. (currparanr>hp^.data.minparacount) then
  1315. begin
  1316. inc(hp^.equal_count);
  1317. eq:=te_equal;
  1318. end
  1319. else
  1320. { same definition -> exact }
  1321. if (def_from=def_to) then
  1322. begin
  1323. inc(hp^.exact_count);
  1324. eq:=te_exact;
  1325. end
  1326. else
  1327. { for value and const parameters check if a integer is constant or
  1328. included in other integer -> equal and calc ordinal_distance }
  1329. if not(currpara.paratyp in [vs_var,vs_out]) and
  1330. is_integer(def_from) and
  1331. is_integer(def_to) and
  1332. is_in_limit(def_from,def_to) then
  1333. begin
  1334. inc(hp^.equal_count);
  1335. eq:=te_equal;
  1336. hp^.ordinal_distance:=hp^.ordinal_distance+
  1337. abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
  1338. hp^.ordinal_distance:=hp^.ordinal_distance+
  1339. abs(bestreal(torddef(def_to).high)-bestreal(torddef(def_from).high));
  1340. { Give wrong sign a small penalty, this is need to get a diffrence
  1341. from word->[longword,longint] }
  1342. if is_signed(def_from)<>is_signed(def_to) then
  1343. hp^.ordinal_distance:=hp^.ordinal_distance+1.0;
  1344. end
  1345. else
  1346. { generic type comparision }
  1347. begin
  1348. eq:=compare_defs_ext(def_from,def_to,pt.left.nodetype,
  1349. false,true,convtype,pdoper);
  1350. { when the types are not equal we need to check
  1351. some special case for parameter passing }
  1352. if (eq<te_equal) then
  1353. begin
  1354. if currpara.paratyp in [vs_var,vs_out] then
  1355. begin
  1356. { para requires an equal type so the previous found
  1357. match was not good enough, reset to incompatible }
  1358. eq:=te_incompatible;
  1359. { var_para_allowed will return te_equal and te_convert_l1 to
  1360. make a difference for best matching }
  1361. var_para_allowed(eq,pt.resulttype.def,currpara.paratype.def)
  1362. end
  1363. else
  1364. para_allowed(eq,pt,def_to);
  1365. end;
  1366. case eq of
  1367. te_exact :
  1368. internalerror(200212071); { already checked }
  1369. te_equal :
  1370. inc(hp^.equal_count);
  1371. te_convert_l1 :
  1372. inc(hp^.cl1_count);
  1373. te_convert_l2 :
  1374. inc(hp^.cl2_count);
  1375. te_convert_l3 :
  1376. inc(hp^.cl3_count);
  1377. te_convert_operator :
  1378. inc(hp^.coper_count);
  1379. te_incompatible :
  1380. hp^.invalid:=true;
  1381. else
  1382. internalerror(200212072);
  1383. end;
  1384. end;
  1385. { stop checking when an incompatible parameter is found }
  1386. if hp^.invalid then
  1387. begin
  1388. { store the current parameter info for
  1389. a nice error message when no procedure is found }
  1390. hp^.wrongpara:=currpara;
  1391. hp^.wrongparanr:=currparanr;
  1392. break;
  1393. end;
  1394. {$ifdef EXTDEBUG}
  1395. { store equal in node tree for dump }
  1396. currpara.eqval:=eq;
  1397. {$endif EXTDEBUG}
  1398. { next parameter in the call tree }
  1399. pt:=tcallparanode(pt.right);
  1400. { next parameter for definition, only goto next para
  1401. if we're out of the varargs }
  1402. if not(po_varargs in hp^.data.procoptions) or
  1403. (currparanr<=hp^.data.maxparacount) then
  1404. begin
  1405. { Ignore vs_hidden parameters }
  1406. repeat
  1407. currpara:=tparaitem(currpara.next);
  1408. until (not assigned(currpara)) or (currpara.paratyp<>vs_hidden);
  1409. end;
  1410. dec(currparanr);
  1411. end;
  1412. if not(hp^.invalid) and
  1413. (assigned(pt) or assigned(currpara) or (currparanr<>0)) then
  1414. internalerror(200212141);
  1415. { next candidate }
  1416. hp:=hp^.next;
  1417. end;
  1418. end;
  1419. function Tcallnode.candidates_choose_best(procs:pcandidate;var bestpd:tprocdef):integer;
  1420. var
  1421. besthpstart,
  1422. hp : pcandidate;
  1423. cntpd,
  1424. res : integer;
  1425. begin
  1426. {
  1427. Returns the number of candidates left and the
  1428. first candidate is returned in pdbest
  1429. }
  1430. { Setup the first procdef as best, only count it as a result
  1431. when it is valid }
  1432. bestpd:=procs^.data;
  1433. if procs^.invalid then
  1434. cntpd:=0
  1435. else
  1436. cntpd:=1;
  1437. if assigned(procs^.next) then
  1438. begin
  1439. besthpstart:=procs;
  1440. hp:=procs^.next;
  1441. while assigned(hp) do
  1442. begin
  1443. res:=is_better_candidate(hp,besthpstart);
  1444. if (res>0) then
  1445. begin
  1446. { hp is better, flag all procs to be incompatible }
  1447. while (besthpstart<>hp) do
  1448. begin
  1449. besthpstart^.invalid:=true;
  1450. besthpstart:=besthpstart^.next;
  1451. end;
  1452. { besthpstart is already set to hp }
  1453. bestpd:=besthpstart^.data;
  1454. cntpd:=1;
  1455. end
  1456. else
  1457. if (res<0) then
  1458. begin
  1459. { besthpstart is better, flag current hp to be incompatible }
  1460. hp^.invalid:=true;
  1461. end
  1462. else
  1463. begin
  1464. { res=0, both are valid }
  1465. if not hp^.invalid then
  1466. inc(cntpd);
  1467. end;
  1468. hp:=hp^.next;
  1469. end;
  1470. end;
  1471. candidates_choose_best:=cntpd;
  1472. end;
  1473. procedure tcallnode.candidates_find_wrong_para(procs:pcandidate);
  1474. var
  1475. currparanr : smallint;
  1476. hp : pcandidate;
  1477. pt : tcallparanode;
  1478. begin
  1479. { Only process the first overloaded procdef }
  1480. hp:=procs;
  1481. { Find callparanode corresponding to the argument }
  1482. pt:=tcallparanode(left);
  1483. currparanr:=paralength;
  1484. while assigned(pt) and
  1485. (currparanr>hp^.wrongparanr) do
  1486. begin
  1487. pt:=tcallparanode(pt.right);
  1488. dec(currparanr);
  1489. end;
  1490. if (currparanr<>hp^.wrongparanr) or
  1491. not assigned(pt) then
  1492. internalerror(200212094);
  1493. { Show error message, when it was a var or out parameter
  1494. guess that it is a missing typeconv }
  1495. if hp^.wrongpara.paratyp in [vs_var,vs_out] then
  1496. CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
  1497. pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename)
  1498. else
  1499. CGMessagePos3(pt.fileinfo,type_e_wrong_parameter_type,
  1500. tostr(hp^.wrongparanr),pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename);
  1501. end;
  1502. function tcallnode.det_resulttype:tnode;
  1503. var
  1504. procs : pcandidate;
  1505. oldcallprocdef : tabstractprocdef;
  1506. hpt : tnode;
  1507. pt : tcallparanode;
  1508. lastpara : longint;
  1509. pdc : tparaitem;
  1510. cand_cnt : integer;
  1511. i : longint;
  1512. is_const : boolean;
  1513. label
  1514. errorexit;
  1515. begin
  1516. result:=nil;
  1517. procs:=nil;
  1518. oldcallprocdef:=aktcallprocdef;
  1519. aktcallprocdef:=nil;
  1520. { determine length of parameter list }
  1521. pt:=tcallparanode(left);
  1522. paralength:=0;
  1523. while assigned(pt) do
  1524. begin
  1525. inc(paralength);
  1526. pt:=tcallparanode(pt.right);
  1527. end;
  1528. { determine the type of the parameters }
  1529. if assigned(left) then
  1530. begin
  1531. tcallparanode(left).get_paratype;
  1532. if codegenerror then
  1533. goto errorexit;
  1534. end;
  1535. { procedure variable ? }
  1536. if assigned(right) then
  1537. begin
  1538. set_varstate(right,true);
  1539. resulttypepass(right);
  1540. if codegenerror then
  1541. exit;
  1542. procdefinition:=tabstractprocdef(right.resulttype.def);
  1543. { check the amount of parameters }
  1544. pdc:=tparaitem(procdefinition.Para.first);
  1545. while assigned(pdc) and (pdc.paratyp=vs_hidden) do
  1546. pdc:=tparaitem(pdc.next);
  1547. pt:=tcallparanode(left);
  1548. lastpara:=paralength;
  1549. while assigned(pdc) and assigned(pt) do
  1550. begin
  1551. { only goto next para if we're out of the varargs }
  1552. if not(po_varargs in procdefinition.procoptions) or
  1553. (lastpara<=procdefinition.maxparacount) then
  1554. begin
  1555. repeat
  1556. pdc:=tparaitem(pdc.next);
  1557. until (not assigned(pdc)) or (pdc.paratyp<>vs_hidden);
  1558. end;
  1559. pt:=tcallparanode(pt.right);
  1560. dec(lastpara);
  1561. end;
  1562. if assigned(pt) or assigned(pdc) then
  1563. begin
  1564. if assigned(pt) then
  1565. aktfilepos:=pt.fileinfo;
  1566. CGMessage(parser_e_wrong_parameter_size);
  1567. end;
  1568. end
  1569. else
  1570. { not a procedure variable }
  1571. begin
  1572. { do we know the procedure to call ? }
  1573. if not(assigned(procdefinition)) then
  1574. begin
  1575. procs:=candidates_find;
  1576. { no procedures found? then there is something wrong
  1577. with the parameter size }
  1578. if not assigned(procs) then
  1579. begin
  1580. { when it's an auto inherited call and there
  1581. is no procedure found, but the procedures
  1582. were defined with overload directive and at
  1583. least two procedures are defined then we ignore
  1584. this inherited by inserting a nothingn. Only
  1585. do this ugly hack in Delphi mode as it looks more
  1586. like a bug. It's also not documented }
  1587. if (m_delphi in aktmodeswitches) and
  1588. (nf_auto_inherited in flags) and
  1589. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1590. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1591. (symtableprocentry.procdef_count>=2) then
  1592. result:=cnothingnode.create
  1593. else
  1594. begin
  1595. { in tp mode we can try to convert to procvar if
  1596. there are no parameters specified. Only try it
  1597. when there is only one proc definition, else the
  1598. loadnode will give a strange error }
  1599. if not(assigned(left)) and
  1600. (m_tp_procvar in aktmodeswitches) and
  1601. (symtableprocentry.procdef_count=1) then
  1602. begin
  1603. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1604. if (symtableprocentry.owner.symtabletype=objectsymtable) and
  1605. assigned(methodpointer) then
  1606. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1607. resulttypepass(hpt);
  1608. result:=hpt;
  1609. end
  1610. else
  1611. begin
  1612. if assigned(left) then
  1613. aktfilepos:=left.fileinfo;
  1614. CGMessage(parser_e_wrong_parameter_size);
  1615. symtableprocentry.write_parameter_lists(nil);
  1616. end;
  1617. end;
  1618. goto errorexit;
  1619. end;
  1620. { Retrieve information about the candidates }
  1621. candidates_get_information(procs);
  1622. {$ifdef EXTDEBUG}
  1623. { Display info when multiple candidates are found }
  1624. if assigned(procs^.next) then
  1625. candidates_dump_info(V_Debug,procs);
  1626. {$endif EXTDEBUG}
  1627. { Choose the best candidate and count the number of
  1628. candidates left }
  1629. cand_cnt:=candidates_choose_best(procs,tprocdef(procdefinition));
  1630. { All parameters are checked, check if there are any
  1631. procedures left }
  1632. if cand_cnt>0 then
  1633. begin
  1634. { Multiple candidates left? }
  1635. if cand_cnt>1 then
  1636. begin
  1637. CGMessage(cg_e_cant_choose_overload_function);
  1638. {$ifdef EXTDEBUG}
  1639. candidates_dump_info(V_Hint,procs);
  1640. {$else}
  1641. candidates_list(procs,false);
  1642. {$endif EXTDEBUG}
  1643. { we'll just use the first candidate to make the
  1644. call }
  1645. end;
  1646. { assign procdefinition }
  1647. if symtableproc=nil then
  1648. symtableproc:=procdefinition.owner;
  1649. { update browser information }
  1650. if make_ref then
  1651. begin
  1652. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1653. inc(tprocdef(procdefinition).refcount);
  1654. if tprocdef(procdefinition).defref=nil then
  1655. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1656. end;
  1657. end
  1658. else
  1659. begin
  1660. { No candidates left, this must be a type error,
  1661. because wrong size is already checked. procdefinition
  1662. is filled with the first (random) definition that is
  1663. found. We use this definition to display a nice error
  1664. message that the wrong type is passed }
  1665. candidates_find_wrong_para(procs);
  1666. candidates_list(procs,true);
  1667. {$ifdef EXTDEBUG}
  1668. candidates_dump_info(V_Hint,procs);
  1669. {$endif EXTDEBUG}
  1670. { We can not proceed, release all procs and exit }
  1671. candidates_free(procs);
  1672. goto errorexit;
  1673. end;
  1674. candidates_free(procs);
  1675. end; { end of procedure to call determination }
  1676. { add needed default parameters }
  1677. if assigned(procdefinition) and
  1678. (paralength<procdefinition.maxparacount) then
  1679. begin
  1680. pdc:=tparaitem(procdefinition.Para.last);
  1681. for i:=1 to paralength do
  1682. pdc:=tparaitem(pdc.previous);
  1683. while assigned(pdc) do
  1684. begin
  1685. if not assigned(pdc.defaultvalue) then
  1686. internalerror(200212142);
  1687. left:=ccallparanode.create(genconstsymtree(tconstsym(pdc.defaultvalue)),left);
  1688. pdc:=tparaitem(pdc.previous);
  1689. end;
  1690. end;
  1691. end;
  1692. { handle predefined procedures }
  1693. is_const:=(po_internconst in procdefinition.procoptions) and
  1694. ((block_type in [bt_const,bt_type]) or
  1695. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1696. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1697. begin
  1698. if assigned(left) then
  1699. begin
  1700. { ptr and settextbuf needs two args }
  1701. if assigned(tcallparanode(left).right) then
  1702. begin
  1703. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1704. left:=nil;
  1705. end
  1706. else
  1707. begin
  1708. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1709. tcallparanode(left).left:=nil;
  1710. end;
  1711. end
  1712. else
  1713. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1714. result:=hpt;
  1715. goto errorexit;
  1716. end;
  1717. { ensure that the result type is set }
  1718. if not restypeset then
  1719. resulttype:=procdefinition.rettype
  1720. else
  1721. resulttype:=restype;
  1722. { modify the exit code, in case of special cases }
  1723. if (not is_void(resulttype.def)) then
  1724. begin
  1725. if paramanager.ret_in_reg(resulttype.def,procdefinition.proccalloption) then
  1726. begin
  1727. { wide- and ansistrings are returned in EAX }
  1728. { but they are imm. moved to a memory location }
  1729. if is_widestring(resulttype.def) or
  1730. is_ansistring(resulttype.def) then
  1731. begin
  1732. { we use ansistrings so no fast exit here }
  1733. if assigned(procinfo) then
  1734. procinfo.no_fast_exit:=true;
  1735. end;
  1736. end;
  1737. end;
  1738. { constructors return their current class type, not the type where the
  1739. constructor is declared, this can be different because of inheritance }
  1740. if (procdefinition.proctypeoption=potype_constructor) then
  1741. begin
  1742. if assigned(methodpointer) and
  1743. assigned(methodpointer.resulttype.def) and
  1744. (methodpointer.resulttype.def.deftype=classrefdef) then
  1745. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype;
  1746. end;
  1747. { flag all callparanodes that belong to the varargs }
  1748. if (po_varargs in procdefinition.procoptions) then
  1749. begin
  1750. pt:=tcallparanode(left);
  1751. i:=paralength;
  1752. while (i>procdefinition.maxparacount) do
  1753. begin
  1754. include(tcallparanode(pt).flags,nf_varargs_para);
  1755. pt:=tcallparanode(pt.right);
  1756. dec(i);
  1757. end;
  1758. end;
  1759. { insert type conversions }
  1760. if assigned(left) then
  1761. begin
  1762. aktcallprocdef:=procdefinition;
  1763. tcallparanode(left).insert_typeconv(tparaitem(procdefinition.Para.first),true);
  1764. end;
  1765. errorexit:
  1766. aktcallprocdef:=oldcallprocdef;
  1767. end;
  1768. function tcallnode.pass_1 : tnode;
  1769. var
  1770. inlinecode : tnode;
  1771. inlined : boolean;
  1772. {$ifdef m68k}
  1773. regi : tregister;
  1774. {$endif}
  1775. method_must_be_valid : boolean;
  1776. label
  1777. errorexit;
  1778. begin
  1779. { the default is nothing to return }
  1780. location.loc:=LOC_INVALID;
  1781. result:=nil;
  1782. inlined:=false;
  1783. inlinecode := nil;
  1784. { work trough all parameters to get the register requirements }
  1785. if assigned(left) then
  1786. tcallparanode(left).det_registers;
  1787. { return node }
  1788. if assigned(funcretrefnode) then
  1789. firstpass(funcretrefnode);
  1790. if assigned(procdefinition) and
  1791. (procdefinition.proccalloption=pocall_inline) then
  1792. begin
  1793. inlinecode:=right;
  1794. if assigned(inlinecode) then
  1795. inlined:=true;
  1796. right:=nil;
  1797. end;
  1798. { procedure variable ? }
  1799. if assigned(right) then
  1800. begin
  1801. firstpass(right);
  1802. { procedure does a call }
  1803. if not (block_type in [bt_const,bt_type]) then
  1804. procinfo.flags:=procinfo.flags or pi_do_call;
  1805. rg.incrementintregisterpushed(all_intregisters);
  1806. rg.incrementotherregisterpushed(all_registers);
  1807. end
  1808. else
  1809. { not a procedure variable }
  1810. begin
  1811. { calc the correture value for the register }
  1812. { handle predefined procedures }
  1813. if (procdefinition.proccalloption=pocall_inline) then
  1814. begin
  1815. if assigned(methodpointer) then
  1816. CGMessage(cg_e_unable_inline_object_methods);
  1817. if assigned(right) and (right.nodetype<>procinlinen) then
  1818. CGMessage(cg_e_unable_inline_procvar);
  1819. if not assigned(inlinecode) then
  1820. begin
  1821. if assigned(tprocdef(procdefinition).code) then
  1822. inlinecode:=cprocinlinenode.create(tprocdef(procdefinition))
  1823. else
  1824. CGMessage(cg_e_no_code_for_inline_stored);
  1825. if assigned(inlinecode) then
  1826. begin
  1827. { consider it has not inlined if called
  1828. again inside the args }
  1829. procdefinition.proccalloption:=pocall_fpccall;
  1830. firstpass(inlinecode);
  1831. inlined:=true;
  1832. end;
  1833. end;
  1834. end
  1835. else
  1836. begin
  1837. if not (block_type in [bt_const,bt_type]) then
  1838. procinfo.flags:=procinfo.flags or pi_do_call;
  1839. end;
  1840. { It doesn't hurt to calculate it already though :) (JM) }
  1841. rg.incrementintregisterpushed(tprocdef(procdefinition).usedintregisters);
  1842. rg.incrementotherregisterpushed(tprocdef(procdefinition).usedotherregisters);
  1843. end;
  1844. { get a register for the return value }
  1845. if (not is_void(resulttype.def)) then
  1846. begin
  1847. { for win32 records returned in EDX:EAX, we
  1848. move them to memory after ... }
  1849. if (resulttype.def.deftype=recorddef) then
  1850. begin
  1851. location.loc:=LOC_CREFERENCE;
  1852. end
  1853. else
  1854. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1855. begin
  1856. location.loc:=LOC_CREFERENCE;
  1857. end
  1858. else
  1859. { ansi/widestrings must be registered, so we can dispose them }
  1860. if is_ansistring(resulttype.def) or
  1861. is_widestring(resulttype.def) then
  1862. begin
  1863. location.loc:=LOC_CREFERENCE;
  1864. registers32:=1;
  1865. end
  1866. else
  1867. { we have only to handle the result if it is used }
  1868. if (nf_return_value_used in flags) then
  1869. begin
  1870. case resulttype.def.deftype of
  1871. enumdef,
  1872. orddef :
  1873. begin
  1874. if (procdefinition.proctypeoption=potype_constructor) then
  1875. begin
  1876. if assigned(methodpointer) and
  1877. (methodpointer.resulttype.def.deftype=classrefdef) then
  1878. begin
  1879. location.loc:=LOC_REGISTER;
  1880. registers32:=1;
  1881. end
  1882. else
  1883. location.loc:=LOC_FLAGS;
  1884. end
  1885. else
  1886. begin
  1887. location.loc:=LOC_REGISTER;
  1888. if is_64bitint(resulttype.def) then
  1889. registers32:=2
  1890. else
  1891. registers32:=1;
  1892. end;
  1893. end;
  1894. floatdef :
  1895. begin
  1896. location.loc:=LOC_FPUREGISTER;
  1897. {$ifdef cpufpemu}
  1898. if (cs_fp_emulation in aktmoduleswitches) then
  1899. registers32:=1
  1900. else
  1901. {$endif cpufpemu}
  1902. {$ifdef m68k}
  1903. if (tfloatdef(resulttype.def).typ=s32real) then
  1904. registers32:=1
  1905. else
  1906. {$endif m68k}
  1907. registersfpu:=1;
  1908. end;
  1909. else
  1910. begin
  1911. location.loc:=LOC_REGISTER;
  1912. registers32:=1;
  1913. end;
  1914. end;
  1915. end;
  1916. end;
  1917. {$ifdef m68k}
  1918. { we need one more address register for virtual calls on m68k }
  1919. if (po_virtualmethod in procdefinition.procoptions) then
  1920. inc(registers32);
  1921. {$endif m68k}
  1922. { a fpu can be used in any procedure !! }
  1923. {$ifdef i386}
  1924. registersfpu:=procdefinition.fpu_used;
  1925. {$endif i386}
  1926. { if this is a call to a method calc the registers }
  1927. if (methodpointer<>nil) then
  1928. begin
  1929. { if we are calling the constructor }
  1930. if procdefinition.proctypeoption in [potype_constructor] then
  1931. verifyabstractcalls;
  1932. case methodpointer.nodetype of
  1933. { but only, if this is not a supporting node }
  1934. typen: ;
  1935. { we need one register for new return value PM }
  1936. hnewn : if registers32=0 then
  1937. registers32:=1;
  1938. else
  1939. begin
  1940. if (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1941. assigned(symtableproc) and (symtableproc.symtabletype=withsymtable) and
  1942. not twithsymtable(symtableproc).direct_with then
  1943. begin
  1944. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1945. end; { Is accepted by Delphi !! }
  1946. { this is not a good reason to accept it in FPC if we produce
  1947. wrong code for it !!! (PM) }
  1948. { R.Assign is not a constructor !!! }
  1949. { but for R^.Assign, R must be valid !! }
  1950. if (procdefinition.proctypeoption=potype_constructor) or
  1951. ((methodpointer.nodetype=loadn) and
  1952. ((methodpointer.resulttype.def.deftype=classrefdef) or
  1953. ((methodpointer.resulttype.def.deftype=objectdef) and
  1954. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1955. )
  1956. )
  1957. ) then
  1958. method_must_be_valid:=false
  1959. else
  1960. method_must_be_valid:=true;
  1961. firstpass(methodpointer);
  1962. set_varstate(methodpointer,method_must_be_valid);
  1963. { The object is already used ven if it is called once }
  1964. if (methodpointer.nodetype=loadn) and
  1965. (tloadnode(methodpointer).symtableentry.typ=varsym) then
  1966. tvarsym(tloadnode(methodpointer).symtableentry).varstate:=vs_used;
  1967. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1968. registers32:=max(methodpointer.registers32,registers32);
  1969. {$ifdef SUPPORT_MMX }
  1970. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1971. {$endif SUPPORT_MMX}
  1972. end;
  1973. end;
  1974. end;
  1975. if inlined then
  1976. right:=inlinecode;
  1977. { determine the registers of the procedure variable }
  1978. { is this OK for inlined procs also ?? (PM) }
  1979. if assigned(right) then
  1980. begin
  1981. registersfpu:=max(right.registersfpu,registersfpu);
  1982. registers32:=max(right.registers32,registers32);
  1983. {$ifdef SUPPORT_MMX}
  1984. registersmmx:=max(right.registersmmx,registersmmx);
  1985. {$endif SUPPORT_MMX}
  1986. end;
  1987. { determine the registers of the procedure }
  1988. if assigned(left) then
  1989. begin
  1990. registersfpu:=max(left.registersfpu,registersfpu);
  1991. registers32:=max(left.registers32,registers32);
  1992. {$ifdef SUPPORT_MMX}
  1993. registersmmx:=max(left.registersmmx,registersmmx);
  1994. {$endif SUPPORT_MMX}
  1995. end;
  1996. errorexit:
  1997. if inlined then
  1998. procdefinition.proccalloption:=pocall_inline;
  1999. end;
  2000. {$ifdef state_tracking}
  2001. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  2002. var hp:Tcallparanode;
  2003. value:Tnode;
  2004. begin
  2005. track_state_pass:=false;
  2006. hp:=Tcallparanode(left);
  2007. while assigned(hp) do
  2008. begin
  2009. if left.track_state_pass(exec_known) then
  2010. begin
  2011. left.resulttype.def:=nil;
  2012. do_resulttypepass(left);
  2013. end;
  2014. value:=aktstate.find_fact(hp.left);
  2015. if value<>nil then
  2016. begin
  2017. track_state_pass:=true;
  2018. hp.left.destroy;
  2019. hp.left:=value.getcopy;
  2020. do_resulttypepass(hp.left);
  2021. end;
  2022. hp:=Tcallparanode(hp.right);
  2023. end;
  2024. end;
  2025. {$endif}
  2026. function tcallnode.docompare(p: tnode): boolean;
  2027. begin
  2028. docompare :=
  2029. inherited docompare(p) and
  2030. (symtableprocentry = tcallnode(p).symtableprocentry) and
  2031. (procdefinition = tcallnode(p).procdefinition) and
  2032. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  2033. ((restypeset and tcallnode(p).restypeset and
  2034. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  2035. (not restypeset and not tcallnode(p).restypeset));
  2036. end;
  2037. {****************************************************************************
  2038. TPROCINLINENODE
  2039. ****************************************************************************}
  2040. constructor tprocinlinenode.create(p:tprocdef);
  2041. begin
  2042. inherited create(procinlinen);
  2043. inlineprocdef:=p;
  2044. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2045. para_offset:=0;
  2046. para_size:=0;
  2047. { copy inlinetree }
  2048. if assigned(p.code) then
  2049. inlinetree:=p.code.getcopy
  2050. else
  2051. inlinetree:=nil;
  2052. end;
  2053. destructor tprocinlinenode.destroy;
  2054. begin
  2055. if assigned(inlinetree) then
  2056. inlinetree.free;
  2057. inherited destroy;
  2058. end;
  2059. constructor tprocinlinenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  2060. begin
  2061. inherited ppuload(t,ppufile);
  2062. inlineprocdef:=tprocdef(ppufile.getderef);
  2063. inlinetree:=ppuloadnode(ppufile);
  2064. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2065. para_offset:=0;
  2066. para_size:=0;
  2067. end;
  2068. procedure tprocinlinenode.ppuwrite(ppufile:tcompilerppufile);
  2069. begin
  2070. inherited ppuwrite(ppufile);
  2071. ppufile.putderef(inlineprocdef);
  2072. ppuwritenode(ppufile,inlinetree);
  2073. end;
  2074. procedure tprocinlinenode.derefimpl;
  2075. begin
  2076. inherited derefimpl;
  2077. if assigned(inlinetree) then
  2078. inlinetree.derefimpl;
  2079. resolvedef(pointer(inlineprocdef));
  2080. end;
  2081. function tprocinlinenode.getcopy : tnode;
  2082. var
  2083. n : tprocinlinenode;
  2084. begin
  2085. n:=tprocinlinenode(inherited getcopy);
  2086. n.inlineprocdef:=inlineprocdef;
  2087. if assigned(inlinetree) then
  2088. n.inlinetree:=inlinetree.getcopy
  2089. else
  2090. n.inlinetree:=nil;
  2091. n.retoffset:=retoffset;
  2092. n.para_offset:=para_offset;
  2093. n.para_size:=para_size;
  2094. getcopy:=n;
  2095. end;
  2096. procedure tprocinlinenode.insertintolist(l : tnodelist);
  2097. begin
  2098. end;
  2099. function tprocinlinenode.det_resulttype : tnode;
  2100. var
  2101. storesymtablelevel : longint;
  2102. storeparasymtable,
  2103. storelocalsymtable : tsymtabletype;
  2104. oldprocdef : tprocdef;
  2105. oldprocinfo : tprocinfo;
  2106. oldinlining_procedure : boolean;
  2107. begin
  2108. result:=nil;
  2109. oldinlining_procedure:=inlining_procedure;
  2110. oldprocdef:=aktprocdef;
  2111. oldprocinfo:=procinfo;
  2112. { we're inlining a procedure }
  2113. inlining_procedure:=true;
  2114. aktprocdef:=inlineprocdef;
  2115. { clone procinfo, but not the asmlists }
  2116. procinfo:=tprocinfo(cprocinfo.newinstance);
  2117. move(pointer(oldprocinfo)^,pointer(procinfo)^,cprocinfo.InstanceSize);
  2118. procinfo.aktentrycode:=nil;
  2119. procinfo.aktexitcode:=nil;
  2120. procinfo.aktproccode:=nil;
  2121. procinfo.aktlocaldata:=nil;
  2122. { set new procinfo }
  2123. procinfo.return_offset:=retoffset;
  2124. procinfo.para_offset:=para_offset;
  2125. procinfo.no_fast_exit:=false;
  2126. { set it to the same lexical level }
  2127. storesymtablelevel:=aktprocdef.localst.symtablelevel;
  2128. storelocalsymtable:=aktprocdef.localst.symtabletype;
  2129. storeparasymtable:=aktprocdef.parast.symtabletype;
  2130. aktprocdef.localst.symtablelevel:=oldprocdef.localst.symtablelevel;
  2131. aktprocdef.localst.symtabletype:=inlinelocalsymtable;
  2132. aktprocdef.parast.symtabletype:=inlineparasymtable;
  2133. { pass inlinetree }
  2134. resulttypepass(inlinetree);
  2135. resulttype:=inlineprocdef.rettype;
  2136. { retrieve info from inlineprocdef }
  2137. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2138. para_offset:=0;
  2139. para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
  2140. if paramanager.ret_in_param(inlineprocdef.rettype.def,inlineprocdef.proccalloption) then
  2141. inc(para_size,POINTER_SIZE);
  2142. { restore procinfo }
  2143. procinfo.free;
  2144. procinfo:=oldprocinfo;
  2145. { restore symtable }
  2146. aktprocdef.localst.symtablelevel:=storesymtablelevel;
  2147. aktprocdef.localst.symtabletype:=storelocalsymtable;
  2148. aktprocdef.parast.symtabletype:=storeparasymtable;
  2149. { restore }
  2150. aktprocdef:=oldprocdef;
  2151. inlining_procedure:=oldinlining_procedure;
  2152. end;
  2153. function tprocinlinenode.pass_1 : tnode;
  2154. begin
  2155. firstpass(inlinetree);
  2156. registers32:=inlinetree.registers32;
  2157. registersfpu:=inlinetree.registersfpu;
  2158. {$ifdef SUPPORT_MMX}
  2159. registersmmx:=inlinetree.registersmmx;
  2160. {$endif SUPPORT_MMX}
  2161. result:=nil;
  2162. end;
  2163. function tprocinlinenode.docompare(p: tnode): boolean;
  2164. begin
  2165. docompare :=
  2166. inherited docompare(p) and
  2167. inlinetree.isequal(tprocinlinenode(p).inlinetree) and
  2168. (inlineprocdef = tprocinlinenode(p).inlineprocdef);
  2169. end;
  2170. begin
  2171. ccallnode:=tcallnode;
  2172. ccallparanode:=tcallparanode;
  2173. cprocinlinenode:=tprocinlinenode;
  2174. end.
  2175. {
  2176. $Log$
  2177. Revision 1.129 2003-03-17 15:54:22 peter
  2178. * store symoptions also for procdef
  2179. * check symoptions (private,public) when calculating possible
  2180. overload candidates
  2181. Revision 1.128 2003/02/19 22:00:14 daniel
  2182. * Code generator converted to new register notation
  2183. - Horribily outdated todo.txt removed
  2184. Revision 1.127 2003/01/16 22:13:52 peter
  2185. * convert_l3 convertlevel added. This level is used for conversions
  2186. where information can be lost like converting widestring->ansistring
  2187. or dword->byte
  2188. Revision 1.126 2003/01/15 01:44:32 peter
  2189. * merged methodpointer fixes from 1.0.x
  2190. Revision 1.125 2003/01/12 17:52:07 peter
  2191. * only check for auto inherited in objectsymtable
  2192. Revision 1.124 2003/01/09 21:45:46 peter
  2193. * extended information about overloaded candidates when compiled
  2194. with EXTDEBUG
  2195. Revision 1.123 2002/12/26 18:24:33 jonas
  2196. * fixed check for whether or not a high parameter was already generated
  2197. * no type checking/conversions for invisible parameters
  2198. Revision 1.122 2002/12/15 22:50:00 florian
  2199. + some stuff for the new hidden parameter handling added
  2200. Revision 1.121 2002/12/15 21:34:15 peter
  2201. * give sign difference between ordinals a small penalty. This is
  2202. needed to get word->[longword|longint] working
  2203. Revision 1.120 2002/12/15 21:30:12 florian
  2204. * tcallnode.paraitem introduced, all references to defcoll removed
  2205. Revision 1.119 2002/12/15 20:59:58 peter
  2206. * fix crash with default parameters
  2207. Revision 1.118 2002/12/15 11:26:02 peter
  2208. * ignore vs_hidden parameters when choosing overloaded proc
  2209. Revision 1.117 2002/12/11 22:42:28 peter
  2210. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2211. the old code. The new code collects the information about possible
  2212. candidates only once resultting in much less calls to type compare
  2213. routines
  2214. Revision 1.116 2002/12/07 14:27:07 carl
  2215. * 3% memory optimization
  2216. * changed some types
  2217. + added type checking with different size for call node and for
  2218. parameters
  2219. Revision 1.115 2002/12/06 17:51:10 peter
  2220. * merged cdecl and array fixes
  2221. Revision 1.114 2002/12/06 16:56:58 peter
  2222. * only compile cs_fp_emulation support when cpufpuemu is defined
  2223. * define cpufpuemu for m68k only
  2224. Revision 1.113 2002/11/27 20:04:38 peter
  2225. * cdecl array of const fixes
  2226. Revision 1.112 2002/11/27 15:33:46 peter
  2227. * the never ending story of tp procvar hacks
  2228. Revision 1.111 2002/11/27 02:31:17 peter
  2229. * fixed inlinetree parsing in det_resulttype
  2230. Revision 1.110 2002/11/25 18:43:32 carl
  2231. - removed the invalid if <> checking (Delphi is strange on this)
  2232. + implemented abstract warning on instance creation of class with
  2233. abstract methods.
  2234. * some error message cleanups
  2235. Revision 1.109 2002/11/25 17:43:17 peter
  2236. * splitted defbase in defutil,symutil,defcmp
  2237. * merged isconvertable and is_equal into compare_defs(_ext)
  2238. * made operator search faster by walking the list only once
  2239. Revision 1.108 2002/11/18 17:31:54 peter
  2240. * pass proccalloption to ret_in_xxx and push_xxx functions
  2241. Revision 1.107 2002/11/15 01:58:50 peter
  2242. * merged changes from 1.0.7 up to 04-11
  2243. - -V option for generating bug report tracing
  2244. - more tracing for option parsing
  2245. - errors for cdecl and high()
  2246. - win32 import stabs
  2247. - win32 records<=8 are returned in eax:edx (turned off by default)
  2248. - heaptrc update
  2249. - more info for temp management in .s file with EXTDEBUG
  2250. Revision 1.106 2002/10/14 18:20:30 carl
  2251. * var parameter checking for classes and interfaces in Delphi mode
  2252. Revision 1.105 2002/10/06 21:02:17 peter
  2253. * fixed limit checking for qword
  2254. Revision 1.104 2002/10/05 15:15:45 peter
  2255. * Write unknwon compiler proc using Comment and only in Extdebug
  2256. Revision 1.103 2002/10/05 12:43:25 carl
  2257. * fixes for Delphi 6 compilation
  2258. (warning : Some features do not work under Delphi)
  2259. Revision 1.102 2002/10/05 00:48:57 peter
  2260. * support inherited; support for overload as it is handled by
  2261. delphi. This is only for delphi mode as it is working is
  2262. undocumented and hard to predict what is done
  2263. Revision 1.101 2002/09/16 14:11:12 peter
  2264. * add argument to equal_paras() to support default values or not
  2265. Revision 1.100 2002/09/15 17:49:59 peter
  2266. * don't have strict var parameter checking for procedures in the
  2267. system unit
  2268. Revision 1.99 2002/09/09 19:30:34 peter
  2269. * don't allow convertable parameters for var and out parameters in
  2270. delphi and tp mode
  2271. Revision 1.98 2002/09/07 15:25:02 peter
  2272. * old logs removed and tabs fixed
  2273. Revision 1.97 2002/09/07 12:16:05 carl
  2274. * second part bug report 1996 fix, testrange in cordconstnode
  2275. only called if option is set (also make parsing a tiny faster)
  2276. Revision 1.96 2002/09/05 14:53:41 peter
  2277. * fixed old callnode.det_resulttype code
  2278. * old ncal code is default again
  2279. Revision 1.95 2002/09/03 21:32:49 daniel
  2280. * Small bugfix for procdef selection
  2281. Revision 1.94 2002/09/03 19:27:22 daniel
  2282. * Activated new ncal code
  2283. Revision 1.93 2002/09/03 16:26:26 daniel
  2284. * Make Tprocdef.defs protected
  2285. Revision 1.92 2002/09/01 13:28:37 daniel
  2286. - write_access fields removed in favor of a flag
  2287. Revision 1.91 2002/09/01 12:14:15 peter
  2288. * remove debug line
  2289. * containself methods can be called directly
  2290. Revision 1.90 2002/09/01 08:01:16 daniel
  2291. * Removed sets from Tcallnode.det_resulttype
  2292. + Added read/write notifications of variables. These will be usefull
  2293. for providing information for several optimizations. For example
  2294. the value of the loop variable of a for loop does matter is the
  2295. variable is read after the for loop, but if it's no longer used
  2296. or written, it doesn't matter and this can be used to optimize
  2297. the loop code generation.
  2298. Revision 1.89 2002/08/23 16:13:16 peter
  2299. * also firstpass funcretrefnode if available. This was breaking the
  2300. asnode compilerproc code
  2301. Revision 1.88 2002/08/20 10:31:26 daniel
  2302. * Tcallnode.det_resulttype rewritten
  2303. Revision 1.87 2002/08/19 19:36:42 peter
  2304. * More fixes for cross unit inlining, all tnodes are now implemented
  2305. * Moved pocall_internconst to po_internconst because it is not a
  2306. calling type at all and it conflicted when inlining of these small
  2307. functions was requested
  2308. Revision 1.86 2002/08/17 22:09:44 florian
  2309. * result type handling in tcgcal.pass_2 overhauled
  2310. * better tnode.dowrite
  2311. * some ppc stuff fixed
  2312. Revision 1.85 2002/08/17 09:23:34 florian
  2313. * first part of procinfo rewrite
  2314. Revision 1.84 2002/08/16 14:24:57 carl
  2315. * issameref() to test if two references are the same (then emit no opcodes)
  2316. + ret_in_reg to replace ret_in_acc
  2317. (fix some register allocation bugs at the same time)
  2318. + save_std_register now has an extra parameter which is the
  2319. usedinproc registers
  2320. Revision 1.83 2002/07/20 11:57:53 florian
  2321. * types.pas renamed to defbase.pas because D6 contains a types
  2322. unit so this would conflicts if D6 programms are compiled
  2323. + Willamette/SSE2 instructions to assembler added
  2324. Revision 1.82 2002/07/19 11:41:35 daniel
  2325. * State tracker work
  2326. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2327. allows the state tracker to change while nodes automatically into
  2328. repeat nodes.
  2329. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2330. 'not(a>b)' is optimized into 'a<=b'.
  2331. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2332. by removing the notn and later switchting the true and falselabels. The
  2333. same is done with 'repeat until not a'.
  2334. Revision 1.81 2002/07/15 18:03:14 florian
  2335. * readded removed changes
  2336. Revision 1.79 2002/07/11 14:41:27 florian
  2337. * start of the new generic parameter handling
  2338. Revision 1.80 2002/07/14 18:00:43 daniel
  2339. + Added the beginning of a state tracker. This will track the values of
  2340. variables through procedures and optimize things away.
  2341. Revision 1.78 2002/07/04 20:43:00 florian
  2342. * first x86-64 patches
  2343. }