ncal.pas 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602
  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. { only when the # of parameter are supported by the
  1125. procedure }
  1126. if (paralength>=pd.minparacount) and
  1127. ((po_varargs in pd.procoptions) or { varargs }
  1128. (paralength<=pd.maxparacount)) then
  1129. proc_add(pd);
  1130. end;
  1131. { remember if the procedure is declared with the overload directive,
  1132. it's information is still needed also after all procs are removed }
  1133. has_overload_directive:=(po_overload in symtableprocentry.first_procdef.procoptions);
  1134. { when the definition has overload directive set, we search for
  1135. overloaded definitions in the symtablestack. The found
  1136. entries are only added to the procs list and not the procsym, because
  1137. the list can change in every situation }
  1138. if has_overload_directive and
  1139. (symtableprocentry.owner.symtabletype<>objectsymtable) then
  1140. begin
  1141. srsymtable:=symtableprocentry.owner.next;
  1142. while assigned(srsymtable) do
  1143. begin
  1144. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1145. begin
  1146. srprocsym:=tprocsym(srsymtable.speedsearch(symtableprocentry.name,symtableprocentry.speedvalue));
  1147. { process only visible procsyms }
  1148. if assigned(srprocsym) and
  1149. (srprocsym.typ=procsym) and
  1150. srprocsym.is_visible_for_proc(aktprocdef) then
  1151. begin
  1152. { if this procedure doesn't have overload we can stop
  1153. searching }
  1154. if not(po_overload in srprocsym.first_procdef.procoptions) then
  1155. break;
  1156. { process all overloaded definitions }
  1157. for j:=1 to srprocsym.procdef_count do
  1158. begin
  1159. pd:=srprocsym.procdef[j];
  1160. { only when the # of parameter are supported by the
  1161. procedure }
  1162. if (paralength>=pd.minparacount) and
  1163. ((po_varargs in pd.procoptions) or { varargs }
  1164. (paralength<=pd.maxparacount)) then
  1165. begin
  1166. found:=false;
  1167. hp:=procs;
  1168. while assigned(hp) do
  1169. begin
  1170. if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,false)>=te_equal then
  1171. begin
  1172. found:=true;
  1173. break;
  1174. end;
  1175. hp:=hp^.next;
  1176. end;
  1177. if not found then
  1178. proc_add(pd);
  1179. end;
  1180. end;
  1181. end;
  1182. end;
  1183. srsymtable:=srsymtable.next;
  1184. end;
  1185. end;
  1186. candidates_find:=procs;
  1187. end;
  1188. procedure tcallnode.candidates_free(procs:pcandidate);
  1189. var
  1190. hpnext,
  1191. hp : pcandidate;
  1192. begin
  1193. hp:=procs;
  1194. while assigned(hp) do
  1195. begin
  1196. hpnext:=hp^.next;
  1197. dispose(hp);
  1198. hp:=hpnext;
  1199. end;
  1200. end;
  1201. procedure tcallnode.candidates_list(procs:pcandidate;all:boolean);
  1202. var
  1203. hp : pcandidate;
  1204. begin
  1205. hp:=procs;
  1206. while assigned(hp) do
  1207. begin
  1208. if all or
  1209. (not hp^.invalid) then
  1210. MessagePos1(hp^.data.fileinfo,sym_h_param_list,hp^.data.fullprocname);
  1211. hp:=hp^.next;
  1212. end;
  1213. end;
  1214. {$ifdef EXTDEBUG}
  1215. procedure Tcallnode.candidates_dump_info(lvl:longint;procs:pcandidate);
  1216. function ParaTreeStr(p:tcallparanode):string;
  1217. begin
  1218. result:='';
  1219. while assigned(p) do
  1220. begin
  1221. if result<>'' then
  1222. result:=result+',';
  1223. result:=result+p.resulttype.def.typename;
  1224. p:=tcallparanode(p.right);
  1225. end;
  1226. end;
  1227. var
  1228. hp : pcandidate;
  1229. currpara : tparaitem;
  1230. begin
  1231. if not CheckVerbosity(lvl) then
  1232. exit;
  1233. Comment(lvl+V_LineInfo,'Overloaded callnode: '+symtableprocentry.name+'('+ParaTreeStr(tcallparanode(left))+')');
  1234. hp:=procs;
  1235. while assigned(hp) do
  1236. begin
  1237. Comment(lvl,' '+hp^.data.fullprocname);
  1238. if (hp^.invalid) then
  1239. Comment(lvl,' invalid')
  1240. else
  1241. begin
  1242. Comment(lvl,' ex: '+tostr(hp^.exact_count)+
  1243. ' eq: '+tostr(hp^.equal_count)+
  1244. ' l1: '+tostr(hp^.cl1_count)+
  1245. ' l2: '+tostr(hp^.cl2_count)+
  1246. ' l3: '+tostr(hp^.cl3_count)+
  1247. ' oper: '+tostr(hp^.coper_count)+
  1248. ' ord: '+realtostr(hp^.exact_count));
  1249. { Print parameters in left-right order }
  1250. currpara:=hp^.firstpara;
  1251. if assigned(currpara) then
  1252. begin
  1253. while assigned(currpara.next) do
  1254. currpara:=tparaitem(currpara.next);
  1255. end;
  1256. while assigned(currpara) do
  1257. begin
  1258. if (currpara.paratyp<>vs_hidden) then
  1259. Comment(lvl,' - '+currpara.paratype.def.typename+' : '+EqualTypeName[currpara.eqval]);
  1260. currpara:=tparaitem(currpara.previous);
  1261. end;
  1262. end;
  1263. hp:=hp^.next;
  1264. end;
  1265. end;
  1266. {$endif EXTDEBUG}
  1267. procedure Tcallnode.candidates_get_information(procs:pcandidate);
  1268. var
  1269. hp : pcandidate;
  1270. currpara : tparaitem;
  1271. currparanr : byte;
  1272. def_from,
  1273. def_to : tdef;
  1274. pt : tcallparanode;
  1275. eq : tequaltype;
  1276. convtype : tconverttype;
  1277. pdoper : tprocdef;
  1278. begin
  1279. { process all procs }
  1280. hp:=procs;
  1281. while assigned(hp) do
  1282. begin
  1283. { Setup first parameter to compare }
  1284. currparanr:=paralength;
  1285. currpara:=hp^.firstpara;
  1286. while assigned(currpara) and (currpara.paratyp=vs_hidden) do
  1287. currpara:=tparaitem(currpara.next);
  1288. pt:=tcallparanode(left);
  1289. while assigned(pt) and assigned(currpara) do
  1290. begin
  1291. { retrieve current parameter definitions to compares }
  1292. eq:=te_incompatible;
  1293. def_from:=pt.resulttype.def;
  1294. def_to:=currpara.paratype.def;
  1295. if not(assigned(def_from)) then
  1296. internalerror(200212091);
  1297. if not(
  1298. assigned(def_to) or
  1299. ((po_varargs in hp^.data.procoptions) and
  1300. (currparanr>hp^.data.minparacount))
  1301. ) then
  1302. internalerror(200212092);
  1303. { varargs are always equal, but not exact }
  1304. if (po_varargs in hp^.data.procoptions) and
  1305. (currparanr>hp^.data.minparacount) then
  1306. begin
  1307. inc(hp^.equal_count);
  1308. eq:=te_equal;
  1309. end
  1310. else
  1311. { same definition -> exact }
  1312. if (def_from=def_to) then
  1313. begin
  1314. inc(hp^.exact_count);
  1315. eq:=te_exact;
  1316. end
  1317. else
  1318. { for value and const parameters check if a integer is constant or
  1319. included in other integer -> equal and calc ordinal_distance }
  1320. if not(currpara.paratyp in [vs_var,vs_out]) and
  1321. is_integer(def_from) and
  1322. is_integer(def_to) and
  1323. is_in_limit(def_from,def_to) then
  1324. begin
  1325. inc(hp^.equal_count);
  1326. eq:=te_equal;
  1327. hp^.ordinal_distance:=hp^.ordinal_distance+
  1328. abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
  1329. hp^.ordinal_distance:=hp^.ordinal_distance+
  1330. abs(bestreal(torddef(def_to).high)-bestreal(torddef(def_from).high));
  1331. { Give wrong sign a small penalty, this is need to get a diffrence
  1332. from word->[longword,longint] }
  1333. if is_signed(def_from)<>is_signed(def_to) then
  1334. hp^.ordinal_distance:=hp^.ordinal_distance+1.0;
  1335. end
  1336. else
  1337. { generic type comparision }
  1338. begin
  1339. eq:=compare_defs_ext(def_from,def_to,pt.left.nodetype,
  1340. false,true,convtype,pdoper);
  1341. { when the types are not equal we need to check
  1342. some special case for parameter passing }
  1343. if (eq<te_equal) then
  1344. begin
  1345. if currpara.paratyp in [vs_var,vs_out] then
  1346. begin
  1347. { para requires an equal type so the previous found
  1348. match was not good enough, reset to incompatible }
  1349. eq:=te_incompatible;
  1350. { var_para_allowed will return te_equal and te_convert_l1 to
  1351. make a difference for best matching }
  1352. var_para_allowed(eq,pt.resulttype.def,currpara.paratype.def)
  1353. end
  1354. else
  1355. para_allowed(eq,pt,def_to);
  1356. end;
  1357. case eq of
  1358. te_exact :
  1359. internalerror(200212071); { already checked }
  1360. te_equal :
  1361. inc(hp^.equal_count);
  1362. te_convert_l1 :
  1363. inc(hp^.cl1_count);
  1364. te_convert_l2 :
  1365. inc(hp^.cl2_count);
  1366. te_convert_l3 :
  1367. inc(hp^.cl3_count);
  1368. te_convert_operator :
  1369. inc(hp^.coper_count);
  1370. te_incompatible :
  1371. hp^.invalid:=true;
  1372. else
  1373. internalerror(200212072);
  1374. end;
  1375. end;
  1376. { stop checking when an incompatible parameter is found }
  1377. if hp^.invalid then
  1378. begin
  1379. { store the current parameter info for
  1380. a nice error message when no procedure is found }
  1381. hp^.wrongpara:=currpara;
  1382. hp^.wrongparanr:=currparanr;
  1383. break;
  1384. end;
  1385. {$ifdef EXTDEBUG}
  1386. { store equal in node tree for dump }
  1387. currpara.eqval:=eq;
  1388. {$endif EXTDEBUG}
  1389. { next parameter in the call tree }
  1390. pt:=tcallparanode(pt.right);
  1391. { next parameter for definition, only goto next para
  1392. if we're out of the varargs }
  1393. if not(po_varargs in hp^.data.procoptions) or
  1394. (currparanr<=hp^.data.maxparacount) then
  1395. begin
  1396. { Ignore vs_hidden parameters }
  1397. repeat
  1398. currpara:=tparaitem(currpara.next);
  1399. until (not assigned(currpara)) or (currpara.paratyp<>vs_hidden);
  1400. end;
  1401. dec(currparanr);
  1402. end;
  1403. if not(hp^.invalid) and
  1404. (assigned(pt) or assigned(currpara) or (currparanr<>0)) then
  1405. internalerror(200212141);
  1406. { next candidate }
  1407. hp:=hp^.next;
  1408. end;
  1409. end;
  1410. function Tcallnode.candidates_choose_best(procs:pcandidate;var bestpd:tprocdef):integer;
  1411. var
  1412. besthpstart,
  1413. hp : pcandidate;
  1414. cntpd,
  1415. res : integer;
  1416. begin
  1417. {
  1418. Returns the number of candidates left and the
  1419. first candidate is returned in pdbest
  1420. }
  1421. { Setup the first procdef as best, only count it as a result
  1422. when it is valid }
  1423. bestpd:=procs^.data;
  1424. if procs^.invalid then
  1425. cntpd:=0
  1426. else
  1427. cntpd:=1;
  1428. if assigned(procs^.next) then
  1429. begin
  1430. besthpstart:=procs;
  1431. hp:=procs^.next;
  1432. while assigned(hp) do
  1433. begin
  1434. res:=is_better_candidate(hp,besthpstart);
  1435. if (res>0) then
  1436. begin
  1437. { hp is better, flag all procs to be incompatible }
  1438. while (besthpstart<>hp) do
  1439. begin
  1440. besthpstart^.invalid:=true;
  1441. besthpstart:=besthpstart^.next;
  1442. end;
  1443. { besthpstart is already set to hp }
  1444. bestpd:=besthpstart^.data;
  1445. cntpd:=1;
  1446. end
  1447. else
  1448. if (res<0) then
  1449. begin
  1450. { besthpstart is better, flag current hp to be incompatible }
  1451. hp^.invalid:=true;
  1452. end
  1453. else
  1454. begin
  1455. { res=0, both are valid }
  1456. if not hp^.invalid then
  1457. inc(cntpd);
  1458. end;
  1459. hp:=hp^.next;
  1460. end;
  1461. end;
  1462. candidates_choose_best:=cntpd;
  1463. end;
  1464. procedure tcallnode.candidates_find_wrong_para(procs:pcandidate);
  1465. var
  1466. currparanr : smallint;
  1467. hp : pcandidate;
  1468. pt : tcallparanode;
  1469. begin
  1470. { Only process the first overloaded procdef }
  1471. hp:=procs;
  1472. { Find callparanode corresponding to the argument }
  1473. pt:=tcallparanode(left);
  1474. currparanr:=paralength;
  1475. while assigned(pt) and
  1476. (currparanr>hp^.wrongparanr) do
  1477. begin
  1478. pt:=tcallparanode(pt.right);
  1479. dec(currparanr);
  1480. end;
  1481. if (currparanr<>hp^.wrongparanr) or
  1482. not assigned(pt) then
  1483. internalerror(200212094);
  1484. { Show error message, when it was a var or out parameter
  1485. guess that it is a missing typeconv }
  1486. if hp^.wrongpara.paratyp in [vs_var,vs_out] then
  1487. CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
  1488. pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename)
  1489. else
  1490. CGMessagePos3(pt.fileinfo,type_e_wrong_parameter_type,
  1491. tostr(hp^.wrongparanr),pt.resulttype.def.typename,hp^.wrongpara.paratype.def.typename);
  1492. end;
  1493. function tcallnode.det_resulttype:tnode;
  1494. var
  1495. procs : pcandidate;
  1496. oldcallprocdef : tabstractprocdef;
  1497. hpt : tnode;
  1498. pt : tcallparanode;
  1499. lastpara : longint;
  1500. pdc : tparaitem;
  1501. cand_cnt : integer;
  1502. i : longint;
  1503. is_const : boolean;
  1504. label
  1505. errorexit;
  1506. begin
  1507. result:=nil;
  1508. procs:=nil;
  1509. oldcallprocdef:=aktcallprocdef;
  1510. aktcallprocdef:=nil;
  1511. { determine length of parameter list }
  1512. pt:=tcallparanode(left);
  1513. paralength:=0;
  1514. while assigned(pt) do
  1515. begin
  1516. inc(paralength);
  1517. pt:=tcallparanode(pt.right);
  1518. end;
  1519. { determine the type of the parameters }
  1520. if assigned(left) then
  1521. begin
  1522. tcallparanode(left).get_paratype;
  1523. if codegenerror then
  1524. goto errorexit;
  1525. end;
  1526. { procedure variable ? }
  1527. if assigned(right) then
  1528. begin
  1529. set_varstate(right,true);
  1530. resulttypepass(right);
  1531. if codegenerror then
  1532. exit;
  1533. procdefinition:=tabstractprocdef(right.resulttype.def);
  1534. { check the amount of parameters }
  1535. pdc:=tparaitem(procdefinition.Para.first);
  1536. while assigned(pdc) and (pdc.paratyp=vs_hidden) do
  1537. pdc:=tparaitem(pdc.next);
  1538. pt:=tcallparanode(left);
  1539. lastpara:=paralength;
  1540. while assigned(pdc) and assigned(pt) do
  1541. begin
  1542. { only goto next para if we're out of the varargs }
  1543. if not(po_varargs in procdefinition.procoptions) or
  1544. (lastpara<=procdefinition.maxparacount) then
  1545. begin
  1546. repeat
  1547. pdc:=tparaitem(pdc.next);
  1548. until (not assigned(pdc)) or (pdc.paratyp<>vs_hidden);
  1549. end;
  1550. pt:=tcallparanode(pt.right);
  1551. dec(lastpara);
  1552. end;
  1553. if assigned(pt) or assigned(pdc) then
  1554. begin
  1555. if assigned(pt) then
  1556. aktfilepos:=pt.fileinfo;
  1557. CGMessage(parser_e_wrong_parameter_size);
  1558. end;
  1559. end
  1560. else
  1561. { not a procedure variable }
  1562. begin
  1563. { do we know the procedure to call ? }
  1564. if not(assigned(procdefinition)) then
  1565. begin
  1566. procs:=candidates_find;
  1567. { no procedures found? then there is something wrong
  1568. with the parameter size }
  1569. if not assigned(procs) then
  1570. begin
  1571. { when it's an auto inherited call and there
  1572. is no procedure found, but the procedures
  1573. were defined with overload directive and at
  1574. least two procedures are defined then we ignore
  1575. this inherited by inserting a nothingn. Only
  1576. do this ugly hack in Delphi mode as it looks more
  1577. like a bug. It's also not documented }
  1578. if (m_delphi in aktmodeswitches) and
  1579. (nf_auto_inherited in flags) and
  1580. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1581. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1582. (symtableprocentry.procdef_count>=2) then
  1583. result:=cnothingnode.create
  1584. else
  1585. begin
  1586. { in tp mode we can try to convert to procvar if
  1587. there are no parameters specified. Only try it
  1588. when there is only one proc definition, else the
  1589. loadnode will give a strange error }
  1590. if not(assigned(left)) and
  1591. (m_tp_procvar in aktmodeswitches) and
  1592. (symtableprocentry.procdef_count=1) then
  1593. begin
  1594. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1595. if (symtableprocentry.owner.symtabletype=objectsymtable) and
  1596. assigned(methodpointer) then
  1597. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1598. resulttypepass(hpt);
  1599. result:=hpt;
  1600. end
  1601. else
  1602. begin
  1603. if assigned(left) then
  1604. aktfilepos:=left.fileinfo;
  1605. CGMessage(parser_e_wrong_parameter_size);
  1606. symtableprocentry.write_parameter_lists(nil);
  1607. end;
  1608. end;
  1609. goto errorexit;
  1610. end;
  1611. { Retrieve information about the candidates }
  1612. candidates_get_information(procs);
  1613. {$ifdef EXTDEBUG}
  1614. { Display info when multiple candidates are found }
  1615. if assigned(procs^.next) then
  1616. candidates_dump_info(V_Debug,procs);
  1617. {$endif EXTDEBUG}
  1618. { Choose the best candidate and count the number of
  1619. candidates left }
  1620. cand_cnt:=candidates_choose_best(procs,tprocdef(procdefinition));
  1621. { All parameters are checked, check if there are any
  1622. procedures left }
  1623. if cand_cnt>0 then
  1624. begin
  1625. { Multiple candidates left? }
  1626. if cand_cnt>1 then
  1627. begin
  1628. CGMessage(cg_e_cant_choose_overload_function);
  1629. {$ifdef EXTDEBUG}
  1630. candidates_dump_info(V_Hint,procs);
  1631. {$else}
  1632. candidates_list(procs,false);
  1633. {$endif EXTDEBUG}
  1634. { we'll just use the first candidate to make the
  1635. call }
  1636. end;
  1637. { assign procdefinition }
  1638. if symtableproc=nil then
  1639. symtableproc:=procdefinition.owner;
  1640. { update browser information }
  1641. if make_ref then
  1642. begin
  1643. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1644. inc(tprocdef(procdefinition).refcount);
  1645. if tprocdef(procdefinition).defref=nil then
  1646. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1647. end;
  1648. end
  1649. else
  1650. begin
  1651. { No candidates left, this must be a type error,
  1652. because wrong size is already checked. procdefinition
  1653. is filled with the first (random) definition that is
  1654. found. We use this definition to display a nice error
  1655. message that the wrong type is passed }
  1656. candidates_find_wrong_para(procs);
  1657. candidates_list(procs,true);
  1658. {$ifdef EXTDEBUG}
  1659. candidates_dump_info(V_Hint,procs);
  1660. {$endif EXTDEBUG}
  1661. { We can not proceed, release all procs and exit }
  1662. candidates_free(procs);
  1663. goto errorexit;
  1664. end;
  1665. candidates_free(procs);
  1666. end; { end of procedure to call determination }
  1667. { add needed default parameters }
  1668. if assigned(procdefinition) and
  1669. (paralength<procdefinition.maxparacount) then
  1670. begin
  1671. pdc:=tparaitem(procdefinition.Para.last);
  1672. for i:=1 to paralength do
  1673. pdc:=tparaitem(pdc.previous);
  1674. while assigned(pdc) do
  1675. begin
  1676. if not assigned(pdc.defaultvalue) then
  1677. internalerror(200212142);
  1678. left:=ccallparanode.create(genconstsymtree(tconstsym(pdc.defaultvalue)),left);
  1679. pdc:=tparaitem(pdc.previous);
  1680. end;
  1681. end;
  1682. end;
  1683. { handle predefined procedures }
  1684. is_const:=(po_internconst in procdefinition.procoptions) and
  1685. ((block_type in [bt_const,bt_type]) or
  1686. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1687. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1688. begin
  1689. if assigned(left) then
  1690. begin
  1691. { ptr and settextbuf needs two args }
  1692. if assigned(tcallparanode(left).right) then
  1693. begin
  1694. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1695. left:=nil;
  1696. end
  1697. else
  1698. begin
  1699. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1700. tcallparanode(left).left:=nil;
  1701. end;
  1702. end
  1703. else
  1704. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1705. result:=hpt;
  1706. goto errorexit;
  1707. end;
  1708. { ensure that the result type is set }
  1709. if not restypeset then
  1710. resulttype:=procdefinition.rettype
  1711. else
  1712. resulttype:=restype;
  1713. { modify the exit code, in case of special cases }
  1714. if (not is_void(resulttype.def)) then
  1715. begin
  1716. if paramanager.ret_in_reg(resulttype.def,procdefinition.proccalloption) then
  1717. begin
  1718. { wide- and ansistrings are returned in EAX }
  1719. { but they are imm. moved to a memory location }
  1720. if is_widestring(resulttype.def) or
  1721. is_ansistring(resulttype.def) then
  1722. begin
  1723. { we use ansistrings so no fast exit here }
  1724. if assigned(procinfo) then
  1725. procinfo.no_fast_exit:=true;
  1726. end;
  1727. end;
  1728. end;
  1729. { constructors return their current class type, not the type where the
  1730. constructor is declared, this can be different because of inheritance }
  1731. if (procdefinition.proctypeoption=potype_constructor) then
  1732. begin
  1733. if assigned(methodpointer) and
  1734. assigned(methodpointer.resulttype.def) and
  1735. (methodpointer.resulttype.def.deftype=classrefdef) then
  1736. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype;
  1737. end;
  1738. { flag all callparanodes that belong to the varargs }
  1739. if (po_varargs in procdefinition.procoptions) then
  1740. begin
  1741. pt:=tcallparanode(left);
  1742. i:=paralength;
  1743. while (i>procdefinition.maxparacount) do
  1744. begin
  1745. include(tcallparanode(pt).flags,nf_varargs_para);
  1746. pt:=tcallparanode(pt.right);
  1747. dec(i);
  1748. end;
  1749. end;
  1750. { insert type conversions }
  1751. if assigned(left) then
  1752. begin
  1753. aktcallprocdef:=procdefinition;
  1754. tcallparanode(left).insert_typeconv(tparaitem(procdefinition.Para.first),true);
  1755. end;
  1756. errorexit:
  1757. aktcallprocdef:=oldcallprocdef;
  1758. end;
  1759. function tcallnode.pass_1 : tnode;
  1760. var
  1761. inlinecode : tnode;
  1762. inlined : boolean;
  1763. {$ifdef m68k}
  1764. regi : tregister;
  1765. {$endif}
  1766. method_must_be_valid : boolean;
  1767. label
  1768. errorexit;
  1769. begin
  1770. { the default is nothing to return }
  1771. location.loc:=LOC_INVALID;
  1772. result:=nil;
  1773. inlined:=false;
  1774. inlinecode := nil;
  1775. { work trough all parameters to get the register requirements }
  1776. if assigned(left) then
  1777. tcallparanode(left).det_registers;
  1778. { return node }
  1779. if assigned(funcretrefnode) then
  1780. firstpass(funcretrefnode);
  1781. if assigned(procdefinition) and
  1782. (procdefinition.proccalloption=pocall_inline) then
  1783. begin
  1784. inlinecode:=right;
  1785. if assigned(inlinecode) then
  1786. inlined:=true;
  1787. right:=nil;
  1788. end;
  1789. { procedure variable ? }
  1790. if assigned(right) then
  1791. begin
  1792. firstpass(right);
  1793. { procedure does a call }
  1794. if not (block_type in [bt_const,bt_type]) then
  1795. procinfo.flags:=procinfo.flags or pi_do_call;
  1796. rg.incrementintregisterpushed(all_intregisters);
  1797. rg.incrementotherregisterpushed(all_registers);
  1798. end
  1799. else
  1800. { not a procedure variable }
  1801. begin
  1802. { calc the correture value for the register }
  1803. { handle predefined procedures }
  1804. if (procdefinition.proccalloption=pocall_inline) then
  1805. begin
  1806. if assigned(methodpointer) then
  1807. CGMessage(cg_e_unable_inline_object_methods);
  1808. if assigned(right) and (right.nodetype<>procinlinen) then
  1809. CGMessage(cg_e_unable_inline_procvar);
  1810. if not assigned(inlinecode) then
  1811. begin
  1812. if assigned(tprocdef(procdefinition).code) then
  1813. inlinecode:=cprocinlinenode.create(tprocdef(procdefinition))
  1814. else
  1815. CGMessage(cg_e_no_code_for_inline_stored);
  1816. if assigned(inlinecode) then
  1817. begin
  1818. { consider it has not inlined if called
  1819. again inside the args }
  1820. procdefinition.proccalloption:=pocall_fpccall;
  1821. firstpass(inlinecode);
  1822. inlined:=true;
  1823. end;
  1824. end;
  1825. end
  1826. else
  1827. begin
  1828. if not (block_type in [bt_const,bt_type]) then
  1829. procinfo.flags:=procinfo.flags or pi_do_call;
  1830. end;
  1831. { It doesn't hurt to calculate it already though :) (JM) }
  1832. rg.incrementintregisterpushed(tprocdef(procdefinition).usedintregisters);
  1833. rg.incrementotherregisterpushed(tprocdef(procdefinition).usedotherregisters);
  1834. end;
  1835. { get a register for the return value }
  1836. if (not is_void(resulttype.def)) then
  1837. begin
  1838. { for win32 records returned in EDX:EAX, we
  1839. move them to memory after ... }
  1840. if (resulttype.def.deftype=recorddef) then
  1841. begin
  1842. location.loc:=LOC_CREFERENCE;
  1843. end
  1844. else
  1845. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1846. begin
  1847. location.loc:=LOC_CREFERENCE;
  1848. end
  1849. else
  1850. { ansi/widestrings must be registered, so we can dispose them }
  1851. if is_ansistring(resulttype.def) or
  1852. is_widestring(resulttype.def) then
  1853. begin
  1854. location.loc:=LOC_CREFERENCE;
  1855. registers32:=1;
  1856. end
  1857. else
  1858. { we have only to handle the result if it is used }
  1859. if (nf_return_value_used in flags) then
  1860. begin
  1861. case resulttype.def.deftype of
  1862. enumdef,
  1863. orddef :
  1864. begin
  1865. if (procdefinition.proctypeoption=potype_constructor) then
  1866. begin
  1867. if assigned(methodpointer) and
  1868. (methodpointer.resulttype.def.deftype=classrefdef) then
  1869. begin
  1870. location.loc:=LOC_REGISTER;
  1871. registers32:=1;
  1872. end
  1873. else
  1874. location.loc:=LOC_FLAGS;
  1875. end
  1876. else
  1877. begin
  1878. location.loc:=LOC_REGISTER;
  1879. if is_64bitint(resulttype.def) then
  1880. registers32:=2
  1881. else
  1882. registers32:=1;
  1883. end;
  1884. end;
  1885. floatdef :
  1886. begin
  1887. location.loc:=LOC_FPUREGISTER;
  1888. {$ifdef cpufpemu}
  1889. if (cs_fp_emulation in aktmoduleswitches) then
  1890. registers32:=1
  1891. else
  1892. {$endif cpufpemu}
  1893. {$ifdef m68k}
  1894. if (tfloatdef(resulttype.def).typ=s32real) then
  1895. registers32:=1
  1896. else
  1897. {$endif m68k}
  1898. registersfpu:=1;
  1899. end;
  1900. else
  1901. begin
  1902. location.loc:=LOC_REGISTER;
  1903. registers32:=1;
  1904. end;
  1905. end;
  1906. end;
  1907. end;
  1908. {$ifdef m68k}
  1909. { we need one more address register for virtual calls on m68k }
  1910. if (po_virtualmethod in procdefinition.procoptions) then
  1911. inc(registers32);
  1912. {$endif m68k}
  1913. { a fpu can be used in any procedure !! }
  1914. {$ifdef i386}
  1915. registersfpu:=procdefinition.fpu_used;
  1916. {$endif i386}
  1917. { if this is a call to a method calc the registers }
  1918. if (methodpointer<>nil) then
  1919. begin
  1920. { if we are calling the constructor }
  1921. if procdefinition.proctypeoption in [potype_constructor] then
  1922. verifyabstractcalls;
  1923. case methodpointer.nodetype of
  1924. { but only, if this is not a supporting node }
  1925. typen: ;
  1926. { we need one register for new return value PM }
  1927. hnewn : if registers32=0 then
  1928. registers32:=1;
  1929. else
  1930. begin
  1931. if (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1932. assigned(symtableproc) and (symtableproc.symtabletype=withsymtable) and
  1933. not twithsymtable(symtableproc).direct_with then
  1934. begin
  1935. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1936. end; { Is accepted by Delphi !! }
  1937. { this is not a good reason to accept it in FPC if we produce
  1938. wrong code for it !!! (PM) }
  1939. { R.Assign is not a constructor !!! }
  1940. { but for R^.Assign, R must be valid !! }
  1941. if (procdefinition.proctypeoption=potype_constructor) or
  1942. ((methodpointer.nodetype=loadn) and
  1943. ((methodpointer.resulttype.def.deftype=classrefdef) or
  1944. ((methodpointer.resulttype.def.deftype=objectdef) and
  1945. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1946. )
  1947. )
  1948. ) then
  1949. method_must_be_valid:=false
  1950. else
  1951. method_must_be_valid:=true;
  1952. firstpass(methodpointer);
  1953. set_varstate(methodpointer,method_must_be_valid);
  1954. { The object is already used ven if it is called once }
  1955. if (methodpointer.nodetype=loadn) and
  1956. (tloadnode(methodpointer).symtableentry.typ=varsym) then
  1957. tvarsym(tloadnode(methodpointer).symtableentry).varstate:=vs_used;
  1958. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1959. registers32:=max(methodpointer.registers32,registers32);
  1960. {$ifdef SUPPORT_MMX }
  1961. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1962. {$endif SUPPORT_MMX}
  1963. end;
  1964. end;
  1965. end;
  1966. if inlined then
  1967. right:=inlinecode;
  1968. { determine the registers of the procedure variable }
  1969. { is this OK for inlined procs also ?? (PM) }
  1970. if assigned(right) then
  1971. begin
  1972. registersfpu:=max(right.registersfpu,registersfpu);
  1973. registers32:=max(right.registers32,registers32);
  1974. {$ifdef SUPPORT_MMX}
  1975. registersmmx:=max(right.registersmmx,registersmmx);
  1976. {$endif SUPPORT_MMX}
  1977. end;
  1978. { determine the registers of the procedure }
  1979. if assigned(left) then
  1980. begin
  1981. registersfpu:=max(left.registersfpu,registersfpu);
  1982. registers32:=max(left.registers32,registers32);
  1983. {$ifdef SUPPORT_MMX}
  1984. registersmmx:=max(left.registersmmx,registersmmx);
  1985. {$endif SUPPORT_MMX}
  1986. end;
  1987. errorexit:
  1988. if inlined then
  1989. procdefinition.proccalloption:=pocall_inline;
  1990. end;
  1991. {$ifdef state_tracking}
  1992. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  1993. var hp:Tcallparanode;
  1994. value:Tnode;
  1995. begin
  1996. track_state_pass:=false;
  1997. hp:=Tcallparanode(left);
  1998. while assigned(hp) do
  1999. begin
  2000. if left.track_state_pass(exec_known) then
  2001. begin
  2002. left.resulttype.def:=nil;
  2003. do_resulttypepass(left);
  2004. end;
  2005. value:=aktstate.find_fact(hp.left);
  2006. if value<>nil then
  2007. begin
  2008. track_state_pass:=true;
  2009. hp.left.destroy;
  2010. hp.left:=value.getcopy;
  2011. do_resulttypepass(hp.left);
  2012. end;
  2013. hp:=Tcallparanode(hp.right);
  2014. end;
  2015. end;
  2016. {$endif}
  2017. function tcallnode.docompare(p: tnode): boolean;
  2018. begin
  2019. docompare :=
  2020. inherited docompare(p) and
  2021. (symtableprocentry = tcallnode(p).symtableprocentry) and
  2022. (procdefinition = tcallnode(p).procdefinition) and
  2023. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  2024. ((restypeset and tcallnode(p).restypeset and
  2025. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  2026. (not restypeset and not tcallnode(p).restypeset));
  2027. end;
  2028. {****************************************************************************
  2029. TPROCINLINENODE
  2030. ****************************************************************************}
  2031. constructor tprocinlinenode.create(p:tprocdef);
  2032. begin
  2033. inherited create(procinlinen);
  2034. inlineprocdef:=p;
  2035. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2036. para_offset:=0;
  2037. para_size:=0;
  2038. { copy inlinetree }
  2039. if assigned(p.code) then
  2040. inlinetree:=p.code.getcopy
  2041. else
  2042. inlinetree:=nil;
  2043. end;
  2044. destructor tprocinlinenode.destroy;
  2045. begin
  2046. if assigned(inlinetree) then
  2047. inlinetree.free;
  2048. inherited destroy;
  2049. end;
  2050. constructor tprocinlinenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  2051. begin
  2052. inherited ppuload(t,ppufile);
  2053. inlineprocdef:=tprocdef(ppufile.getderef);
  2054. inlinetree:=ppuloadnode(ppufile);
  2055. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2056. para_offset:=0;
  2057. para_size:=0;
  2058. end;
  2059. procedure tprocinlinenode.ppuwrite(ppufile:tcompilerppufile);
  2060. begin
  2061. inherited ppuwrite(ppufile);
  2062. ppufile.putderef(inlineprocdef);
  2063. ppuwritenode(ppufile,inlinetree);
  2064. end;
  2065. procedure tprocinlinenode.derefimpl;
  2066. begin
  2067. inherited derefimpl;
  2068. if assigned(inlinetree) then
  2069. inlinetree.derefimpl;
  2070. resolvedef(pointer(inlineprocdef));
  2071. end;
  2072. function tprocinlinenode.getcopy : tnode;
  2073. var
  2074. n : tprocinlinenode;
  2075. begin
  2076. n:=tprocinlinenode(inherited getcopy);
  2077. n.inlineprocdef:=inlineprocdef;
  2078. if assigned(inlinetree) then
  2079. n.inlinetree:=inlinetree.getcopy
  2080. else
  2081. n.inlinetree:=nil;
  2082. n.retoffset:=retoffset;
  2083. n.para_offset:=para_offset;
  2084. n.para_size:=para_size;
  2085. getcopy:=n;
  2086. end;
  2087. procedure tprocinlinenode.insertintolist(l : tnodelist);
  2088. begin
  2089. end;
  2090. function tprocinlinenode.det_resulttype : tnode;
  2091. var
  2092. storesymtablelevel : longint;
  2093. storeparasymtable,
  2094. storelocalsymtable : tsymtabletype;
  2095. oldprocdef : tprocdef;
  2096. oldprocinfo : tprocinfo;
  2097. oldinlining_procedure : boolean;
  2098. begin
  2099. result:=nil;
  2100. oldinlining_procedure:=inlining_procedure;
  2101. oldprocdef:=aktprocdef;
  2102. oldprocinfo:=procinfo;
  2103. { we're inlining a procedure }
  2104. inlining_procedure:=true;
  2105. aktprocdef:=inlineprocdef;
  2106. { clone procinfo, but not the asmlists }
  2107. procinfo:=tprocinfo(cprocinfo.newinstance);
  2108. move(pointer(oldprocinfo)^,pointer(procinfo)^,cprocinfo.InstanceSize);
  2109. procinfo.aktentrycode:=nil;
  2110. procinfo.aktexitcode:=nil;
  2111. procinfo.aktproccode:=nil;
  2112. procinfo.aktlocaldata:=nil;
  2113. { set new procinfo }
  2114. procinfo.return_offset:=retoffset;
  2115. procinfo.para_offset:=para_offset;
  2116. procinfo.no_fast_exit:=false;
  2117. { set it to the same lexical level }
  2118. storesymtablelevel:=aktprocdef.localst.symtablelevel;
  2119. storelocalsymtable:=aktprocdef.localst.symtabletype;
  2120. storeparasymtable:=aktprocdef.parast.symtabletype;
  2121. aktprocdef.localst.symtablelevel:=oldprocdef.localst.symtablelevel;
  2122. aktprocdef.localst.symtabletype:=inlinelocalsymtable;
  2123. aktprocdef.parast.symtabletype:=inlineparasymtable;
  2124. { pass inlinetree }
  2125. resulttypepass(inlinetree);
  2126. resulttype:=inlineprocdef.rettype;
  2127. { retrieve info from inlineprocdef }
  2128. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  2129. para_offset:=0;
  2130. para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
  2131. if paramanager.ret_in_param(inlineprocdef.rettype.def,inlineprocdef.proccalloption) then
  2132. inc(para_size,POINTER_SIZE);
  2133. { restore procinfo }
  2134. procinfo.free;
  2135. procinfo:=oldprocinfo;
  2136. { restore symtable }
  2137. aktprocdef.localst.symtablelevel:=storesymtablelevel;
  2138. aktprocdef.localst.symtabletype:=storelocalsymtable;
  2139. aktprocdef.parast.symtabletype:=storeparasymtable;
  2140. { restore }
  2141. aktprocdef:=oldprocdef;
  2142. inlining_procedure:=oldinlining_procedure;
  2143. end;
  2144. function tprocinlinenode.pass_1 : tnode;
  2145. begin
  2146. firstpass(inlinetree);
  2147. registers32:=inlinetree.registers32;
  2148. registersfpu:=inlinetree.registersfpu;
  2149. {$ifdef SUPPORT_MMX}
  2150. registersmmx:=inlinetree.registersmmx;
  2151. {$endif SUPPORT_MMX}
  2152. result:=nil;
  2153. end;
  2154. function tprocinlinenode.docompare(p: tnode): boolean;
  2155. begin
  2156. docompare :=
  2157. inherited docompare(p) and
  2158. inlinetree.isequal(tprocinlinenode(p).inlinetree) and
  2159. (inlineprocdef = tprocinlinenode(p).inlineprocdef);
  2160. end;
  2161. begin
  2162. ccallnode:=tcallnode;
  2163. ccallparanode:=tcallparanode;
  2164. cprocinlinenode:=tprocinlinenode;
  2165. end.
  2166. {
  2167. $Log$
  2168. Revision 1.128 2003-02-19 22:00:14 daniel
  2169. * Code generator converted to new register notation
  2170. - Horribily outdated todo.txt removed
  2171. Revision 1.127 2003/01/16 22:13:52 peter
  2172. * convert_l3 convertlevel added. This level is used for conversions
  2173. where information can be lost like converting widestring->ansistring
  2174. or dword->byte
  2175. Revision 1.126 2003/01/15 01:44:32 peter
  2176. * merged methodpointer fixes from 1.0.x
  2177. Revision 1.125 2003/01/12 17:52:07 peter
  2178. * only check for auto inherited in objectsymtable
  2179. Revision 1.124 2003/01/09 21:45:46 peter
  2180. * extended information about overloaded candidates when compiled
  2181. with EXTDEBUG
  2182. Revision 1.123 2002/12/26 18:24:33 jonas
  2183. * fixed check for whether or not a high parameter was already generated
  2184. * no type checking/conversions for invisible parameters
  2185. Revision 1.122 2002/12/15 22:50:00 florian
  2186. + some stuff for the new hidden parameter handling added
  2187. Revision 1.121 2002/12/15 21:34:15 peter
  2188. * give sign difference between ordinals a small penalty. This is
  2189. needed to get word->[longword|longint] working
  2190. Revision 1.120 2002/12/15 21:30:12 florian
  2191. * tcallnode.paraitem introduced, all references to defcoll removed
  2192. Revision 1.119 2002/12/15 20:59:58 peter
  2193. * fix crash with default parameters
  2194. Revision 1.118 2002/12/15 11:26:02 peter
  2195. * ignore vs_hidden parameters when choosing overloaded proc
  2196. Revision 1.117 2002/12/11 22:42:28 peter
  2197. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2198. the old code. The new code collects the information about possible
  2199. candidates only once resultting in much less calls to type compare
  2200. routines
  2201. Revision 1.116 2002/12/07 14:27:07 carl
  2202. * 3% memory optimization
  2203. * changed some types
  2204. + added type checking with different size for call node and for
  2205. parameters
  2206. Revision 1.115 2002/12/06 17:51:10 peter
  2207. * merged cdecl and array fixes
  2208. Revision 1.114 2002/12/06 16:56:58 peter
  2209. * only compile cs_fp_emulation support when cpufpuemu is defined
  2210. * define cpufpuemu for m68k only
  2211. Revision 1.113 2002/11/27 20:04:38 peter
  2212. * cdecl array of const fixes
  2213. Revision 1.112 2002/11/27 15:33:46 peter
  2214. * the never ending story of tp procvar hacks
  2215. Revision 1.111 2002/11/27 02:31:17 peter
  2216. * fixed inlinetree parsing in det_resulttype
  2217. Revision 1.110 2002/11/25 18:43:32 carl
  2218. - removed the invalid if <> checking (Delphi is strange on this)
  2219. + implemented abstract warning on instance creation of class with
  2220. abstract methods.
  2221. * some error message cleanups
  2222. Revision 1.109 2002/11/25 17:43:17 peter
  2223. * splitted defbase in defutil,symutil,defcmp
  2224. * merged isconvertable and is_equal into compare_defs(_ext)
  2225. * made operator search faster by walking the list only once
  2226. Revision 1.108 2002/11/18 17:31:54 peter
  2227. * pass proccalloption to ret_in_xxx and push_xxx functions
  2228. Revision 1.107 2002/11/15 01:58:50 peter
  2229. * merged changes from 1.0.7 up to 04-11
  2230. - -V option for generating bug report tracing
  2231. - more tracing for option parsing
  2232. - errors for cdecl and high()
  2233. - win32 import stabs
  2234. - win32 records<=8 are returned in eax:edx (turned off by default)
  2235. - heaptrc update
  2236. - more info for temp management in .s file with EXTDEBUG
  2237. Revision 1.106 2002/10/14 18:20:30 carl
  2238. * var parameter checking for classes and interfaces in Delphi mode
  2239. Revision 1.105 2002/10/06 21:02:17 peter
  2240. * fixed limit checking for qword
  2241. Revision 1.104 2002/10/05 15:15:45 peter
  2242. * Write unknwon compiler proc using Comment and only in Extdebug
  2243. Revision 1.103 2002/10/05 12:43:25 carl
  2244. * fixes for Delphi 6 compilation
  2245. (warning : Some features do not work under Delphi)
  2246. Revision 1.102 2002/10/05 00:48:57 peter
  2247. * support inherited; support for overload as it is handled by
  2248. delphi. This is only for delphi mode as it is working is
  2249. undocumented and hard to predict what is done
  2250. Revision 1.101 2002/09/16 14:11:12 peter
  2251. * add argument to equal_paras() to support default values or not
  2252. Revision 1.100 2002/09/15 17:49:59 peter
  2253. * don't have strict var parameter checking for procedures in the
  2254. system unit
  2255. Revision 1.99 2002/09/09 19:30:34 peter
  2256. * don't allow convertable parameters for var and out parameters in
  2257. delphi and tp mode
  2258. Revision 1.98 2002/09/07 15:25:02 peter
  2259. * old logs removed and tabs fixed
  2260. Revision 1.97 2002/09/07 12:16:05 carl
  2261. * second part bug report 1996 fix, testrange in cordconstnode
  2262. only called if option is set (also make parsing a tiny faster)
  2263. Revision 1.96 2002/09/05 14:53:41 peter
  2264. * fixed old callnode.det_resulttype code
  2265. * old ncal code is default again
  2266. Revision 1.95 2002/09/03 21:32:49 daniel
  2267. * Small bugfix for procdef selection
  2268. Revision 1.94 2002/09/03 19:27:22 daniel
  2269. * Activated new ncal code
  2270. Revision 1.93 2002/09/03 16:26:26 daniel
  2271. * Make Tprocdef.defs protected
  2272. Revision 1.92 2002/09/01 13:28:37 daniel
  2273. - write_access fields removed in favor of a flag
  2274. Revision 1.91 2002/09/01 12:14:15 peter
  2275. * remove debug line
  2276. * containself methods can be called directly
  2277. Revision 1.90 2002/09/01 08:01:16 daniel
  2278. * Removed sets from Tcallnode.det_resulttype
  2279. + Added read/write notifications of variables. These will be usefull
  2280. for providing information for several optimizations. For example
  2281. the value of the loop variable of a for loop does matter is the
  2282. variable is read after the for loop, but if it's no longer used
  2283. or written, it doesn't matter and this can be used to optimize
  2284. the loop code generation.
  2285. Revision 1.89 2002/08/23 16:13:16 peter
  2286. * also firstpass funcretrefnode if available. This was breaking the
  2287. asnode compilerproc code
  2288. Revision 1.88 2002/08/20 10:31:26 daniel
  2289. * Tcallnode.det_resulttype rewritten
  2290. Revision 1.87 2002/08/19 19:36:42 peter
  2291. * More fixes for cross unit inlining, all tnodes are now implemented
  2292. * Moved pocall_internconst to po_internconst because it is not a
  2293. calling type at all and it conflicted when inlining of these small
  2294. functions was requested
  2295. Revision 1.86 2002/08/17 22:09:44 florian
  2296. * result type handling in tcgcal.pass_2 overhauled
  2297. * better tnode.dowrite
  2298. * some ppc stuff fixed
  2299. Revision 1.85 2002/08/17 09:23:34 florian
  2300. * first part of procinfo rewrite
  2301. Revision 1.84 2002/08/16 14:24:57 carl
  2302. * issameref() to test if two references are the same (then emit no opcodes)
  2303. + ret_in_reg to replace ret_in_acc
  2304. (fix some register allocation bugs at the same time)
  2305. + save_std_register now has an extra parameter which is the
  2306. usedinproc registers
  2307. Revision 1.83 2002/07/20 11:57:53 florian
  2308. * types.pas renamed to defbase.pas because D6 contains a types
  2309. unit so this would conflicts if D6 programms are compiled
  2310. + Willamette/SSE2 instructions to assembler added
  2311. Revision 1.82 2002/07/19 11:41:35 daniel
  2312. * State tracker work
  2313. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2314. allows the state tracker to change while nodes automatically into
  2315. repeat nodes.
  2316. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2317. 'not(a>b)' is optimized into 'a<=b'.
  2318. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2319. by removing the notn and later switchting the true and falselabels. The
  2320. same is done with 'repeat until not a'.
  2321. Revision 1.81 2002/07/15 18:03:14 florian
  2322. * readded removed changes
  2323. Revision 1.79 2002/07/11 14:41:27 florian
  2324. * start of the new generic parameter handling
  2325. Revision 1.80 2002/07/14 18:00:43 daniel
  2326. + Added the beginning of a state tracker. This will track the values of
  2327. variables through procedures and optimize things away.
  2328. Revision 1.78 2002/07/04 20:43:00 florian
  2329. * first x86-64 patches
  2330. }